Skip to content

obs_prerank_enrich() Enrichment: Gene List with Rank Scores for Observations

Step 1: Prepare rank_df

Begin by preparing a list of genes along with their preranked scores (e.g., gene expression). Store this information in a DataFrame called rank_df.

  • The index of rank_df should be the gene symbols.
  • The columns of rank_df should correspond to one observation ID (e.g., sample or cell identifier).

This format allows obs_prerank_enrich() to perform enrichment analysis using observation-level ranked gene-level statistics.

%load_ext autoreload

import pandas as pd
rank_df = pd.read_csv("grea/db/GSE13268_expr.csv", index_col=0)
rank_df.head()
The autoreload extension is already loaded. To reload it, use:
  %reload_ext autoreload

GSM334850 GSM334851 GSM334852 GSM334853 GSM334854 GSM334855 GSM334856 GSM334857 GSM334858 GSM334859 ... GSM334941 GSM334942 GSM334943 GSM334944 GSM334945 GSM334946 GSM334947 GSM334948 GSM334949 GSM334950
symbol
A1bg 3.571760 1.11627 11.55050 11.04560 2.742960 9.69463 7.40349 0.709628 7.526350 15.62100 ... 7.59029 0.450372 0.911598 8.24978 0.567557 6.796200 6.382740 2.34760 0.68466 11.23300
A1cf 48.075200 23.09380 47.03710 36.40960 28.652900 26.35890 33.77320 33.610200 27.605900 15.56650 ... 25.29960 20.527300 17.157700 31.47500 14.894300 22.987000 26.335800 24.31280 15.56490 29.42810
A2ml1 0.953989 2.70178 6.83848 2.23235 0.845507 1.59083 4.44694 2.506430 0.690331 1.04533 ... 4.27877 7.875130 1.937090 3.39644 6.506060 0.845852 0.871744 3.71262 5.47173 1.30705
A3galt2 55.093700 53.86570 66.91050 55.12170 61.720200 56.92840 53.99490 54.910100 60.342300 37.47140 ... 85.77660 74.817700 53.456900 79.28140 53.265400 71.644300 76.083200 80.58420 64.71110 79.28970
A4galt 18.853800 11.25860 4.73029 20.51850 11.892200 8.38279 17.57540 7.552850 13.629200 14.04210 ... 2.98861 2.015280 11.015100 3.56110 14.187100 3.654270 11.556800 14.73220 2.16436 11.30980

5 rows Ă— 101 columns

Step 2: Preparing Gene Set Libraries

There are several ways to prepare gene set libraries for use in GREA:

Option 1: Use Built-in Libraries

Simply specify the libraries you're interested in as a list. For example:

libraries = ['KEGG_2019_Mouse', 'WikiPathways_2024_Mouse']

You can use the grea.library.list_libraries() function to view all available pathway libraries included in GREA.

Option 2: Load from GMT File

You can load external gene set libraries from .gmt files using:

libraries = read_gmt('your_library_file.gmt')
Option 3: Define a Custom Library

Create your own gene set library using a Python dictionary, where each key is a pathway name and the corresponding value is a list of genes:

libraries = {
    'term1': ['A2ml1', 'A1cf'],
    'term2': ['A3galt2', 'A4galt']
}
%autoreload
from grea.library import list_libraries

