gedi2py.tools.pathway_associations¶
- gedi2py.tools.pathway_associations(adata, *, sparse_output=False, key='gedi', key_added=None, copy=False)[source]¶
Compute pathway-gene associations from GEDI model.
Uses the pathway coefficient matrix A and gene loading matrix Z to compute associations between pathways and genes, accounting for the learned latent structure.
- Parameters:
adata (
AnnData) – Annotated data matrix with GEDI results.sparse_output (
bool, default:False) – IfTrue, return a sparse matrix. Useful for large pathway sets.key (
str, default:'gedi') – Key inadata.unswhere GEDI results are stored.key_added (
str|None, default:None) – Key to store results inadata.varm. Defaults to{key}_pathway_assoc.copy (
bool, default:False) – IfTrue, return the association matrix instead of storing inadata.
- Return type:
- Returns:
If ``copy=True``,returns pathway association matrix (n_genes,n_pathways).Otherwise,stores in ``adata.varm[key_added]``andreturns ``None`.`
Notes
Pathway associations require that a gene-level prior matrix C was provided during model training via
gd.tl.gedi(..., C=pathway_matrix).The association matrix represents how strongly each gene is associated with each pathway through the learned latent factors.
Examples
>>> import gedi2py as gd >>> # C is (n_genes, n_pathways) pathway membership matrix >>> gd.tl.gedi(adata, batch_key="sample", C=pathway_matrix) >>> gd.tl.pathway_associations(adata) >>> adata.varm["gedi_pathway_assoc"] # (n_genes, n_pathways)