Agent Skills

Gsea

AIPOCH

对按统计量排序的基因列表执行 GSEA 分析,输出富集结果表、运行分数表和绘图结果。

11
0
FILES
gsea/
skill.md
scripts
functions.R
main.R
plot_functions.R
run_analysis.R
utils.R
references
algorithm.md
cli-guide.md
troubleshooting.md
assets
ssGSEA.rds
90100Total Score
View Evaluation Report
Core Capability
91 / 100
Functional Suitability
12 / 12
Reliability
11 / 12
Performance & Context
7 / 8
Agent Usability
14 / 16
Human Usability
6 / 8
Security
12 / 12
Maintainability
11 / 12
Agent-Specific
18 / 20
Medical Task
24 / 24 Passed
94Human KEGG analysis
5/5
92Hallmarks via RDS
5/5
76Invalid gene column
4/4
93Plot top three pathways
5/5
91Conflicting mode inputs
5/5

SKILL.md

何时读取外部文件

情况读取文件目的
需要了解算法细节references/algorithm.md统计方法与公式
需要执行分析scripts/main.R获取完整命令
遇到报错references/troubleshooting.md查找解决方案
需要 CLI 示例references/cli-guide.md参数用法示例

适用场景

适用于:

  • 对按统计量排序的基因列表执行 GSEA 分析
  • 基于已有 enrichGSEA.csvgsea_running_scores.csv 生成富集曲线图
  • 使用 tests/data/sample_deg_results.csv 做最小可运行验证

不适用于:

  • 原始表达矩阵的差异分析
  • 单样本 ssGSEA
  • 网络分析或多组学整合分析

使用方法

分析模式: Rscript scripts/main.R --input tests/data/sample_deg_results.csv --outdir ./GSEA_analysis --type KEGG --species human --seed 42 --timeout 300

绘图模式: Rscript scripts/main.R --running_file ./GSEA_analysis/Table/gsea_running_scores.csv --enrich_file ./GSEA_analysis/Table/enrichGSEA.csv --plot_output ./GSEA_analysis/plot/gsea_plot.pdf --top_n 5 --plot_format pdf --seed 42 --timeout 300

说明:详见 references/cli-guide.md

模式选择说明:

  • 仅提供 --input 时进入分析模式
  • 同时提供 --running_file--enrich_file 时进入绘图模式
  • 若同时提供分析参数与绘图参数,则绘图模式优先,分析模式会被跳过,并输出警告信息

参数说明

分析模式参数

短参数长参数类型默认值是否必填说明
-i--inputcharacterNULL输入 CSV 文件
-o--outdircharacterGSEA_analysis输出目录
-g--gene_colcharactername基因列名
-f--fc_colcharacterlogFC排序统计量列名
-t--typecharacterKEGG基因集类型:KEGGHALLMARKSGO_BPGO_MFGO_CC;预载 RDS 中会自动将 HALLMARKS 映射到资产键 Hallmarks
-s--speciescharacterhuman物种:humanmouserat
-p--pvalue_cutoffnumeric0.05显著性阈值
-m--methodcharacterfgseaGSEA 方法:fgseaDOSE
-c--chunk_sizenumeric1000大基因集转换时的分块大小
-r--rds_pathcharacterNULL预存基因集 RDS 路径
-v--verboselogicalFALSE输出详细日志
--seedinteger42随机种子
--timeoutinteger300超时秒数,<=0 表示不限制
-h--helplogicalFALSE显示帮助

绘图模式参数

