Logo: Km Survival Curve

Km Survival Curve

OrganisatiounBeléift
aipoch
km-survival-curve

Use when generating Kaplan-Meier survival curves from tabular survival data containing time, event status, and a precomputed risk group. Supports command-line parameter input, parameter validation, automatic time-unit handling, single-file PDF figure export, and session metadata capture.

Iwwersiicht

Editeuraipoch
Repositorymedical-research-skills
Skill-Nummkm-survival-curve
Stären
1.9K
Forks
175
Matgeliwwert Dateien
12
LizenzMIT
Linken
  • Instruktiounen am Markdown-Format

    Eng SKILL.md-Datei, déi de Modell bei Bedarf luet, soudatt nëmmen Token ufalen, wann eng Ufro tatsächlech dozou passt.

  • Funktionéiert mat all LLM

    KI-Skills si reng Markdown, keen ubidderspezifesche Code. Dofir funktionéiert dëse Skill mat GPT, Claude, Gemini, Grok oder engem lokale Modell.

  • 12 matgeliwwert Dateien

    Skripten, Virlagen a Referenzen, déi de Modell beim Schaffe liese kann. D'Dateie kënnen nëmme gelies ginn a ginn ni ausgeféiert.

  • Open Source

    aipoch huet de Skill op GitHub verëffentlecht. Liest de Quelltext, ier Dir de Skill installéiert.

Installatioun

Installéiert de KI-Skill Km Survival Curve an TypingMind, fir e mat all LLM ze benotzen, oder setzt en an en anere KI-Agent an, deen SKILL.md liest.

1

An TypingMind installéieren

TypingMind installéiert e Skill direkt aus sengem GitHub-Dossier — dobäi gëtt SKILL.md gelies, d'Ressourcedateie gi gebëndelt an d'Resultat gëtt lokal gespäichert.

  1. Maacht d'App op a gitt op Plugins → Skills.
  2. Wielt „Vu GitHub installéieren“.
  3. Pecht d'URL vum Skill-Dossier, déi hei drënner steet, an a bestätegt d'Installatioun.
    https://github.com/aipoch/medical-research-skills/tree/main/awesome-med-research-skills/Data%20Analysis/km-survival-curve
  4. Aktivéiert de Skill an all Chat, an deem Dir e benotze wëllt.
Plugins → Skills → Skill derbäisetzen → Iwwer eng GitHub-URL. Pecht dann d'URL vum Dossier an a klickt op Weider.

An TypingMind benotzen

Aktivéiert Km Survival Curve an engem Chat vun TypingMind, an de Modell iwwerhëlt de Rescht. Den Numm an d'Beschreiwung stinn am System-Prompt. Soubal eng Ufro dozou passt, luet de Modell déi komplett Instruktioune selwer — Dir musst de Skill ni manuell opruffen, an et fale keng Token un, bis en tatsächlech benotzt gëtt.

De Modell luet Km Survival Curve automatesch, soubal eng Ufro dozou passt.

Funktionéiert mat all KI-Modell

KI-Skills si reng Markdown-Instruktiounen amplaz vun ubidderspezifeschem Code. Dofir ass Km Survival Curve net un de Modell gebonnen, fir deen de Skill geschriwwe gouf. Installéiert en eemol an TypingMind a benotzt e mat GPT-5, Claude, Gemini, Grok, DeepSeek, Mistral, Llama oder engem lokale Modell, deen Dir selwer bedreift — alles mat Ären eegenen API-Schlësselen.

  • Gëtt nëmme gelueden, wann et néideg ass

    De System-Prompt enthält nëmmen den Numm an d'Beschreiwung. D'Instruktioune gi bei der éischter passender Ufro gelueden, soudatt en onbenotzte Skill näischt kascht.

  • De Modell am lafende Chat wiesselen

    Well de Skill aus Instruktiounen amplaz vu Code besteet, funktionéiert en och no engem Modellwiessel — den nächste Modell liest déi selwecht SKILL.md-Datei.

Skill-Instruktiounen

Dëst ass den Inhalt vu SKILL.md, deen de Modell luet. Liest e virun der Installatioun — e Skill besteet aus Instruktiounen, déi Äre Modell befollegt.