print(list_libraries())
['GeneSigDB', 'Enrichr_Submissions_TF-Gene_Coocurrence', 'SysMyo_Muscle_Gene_Sets', 'WikiPathway_2021_Human', 'HomoloGene', 'WikiPathways_2013', 'PFOCR_Pathways_2023', 'OMIM_Disease', 'Data_Acquisition_Method_Most_Popular_Genes', 'NIBR_Jensen_DISEASES_Curated_2025', 'Cancer_Cell_Line_Encyclopedia', 'WikiPathways_2016', 'WikiPathways_2015', 'RNAseq_Automatic_GEO_Signatures_Human_Up', 'Human_Gene_Atlas', 'KOMP2_Mouse_Phenotypes_2022', 'MoTrPAC_2023', 'Kinase_Perturbations_from_GEO_down', 'Disease_Signatures_from_GEO_down_2014', 'Disease_Perturbations_from_GEO_up', 'Old_CMAP_down', 'MCF7_Perturbations_from_GEO_up', 'NIH_Funded_PIs_2017_GeneRIF_ARCHS4_Predictions', 'DepMap_WG_CRISPR_Screens_Sanger_CellLines_2019', 'PPI_Hub_Proteins', 'Disease_Signatures_from_GEO_up_2014', 'GTEx_Tissue_Expression_Up', 'NIBR_DRUGseq_2025_down', 'L1000_Kinase_and_GPCR_Perturbations_up', 'ARCHS4_Cell-lines', 'VirusMINT', 'KEGG_2019_Human', 'ARCHS4_Tissues', 'MGI_Mammalian_Phenotype_Level_4', 'The_Kinase_Library_2024', 'The_Kinase_Library_2023', 'MGI_Mammalian_Phenotype_Level_3', 'InterPro_Domains_2019', 'WikiPathways_2024_Mouse', 'DRUGseq_2025_up', 'KEGG_2015', 'MSigDB_Computational', 'KEGG_2013', 'TF-LOF_Expression_from_GEO', 'GWAS_Catalog_2019', 'KEGG_2016', 'NCI-Nature_2015', 'NCI-Nature_2016', 'CCLE_Proteomics_2020', 'PheWeb_2019', 'GeDiPNet_2023', 'RNA-Seq_Disease_Gene_and_Drug_Signatures_from_GEO', 'LINCS_L1000_Chem_Pert_down', 'Old_CMAP_up', 'LINCS_L1000_Ligand_Perturbations_down', 'Enrichr_Users_Contributed_Lists_2020', 'NIH_Funded_PIs_2017_Human_GeneRIF', 'Jensen_TISSUES', 'Azimuth_Cell_Types_2021', 'DisGeNET', 'Panther_2016', 'LINCS_L1000_Ligand_Perturbations_up', 'Rare_Diseases_AutoRIF_Gene_Lists', 'Achilles_fitness_increase', 'TargetScan_microRNA', 'Panther_2015', 'WikiPathways_2019_Mouse', 'ARCHS4_TFs_Coexp', 'LINCS_L1000_Chem_Pert_up', 'MSigDB_Oncogenic_Signatures', 'Gene_Perturbations_from_GEO_down', 'Table_Mining_of_CRISPR_Studies', 'Rare_Diseases_GeneRIF_Gene_Lists', 'Ligand_Perturbations_from_GEO_down', 'SILAC_Phosphoproteomics', 'Ligand_Perturbations_from_GEO_up', 'Drug_Perturbations_from_GEO_up', 'SynGO_2022', 'MGI_Mammalian_Phenotype_Level_4_2024', 'SynGO_2024', 'Allen_Brain_Atlas_10x_scRNA_2021', 'MGI_Mammalian_Phenotype_Level_4_2021', 'ClinVar_2019', 'GWAS_Catalog_2023', 'MAGMA_Drugs_and_Diseases', 'KEA_2015', 'KEA_2013', 'Microbe_Perturbations_from_GEO_up', 'Chromosome_Location', 'COVID-19_Related_Gene_Sets_2021', 'MGI_Mammalian_Phenotype_Level_4_2019', 'DRUGseqr_2025_down', 'ARCHS4_IDG_Coexp', 'NIH_Funded_PIs_2017_AutoRIF_ARCHS4_Predictions', 'Jensen_DISEASES_Experimental_2025', 'lncHUB_lncRNA_Co-Expression', 'PerturbAtlas', 'DrugMatrix', 'Virus_Perturbations_from_GEO_down', 'huMAP', 'L1000_Kinase_and_GPCR_Perturbations_down', 'Elsevier_Pathway_Collection', 'NIH_Funded_PIs_2017_Human_AutoRIF', 'Diabetes_Perturbations_GEO_2022', 'ESCAPE', 'RNAseq_Automatic_GEO_Signatures_Mouse_Down', 'UK_Biobank_GWAS_v1', 'Aging_Perturbations_from_GEO_up', 'Human_Phenotype_Ontology', 'Jensen_DISEASES_Curated_2025', 'Proteomics_Drug_Atlas_2023', 'dbGaP', 'SubCell_BarCode', 'Transcription_Factor_PPIs', 'GO_Cellular_Component_2017b', 'HuBMAP_ASCTplusB_augmented_2022', 'MSigDB_Hallmark_2020', 'GlyGen_Glycosylated_Proteins_2022', 'MAGNET_2023', 'CellMarker_2024', 'BioPlanet_2019', 'HDSigDB_Human_2021', 'GTEx_Tissues_V8_2023', 'GTEx_Tissue_Expression_Down', 'Metabolomics_Workbench_Metabolites_2022', 'Tissue_Protein_Expression_from_Human_Proteome_Map', 'Epigenomics_Roadmap_HM_ChIP-seq', 'PhenGenI_Association_2021', 'MCF7_Perturbations_from_GEO_down', 'ProteomicsDB_2020', 'Virus-Host_PPI_P-HIPSTer_2020', 'OMIM_Expanded', 'Reactome_2022', 'Genes_Associated_with_NIH_Grants', 'CellMarker_Augmented_2021', 'ENCODE_and_ChEA_Consensus_TFs_from_ChIP-X', 'HDSigDB_Mouse_2021', 'Jensen_COMPARTMENTS', 'ChEA_2015', 'ChEA_2016', 'KEGG_2019_Mouse', 'ChEA_2022', 'LINCS_L1000_Chem_Pert_Consensus_Sigs', 'Drug_Perturbations_from_GEO_2014', 'TargetScan_microRNA_2017', 'KEGG_2021_Mouse', 'Allen_Brain_Atlas_down', 'WikiPathways_2019_Human', 'Reactome_2013', 'BioCarta_2013', 'Rummagene_transcription_factors', 'Gene_Perturbations_from_GEO_up', 'GO_Cellular_Component_2015', 'Rummagene-signatures', 'GO_Cellular_Component_2013', 'BioCarta_2016', 'NIBR_Jensen_DISEASES_Experimental_2025', 'BioCarta_2015', 'Reactome_2015', 'Reactome_2016', 'GO_Cellular_Component_2018', 'GO_Cellular_Component_2017', 'GO_Cellular_Component_2023', 'GO_Cellular_Component_2021', 'WikiPathway_2021_Mouse', 'ENCODE_TF_ChIP-seq_2015', 'ENCODE_TF_ChIP-seq_2014', 'RNAseq_Automatic_GEO_Signatures_Mouse_Up', 'GO_Molecular_Function_2017b', 'DRUGseq_2025_down', 'FANTOM6_lncRNA_KD_DEGs', 'MGI_Mammalian_Phenotype_2013', 'GO_Cellular_Component_2025', 'HMS_LINCS_KinomeScan', 'NCI-60_Cancer_Cell_Lines', 'Azimuth_2023', 'MGI_Mammalian_Phenotype_2017', 'Rare_Diseases_GeneRIF_ARCHS4_Predictions', 'Virus_Perturbations_from_GEO_up', 'PFOCR_Pathways', 'IDG_Drug_Targets_2022', 'Enrichr_Libraries_Most_Popular_Genes', 'Orphanet_Augmented_2021', 'NIBR_DRUGseq_2025_up', 'GO_Biological_Process_2021', 'TRANSFAC_and_JASPAR_PWMs', 'Reactome_Pathways_2024', 'GO_Biological_Process_2023', 'Rare_Diseases_AutoRIF_ARCHS4_Predictions', 'COVID-19_Related_Gene_Sets', 'Kinase_Perturbations_from_GEO_up', 'Descartes_Cell_Types_and_Tissue_2021', 'Tabula_Muris', 'Tabula_Sapiens', 'GO_Biological_Process_2025', 'TF_Perturbations_Followed_by_Expression', 'Rummagene_kinases', 'GTEx_Aging_Signatures_2021', 'WikiPathways_2024_Human', 'Tissue_Protein_Expression_from_ProteomicsDB', 'DGIdb_Drug_Targets_2024', 'Serine_Threonine_Kinome_Atlas_2023', 'Aging_Perturbations_from_GEO_down', 'DepMap_CRISPR_GeneDependency_CellLines_2023', 'GO_Biological_Process_2013', 'GO_Biological_Process_2017b', 'GO_Biological_Process_2018', 'CORUM', 'GO_Biological_Process_2015', 'Phosphatase_Substrates_from_DEPOD', 'BioPlex_2017', 'TRRUST_Transcription_Factors_2019', 'GO_Biological_Process_2017', 'Pfam_InterPro_Domains', 'HuBMAP_ASCT_plus_B_augmented_w_RNAseq_Coexpression', 'Pfam_Domains_2019', 'WikiPathway_2023_Human', 'Allen_Brain_Atlas_up', 'Genome_Browser_PWMs', 'NURSA_Human_Endogenous_Complexome', 'HumanCyc_2015', 'HumanCyc_2016', 'Rummagene_signatures', 'Chromosome_Location_hg19', 'Mouse_Gene_Atlas', 'ChEA_2013', 'miRTarBase_2017', 'GO_Molecular_Function_2023', 'Jensen_DISEASES', 'RNAseq_Automatic_GEO_Signatures_Human_Down', 'GO_Molecular_Function_2025', 'Rummagene-transcription-factors', 'ARCHS4_Kinases_Coexp', 'Microbe_Perturbations_from_GEO_down', 'DRUGseqr_2025_up', 'PanglaoDB_Augmented_2021', 'ENCODE_Histone_Modifications_2013', 'ENCODE_Histone_Modifications_2015', 'Achilles_fitness_decrease', 'DSigDB', 'DepMap_WG_CRISPR_Screens_Broad_CellLines_2019', 'Disease_Perturbations_from_GEO_down', 'Drug_Perturbations_from_GEO_down', 'GO_Molecular_Function_2021', 'GO_Molecular_Function_2017', 'GO_Molecular_Function_2018', 'Mitchell_Proteomics_Drug_Atlas_2023', 'GO_Molecular_Function_2013', 'GO_Molecular_Function_2015', 'Rummagene-kinases', 'TG_GATES_2020', 'KEGG_2021_Human', 'HMDB_Metabolites', 'LINCS_L1000_CRISPR_KO_Consensus_Sigs']

