Forest Plot Styler
ID: 157
Beautifies Meta-analysis or subgroup analysis forest plots, customizes Odds Ratio point sizes and confidence interval line styles.
Features
- - Reads Meta-analysis data (CSV/Excel format)
- Draws high-quality forest plots
- Customizes Odds Ratio point sizes, colors, and shapes
- Customizes confidence interval line styles (color, thickness, endpoint style)
- Supports subgroup analysis display
- Automatically calculates and displays pooled effect values
- Outputs to PNG, PDF, or SVG format
Usage
CODEBLOCK0
Parameters
| Parameter | Type | Default | Required | Description |
|---|
| INLINECODE0 , INLINECODE1 | string | - | Yes | Input data file (CSV or Excel) |
| INLINECODE2 , INLINECODE3 |
string | forest_plot.png | No | Output file path |
|
--format,
-f | string | png | No | Output format (png/pdf/svg) |
|
--point-size | int | 8 | No | OR point size |
|
--point-color | string | #2E86AB | No | OR point color |
|
--ci-color | string | #2E86AB | No | Confidence interval line color |
|
--ci-linewidth | int | 2 | No | Confidence interval line thickness |
|
--ci-capwidth | int | 5 | No | Confidence interval endpoint width |
|
--summary-color | string | #A23B72 | No | Pooled effect point color |
|
--summary-shape | string | diamond | No | Pooled effect point shape |
|
--subgroup | string | - | No | Subgroup analysis column name |
|
--title,
-t | string | Forest Plot | No | Chart title |
|
--xlabel,
-x | string | Odds Ratio (95% CI) | No | X-axis label |
|
--reference-line | float | 1.0 | No | Reference line position |
|
--width,
-W | int | 12 | No | Image width (inches) |
|
--height,
-H | int | auto | No | Image height (inches) |
|
--dpi | int | 300 | No | Image resolution |
|
--font-size | int | 10 | No | Font size |
|
--style,
-s | string | default | No | Preset style (default/minimal/dark) |
Input Data Format
CSV/Excel files must contain the following columns:
| Column Name | Description | Type |
|---|
| INLINECODE27 | Study name | Text |
| INLINECODE28 |
Odds Ratio value | Numeric |
|
ci_lower | Confidence interval lower bound | Numeric |
|
ci_upper | Confidence interval upper bound | Numeric |
|
weight | Weight (optional, for point size) | Numeric |
|
subgroup | Subgroup label (optional) | Text |
Sample Data
CODEBLOCK1
Examples
Basic Usage
CODEBLOCK2
Custom Style
CODEBLOCK3
Subgroup Analysis
CODEBLOCK4
Output PDF Vector Graphic
CODEBLOCK5
Preset Styles
default
- - Blue color scheme
- Standard font size
- White background
minimal
- - Clean lines
- Grayscale color scheme
- No grid lines
dark
- - Dark background
- Bright data points
- Suitable for dark theme presentations
Dependencies
- - Python >= 3.8
- matplotlib >= 3.5.0
- pandas >= 1.3.0
- numpy >= 1.20.0
- openpyxl >= 3.0.0 (for reading Excel)
Output Example
Generated forest plot contains:
- - Left side: Study name list
- Middle: OR values and confidence intervals
- Right side: Weight percentage (if available)
- Bottom: Pooled effect value (diamond marker)
- Reference line (OR=1)
Notes
- 1. Ensure input file encoding is UTF-8
- OR values are automatically converted when log scale is suggested
- Studies with confidence intervals crossing 1 are not statistically significant
- Weight values are used to adjust point size, reflecting study contribution
Risk Assessment
| Risk Indicator | Assessment | Level |
|---|
| Code Execution | Python/R scripts executed locally | Medium |
| Network Access |
No external API calls | Low |
| File System Access | Read input files, write output files | Medium |
| Instruction Tampering | Standard prompt guidelines | Low |
| Data Exposure | Output files saved to workspace | Low |
Security Checklist
- - [ ] No hardcoded credentials or API keys
- [ ] No unauthorized file system access (../)
- [ ] Output does not expose sensitive information
- [ ] Prompt injection protections in place
- [ ] Input file paths validated (no ../ traversal)
- [ ] Output directory restricted to workspace
- [ ] Script execution in sandboxed environment
- [ ] Error messages sanitized (no stack traces exposed)
- [ ] Dependencies audited
Prerequisites
CODEBLOCK6
Evaluation Criteria
Success Metrics
- - [ ] Successfully executes main functionality
- [ ] Output meets quality standards
- [ ] Handles edge cases gracefully
- [ ] Performance is acceptable
Test Cases
- 1. Basic Functionality: Standard input → Expected output
- Edge Case: Invalid input → Graceful error handling
- Performance: Large dataset → Acceptable processing time
Lifecycle Status
- - Current Stage: Draft
- Next Review Date: 2026-03-06
- Known Issues: None
- Planned Improvements:
- Performance optimization
- Additional feature support
森林图样式编辑器
ID: 157
美化元分析或亚组分析森林图,自定义比值比点大小和置信区间线条样式。
功能特点
- - 读取元分析数据(CSV/Excel格式)
- 绘制高质量森林图
- 自定义比值比点的大小、颜色和形状
- 自定义置信区间线条样式(颜色、粗细、端点样式)
- 支持亚组分析显示
- 自动计算并显示合并效应值
- 输出为PNG、PDF或SVG格式
使用方法
bash
python scripts/main.py --input [选项]
参数说明
| 参数 | 类型 | 默认值 | 必填 | 说明 |
|---|
| --input, -i | 字符串 | - | 是 | 输入数据文件(CSV或Excel) |
| --output, -o |
字符串 | forest_plot.png | 否 | 输出文件路径 |
| --format, -f | 字符串 | png | 否 | 输出格式(png/pdf/svg) |
| --point-size | 整数 | 8 | 否 | 比值比点大小 |
| --point-color | 字符串 | #2E86AB | 否 | 比值比点颜色 |
| --ci-color | 字符串 | #2E86AB | 否 | 置信区间线条颜色 |
| --ci-linewidth | 整数 | 2 | 否 | 置信区间线条粗细 |
| --ci-capwidth | 整数 | 5 | 否 | 置信区间端点宽度 |
| --summary-color | 字符串 | #A23B72 | 否 | 合并效应点颜色 |
| --summary-shape | 字符串 | diamond | 否 | 合并效应点形状 |
| --subgroup | 字符串 | - | 否 | 亚组分析列名 |
| --title, -t | 字符串 | Forest Plot | 否 | 图表标题 |
| --xlabel, -x | 字符串 | Odds Ratio (95% CI) | 否 | X轴标签 |
| --reference-line | 浮点数 | 1.0 | 否 | 参考线位置 |
| --width, -W | 整数 | 12 | 否 | 图像宽度(英寸) |
| --height, -H | 整数 | auto | 否 | 图像高度(英寸) |
| --dpi | 整数 | 300 | 否 | 图像分辨率 |
| --font-size | 整数 | 10 | 否 | 字体大小 |
| --style, -s | 字符串 | default | 否 | 预设样式(default/minimal/dark) |
输入数据格式
CSV/Excel文件必须包含以下列:
比值比值 | 数值 |
| ci_lower | 置信区间下限 | 数值 |
| ci_upper | 置信区间上限 | 数值 |
| weight | 权重(可选,用于点大小) | 数值 |
| subgroup | 亚组标签(可选) | 文本 |
示例数据
csv
study,or,cilower,ciupper,weight,subgroup
Study A,0.85,0.65,1.12,15.2,Drug A
Study B,0.72,0.55,0.94,18.5,Drug A
Study C,1.15,0.88,1.50,12.3,Drug B
Study D,0.95,0.75,1.20,14.8,Drug B
使用示例
基本用法
bash
python scripts/main.py -i meta_data.csv
自定义样式
bash
python scripts/main.py -i meta_data.csv \
--point-color=#E63946 \
--ci-color=#457B9D \
--point-size=10 \
--ci-linewidth=3 \
-t Meta-Analysis of Treatment Effects
亚组分析
bash
python scripts/main.py -i meta_data.csv \
--subgroup subgroup_column \
--summary-color=#F4A261 \
-o subgroup_forest.png
输出PDF矢量图
bash
python scripts/main.py -i meta_data.csv \
-f pdf \
-o forest_plot.pdf
预设样式
default(默认)
minimal(简约)
dark(深色)
依赖项
- - Python >= 3.8
- matplotlib >= 3.5.0
- pandas >= 1.3.0
- numpy >= 1.20.0
- openpyxl >= 3.0.0(用于读取Excel)
输出示例
生成的森林图包含:
- - 左侧:研究名称列表
- 中间:比值比值和置信区间
- 右侧:权重百分比(如有)
- 底部:合并效应值(菱形标记)
- 参考线(OR=1)
注意事项
- 1. 确保输入文件编码为UTF-8
- 建议使用对数尺度时自动转换比值比值
- 置信区间跨越1的研究不具有统计学显著性
- 权重值用于调整点大小,反映研究贡献度
风险评估
| 风险指标 | 评估 | 等级 |
|---|
| 代码执行 | Python/R脚本本地执行 | 中等 |
| 网络访问 |
无外部API调用 | 低 |
| 文件系统访问 | 读取输入文件,写入输出文件 | 中等 |
| 指令篡改 | 标准提示指南 | 低 |
| 数据泄露 | 输出文件保存到工作区 | 低 |
安全检查清单
- - [ ] 无硬编码凭据或API密钥
- [ ] 无未经授权的文件系统访问(../)
- [ ] 输出不泄露敏感信息
- [ ] 已实施提示注入保护
- [ ] 已验证输入文件路径(无../遍历)
- [ ] 输出目录限制在工作区
- [ ] 在沙盒环境中执行脚本
- [ ] 错误消息已清理(不暴露堆栈跟踪)
- [ ] 已审计依赖项
先决条件
bash
Python依赖项
pip install -r requirements.txt
评估标准
成功指标
- - [ ] 成功执行主要功能
- [ ] 输出符合质量标准
- [ ] 优雅处理边缘情况
- [ ] 性能可接受
测试用例
- 1. 基本功能:标准输入 → 预期输出
- 边缘情况:无效输入 → 优雅错误处理
- 性能:大数据集 → 可接受处理时间
生命周期状态
- - 当前阶段:草稿
- 下次审查日期:2026-03-06
- 已知问题:无
- 计划改进:
- 性能优化
- 增加功能支持