短参数长参数类型默认值是否必填说明
--running_filecharacterNULLgsea_running_scores.csv 路径
--enrich_filecharacterNULLenrichGSEA.csv 路径
--plot_outputcharactergsea_plot.pdf输出图文件路径
--plot_widthnumeric8图宽
--plot_heightnumeric6图高
--plot_formatcharacterpdf输出格式:pdfpng
--top_nnumeric1未指定 geneSetID 时绘制前 N 条通路
--rank_bycharacterp.adjust通路排序列
--geneSetIDcharacter""逗号分隔的通路 ID
--plot_titlecharacter""图标题
--colorscharacter#4DBBD5,#E64B35,#00A087,#F39B7F,#3C5488,#8491B4颜色列表
--base_sizenumeric11基础字号
--subplotscharacter1,2,3显示子图编号
--rel_heightscharacter1.5,0.8,1子图高度比例
--NES_tablelogicalTRUE显示 NES 注释
--no_NES_tablelogicalFALSE关闭 NES 注释
--NES_label_sizenumeric4NES 注释字号
--NES_label_xnumeric0.75NES 注释横向位置
--NES_label_ynumeric0.75NES 注释纵向位置
--NES_label_colorcharacterblackNES 注释颜色
--NES_label_hjustnumeric0NES 注释水平对齐
--NES_label_vjustnumeric1NES 注释垂直对齐
--line_widthnumeric1ES 线宽
--dot_sizenumeric1.2ES 点大小
--legend_positioncharacterauto图例位置
--legend_xnumeric0.02内嵌图例横坐标
--legend_ynumeric0.02内嵌图例纵坐标
--legend_just_xnumeric0图例横向对齐
--legend_just_ynumeric0图例纵向对齐
--legend_text_sizenumeric9图例文字大小
--legend_key_sizenumeric0.6图例键大小
--legend_bg_alphanumeric0图例背景透明度
--grid_major_colorcharactergrey92主网格颜色
--grid_minor_colorcharactergrey92次网格颜色
--ylab_escharacterEnrichment ScoreES 面板纵轴标题
--ylab_rankcharacterRanked List Metric排名面板纵轴标题
--xlab_rankcharacterRank in Ordered Dataset排名面板横轴标题
--hit_heightnumeric1命中条高度
--hit_gapnumeric0命中条间距
--hit_linewidthnumeric0.5命中条线宽
--rank_bar_alphanumeric0.9排名条透明度
--rank_bar_height_rationumeric0.3排名条高度比例
--rank_metric_segment_colorcharactergrey排名线颜色
--rank_metric_segment_widthnumeric0.3排名线宽
--rank_metric_segment_alphanumeric1排名线透明度
--pvalue_tablelogicalFALSE显示 P 值表
--ES_geomcharacterlineES 绘制方式:linedot
--verboselogicalFALSE输出详细日志
--seedinteger42随机种子
--timeoutinteger300超时秒数,<=0 表示不限制
-h--helplogicalFALSE显示帮助

输入格式

分析模式输入为 CSV 文件,至少包含两列:

  • 基因列,默认列名为 name
  • 排序统计量列,默认列名为 logFC

示例:

name,logFC,pvalue,padj
TP53,2.5,0.001,0.01
BRCA1,1.8,0.005,0.02
EGFR,-1.2,0.01,0.05

取值约束:

  • type 支持 KEGGHALLMARKSGO_BPGO_MFGO_CC
  • 当使用预载 RDS 时,HALLMARKS 会自动匹配资产中的 Hallmarks 键名
  • species 支持 humanmouserat

输出文件

文件名格式内容说明
data/GSEA_list.rdaRDA完整 GSEA 结果对象
Table/enrichGSEA.csvCSV富集结果表
Table/gsea_running_scores.csvCSV运行分数表;若无富集结果则输出空表头文件
plot/directory绘图输出目录
session_info.txtTXTR 版本与包版本信息

enrichGSEA.csv 主要包含:IDDescriptionNESpvaluep.adjustcore_enrichment

错误处理

常见错误码:

  • SKILL_FILE_NOT_FOUND:输入文件不存在
  • SKILL_MISSING_COLUMNS:缺少必要列
  • SKILL_EMPTY_DATA:输入数据为空或过滤后为空
  • SKILL_INVALID_PARAMETER:参数值不合法
  • SKILL_PACKAGE_NOT_FOUND:依赖包未安装
  • SKILL_ANALYSIS_FAILED:分析重试后仍失败

排查文档:references/troubleshooting.md

退出状态码:

  • 0:运行成功
  • 1:运行失败

测试方法

最小测试数据集:tests/data/sample_deg_results.csv

最小运行命令: Rscript scripts/main.R --input tests/data/sample_deg_results.csv --outdir ./test_output --type KEGG --species human --seed 42 --timeout 300 --verbose

预期输出:

  • ./test_output/data/GSEA_list.rda
  • ./test_output/Table/enrichGSEA.csv
  • ./test_output/Table/gsea_running_scores.csv
  • ./test_output/session_info.txt
  • 若无显著富集结果,gsea_running_scores.csv 仍会生成,但只包含表头
  • 退出状态码为 0