Users can set rownames of an SCE object with either a character vector where the length equals to nrow(x), or a single character specifying a column in rowData(x). Also applicable to matrix like object where rownames<- method works, but only allows full size name vector. Users can set dedup = TRUE to remove duplicated entries in the specification, by adding -1, -2, ..., -i suffix to the duplication of the same identifier.

setRowNames(x, rowNames, dedup = TRUE)

Arguments

x

Input object where the rownames will be modified.

rowNames

Character vector of the rownames. If x is an SingleCellExperiment object, a single character specifying a column in rowData(x).

dedup

Logical. Whether to deduplicate the specified rowNames. Default TRUE

Value

The input SCE object with rownames updated.

Examples

data("scExample", package = "singleCellTK")
head(rownames(sce))
#> [1] "ENSG00000251562" "ENSG00000205542" "ENSG00000177954" "ENSG00000166710"
#> [5] "ENSG00000156508" "ENSG00000147403"
sce <- setRowNames(sce, "feature_name")
head(rownames(sce))
#> [1] "MALAT1" "TMSB4X" "RPS27"  "B2M"    "EEF1A1" "RPL10"