peach.tl.pathway_associations#
- peach.tl.pathway_associations(adata, *, pathway_obsm_key='pathway_scores', obsm_key='archetype_distances', obs_key='archetypes', test_method='mannwhitneyu', fdr_method='benjamini_hochberg', fdr_scope='global', test_direction='two-sided', min_logfc=0.01, min_cells=10, comparison_group='all', verbose=True, **kwargs)[source]#
Test pathway activity associations with archetypal assignments.
Performs Mann-Whitney U tests to identify pathways with significantly different activity between each archetype and all other cells.
- Parameters:
adata (AnnData) β
Annotated data object with:
obsm[pathway_obsm_key]: Pathway scores [n_cells, n_pathways]obsm[obsm_key]: Archetype distance matrixobs[obs_key]: Archetype assignmentsuns[pathway_obsm_key + '_pathways']: Pathway names (optional)
pathway_obsm_key (str, default: "pathway_scores") β Key in adata.obsm containing pathway activity scores.
obsm_key (str, default: "archetype_distances") β Key in adata.obsm containing archetype distance matrix.
obs_key (str, default: "archetypes") β Column in adata.obs containing archetypal assignments.
test_method (str, default: "mannwhitneyu") β Statistical test method.
fdr_method (str, default: "benjamini_hochberg") β FDR correction method.
fdr_scope ({'global', 'per_archetype', 'none'}, default: 'global') β Scope of FDR correction.
test_direction (str, default: "two-sided") β Direction of statistical test.
min_logfc (float, default: 0.01) β Minimum effect size threshold (mean_diff for pathways).
min_cells (int, default: 10) β Minimum cells required per archetype.
comparison_group (str, default: 'all') β Comparison group: βallβ or βarchetypes_onlyβ.
verbose (bool, default: True) β Whether to print progress.
- Returns:
Results with columns:
pathway: str - Pathway namearchetype: str - Archetype identifiern_archetype_cells: int - Cells in archetypen_other_cells: int - Cells in comparisonmean_archetype: float - Mean score in archetypemean_other: float - Mean score in othersmean_diff: float - Mean difference (primary effect size)log_fold_change: float - Alias for mean_diffstatistic: float - Test statisticpvalue: float - Raw p-valuefdr_pvalue: float - FDR-corrected p-valuesignificant: bool - Whether significantdirection: str - βhigherβ or βlowerβ
- Return type:
pd.DataFrame
Notes
Pathway scores (from AUCell, pySCENIC, etc.) represent activity levels, not expression counts. Mean difference is more interpretable than log fold change for these scores.
Examples
>>> # Basic usage >>> results = pc.tl.pathway_associations(adata) >>> # Filter for specific pathway categories >>> metabolism = results[results["pathway"].str.contains("METABOLISM", case=False)] >>> # Top pathways per archetype >>> for arch in results["archetype"].unique(): ... top = results[(results["archetype"] == arch) & (results["significant"])].nlargest(5, "mean_diff") ... print(f"{arch}: {top['pathway'].tolist()}")
See also
peach.tl.gene_associationsGene-level testing
peach._core.types.PathwayAssociationResultResult row structure