scviva.tools.harreman.HarremanToolsAccessor#

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

Tool methods accessible as ha.tl.<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

compute_interaction_module_correlation([...])

Compute correlations between interacting cell scores and module scores.

compute_knn_graph([adata, ...])

Computes the spatial proximity graph.

select_significant_interactions([adata, ...])

Select significant gene pairs or metabolite-mediated interactions.

Methods

HarremanToolsAccessor.compute_interaction_module_correlation(adata=None, *, cor_method='pearson', test=None, interaction_type='metabolite', only_sig_values=False, normalize_values=False, use_FDR=True, use_super_modules=False, ct_aware=None)[source]#

Compute correlations between interacting cell scores and module scores.

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

Parameters:
adata AnnData | None

Must contain: - uns['interacting_cell_results'] with parametric or non-parametric scores - obsm['module_scores'] or obsm['super_module_scores'] - uns['metabolites'] or uns['gene_pairs_sig_names']

cor_method Union[Literal['pearson'], Literal['spearman'], None]

Statistical method used to compute correlations.

test Union[Literal['parametric'], Literal['non-parametric'], None]

Which interacting-cell score set to use. - "parametric" uses uns['interacting_cell_results']['p'] - "non-parametric" uses uns['interacting_cell_results']['np']

interaction_type Union[Literal['metabolite'], Literal['gene_pair'], None]

Select whether to correlate: - metabolite scores, or - gene pair scores.

only_sig_values bool | None

If True, use only significant interacting cell score values (cs_sig_pval or cs_sig_FDR).

normalize_values bool | None

Apply min-max normalization to interacting cell score values per interaction.

use_FDR bool | None

If only_sig_values=True, determines whether to filter by FDR or raw p-values.

use_super_modules bool | None

Whether to use super-module scores instead of module scores.

ct_aware bool | None

Whether to use cell-type-aware interacting cell scores. If None, cell-type-aware scores are used only when standard scores are absent and matching cell-type-aware scores are present.

Return type:

None

HarremanToolsAccessor.compute_knn_graph(adata=None, *, compute_neighbors_on_key=None, distances_obsp_key=None, weighted_graph=False, neighborhood_radius=None, n_neighbors=None, neighborhood_factor=3, sample_key=None, tree=None, use_gpu=None, verbose=False, random_state=0)[source]#

Computes the spatial proximity graph.

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

Parameters:
adata AnnData | None

AnnData object.

compute_neighbors_on_key str | None

Key in adata.obsm to use for computing neighbors. If None, use neighbors stored in adata. If no neighbors have been previously computed an error will be raised.

distances_obsp_key str | None

Distances encoding cell-cell similarities directly. Shape is (cells x cells). Input is key in adata.obsp.

weighted_graph bool | None

Whether or not to create a weighted graph.

neighborhood_radius int | None

Neighborhood radius.

n_neighbors int | None

Neighborhood size.

neighborhood_factor int | None

Used when creating a weighted graph. Sets how quickly weights decay relative to distances within the neighborhood. The weight for a cell with distance d decays as exp(-d^2/D), where D is the distance to the n_neighbors/neighborhood_factor-th neighbor.

sample_key str | None

Sample information in case the data contains different samples or samples from different conditions. Input is key in adata.obs.

tree

Root tree node. Can be created using ete3.Tree

use_gpu bool | None

Whether to use GPU acceleration via rapids_singlecell/cuML. None (default) tries GPU and falls back to CPU automatically; False forces CPU; True raises if GPU fails.

verbose bool | None

Whether to print progress and status messages.

random_state int | Generator | None

Seed (or generator) for the random tie-breaking in the tree-based KNN path (used only when tree is given), for reproducible neighbor selection. Defaults to 0.

HarremanToolsAccessor.select_significant_interactions(adata=None, *, ct_aware=False, test='parametric', use_FDR=True, threshold=0.05)[source]#

Select significant gene pairs or metabolite-mediated interactions.

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

Selection is based on FDR/p-value thresholds and optional cell-type-aware tests.

Parameters:
adata AnnData | None

AnnData object containing:

  • uns['ccc_results'] or uns['ct_ccc_results'], each of which includes:

    • cell_com_df_gp: DataFrame with statistics for gene pairs

    • cell_com_df_m: DataFrame with statistics for metabolites

ct_aware bool | None

If True, use cell-type–aware CCC results (uns['ct_ccc_results']). If False, use cell-type-agnostic CCC results (uns['ccc_results']).

test Union[Literal['parametric'], Literal['non-parametric'], None]

Determines which statistical columns to use: - Parametric: Z_FDR / Z_pval, C_p - Non-parametric: FDR_np / pval_np, C_np

use_FDR bool | None

If True, threshold significance using FDR values. If False, use raw p-values.

threshold float | None

Significance cutoff applied to the selected statistic (FDR or p-value).

Return type:

None