scpdac.tl.extend_atlas#
- scpdac.tl.extend_atlas(query, atlas, species, *, layer='counts', max_epochs=10, batch_key='Sample_ID', freeze_dropout=True)#
Map a query dataset onto the reference atlas via scArches surgery.
The pretrained SCANVI model is adapted to the query with
load_query_data()(scArches architectural surgery), which tolerates batches not present in the reference registry. The query and reference are then embedded in a shared latent space and concatenated into an expanded reference object, retaining all user-supplied query metadata.- Parameters:
query (
AnnData) – Query data with raw counts inadata.layers[layer]andbatch_keyin obs. All of itsobscolumns are preserved in the returned object.atlas (
AnnData) – Reference atlas AnnData (raw counts in the samelayer).species (
str) –"human"or"mouse".layer (
str(default:'counts')) – Layer holding raw counts to bin.max_epochs (
int(default:10)) – Epochs to fine-tune the surgery (query) model.batch_key (
str(default:'Sample_ID')) – Column inadata.obsidentifying the batch covariate.freeze_dropout (
bool(default:True)) – Passed to scArches surgery; freezes dropout in transferred layers.
- Return type:
- Returns:
An expanded reference
AnnDatacontaining both atlas and query cells in a sharedobsm["X_scANVI_emb"]space, with a"source"column (“atlas”/”query”), a joint UMAP, and predicted labels for the query inobs["predicted_celltype"].- Raises:
ValueError – If
batch_keyis absent fromquery.obs.