Meta forest model plot

From aipoch/medical-research-skills · View interactive version

Meta forest model plot is an AI agent skill from the GitHub repository aipoch/medical-research-skills. Generate forest plots for meta-analysis of survival data. Input is a CSV file containing study names, HR and 95% confidence intervals, output forest plot PNG and data table CSV. Supports both R and Python scripts.

How to use this skill

Skill file

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

When to Use

Key Features

Dependencies

Example Usage

cd "20260316/scientific-skills/Data Analytics/meta-forest-model-plot"
python -m py_compile scripts/forest_survival.py
python scripts/forest_survival.py --help

Example run plan:

  1. Confirm the user input, output path, and any required config values.
  2. Edit the in-file CONFIG block or documented parameters if the script uses fixed settings.
  3. Run python scripts/forest_survival.py with the validated inputs.
  4. Review the generated output and return the final artifact with any assumptions called out.

Implementation Details

See ## Workflow above for related details.

Validation Shortcut

Run this minimal command first to verify the supported execution path:

python scripts/validate_skill.py --help

Data Format Requirements

Users need to provide a CSV file with the following columns:

| Column Name | Description | Example |

|------|------|------|

| study | Study name (author + year) | Smith 2020 |

| outcome_new | Outcome indicator name | Overall Survival |

| group1_HR | Hazard Ratio | 0.85 |

| group1_95%Lower CI or group1_95.Lower.CI | 95% Confidence Interval Lower Bound | 0.72 |

| group1_95%Upper CI or group1_95.Upper.CI | 95% Confidence Interval Upper Bound | 1.01 |

Note: HR, Lower CI, and Upper CI must all be positive numbers.


Workflow

Step 1: Validate Input Data

  1. Read the CSV file provided by the user
  2. Check if necessary columns exist (supports two column name formats)
  3. Validate data integrity (at least 2 studies, HR and CI are positive numbers)

If there are data issues, prompt the user to correct and resubmit.

Step 2: Execute Script (R or Python)

Option A: Using R Script (Recommended)

Command:

Rscript scripts/forest_survival.R "<csv_path>" "<outcome_name>" "<output_dir>"
Option B: Using Python Script (Backup)

Command:

python scripts/forest_survival.py "<csv_path>" "<outcome_name>" "<output_dir>"

Parameter Description (same for both scripts):

Step 3: Output Results

Upon successful execution:

═══════════════════════════════════════════
Forest Plot Generation Complete
═══════════════════════════════════════════

【Outcome Indicator】{outcome_name}
【Included Studies】{n} studies

【Output Files】
• Forest Plot: {output_dir}/Survival_forest_{outcome}.png
• Data Table: {output_dir}/Survival_forest_{outcome}.csv

【Pooled Effect Size】
• HR = {value} [{lower}; {upper}]
• P value = {p_value}

【Heterogeneity】
• I² = {I2}%
• Tau² = {tau2}
• Q test P value = {pval_Q}

═══════════════════════════════════════════

Script Dependencies

R Script Dependencies

Install the following R packages:

If the user's environment is missing these packages, prompt them to run:

install.packages(c("meta", "metafor", "grid", "stringr"))

Python Script Dependencies

Install the following Python packages (Python 3.7+ recommended):

If the user's environment is missing these packages, prompt them to run:

pip install pandas numpy matplotlib scipy

Or in a virtual environment:

python -m pip install pandas numpy matplotlib scipy

When Not to Use

Required Inputs

Output Contract

Validation and Safety Rules

Failure Handling

Quick Validation

Run this minimal verification path before full execution when possible:

python scripts/forest_survival.py --help

Expected output format:

Result file: meta_forest_model_plot_result.md
Validation summary: PASS/FAIL with brief notes
Assumptions: explicit list if any

Deterministic Output Rules

Completion Checklist

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.