Source: https://github.com/aipoch/medical-research-skills

Kaplan-Meier Survival Curve Analysis

Use this skill to run Kaplan-Meier survival analysis on a tabular dataset and export a single PDF survival figure.

Use This Skill When

  • You need a Kaplan-Meier survival curve from a table containing time, status, and group columns.
  • You need a command-line survival workflow with parameter validation.
  • You need a single Kaplan-Meier plot as the final analysis result.

Primary Command

bash
Rscript scripts/main.R \
  --input_file <input_file> \
  --output_dir <output_dir> \
  --time_col <time_column> \
  --status_col <status_column> \
  --risk_col <group_column>

Prerequisites

  • Rscript is available in the shell.
  • Required R packages: optparse, data.table, survival, survminer, ggplot2.
  • Install missing packages with Rscript -e 'install.packages(c("optparse", "data.table", "survival", "survminer", "ggplot2"), repos="https://cloud.r-project.org")'.

Core Arguments

ArgumentRequiredDescription
--input_fileYesInput data file in CSV or tab-delimited TXT/TSV format
--output_dirNoOutput directory, default ./KM_Results
--time_colNoSurvival time column, default futime
--status_colNoEvent status column, default fustat
--risk_colNoRisk group column, default risk_group
--time_unitNoTime unit label: year, month, or day, default year
--auto_convert_daysNoHeuristically convert large time values from days when time_unit is year or month, default true
--statistics_methodNologrank or wald, default logrank

Plot Customization Arguments

ArgumentDefaultDescription
--figure_width10Figure width in inches
--figure_height7Figure height in inches
--figure_familysansFont family
--title_xTimeX-axis title. If left as default, the script renders Time (<time_unit>)
--title_ySurvival probabilityY-axis title
--title_mainemptyPlot title
--legend_positiontoptop, bottom, left, right, none
--legend_showtrueWhether to show legend
--legend_titleemptyLegend title
--line_typesolidSurvival line type: solid, dashed, dotted, dotdash, longdash, twodash
--line_size1Survival line width
--line_colors#4DBBD5,#E64B35,#00A087,#3C5488,#F39B7F,#8491B4,#91D1C2,#DC0000Comma-separated group colors
--censor_showtrueWhether to show censor markers
--censor_size7Censor marker size
--confidence_showtrueWhether to show confidence interval
--confidence_alpha0.2Confidence band transparency
--risk_table_showtrueWhether to show the risk table
--risk_table_bordertrueWhether to show the risk table border
--risk_table_panelfalseWhether to show the risk table panel background
--risk_table_size6Risk table font size
--axis_title_size12Axis title font size
--axis_text_size10Axis tick-label font size
--legend_text_size11Legend text font size

Input Requirements

  • The input file must contain the requested time, status, and group columns.
  • .txt inputs must be tab-delimited.
  • time must contain finite non-negative numeric values.
  • status must be coded as 0 for censored and 1 for event.
  • The risk group column must be a precomputed categorical grouping variable, not a continuous score column.
  • The risk group column must contain at least 2 groups after filtering.
  • --line_colors must provide at least one color per retained group when you override the default palette.
  • Rows with missing time, status, or group values are removed before analysis.
  • At least 2 complete observations must remain after filtering.
  • Near-unique or continuous-looking grouping columns are rejected before model fitting.
  • If --auto_convert_days true and max(time) > 365, the script assumes the retained time values are in days and converts them to the requested --time_unit when time_unit is year or month.
  • Only use --auto_convert_days true when the source time column is known to be in days.
  • If your source data are already in years or months, disable --auto_convert_days to avoid incorrect conversion.
  • --statistics_method wald only supports exactly 2 retained groups; use logrank for multi-group comparisons.
  • Invalid plotting parameters such as unsupported --line_type values are rejected before plotting.

Example input:

text
id	fustat	futime	risk_score	risk_group	GPR161	RIBC2
TCGA-C5-A1M5	1	5.62191780821918	-1.10702407761445	low	2.82521576230566	5.35318564979635
TCGA-VS-A94W	0	3.40547945205479	-0.671246677921865	high	4.26241812321536	4.00802068790173

