scpdac.tl.embed_and_predict

scpdac.tl.embed_and_predict#

scpdac.tl.embed_and_predict(adata, species, *, layer='counts', batch_key='Sample_ID')#

Embed a query dataset with a packaged SCANVI model and predict cell types.

This is the lightweight, no-surgery path: it assumes the query batches are compatible with the reference model registry. Use extend_atlas() when the query introduces new batches.

Parameters:
  • adata (AnnData) – Query data. Must contain raw counts in adata.layers[layer] and a batch_key column in adata.obs.

  • species (str) – "human" or "mouse" — selects the packaged model and gene panel.

  • layer (str (default: 'counts')) – Layer holding raw counts to bin before inference.

  • batch_key (str (default: 'Sample_ID')) – Column in adata.obs identifying the batch covariate.

Return type:

AnnData

Returns:

The input adata with the latent embedding in adata.obsm["X_scANVI_emb"] and predicted labels in adata.obs["predicted_celltype"].

Raises:

ValueError – If batch_key is absent from adata.obs.