View source: R/get_celltype_mapping.R
get_celltype_mapping | R Documentation |
For each cell, returns an estimate of its cell type based on cell type labels of neighbors in Selection graph. Requires at least 2 genes for the Selection graph. If cell type mapping for the Selection graph is not possible, returns NULL.
get_celltype_mapping(
sce,
genes.selection,
celltype.id = "celltype",
batch = NULL,
n.neigh = 5,
nPC.selection = NULL,
cosine = F,
return.stat = T,
which_genes_to_use = "all",
...
)
sce |
SingleCellExperiment object containing gene counts matrix (stored in 'logcounts' assay). |
genes.selection |
Character vector specifying genes (at least 2 genes) to be used for the construction of Selection kNN-graph. |
celltype.id |
Character specifying which field in colData(sce) should be used as celltype. Default celltype.id="celltype". |
batch |
Name of the field in colData(sce) to specify batch. Default batch=NULL if no batch is applied. |
n.neigh |
Positive integer > 1, specifying number of neighbors to use for kNN-graph. Default n.neigh=5. |
nPC.selection |
Positive integer (or NULL, if no PCA to be applied) specifying number of PCs to use for construction of True kNN-graph. Default nPC.selection=NULL. We advise to set it to 50 if |
cosine |
Boolean specifying if cosine normalization should be applied prior to constructing kNN-graph. Default cosine=FALSE. |
return.stat |
Boolean specifying if stat for the mapping (= diagonal values for the cell type confusion matrix) should be returned alongside the mapping. |
which_genes_to_use |
String specifying whether cell type mapping should be performed only on differentially expressed (between cell types) genes (= 'DE') or all selected genes (= 'all'). Default which_genes_to_use="all". |
... |
Additional arguments (e.g. the ones you can pass to get_DE_genes). |
List, containing field 'mapping' - data.frame with cell IDs (column 'cell'), originally assigned cell type labels (column 'celltype') and estimated cell type labels (column 'mapped_celltype'). If return.stat == TRUE, also returns field 'stat' - data.frame with cell type IDs (column 'celltype') and fraction of cells from this cell type that mapped correctly (column 'frac_correctly_mapped')
require(SingleCellExperiment)
n_row = 1000
n_col = 100
sce = SingleCellExperiment(assays = list(logcounts = matrix(rnorm(n_row*n_col), ncol=n_col)))
rownames(sce) = as.factor(1:n_row)
colnames(sce) = c(1:n_col)
sce$cell = colnames(sce)
sce$celltype = as.character(sample.int(5, n_col, replace = TRUE))
genes.selection = sample( rownames(sce) , 20)
out = get_celltype_mapping(sce, genes.selection = genes.selection)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.