scviva.tools.vision.compute_signatures_anndata#
- scviva.tools.vision.compute_signatures_anndata(adata, norm_data_key, signature_varm_key, signature_names_uns_key=None, sig_norm_method='znorm_columns', device='auto', batch_size=1200)[source]#
Compute per-cell signature scores.
For sparse expression matrices the computation is performed entirely without densifying the n_cells x n_genes matrix. A
NormDataobject is built from the expression data and_batch_sig_eval_norm()is called, selecting CUDA -> MPS -> scipy automatically.For dense inputs the existing VISION z-score formula is retained.
- Parameters:
- adata
AnnData AnnData object.
- norm_data_key
Union[Literal['use_raw'],str,None] Key in
adata.layersfor the expression matrix, or"use_raw"to read fromadata.raw.X. PassNoneto useadata.X.- signature_varm_key
str Key in
adata.varmfor the (n_genes x n_sigs) signature weight matrix (+1 up-regulated, -1 down-regulated, 0 absent).- signature_names_uns_key
str|None Key in
adata.unsfor column names. WhenNone(or when the stored names don’t match the number of signatures), column names are read from the DataFrame index (if applicable) or auto-generated.- sig_norm_method
str Normalisation method passed to
get_normalized_copy_sparse()for the sparse path. Matches R VISION’ssig_norm_methodparameter; default"znorm_columns"(z-normalise each cell across genes).- device
str Compute device for
_batch_sig_eval_norm();"auto"by default."cpu"forces the deterministic scipy sparse path (see_resolve_torch_device()).- batch_size
int Signatures processed per batch, by default 1200.
- adata
- Return type:
- Returns:
pd.DataFrame of shape (n_cells, n_sigs) Per-cell signature scores. Also stored via
adata.obsm["vision_signatures"];adata.uns["norm_data_key"]andadata.uns["signature_varm_key"]record the keys used.