adaptive-trial-simulator
Design and simulate adaptive clinical trials with interim analyses, decision rules, and operating-characteristic summaries; use when planning adaptive designs or comparing stopping, enrichment, or sample-size re-estimation strategies.
- License 许可
- MIT
- 最近更新
- 2026-10-12
- Stars
- ★ 2
- Forks
- 0
01 前言 Front Matter
- name
- adaptive-trial-simulator
- author
- AIPOCH
- license
- MIT
- description
- Design and simulate adaptive clinical trials with interim analyses, decision rules, and operating-characteristic summaries; use when planning adaptive designs or comparing stopping, enrichment, or sample-size re-estimation strategies.
02 资源文件 3
- 参考文档POLISH_CHANGELOG.md667 B
- 参考文档references/audit-reference.md648 B
- 脚本scripts/main.py27.8 KB
03 SKILL.md 正文
Adaptive Trial Simulator
Statistical simulation platform for designing and validating adaptive clinical trial designs in silico. Enables optimization of interim analysis strategies, sample size adaptation, and early stopping rules while maintaining Type I error control.
Quick Check
Use this command to verify that the packaged script entry point can be parsed before deeper execution.
python -m py_compile scripts/main.py
Audit-Ready Commands
Use these concrete commands for validation. They are intentionally self-contained and avoid placeholder paths.
python -m py_compile scripts/main.py
python scripts/main.py --help
python scripts/main.py --design group_sequential --n-simulations 50
python scripts/main.py --design adaptive_reestimate --n-simulations 25 --optimize
When to Use
- Use this skill when the task is to Design and simulate adaptive clinical trials with interim analyses.
- Use this skill for protocol design tasks that require explicit assumptions, bounded scope, and a reproducible output format.
- Use this skill when the response must stay inside the documented task boundary instead of expanding into adjacent work.
Workflow
- Confirm the user objective, required inputs, and non-negotiable constraints before doing detailed work.
- Validate that the request matches the documented scope and stop early if the task would require unsupported assumptions.
- Use the packaged script path or the documented reasoning path with only the inputs that are actually available.
- Return a structured result that separates assumptions, deliverables, risks, and unresolved items.
- If execution fails or inputs are incomplete, switch to the fallback path and state exactly what blocked full completion.
Features
- Design Simulation: Monte Carlo validation of adaptive designs
- Sample Size Re-estimation: Adapt sample size based on interim data
- Early Stopping Rules: Futility and efficacy boundary optimization
- Type I Error Control: Validate alpha spending strategies
- Multi-Arm Designs: Drop-the-loser and seamless Phase II/III
- Power Optimization: Identify designs with maximum power efficiency
Usage
Basic Usage
# Run standard group sequential design
python scripts/main.py
# Adaptive design with sample size re-estimation
python scripts/main.py --design adaptive_reestimate
# Optimize design parameters
python scripts/main.py --optimize
Parameters
| Parameter | Type | Default | Required | Description |
|---|---|---|---|---|
--design |
str | group_sequential | No | Trial design type |
--n-simulations |
int | 10000 | No | Number of Monte Carlo simulations |
--sample-size |
int | 200 | No | Initial sample size per arm |
--effect-size |
float | 0.3 | No | Effect size (Cohen's d) |
--alpha |
float | 0.05 | No | Type I error rate |
--power |
float | 0.80 | No | Target statistical power |
--interim-looks |
int | 1 | No | Number of interim analyses |
--spending-function |
str | obrien_fleming | No | Alpha spending function |
--reestimate-method |
str | promising_zone | No | Sample size re-estimation method |
--output |
str | results.json | No | Output file path |
--visualize |
flag | False | No | Generate visualization charts |
--optimize |
flag | False | No | Search for optimal design parameters |
Advanced Usage
# Full adaptive design with visualization
python scripts/main.py \
--design adaptive_reestimate \
--n-simulations 50000 \
--sample-size 250 \
--effect-size 0.35 \
--interim-looks 2 \
--spending-function obrien_fleming \
--visualize \
--output adaptive_results.json
Design Types
| Design Type | Description | Use Case |
|---|---|---|
| Group Sequential | Fixed interim looks with stopping boundaries | Standard adaptive trials |
| Adaptive Re-estimate | Sample size adjustment based on interim data | Uncertain effect size |
| Drop the Loser | Multi-arm trials dropping inferior arms | Phase II dose selection |
Spending Functions
| Function | Characteristics | Early Boundary |
|---|---|---|
| O'Brien-Fleming | Conservative early | High Z-scores early |
| Pocock | Aggressive early | Lower Z-scores throughout |
| Power Family | Moderate (ρ=3) | Balanced approach |
Output Example
{
"design_config": {
"design_type": "adaptive_reestimate",
"sample_size_per_arm": 200,
"effect_size": 0.3,
"alpha": 0.05,
"target_power": 0.8
},
"simulation_results": {
"power": 0.8234,
"type_i_error": 0.0481,
"expected_sample_size": 385.2,
"early_stop_rate": {
"efficacy": 0.1523,
"futility": 0.0841
}
}
}
Technical Difficulty: HIGH
References
- references/audit-reference.md - Audit-ready assumptions, supported design modes, and fallback boundaries for constrained runs
⚠️ AI independent acceptance status: manual inspection required This skill requires:
- Python 3.8+ environment
- NumPy, SciPy, and Matplotlib packages
- Understanding of clinical trial statistics
Dependencies
pip install -r requirements.txt
Requirements
numpy>=1.20.0
scipy>=1.7.0
matplotlib>=3.4.0
Risk Assessment
| Risk Indicator | Assessment | Level |
|---|---|---|
| Code Execution | Python scripts with mathematical calculations | Medium |
| Network Access | No network access | Low |
| File System Access | Writes simulation results | Low |
| Instruction Tampering | Statistical parameters could affect results | Medium |
| Data Exposure | No sensitive data exposure | Low |
Security Checklist
- [x] No hardcoded credentials or API keys
- [x] No unauthorized file system access
- [x] Output does not expose sensitive information
- [x] Input parameters validated
- [x] Error messages sanitized
- [x] Dependencies audited
Prerequisites
pip install -r requirements.txt
python scripts/main.py --help
Evaluation Criteria
Success Metrics
- [ ] Simulations run without errors
- [ ] Type I error controlled at nominal level
- [ ] Power estimates are accurate
- [ ] Visualizations generated correctly
Test Cases
- Basic Simulation: Default parameters → Valid results
- Different Designs: All design types → Appropriate behavior
- Optimization Mode: --optimize flag → Finds optimal parameters
- Visualization: --visualize flag → Charts generated
Lifecycle Status
- Current Stage: Draft
- Next Review Date: 2026-03-15
- Known Issues: Type checking warnings with numpy arrays
- Planned Improvements:
- Bayesian adaptive designs
- Multi-arm multi-stage (MAMS) support
- Enhanced visualization options
References
Available in references/:
- Adaptive design statistical theory
- Regulatory guidance documents
- Alpha spending function literature
- Sample size re-estimation methods
Limitations
- Statistical Complexity: Requires biostatistics expertise
- Simulation Time: Large simulations may take hours
- Simplified Models: Does not capture all real-world complexities
- Regulatory Consultation: Results should be validated with regulators
⚠️ DISCLAIMER: This tool provides simulation results for research and planning purposes only. All clinical trial designs should be reviewed by qualified biostatisticians and regulatory experts before implementation.
Output Requirements
Every final response should make these items explicit when they are relevant:
- Objective or requested deliverable
- Inputs used and assumptions introduced
- Workflow or decision path
- Core result, recommendation, or artifact
- Constraints, risks, caveats, or validation needs
- Unresolved items and next-step checks
Error Handling
- If required inputs are missing, state exactly which fields are missing and request only the minimum additional information.
- If the task goes outside the documented scope, stop instead of guessing or silently widening the assignment.
- If
scripts/main.pyfails, report the failure point, summarize what still can be completed safely, and provide a manual fallback. - Do not fabricate files, citations, data, search results, or execution outcomes.
Input Validation
This skill accepts requests that match the documented purpose of adaptive-trial-simulator and include enough context to complete the workflow safely.
Do not continue the workflow when the request is out of scope, missing a critical input, or would require unsupported assumptions. Instead respond:
adaptive-trial-simulatoronly handles its documented workflow. Please provide the missing required inputs or switch to a more suitable skill.
Response Template
Use the following fixed structure for non-trivial requests:
- Objective
- Inputs Received
- Assumptions
- Workflow
- Deliverable
- Risks and Limits
- Next Checks
If the request is simple, you may compress the structure, but still keep assumptions and limits explicit when they affect correctness.
When Not to Use
- Do not proceed when required input files, identifiers, parameters, or context are missing — ask the user to provide them first.
- Do not assume capabilities beyond this skill's declared scope when the user requests external operations or inferences.
- Do not proceed without user confirmation when overwriting existing results, executing high-cost batch operations, or expanding task scope.
Required Inputs
| Field | Required | Format/Source | Example | If Missing |
|---|---|---|---|---|
| User task description | Yes | Text | Research question, writing goal, analysis objective | Stop and ask user to provide |
| Primary input material | Depends on task | Text, file path, ID, table, or literature | PMID, PDF, CSV, DOCX, keywords, etc. | Specify which material type is missing |
| Output preference | No | Text | Language, format, target journal, template | Use skill default format |
Output Contract
- Primary output: Structured result or target file aligned with this skill's objective.
- Optional output: Intermediate check notes, issue list, supplementary suggestions, or generated file paths.
- Format requirement: Unless the user specifies otherwise, prefer stable, reviewable Markdown or JSON; if the skill's bundled script requires a fixed format, use that format.
- If partially complete: Must explicitly mark as PARTIAL and state which steps are completed and which remain.
Failure Handling
- Missing critical input: Explicitly state which fields, files, or identifiers are missing and pause.
- Script, template, or resource execution failure: Report the failing step, likely cause, and recovery suggestions — do not silently degrade.
- Partial completion only: Return the verified portion first, then list remaining blockers and suggested next steps.
User Checkpoints
- Before executing batch processing, overwriting files, long-running searches, or multi-stage generation, confirm scope and output format with the user.
- Before proceeding when a key judgment is ambiguous, evidence is insufficient, or the workflow is entering the next stage, confirm with the user.
Quick Validation
- Check that key scripts, templates, or reference file paths this skill depends on exist.
- Check that the final output contains the core fields, sections, or files specified for this task.
- Check that results clearly mark assumptions, limitations, and incomplete items.
04 同仓库更多 Skills
bio-workflows-metabolomics-pipeline
Orchestrates the untargeted LC-MS metabolomics pipeline end-to-end (xcms 4.x feature extraction, QC/drift/normalization, confidence-stratified annotation, permutation-validated statistics, background-aware pathway mapping), naming what each stage decides and where it silently fails. Use when running a full LC-MS metabolomics study from raw mzML to enriched pathways and needing the honest handoffs between stages. Each stage defers to its component skill for parameters and traps; for stable-isotope flux (a separate branch, not this untargeted flow) see metabolomics/isotope-tracing.
bio-metabolomics-xcms-preprocessing
Programmatic untargeted LC-MS feature extraction in R with the modern xcms 4.x MsExperiment/XcmsExperiment API, taking raw mzML to a feature table via CentWave peak detection, retention-time alignment, peak-density correspondence, gap-filling, CAMERA redundancy collapse, and built-in QC feature filtering. Use when converting centroided LC-MS runs into a features-by-samples matrix and deciding centWave/grouping/alignment parameters. For drift correction and QC/CV filtering execution see metabolomics/normalization-qc; for metabolite identification see metabolomics/metabolite-annotation; for the MS-DIAL GUI alternative with MS2Dec deconvolution see metabolomics/msdial-preprocessing; for downstream statistics see metabolomics/statistical-analysis.
bio-metabolomics-statistical-analysis
Decision-grade statistical analysis for metabolomics intensity tables. Covers transformation and scaling (Pareto vs unit-variance as a hidden hypothesis), unsupervised structure (PCA/HCA for QC), permutation-validated PLS-DA/OPLS-DA (R2 vs Q2, double CV, VIP as heuristic), univariate testing (Welch/Mann-Whitney/ANOVA/LMM with covariate adjustment), and dependence-aware multiple testing. Use when testing which metabolites differ, building or validating a discriminant model, choosing a scaling, or correcting many correlated tests. For sample-wise normalization/drift correction see metabolomics/normalization-qc; for ML classifiers and selection-inside-CV leakage see machine-learning/biomarker-discovery and machine-learning/model-validation; for pathway interpretation see metabolomics/pathway-mapping; for design/power/multiplicity regime see experimental-design/multiple-testing.
bio-metabolomics-pathway-mapping
Maps metabolomics results to biological pathways via over-representation (ORA), metabolite-set enrichment (MSEA/QEA), mummichog/PSEA on raw m/z peaks, and network-diffusion enrichment (FELLA), with correct background-set construction and honest interpretive ceilings. Use when interpreting differential metabolites or an untargeted LC-MS feature table in pathway context, choosing ORA vs MSEA vs mummichog vs topology, or setting the reference/background set. For annotation confidence levels feeding ORA see metabolomics/metabolite-annotation; for gene-set concepts see pathway-analysis/go-enrichment and pathway-analysis/gsea; for joint gene+metabolite pathways see multi-omics-integration/mofa-integration.
bio-metabolomics-normalization-qc
Designs QC, corrects signal drift, removes batch effects, filters features, normalizes samples, and imputes missing values for untargeted LC-MS/GC-MS metabolomics, framing each step as a measurement model that can create or erase biological signal. Use when processing a peak/feature table before statistical analysis, choosing a drift-correction or sample-normalization method, deciding QC RSD vs D-ratio filtering, or handling left-censored missing values. The feature table is produced by metabolomics/xcms-preprocessing or metabolomics/msdial-preprocessing; transformation/scaling for modeling defers to metabolomics/statistical-analysis; cross-study design issues link to experimental-design/batch-design.
bio-metabolomics-msdial-preprocessing
Runs the MS-DIAL preprocessing workflow (peak picking, MS2Dec spectral deconvolution, alignment, gap-filling) and imports the alignment-result table into R or Python with honest filtering. Use when preprocessing LC-MS DDA/DIA (SWATH) or GC-MS raw data with MS-DIAL, deciding MS-DIAL vs XCMS, configuring the MSDIALCUI console run, or parsing an MS-DIAL export into a clean feature matrix. For programmatic R peak detection and the feature-table-as-artifact framing see metabolomics/xcms-preprocessing; for lipid annotation mode see metabolomics/lipidomics; for MSI-level confidence honesty see metabolomics/metabolite-annotation; for drift correction and QC see metabolomics/normalization-qc.