Skill Tracer
Skills › Scientific Agent Skills › pathway-enrichment › databases-and-gene-sets.md

databases-and-gene-sets.md

170 lines · skills/pathway-enrichment/references/databases-and-gene-sets.md at 5f2bc03

Open on GitHub

Most marks come from matching words in the file, so treat them as pointers.

1# Databases, Gene Sets, and Gene-ID Mapping
2

Databases, Gene Sets, and Gene-ID Mapping

Raw lines 1 to 2
3## Contents
4- [Picking libraries by question](#picking-libraries-by-question)
5- [The main gene-set databases](#the-main-gene-set-databases)
6- [MSigDB collections](#msigdb-collections)
7- [g:Profiler (alternative ORA, custom background, many organisms)](#gprofiler)
8- [Gene-ID types and conversion](#gene-id-types-and-conversion)
9- [Organism handling](#organism-handling)
10- [Pathway/interaction APIs (Reactome, KEGG, STRING)](#pathwayinteraction-apis)
11- [Activity inference (decoupler: PROGENy, DoRothEA/CollecTRI)](#activity-inference)

Contents

  • Picking libraries by question
  • The main gene-set databases
  • MSigDB collections
  • g:Profiler (alternative ORA, custom background, many organisms)
  • Gene-ID types and conversion
  • Organism handling
  • Pathway/interaction APIs (Reactome, KEGG, STRING)
  • Activity inference (decoupler: PROGENy, DoRothEA/CollecTRI)
Raw lines 3 to 12
13## Picking libraries by question
15Match the database to the biological question instead of running everything:
17| Question | Best gene sets |
18|----------|----------------|
19| "What are the broad themes?" | MSigDB **Hallmark** (50 curated, low redundancy) |
20| "What mechanism/process?" | **GO Biological Process** |
21| "Which curated pathways?" | **Reactome**, **KEGG**, **WikiPathways** |
22| "Molecular function / localization?" | GO MF / GO CC |
23| "Immune signatures?" | MSigDB **C7** (ImmuneSigDB) |
24| "Oncogenic / perturbation?" | MSigDB **C6** (oncogenic), **C2:CGP** |
25| "TF targets / regulons?" | MSigDB **C3**, ChEA, or decoupler (below) |
26| "Disease/phenotype association?" | g:Profiler HP, DisGeNET, GWAS Catalog |
28Start narrow (Hallmark + one of GO:BP / Reactome). Add libraries only if the
29question needs them — each extra library multiplies the testing burden.

Picking libraries by question

Match the database to the biological question instead of running everything:

QuestionBest gene sets
"What are the broad themes?"MSigDB Hallmark (50 curated, low redundancy)
"What mechanism/process?"GO Biological Process
"Which curated pathways?"Reactome, KEGG, WikiPathways
"Molecular function / localization?"GO MF / GO CC
"Immune signatures?"MSigDB C7 (ImmuneSigDB)
"Oncogenic / perturbation?"MSigDB C6 (oncogenic), C2:CGP
"TF targets / regulons?"MSigDB C3, ChEA, or decoupler (below)
"Disease/phenotype association?"g:Profiler HP, DisGeNET, GWAS Catalog

Start narrow (Hallmark + one of GO:BP / Reactome). Add libraries only if the question needs them — each extra library multiplies the testing burden.

Raw lines 13 to 30
31## The main gene-set databases
33- **GO (Gene Ontology)** — three namespaces: Biological Process (BP), Molecular
34 Function (MF), Cellular Component (CC). Hierarchical → highly redundant; collapse
35 terms after testing (see `interpretation.md`).
36- **KEGG** — manually curated metabolic & signaling pathways. Compact, well known.
37- **Reactome** — large, expert-curated, hierarchical human pathway set; good
38 granularity. APIs in `database-lookup`.
39- **WikiPathways** — community-curated pathways; complements KEGG/Reactome.
40- **MSigDB** — collections of collections (Hallmark, curated, GO, immune, etc.);
41 the standard source of GMT files for GSEA.

The main gene-set databases

  • GO (Gene Ontology) — three namespaces: Biological Process (BP), Molecular Function (MF), Cellular Component (CC). Hierarchical → highly redundant; collapse terms after testing (see interpretation.md).
  • KEGG — manually curated metabolic & signaling pathways. Compact, well known.
  • Reactome — large, expert-curated, hierarchical human pathway set; good granularity. APIs in database-lookup.
  • WikiPathways — community-curated pathways; complements KEGG/Reactome.
  • MSigDB — collections of collections (Hallmark, curated, GO, immune, etc.); the standard source of GMT files for GSEA.
Raw lines 31 to 42
Names a skill database-lookup :38
43## MSigDB collections
45| Collection | Contents |
46|-----------|----------|
47| **H** (`h.all`) | Hallmark — 50 refined, non-redundant signatures (best default for GSEA) |
48| **C2:CP** | Canonical Pathways: `c2.cp.kegg_medicus`, `c2.cp.reactome`, `c2.cp.wikipathways`, `c2.cp.biocarta` |
49| **C2:CGP** | Chemical & genetic perturbations |
50| **C3** | Regulatory targets (TFT, miRNA) |
51| **C5** | Ontology: `c5.go.bp`, `c5.go.mf`, `c5.go.cc`, `c5.hpo` |
52| **C6** | Oncogenic signatures |
53| **C7** | ImmuneSigDB |
54| **C8** | Cell-type signatures |
55| **C9** | Computational perturbation signatures from DepMap CRISPR/CCLE analyses |
57Current release (reviewed 2026-10-01): **2026.1.Hs / 2026.1.Mm**. Fetch human
58Hallmark with `gp.Msigdb.get_gmt(category="h.all", dbver="2026.1.Hs")`.
59Mouse uses its own category codes (Hallmark `mh.all`, `m2`, `m5`, etc.); changing
60only Hs to Mm is insufficient. List categories for the exact release. Symbols and
61Entrez GMTs are available; save the file/hash and comply with MSigDB license terms.
62See [gseapy.md](gseapy.md) and the [official collections](https://www.gsea-msigdb.org/gsea/msigdb).

MSigDB collections

CollectionContents
H (h.all)Hallmark — 50 refined, non-redundant signatures (best default for GSEA)
C2:CPCanonical Pathways: c2.cp.kegg_medicus, c2.cp.reactome, c2.cp.wikipathways, c2.cp.biocarta
C2:CGPChemical & genetic perturbations
C3Regulatory targets (TFT, miRNA)
C5Ontology: c5.go.bp, c5.go.mf, c5.go.cc, c5.hpo
C6Oncogenic signatures
C7ImmuneSigDB
C8Cell-type signatures
C9Computational perturbation signatures from DepMap CRISPR/CCLE analyses

Current release (reviewed 2026-10-01): 2026.1.Hs / 2026.1.Mm. Fetch human Hallmark with gp.Msigdb.get_gmt(category="h.all", dbver="2026.1.Hs"). Mouse uses its own category codes (Hallmark mh.all, m2, m5, etc.); changing only Hs to Mm is insufficient. List categories for the exact release. Symbols and Entrez GMTs are available; save the file/hash and comply with MSigDB license terms. See gseapy.md and the official collections.

Raw lines 43 to 63
64## g:Profiler
66The official client (`gprofiler-official`) is the best path when you need a
67**custom background**, **many organisms** (discover supported organism codes), or g:Profiler's `g:SCS`
68multiple-testing correction. It performs ORA over GO, KEGG, Reactome,
69WikiPathways, miRTarBase, CORUM, HP, and more in one call.
71```python
72from gprofiler import GProfiler
74gp = GProfiler(return_dataframe=True)
75res = gp.profile(
76 organism="hsapiens", # mmusculus, dmelanogaster, ...
77 query=gene_list, # symbols, Ensembl, Entrez — auto-detected
78 sources=["GO:BP", "KEGG", "REAC", "WP"], # restrict sources
79 user_threshold=0.05,
80 significance_threshold_method="g_SCS", # default; or "fdr" / "bonferroni"
81 domain_scope="custom", # use a custom statistical background
82 background=expressed_genes, # the tested/expressed universe
83 all_results=True, # retain nonsignificant returned terms
84 no_evidences=False, # required for intersections/evidences
85 ordered=False, # ranked-prefix ORA is not GSEA
86 no_iea=False, # True = drop electronic GO annotations
88# columns: source, native, name, p_value, term_size, query_size,
89# intersection_size, effective_domain_size, intersections
90```
92`gp.convert(organism="hsapiens", query=ids, target_namespace="ENTREZGENE_ACC")` maps
93numeric Entrez IDs. In the live service, target `ENTREZGENE` returned a symbol
94(`TP53`), whereas `ENTREZGENE_ACC` returned `7157`; validate the output namespace.
95`gp.orth(query=["Trp53"], organism="mmusculus", target="hsapiens")` returns
96source `converted`, target `ortholog_ensg`, and target `name`; do not confuse them.
98`p_value` is **already adjusted** with the requested method. Do not BH-adjust it
99a second time or relabel g:SCS as FDR. `all_results=True` retains nonsignificant
100returned terms; it does not promise all database terms including zero overlap.
101Save `gp.meta` immediately with results (subsequent calls overwrite it), including
102version, effective domains, mapping failures/ambiguities and correction settings.
103Client 1.0.0 forces `domain_scope="custom"` whenever background is supplied; it
104cannot preserve `custom_annotated` via that method. Use the documented raw API
105only if that alternative domain is actually required, and verify echoed metadata.

g:Profiler

The official client (gprofiler-official) is the best path when you need a custom background, many organisms (discover supported organism codes), or g:Profiler's g:SCS multiple-testing correction. It performs ORA over GO, KEGG, Reactome, WikiPathways, miRTarBase, CORUM, HP, and more in one call.

from gprofiler import GProfiler

gp = GProfiler(return_dataframe=True)
res = gp.profile(
    organism="hsapiens",                      # mmusculus, dmelanogaster, ...
    query=gene_list,                          # symbols, Ensembl, Entrez — auto-detected
    sources=["GO:BP", "KEGG", "REAC", "WP"],  # restrict sources
    user_threshold=0.05,
    significance_threshold_method="g_SCS",    # default; or "fdr" / "bonferroni"
    domain_scope="custom",                    # use a custom statistical background
    background=expressed_genes,               # the tested/expressed universe
    all_results=True,                        # retain nonsignificant returned terms
    no_evidences=False,                       # required for intersections/evidences
    ordered=False,                           # ranked-prefix ORA is not GSEA
    no_iea=False,                             # True = drop electronic GO annotations
)
# columns: source, native, name, p_value, term_size, query_size,
#          intersection_size, effective_domain_size, intersections

gp.convert(organism="hsapiens", query=ids, target_namespace="ENTREZGENE_ACC") maps numeric Entrez IDs. In the live service, target ENTREZGENE returned a symbol (TP53), whereas ENTREZGENE_ACC returned 7157; validate the output namespace. gp.orth(query=["Trp53"], organism="mmusculus", target="hsapiens") returns source converted, target ortholog_ensg, and target name; do not confuse them.

p_value is already adjusted with the requested method. Do not BH-adjust it a second time or relabel g:SCS as FDR. all_results=True retains nonsignificant returned terms; it does not promise all database terms including zero overlap. Save gp.meta immediately with results (subsequent calls overwrite it), including version, effective domains, mapping failures/ambiguities and correction settings. Client 1.0.0 forces domain_scope="custom" whenever background is supplied; it cannot preserve custom_annotated via that method. Use the documented raw API only if that alternative domain is actually required, and verify echoed metadata.

Raw lines 64 to 106
107## Gene-ID types and conversion
109Choose one declared namespace and species. Many Enrichr libraries use symbols;
110MSigDB also offers numeric Entrez GMTs. Map only when needed and retain the
111source-to-target table, failed IDs and ambiguous mappings. No casing operation
112constitutes identifier mapping; `capitalize()` can corrupt identifiers.
114| You have | Convert with |
115|----------|--------------|
116| Ensembl gene IDs (`ENSG…`) | `gp.Biomart`, g:Profiler `g:Convert`, or `mygene` |
117| Entrez IDs | `mygene`, g:Profiler |
118| Mouse symbols → human | g:Profiler `g:Orth` or another explicit orthology resource; querying MyGene with `species="human"` is not orthology conversion |
120`mygene` example:
121```python
122import mygene
123mg = mygene.MyGeneInfo()
124mapping = mg.querymany(ensembl_ids, scopes="ensembl.gene",
125 fields="symbol", species="human", returnall=True)
126# mapping["out"] contains query-aligned hits (or notfound); inspect dup/missing.
127# Resolve one-to-many cases before extracting symbols; never silently keep first.
128```
129For versioned Ensembl IDs only, record and strip the numeric version suffix first (`ENSG00000141510.16` → `ENSG00000141510`).
130The `gget` skill (`gget info`) is another quick ID-mapping path.

Gene-ID types and conversion

Choose one declared namespace and species. Many Enrichr libraries use symbols; MSigDB also offers numeric Entrez GMTs. Map only when needed and retain the source-to-target table, failed IDs and ambiguous mappings. No casing operation constitutes identifier mapping; capitalize() can corrupt identifiers.

You haveConvert with
Ensembl gene IDs (ENSG…)gp.Biomart, g:Profiler g:Convert, or mygene
Entrez IDsmygene, g:Profiler
Mouse symbols → humang:Profiler g:Orth or another explicit orthology resource; querying MyGene with species="human" is not orthology conversion

mygene example:

import mygene
mg = mygene.MyGeneInfo()
mapping = mg.querymany(ensembl_ids, scopes="ensembl.gene",
                       fields="symbol", species="human", returnall=True)
# mapping["out"] contains query-aligned hits (or notfound); inspect dup/missing.
# Resolve one-to-many cases before extracting symbols; never silently keep first.

For versioned Ensembl IDs only, record and strip the numeric version suffix first (ENSG00000141510.16 → ENSG00000141510). The gget skill (gget info) is another quick ID-mapping path.

Raw lines 107 to 131
Names a skill gget :130
132## Organism handling
134- Human symbols are often uppercase (`TP53`), and mouse symbols often start
135 with a capital (`Trp53`); these conventions are not a conversion rule.
136- Set `organism=` for `gp.enrichr` (Enrichr) and use the matching MSigDB `dbver`
137 (`…Hs` vs `…Mm`) or g:Profiler `organism=` code.
138- Human and mouse both route to the main Enrichr instance; `organism="mouse"`
139 does not make every selected library mouse-specific. Prefer native mouse GMTs,
140 or map explicit orthologs and disclose one-to-many/lost genes. Apply the same
141 mapping to the assay universe, and resolve ranking collisions before GSEA.

Organism handling

  • Human symbols are often uppercase (TP53), and mouse symbols often start with a capital (Trp53); these conventions are not a conversion rule.
  • Set organism= for gp.enrichr (Enrichr) and use the matching MSigDB dbver (…Hs vs …Mm) or g:Profiler organism= code.
  • Human and mouse both route to the main Enrichr instance; organism="mouse" does not make every selected library mouse-specific. Prefer native mouse GMTs, or map explicit orthologs and disclose one-to-many/lost genes. Apply the same mapping to the assay universe, and resolve ranking collisions before GSEA.
Raw lines 132 to 142
143## Pathway/interaction APIs
145For raw pathway content or network context (not enrichment statistics), use the
146`database-lookup` skill, which wraps:
147- **Reactome** content + Analysis Service (submit a gene list, get pathway
148 over-representation).
149- **KEGG** pathways/compounds.
150- **STRING** — protein–protein interactions plus its own functional-enrichment
151 endpoint for a submitted gene set; pairs well with `networkx` for network views.
152- **Gene Ontology / QuickGO** term metadata.

Pathway/interaction APIs

For raw pathway content or network context (not enrichment statistics), use the database-lookup skill, which wraps:

  • Reactome content + Analysis Service (submit a gene list, get pathway over-representation).
  • KEGG pathways/compounds.
  • STRING — protein–protein interactions plus its own functional-enrichment endpoint for a submitted gene set; pairs well with networkx for network views.
  • Gene Ontology / QuickGO term metadata.
Raw lines 143 to 153
Names a skill database-lookup :146
Names a skill networkx :151
154## Activity inference
156When the goal is **pathway or TF activity** (a continuous score per sample/cell)
157rather than over-representation of a list, use `decoupler`. It runs multiple
158enrichment/activity methods (ORA, GSEA, univariate linear models, etc.) against
159curated priors:
160- **PROGENy** — 14 signaling pathway responsive signatures.
161- **DoRothEA / CollecTRI** — TF→target regulons for TF-activity inference.
162- **Hallmark** and other priors via its OmniPath integration (check resource
163 availability and license). Current decoupler uses `dc.op.progeny`,
164 `dc.op.collectri`, `dc.op.hallmark` and `dc.mt.*` method namespaces; these are
165 documentation pointers here, not runtime-tested decoupler workflows.
167decoupler integrates natively with AnnData/Scanpy (per-cell activities) and with
168per-sample pseudobulk matrices. APIs evolve between major versions — check the
169current decoupler docs (https://decoupler.scverse.org/) for exact function
170names before writing code.

Activity inference

When the goal is pathway or TF activity (a continuous score per sample/cell) rather than over-representation of a list, use decoupler. It runs multiple enrichment/activity methods (ORA, GSEA, univariate linear models, etc.) against curated priors:

  • PROGENy — 14 signaling pathway responsive signatures.
  • DoRothEA / CollecTRI — TF→target regulons for TF-activity inference.
  • Hallmark and other priors via its OmniPath integration (check resource availability and license). Current decoupler uses dc.op.progeny, dc.op.collectri, dc.op.hallmark and dc.mt.* method namespaces; these are documentation pointers here, not runtime-tested decoupler workflows.

decoupler integrates natively with AnnData/Scanpy (per-cell activities) and with per-sample pseudobulk matrices. APIs evolve between major versions — check the current decoupler docs (https://decoupler.scverse.org/) for exact function names before writing code.

Raw lines 154 to 170