scviva.tools.vision.compute_signature_scores#
- scviva.tools.vision.compute_signature_scores(adata, norm_data_key, signature_varm_key, sig_norm_method='znorm_columns', random_state=0)[source]#
Compute Geary’s C spatial/graph autocorrelation for all signatures.
Rank-transforms the per-cell scores in
adata.obsm["vision_signatures"]and computes Geary’s C against the cell-cell neighbor graph inadata.obsp["weights"]. A null distribution is built from randomly generated background signatures (generate_permutations_null()), matched on gene-set size and up/down balance via k-means clustering, and used to derive an empirical p-value per signature (compute_sig_pvals()).Mirrors R VISION’s signature autocorrelation step.
- Parameters:
adata (AnnData) – Annotated data object. Must contain
adata.obsm["vision_signatures"](seecompute_signatures_anndata()) andadata.obsp["weights"].norm_data_key ({"use_raw"} or str or None) – Expression key used for the original signature scoring; also used to score the random background signatures.
"use_raw"reads fromadata.raw.X.signature_varm_key (str) – Key in
adata.varmfor the (n_genes x n_sigs) signature weight matrix used to derive the random background signature sizes/balance.sig_norm_method (str, optional) – Normalisation method used to score the random background signatures. Must match the
sig_norm_methodused to compute the real scores inadata.obsm["vision_signatures"]– scoring the null background under a different normalisation than the real statistic invalidates the permutation test. Default"znorm_columns".random_state (int, optional) – Seed forwarded to
generate_permutations_null()for the random background signature generation, by default 0.
- Returns:
Columns
c_prime(1 - Geary’s C),pvals(empirical p-value from the matched random background), andfdr(BH-corrected).- Return type:
pd.DataFrame indexed by signature name