Step 3: Run Enrichment

To perform enrichment analysis, call the grea.obs_prerank_enrich(rank_df, libraries) function. The observation-level enrichment do not estimate the p-value for efficiency.

The function returns a GREA object containing all enrichment results, including enrichment scores and statistical significance for each library term.

%autoreload

from grea import grea
libraries = ['WikiPathways_2024_Mouse']
obj = grea.obs_prerank_enrich(rank_df, libraries)
obj
---Finished: Load WikiPathways_2024_Mouse with 188 terms.
---WARMING: 100.0% of entries has zero overlap ratio.
Please check the consistency (upper/lower case) of signature names in rand_df and libraries.
Current rand_df sig name: A1bg, library sig name: NQO1
Current setting - sig_upper=True

<grea.grea._GREA at 0x29d270c7a70>

Step 4: Check Enrichment Results

The GREA object stores all enrichment results, including enrichment scores and statistical significance for each library term. GREA supports three types of enrichment scores, each reflecting a different scoring strategy:

  • 'KS-ES': Kolmogorov–Smirnov-based Enrichment Score, capturing the peak deviation between hit and miss distributions.
  • 'KS-ESD': KS-based enrichment Score Difference, the sum of the maximum positive and negative deviations from the running score.
  • 'RC-AUC': Area Under the Recovery Curve, summarizing early enrichment of target genes along the ranking.
  • 'RC-nAUC': The normalized Area Under the Recovery Curve, summarizing early enrichment of target genes along the ranking.
  • 'nRC-AUC': Area Under the normalized Recovery Curve, summarizing early enrichment of target genes along the ranking, ranges from 0 to 1.

