Annotate a query single-cell dataset by projecting it onto a pre-trained reference atlas and transferring cell-type labels, using scArches surgery (scVI/scANVI), Symphony, Azimuth, CellTypist, scPoli, popV, or fine-tuned foundation models. The central discipline this skill enforces is that mapping is a projection, not an annotation oracle: every transferred label must be gated on an out-of-distribution / label-transfer-uncertainty signal, which is a different quantity from the classifier probability.
pip install scvi-tools scanpy anndata scikit-learn celltypist
Conceptual prerequisites: the query must be QC'd (doublets removed, ambient corrected, MT/count filters) to the reference's standard before mapping, and its genes must align to the reference feature set.
Tell your AI agent what you want to do: - "Map my single-cell data to the Human Lung Cell Atlas and flag cells that do not belong" - "Transfer cell-type labels from my reference to my query and gate them on uncertainty" - "Pick the right mapping method for a clinical, reproducible annotation pipeline" - "My query likely has disease states the reference lacks; how do I avoid confident wrong labels?"
"I need a deterministic, CPU-only, reproducible annotation pipeline for a clinical setting. Which mapping method should I use and why?"
"Should I use scGPT zero-shot embeddings to annotate my query, or scANVI surgery?"
"Map my query to the reference scANVI model with scArches surgery, then set low-confidence cells to Unknown using weighted-kNN transfer uncertainty, not the softmax."
"Which cells in my query are out-of-distribution relative to the reference? They may be novel cell types or disease states."
"My query is a differentiation trajectory. Will scANVI collapse it onto discrete reference labels, and should I use unsupervised scVI surgery instead?"
"I have a high scIB integration score. Does that mean my transferred labels are correct?"
prepare_query_anndataweight_decay=0.0predict(soft=True) answers "which label," not "does it belong" -- gate on weighted-kNN uncertainty (HLCA threshold 0.2) or a Mahalanobis/ensemble OOD signalweight_decay=0.0 and frozen weights are not optional: they keep the shared latent fixed so queries mapped to the same atlas stay comparableprepare_query_anndata is mandatory; skipping it silently corrupts the encoder input rather than raising an errorscvi.data.cellxgene())