Install any skill in seconds. Free to start, no credit card required.
Get Started Free →Gene Ontology over-representation analysis using clusterProfiler enrichGO. Use when identifying biological functions enriched in a gene list from differential expression or other analyses. Supports all three ontologies (BP, MF, CC), multiple ID types, and customizable statistical thresholds.
.claude/skills/bio-pathway-go-enrichment/SKILL.md| Test case | Without → With | Effect | Δ tokens | Δ turns |
|---|---|---|---|---|
| case-02 | ✗→✓ | ▲ Improved | — | — |
| case-17 | ✗→✓ | ▲ Improved | — | — |
| case-04 | ✓→✓ | = Same ✓ | — | — |
| case-13 | ✓→✓ | = Same ✓ | — | — |
| case-01 | ✗→✗ | = Same ✗ | — | — |
Reference examples tested with: R stats (base), clusterProfiler 4.10+
Before using code patterns, verify installed versions match. If versions differ:
packageVersion('<pkg>') then ?function_name to verify parametersIf code throws ImportError, AttributeError, or TypeError, introspect the installed package and adapt the example to match the actual API rather than retrying.
Goal: Identify enriched Gene Ontology terms in a gene list from differential expression or similar analyses.
Approach: Test for over-representation of GO terms using the hypergeometric test via clusterProfiler enrichGO.
"Run GO enrichment on my gene list" → Test whether biological process, molecular function, or cellular component terms are over-represented among significant genes.
rlibrary(clusterProfiler) library(org.Hs.eg.db) # Human - change for other organisms ego <- enrichGO( gene = gene_list, # Character vector of gene IDs OrgDb = org.Hs.eg.db, # Organism annotation database keyType = 'ENTREZID', # ID type: ENSEMBL, SYMBOL, ENTREZID, etc. ont = 'BP', # BP, MF, CC, or ALL pAdjustMethod = 'BH', # p-value adjustment method pvalueCutoff = 0.05, qvalueCutoff = 0.2 )
Goal: Extract significant gene IDs from differential expression results and convert to the format required by enrichGO.
Approach: Filter DE results by adjusted p-value and fold change, then convert gene symbols to Entrez IDs using bitr.
rlibrary(dplyr) de_results <- read.csv('de_results.csv') sig_genes <- de_results %>% filter(padj < 0.05, abs(log2FoldChange) > 1) %>% pull(gene_id) # If using gene symbols, convert to Entrez IDs gene_ids <- bitr(sig_genes, fromType = 'SYMBOL', toType = 'ENTREZID', OrgDb = org.Hs.eg.db) gene_list <- gene_ids$ENTREZID
Goal: Convert between gene identifier types (Ensembl, Symbol, Entrez) for compatibility with enrichment tools.
Approach: Use clusterProfiler bitr to map between ID types using organism annotation databases.
r# Check available key types keytypes(org.Hs.eg.db) # Convert between ID types converted <- bitr(genes, fromType = 'ENSEMBL', toType = 'ENTREZID', OrgDb = org.Hs.eg.db) # Multiple output types converted <- bitr(genes, fromType = 'SYMBOL', toType = c('ENTREZID', 'ENSEMBL'), OrgDb = org.Hs.eg.db)
Goal: Improve enrichment specificity by restricting the background to genes actually tested in the experiment.
Approach: Pass all expressed genes (not just significant ones) as the universe parameter to enrichGO.
r# Use all expressed genes as background (recommended) all_genes <- de_results$gene_id universe_ids <- bitr(all_genes, fromType = 'SYMBOL', toType = 'ENTREZID', OrgDb = org.Hs.eg.db) ego <- enrichGO( gene = gene_list, universe = universe_ids$ENTREZID, # Background gene set OrgDb = org.Hs.eg.db, keyType = 'ENTREZID', ont = 'BP', pAdjustMethod = 'BH', pvalueCutoff = 0.05 )
r# Run all ontologies at once ego_all <- enrichGO( gene = gene_list, OrgDb = org.Hs.eg.db, keyType = 'ENTREZID', ont = 'ALL', # BP, MF, and CC combined pAdjustMethod = 'BH', pvalueCutoff = 0.05 ) # Results include ONTOLOGY column head(as.data.frame(ego_all))
r# Convert Entrez IDs to gene symbols in results ego_readable <- setReadable(ego, OrgDb = org.Hs.eg.db, keyType = 'ENTREZID') # Or use readable = TRUE directly (only works with ENTREZID input) ego <- enrichGO( gene = gene_list, OrgDb = org.Hs.eg.db, keyType = 'ENTREZID', ont = 'BP', readable = TRUE # Converts to symbols )
r# View top results head(ego) # Convert to data frame results_df <- as.data.frame(ego) # Key columns: ID, Description, GeneRatio, BgRatio, pvalue, p.adjust, qvalue, geneID, Count # Export to CSV write.csv(results_df, 'go_enrichment_results.csv', row.names = FALSE) # Filter for specific criteria sig_terms <- results_df[results_df$p.adjust < 0.01 & results_df$Count >= 5, ]
Goal: Remove highly similar GO terms to reduce redundancy in enrichment results.
Approach: Cluster GO terms by semantic similarity and retain representative terms using the simplify function.
r# Remove redundant GO terms (keeps representative terms) ego_simplified <- simplify(ego, cutoff = 0.7, by = 'p.adjust', select_fun = min)
r# Mouse library(org.Mm.eg.db) ego_mouse <- enrichGO(gene = genes, OrgDb = org.Mm.eg.db, ont = 'BP') # Zebrafish library(org.Dr.eg.db) ego_zfish <- enrichGO(gene = genes, OrgDb = org.Dr.eg.db, ont = 'BP') # Yeast library(org.Sc.sgd.db) ego_yeast <- enrichGO(gene = genes, OrgDb = org.Sc.sgd.db, ont = 'BP', keyType = 'ORF')
Goal: Classify genes by broad GO slim categories for a high-level functional overview.
Approach: Use groupGO to assign genes to GO terms at a specific hierarchy level.
r# Classify genes by GO slim categories ggo <- groupGO( gene = gene_list, OrgDb = org.Hs.eg.db, ont = 'BP', level = 3, # GO hierarchy level readable = TRUE )
| Parameter | Default | Description | |-----------|---------|-------------| | gene | required | Vector of gene IDs | | OrgDb | required | Organism database | | keyType | ENTREZID | Input ID type | | ont | BP | BP, MF, CC, or ALL | | pvalueCutoff | 0.05 | P-value threshold | | qvalueCutoff | 0.2 | Q-value (FDR) threshold | | pAdjustMethod | BH | BH, bonferroni, etc. | | universe | NULL | Background genes | | minGSSize | 10 | Min genes per term | | maxGSSize | 500 | Max genes per term | | readable | FALSE | Convert to symbols |
| Case | Status | Duration (ms) | Turns | Tokens | Tool calls | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Without | With | Δ | Without | With | Δ | Without | With | Δ | Without | With | Δ | ||
case-01 | fail→fail | — | — | — | — | — | — | — | — | — | — | — | — |
case-03 | fail→fail | — | — | — | — | — | — | — | — | — | — | — | — |
case-04 | pass→pass | — | — | — | — | — | — | — | — | — | — | — | — |
case-20 | fail→fail | — | — | — | — | — | — | — | — | — | — | — | — |
case-21 | fail→fail | — | — | — | — | — | — | — | — | — | — | — | — |
case-14 | fail→fail | — | — | — | — | — | — | — | — | — | — | — | — |
case-09 | fail→fail | — | — | — | — | — | — | — | — | — | — | — | — |
case-12 | fail→fail | — | — | — | — | — | — | — | — | — | — | — | — |
case-11 | fail→fail | — | — | — | — | — | — | — | — | — | — | — | — |
case-18 | fail→fail | — | — | — | — | — | — | — | — | — | — | — | — |
case-07 | fail→fail | — | — | — | — | — | — | — | — | — | — | — | — |
case-02 | fail→pass | — | — | — | — | — | — | — | — | — | — | — | — |
case-08 | fail→fail | — | — | — | — | — | — | — | — | — | — | — | — |
case-19 | fail→fail | — | — | — | — | — | — | — | — | — | — | — | — |
case-10 | fail→fail | — | — | — | — | — | — | — | — | — | — | — | — |
case-15 | fail→fail | — | — | — | — | — | — | — | — | — | — | — | — |
case-05 | fail→fail | — | — | — | — | — | — | — | — | — | — | — | — |
case-13 | pass→pass | — | — | — | — | — | — | — | — | — | — | — | — |
case-06 | fail→fail | — | — | — | — | — | — | — | — | — | — | — | — |
case-17 | fail→pass | — | — | — | — | — | — | — | — | — | — | — | — |
case-16 | fail→fail | — | — | — | — | — | — | — | — | — | — | — | — |
case-22 | fail→fail | — | — | — | — | — | — | — | — | — | — | — | — |
DecimalAI ran this skill against gemini-3.6-flash twice over the same eval suite — once with the skill loaded and once without — and compared the two runs case by case. 22 cases were attempted. The headline lift of +9 percentage points is the difference between those two pass rates over the 22 comparable cases.
The per-case answers from this run were removed by the retention sweep, so the case table below shows the verdicts without the text either arm produced. The counts above were recorded at the time and are unaffected. Answers are now kept for 180 days.
Other measured skills in the registry, with their headline benchmark lift.