Custom Python implementation for the Bayesian network meta-analysis presented in:
Comparative Efficacy and Safety of Perioperative Enfortumab Vedotin-Pembrolizumab, Dose-Dense MVAC, and Gemcitabine-Cisplatin-Durvalumab in Muscle-Invasive Bladder Cancer: A Bayesian Network Meta-Analysis
A lightweight framework for Bayesian Network Meta-Analysis (NMA) using Metropolis-Hastings MCMC sampling, designed for trial-level aggregate data in star network topologies (common comparator design). No dependency on external Bayesian packages (PyMC, Stan).
- Bayesian NMA with fixed-effects and random-effects models
- Bucher indirect treatment comparison (ITC) for HR, OR, and RR
- SUCRA treatment rankings from posterior samples
- Pseudo-IPD reconstruction from published Kaplan-Meier curves (Guyot et al. 2012)
- Weibull parametric fitting for trials without digitizable KM data
- Cox proportional hazards on reconstructed IPD
- Logistic regression for binary endpoint IPD-derived ORs
- Convergence diagnostics: Gelman-Rubin R-hat, effective sample size (ESS)
pip install -r requirements.txtimport numpy as np
from src.nma_engine import prepare_nma_data, run_nma_mcmc, nma_summary, compute_sucra
# Define trials (each experimental arm vs common comparator)
trials = {
'Trial_A': {
'hr_efs': 0.60, 'hr_efs_lo': 0.45, 'hr_efs_hi': 0.80,
'exp_label': 'Drug X',
},
'Trial_B': {
'hr_efs': 0.75, 'hr_efs_lo': 0.58, 'hr_efs_hi': 0.97,
'exp_label': 'Drug Y',
},
}
# Prepare and run NMA
treatments = ['Control', 'Drug X', 'Drug Y']
nma_data = prepare_nma_data(trials, endpoint='efs', treatments=treatments)
np.random.seed(42)
d_samples, tau, trts = run_nma_mcmc(nma_data, n_iter=50000, burnin=10000)
# Results
print(nma_summary(d_samples, trts, metric='HR'))
print(compute_sucra(d_samples, trts, higher_is_better=False))See examples/example_star_nma.py for a complete working example with 3 trials.
| Module | Description |
|---|---|
src/nma_engine.py |
MCMC sampler (FE/RE), NMA summary, SUCRA, R-hat, ESS |
src/itc.py |
Bucher ITC for HR, OR, RR; risk difference; NNH |
src/ipd_reconstruction.py |
Guyot algorithm, Weibull fitting, Cox PH, logistic regression |
y_k ~ N(d[trt_k], se_k^2)
d ~ N(0, 100) # vague prior
y_k ~ N(delta_k, se_k^2)
delta_k ~ N(d[trt_k], tau^2)
d ~ N(0, 100) # vague prior
tau ~ HalfNormal(0, 0.5)
- Metropolis-Hastings with Gaussian proposals (SD = 0.05)
- 4 independent chains
- 50,000-80,000 iterations, 10,000-20,000 burn-in
- Convergence: R-hat < 1.05, ESS > 1,000
- OSF Preregistration: https://osf.io/7un2d/
- PROSPERO: [Registration ID pending]
- Dias S et al. Stat Med. 2010;29(7-8):932-944.
- Salanti G et al. J Clin Epidemiol. 2011;64(2):163-171.
- Bucher HC et al. J Clin Epidemiol. 1997;50(6):683-691.
- Guyot P et al. BMC Med Res Methodol. 2012;12:9.
If you use this framework, please cite:
Subiela JD, Gonzalez-Padilla DA, Villacampa F, et al. Comparative Efficacy and Safety of Perioperative Enfortumab Vedotin-Pembrolizumab, Dose-Dense MVAC, and Gemcitabine-Cisplatin-Durvalumab in Muscle-Invasive Bladder Cancer: A Bayesian Network Meta-Analysis. [Journal pending]. 2026.
- Study-specific analysis (data + results): Available upon publication at github.com/jdsubiela/EV-P-vs-MVAC-vs-GC-Durva
MIT License. See LICENSE.