Skip to contents

Converts a named list of CellType -> cluster IDs into a new metadata column on a Seurat object. Clusters absent from assignments receive NA.

Usage

AssignCellTypes(
  object,
  assignments,
  cluster_col = "Cluster",
  new_col = "CellType",
  other = NULL
)

Arguments

object

A Seurat object.

assignments

Named list. Names are cell-type labels; each element is a character vector of cluster IDs belonging to that type. E.g.: list(Excitatory_Neurons = c("C02","C03"), Astrocytes = "C05").

cluster_col

Metadata column containing cluster IDs. Default "Cluster".

new_col

Name of the new metadata column to create. Default "CellType".

other

Character or NULL. Label assigned to any cluster not present in assignments. NULL (default) leaves them as NA.

Value

The Seurat object with new_col added to meta.data.

Examples

if (FALSE) { # \dontrun{
Assign <- list(
  Excitatory_Neurons = c("C02","C03","C07"),
  Inhibitory_Neurons = c("C06","C08"),
  Astrocytes         = "C05"
)
# Unassigned clusters labeled "Tumor"
SeuratObj <- AssignCellTypes(SeuratObj, Assign,
                             cluster_col = "Cluster",
                             new_col     = "GlobalAssignment",
                             other       = "Tumor")
} # }