Skip to contents

[Experimental]

This method renames columns of the rowData and colData, as well as assays, of SummarizedExperiment::SummarizedExperiment objects. This increases the flexibility since renaming can be done before conversion to a HermesData object.

Usage

# S4 method for class 'SummarizedExperiment'
rename(
  x,
  row_data = character(),
  col_data = character(),
  assays = character(),
  ...
)

# S4 method for class 'data.frame'
rename(x, ...)

Arguments

x

(SummarizedExperiment)
object to rename contents in.

row_data

(named character)
mapping from existing (right-hand side values) to new (left-hand side names) column names of rowData.

col_data

(named character)
mapping from existing (right-hand side values) to new (left-hand side names) column names of colData.

assays

(named character)
mapping from existing (right-hand side values) to new (left-hand side names) assay names.

...

additional arguments (not used here).

Value

The SummarizedExperiment::SummarizedExperiment object with renamed contents.

Examples

x <- summarized_experiment
# Use deliberately a non-standard assay name in this example.
assayNames(x) <- "count"

# Rename `HGNC` to `symbol` in the `rowData`.
x <- rename(x, row_data = c(symbol = "HGNC"))
head(names(rowData(x)))
#> [1] "symbol"       "HGNCGeneName" "GeneID"       "Chromosome"   "StartBP"     
#> [6] "EndBP"       

# Rename `LowDepthFlag` to `low_depth_flag` in `colData`.
x <- rename(x, col_data = c(low_depth_flag = "LowDepthFlag"))
tail(names(colData(x)))
#> [1] "ALIVDT"               "COHORT"               "TTYPE"               
#> [4] "STDSSDY"              "low_depth_flag"       "TechnicalFailureFlag"

# Rename assay `count` to `counts`.
x <- rename(x, assays = c(counts = "count"))
assayNames(x)
#> [1] "counts"