You can select the appropriate metric depending on your analysis goal or data characteristics.

To retrieve the enrichment results as a long DataFrame, use the get_enrich_results(metric) function, as a wide DataFrame, use the get_enrich_score(metric).

%autoreload

df = obj.get_enrich_results(metric='KS-ES')
df
Term Obs KS-ES N_lead_sigs Lead_sigs
73 WikiPathways_2024_Mouse|Cytoplasmic Ribosomal ... GSM334872 0.981638 27 Rps4x;Rpl26;Rps23;Rpl3;Rpl18a;Rps27a;Rps24;Rpl...
73 WikiPathways_2024_Mouse|Cytoplasmic Ribosomal ... GSM334882 0.980820 27 Rpl26;Rps4x;Rps23;Rpl3;Rpl18a;Rps15a;Rps24;Rpl...
37 WikiPathways_2024_Mouse|Peroxiredoxin 2 Induce... GSM334871 0.980468 3 Cyp11a1;Star;Prdx2
73 WikiPathways_2024_Mouse|Cytoplasmic Ribosomal ... GSM334943 0.979097 27 Rpl26;Rps23;Rps4x;Rps24;Rpl18a;Rpl19;Rpl3;Rps8...
73 WikiPathways_2024_Mouse|Cytoplasmic Ribosomal ... GSM334890 0.978595 27 Rps4x;Rpl26;Rps23;Rps24;Rpl18a;Rpl11;Rpl3;Rpl1...
... ... ... ... ... ...
4 WikiPathways_2024_Mouse|Eicosanoid Metabolism ... GSM334880 -0.834127 2 Cyp2c23;Ppara
4 WikiPathways_2024_Mouse|Eicosanoid Metabolism ... GSM334903 -0.844580 2 Cyp2c23;Ppara
4 WikiPathways_2024_Mouse|Eicosanoid Metabolism ... GSM334949 -0.872260 2 Cyp2c23;Ppara
4 WikiPathways_2024_Mouse|Eicosanoid Metabolism ... GSM334950 -0.873169 2 Cyp2c23;Ppara
4 WikiPathways_2024_Mouse|Eicosanoid Metabolism ... GSM334882 -0.882219 2 Cyp2c23;Ppara

18988 rows Ă— 5 columns

%autoreload

