gseapy-gene-enrichment
GSEA and over-representation analysis (ORA) for RNA-seq and proteomics. Wraps Enrichr for ORA against MSigDB, KEGG, GO, and 200+ databases; runs preranked GSEA on ranked DE gene lists. Outputs enrichment tables and running-score plots. Use after DESeq2 or edgeR for pathway-level interpretation.
Install / Use
npx skills add jaechang-hits/SciAgent-Skills --skill gseapy-gene-enrichmentInstalls into whichever agent you are using.
SKILL.md
Installable skill definition
Quality Score
Category
Data & AnalyticsSupported Platforms
Our assessment of gseapy-gene-enrichment
gseapy-gene-enrichment scores 91/100 on our quality scale, 262nd of 599 Data & Analytics skills we index (top 44%).
Its SKILL.md is 16 KB long, well organised into 46 sections with 11 code examples: a thorough specification that gives an agent plenty to work with.
It has 367 GitHub stars, a meaningful sign that others use it.
Maintenance, license and trust
- The repository was last updated about 3 months ago, so gseapy-gene-enrichment is actively maintained.
- Our last check on 2026-11-20 found the source still online.
- No license is declared. By default that means all rights are reserved: you can read it, but reusing or redistributing it is not clearly permitted. Ask the author before building on it commercially.
- Its trust signals score 88/100, with 1 caution from licensing, adoption, age or documentation. These come from repository metadata, not a code audit — read the skill file before letting an agent act on it.
Safety scan
No issues foundOur scan of the whole file found no instruction hijacking, hidden characters, credential access, data exfiltration or destructive commands. An AI review of the same text found nothing harmful.
AI review by kimi-k2.7-code on 2026-10-05. Automated pattern scan on 2026-10-05. It catches known dangerous patterns, not every risk — read a skill before letting an agent act on it.
gseapy-gene-enrichment compared with similar skills
All 4 of these similar skills score higher than gseapy-gene-enrichment; compare them before choosing.
| Skill | Score | Stars | Updated | Format |
|---|---|---|---|---|
| gseapy-gene-enrichment (this skill)by jaechang-hits | 91 | 367 | 3mo ago | SKILL.md |
| Agent-Reachby Panniantong | 100 | 113.3k | 12d ago | CLAUDE.md |
| headroomby headroomlabs-ai | 100 | 80.2k | today | CLAUDE.md |
| Scraplingby D4Vinci | 100 | 104.4k | 2d ago | MCP Server |
| crawl4aiby unclecode | 100 | 87.6k | today | MCP Server |
Frequently asked questions
- How do I install gseapy-gene-enrichment?
- Run
npx skills add jaechang-hits/SciAgent-Skills --skill gseapy-gene-enrichment. The install tabs above show the steps for each supported agent. - Which AI agents does gseapy-gene-enrichment work with?
- It is written for Universal, as a SKILL.md file. Other agents that read the same format can often use it too.
- Is gseapy-gene-enrichment safe to use?
- Our scan of the whole file found no instruction hijacking, hidden characters, credential access, data exfiltration or destructive commands. An AI review of the same text found nothing harmful. It declares no license and scores 88/100 on trust signals. Skills are instructions an agent will follow, so read the file before installing it and do not approve commands you do not understand.
- Is gseapy-gene-enrichment still maintained?
- The repository was last updated about 3 months ago, so gseapy-gene-enrichment is actively maintained.
Skill content
View source on GitHubname: "gseapy-gene-enrichment" description: "GSEA and over-representation analysis (ORA) for RNA-seq and proteomics. Wraps Enrichr for ORA against MSigDB, KEGG, GO, and 200+ databases; runs preranked GSEA on ranked DE gene lists. Outputs enrichment tables and running-score plots. Use after DESeq2 or edgeR for pathway-level interpretation." license: "MIT"
GSEApy — Gene Set Enrichment Analysis in Python
Overview
GSEApy provides Python implementations of GSEA and over-representation analysis (ORA) for interpreting gene expression changes at the pathway level. The enrich module queries the Enrichr API to test a gene list against 200+ databases (GO, KEGG, MSigDB Hallmarks, Reactome, WikiPathways). The prerank and gsea modules run the GSEA algorithm on a pre-ranked gene list or expression matrix — computing normalized enrichment scores (NES) and FDR values for each gene set. GSEApy integrates directly with pandas DataFrames from DESeq2 or scanpy differential expression output, making it the standard Python tool for pathway analysis in RNA-seq workflows.
When to Use
- Interpreting DESeq2 or edgeR differential expression results at pathway/GO-term level
- Running fast ORA (over-representation analysis) against Enrichr's 200+ databases including GO, KEGG, and MSigDB Hallmarks
- Performing GSEA prerank analysis on a log2-fold-change-ranked gene list without an expression matrix
- Identifying enriched pathways in scRNA-seq cluster marker genes
- Generating publication-ready enrichment dot plots and GSEA running-score plots
- Use GSEA Java application for the official GUI-based analysis with full GSEA desktop interface
- Use fgsea (R) as an alternative with fast permutation-based p-values; GSEApy is preferred for Python-native pipelines
- Use omics-plotting SKILL after DE and for publication-quality plots of gsea results
Prerequisites
- Python packages:
gseapy,pandas,matplotlib - Internet access:
enrichmodule queries the Enrichr API (requires connection)
pip install gseapy
# Verify
python -c "import gseapy; print(gseapy.__version__)"
# 1.1.3
Pre-flight Interview
Settle these with the user before writing any analysis code.
decisions:
- id: D1
param: analysis_mode
kind: required
source: upstream
ask: "Test only the genes that passed a significance cut (ORA), or the whole ranked list without a cut (GSEA prerank)?"
default: "prerank when the upstream stage yields a full ranking; ORA when it yields a gene list"
- id: D2
param: organism
kind: derived
source: upstream
ask: "Which species are these genes from?"
default: "carried from the upstream dataset"
- id: D3
param: gene_sets
kind: required
source: user
depends_on: [D2]
ask: "Which collections should the genes be tested against - GO terms, pathways, disease or perturbation signatures?"
default: null
- id: D4
param: rnk
kind: optional
source: user
depends_on: [D1]
ask: "What should order the genes - effect size, signed significance, or the test statistic?"
default: "log2FoldChange"
skip_if: "ORA mode - ranking is not used"
- id: D5
param: cutoff
kind: optional
source: user
ask: "How strong must a term's evidence be before it is reported?"
default: 0.05
- id: D6
param: min_size, max_size
kind: optional_conditional
source: user
ask: "Should very small or very broad gene sets be excluded as uninformative?"
default: "15-500 genes"
- id: D7
param: permutation_num
kind: optional_conditional
source: user
ask: "More permutations give finer p-values at proportionally more runtime - is the default enough?"
default: 1000
- id: D8
param: weighted_score_type
kind: optional
source: user
ask: "Should GSEA use the standard weighted enrichment score, or a different weighting for this ranking?"
default: 1
- id: D9
param: seed, threads
kind: never_ask
source: data
reason: "A fixed seed and available CPU cores affect reproducibility and runtime, not the enrichment model."
default: "seed fixed, threads min(4, available_cores)"
Two orderings matter here. D3 hangs on D2 because Enrichr's libraries are
species-specific — the catalog itself changes with the organism. D4 hangs on D1
because a ranking metric only exists in prerank mode; under ORA the question has
no answer, which is what skip_if records.
Quick Start
import gseapy as gp
# ORA: test a gene list against GO Biological Process
gene_list = ["TP53", "BRCA1", "CDK2", "CCND1", "MYC", "EGFR", "KRAS", "PTEN"]
enr = gp.enrichr(gene_list=gene_list,
gene_sets=["GO_Biological_Process_2023"],
organism="human",
outdir=None)
print(enr.results.head(5)[["Term", "P-value", "Adjusted P-value", "Genes"]])
Workflow
Step 1: Over-Representation Analysis with Enrichr (ORA)
Test a gene list against pathway databases via the Enrichr API.
import gseapy as gp
import pandas as pd
# Gene list from DESeq2 (significant upregulated genes)
sig_genes = ["TP53", "BRCA1", "CDK2", "CCND1", "MYC", "EGFR",
"KRAS", "PTEN", "RB1", "AKT1", "PIK3CA", "MDM2"]
# Run ORA against multiple databases
enr = gp.enrichr(
gene_list=sig_genes,
gene_sets=[
"GO_Biological_Process_2023",
"KEGG_2021_Human",
"MSigDB_Hallmark_2020",
"Reactome_2022",
],
organism="human",
outdir="enrichr_results/",
cutoff=0.05,
)
# Display top results
results = enr.results
print(f"Enriched terms: {len(results[results['Adjusted P-value'] < 0.05])}")
print(results[results["Adjusted P-value"] < 0.05].sort_values("Adjusted P-value")
.head(10)[["Gene_set", "Term", "Adjusted P-value", "Combined Score"]])
Step 2: List Available Gene Set Databases
Discover the 200+ databases available through Enrichr.
import gseapy as gp
# List all available gene set libraries
libraries = gp.get_library_name(organism="human")
print(f"Available databases: {len(libraries)}")
print("Selected databases:")
for lib in sorted(libraries):
if any(kw in lib for kw in ["GO_Bio", "KEGG", "Hallmark", "Reactome"]):
print(f" {lib}")
# Mouse databases
mouse_libs = gp.get_library_name(organism="mouse")
print(f"\nMouse databases: {len(mouse_libs)}")
Step 3: GSEA Prerank — Ranked Gene List Analysis
Run GSEA on a log2 fold-change ranked gene list from differential expression.
import gseapy as gp
import pandas as pd
import numpy as np
# Load DESeq2 results (or create example ranked list)
# deseq_results = pd.read_csv("deseq2_results.tsv", sep="\t", index_col=0)
# ranked = deseq_results["log2FoldChange"].dropna().sort_values(ascending=False)
# Example ranked gene list (gene → log2FC)
np.random.seed(42)
gene_names = [f"GENE_{i}" for i in range(1000)]
log2fc = np.random.normal(0, 2, 1000)
ranked = pd.Series(log2fc, index=gene_names).sort_values(ascending=False)
# Run preranked GSEA against MSigDB Hallmarks
pre_res = gp.prerank(
rnk=ranked,
gene_sets="MSigDB_Hallmark_2020",
threads=4,
min_size=15,
max_size=500,
permutation_num=1000,
outdir="gsea_results/prerank/",
seed=42,
verbose=True,
)
# View results
res_df = pre_res.res2d
sig = res_df[res_df["FDR q-val"] < 0.25]
print(f"Significant gene sets (FDR < 0.25): {len(sig)}")
print(sig.sort_values("NES", ascending=False)[["Term", "NES", "NOM p-val", "FDR q-val"]].head(10))
Step 4: Plot GSEA Running Score
The running enrichment-score curve is GSEApy-specific — draw it with gseaplot. (omics-plotting covers the GSEA bar/dot summary plots instead, see Step 5.)
from gseapy import gseaplot
# pre_res: prerank result from Step 3
top_term = pre_res.res2d.sort_values("NES", ascending=False).index[0]
gseaplot(
rank_metric=pre_res.ranking,
term=top_term,
**pre_res.results[top_term],
ofname="figures/gsea_running_score.png",
)
print(f"Saved figures/gsea_running_score.png ({top_term})")
Step 5: Enrichment Dot Plot for Multiple Terms
Run ORA, then read skills/data-visualization/omics-plotting/SKILL.md and follow its "GSEA dot plot" recipe on the exported table (→ figures/enrichment_dotplot.png). Map GSEApy's Overlap column to the recipe's GeneRatio.
import gseapy as gp
# enr.results is the enrichment table: Term, Overlap, Adjusted P-value, Genes, ...
enr = gp.enrichr(
gene_list=["TP53", "BRCA1", "CDK2", "CCND1", "MYC", "EGFR",
"KRAS", "PTEN", "RB1", "AKT1", "PIK3CA", "MDM2",
"BCL2", "CDKN1A", "E2F1", "CCNE1"],
gene_sets=["KEGG_2021_Human"],
organism="human",
outdir=None,
cutoff=0.05,
)
enr.results.to_csv("enrichment.csv", index=False)
print(f"ORA terms: {len(enr.results)} -> enrichment.csv")
# Render with the omics-plotting SKILL (`skills/data-visualization/omics-plotting/SKILL.md`) "GSEA dot plot" recipe.
Step 6: Integrate with DESeq2 / scanpy Output
Use GSEApy directly on differential expression results.
import gseapy as gp
import pandas as pd
# From DESeq2 output loaded into Python
# deseq_df = pd.read_csv("deseq2_results.tsv", sep="\t", index_col=0)
# deseq_df = deseq_df.dropna(subset=["log2FoldChange", "padj"])
# Simulate DESeq2 output
import numpy as np
np.random.seed(0)
n = 500
deseq_df = pd.DataFrame({
"log2FoldChange": np.random.normal(0, 1.5, n),
"padj": np.random.uniform(0, 1, n),
}, index=[f"GENE{i}" for i in range(n)])
# Significant up/down gene lists for ORA
up_genes = deseq_df[(deseq_df["padj"] < 0.05) & (deseq_df["log2FoldChange"] > 1)].index.tolist()
dn_genes = deseq_df[(deseq_df["padj"] < 0.05) & (deseq_df["log2FoldChange"] < -1)].index.tolist()
print(f"Upregulated: {len(up_genes)}, Downregulated: {len(dn_genes)}")
# ORA on upregulated genes
if up_genes:
enr_up = gp.enrichr(gene_list=up_genes,
gene_sets=["GO_Biological_Process_2023", "KEGG_2021_Human"],
organism="human", outdir=None)
sig_up = enr_up.results[enr_up.results["Adjusted P-value"] < 0.05]
print(f"Enriched terms (upregulated): {len(sig_up)}")
print(sig_up.sort_values("Adjusted P-value").head(5)[["Term", "Adjusted P-value"]])
# Preranked GSEA on full ranked list
ranked = deseq_df["log2FoldChange"].sort_values(ascending=False)
pre = gp.prerank(rnk=ranked, gene_sets="MSigDB_Hallmark_2020",
threads=4, permutation_num=500, outdir="gsea_out/", seed=42)
print(pre.res2d[pre.res2d["FDR q-val"] < 0.25].sort_values("NES", ascending=False)
.head(5)[["Term", "NES", "FDR q-val"]])
Key Parameters
| Parameter | Default | Range/Options | Effect |
|-----------|---------|---------------|--------|
| gene_sets (enrichr) | required | string or list | Database name(s) from Enrichr; use gp.get_library_name() to list |
| organism (enrichr) | "human" | "human", "mouse", "fly", "fish", "worm", "yeast" | Species for gene set lookup |
| cutoff (enrichr) | 0.05 | 0–1 | Adjusted p-value cutoff for filtering results |
| rnk (prerank) | required | pd.Series | Gene → score mapping; sorted descending (log2FC recommended) |
| permutation_num (prerank) | 1000 | 100–10000 | Permutations for p-value estimation; 1000 for publication |
| min_size (prerank) | 15 | 5–50 | Minimum gene set size; filters small/poorly characterized sets |
| max_size (prerank) | 500 | 100–2000 | Maximum gene set size; filters very large generic sets |
| threads (prerank) | 4 | 1–64 | CPU threads for permutation |
| seed (prerank) | None | integer | Random seed for reproducibility |
| weighted_score_type (prerank) | 1 | 0, 1, 1.5 | GSEA weighting; 1 = standard weighted GSEA |
Common Recipes
Recipe 1: Compare Enrichment Between Two Conditions
import gseapy as gp
import pandas as pd
conditi
Truncated for display — read the full file on GitHub.
Related Skills
Agent-Reach
113.3kGive your AI agent eyes to see the entire internet. Read & search Twitter, Reddit, YouTube, GitHub, Bilibili, XiaoHongShu — one CLI, zero API fees.
headroom
80.2kCompress tool outputs, logs, files, and RAG chunks before they reach the LLM. 20% fewer tokens for coding agents, 60-95% fewer tokens for JSON, same answers. Library, proxy, MCP server.
Scrapling
104.4k🕷️ The BEST Web Scraping framework that handles everything from a single request to a full-scale crawl! Don't be shy, join here: https://discord.gg/EMgGbDceNQ and follow here for daily tips and tricks: https://x.com/Scrapling_dev
crawl4ai
87.6kOfficial Crawl4AI Cloud: a hosted web scraping, extraction, and search API for AI agents. Free API key, 1,000 credits a month, no card. Fully open source: this repo is the Apache-2.0 crawler that powers it, and you can self-host it.
Languages
Trust signals
From repository metadata: license, adoption, age and documentation. Not a code audit — see the Safety scan above for what the skill file itself contains.
