{"data":{"slug":"github-aipoch-medical-research-skills-awesome-med-research-skills-data-analysis-roc-diagnostic-performance-83150e1f6eb8","title":"ROC Diagnostic Performance Analysis","summary":"Evaluate diagnostic biomarker performance using logistic regression and ROC curves. Export coefficient tables, AUC values, and ROC PDFs for case-control expression data.","url":"https:\/\/skillshunter.net\/skills\/github-aipoch-medical-research-skills-awesome-med-research-skills-data-analysis-roc-diagnostic-performance-83150e1f6eb8","json_url":"https:\/\/skillshunter.net\/api\/public\/v1\/skills\/github-aipoch-medical-research-skills-awesome-med-research-skills-data-analysis-roc-diagnostic-performance-83150e1f6eb8","markdown_url":"https:\/\/skillshunter.net\/skills\/github-aipoch-medical-research-skills-awesome-med-research-skills-data-analysis-roc-diagnostic-performance-83150e1f6eb8.md","download_url":"https:\/\/skillshunter.net\/skills\/github-aipoch-medical-research-skills-awesome-med-research-skills-data-analysis-roc-diagnostic-performance-83150e1f6eb8\/download","category":{"slug":"data-research","name":"Data & Research"},"editor_note":"Ensure the expression matrix has numeric finite values for selected marker genes and that the group file contains at least 10 matched samples, 2 case samples, and 2 control samples.","instructions":"---\nname: roc-diagnostic-performance\ndescription: \"Use when evaluating diagnostic biomarker performance from case-control expression data with logistic regression and ROC curves, exporting coefficient and AUC tables together with a ROC PDF. NOT for: survival analysis, time-to-event outcomes, multiclass classification, calibration curves, decision-curve analysis, or nomogram construction.\"\n---\n\n# ROC Diagnostic Performance\n\n## When to Use\n\nUse this skill when you need to:\n- evaluate one or more diagnostic marker genes in a case-control cohort;\n- build a multivariable logistic regression diagnostic model from marker expression values;\n- compare the ROC performance of the full model against individual markers.\n\nTypical user requests:\n- \"Use these genes to build a diagnostic ROC model for case vs control samples.\"\n- \"Evaluate the AUC of FOXP3, CD45, and CD3E and plot all ROC curves together.\"\n- \"Run logistic regression on biomarker expression and export ROC results.\"\n\n## When Not to Use\n\nDo not use this skill for:\n- survival or prognostic analysis with time-to-event outcomes;\n- multiclass classification tasks;\n- calibration plots, nomograms, or decision-curve analysis;\n- non-expression diagnostic inputs such as imaging, clinical scores, or mutation-only tables.\n\n## When to Read External Files\n\n| Situation | File to Read | Purpose |\n|-----------|--------------|---------|\n| **Need algorithm details** | `references\/algorithm.md` | Logistic regression, ROC, AUC, and modeling assumptions |\n| **Need to run analysis** | `scripts\/main.R` | Execute `Rscript scripts\/main.R --expression_file ... --group_file ...` |\n| **Encounter errors** | `references\/troubleshooting.md` | Common `SKILL_*` errors and solutions |\n| **Need CLI examples** | `references\/cli-guide.md` | Detailed command-line examples |\n| **Need test data** | `tests\/data\/` | Example expression matrix and group file |\n\n---\n\n## Usage\n\n```bash\nRscript scripts\/main.R \\\n  --expression_file .\/expression_matrix.csv \\\n  --group_file .\/group_info.csv \\\n  --marker_genes FOXP3,CD45,CD3E \\\n  --case_group Disease \\\n  --output_dir .\/output\/ \\\n  --seed 42\n```\n\n---\n\n## Arguments\n\n| Short | Long | Type | Default | Description |\n|-------|------|------|---------|-------------|\n| `-e` | `--expression_file` | character | **required** | Expression matrix file in CSV\/TSV format |\n| `-g` | `--group_file` | character | **required** | Group file with sample IDs and labels |\n| `-m` | `--marker_genes` | character | **required** | Comma-separated marker genes |\n| `-c` | `--case_group` | character | **required** | Case group label in the group file |\n|  | `--group_col` | character | `NULL` | Optional group column name; auto-detected if omitted |\n| `-o` | `--output_dir` | character | `.\/output\/` | Output directory |\n|  | `--overwrite` | flag | `FALSE` | Allow writing into a non-empty output directory |\n| `-s` | `--seed` | integer | `42` | Random seed for reproducibility |\n| `-T` | `--timeout_seconds` | integer | `0` | Elapsed time limit in seconds; `0` disables timeout |\n|  | `--plot_width` | double | `6` | ROC plot width in inches |\n|  | `--plot_height` | double | `6` | ROC plot height in inches |\n|  | `--font_family` | character | `sans` | PDF font family |\n|  | `--line_colors` | character | `#E64B35,#4DBBD5,#00A087,#3C5488,#F39B7F` | Comma-separated ROC line colors |\n|  | `--line_width` | double | `1.2` | ROC curve line width |\n|  | `--show_diagonal` | character | `true` | Show diagonal reference line: `true` or `false` |\n|  | `--diagonal_color` | character | `#7F7F7F` | Diagonal line color |\n|  | `--diagonal_lty` | integer | `2` | Diagonal line type |\n|  | `--plot_title` | character | `ROC Diagnostic Performance` | ROC plot title |\n|  | `--x_label` | character | `1 - Specificity` | X-axis label |\n|  | `--y_label` | character | `Sensitivity` | Y-axis label |\n|  | `--base_cex` | double | `0.9` | Base text-size multiplier |\n|  | `--legend_position` | character | `bottomright` | Legend position |\n|  | `--legend_cex` | double | `0.8` | Legend text size |\n\n---\n\n## Input Format\n\n### Expression Matrix (`expression_file`)\n\nCSV or TSV file with genes as rows and samples as columns. The first column must store unique gene identifiers.\n\n```csv\ngene,Sample1,Sample2,Sample3\nFOXP3,8.4,7.1,3.8\nCD45,2.1,1.9,5.4\nCD3E,5.8,6.2,4.0\n```\n\n**Requirements**\n- File extension must be `.csv`, `.tsv`, or `.txt`.\n- The first column must contain non-missing, unique gene identifiers.\n- Remaining columns must be sample IDs.\n- Selected marker genes must have numeric finite expression values across matched samples.\n\n### Group File (`group_file`)\n\nCSV or TSV file with sample IDs in the first column and at least one group-label column.\n\n```csv\nsample,group\nSample1,Disease\nSample2,Disease\nSample3,Control\n```\n\n**Requirements**\n- File extension must be `.csv`, `.tsv`, or `.txt`.\n- The first column must contain non-missing, unique sample IDs.\n- At least one group column must be present.\n- The `case_group` value must appear in the selected group column.\n- At least 10 matched samples, 2 case samples, and 2 control samples are required.\n\n---\n\n## Output Files\n\n| File | Description |\n|------|-------------|\n| `data\/analysis_data.rds` | Matched sample-level analysis dataset used for model fitting |\n| `data\/roc_model.rds` | Saved logistic regression model bundle with data and selected genes |\n| `table\/model_coefficients.csv` | Logistic regression coefficients, z statistics, p-values, and odds ratios |\n| `table\/roc_auc_summary.csv` | AUC values for the full model and each marker |\n| `plot\/roc_curve.pdf` | ROC curves for the full model and individual markers |\n| `session_info.txt` | Session information and run parameters |\n\n### model_coefficients.csv\n\n| Column | Description |\n|--------|-------------|\n| `term` | Model term name |\n| `estimate` | Logistic regression coefficient |\n| `std_error` | Standard error of the coefficient |\n| `z_value` | Wald z statistic |\n| `p_value` | Wald test p-value |\n| `odds_ratio` | Exponentiated coefficient |\n| `odds_ratio_95_ci` | Odds ratio with 95% confidence interval |\n\n### roc_auc_summary.csv\n\n| Column | Description |\n|--------|-------------|\n| `model` | Full model or marker name |\n| `auc` | Area under the ROC curve |\n\n---\n\n## Workflow\n\n### Step 1: Validate Input\n- Check that the expression matrix and group file exist and have supported formats.\n- Validate unique gene identifiers and sample IDs.\n- Match samples shared by both files.\n\n### Step 2: Prepare Analysis Dataset\n- Keep only the requested marker genes that exist in the expression matrix.\n- Merge matched expression values with group labels.\n- Convert the selected case group to binary outcome labels.\n\n### Step 3: Fit Logistic Regression\n- Fit a multivariable logistic regression model using the selected markers.\n- Extract coefficient estimates, standard errors, p-values, and odds ratios.\n\n### Step 4: Compute ROC Performance\n- Generate the ROC curve of the full logistic model.\n- Generate ROC curves for each individual marker.\n- Calculate AUC values for the full model and each marker.\n\n### Step 5: Save Outputs\n- Save the matched analysis dataset and model bundle as `.rds` files.\n- Save coefficient and AUC summary tables as `.csv` files.\n- Save the combined ROC plot as a PDF.\n\n---\n\n## Examples\n\n### Basic Usage\n\n```bash\nRscript scripts\/main.R \\\n  -e expression_matrix.csv \\\n  -g group_info.csv \\\n  -m FOXP3,CD45,CD3E \\\n  -c Disease \\\n  -o .\/output\/\n```\n\n### With Explicit Group Column and Custom Plot\n\n```bash\nRscript scripts\/main.R \\\n  -e expression_matrix.csv \\\n  -g group_info.csv \\\n  -m FOXP3,CD45,CD3E \\\n  -c Disease \\\n  --group_col diagnosis \\\n  --plot_width 8 \\\n  --plot_height 6 \\\n  --plot_title \"Biomarker ROC Comparison\" \\\n  --legend_position topright \\\n  -o .\/output\/\n```\n\n### With Test Data\n\n```bash\nRscript scripts\/main.R \\\n  -e tests\/data\/sample_expression_matrix.csv \\\n  -g tests\/data\/sample_group_info.csv \\\n  -m FOXP3,CD45,CD3E \\\n  -c Disease \\\n  -o tests\/expected_output\/ \\\n  --overwrite\n```\n\n---\n\n## Error Handling\n\n| Error | Cause | Solution |\n|-------|-------|----------|\n| `SKILL_INVALID_PARAMETER` | Missing required argument, invalid option value, invalid matrix\/group structure, invalid case label, insufficient case-control counts, or logistic fitting failure | Check argument names, input content, class balance, and model stability |\n| `SKILL_FILE_NOT_FOUND` | Input file does not exist | Verify the file path |\n| `SKILL_EMPTY_DATA` | Input file contains no usable rows, or no requested markers remain after filtering | Check file content, delimiter, and marker names |\n| `SKILL_MISSING_COLUMNS` | Requested group column is absent | Verify `--group_col` and the group file header |\n| `SKILL_SAMPLE_MISMATCH` | Expression matrix and group file do not share sample IDs | Verify that sample IDs match exactly between files |\n| `SKILL_PACKAGE_NOT_FOUND` | Required R package is not installed | Install the missing CRAN package |\n\n**IF error persists**, READ: `references\/troubleshooting.md`\n\n---\n\n## Testing\n\n### Smoke Test With Included Data\n\n```bash\nRscript scripts\/main.R --help\n\nRscript scripts\/main.R \\\n  -e tests\/data\/sample_expression_matrix.csv \\\n  -g tests\/data\/sample_group_info.csv \\\n  -m FOXP3,CD45,CD3E \\\n  -c Disease \\\n  -o tests\/expected_output\/ \\\n  --overwrite\n```\n\n### Automated Smoke Test Script\n\n```bash\nRscript tests\/run_smoke_test.R\n```\n\nOptional shell wrapper:\n\n```bash\nbash tests\/run_smoke_test.sh\n```\n\n### Expected Output\n\n```text\ntests\/expected_output\/\n|-- data\/analysis_data.rds\n|-- data\/roc_model.rds\n|-- plot\/roc_curve.pdf\n|-- session_info.txt\n|-- table\/model_coefficients.csv\n`-- table\/roc_auc_summary.csv\n```\n\n---\n\n## References\n\n1. Hosmer DW, Lemeshow S, Sturdivant RX (2013). *Applied Logistic Regression*.\n2. Fawcett T (2006). An Introduction to ROC Analysis. *Pattern Recognition Letters*.\n3. Robin X et al. (2011). pROC: an open-source package for R and S+ to analyze and compare ROC curves. *BMC Bioinformatics*.\n\n**For detailed algorithm**, READ: `references\/algorithm.md`\n\n---\n\n## Implementation Checklist\n\n- [x] CLI parsing with `optparse`\n- [x] `set.seed()` for reproducibility\n- [x] `requireNamespace()` dependency checks\n- [x] Session info recording\n- [x] Timeout parameter exposed as CLI option\n- [x] File reading instructions in `SKILL.md`\n- [x] Modular script structure in `scripts\/`\n- [x] Test data provided in `tests\/data\/`\n- [x] Error handling with `SKILL_*` codes\n- [x] References documented in `references\/`\n\n---\n\n*Last updated: 2026-04-17 | Version: 2.1.0*\n","use_cases":["Evaluate the AUC of FOXP3, CD45, and CD3E and plot all ROC curves together.","Run logistic regression on biomarker expression and export ROC results.","Build a diagnostic ROC model for case vs control samples using specific marker genes."],"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\/roc-diagnostic-performance\/SKILL.md","source_commit":"686e09dfdb45d9fa1a08664f06bb93769b3c9d91","license":null,"version":null,"listing_approved_at":"2026-11-24","created_at":"2026-11-23T07:28:40.000000Z","updated_at":"2026-11-24T07:13:04.000000Z","seo_title":"ROC Diagnostic Performance Analysis","seo_description":"Evaluate diagnostic biomarker performance using logistic regression and ROC curves. Export coefficient tables and AUC values with ROC PDFs.","seo_keywords":["ROC diagnostic analysis","logistic regression biomarker evaluation","AUC and ROC curve export","case-control diagnostic model","marker gene performance analysis"]}}