Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

RenameCells

Rename cells


Description

Change the cell names in all the different parts of an object. Can be useful before combining multiple objects.

Usage

RenameCells(object, ...)

## S3 method for class 'Assay'
RenameCells(object, new.names = NULL, ...)

## S3 method for class 'DimReduc'
RenameCells(object, new.names = NULL, ...)

## S3 method for class 'Neighbor'
RenameCells(object, old.names = NULL, new.names = NULL, ...)

## S3 method for class 'Seurat'
RenameCells(
  object,
  add.cell.id = NULL,
  new.names = NULL,
  for.merge = FALSE,
  ...
)

Arguments

object

An object

...

Arguments passed to other methods

new.names

vector of new cell names

old.names

vector of old cell names

add.cell.id

prefix to add cell names

for.merge

Only rename slots needed for merging Seurat objects. Currently only renames the raw.data and meta.data slots.

Details

If add.cell.id is set a prefix is added to existing cell names. If new.names is set these will be used to replace existing names.

Value

An object with new cell names

Examples

# Rename cells in an Assay
head(x = colnames(x = pbmc_small[["RNA"]]))
renamed.assay <- RenameCells(
    pbmc_small[["RNA"]],
    new.names = paste0("A_", colnames(x = pbmc_small[["RNA"]]))
)
head(x = colnames(x = renamed.assay))

# Rename cells in a DimReduc
head(x = Cells(x = pbmc_small[["pca"]]))
renamed.dimreduc <- RenameCells(
    object = pbmc_small[["pca"]],
    new.names = paste0("A_", Cells(x = pbmc_small[["pca"]]))
)
head(x = Cells(x = renamed.dimreduc))

# Rename cells in a Seurat object
head(x = colnames(x = pbmc_small))
pbmc_small <- RenameCells(object = pbmc_small, add.cell.id = "A")
head(x = colnames(x = pbmc_small))

SeuratObject

Data Structures for Single Cell Data

v4.0.1
GPL-3
Authors
Rahul Satija [aut] (<https://orcid.org/0000-0001-9448-8833>), Andrew Butler [aut] (<https://orcid.org/0000-0003-3608-0463>), Paul Hoffman [aut, cre] (<https://orcid.org/0000-0002-7693-8957>), Tim Stuart [aut] (<https://orcid.org/0000-0002-3044-0897>), Jeff Farrell [ctb], Shiwei Zheng [ctb] (<https://orcid.org/0000-0001-6682-6743>), Christoph Hafemeister [ctb] (<https://orcid.org/0000-0001-6365-8254>), Patrick Roelli [ctb], Yuhan Hao [ctb] (<https://orcid.org/0000-0002-1810-0822>)
Initial release
2021-05-07

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.