
Automated cell-type annotation with rcellmarker, scType, and SingleR
CellTypeAssignmentHelper.RdRuns up to three automated cell-type annotation methods on a Seurat object, adds their results as new metadata columns, and produces two summary PDFs:
An
AutoAssignment umaps.pdfwith scType, rcellmarker, and cluster UMAPs side-by-side.An
AutoAssignment umaps with singleR.pdf+Assignment Helper.pdfcombining all annotations and canonical-marker dotplots.
Usage
CellTypeAssignmentHelper(
seurat_object,
markers,
cluster_column = "Cluster",
output_dir = NULL,
object_name = "",
subset_name = "",
reduction = "umap",
cluster_colors = NULL,
species = "human",
run_rcellmarker = TRUE,
run_sctype = TRUE,
sctype_tissues = c("Immune system", "Brain"),
sctype_assay = "RNA",
sctype_layer = "scale.data",
sctype_db = NULL,
run_singler = TRUE,
singler_ref = NULL,
singler_col = "SingleRAssignment",
markers_csv = NULL,
marker_groups = NULL,
top_n_per_cluster = 3L,
extra_dimplot_cols = NULL,
extra_col_colors = NULL,
col.min = 0,
col.max = 2,
scale.min = 0,
scale.max = 100,
caffeinate = FALSE
)Arguments
- seurat_object
A Seurat object.
- markers
Data frame of DE results from
presto::wilcoxauc(). Required for rcellmarker annotation and for the top-marker dotplot. Expected columns:feature,group,avgExpr,avg_log2FC(orlogFC),auc,pval,padj,pct_in,pct_out.- cluster_column
Character. Metadata column holding cluster labels. Default
"Cluster".- output_dir
Character. Directory for PDFs.
- object_name
Character. Prefix for PDF filenames.
- subset_name
Character. Second prefix component.
- reduction
Character. UMAP reduction name. Default
"umap".- cluster_colors
Named character vector of colors for
cluster_columnlevels.NULLauto-generates fromNour_pal().- species
Character.
"human"(default) or"mouse". Controls: (1) which gene column is read from the markers CSV (HumanvsMouse), (2) the rcellmarkerspeciesargument, and (3) which CellChatDB is loaded in downstream CellChat workflows.- run_rcellmarker
Logical. Run rcellmarker automated annotation? Requires the
rcellmarkerpackage. DefaultTRUE.- run_sctype
Logical. Run scType automated annotation? Requires
openxlsx. DefaultTRUE.- sctype_tissues
Character vector of tissue type(s) to query from the bundled
ScTypeDB_full.xlsx. Combine multiple types for broader coverage. All valid values (from the bundled database):"Adrenal"- adrenal gland"Brain"- cerebral cortex, broad neuronal/glial types"Eye"- retinal and eye-specific cell types"Heart"- cardiac cell types"Hippocampus"- hippocampal-specific subtypes (use with"Brain"for combined brain data)"Immune system"- broad immune cells: T, B, NK, myeloid, etc."Intestine"- intestinal epithelial and stromal types"Kidney"- renal cell types"Liver"- hepatocytes, Kupffer cells, stellate cells"Lung"- airway epithelium, alveolar cells, immune"Muscle"- skeletal and smooth muscle"Pancreas"- islet and exocrine types"Placenta"- trophoblast and decidual types"Spleen"- splenic immune populations"Stomach"- gastric epithelial types"Thymus"- thymocyte and thymic stromal types
Recommended combinations:
c("Brain", "Hippocampus")for brain snRNAseq;c("Immune system", "Spleen")for immune-rich tissues;c("Immune system", "Brain")for neuroinflammation datasets.- sctype_assay
Character. Seurat assay to use for scoring. Must contain a
scale.data(scaled) layer. Common choices:"RNA"- standard full assay (default); usesctype_layer = "scale.data""sketch"- BPCells sketch assay for large datasets; usesctype_layer = "scale.data"afterScaleData()on the sketch
- sctype_layer
Character. Layer within
sctype_assaythat holds scaled expression values. Default"scale.data". Must be a scaled (mean-centered) matrix - scType scores are not meaningful on raw counts.- sctype_db
Character or
NULL. Path to aScTypeDB_full.xlsxdatabase file.NULL(default) uses the copy bundled ininst/extdata/ScTypeDB_full.xlsx; if that is missing it is downloaded once from the scType GitHub and cached attools::R_user_dir("scSidekick", "cache").- run_singler
Logical. Run SingleR cluster-level annotation? Requires
SingleR,scuttle,celldex,SingleCellExperiment. DefaultTRUE.- singler_ref
A reference
SummarizedExperimentforSingleR::SingleR(), orNULLto usecelldex::BlueprintEncodeData()(default). Choose based on tissue type and species:- Human references:
celldex::BlueprintEncodeData()Blueprint/ENCODE bulk RNA-seq. Broad cell types; good general-purpose starting point. Default.
celldex::HumanPrimaryCellAtlasData()Human Primary Cell Atlas. Very broad coverage across many tissues; best for highly heterogeneous datasets with diverse cell populations.
celldex::MonacoImmuneData()Monaco et al. Finest immune subtype resolution (29 populations). Best for PBMCs, spleen, or any immune-focused study.
celldex::DatabaseImmuneCellExpressionData()DICE database. Good alternative immune reference with activated/resting states.
celldex::NovershternHematopoieticData()Hematopoietic lineages. Best for bone marrow or stem-cell datasets.
- Mouse references:
celldex::ImmGenData()ImmGen consortium. The most comprehensive mouse immune cell reference (over 250 subtypes).
celldex::MouseRNAseqData()Broad mouse tissue types from bulk RNA-seq. Good for non-immune mouse tissues.
All celldex references are downloaded once and cached by
BiocFileCache; subsequent calls are instant.- singler_col
Character. Name for the new metadata column storing numbered SingleR labels (e.g.
"01.CD8+ T cells"). Default"SingleRAssignment".- markers_csv
Character or
NULL. Path to a canonical-marker CSV.NULLuses the CSV bundled with scSidekick (inst/extdata/Markers.csv). Required columns:Type,Cell types, plusHumanand/orMousegene symbol columns. The bundled CSV covers brain and immune markers (seemarker_groupsfor the full list ofTypevalues).- marker_groups
Named list controlling how many dotplots are produced and which
Typevalues from the markers CSV appear in each. OneSplitDotPlot()is generated per list entry.NULLproduces a single dotplot with all markers combined.Typevalues in the bundledMarkers.csv:"Brain Stroma"- Astrocytes, Oligodendrocytes, OPC, Microglia, Endothelial, Pericytes, Neurons (excitatory, inhibitory, dopaminergic, glutamatergic, serotonergic), VLMC, and stem/progenitor types"Lymphocytes"- T cells (naive, cytotoxic, Th1/2/17, Treg, exhausted, MAIT, GDT), B cells, NK cells"Monocytes"- CD14/CD16 monocytes, MDSCs"Macrophages"- tissue macrophages"Dendritic cells"- cDC1, cDC2, pDCs, LAMP3+ DCs"Granulocytes"- neutrophils, basophils, mast cells"Bone Marrow Derived"- BMD immune cells"All"- proliferating cells (Prol)"Tumor"- generic tumor marker
Example for brain snRNAseq with separate immune panel:
- top_n_per_cluster
Integer. Number of top DE genes per cluster shown in the cluster-faceted dotplot (uses the
markersdata frame). Default3.- extra_dimplot_cols
Character vector of additional metadata columns to include as panels in the multi-UMAP summary figure (e.g.
"Subclass"for SEAAD reference labels or"Donor.ID"for QC). Colors are auto-generated fromNour_pal()unless supplied viaextra_col_colors.- extra_col_colors
Named list of color vectors for
extra_dimplot_cols. Names must matchextra_dimplot_cols. Example:list(Subclass = subclass_colors).- col.min
Numeric. Minimum scaled expression value for dotplot color scale. Default
0.- col.max
Numeric. Maximum scaled expression value for dotplot color scale. Default
2.- scale.min
Numeric. Minimum percentage of expressing cells for the dotplot size scale. Default
0.- scale.max
Numeric. Maximum percentage of expressing cells for the dotplot size scale. Default
100.- caffeinate
Logical. If
TRUE, prevent macOS system sleep for the duration of the function call usingcaffeinate. DefaultFALSE.
Value
The modified Seurat object (returned invisibly), with:
- New metadata columns
scType_CellType,rcellmarker_CellType, and/or the column named bysingler_col, depending on which methods ran.seurat_object@misc$annotation_colorsNamed list of color vectors for each annotation column:
rcellmarker,sctype,singler, plus anyextra_dimplot_colscolors. Retrieve withseurat_object@misc$annotation_colors$sctypeetc.