Bundled test datasets:

  • tests/data/km_sample1.txt: baseline KM example with risk_group
  • tests/data/km_sample2.txt: alternate cohort for plotting and statistics examples
  • tests/data/km_sample3.txt: additional cohort for validation and repeated testing

Minimal Workflow

  1. Confirm the input file exists and identify the time, status, and group columns.
  2. Run scripts/main.R with the requested output directory and any optional plot parameters.
  3. Check the output directory for km-plot.pdf.

If you omit --input_file, the script exits with SKILL_MISSING_INPUT.

Outputs

Expected output:

text
<output_dir>/
├── km-plot.pdf
└── session_info.txt

Interpretation Guide

  • Use the survival figure to inspect separation between groups over time.
  • Use the p-value annotation, confidence interval, and risk table in the figure to interpret group separation.

Time Conversion Caution

  • Automatic conversion is a convenience heuristic, not a unit detector.
  • The script only checks whether max(time) > 365; it does not infer the true source unit from metadata.
  • If the input time column is already expressed in years or months, run with --auto_convert_days false.
  • Review the console log for the conversion warning whenever time_unit is year or month.

Reproducibility Note

  • Repeated runs on identical input should be analytically consistent.
  • The exported km-plot.pdf may not be byte-identical across repeated runs because PDF metadata and graphics-device output can vary.
  • If you need byte-stable artifacts, add a deterministic PDF post-processing step outside this skill.

Do Not Use This Skill When

  • You need this tool to derive a cutoff or split a continuous score into risk groups.
  • You need multivariable Cox regression, covariate adjustment, or hazard-ratio modeling beyond the p-value route already exposed here.
  • You need a broader survival-analysis workflow with upstream feature engineering, biomarker selection, or data harmonization.
  • You need multiple plots, report generation, or downstream interpretation beyond producing one Kaplan-Meier figure and session metadata.

Read These Files When Needed

NeedFile
Kaplan-Meier method details and interpretationreferences/algorithm.md
More CLI examplesreferences/cli-guide.md
Error diagnosisreferences/troubleshooting.md
Main execution entry pointscripts/main.R
Sample test datatests/data/km_sample1.txt, tests/data/km_sample2.txt, tests/data/km_sample3.txt

Quick Examples

Basic Kaplan-Meier analysis:

bash
Rscript scripts/main.R \
  --input_file tests/data/km_sample1.txt \
  --output_dir tests/output_basic

Custom column names:

bash
Rscript scripts/main.R \
  --input_file tests/data/km_sample1.txt \
  --time_col futime \
  --status_col fustat \
  --risk_col risk_group \
  --output_dir tests/output_custom_columns

Custom plot title:

bash
Rscript scripts/main.R \
  --input_file tests/data/km_sample2.txt \
  --title_main "Study KM Curve" \
  --output_dir tests/output_title

Hide confidence interval and risk table:

bash
Rscript scripts/main.R \
  --input_file tests/data/km_sample3.txt \
  --confidence_show false \
  --risk_table_show false \
  --output_dir tests/output_simple

Validation

bash
Rscript scripts/main.R --help
bash
Rscript scripts/main.R \
  --input_file tests/data/km_sample1.txt \
  --output_dir tests/validation_output

After running analysis, verify that tests/validation_output/km-plot.pdf exists.

Common Errors

  • SKILL_FILE_NOT_FOUND: Input file path is wrong or inaccessible.
  • SKILL_MISSING_COLUMNS: A requested time, status, or risk group column is missing.
  • SKILL_INVALID_DATA: Input data is malformed or unsuitable for survival analysis.
  • SKILL_INVALID_DATA: A continuous or near-unique risk column was supplied where a categorical group column is required.
  • SKILL_INVALID_PARAMETER: An argument value is invalid.
  • SKILL_INVALID_PARAMETER: Plotting options such as --line_type or --line_colors are incompatible with the retained groups.
  • SKILL_INSUFFICIENT_DATA: Too few complete observations remain after filtering.
  • SKILL_DEPENDENCY_MISSING: A required R package such as optparse or survival is unavailable.

If the issue is not obvious, read references/troubleshooting.md.

Matgeliwwert Dateien