df = obj.get_enrich_score(metric='KS-ES')
df
GSM334850 GSM334851 GSM334852 GSM334853 GSM334854 GSM334855 GSM334856 GSM334857 GSM334858 GSM334859 ... GSM334941 GSM334942 GSM334943 GSM334944 GSM334945 GSM334946 GSM334947 GSM334948 GSM334949 GSM334950
WikiPathways_2024_Mouse|Transcriptional Activation By Nfe2l2 Response To Phytochemicals WP1245 0.412830 0.467998 0.436660 0.458399 0.462322 0.395814 0.440631 0.427856 0.504467 0.426130 ... 0.570103 0.609538 0.614854 0.580669 0.555469 0.566584 0.621786 0.580979 0.618088 0.533673
WikiPathways_2024_Mouse|Cholesterol Metabolism W Bloch And Kandutsch Russell Pathways WP4346 0.670548 0.649544 0.673325 0.726577 0.634954 0.605772 0.648493 0.634346 0.602966 0.593843 ... 0.647829 0.681657 0.662473 0.656324 0.633617 0.630928 0.664833 0.605766 0.635952 0.635421
WikiPathways_2024_Mouse|Ethanol Metabolism Resulting In Production Of ROS By CYP2E1 WP4265 0.341948 0.198178 0.243526 0.279609 0.277841 0.264209 0.385532 0.268891 0.249796 0.197347 ... 0.301717 0.291126 0.305152 0.318816 0.258572 0.312139 0.347613 0.295290 0.338123 0.302688
WikiPathways_2024_Mouse|Dysregulated miRNA Targeting In Insulin PI3K AKT Signaling WP3855 0.864432 0.866824 0.876477 0.892865 0.859135 0.855858 0.870907 0.871072 0.881901 0.881987 ... 0.855171 0.847003 0.816605 0.816138 0.811848 0.804385 0.795185 0.831287 0.814979 0.836070
WikiPathways_2024_Mouse|Eicosanoid Metabolism Via Cytochrome P450 Monooxygenases WP4349 -0.570016 -0.661496 -0.527145 -0.560909 -0.653584 -0.745868 -0.611986 -0.754485 -0.713905 -0.741716 ... -0.544996 -0.452423 -0.617188 -0.548674 -0.734372 -0.768024 -0.778717 -0.776660 -0.872260 -0.873169
... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ...
WikiPathways_2024_Mouse|Methylation WP1247 0.391970 0.324458 0.328212 0.332118 0.386053 0.362876 0.418902 0.326840 0.327292 0.406575 ... 0.457257 0.519223 0.515295 0.512668 0.480336 0.496474 0.489760 0.477241 0.454640 0.518497
WikiPathways_2024_Mouse|Mapk Cascade WP251 0.568139 0.580301 0.609159 0.565462 0.556724 0.495847 0.499219 0.519504 0.571507 0.558285 ... 0.412599 0.418264 0.450851 0.409032 0.457314 0.486550 0.478074 0.396986 0.455132 0.491183
WikiPathways_2024_Mouse|Apoptosis WP1254 0.294739 0.281215 0.322398 0.326298 0.289497 0.358050 0.369617 0.327916 0.311259 0.281115 ... 0.384741 0.377897 0.384152 0.336996 0.380882 0.374894 0.357647 0.362886 0.410473 0.349025
WikiPathways_2024_Mouse|GPCRs Other WP41 -0.512467 -0.480542 -0.472730 -0.454921 -0.475378 -0.470748 -0.440662 -0.442404 -0.511002 -0.507203 ... -0.451471 -0.457074 -0.479113 -0.458720 -0.463978 -0.445054 -0.477035 -0.448287 -0.459994 -0.437742
WikiPathways_2024_Mouse|TCA Cycle WP434 0.912299 0.926151 0.906870 0.925250 0.919301 0.907569 0.902905 0.904835 0.913677 0.906402 ... 0.885823 0.884007 0.876870 0.892901 0.882622 0.881128 0.873515 0.876634 0.886494 0.875674

188 rows Ă— 101 columns

%autoreload

df = obj.get_enrich_results(metric='KS-ESD')
df
Term Obs KS-ESD N_lead_sigs Lead_sigs
73 WikiPathways_2024_Mouse|Cytoplasmic Ribosomal ... GSM334872 0.980696 27 Rps4x;Rpl26;Rps23;Rpl3;Rpl18a;Rps27a;Rps24;Rpl...
73 WikiPathways_2024_Mouse|Cytoplasmic Ribosomal ... GSM334882 0.980035 27 Rpl26;Rps4x;Rps23;Rpl3;Rpl18a;Rps15a;Rps24;Rpl...
37 WikiPathways_2024_Mouse|Peroxiredoxin 2 Induce... GSM334871 0.979685 3 Cyp11a1;Star;Prdx2
73 WikiPathways_2024_Mouse|Cytoplasmic Ribosomal ... GSM334943 0.978154 27 Rpl26;Rps23;Rps4x;Rps24;Rpl18a;Rpl19;Rpl3;Rps8...
73 WikiPathways_2024_Mouse|Cytoplasmic Ribosomal ... GSM334896 0.977635 27 Rpl26;Rps4x;Rps23;Rpl18a;Rpl3;Rps24;Rps15a;Rpl...
... ... ... ... ... ...
4 WikiPathways_2024_Mouse|Eicosanoid Metabolism ... GSM334908 -0.767813 2 Ppara;Cyp2c23
4 WikiPathways_2024_Mouse|Eicosanoid Metabolism ... GSM334903 -0.773683 2 Cyp2c23;Ppara
4 WikiPathways_2024_Mouse|Eicosanoid Metabolism ... GSM334949 -0.798073 2 Cyp2c23;Ppara
4 WikiPathways_2024_Mouse|Eicosanoid Metabolism ... GSM334882 -0.804115 2 Cyp2c23;Ppara
4 WikiPathways_2024_Mouse|Eicosanoid Metabolism ... GSM334950 -0.824991 2 Cyp2c23;Ppara

18988 rows Ă— 5 columns

%autoreload

