Automated reference-based cell type annotation for single-cell RNA-seq using CellTypist, SingleR, Azimuth, scANVI, and scmap to transfer labels from a reference. Use when annotating cell types from a reference atlas or pretrained model, transferring labels onto a query, assessing prediction confidence and rejection, or triaging whether an unexpected cluster is a novel type versus a doublet, low-quality, or batch artifact.
Standardmäßig ist der Prompt ausgewählt, der zuerst die Quelle prüft. Sie können zu einem direkten Befehl wechseln oder eine lokale Kopie herunterladen.
Quelldateien prüfen
Lesen Sie SKILL.md und alle von SkillsMP angezeigten Begleitdateien, bevor Sie sich für eine Installation entscheiden.
Mit Codex oder Claude installieren Kopieren Sie diesen Prompt, fügen Sie ihn in Codex, Claude oder einen anderen Assistant ein und lassen Sie die Skill-Seite prüfen und installieren.
Ein direkter Befehl überspringt den Prüf-Prompt. Prüfen Sie die Quelle, bevor Sie ihn ausführen.
Automated reference-based cell type annotation for single-cell RNA-seq using CellTypist, SingleR, Azimuth, scANVI, and scmap to transfer labels from a reference. Use when annotating cell types from a reference atlas or pretrained model, transferring labels onto a query, assessing prediction confidence and rejection, or triaging whether an unexpected cluster is a novel type versus a doublet, low-quality, or batch artifact.
Before using code patterns, verify installed versions match. If versions differ:
Python: pip show <package> then help(module.function) to check signatures
R: packageVersion('<pkg>') then ?function_name to verify parameters
If code throws ImportError, AttributeError, or TypeError, introspect the installed
package and adapt the example to match the actual API rather than retrying.
Automated Reference-Based Cell Annotation
"Annotate my cells from a reference" -> Transfer labels from an annotated reference or pretrained model onto query cells, with a calibrated confidence/rejection step.
Python: celltypist.annotate() (pretrained LR) or scvi-tools scANVI label transfer
R: SingleR() (correlation to a reference) or RunAzimuth() (anchor-based mapping)
Governing principle
An annotation is a HYPOTHESIS, not a measurement. Reference-based annotators are closed-world: every query cell is forced toward the nearest label the reference contains, so a genuinely novel state gets the nearest wrong label - often with high apparent confidence. Reproducible is not the same as correct; an automated label inherits the reference's annotation errors, granularity, and tissue/donor/disease scope, and propagates them at scale wearing the authority of "automated."
Markers are context-dependent. A marker gene is a conditional statement: "marker X = type Y" means "in this tissue, platform, and processing, X enriches in Y relative to these other cells." A marker in blood may be expressed broadly in tumor; "canonical confirmation" using the same markers that defined the type is circular (recovering the prior, not new evidence). Treat reference labels and marker catalogs (PanglaoDB, CellMarker) as priors to be triangulated, never ground truth.
Before naming a new cell type, triage the four-way confusion in decreasing frequency: (1) doublets - two cell types summed, co-expressing mutually exclusive lineage markers; (2) low-quality/dying - high mito %, low gene count, ambient-dominated; (3) batch/technical - the cluster maps to one sample/lane/chemistry; (4) ambient-RNA contamination (SoupX/CellBender). Only after excluding all four is "novel cell type" admissible. The field is littered with "novel populations" that were doublets or stress artifacts.
This skill covers automated reference transfer. Manual marker discovery and hand-labeling live in single-cell/markers-annotation; the two are complementary - automate a first pass, confirm with markers, reserve expert curation for the final label and ambiguous populations.
Choosing an annotation method
Method
Model
Reference
World
Use when
Fails when
CellTypist
Logistic regression (pretrained)
Pretrained immune/cross-tissue models
Closed (+probability)
Immune/PBMC, fast first pass, no R needed
Input not log1p CP10K-normalized; query far from training distribution
SingleR
Spearman correlation to reference
celldex bulk or single-cell refs
Closed (+pruning)
Bulk reference available, R workflow, per-cell scoring
Strong platform/chemistry shift vs reference; forces nearest label
Azimuth
Supervised PCA + anchor mapping
Curated Seurat atlases (PBMC, lung...)
Closed (+mapping.score)
A curated Azimuth reference matches the tissue
No matching reference; locked to provided atlases
scANVI / scArches
Semi-supervised VAE
Annotated atlas + raw counts
Closed (+latent uncertainty)
Strong query batch vs reference; mapping onto a large atlas
Training cost/hyperparameters; raw counts required
scmap
Nearest reference centroid/cell
Single-cell reference
Open (explicit unassigned)
An explicit rejection category is needed
Coarser resolution; threshold tuning
LLM (GPTCelltype)
Prompted from top markers
None (uses marker list)
Open-ish
Fast hypothesis from a marker table
Hallucination, non-reproducible, never sees expression
No method escapes the closed-world limit except by an explicit reject/unassigned bin. When methods compete, verify current best practice and reference availability against installed docs before committing.
Normalization requirements (silent-failure risk)
Tool
Required input
Wrong input symptom
CellTypist
log1p-normalized to 10,000 counts/cell (CP10K)
Confident but degraded/wrong labels, no error
SingleR
log-normalized expression (logcounts)
Distorted correlations
scANVI/scArches
RAW counts in a layer
Model trains on the wrong likelihood
Azimuth
raw counts (SCTransform applied internally)
Mapping QC degrades
CellTypist (Python)
Goal: Transfer labels from a pretrained model with cluster-level smoothing and a probability for rejection.
Approach: Normalize the query to CP10K log1p (the model's expected input), run annotate with majority_voting to reassign each over-clustered subgroup to its dominant label, then keep a per-cell confidence for filtering.
Goal: Assign each cell by correlation to a reference and prune low-confidence calls.
Approach: Score each cell's Spearman correlation to reference profiles (per-label score is the 0.8 quantile), assign the max, fine-tune, then prune cells whose delta (assigned-label score minus median) falls >3 MADs below the delta distribution.
Use de.method='classic' for bulk references and de.method='wilcox' for single-cell references. Cells pruned to NA are the rejection set; inspect the delta distribution rather than trusting a hard score cutoff.
Azimuth (R/Seurat)
Goal: Map a query onto a curated reference atlas and transfer hierarchical labels with a mapping score.
Approach: Project query cells onto the supervised reference embedding via anchors, transfer l1/l2/l3 labels, and gate by mapping.score and prediction.score.
A hard universal probability cutoff is not principled across models - inspect the score distribution and calibrate per dataset.
Triage an unexpected cluster (before claiming novelty)
Goal: Decide whether a poorly-mapped cluster is a novel type or an artifact.
Approach: A whole cluster scoring low (vs scattered low-confidence cells) suggests "not in reference"; rule out doublets, low-quality, batch, and ambient before annotating de novo.
High mito or low gene count flags low-quality; doublet rate or co-expressed exclusive lineages flags doublets; near-1 batch purity flags a technical artifact. Only a low-confidence, QC-clean, batch-mixed cluster with coherent de-novo markers is a novel-type candidate.
Validate predictions with markers
Goal: Confirm transferred labels against canonical markers (triangulation, not proof).
Approach: Dot-plot lineage markers grouped by predicted label and check the expected on/off pattern; disagreement between automated calls and markers flags cells to re-examine.
canonical <-c('CD3D','CD8A','MS4A1','CD14','FCGR3A','NKG7','FCER1A')
DotPlot(seurat_obj, features = canonical, group.by ='SingleR')+ Seurat::RotatedAxis()
Common Errors
Symptom
Cause
Fix
Confident labels that contradict canonical markers
Closed-world: novel/absent state forced to nearest label
Add a reject bin; annotate de novo; do not trust labels outside the reference's domain
CellTypist labels degrade silently
Query not CP10K log1p normalized
Normalize to target_sum=1e4 then log1p before annotate
CellTypist returns confident but nonsensical labels
Gene-ID space mismatch (query var_names are Ensembl IDs vs symbol-based model); few genes matched
Set var_names to gene symbols; check the matched-gene fraction reported by annotate before trusting labels
Reference labels look wrong everywhere
Platform/chemistry shift vs reference (domain shift)
Use a batch-modeling mapper (scANVI/scArches) or a matched reference
"Novel cell type" turns out artifactual
Doublet / low-quality / batch / ambient not excluded
Run the four-way triage before claiming novelty
Fine labels (CD4 Tcm vs Tem) unstable
Granularity finer than data or reference supports
Annotate hierarchically; report coarse labels confidently, fine as hypotheses
Two tools disagree on the same cells
Different references/granularity
Report consensus + flag disagreements as ambiguous; curate manually
Related Skills
markers-annotation - Manual marker discovery and hand-labeling that complements automated transfer
clustering - Cluster cells before annotating
preprocessing - Normalize correctly for each annotator's expected input
batch-integration - Reference mapping vs de-novo integration; closed-world caveats
differential-abundance - Test whether annotated cell-type proportions changed between conditions
pathway-analysis/go-enrichment - Functionally characterize a de-novo / novel population
References
Aran et al. 2019, Nat Immunol 20:163-172 - SingleR correlation-based reference annotation with delta-based pruning.