简介
专业生存分析工具,基于Kaplan-Meier方法生成发表级生存曲线,自动计算Log-rank检验、风险比及中位生存时间,适用于肿瘤临床试验与生物医学研究,但需生物统计师审核结果。
原始描述
Generates Kaplan-Meier survival curves, calculates survival statistics (log-rank test, median survival time), and estimates hazard ratios for clinical and bi...
通过你的 Agent 添加
安装目录:survival-analysis-km/(目录名取自 SKILL.md 的 frontmatter name,不是 URL 里的 slug)。
点「快速安装」复制一段指令贴给你的 Agent:它会先下载到 /tmp、把文件清单和校验值给你看,你确认之后才解压安装。不会一步装完、也不改系统其它位置。
或者手动安装
包是「根级 SKILL.md + 作者附带的文件」,解压到上面的 <slug>/ 目录即可;
目录名不用换,也不要把包直接解压到 skills 根目录。
技能申请的权限由作者决定:装之前先看清单里有没有脚本、它会读写什么。
中文使用说明 来自收录源
核心用法
该 Skill 是专为临床和生物研究设计的生存分析工具,通过 Python 脚本执行完整的生存数据分析流程。用户需提供包含生存时间、事件状态及分组变量的 CSV 数据文件,工具将自动生成 Kaplan-Meier 生存曲线、执行对数秩检验、计算 Cox 比例风险模型的风险比及置信区间,并输出可用于学术发表的统计报告。
典型工作流包括:准备标准化临床数据(患者 ID、生存月数、死亡事件标记、治疗分组)→ 调用脚本指定输入输出路径 → 获取包含 PNG/PDF 可视化图表、CSV 统计结果及人类可读报告的多格式输出。工具支持多组比较、风险表展示、中位生存时间计算等高级功能,满足从探索性分析到正式论文投稿的全流程需求。
显著优点
专业性与准确性:底层采用 lifelines 库实现 Kaplan-Meier 估计量(乘积极限法)和 Greenwood 方差公式,统计方法经学术共同体长期验证;Cox 回归自动检验比例风险假设(Schoenfeld 残差),避免模型误用。
出版级输出质量:同时生成 PNG 位图和 PDF 矢量图,支持 300 DPI 高清输出;风险表、置信区间带、分组图例等要素完整,可直接嵌入 SCI 论文而无需二次美化。
操作友好性:纯命令行交互,无需编程基础即可调用;输入格式为通用 CSV,与 Excel、R、SPSS 无缝衔接;输出包含人类可读报告,降低统计结果解读门槛。
安全与隐私:完全离线运行,零网络通信;数据仅本地读写,满足 HIPAA、GDPR 等医疗数据合规要求。
潜在缺点与局限性
技术门槛较高:虽为工具封装,但生存分析本身属于高级统计方法,用户需理解截尾数据、风险集、比例风险假设等专业概念,否则易误读结果(如将"无显著差异"等同于"治疗效果等同")。
样本量敏感性:小样本场景(<30 例/组)或高截尾率(>50%)时,估计方差增大,置信区间变宽,检验效能不足;工具虽输出警告,但无法替代生物统计学家的专业判断。
功能边界明确:专注 Kaplan-Meier 与 Cox 模型,不支持时变协变量、竞争风险模型、多状态模型等复杂生存分析场景;如需这些方法,需额外工具补充。
依赖环境要求:需预装 Python 3.x 及 lifelines、matplotlib 等科学计算库,对非技术背景用户存在环境配置障碍。
适合的目标群体
- 临床研究者:肿瘤、心血管等需要报告生存终点的临床试验人员
- 生物医学研究生:需完成生存分析课程作业或毕业论文数据分析
- 医院科研部门:开展真实世界研究(RWS)的数据分析团队
- CRO 统计师:快速生成中期分析或最终分析的可视化图表
- 生物信息学工程师:整合到自动化分析流程中的标准化生存分析模块
使用风险
统计误用风险:最主要的风险在于用户可能忽视比例风险假设检验失败、样本量不足等警告,强行解读风险比。建议在关键决策前咨询生物统计学家。
数据质量风险:工具假设输入数据已清洗(无负时间、事件标记为 0/1),若原始数据存在编码错误(如用 2 表示删失),将导致错误结果。
性能与资源风险:未限制输入文件大小,超大 CSV(百万级记录)可能引发内存溢出;建议预处理数据或分批次分析。
版本可重复性风险:依赖库更新可能改变数值计算细节,建议锁定版本并记录分析环境以确保结果可复现。
技能正文
name: survival-analysis-km description: Generates Kaplan-Meier survival curves, calculates survival statistics (log-rank test, median survival time), and estimates hazard ratios for clinical and biological survival data analysis. Triggered when user requests survival analysis, Kaplan-Meier plots, time-to-event analysis, or asks about survival statistics in biomedical contexts. version: 1.0.0 category: Bioinfo tags: [] author: AIPOCH license: MIT status: Draft risk_level: Medium skill_type: Tool/Script owner: AIPOCH reviewer: '' last_updated: '2026-02-06'
Survival Analysis (Kaplan-Meier)
Kaplan-Meier survival analysis tool for clinical and biological research. Generates publication-ready survival curves with statistical tests.
Features
- Kaplan-Meier Curve Generation: Publication-quality survival plots with confidence intervals
- Statistical Tests: Log-rank test, Wilcoxon test, Peto-Peto test
- Hazard Ratios: Cox proportional hazards regression with 95% CI
- Summary Statistics: Median survival time, restricted mean survival time (RMST)
- Multi-group Analysis: Supports 2+ comparison groups
- Risk Tables: Optional at-risk table below curves
Usage
Python Script
python scripts/main.py --input data.csv --time time_col --event event_col --group group_col --output results/
Arguments
| Argument | Description | Required |
|---|---|---|
--input |
Input CSV file path | Yes |
--time |
Column name for survival time | Yes |
--event |
Column name for event indicator (1=event, 0=censored) | Yes |
--group |
Column name for grouping variable | Optional |
--output |
Output directory for results | Yes |
--conf-level |
Confidence level (default: 0.95) | Optional |
--risk-table |
Include risk table in plot | Optional |
Input Format
CSV with columns:
- Time column: Numeric, time to event or censoring
- Event column: Binary (1 = event occurred, 0 = censored/right-censored)
- Group column: Categorical variable for stratification
Example:
patient_id,time_months,death,treatment_group
P001,24.5,1,Drug_A
P002,36.2,0,Drug_A
P003,18.7,1,Placebo
Output Files
km_curve.png: Kaplan-Meier survival curvekm_curve.pdf: Vector version for publicationssurvival_stats.csv: Statistical summary (median survival, confidence intervals)hazard_ratios.csv: Cox regression results with HR and 95% CI- `logrank_test.csv**: Pairwise comparison p-values
- `report.txt**: Human-readable summary report
Technical Details
Statistical Methods
-
Kaplan-Meier Estimator: Non-parametric maximum likelihood estimate of survival function
- Product-limit estimator: Ŝ(t) = Π(tᵢ≤t) (1 - dᵢ/nᵢ)
- Greenwood's formula for variance estimation
-
Log-Rank Test: Most widely used test for comparing survival curves
- Null hypothesis: No difference between groups
- Weighted by number at risk at each event time
-
Cox Proportional Hazards: Semi-parametric regression model
- h(t|X) = h₀(t) × exp(β₁X₁ + β₂X₂ + ...)
- Proportional hazards assumption checked via Schoenfeld residuals
Dependencies
lifelines: Core survival analysis librarymatplotlib,seaborn: Visualizationpandas,numpy: Data handlingscipy: Statistical tests
Technical Difficulty: High ⚠️
This skill involves advanced statistical modeling. Results should be reviewed by a biostatistician, especially for:
- Proportional hazards assumption violations
- Small sample sizes (< 30 per group)
- Heavy censoring (> 50%)
- Time-varying covariates
References
See references/ folder for:
- Kaplan EL, Meier P (1958) original paper
- Cox DR (1972) regression models paper
- Sample datasets for testing
- Clinical reporting guidelines (ATN, CONSORT)
Parameters
| Parameter | Type | Default | Description |
|---|---|---|---|
--input |
str | Required | Input CSV file path |
--time |
str | Required | Column name for survival time |
--event |
str | Required | |
--group |
str | Required | |
--output |
str | Required | Output directory for results |
--conf-level |
float | 0.95 | |
--risk-table |
str | Required | Include risk table in plot |
--figsize |
str | '10 | |
--dpi |
int | 300 |
Example
# Basic survival curve
python scripts/main.py \
--input clinical_data.csv \
--time overall_survival_months \
--event death \
--group treatment_arm \
--output ./results/ \
--risk-table
Output includes:
- Survival curves with 95% confidence bands
- Median survival: Drug A = 28.4 months (95% CI: 24.1-32.7), Placebo = 18.2 months (95% CI: 15.3-21.1)
- Log-rank test p-value: 0.0023
- Hazard ratio: 0.62 (95% CI: 0.45-0.85), p = 0.003
Risk Assessment
| Risk Indicator | Assessment | Level |
|---|---|---|
| Code Execution | Python/R scripts executed locally | Medium |
| Network Access | No external API calls | Low |
| File System Access | Read input files, write output files | Medium |
| Instruction Tampering | Standard prompt guidelines | Low |
| Data Exposure | Output files saved to workspace | Low |
Security Checklist
- No hardcoded credentials or API keys
- No unauthorized file system access (../)
- Output does not expose sensitive information
- Prompt injection protections in place
- Input file paths validated (no ../ traversal)
- Output directory restricted to workspace
- Script execution in sandboxed environment
- Error messages sanitized (no stack traces exposed)
- Dependencies audited
Prerequisites
# Python dependencies
pip install -r requirements.txt
Evaluation Criteria
Success Metrics
- Successfully executes main functionality
- Output meets quality standards
- Handles edge cases gracefully
- Performance is acceptable
Test Cases
- Basic Functionality: Standard input → Expected output
- Edge Case: Invalid input → Graceful error handling
- Performance: Large dataset → Acceptable processing time
Lifecycle Status
- Current Stage: Draft
- Next Review Date: 2026-03-06
- Known Issues: None
- Planned Improvements:
- Performance optimization
- Additional feature support
正文来自原始发布页, 版权归作者所有,许可未标注。 权利人认为有不妥,可申请下架。