{"data":{"slug":"github-aipoch-medical-research-skills-awesome-med-research-skills-data-analysis-gokegg-83e15e93d51d","title":"GO and KEGG Enrichment Analysis for Gene Lists from Bulk RNA-seq or Microarray Studies","summary":"Perform GO and KEGG enrichment analysis on gene lists from bulk RNA-seq or microarray studies and generate a combined dot chart. The analysis supports gene lists provided as comma-separated values, with trimming of spaces and compatibility with gene ID types such as SYMBOL, ENSEMBL, and ENTREZID.","url":"https:\/\/skillshunter.net\/skills\/github-aipoch-medical-research-skills-awesome-med-research-skills-data-analysis-gokegg-83e15e93d51d","json_url":"https:\/\/skillshunter.net\/api\/public\/v1\/skills\/github-aipoch-medical-research-skills-awesome-med-research-skills-data-analysis-gokegg-83e15e93d51d","markdown_url":"https:\/\/skillshunter.net\/skills\/github-aipoch-medical-research-skills-awesome-med-research-skills-data-analysis-gokegg-83e15e93d51d.md","download_url":"https:\/\/skillshunter.net\/skills\/github-aipoch-medical-research-skills-awesome-med-research-skills-data-analysis-gokegg-83e15e93d51d\/download","category":{"slug":"data-research","name":"Data & Research"},"editor_note":"Ensure the gene ID type matches `--gene_type` and that the species database (`--sp`) is one of `org.Hs.eg.db`, `org.Mm.eg.db`, or `org.Rn.eg.db`. The first deliverable is the parsed gene count after trimming and parsing, which is reported in the output.","instructions":"---\nname: gokegg-analysis\ndescription: Use when performing GO and KEGG enrichment on a gene list from bulk RNA-seq or microarray studies, then generating a combined GO\/KEGG dot chart. NOT for single-cell RNA-seq, methylation data, or non-expression data.\nlicense: MIT\nauthor: AIPOCH\n---\n> **Source**: [https:\/\/github.com\/aipoch\/medical-research-skills](https:\/\/github.com\/aipoch\/medical-research-skills)\n\n## When To Read External Files\n\n| Situation | File To Read | Purpose |\n|---|---|---|\n| Need algorithm details | `references\/algorithm.md` | Statistical methods and formulas |\n| Need to run the analysis | `scripts\/main.R` | Full execution command |\n| Encounter an error | `references\/troubleshooting.md` | Troubleshooting guidance |\n| Need CLI examples | `references\/cli-guide.md` | Parameter usage examples |\n\n## When To Use\n\nUse this skill for:\n- GO and KEGG enrichment from a gene list derived from bulk RNA-seq or microarray studies\n- Supported gene ID types: `SYMBOL`, `ENSEMBL`, `ENTREZID`\n- Supported species databases: `org.Hs.eg.db`, `org.Mm.eg.db`, `org.Rn.eg.db`\n\nDo not use this skill for:\n- Single-cell RNA-seq analysis\n- Methylation, proteomics, or non-expression omics workflows\n- Differential expression testing from raw count matrices\n\n## Usage\n\nMain analysis and plotting:\n`Rscript scripts\/main.R --feature \"TP53,EGFR,BRCA1,MYC\" --output_dir .\/output --sp org.Hs.eg.db --gene_type SYMBOL --pvalue_cutoff 0.05 --qvalue_cutoff 0.2 --pAdjustMethod BH --seed 66 --go_top_n 3 --kegg_top_n 3 --format pdf`\n\nNotes:\n- `scripts\/main.R` is the only command-line entry point\n- `scripts\/dochart.R` currently provides plotting functions and is sourced by `scripts\/main.R`\n- If `--go_input`, `--kegg_input`, or `--outdir` are omitted, `main.R` uses `output_dir\/temp\/GO_list.rda`, `output_dir\/temp\/KEGG_list.rda`, and `output_dir\/plot` automatically\n\n## Agent Output\n\nOn success, the agent should report:\n- Whether GO enrichment completed successfully\n- Whether KEGG enrichment completed successfully\n- The normalized input gene count after trimming and parsing\n- The main output directory\n- The generated files, especially `GO_df.csv`, `KEGG_df.csv`, `GO_list.rda`, `KEGG_list.rda`, and the combined dot chart\n- The path to `session_info.txt`\n\nPost-run checklist:\n- Re-parse the original `--feature` string using the documented separator rules and report the deduplicated gene count after trimming\n- Check `temp\/GO_df.csv` and `temp\/GO_list.rda` before claiming GO success\n- Check `temp\/KEGG_df.csv` and `temp\/KEGG_list.rda` before claiming KEGG success\n- Check `plot\/gokegg_dot_chart.<format>`, `plot\/gokegg_dot_chart_data.csv`, `plot\/gokegg_dot_chart_data.rda`, and `session_info.txt` before claiming full success\n- Summarize the final result with: parsed gene count, GO status, KEGG status, plot status, output directory, and key output files\n\nOn failure, the agent should report:\n- The exact `SKILL_*` error code\n- The failing step, such as gene parsing, ID conversion, enrichment, or plotting\n- The actionable next step, such as fixing input IDs, checking missing packages, or regenerating `.rda` files\n\n## Parameter Reference\n\n### `scripts\/main.R`\n\n| Short | Long | Type | Default | Required | Description |\n|---|---|---|---|---|---|\n| `-f` | `--feature` | character | `\"\"` | Yes | Gene list separated by commas, Chinese commas, semicolons, tabs, or newlines |\n| `-o` | `--output_dir` | character | `.\/output\/` | No | Main output directory |\n| `-s` | `--sp` | character | `org.Hs.eg.db` | No | Species database |\n| `-g` | `--gene_type` | character | `SYMBOL` | No | Input gene ID type |\n| `-p` | `--pvalue_cutoff` | numeric | `0.05` | No | Enrichment p-value cutoff |\n| `-q` | `--qvalue_cutoff` | numeric | `0.2` | No | Enrichment q-value cutoff |\n| `-m` | `--pAdjustMethod` | character | `BH` | No | P-value adjustment method |\n|  | `--seed` | integer | `66` | No | Random seed |\n|  | `--go_input` | character | `NULL` | No | Optional GO `.rda`; defaults to `output_dir\/temp\/GO_list.rda` |\n|  | `--kegg_input` | character | `NULL` | No | Optional KEGG `.rda`; defaults to `output_dir\/temp\/KEGG_list.rda` |\n|  | `--outdir` | character | `NULL` | No | Plot output directory; defaults to `output_dir\/plot` |\n|  | `--go_top_n` | numeric | `3` | No | Top GO terms per ontology |\n|  | `--kegg_top_n` | numeric | `3` | No | Top KEGG pathways |\n| `-w` | `--width` | numeric | `20` | No | Plot width in cm |\n|  | `--height` | numeric | `16` | No | Plot height in cm |\n|  | `--format` | character | `pdf` | No | Plot format: `pdf`, `png`, `svg` |\n|  | `--dpi` | numeric | `300` | No | DPI for raster output |\n| `-c` | `--colors` | character | `#E41A1C,#FFFF33,#2E86AB,#4DAF4A` | No | Colors for `GO:BP,GO:CC,GO:MF,KEGG` |\n|  | `--title` | character | `GO + KEGG Dot Chart` | No | Plot title |\n|  | `--xlab` | character | `NULL` | No | Horizontal axis label override |\n|  | `--ylab` | character | `NULL` | No | Vertical axis label override |\n|  | `--dot_size` | numeric | `4.5` | No | Dot size |\n|  | `--shape` | numeric | `19` | No | Dot shape |\n|  | `--rotate` \/ `--no-rotate` | logical flag | `TRUE` | No | Rotate plot orientation on or off |\n|  | `--sorting` | character | `descending` | No | Dot sorting order |\n|  | `--label_width` | numeric | `35` | No | Label wrap width |\n|  | `--title_size` | numeric | `12` | No | Title font size |\n|  | `--axis_title_size` | numeric | `9` | No | Axis title font size |\n|  | `--axis_text_size` | numeric | `8` | No | Axis text font size |\n|  | `--legend_title_size` | numeric | `8` | No | Legend title font size |\n|  | `--legend_text_size` | numeric | `7` | No | Legend text font size |\n|  | `--legend_position` | character | `top` | No | Legend position |\n|  | `--plot_margin` | character | `10,10,10,10` | No | Plot margins: top,right,bottom,left |\n|  | `--axis_line_size` | numeric | `0.5` | No | Axis line width |\n|  | `--axis_ticks_size` | numeric | `0.5` | No | Axis tick width |\n|  | `--show_grid` | logical | `FALSE` | No | Show grid lines |\n| `-v` | `--verbose` | logical | `FALSE` | No | Enable verbose logging |\n\n## Input Format\n\n### Main Analysis Input\n- `--feature` should be provided as a gene list\n- Preferred separator: comma\n- Also accepted: Chinese commas, semicolons, tabs, and newlines\n- Leading and trailing spaces around each gene are removed automatically with trimming\n- The gene ID type must match `--gene_type`\n- `--sp` supports only `org.Hs.eg.db`, `org.Mm.eg.db`, and `org.Rn.eg.db`\n\nExamples:\n`TP53,EGFR,BRCA1,MYC`\n\n`TP53, EGFR, BRCA1, MYC`\n\n`TP53\uff1bEGFR\uff1bBRCA1\uff1bMYC`\n\n`TP53\\nEGFR\\nBRCA1\\nMYC`\n\nExample command with minimal input:\n`Rscript scripts\/main.R --feature \"TP53,EGFR,BRCA1,MYC\" --output_dir .\/example_output --sp org.Hs.eg.db --gene_type SYMBOL`\n\nExample command with custom plotting parameters:\n`Rscript scripts\/main.R --feature \"TP53,EGFR,BRCA1,MYC\" --output_dir .\/example_plot_output --sp org.Hs.eg.db --gene_type SYMBOL --go_top_n 5 --kegg_top_n 8 --colors \"#E41A1C,#FFFF33,#2E86AB,#4DAF4A\" --title \"Custom GO + KEGG Dot Chart\" --xlab=\"-log10(adjusted p-value)\" --ylab=\"Enriched Terms\" --width 24 --height 18 --label_width 40 --format png --dpi 300 --no-rotate --verbose`\n\nNote: values passed to `--xlab` or `--ylab` that start with `-` should use `--option=value` syntax to avoid being parsed as flags.\n\nNote: separator variants are supported only when they are passed inside a single `--feature` argument value.\n\n### Plot Input\n- Plotting is triggered by `scripts\/main.R`\n- `--go_input`: optional `.rda` file containing a `GO_list` object\n- `--kegg_input`: optional `.rda` file containing a `KEGG_list` object\n- If not provided, `main.R` uses the newly generated files under `output_dir\/temp`\n- Plotting requires result tables with at least `Description` and `p.adjust`\n\n## Output Files\n\n| File Name | Format | Description |\n|---|---|---|\n| `temp\/GO_df.csv` | CSV | GO enrichment result table |\n| `temp\/GO_list.rda` | RDA | Full GO enrichment object |\n| `temp\/KEGG_df.csv` | CSV | KEGG enrichment result table |\n| `temp\/KEGG_list.rda` | RDA | Full KEGG enrichment object |\n| `plot\/gokegg_dot_chart.pdf` etc. | PDF\/PNG\/SVG | Combined GO\/KEGG dot chart |\n| `plot\/gokegg_dot_chart_data.csv` | CSV | Combined plotting table used for the figure |\n| `plot\/gokegg_dot_chart_data.rda` | RDA | Plot bundle with plotting data and parameters |\n| `session_info.txt` | TXT | Runtime session information |\n\n## Error Handling\n\nCommon error codes and fixes:\n- `SKILL_FILE_NOT_FOUND`: Input file does not exist; check the path and permissions\n- `SKILL_FILE_FORMAT_ERROR`: `.rda` cannot be read or is malformed; regenerate upstream results\n- `SKILL_MISSING_COLUMNS`: Result table is missing `Description` or `p.adjust`\n- `SKILL_EMPTY_DATA`: Input genes are empty after parsing, cannot be converted, or enrichment results are empty\n- `SKILL_INVALID_PARAMETER`: Required parameter missing, unsupported species, or insufficient color count\n- `SKILL_PACKAGE_NOT_FOUND`: Required package is not installed\n- `SKILL_ANALYSIS_FAILED`: Internal GO\/KEGG enrichment failure; verify `gene_type`, `sp`, and input genes\n\nFor detailed troubleshooting, read `references\/troubleshooting.md`.\n\n## Testing\n\nMinimal test dataset: use a small built-in gene list directly, with no extra files required.\n\nSmoke test command:\n`Rscript scripts\/main.R --feature \"TP53,EGFR,BRCA1,MYC\" --output_dir .\/test_output --sp org.Hs.eg.db --gene_type SYMBOL --pvalue_cutoff 0.05 --qvalue_cutoff 0.2 --pAdjustMethod BH --seed 66 --go_top_n 3 --kegg_top_n 3 --format pdf --verbose`\n\nExpected smoke-test outputs:\n- `.\/test_output\/temp\/GO_list.rda`\n- `.\/test_output\/temp\/KEGG_list.rda`\n- `.\/test_output\/temp\/GO_df.csv`\n- `.\/test_output\/temp\/KEGG_df.csv`\n- `.\/test_output\/plot\/gokegg_dot_chart.pdf`\n- `.\/test_output\/plot\/gokegg_dot_chart_data.csv`\n- `.\/test_output\/plot\/gokegg_dot_chart_data.rda`\n- `.\/test_output\/session_info.txt`\n- Exit status code `0`\n\nAutomated regression script:\n`Rscript test\/test_regressions.R`\n\nThe regression script covers:\n- Separator parsing with comma, Chinese semicolon, newline, tab, and mixed separators\n- Empty parsed-gene handling\n- Invalid `--plot_margin` validation\n- Plot input validation for missing GO\/KEGG inputs\n\nSeparator examples for manual CLI verification:\n`Rscript scripts\/main.R --feature \"TP53,EGFR,BRCA1,MYC\" --output_dir .\/test_sep_comma`\n`Rscript scripts\/main.R --feature \"TP53\uff1bEGFR\uff1bBRCA1\uff1bMYC\" --output_dir .\/test_sep_cn_semicolon`\n`Rscript scripts\/main.R --feature $'TP53\\nEGFR\\nBRCA1\\nMYC' --output_dir .\/test_sep_newline`\n`Rscript scripts\/main.R --feature $'TP53\\tEGFR\\tBRCA1\\tMYC' --output_dir .\/test_sep_tab`\n`Rscript scripts\/main.R --feature $'TP53\uff1b EGFR, BRCA1\tMYC' --output_dir .\/test_sep_mixed`\n\nNote: all separators must be passed inside a single `--feature` argument value.","use_cases":["Analyzing gene lists from bulk RNA-seq or microarray studies for biological pathway enrichment","Generating a combined GO\/KEGG dot chart for visual interpretation of enrichment results"],"limitations":[],"compatibility":[],"setup_tip":null,"sample_input":null,"sample_output":null,"source_url":"https:\/\/github.com\/aipoch\/medical-research-skills\/blob\/686e09dfdb45d9fa1a08664f06bb93769b3c9d91\/awesome-med-research-skills\/Data%20Analysis\/gokegg\/SKILL.md","source_commit":"686e09dfdb45d9fa1a08664f06bb93769b3c9d91","license":"MIT","version":null,"listing_approved_at":"2026-11-24","created_at":"2026-11-23T07:10:04.000000Z","updated_at":"2026-11-24T07:13:04.000000Z","seo_title":"GO and KEGG Enrichment Analysis for Gene Lists from Bulk RNA-seq or Ex","seo_description":"Perform GO and KEGG enrichment analysis on gene lists from bulk RNA-seq or microarray studies and generate a combined dot chart. Supports gene lists with various delimit","seo_keywords":["GO enrichment analysis","KEGG pathway analysis","gene list enrichment","RNA-seq pathway analysis","bulk RNA-seq analysis"]}}