RenameClusters: Rename clusters for the Seurat object

View source: R/SCP-workflow.R

RenameClustersR Documentation

Rename clusters for the Seurat object

Description

Rename clusters for the Seurat object

Usage

RenameClusters(
  srt,
  group.by,
  nameslist = list(),
  name = "newclusters",
  keep_levels = FALSE
)

Arguments

srt

A Seurat object.

group.by

The old group used to rename cells.

nameslist

A named list of new cluster value.

name

The name of the new cluster stored in the Seurat object.

keep_levels

If the old group is a factor, keep the order of the levels.

Examples

data("pancreas_sub")
levels(pancreas_sub@meta.data[["SubCellType"]])

# Rename all clusters
pancreas_sub <- RenameClusters(pancreas_sub, group.by = "SubCellType", nameslist = letters[1:8])
CellDimPlot(pancreas_sub, "newclusters")

# Rename specified clusters
pancreas_sub <- RenameClusters(pancreas_sub,
  group.by = "SubCellType",
  nameslist = list("a" = "Alpha", "b" = "Beta")
)
CellDimPlot(pancreas_sub, "newclusters")

# Merge and rename clusters
pancreas_sub <- RenameClusters(pancreas_sub,
  group.by = "SubCellType",
  nameslist = list("EndocrineClusters" = c("Alpha", "Beta", "Epsilon", "Delta")),
  name = "Merged", keep_levels = TRUE
)
CellDimPlot(pancreas_sub, "Merged")


zh542370159/SCP documentation built on Nov. 22, 2023, 2:34 a.m.