De Modell liest dës Dateie bei Bedarf, wärend de Skill gelueden ass. Si ginn als liesbar Dateie bereetgestallt a ginn ni ausgeféiert.

Heefeg gestallte Froen

Wat mécht de KI-Skill Km Survival Curve?

Use when generating Kaplan-Meier survival curves from tabular survival data containing time, event status, and a precomputed risk group. Supports command-line parameter input, parameter validation, automatic time-unit handling, single-file PDF figure export, and session metadata capture.

Firwat Km Survival Curve op TypingMind benotzen?

Well Dir en eemol installéiert a mat all Modell benotze kënnt. Km Survival Curve besteet aus einfachem Markdown amplaz vun ubidderspezifeschem Code. Dee selwechte Skill funktionéiert also mat GPT-5, Claude, Gemini, Grok oder engem lokale Modell – an Dir kënnt de Modell matzen am Chat wiesselen, ouni datt de Skill ophält ze funktionéieren. TypingMind benotzt Är eegen API-Schlësselen, sou datt Dir d'Ubidder direkt bezuelt, amplaz en Abonnement pro Benotzerplaz ze bezuelen. Är Skills a Chats bleiwen an Ärem eegene Späicher.

Wéi installéieren ech Km Survival Curve an TypingMind?

Maacht an TypingMind Plugins → Skills → Vu GitHub installéieren op a setzt https://github.com/aipoch/medical-research-skills/tree/main/awesome-med-research-skills/Data%20Analysis/km-survival-curve an. TypingMind liest d'Datei SKILL.md, bëndelt déi zougehéiereg Dateien an installéiert dat Ganzt als Skill, deen Dir pro Chat aktivéiere kënnt.

Wéi eng KI-Modeller kënnen Km Survival Curve benotzen?

All Modell, deen Dir an TypingMind verbënnt. KI-Skills sinn einfach Markdown-Instruktiounen an net ubidderspezifesche Code. Dofir kënne GPT, Claude, Gemini, Grok a lokal Modeller dëse Skill lueden, wann eng Ufro dozou passt.

Wéi vill KI-Modeller kann ech mat Km Survival Curve benotzen?

Esou vill wéi Dir wëllt. Soulaang e Modell Skills ënnerstëtzt, kënnt Dir Km Survival Curve domat benotzen – zum Beispill mat GPT, Claude, Gemini, Grok, DeepSeek, Mistral oder Llama – alles op TypingMind mat Ären eegenen API-Schlësselen.

Ass de KI-Skill Km Survival Curve gratis?

Jo. aipoch huet de Skill ënner der Lizenz MIT op GitHub publizéiert. Dir bezuelt nëmmen Ären eegene KI-Ubidder fir d'Token, déi Dir benotzt.

Wat si KI-Skills?

E KI-Skill ass e weiderverwendbare Pak vun Instruktiounen, deen engem KI-Modell bäibréngt, wéi en eng bestëmmt Aufgab erfëllt. E follegt dem oppenen Agent Skills-Format: eng Datei SKILL.md mat engem Numm an enger Beschreiwung, plus all Scripten, Virlagen oder Referenzdateien, déi de Modell eventuell brauch. De Modell liest d'Instruktiounen eréischt, wann Är Ufro zum Skill passt. En installéierte Skill kascht also näischt, bis e benotzt gëtt.

Wéi ënnerscheede sech KI-Skills vu Plugins oder MCP-Serveren?

E Plugin oder MCP-Server gëtt engem Modell nei Tools, déi en opruffe kann – Code, deen iergendwou leeft an e Resultat zeréckgëtt. E KI-Skill gëtt dem Modell dogéint Wëssen an eng Virgoensweis: wéi en eng Aufgab ugeet, wéi eng Schrëtt e maache soll a wéi eng gutt Ausgab ausgesäit. Skills bestinn aus einfachem Markdown, brauche kee Server, keen API-Schlëssel a kee Lafzäitëmfeld a funktionéiere mat all Modell.

Alleguer weisen

Elo Ären eegene KI-Aarbechtsberäich ariichten

Abonnéiert Iech op eisen Newsletter, fir iwwer nei Funktiounen an zukünfteg Gewënnspiller informéiert ze ginn 👇