{"data":{"slug":"github-aipoch-medical-research-skills-awesome-med-research-skills-data-analysis-time-dependent-roc-14040723f0f5","title":"Time-Dependent ROC Curve Analysis for Survival Data","summary":"Compute and plot time-dependent ROC curves for survival outcomes using follow-up time, event status, and a numeric marker. Generates AUC tables, ROC points, and PDF figures for medical research.","url":"https:\/\/skillshunter.net\/skills\/github-aipoch-medical-research-skills-awesome-med-research-skills-data-analysis-time-dependent-roc-14040723f0f5","json_url":"https:\/\/skillshunter.net\/api\/public\/v1\/skills\/github-aipoch-medical-research-skills-awesome-med-research-skills-data-analysis-time-dependent-roc-14040723f0f5","markdown_url":"https:\/\/skillshunter.net\/skills\/github-aipoch-medical-research-skills-awesome-med-research-skills-data-analysis-time-dependent-roc-14040723f0f5.md","download_url":"https:\/\/skillshunter.net\/skills\/github-aipoch-medical-research-skills-awesome-med-research-skills-data-analysis-time-dependent-roc-14040723f0f5\/download","category":{"slug":"data-research","name":"Data & Research"},"editor_note":"Ensure `Rscript` is installed and the required R packages (`optparse`, `timeROC`, `survival`, `ggplot2`) are available. The input file must contain `futime` and `fustat` columns, and the marker column must be numeric or coercible to numeric. If `--marker_col` is omitted, the input file must contain a `risk_score` column.","instructions":"---\nname: time-dependent-roc\ndescription: Use when performing time-dependent ROC curve analysis for survival data with follow-up time, event status, and a numeric marker. Supports CSV\/TXT\/TSV\/Excel input, `risk_score` as the default marker unless `--marker_col` is provided, parameter validation, standardized output directories, AUC table export, ROC point export, and PDF figure generation.\nlicense: MIT\nauthor: AIPOCH\n---\n> **Source**: [https:\/\/github.com\/aipoch\/medical-research-skills](https:\/\/github.com\/aipoch\/medical-research-skills)\n\n# Time-Dependent ROC Analysis\n\nUse this skill to compute and plot time-dependent ROC curves for survival outcomes.\n\n## Use This Skill When\n\n- You have survival data with `futime` and `fustat` columns.\n- You need time-specific ROC curves and AUC values for a numeric risk marker.\n- You want a command-line workflow with parameter validation and standardized outputs.\n- Your file contains a numeric marker column named `risk_score`, or you will provide another marker explicitly with `--marker_col`.\n\n## Primary Command\n\n```bash\nRscript scripts\/main.R \\\n  --data_file <input_file> \\\n  --times <comma_separated_times> \\\n  --output_dir <output_dir>\n```\n\n## Prerequisites\n\n- `Rscript` is available in the shell.\n- Required R packages: `optparse`, `timeROC`, `survival`, `ggplot2`.\n- Optional package for Excel input: `openxlsx`.\n- Install missing packages with `Rscript -e 'install.packages(c(\"optparse\", \"timeROC\", \"survival\", \"ggplot2\", \"openxlsx\"), repos=\"https:\/\/cloud.r-project.org\")'`.\n\n## Core Arguments\n\n| Argument | Required | Description |\n|----------|----------|-------------|\n| `--data_file` | Yes | Input data file in CSV, TXT, TSV, TAB, XLS, or XLSX format |\n| `--times` | No | Prediction time points, comma-separated. Default `1,3,5` |\n| `--marker_col` | No | Marker column name. Default `risk_score`; provide this option when your file uses a different marker |\n| `--output_dir` | No | Output directory, default `.\/TimeROC_Results` |\n| `--time_unit` | No | Time unit label for plot\/output: `year`, `month`, or `day`. Default `year` |\n| `--auto_convert_days` | No | If `TRUE`, convert large `futime` values from days to the selected unit when appropriate. Default `TRUE` |\n| `--weighting` | No | IPCW weighting method: `aalen`, `marginal`, or `cox`. Default `aalen` |\n| `--cause` | No | Event code treated as the outcome of interest. Default `1` |\n\n## Input Requirements\n\n- The input file must contain `futime` and `fustat` columns.\n- The selected marker column must exist and be numeric or coercible to numeric.\n- If `--marker_col` is omitted, the input file must contain `risk_score`.\n- `futime` must be numeric or coercible to numeric.\n- `fustat` must be numeric or coercible to numeric.\n- Rows with missing `futime`, `fustat`, or marker values are excluded.\n- At least 5 complete rows and at least 1 event for the requested `cause` are required.\n\nExample input:\n\n```text\nid\tfustat\tfutime\trisk_score\trisk_group\tGPR161\tRIBC2\nTCGA-C5-A1M5\t1\t5.6219\t-1.1070\tlow\t2.8252\t5.3532\nTCGA-EA-A5O9\t0\t2.1589\t-0.8964\tlow\t2.6046\t4.4293\nTCGA-C5-A3HL\t0\t1.7014\t-0.9044\tlow\t4.1248\t4.9166\n```\n\n## Minimal Workflow\n\n1. Confirm the input file exists and includes `futime`, `fustat`, and `risk_score`, or plan to pass `--marker_col`.\n2. Run `scripts\/main.R` with the requested time points.\n3. Check the output directory for the AUC table and PDF figure.\n\nIf you omit `--data_file`, the script exits with `SKILL_MISSING_INPUT`.\n\n## Outputs\n\nExpected output structure:\n\n```text\n<output_dir>\/\n\u251c\u2500\u2500 data\/\n\u2502   \u2514\u2500\u2500 time_roc_points.<csv|txt>\n\u251c\u2500\u2500 session_info.txt\n\u251c\u2500\u2500 figure\/\n\u2502   \u2514\u2500\u2500 time_roc.pdf\n\u2514\u2500\u2500 table\/\n    \u2514\u2500\u2500 time_roc_auc.<csv|txt>\n```\n\nPrimary output files:\n\n- `data\/time_roc_points.csv` or `data\/time_roc_points.txt`\n- `table\/time_roc_auc.csv` or `table\/time_roc_auc.txt`\n- `figure\/time_roc.pdf`\n- `session_info.txt`\n\nExported result fields include:\n\n- `time`\n- `time_unit`\n- `auc`\n- `marker_col`\n- `n_complete`\n- `n_events`\n\nExported ROC point fields include:\n\n- `false_positive_rate`\n- `sensitivity`\n- `time`\n- `time_unit`\n- `auc`\n- `curve_label`\n\n## Read These Files When Needed\n\n| Need | File |\n|------|------|\n| Statistical details and assumptions | `references\/algorithm.md` |\n| More CLI examples | `references\/cli-guide.md` |\n| Error diagnosis | `references\/troubleshooting.md` |\n| Main execution entry point | `scripts\/main.R` |\n| Sample test data | `tests\/data\/` |\n\n## Quick Examples\n\nBasic analysis:\n\n```bash\nRscript scripts\/main.R \\\n  --data_file tests\/data\/time_roc_sample1.txt \\\n  --times 1,3,5 \\\n  --output_dir tests\/output_basic\n```\n\nSpecify marker column and plot styling:\n\n```bash\nRscript scripts\/main.R \\\n  --data_file tests\/data\/time_roc_sample2.txt \\\n  --marker_col GPR161 \\\n  --times 1,2,4 \\\n  --line_colors \"#4DBBD5,#E64B35,#00A087\" \\\n  --legend_position bottom \\\n  --output_dir tests\/output_gpr161\n```\n\n## Validation\n\n```bash\nRscript scripts\/main.R --help\n```\n\n```bash\nRscript scripts\/main.R \\\n  --data_file tests\/data\/time_roc_sample1.txt \\\n  --times 1,3,5 \\\n  --output_dir tests\/validation_output\n```\n\nAfter running analysis, verify that these files exist:\n\n- `tests\/validation_output\/data\/time_roc_points.csv`\n- `tests\/validation_output\/table\/time_roc_auc.csv`\n- `tests\/validation_output\/figure\/time_roc.pdf`\n- `tests\/validation_output\/session_info.txt`\n\n## Common Errors\n\n- `SKILL_FILE_NOT_FOUND`: Input file path is wrong or inaccessible.\n- `SKILL_MISSING_COLUMNS`: `futime` or `fustat` is missing.\n- `SKILL_INVALID_DATA`: The marker column is non-numeric, no complete rows remain, event coding is unsuitable, or requested time points yield unusable AUC values.\n- `SKILL_INVALID_PARAMETER`: An argument value is invalid.\n- `SKILL_INSUFFICIENT_DATA`: Too few complete rows or no target events remain.\n- `SKILL_DEPENDENCY_MISSING`: A required R package such as `optparse`, `timeROC`, `survival`, `ggplot2`, or `openxlsx` is unavailable.\n\nIf the issue is not obvious, read `references\/troubleshooting.md`.\n","use_cases":["Analyzing survival data with follow-up time and event status to evaluate the performance of a numeric risk marker.","Generating time-specific ROC curves and AUC values for survival outcomes in medical research.","Creating standardized outputs including AUC tables, ROC points, and PDF figures for survival analysis."],"limitations":[],"compatibility":[],"setup_tip":null,"sample_input":null,"sample_output":null,"source_url":"https:\/\/github.com\/aipoch\/medical-research-skills\/blob\/686e09dfdb45d9fa1a08664f06bb93769b3c9d91\/awesome-med-research-skills\/Data%20Analysis\/time-dependent-roc\/SKILL.md","source_commit":"686e09dfdb45d9fa1a08664f06bb93769b3c9d91","license":"MIT","version":null,"listing_approved_at":"2026-11-24","created_at":"2026-11-23T07:36:35.000000Z","updated_at":"2026-11-24T07:13:22.000000Z","seo_title":"Time-Dependent ROC Analysis for Survival Data","seo_description":"Compute and plot time-dependent ROC curves for survival outcomes with follow-up time, event status, and a numeric marker. Supports CSV, TSV, and Excel input formats and A","seo_keywords":["time-dependent ROC analysis","survival data analysis","ROC curve for survival outcomes","medical research analysis","AUC table export","PDF figure generation"]}}