rename: Renaming Contents of 'SummarizedExperiment' Objects

rename,SummarizedExperiment-methodR Documentation

Renaming Contents of SummarizedExperiment Objects

Description

[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 signature 'SummarizedExperiment'
rename(
  x,
  row_data = character(),
  col_data = character(),
  assays = character(),
  ...
)

## S4 method for signature '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)))

# Rename `LowDepthFlag` to `low_depth_flag` in `colData`.
x <- rename(x, col_data = c(low_depth_flag = "LowDepthFlag"))
tail(names(colData(x)))

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

insightsengineering/hermes documentation built on Sept. 19, 2024, 9:06 p.m.