{"id":48352953,"url":"https://github.com/rainoffallingstar/enrichgo","last_synced_at":"2026-04-05T10:01:54.486Z","repository":{"id":343156048,"uuid":"1176515245","full_name":"rainoffallingstar/enrichgo","owner":"rainoffallingstar","description":null,"archived":false,"fork":false,"pushed_at":"2026-03-28T08:15:01.000Z","size":16491,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2026-03-28T12:49:59.015Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/rainoffallingstar.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2026-03-09T05:06:21.000Z","updated_at":"2026-03-28T08:14:17.000Z","dependencies_parsed_at":null,"dependency_job_id":"ccbc70db-d120-4012-a0b9-48e8ac0bb2f3","html_url":"https://github.com/rainoffallingstar/enrichgo","commit_stats":null,"previous_names":["rainoffallingstar/enrichgo"],"tags_count":6,"template":false,"template_full_name":null,"purl":"pkg:github/rainoffallingstar/enrichgo","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rainoffallingstar%2Fenrichgo","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rainoffallingstar%2Fenrichgo/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rainoffallingstar%2Fenrichgo/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rainoffallingstar%2Fenrichgo/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/rainoffallingstar","download_url":"https://codeload.github.com/rainoffallingstar/enrichgo/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rainoffallingstar%2Fenrichgo/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":31431451,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-05T08:13:15.228Z","status":"ssl_error","status_checked_at":"2026-04-05T08:13:11.839Z","response_time":75,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2026-04-05T10:00:45.824Z","updated_at":"2026-04-05T10:01:54.476Z","avatar_url":"https://github.com/rainoffallingstar.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# enrichgo\n\n`enrichgo` 是一个用于 ORA / GSEA 的 Go 命令行工具，并内置与 R `clusterProfiler` 的对齐与性能对比能力。\n\n- 核心文档：[对齐流程与门禁说明](docs/alignment.md)\n- 代码结构与算法设计：[docs/README.md](docs/README.md)\n\n## 功能概览\n\n- ORA：过度富集分析（`enrich`）\n- GSEA：基因集富集分析（`gsea`）\n- 数据库缓存：KEGG / GO / Reactome / MSigDB（`download`）\n- 双实现模式：\n  - 默认 Go 实现\n  - `--use-r` 调用 R 基线（`clusterProfiler`）\n  - `--benchmark` 同时跑 Go+R 并输出时间/内存报告\n\n## 快速开始\n\n### 1) 构建\n\n```bash\ngo build -o enrichgo .\n```\n\n### 2) 下载离线数据库缓存\n\n```bash\n./enrichgo download -d kegg -s hsa -o data/\n./enrichgo download -d go -s hsa -ont BP -o data/\n```\n\n也可以把“通路数据库 + ID 映射”打包到单个 SQLite 文件（便于离线分发与复用）：\n\n```bash\n# 打包所有通路库（KEGG/GO/Reactome/MSigDB）+ 离线 ID 映射到一个文件\n./enrichgo download -d all -s hsa -ont ALL -c all --db data/enrichgo.db --db-only --idmaps --idmaps-level extended\n```\n\n说明：\n- `--idmaps-level basic`：只用 KEGG list/link（更快、更小，但覆盖可能不如 extended）\n- `--idmaps-level extended`：使用 NCBI + UniProt 官方映射（更全，但耗时/体积更大）\n\n### 3) 运行 ORA / GSEA\n\n```bash\n# ORA（Go 默认实现）\n./enrichgo enrich \\\n  -i test-data/DE_results.csv \\\n  -d go -s hsa \\\n  --fdr-col FDR --fdr-threshold 0.05 --split-by-direction=false \\\n  -o /tmp/ora_go.tsv\n\n# GSEA（Go 默认实现）\n./enrichgo gsea \\\n  -i test-data/DE_results.csv \\\n  -d kegg -s hsa \\\n  -rank-col logFC -nPerm 1000 \\\n  -o /tmp/gsea_kegg.tsv\n```\n\n默认发布二进制内置一个 SQLite 默认库（CI 构建 profile: `species=hsa`, `idmaps_level=basic`）。\n不传 `--db` 时会自动使用内置库落盘副本（可用 `ENRICHGO_DEFAULT_DB_PATH` 指定默认落盘路径）。\n\n```bash\n# 直接使用内置 SQLite（无需 --db）\n./enrichgo enrich -i test-data/DE_results.csv -d kegg -s hsa -o /tmp/ora_kegg.tsv\n./enrichgo gsea   -i test-data/DE_results.csv -d go   -s hsa -o /tmp/gsea_go.tsv\n```\n\n如果要显式指定 DB 文件，继续使用 `--db`：\n\n```bash\n./enrichgo enrich -i test-data/DE_results.csv -d kegg -s hsa --db data/enrichgo.db -o /tmp/ora_kegg.tsv\n./enrichgo gsea   -i test-data/DE_results.csv -d go   -s hsa --db data/enrichgo.db -o /tmp/gsea_go.tsv\n```\n\n如需在分析前刷新 SQLite 数据，可开启更新：\n\n```bash\n./enrichgo enrich -i test-data/DE_results.csv -d kegg -s hsa --update-db -o /tmp/ora_kegg.tsv\n./enrichgo gsea -i test-data/DE_results.csv -d go -s hsa --update-db --update-db-idmaps --update-db-idmaps-level basic -o /tmp/gsea_go.tsv\n```\n\n说明：\n- `--update-db` 不支持 `-d custom`\n- `--update-db` 成功后，该 DB 会标记为用户管理，后续不会被内置默认库自动覆盖\n\n## Go / R 运行模式\n\n### 默认 Go 实现\n\n```bash\n./enrichgo gsea -i test-data/DE_results.csv -d go -s hsa -rank-col logFC -o /tmp/go.tsv\n```\n\n### 使用 R 基线实现（clusterProfiler）\n\n```bash\n./enrichgo gsea -i test-data/DE_results.csv -d go -s hsa -rank-col logFC --use-r -o /tmp/r.tsv\n```\n\n### 同时运行 Go + R 并输出 benchmark\n\n```bash\n./enrichgo gsea \\\n  -i test-data/DE_results.csv \\\n  -d kegg -s hsa \\\n  -rank-col logFC -nPerm 100 \\\n  --benchmark \\\n  --benchmark-out /tmp/gsea_benchmark.tsv \\\n  -o /tmp/gsea_go.tsv\n```\n\nbenchmark 输出示例列：\n\n- `impl`：`go` / `r`\n- `seconds`：运行时长（秒）\n- `max_rss_kb`：峰值内存（KB）\n- `output`：对应结果文件路径\n\n### R 依赖检查（自动）\n\n在 `--use-r` 或 `--benchmark` 模式下，程序会先检查：\n\n- `Rscript` 是否可用\n- R 包是否存在：`clusterProfiler`、`org.Hs.eg.db`、`jsonlite`\n\n缺失时会直接报错退出（fail-fast）。\n\n## 常用参数\n\n- 通用：\n  - `-i` 输入文件\n  - `-o` 输出文件\n  - `-d` 数据库（`kegg/go/reactome/msigdb/custom`）\n  - `--data-dir` 缓存目录（默认 `data`）\n  - `--db` 指定 SQLite 离线包\n  - `--use-embedded-db` 未提供 `--db` 时是否使用内置默认 SQLite（默认 `true`）\n  - `--update-db` 分析前先更新目标 SQLite\n  - `--update-db-idmaps` / `--update-db-idmaps-level` 控制更新时 ID 映射刷新\n- GSEA：\n  - `-rank-col` 排名列（默认 `logFC`）\n  - `-nPerm` 置换次数（默认 `1000`）\n  - `-pvalue-method`（`simple` / `adaptive`）\n- ORA：\n  - `--fdr-col`、`--fdr-threshold`\n  - `--split-by-direction`\n- 模式切换：\n  - `--use-r`\n  - `--benchmark`\n  - `--benchmark-out`\n\n## 与 clusterProfiler 对齐与性能（最新基线）\n\n- 对齐日期：2026-03-09\n- 性能日期：2026-03-08\n- 数据集：`test-data/DE_results.csv`\n- 口径：`nPerm=1000`，Go `adaptive`（MSigDB 用 `simple`），库覆盖 KEGG+GO+Reactome+MSigDB(c7)\n\n关键产物：\n\n- 对齐汇总：`/tmp/alignment_latest_universe_fix/comparison_summary.tsv`\n- GSEA 性能汇总：`/tmp/perf_cmp/latest_alignment_perf_compare.tsv`\n- ORA 性能汇总：`/tmp/perf_cmp/latest_ora_alignment_perf_compare.tsv`\n\n### GSEA 对齐（Go vs R）\n\n| DB | go_rows | r_rows | shared | shared/go | shared/r | top20_overlap | sig_jaccard | nes_abs_err_median |\n|---|---:|---:|---:|---:|---:|---:|---:|---:|\n| kegg | 31 | 33 | 30 | 0.968 | 0.909 | 0.90 | 0.8824 | 0.017134 |\n| go | 45 | 41 | 40 | 0.889 | 0.976 | 0.80 | 0.8696 | 0.022662 |\n| reactome | 57 | 54 | 53 | 0.930 | 0.981 | 0.80 | 0.9138 | 0.015152 |\n| msigdb(c7) | 1209 | 1331 | 1191 | 0.985 | 0.895 | 0.15 | 0.8829 | 0.011145 |\n\n当前门禁剩余项：`gsea/go` 的 `nes_abs_err_median=0.022662`（阈值 `0.02`）。\n\n### GSEA 性能（Go vs R）\n\n| DB | Go时长(s) | R时长(s) | Go/R时长 | Go峰值RSS(KB) | R峰值RSS(KB) | Go/R内存 |\n|---|---:|---:|---:|---:|---:|---:|\n| kegg | 1.994 | 10.299 | 0.194x | 23200 | 531792 | 0.044x |\n| go | 6.283 | 12.696 | 0.495x | 40712 | 574968 | 0.071x |\n| reactome | 7.431 | 14.642 | 0.508x | 40744 | 593452 | 0.069x |\n| msigdb | 13.453 | 49.327 | 0.273x | 128744 | 1061608 | 0.121x |\n\n### ORA 对齐（Go vs R）\n\n| DB | go_rows | r_rows | shared | shared/go | shared/r | top20_overlap | sig_jaccard |\n|---|---:|---:|---:|---:|---:|---:|---:|\n| kegg | 15 | 11 | 11 | 0.733 | 1.000 | 0.7333 | 0.7333 |\n| go | 34 | 34 | 34 | 1.000 | 1.000 | 1.0000 | 1.0000 |\n| reactome | 9 | 8 | 8 | 0.889 | 1.000 | 0.8889 | 0.8889 |\n| msigdb(c7) | 363 | 371 | 362 | 0.997 | 0.976 | 0.9000 | 0.9731 |\n\n### ORA 性能（Go vs R）\n\n| DB | Go时长(s) | R时长(s) | Go/R时长 | Go峰值RSS(KB) | R峰值RSS(KB) | Go/R内存 |\n|---|---:|---:|---:|---:|---:|---:|\n| kegg | 0.654 | 6.787 | 0.096x | 14964 | 534540 | 0.028x |\n| go | 0.223 | 7.157 | 0.031x | 2432 | 553016 | 0.004x |\n| reactome | 0.225 | 7.562 | 0.030x | 2304 | 565948 | 0.004x |\n| msigdb | 0.436 | 18.803 | 0.023x | 56704 | 977840 | 0.058x |\n\n## CI 工作流\n\n- 对齐回归：`.github/workflows/alignment.yml`\n  - 运行 smoke + formal 对齐\n  - 执行阈值门禁\n- 性能对比：`.github/workflows/performance.yml`\n  - 运行 Go vs R benchmark（时间+内存）\n  - 上传 benchmark 工件\n\n## 仓库目录\n\n- Go 源码：`main.go`、`cmd_*.go`、`pkg/`\n- 脚本：`scripts/alignment/`\n- 文档：`docs/`\n- 数据与测试数据：`data/`、`test-data/`\n- 示例：`examples/input/`、`examples/output/`\n- 参考实现（本地保留，不纳入版本控制）：`refer-code/`\n\n## 相关文档\n\n- [docs/alignment.md](docs/alignment.md)：完整对齐流程、参数、门禁阈值\n- [docs/README.md](docs/README.md)：文档导航\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frainoffallingstar%2Fenrichgo","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frainoffallingstar%2Fenrichgo","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frainoffallingstar%2Fenrichgo/lists"}