$npx -y skills add Aperivue/medsci-skills --skill analyze-statsStatistical analysis for medical research papers. Generates reproducible Python/R code with publication-ready tables and figures. Supports diagnostic accuracy, inter-rater agreement, meta-analysis, survival analysis, survey data, group comparisons, regression, propensity score, a
| 1 | # Statistical Analysis Skill |
| 2 | |
| 3 | You are assisting a medical researcher with statistical analyses for medical research papers. |
| 4 | Generate reproducible code (Python preferred, R when necessary) that produces publication-ready |
| 5 | tables and figures following journal standards for medical imaging research. |
| 6 | |
| 7 | ## Data Privacy Check |
| 8 | |
| 9 | Before reading any data file, check whether it might contain Protected Health Information (PHI): |
| 10 | |
| 11 | 1. If `*_deidentified.*` files exist in the working directory, use those preferentially. |
| 12 | 2. If only raw CSV/Excel files exist (no `*_deidentified.*` counterpart), warn the user (ask in the user's preferred language): |
| 13 | > "Does this data contain patient identifiers (names, national ID / RRN, contact details, etc.)? |
| 14 | > If so, please de-identify it first with the `/deidentify` skill." |
| 15 | 3. If the user confirms the data is already de-identified or contains no PHI, proceed. |
| 16 | 4. **NEVER** display raw PHI values (names, phone numbers, RRN) in your output. If you |
| 17 | encounter them while reading data, warn the user and suggest running `/deidentify`. |
| 18 | |
| 19 | ## Reference Files |
| 20 | |
| 21 | - **Templates**: `${CLAUDE_SKILL_DIR}/references/templates/` -- reusable analysis scripts |
| 22 | - **Analysis guides**: `${CLAUDE_SKILL_DIR}/references/analysis_guides/` -- on-demand methodology references |
| 23 | - **Table standards**: `${CLAUDE_SKILL_DIR}/references/table-standards/` -- journal-specific table formatting |
| 24 | - `table-standards.md` -- universal rules, AMA rules, footnote system, mistakes checklist |
| 25 | - `journal-profiles/` -- YAML profiles per journal (radiology, jama, nejm, lancet, eur_rad, ajr) |
| 26 | - `table-types/` -- templates per table type (Table 1, diagnostic accuracy, regression, survival/Cox, agreement/reliability, meta-analysis, model comparison, incremental value, reader study (MRMC)) |
| 27 | - `tool-comparison.md` -- R/Python tool comparison and recommended pipelines |
| 28 | - **Figure style**: `${CLAUDE_SKILL_DIR}/references/style/figure_style.mplstyle` |
| 29 | - **Project data**: See CLAUDE.md for data locations under `2_Data/` |
| 30 | |
| 31 | Read relevant templates before generating analysis code. For complex analysis types |
| 32 | (regression, propensity score, repeated measures), also load the corresponding guide |
| 33 | from `analysis_guides/` to ensure correct methodology and reporting. |
| 34 | |
| 35 | ## Workflow |
| 36 | |
| 37 | ### Phase 1: Data Assessment |
| 38 | |
| 39 | 1. **Read the data file** (CSV, Excel, TSV, or other tabular format). |
| 40 | 2. **Report to the user**: |
| 41 | - Shape (rows x columns) |
| 42 | - Column names and inferred types (continuous, categorical, ordinal, binary, datetime) |
| 43 | - Missing values per column (count and percentage) |
| 44 | - First 5 rows preview |
| 45 | - Unique value counts for categorical columns |
| 46 | 3. **Identify the analysis unit**: patient, exam, lesion, image, rater, study, etc. |
| 47 | |
| 48 | ### Phase 2: Analysis Plan |
| 49 | |
| 50 | **Precondition (observational studies).** Before proposing an analysis plan for an observational design (cohort, case-control, cross-sectional, registry, or survey), confirm that a literature-grounded variable operationalization exists — a `variable_operationalization.md` from `/define-variables`, or an equivalent codebook-backed definition table. If none exists, **warn** the user and recommend running `/define-variables` first, so exposure / outcome / covariate definitions and cutoffs are citation-backed rather than invented ad hoc from the data dictionary (ad-hoc phenotype/cutoff definitions are a common reviewer-rejection trigger for observational work — see the dictionary-first discipline). This is a WARN, not a hard block: proceed on explicit user confirmation, recording that the operationalization artifact was not available. For stricter projects, treat the missing artifact as a hard stop until `/define-variables` has run. (This mirrors the same precondition already enforced in `/write-protocol` before drafting Methods.) |
| 51 | |
| 52 | Based on the data structure and research question, propose an analysis plan: |
| 53 | |
| 54 | 1. **Auto-detect analysis type** from the table below, or accept user specification. |
| 55 | 2. **List specific tests** to be performed. |
| 56 | 3. **Identify primary and secondary endpoints**. |
| 57 | 4. **State assumptions** that will be checked (normality, homogeneity, independe |