Kaplan-Meier survival analysis with log-rank tests, Cox regression, and publication-ready survival curves for clinical and biological research.
77
72%
Does it follow best practices?
Impact
Pending
No eval scenarios have been run
Passed
No known issues
Optimize this skill with Tessl
npx tessl skill review --optimize ./scientific-skills/Data analysis/survival-analysis-km/SKILL.mdKaplan-Meier survival analysis tool for clinical and biological research. Generates publication-ready survival curves with statistical tests and hazard ratios.
python -m py_compile scripts/main.py
pip install lifelines && python scripts/main.py --helpNote: The
lifelinespackage is required. Install it before running:pip install lifelines
python scripts/main.py \
--input clinical_data.csv \
--time overall_survival_months \
--event death \
--group treatment_arm \
--output ./results/ \
--risk-table| Parameter | Required | Default | Description |
|---|---|---|---|
--input | Yes | — | Input CSV file path |
--time | Yes | — | Column name for survival time |
--event | Yes | — | Event indicator column (1=event, 0=censored) |
--group | No | — | Grouping variable for stratification |
--output | Yes | — | Output directory for results |
--conf-level | No | 0.95 | Confidence level |
--risk-table | No | False | Include at-risk table in plot |
--dpi | No | 300 | Output figure resolution |
CSV with required columns:
patient_id,time_months,death,treatment_group
P001,24.5,1,Drug_A
P002,36.2,0,Drug_A
P003,18.7,1,Placebokm_curve.png / km_curve.pdf — Survival curves with 95% CIsurvival_stats.csv — Median survival and confidence intervalshazard_ratios.csv — Cox regression results with HR and 95% CIlogrank_test.csv — Pairwise comparison p-valuesreport.txt — Human-readable summary--group is not provided: emit "Note: No group column specified — log-rank test and Cox regression skipped. Single-arm KM only." before proceeding.scripts/main.py with available inputs, or use the documented reasoning path.If scripts/main.py cannot run (missing lifelines, missing inputs), respond with:
FALLBACK REPORT
───────────────────────────────────────
Objective : <stated goal>
Blocked by : <exact missing input or error>
Partial result : <what can still be assessed manually>
Next step : pip install lifelines OR provide missing column names
───────────────────────────────────────High-risk scenarios requiring biostatistician review:
Every response must make these explicit when relevant:
scripts/main.py fails, report the failure point, summarize what can still be completed safely, and provide the manual fallback above.This skill accepts: CSV datasets with time-to-event and event indicator columns for Kaplan-Meier survival analysis and Cox regression.
If the request does not involve survival analysis — for example, asking to perform logistic regression, ROC curve analysis, general linear modeling, or time-varying covariate analysis — do not proceed. Instead respond:
"survival-analysis-km is designed for Kaplan-Meier survival analysis and Cox regression. Your request appears to be outside this scope. Please provide a dataset with time and event columns, or use a more appropriate tool for your task. For time-varying covariate analysis, consider the
survivalpackage in R."
Use this fixed structure for non-trivial requests:
For simple requests, compress the structure but keep assumptions and limits explicit when they affect correctness.
pip install -r requirements.txt
# Requires: lifelines, matplotlib, seaborn, pandas, numpy, scipyca9aaa4
If you maintain this skill, you can claim it as your own. Once claimed, you can manage eval scenarios, bundle related skills, attach documentation or rules, and ensure cross-agent compatibility.