df = obj.get_enrich_score(metric='KS-ESD')
df
GSM334850 GSM334851 GSM334852 GSM334853 GSM334854 GSM334855 GSM334856 GSM334857 GSM334858 GSM334859 ... GSM334941 GSM334942 GSM334943 GSM334944 GSM334945 GSM334946 GSM334947 GSM334948 GSM334949 GSM334950
WikiPathways_2024_Mouse|Transcriptional Activation By Nfe2l2 Response To Phytochemicals WP1245 0.324636 0.414611 0.372847 0.406815 0.405251 0.322672 0.390537 0.362867 0.451002 0.353223 ... 0.529965 0.569557 0.575735 0.538415 0.512901 0.528249 0.576160 0.538019 0.575442 0.485774
WikiPathways_2024_Mouse|Cholesterol Metabolism W Bloch And Kandutsch Russell Pathways WP4346 0.669448 0.645677 0.668263 0.726420 0.634168 0.591900 0.647550 0.632460 0.600765 0.591249 ... 0.646493 0.680242 0.660744 0.654909 0.632123 0.629592 0.662554 0.595761 0.634616 0.634085
WikiPathways_2024_Mouse|Ethanol Metabolism Resulting In Production Of ROS By CYP2E1 WP4265 0.210511 0.061569 0.112168 0.147624 0.159964 0.135571 0.250255 0.145292 0.151434 0.070064 ... 0.200377 0.198721 0.199109 0.205641 0.145710 0.209388 0.259440 0.183291 0.234980 0.188338
WikiPathways_2024_Mouse|Dysregulated miRNA Targeting In Insulin PI3K AKT Signaling WP3855 0.864118 0.866510 0.876320 0.892786 0.859135 0.855623 0.870907 0.870836 0.881822 0.881830 ... 0.854543 0.845983 0.813702 0.814177 0.810906 0.803601 0.794086 0.830895 0.814273 0.835835
WikiPathways_2024_Mouse|Eicosanoid Metabolism Via Cytochrome P450 Monooxygenases WP4349 -0.413965 -0.536467 -0.467293 -0.334978 -0.569683 -0.616295 -0.552683 -0.550725 -0.584881 -0.662515 ... -0.288425 -0.270299 -0.548752 -0.463362 -0.713142 -0.702063 -0.740096 -0.719864 -0.798073 -0.824991
... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ...
WikiPathways_2024_Mouse|Methylation WP1247 0.228440 0.101532 0.168696 0.188356 0.260204 0.182830 0.258322 0.116430 0.060950 0.203101 ... 0.310465 0.446882 0.443503 0.439230 0.349936 0.412625 0.432075 0.283084 0.379164 0.331828
WikiPathways_2024_Mouse|Mapk Cascade WP251 0.514322 0.548058 0.586095 0.553223 0.503849 0.412848 0.454424 0.444349 0.497450 0.487052 ... 0.317047 0.359270 0.391386 0.313480 0.386239 0.410768 0.436182 0.287392 0.376996 0.414930
WikiPathways_2024_Mouse|Apoptosis WP1254 0.281438 0.264137 0.313111 0.319529 0.277613 0.346480 0.360881 0.317291 0.284893 0.257347 ... 0.381986 0.374434 0.380296 0.332746 0.367423 0.373163 0.352531 0.359974 0.408663 0.346821
WikiPathways_2024_Mouse|GPCRs Other WP41 -0.500362 -0.469012 -0.444671 -0.399914 -0.462654 -0.443355 -0.376171 -0.418668 -0.500155 -0.493605 ... -0.431743 -0.436391 -0.428427 -0.431691 -0.437685 -0.412836 -0.426068 -0.437598 -0.420218 -0.422887
WikiPathways_2024_Mouse|TCA Cycle WP434 0.908296 0.922305 0.902082 0.922502 0.915691 0.901368 0.896940 0.899106 0.907555 0.899573 ... 0.880171 0.877257 0.869257 0.885994 0.877834 0.875712 0.863547 0.868942 0.878409 0.869473

188 rows Ă— 101 columns

%autoreload

df = obj.get_enrich_results(metric='RC-AUC')
df
Term Obs RC-AUC
172 WikiPathways_2024_Mouse|mRNA Processing WP310 GSM334869 148671.416845
172 WikiPathways_2024_Mouse|mRNA Processing WP310 GSM334882 143134.458796
172 WikiPathways_2024_Mouse|mRNA Processing WP310 GSM334859 140356.589438
172 WikiPathways_2024_Mouse|mRNA Processing WP310 GSM334872 139825.309173
172 WikiPathways_2024_Mouse|mRNA Processing WP310 GSM334896 139609.507810
... ... ... ...
4 WikiPathways_2024_Mouse|Eicosanoid Metabolism ... GSM334922 73.006146
4 WikiPathways_2024_Mouse|Eicosanoid Metabolism ... GSM334901 70.024766
4 WikiPathways_2024_Mouse|Eicosanoid Metabolism ... GSM334949 61.704440
4 WikiPathways_2024_Mouse|Eicosanoid Metabolism ... GSM334950 61.675580
4 WikiPathways_2024_Mouse|Eicosanoid Metabolism ... GSM334882 59.670673

18988 rows Ă— 3 columns

%autoreload

