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
Union[Literal['use_raw'],str,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 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 Seed forwarded to
generate_permutations_null()for the random background signature generation, by default 0.
- adata
- Return type:
- Returns:
pd.DataFrame indexed by signature name Columns
c_prime(1 - Geary’s C),pvals(empirical p-value from the matched random background), andfdr(BH-corrected).