Annotate single cells using SingleR
Usage
RunSingleR(
srt_query,
srt_ref,
query_group = NULL,
ref_group = NULL,
query_assay = "RNA",
ref_assay = "RNA",
genes = "de",
de.method = "wilcox",
sd.thresh = 1,
de.n = NULL,
aggr.ref = FALSE,
aggr.args = list(),
quantile = 0.8,
fine.tune = TRUE,
tune.thresh = 0.05,
prune = TRUE,
cores = 1,
verbose = TRUE
)Arguments
- srt_query
An object of class Seurat to be annotated with cell types.
- srt_ref
An object of class Seurat storing the reference cells.
- query_group
Column name in the
srt_querymetadata that represents the cell grouping.- ref_group
Column name in the
srt_refmetadata that represents the cell grouping.- query_assay
Assay to be used for the query data. Default is the default assay of the
srt_queryobject.- ref_assay
Assay to be used for the reference data. Default is the default assay of the
srt_refobject.- genes
Marker selection strategy:
"de"to detect markers from the reference, or a list of marker genes accepted by SingleR::trainSingleR.- de.method
Differential expression method used to select markers:
"wilcox","t", or"classic". Ignored whengenessupplies markers.- sd.thresh
Numeric threshold forwarded to SingleR::SingleR for compatibility with older versions; ignored by current SingleR versions.
- de.n
Number of marker genes selected per pair of labels.
NULLuses the default for the selectedde.methodin SingleR::trainSingleR.- aggr.ref
Logical indicating whether to aggregate reference cells into pseudo-bulk samples before classification.
- aggr.args
Named list of arguments passed to SingleR::aggregateReference when
aggr.ref = TRUE.- quantile
"quantile" parameter in SingleR::SingleR function.
- fine.tune
"fine.tune"parameter in SingleR::SingleR function.- tune.thresh
"tune.thresh"parameter in SingleR::SingleR function.- prune
"prune"parameter in SingleR::SingleR function.- cores
The number of worker processes to use for parallelization. Default is
1.- verbose
Whether to print the message. Default is
TRUE.
Value
An annotate Seurat object.
The annotation results are stored in the singler_annotation column of the meta data,
and the corresponding scores are stored in the singler_score column.
Examples
data(panc8_sub)
keep <- panc8_sub$celltype %in% c("ductal", "alpha", "beta")
panc8_sub <- Seurat::NormalizeData(panc8_sub[, keep], verbose = FALSE)
reference <- panc8_sub[, panc8_sub$tech != "fluidigmc1"]
query <- panc8_sub[, panc8_sub$tech == "fluidigmc1"]
query <- RunSingleR(
srt_query = query, srt_ref = reference,
ref_group = "celltype", genes = "de", cores = 1, verbose = FALSE
)
#> ℹ [2026-11-12 06:04:25] Data type is log-normalized
#> ℹ [2026-11-12 06:04:25] Detected `srt_query` data type: "log_normalized_counts"
#> ℹ [2026-11-12 06:04:25] Data type is log-normalized
#> ℹ [2026-11-12 06:04:25] Detected `srt_ref` data type: "log_normalized_counts"
query <- RunStandardWorkflow(query, verbose = FALSE, linear_reduction_dims = 10)
#> ℹ [2026-11-12 06:04:26] Skip `log1p()` because `layer = data` is not "counts"
CellDimPlot(
query,
group.by = "singler_annotation",
label = TRUE, legend.position = "bottom"
)
FeatureStatPlot(
query,
stat.by = "singler_score",
group.by = "singler_annotation"
)