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
adatais not passed.
- ha
Methods table
|
Run VISION analysis on the AnnData object. |
|
Alias for |
|
Integrate VISION signature scoring with Hotspot module assignments. |
|
Load gene signatures into |
|
Alias for |
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
VisionAnalysisso this accessor and the standalonevisionpackage 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 (
Noneusesadata.X,"use_raw"usesadata.raw.X, any other string is looked up inadata.layers).- signature_varm_key
str Key in
adata.varmfor the gene x signature weight matrix. Signatures must already be loaded, e.g. viaload_signatures()/signatures_from_file().- signature_names_uns_key
str|None Key in
adata.unsfor custom signature column names.- scores_only
bool When
True, only per-cell signature scores are computed (no KNN graph or graph autocorrelation) — equivalent to callingcompute_vision_signatures()directly. Use this when the dataset does not yet have a neighbor graph anywhere inadata.obsp.- with_differential_expression
bool When
True(andscores_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 andadata.obsp["weights"]already exists — e.g. becausesetup()already built a neighbor graph on this sameadata— that existing graph is reused as-is instead of being rebuilt (and instead of silently overwriting it, since both tools happen to use the sameobspkey).- **kwargs
When
scores_only=True, forwarded tocompute_signatures_anndata()(e.g.device,batch_size,sig_norm_method). Ignored whenscores_only=False— passsetup_kwargsinstead.
- adata
- Return type:
- 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()withscores_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 (
Noneusesadata.X,"use_raw"usesadata.raw.X, any other string is looked up inadata.layers).- signature_varm_key
str Key in
adata.varmfor the gene x signature weight matrix.- signature_names_uns_key
str|None Key in
adata.unsfor custom signature column names.- **kwargs
Forwarded through
analyze_vision()tocompute_signatures_anndata()(e.g.device,batch_size,sig_norm_method).
- adata
- Return type:
- 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().adatadefaults 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'], andadata.uns['signature_varm_key']— e.g. viacompute_signatures()) and that Hotspot modules have been created viacreate_modules()and scored viacalculate_module_scores()(orcalculate_super_module_scores()whenuse_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 byscviva.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 inadata.varmfor the gene x signature scoring matrix.uns['gene_modules'](oruns['gene_modules_sm']whenuse_super_modules=True): module -> gene-list mapping produced bycalculate_module_scores()/calculate_super_module_scores().obsm['module_scores'](orobsm['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:
- 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 withsplit_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.varmwhere the gene x signature matrix is stored.- use_raw
bool Whether to use
adata.rawfor gene matching.- **kwargs
Forwarded to
load_signatures()(e.g.gmt_files,dicts,min_signature_genes,sig_gene_threshold).
- adata
- Return type:
- 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).
- adata
- Return type: