grassp.tl.calculate_cluster_enrichment

grassp.tl.calculate_cluster_enrichment#

calculate_cluster_enrichment(data, cluster_key='leiden', gene_name_key='Gene_name_canonical', gene_sets='custom_goterms_genes_reviewed.gmt', obs_key_added='Cell_compartment', enrichment_ranking_metric='P-value', return_enrichment_res=True, inplace=True)[source]#

Calculate cluster enrichment using gseapy.

Parameters:
data AnnData

Annotated data matrix with proteins as observations (rows)

cluster_key str (default: 'leiden')

Key in data.obs containing cluster assignments

gene_name_key str (default: 'Gene_name_canonical')

Key in data.obs containing gene names

gene_sets str (default: 'custom_goterms_genes_reviewed.gmt')

Gene set database to use for enrichment analysis

obs_key_added str (default: 'Cell_compartment')

Key under which to add enrichment annotations in data.obs

enrichment_ranking_metric Literal['P-value', 'Odds Ratio', 'Combined Score'] (default: 'P-value')

Metric to use for ranking enrichment results. One of: ‘P-value’, ‘Odds Ratio’, ‘Combined Score’

return_enrichment_res bool (default: True)

Whether to return the full enrichment results DataFrame

inplace bool (default: True)

Whether to modify data in place

Return type:

Union[AnnData, DataFrame, None]

Returns:

Optional[Union[AnnData, pd.DataFrame]] If inplace=True and return_enrichment_res=True, returns enrichment results DataFrame If inplace=True and return_enrichment_res=False, returns None If inplace=False and return_enrichment_res=True, returns tuple of (data, enrichment_results) If inplace=False and return_enrichment_res=False, returns data