df = obj.get_enrich_score(metric='RC-AUC')
df
GSM334850 GSM334851 GSM334852 GSM334853 GSM334854 GSM334855 GSM334856 GSM334857 GSM334858 GSM334859 ... GSM334941 GSM334942 GSM334943 GSM334944 GSM334945 GSM334946 GSM334947 GSM334948 GSM334949 GSM334950
WikiPathways_2024_Mouse|Transcriptional Activation By Nfe2l2 Response To Phytochemicals WP1245 1728.159905 2351.103532 1994.681650 2318.750721 2124.519332 1786.577461 2037.191753 1963.697246 2556.636274 2039.257692 ... 2960.736947 3081.768920 2775.771963 2629.290437 2797.675872 2966.597562 2462.900167 2861.366643 2670.161927 2336.667330
WikiPathways_2024_Mouse|Cholesterol Metabolism W Bloch And Kandutsch Russell Pathways WP4346 20688.145673 21519.565627 23312.020514 29248.000321 19713.434477 17226.990813 19367.233450 18719.107988 17935.757995 16563.729070 ... 18767.697946 20967.258874 17934.822221 18708.982835 17179.245136 16114.756826 16507.815746 17462.773144 16965.077818 19301.640667
WikiPathways_2024_Mouse|Ethanol Metabolism Resulting In Production Of ROS By CYP2E1 WP4265 1023.745856 911.661212 983.972585 1096.868488 1001.103676 982.600984 971.049459 1005.950343 1071.902190 926.442363 ... 1182.450902 1226.531318 1034.089830 1199.008140 1167.276825 1196.757060 1314.165628 1147.363710 1266.944014 1151.462087
WikiPathways_2024_Mouse|Dysregulated miRNA Targeting In Insulin PI3K AKT Signaling WP3855 39726.878808 41627.175102 46627.269194 50927.879857 36336.886247 34714.694557 35177.101932 37508.667294 41260.526039 36984.613741 ... 26517.379068 25930.254750 18693.657107 20831.691892 23363.216524 21622.859773 18004.134150 26077.948230 22983.837724 24360.593427
WikiPathways_2024_Mouse|Eicosanoid Metabolism Via Cytochrome P450 Monooxygenases WP4349 187.682448 200.331111 190.896766 233.522505 176.858608 154.872949 168.269473 190.375199 200.214553 131.730134 ... 350.644897 328.080797 205.871278 183.904791 107.869725 107.549898 98.609554 83.443487 61.704440 61.675580
... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ...
WikiPathways_2024_Mouse|Methylation WP1247 1481.948801 1224.450461 1361.148764 1399.913313 1424.781201 1386.866406 1605.121929 1408.186714 1236.608362 1443.029129 ... 1623.589344 1770.760143 1703.623446 1790.013073 1759.882434 1844.485101 1834.214229 1611.350068 1526.379280 1714.140654
WikiPathways_2024_Mouse|Mapk Cascade WP251 3427.687671 4034.010351 4422.693700 5030.750866 3370.679990 2868.445878 2871.973947 2967.901472 3850.362810 3289.628499 ... 2463.822619 2679.224104 2298.827271 2351.364082 2881.077748 2794.818044 2749.948464 2315.948391 2535.283040 2968.940484
WikiPathways_2024_Mouse|Apoptosis WP1254 10567.592020 10766.750221 11657.932840 11707.904993 10382.825052 10781.325318 10793.048680 11171.568666 11026.948495 10167.164672 ... 11497.183967 11429.440076 11889.214336 11254.810942 12013.964218 11368.323225 10872.636887 11376.315769 12485.504708 10794.229008
WikiPathways_2024_Mouse|GPCRs Other WP41 2856.426317 3132.065709 3174.962629 3475.190170 2993.871071 3152.421231 3158.894479 3176.904616 2857.734516 2827.617066 ... 2936.438541 2773.645067 3012.127277 2844.652589 3013.148814 2958.982715 3167.991805 2780.083217 3054.315818 2936.208732
WikiPathways_2024_Mouse|TCA Cycle WP434 50289.386611 55501.381648 49935.125548 55392.068375 47886.909152 45631.450323 40506.109989 46944.951604 54789.106472 45650.056483 ... 30295.900070 33342.118782 26035.030690 35840.847604 28130.964698 26015.183058 25263.765249 31271.632958 26681.648514 27804.969734

188 rows Ă— 101 columns

%autoreload

df = obj.get_enrich_results(metric='RC-nAUC')
df
Term Obs RC-nAUC
73 WikiPathways_2024_Mouse|Cytoplasmic Ribosomal ... GSM334869 3757.080794
73 WikiPathways_2024_Mouse|Cytoplasmic Ribosomal ... GSM334919 3753.980702
73 WikiPathways_2024_Mouse|Cytoplasmic Ribosomal ... GSM334896 3639.503472
73 WikiPathways_2024_Mouse|Cytoplasmic Ribosomal ... GSM334882 3559.959174
73 WikiPathways_2024_Mouse|Cytoplasmic Ribosomal ... GSM334872 3528.439808
... ... ... ...
4 WikiPathways_2024_Mouse|Eicosanoid Metabolism ... GSM334922 24.335382
4 WikiPathways_2024_Mouse|Eicosanoid Metabolism ... GSM334901 23.341589
4 WikiPathways_2024_Mouse|Eicosanoid Metabolism ... GSM334949 20.568147
4 WikiPathways_2024_Mouse|Eicosanoid Metabolism ... GSM334950 20.558527
4 WikiPathways_2024_Mouse|Eicosanoid Metabolism ... GSM334882 19.890224

18988 rows Ă— 3 columns

%autoreload

