Skip to content
cccskills
FreePublished on GitHub

bio-pathway-kegg-pathways

Analyze gene lists with clusterProfiler to find KEGG pathways and modules represented more often than expected. Prepare gene identifiers, set measured genes as the comparison background, compare groups, and export results or display genes on pathway diagrams.

OriginalShow the original description

KEGG pathway and module enrichment analysis using clusterProfiler enrichKEGG and enrichMKEGG. Use when identifying metabolic and signaling pathways over-represented in a gene list. Supports 4000+ organisms via KEGG online database.

Run score Not tested

See how to install

Good for

  • Finding pathways enriched in a gene list
  • Using measured genes as the analysis background
  • Comparing pathways between increased and decreased expression
  • Exporting results and viewing pathway diagrams

Files included (4)

  • SKILL.md6.6 KB
  • examples/kegg_enrichment.R851 B
  • examples/kegg_module.R1.2 KB
  • usage-guide.md2.5 KB

SKILL.md (original)

Review the instructions the agent will receive before you install.

Version Compatibility

Reference examples tested with: R stats (base), clusterProfiler 4.10+

Before using code patterns, verify installed versions match. If versions differ:

  • R: packageVersion('<pkg>') then ?function_name to verify parameters

If code throws ImportError, AttributeError, or TypeError, introspect the installed package and adapt the example to match the actual API rather than retrying.

KEGG Pathway Enrichment

Core Pattern

Goal: Identify KEGG metabolic and signaling pathways over-represented in a gene list.

Approach: Test for enrichment using the hypergeometric test via clusterProfiler enrichKEGG against the KEGG online database.

"Find enriched KEGG pathways in my gene list" → Test whether KEGG pathway gene sets are over-represented among significant genes.

library(clusterProfiler)

kk <- enrichKEGG(
    gene = gene_list,           # Character vector of gene IDs
    organism = 'hsa',           # KEGG organism code
    pvalueCutoff = 0.05,
    pAdjustMethod = 'BH'
)

Prepare Gene List

Goal: Extract significant Entrez gene IDs from DE results in the format required by enrichKEGG.

Approach: Filter by significance thresholds and convert gene symbols to Entrez IDs (KEGG requires NCBI Entrez).

library(org.Hs.eg.db)

de_results <- read.csv('de_results.csv')
sig_genes <- de_results$gene_id[de_results$padj < 0.05 & abs(de_results$log2FoldChange) > 1]

# KEGG requires NCBI Entrez gene IDs (kegg, ncbi-geneid)
gene_ids <- bitr(sig_genes, fromType = 'SYMBOL', toType = 'ENTREZID', OrgDb = org.Hs.eg.db)
gene_list <- gene_ids$ENTREZID

KEGG ID Conversion

Goal: Convert between KEGG-specific identifiers and other gene ID formats.

Approach: Use bitr_kegg to map between kegg, ncbi-geneid, ncbi-proteinid, and uniprot ID types.

# Convert between KEGG and other IDs
kegg_ids <- bitr_kegg(gene_list, fromType = 'ncbi-geneid', toType = 'kegg', organism = 'hsa')

# Available types: kegg, ncbi-geneid, ncbi-proteinid, uniprot

Run KEGG Pathway Enrichment

Goal: Perform KEGG pathway over-representation analysis with customizable parameters.

Approach: Run enrichKEGG with specified organism, ID type, and statistical thresholds.

kk <- enrichKEGG(
    gene = gene_list,
    organism = 'hsa',
    keyType = 'ncbi-geneid',    # or 'kegg'
    pvalueCutoff = 0.05,
    pAdjustMethod = 'BH',
    minGSSize = 10,
    maxGSSize = 500
)

# View results
head(kk)
results <- as.data.frame(kk)

Make Results Readable

# enrichKEGG does NOT have readable parameter - use setReadable
library(org.Hs.eg.db)
kk_readable <- setReadable(kk, OrgDb = org.Hs.eg.db, keyType = 'ENTREZID')

KEGG Module Enrichment

Goal: Test for enrichment of KEGG modules (smaller functional units than pathways).

Approach: Use enrichMKEGG which tests against KEGG module definitions rather than full pathways.

# KEGG modules are smaller functional units than pathways
mkk <- enrichMKEGG(
    gene = gene_list,
    organism = 'hsa',
    pvalueCutoff = 0.05
)

Common Organism Codes

OrganismCodeCommon Name
hsaHumanHomo sapiens
mmuMouseMus musculus
rnoRatRattus norvegicus
dreZebrafishDanio rerio
dmeFruit flyDrosophila melanogaster
celWormC. elegans
sceYeastS. cerevisiae
athArabidopsisA. thaliana
ecoE. coli K-12
# Find organism codes
search_kegg_organism('mouse')
search_kegg_organism('zebrafish')

With Background Universe

Goal: Restrict KEGG enrichment to genes actually measured in the experiment.

Approach: Convert all tested genes to Entrez IDs and pass as the universe parameter.

all_genes <- de_results$gene_id
universe_ids <- bitr(all_genes, fromType = 'SYMBOL', toType = 'ENTREZID', OrgDb = org.Hs.eg.db)

kk <- enrichKEGG(
    gene = gene_list,
    universe = universe_ids$ENTREZID,
    organism = 'hsa',
    pvalueCutoff = 0.05
)

Extract and Export Results

Goal: Save KEGG enrichment results to CSV and extract genes belonging to specific pathways.

