Classify | R Documentation |
This function performs a simple automatic cell type classification based on signatures or other scores stored in the metadata or features (features names should be unique accross assays, or in the format assay_feature). Useful for automating the simple first broad classification of cell types before a cell-type aware QC (for example, taking into account that immune cells have less detected genes/transcripts, and fibroblast less mitochondrial content, than epithelial/cancer cells). Also useful in general for classifying cells to their most likely identity, while not attempting to remove any multiplet or cell with no good identity match (for example to look for subcategories such as polarities within a previously identified celltype).
Classify(
object,
signatures,
expected.values = NA,
metadata.name = "celltype",
cell.names = NA,
assay = DefaultAssay(object),
layer = "data",
restrict.ident = "Default",
restrict.to = as.character(unique(Idents(object))),
by.clusters = NULL
)
object |
Seurat object. Must contain nFeature_RNA and percent.mito metadata columns, or the x and y plot parameters must be changed accordingly to plot other QC info otherwise. |
signatures |
character(n) or named list(n). Names of the signatures to use. Must correspond to names of metadata columns or features is the current default assay. If a named list of signatures is passed, the names of the list will be used and the content ignored. |
expected.values |
numeric(n). Expected values for the signatures, used for normalization of the signatures before classifying cells. If NA (Default), normalized to max. If 1, no normalization. If The vector/list is named and the names match the signature names, the names will be used to match each scale factor to the right signature. If no matching names are given, the expected values are assumed to be given in the same order as the signatures. |
metadata.name |
character(1). The name of the new metadata column where cell type annotations are stored (Default: celltype) |
cell.names |
character(n). Give only if the signature names should not be used as celltypes names, but rather be replaced by these cell names. |
assay |
character(1). If some signatures used for classification are stored as assay features, which assay should be used in priority (Default: DefaultAssay(object)). |
layer |
character(1). If some signatures used for classification are stored as assay features, which layer should be used (Default: "data"). |
restrict.ident |
character(1). The name of a metadata column containing celltype annotations, which will be used to define the subset of cells that should be classified. Default: "Default", which uses current default, i.e. Idents(object). |
restrict.to |
character(n). Which celltypes (as defined in the restrict.ident metadata column) should be classified. Default: All cells. |
by.clusters |
character(1) or character(n) or factor(n). If not NULL, clusters instead of single cells will be classified. The parameter should indicate the name of a metadata column containing the clusters to consider (e.g. "seurat_clusters"), or the actual cluster info (e.g. object$seurat_clusters). |
Each single cell will be associated to the cell type whose signature is maximal on the cell. A list of expected values for the signatures is optional (typically obtained by checking the typical signature score for cells of known identity beforehand). If given, expected values are used to normalize signature scores before classifying cells to the signature having maximal score. It is strongly recommended to use imputed data to score cell type signatures, to avoid misclassifications due to dropouts.
If the by.clusters parameter is set to some identities or metadata column containing identities, the classification will be done on clusters rather than single cells. This can help to overcome strong noise, or to take into account some prior knowledge such as dataset alignment in the classification.
A Seurat object with an additional metadata column containing the cell type annotations and Idents() set to these annotations.
# After MySeuratObject has been log-normalized in order to contain an RNA>data assay>layer and been augmented with a percent.mito metadata column:
# SignatureList should be a list of character vectors, each containing a series of feature/gene names. In this example, the signatures correspond to cell types, and the name of each signature is the name of the corresponding cell type (e.g. Tcell, Bcell, EpithelialCell, Fibroblasts, etc).
MySeuratObject <- Impute(MySeuratObject)
MySeuratObject <- ScoreSignatures(MySeuratObject,SignatureList)
MySeuratObject <- Classify(MySeuratObject,SignatureList) # Automatic annotation based on cell type signatures, stored in metadata column "celltype".
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.