df = obj.get_enrich_score(metric='RC-nAUC')
df
GSM334850 GSM334851 GSM334852 GSM334853 GSM334854 GSM334855 GSM334856 GSM334857 GSM334858 GSM334859 ... GSM334941 GSM334942 GSM334943 GSM334944 GSM334945 GSM334946 GSM334947 GSM334948 GSM334949 GSM334950
WikiPathways_2024_Mouse|Transcriptional Activation By Nfe2l2 Response To Phytochemicals WP1245 144.013325 195.925294 166.223471 193.229227 177.043278 148.881455 169.765979 163.641437 213.053023 169.938141 ... 246.728079 256.814077 231.314330 219.107536 233.139656 247.216464 205.241681 238.447220 222.513494 194.722278
WikiPathways_2024_Mouse|Cholesterol Metabolism W Bloch And Kandutsch Russell Pathways WP4346 459.736571 478.212569 518.044900 649.955563 438.076322 382.822018 430.382966 415.980178 398.572400 368.082868 ... 417.059954 465.939086 398.551605 415.755174 381.761003 358.105707 366.840350 388.061625 377.001729 428.925348
WikiPathways_2024_Mouse|Ethanol Metabolism Resulting In Production Of ROS By CYP2E1 WP4265 113.749540 101.295690 109.330287 121.874276 111.233742 109.177887 107.894384 111.772260 119.100243 102.938040 ... 131.383434 136.281258 114.898870 133.223127 129.697425 132.973007 146.018403 127.484857 140.771557 127.940232
WikiPathways_2024_Mouse|Dysregulated miRNA Targeting In Insulin PI3K AKT Signaling WP3855 1655.286617 1734.465629 1942.802883 2121.994994 1514.036927 1446.445607 1465.712580 1562.861137 1719.188585 1541.025573 ... 1104.890794 1080.427281 778.902379 867.987162 973.467355 900.952491 750.172256 1086.581176 957.659905 1015.024726
WikiPathways_2024_Mouse|Eicosanoid Metabolism Via Cytochrome P450 Monooxygenases WP4349 62.560816 66.777037 63.632255 77.840835 58.952869 51.624316 56.089824 63.458400 66.738184 43.910045 ... 116.881632 109.360266 68.623759 61.301597 35.956575 35.849966 32.869851 27.814496 20.568147 20.558527
... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ...
WikiPathways_2024_Mouse|Methylation WP1247 164.660978 136.050051 151.238752 155.545924 158.309022 154.096267 178.346881 156.465190 137.400929 160.336570 ... 180.398816 196.751127 189.291494 198.890341 195.542493 204.942789 203.801581 179.038896 169.597698 190.460073
WikiPathways_2024_Mouse|Mapk Cascade WP251 163.223222 192.095731 210.604462 239.559565 160.508571 136.592661 136.760664 141.328642 183.350610 156.648976 ... 117.324887 127.582100 109.467965 111.969718 137.194178 133.086574 130.949927 110.283257 120.727764 141.378118
WikiPathways_2024_Mouse|Apoptosis WP1254 170.445033 173.657262 188.031175 188.837177 167.464920 173.892344 174.081430 180.186591 177.854008 163.986527 ... 185.438451 184.345808 191.761522 181.529209 193.773616 183.360052 175.365111 183.488964 201.379108 174.100468
WikiPathways_2024_Mouse|GPCRs Other WP41 63.476140 69.601460 70.554725 77.226448 66.530468 70.053805 70.197655 70.597880 63.505211 62.835935 ... 65.254190 61.636557 66.936162 63.214502 66.958863 65.755171 70.399818 61.779627 67.873685 65.249083
WikiPathways_2024_Mouse|TCA Cycle WP434 1862.569874 2055.606728 1849.449094 2051.558088 1773.589228 1690.053716 1500.226296 1738.701911 2029.226166 1690.742833 ... 1122.070373 1234.893288 964.260396 1327.438800 1041.887581 963.525298 935.695009 1158.208628 988.209204 1029.813694

188 rows Ă— 101 columns

Step 5: Visualize Enrichment Results

To visualize the enrichment results, use the pl_running_sum(metric, term, obs_id) function by specifying the desired metric, term, and observation ID.

%autoreload
term = 'WikiPathways_2024_Mouse|TCA Cycle WP434'
obs_id = 'GSM334850'
fig = obj.pl_running_sum('KS-ES', term, obs_id)
fig
No description has been provided for this image
%autoreload
term = 'WikiPathways_2024_Mouse|TCA Cycle WP434'
obs_id = 'GSM334850'
fig = obj.pl_running_sum('KS-ESD', term, obs_id)
fig
No description has been provided for this image
%autoreload
term = 'WikiPathways_2024_Mouse|TCA Cycle WP434'
obs_id = 'GSM334850'
fig = obj.pl_running_sum('RC-AUC', term, obs_id)
fig
No description has been provided for this image
%autoreload
term = 'WikiPathways_2024_Mouse|TCA Cycle WP434'
obs_id = 'GSM334850'
fig = obj.pl_running_sum('RC-nAUC', term, obs_id)
fig
No description has been provided for this image
%autoreload
term = 'WikiPathways_2024_Mouse|TCA Cycle WP434'
obs_id = 'GSM334850'
fig = obj.pl_running_sum('nRC-AUC', term, obs_id)
fig
No description has been provided for this image