Approach: Convert enrichment object to data frame, export, and access pathway gene sets via the geneSets slot.

# Convert to data frame
results_df <- as.data.frame(kk)

# Key columns: ID (pathway), Description, GeneRatio, BgRatio, pvalue, p.adjust, geneID, Count

# Export
write.csv(results_df, 'kegg_enrichment_results.csv', row.names = FALSE)

# Get genes in a specific pathway
pathway_genes <- kk@geneSets[['hsa04110']]  # Cell cycle

Browse KEGG Pathways

Goal: Visualize enriched genes overlaid on KEGG pathway diagrams.

Approach: Use browseKEGG for interactive browser view or pathview to generate annotated pathway images.

# View pathway in browser (opens KEGG website)
browseKEGG(kk, 'hsa04110')

# Download pathway image
library(pathview)
pathview(gene.data = gene_list, pathway.id = 'hsa04110', species = 'hsa')

Key Parameters

ParameterDefaultDescription
generequiredVector of gene IDs
organismhsaKEGG organism code
keyTypekeggInput ID type
pvalueCutoff0.05P-value threshold
qvalueCutoff0.2Q-value threshold
pAdjustMethodBHAdjustment method
universeNULLBackground genes
minGSSize10Min genes per pathway
maxGSSize500Max genes per pathway
use_internal_dataFALSEUse local KEGG data

Compare Multiple Gene Lists

Goal: Compare KEGG pathway enrichment across multiple gene lists (e.g., upregulated vs downregulated).

Approach: Use compareCluster with enrichKEGG to run enrichment per group and visualize with dotplot.

# Compare KEGG enrichment across groups
gene_lists <- list(
    up = up_genes,
    down = down_genes
)

ck <- compareCluster(
    geneClusters = gene_lists,
    fun = 'enrichKEGG',
    organism = 'hsa'
)

dotplot(ck)

Notes

  • No readable parameter - use setReadable() with OrgDb
  • Requires internet - queries KEGG database online
  • use_internal_data - set TRUE to use cached KEGG data (may be outdated)
  • Pathway IDs - format is organism code + 5 digits (e.g., hsa04110)

Related Skills

  • go-enrichment - Gene Ontology enrichment analysis
  • gsea - GSEA using KEGG pathways (gseKEGG)
  • enrichment-visualization - Visualize KEGG results

Reviews

No reviews yet. Tell others what you thought.

Comments

No login needed. Share how it worked for you, ask a question, or note where it did not run.

No comments yet. Be the first to write one.

Comments are published right away. Do not include personal information such as email addresses or phone numbers. Up to 2 URLs.

0 / 1,000 characters

This form is protected by reCAPTCHA, and the Google Privacy Policy and Terms of Service apply.

More skills from this repository

adaptyv

FreeSummary

Support protein design with cloud laboratory testing for binding, expression, thermal stability, and enzyme activity. Covers sequence optimization, submitting experiments through the Adaptyv API, checking progress, and downloading experimental results.

  • Validate designed proteins with laboratory assays
  • Screen and redesign sequences for better solubility
  • Submit protein testing experiments through an API
FreedomIntelligence/OpenClaw-Medical-Skills3.1KUpdated Jul 21, 2026

Build flexible daily plans that account for ADHD-related difficulties with time estimation and getting started. Narrow priorities to three tasks, add transition buffers, and choose small next actions that match the energy available that day.

  • Choosing three priorities for today
  • Planning a schedule with transition buffers
  • Finding a small first step when starting feels difficult
FreedomIntelligence/OpenClaw-Medical-Skills3.1KUpdated Jul 21, 2026

aeon

FreeSummary

Build Python workflows for data recorded over time, including classification, forecasting, anomaly detection, and pattern search. Using aeon, the skill guides preprocessing, algorithm selection, feature extraction, and evaluation through interfaces compatible with scikit-learn.

  • Classify time series by their patterns
  • Forecast future values from historical data
  • Detect anomalies and change points
FreedomIntelligence/OpenClaw-Medical-Skills3.1KUpdated Jul 21, 2026

agent-browser

FreeSummary

Use a browser to research topics, extract page information, fill forms, and test websites. Guides agents through identifying page controls, interacting with web apps, saving screenshots or PDFs, and reusing saved login sessions.

  • Researching topics and reading web articles
  • Filling and submitting online forms
  • Extracting page text and links
FreedomIntelligence/OpenClaw-Medical-Skills3.1KUpdated Jul 21, 2026

ai-analyzer

FreeSummary

Combine health measurements, exercise, sleep, nutrition, and mental health records to examine trends, unusual changes, and estimated risks. The skill produces personalized suggestions and text or interactive HTML reports using local data without external API calls.

  • Review health records together in a comprehensive report
  • Explore links between sleep, mood, exercise, and weight
  • Summarize estimated disease and nutrition risks
FreedomIntelligence/OpenClaw-Medical-Skills3.1KUpdated Jul 21, 2026

alphafold

FreeSummary

Predict structures for designed protein sequences and protein complexes with AlphaFold2 or ColabFold. Inspect structure files and confidence scores to assess folding and chain interfaces, with guidance for local runs, Modal execution, and common prediction errors.

  • Check predicted folding of a designed protein sequence
  • Predict a binder–target protein complex
  • Review structure and interface confidence scores
FreedomIntelligence/OpenClaw-Medical-Skills3.1KUpdated Jul 21, 2026

See all skills by FreedomIntelligence

Report a problem with this skill