scviva.tools.harreman.HarremanVisionAccessor#

class scviva.tools.harreman.HarremanVisionAccessor(ha)[source]#

VISION signature analysis methods accessible as ha.vs.<method>.

Created automatically by HarremanAnalysis; users do not instantiate it directly.

Parameters:
ha HarremanAnalysis

The analysis object whose AnnData is used when adata is not passed.

Methods table

analyze_vision([adata, norm_data_key, ...])

Run VISION analysis on the AnnData object.

compute_vision_signatures([adata, ...])

Alias for analyze_vision() with scores_only=True.

integrate_vision_hotspot_results([adata, ...])

Integrate VISION signature scoring with Hotspot module assignments.

load_signatures([adata, split_signed, ...])

Load gene signatures into adata.varm.

signatures_from_file([adata])

Alias for load_signatures().

Methods

HarremanVisionAccessor.analyze_vision(adata=None, norm_data_key=None, signature_varm_key='signatures', signature_names_uns_key=None, scores_only=False, with_differential_expression=False, setup_kwargs=None, **kwargs)[source]#

Run VISION analysis on the AnnData object.

Delegates to VisionAnalysis so this accessor and the standalone vision package share one implementation of the neighbor-weight graph, signature scoring, and autocorrelation logic.

Parameters:
adata AnnData | None

AnnData object to analyse. Defaults to ha._adata.

norm_data_key str | None

Expression layer to use (None uses adata.X, "use_raw" uses adata.raw.X, any other string is looked up in adata.layers).

signature_varm_key str

Key in adata.varm for the gene x signature weight matrix. Signatures must already be loaded, e.g. via load_signatures()/signatures_from_file().

signature_names_uns_key str | None

Key in adata.uns for custom signature column names.

scores_only bool

When True, only per-cell signature scores are computed (no KNN graph or graph autocorrelation) — equivalent to calling compute_vision_signatures() directly. Use this when the dataset does not yet have a neighbor graph anywhere in adata.obsp.

with_differential_expression bool

When True (and scores_only=False), also runs one-vs-all differential expression of signatures/metadata across clusters, per-signature gene importance, and the signature dendrogram (compute_differential_expression()). This is the most expensive step; leave it off if you only need signature scores and their autocorrelation.

setup_kwargs dict | None

Forwarded to setup() (e.g. compute_neighbors_on_key, num_neighbors, exact_knn, tree, lca_knn, lca_min_size). If omitted and adata.obsp["weights"] already exists — e.g. because setup() already built a neighbor graph on this same adata — that existing graph is reused as-is instead of being rebuilt (and instead of silently overwriting it, since both tools happen to use the same obsp key).

**kwargs

When scores_only=True, forwarded to compute_signatures_anndata() (e.g. device, batch_size, sig_norm_method). Ignored when scores_only=False — pass setup_kwargs instead.

Return type:

None

HarremanVisionAccessor.compute_vision_signatures(adata=None, norm_data_key=None, signature_varm_key='signatures', signature_names_uns_key=None, **kwargs)[source]#

Alias for analyze_vision() with scores_only=True.

Computes per-cell signature scores only (no KNN graph or autocorrelation).

Parameters:
adata AnnData | None

AnnData to use. Defaults to the AnnData held by the analysis object.

norm_data_key str | None

Expression layer to use (None uses adata.X, "use_raw" uses adata.raw.X, any other string is looked up in adata.layers).

signature_varm_key str

Key in adata.varm for the gene x signature weight matrix.

signature_names_uns_key str | None

Key in adata.uns for custom signature column names.

**kwargs

Forwarded through analyze_vision() to compute_signatures_anndata() (e.g. device, batch_size, sig_norm_method).

Return type:

None

HarremanVisionAccessor.integrate_vision_hotspot_results(adata=None, *, cor_method='pearson', use_super_modules=False)[source]#

Integrate VISION signature scoring with Hotspot module assignments.

Forwards to integrate_vision_hotspot_results(). adata defaults to the AnnData held by the analysis object.

Requires that VISION signature scoring has already been run (producing adata.obsm['vision_signatures'], adata.uns['norm_data_key'], and adata.uns['signature_varm_key'] — e.g. via compute_signatures()) and that Hotspot modules have been created via create_modules() and scored via calculate_module_scores() (or calculate_super_module_scores() when use_super_modules=True).

For each (signature, module) pair the function computes:

  • A hypergeometric enrichment test of signature gene overlap with module genes (log2 fold-enrichment, raw p-value, BH-FDR).

  • Pearson or Spearman correlation between per-cell signature scores and per-cell module activity scores.

An overlap signature matrix (genes present in significant signature-module intersections) is also computed and stored for downstream use.

Parameters:
adata AnnData | None

Annotated data object. Must contain:

  • obsm['vision_signatures']: per-cell signature scores produced by scviva.tools.vision.tools.signature.compute_signatures_anndata().

  • uns['norm_data_key']: expression layer key used for signature scoring (None, "use_raw", or a layer name).

  • uns['signature_varm_key']: key in adata.varm for the gene x signature scoring matrix.

  • uns['gene_modules'] (or uns['gene_modules_sm'] when use_super_modules=True): module -> gene-list mapping produced by calculate_module_scores() / calculate_super_module_scores().

  • obsm['module_scores'] (or obsm['super_module_scores']): per-cell module activity scores.

cor_method Literal[‘pearson’, ‘spearman’]

Correlation method used to relate signature scores to module scores.

use_super_modules bool

If True, use super-module gene lists and scores (gene_modules_sm / super_module_scores) instead of the standard module equivalents.

Return type:

None

Returns:

None Results are stored in-place on adata:

  • uns['sig_mod_enrichment_stats']: log2 fold-enrichment (signatures x modules).

  • uns['sig_mod_enrichment_pvals']: raw hypergeometric p-values (signatures x modules).

  • uns['sig_mod_enrichment_FDR']: BH-corrected FDR values (signatures x modules).

  • uns['sig_mod_correlation_coefs']: correlation coefficients (modules x signatures).

  • uns['sig_mod_correlation_pvals']: raw correlation p-values (modules x signatures).

  • uns['sig_mod_correlation_FDR']: BH-corrected FDR values (modules x signatures).

  • uns['cor_method']: the correlation method used.

  • varm['signatures_overlap']: binary gene x overlap-signature matrix for signature-module intersections with p < 0.05.

  • obsm['signature_modules_overlap']: per-cell scores for each significant signature-module overlap.

HarremanVisionAccessor.load_signatures(adata=None, split_signed=True, varm_key='signatures', use_raw=False, **kwargs)[source]#

Load gene signatures into adata.varm.

Forwards to load_signatures(), then optionally splits signed signatures with split_signed_signatures().

Parameters:
adata AnnData | None

AnnData to use. Defaults to the AnnData held by the analysis object.

split_signed bool

Whether to split signed signatures into up/down parts after loading.

varm_key str

Key in adata.varm where the gene x signature matrix is stored.

use_raw bool

Whether to use adata.raw for gene matching.

**kwargs

Forwarded to load_signatures() (e.g. gmt_files, dicts, min_signature_genes, sig_gene_threshold).

Return type:

None

HarremanVisionAccessor.signatures_from_file(adata=None, **kwargs)[source]#

Alias for load_signatures().

Parameters:
adata AnnData | None

AnnData to use. Defaults to the AnnData held by the analysis object.

**kwargs

Forwarded to load_signatures() of this accessor (e.g. split_signed, varm_key, use_raw, gmt_files).

Return type:

None