본문으로 건너뛰기
cccskills
무료GitHub에 공개

km-survival-curve

Create a Kaplan-Meier survival curve from a table with follow-up time, event status, and an existing categorical risk group. The workflow validates inputs, supports plot settings and time-unit handling, and exports a PDF figure with session metadata.

한국어 요약은 준비 중입니다. 영어 요약을 표시하고 있습니다.

원문원문 설명 보기

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.

실행 점수 미검증

설치 방법 보기

이럴 때 유용합니다

  • Plotting survival by precomputed risk group
  • Exporting one survival figure as a PDF
  • Comparing two or more categorical groups over time
  • Checking a tabular survival dataset before plotting

포함된 파일(13)

  • SKILL.md9.6 KB
  • eval_report_km-survival-curve_result.json16.5 KB
  • references/algorithm.md3.3 KB
  • references/cli-guide.md5.6 KB
  • references/troubleshooting.md4.3 KB
  • scripts/functions.R11.5 KB
  • scripts/main.R7.1 KB
  • scripts/run_analysis.R1.7 KB
  • scripts/utils.R5.0 KB
  • tests/data/km_custom_columns.csv166 B
  • tests/data/km_sample1.txt15.7 KB
  • tests/data/km_sample2.txt5.5 KB
  • tests/data/km_sample3.txt21.1 KB

SKILL.md(원문)

설치하기 전에 에이전트에게 전달되는 지시 내용을 확인할 수 있습니다.

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

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:

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:

<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:

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

Custom column names:

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:

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:

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

Validation

Rscript scripts/main.R --help
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.

리뷰

아직 리뷰가 없습니다. 사용해 본 소감을 남겨 주세요.

댓글

로그인 없이 쓸 수 있습니다. 사용 후기, 질문, 작동하지 않은 환경 등을 편하게 남겨 주세요.

아직 댓글이 없습니다. 첫 댓글을 남겨 보세요.

보내면 바로 공개됩니다. 이메일 주소나 전화번호 같은 개인 정보는 쓰지 마세요. URL은 2개까지입니다.

0 / 1,000자

이 양식은 reCAPTCHA로 보호되며 Google 개인정보처리방침 및 서비스 약관이 적용됩니다.

같은 저장소의 스킬

Condense an academic paper into a structured abstract of up to 250 words, organized by background, objective, methods, results, and conclusion. It aims to retain key quantitative findings and supports papers from several research fields; figures and charts are not interpreted.

한국어 요약은 준비 중입니다. 영어 요약을 표시하고 있습니다.

  • Creating a concise abstract from a research paper
  • Summarizing empirical studies while retaining key statistics
  • Preparing structured summaries across multiple papers
aipoch/medical-research-skills2천2026년 9월 17일 업데이트

Trim English academic abstracts to a target word count while preserving key findings, statistics, and the background-to-conclusion structure. Choose conservative, balanced, or aggressive compression, check word counts, and review the edited text for readability and accuracy.

한국어 요약은 준비 중입니다. 영어 요약을 표시하고 있습니다.

  • Cutting an abstract to meet a journal word limit
  • Preparing a conference abstract with a strict word count
  • Checking an abstract's word count before submission
aipoch/medical-research-skills2천2026년 9월 17일 업데이트

Refines long medical drafts, reports, or literature notes into formal, single-paragraph Chinese and English abstracts in an SCI journal style. It can place both abstracts in a Markdown report while keeping claims grounded in the source text.

한국어 요약은 준비 중입니다. 영어 요약을 표시하고 있습니다.

  • Condensing a medical study report into bilingual abstracts
  • Preparing unstructured abstracts from literature notes
  • Creating a Markdown report with Chinese and English abstracts
aipoch/medical-research-skills2천2026년 9월 17일 업데이트

Creates three to five concise English Highlights for journal submission from manuscript text or supported files. It adapts bullets to the article type, keeps each within 85 characters, and grounds every claim in the supplied source without inventing results.

한국어 요약은 준비 중입니다. 영어 요약을 표시하고 있습니다.

  • Draft journal Highlights from an abstract or manuscript
  • Summarize a meta-analysis or review for submission
  • Extract key findings from a supported PDF or DOCX
aipoch/medical-research-skills2천2026년 9월 17일 업데이트

Design comparative drug safety studies using FAERS, the FDA’s adverse event reporting database, within one defined safety area. The plan compares drugs or classes, lays out workload options and analysis steps, and distinguishes detected signals from conclusions the data cannot support.

한국어 요약은 준비 중입니다. 영어 요약을 표시하고 있습니다.

  • Comparing drug classes within one adverse event area
  • Planning a FAERS study with active comparators
  • Adding declared subgroup or onset characterization
aipoch/medical-research-skills2천2026년 9월 17일 업데이트

Predicts absorption, distribution, metabolism, and excretion properties for small molecules from their structures. Use the results to compare compounds, screen libraries, and review drug-likeness scores in structured outputs. Predictions support prioritization and need experimental validation.

한국어 요약은 준비 중입니다. 영어 요약을 표시하고 있습니다.

  • Compare predicted ADME profiles for small-molecule candidates
  • Screen a compound library for drug-likeness
  • Rank candidates against target property ranges
aipoch/medical-research-skills2천2026년 9월 17일 업데이트

aipoch의 스킬 모두 보기

이 스킬의 문제 신고