How to build Reviewer-2-proof Jupyter notebooks that still rerun six months later
Structure reproducible Python and Jupyter notebooks with fixed seeds, file fingerprints, ITT sensitivity checks, and clean-start Verify reruns.
By Amir Hesham

You submit a manuscript in October, feel relieved for five minutes, and move on to the next experiment. In April, Reviewer 2 asks for a per-protocol sensitivity analysis excluding five deviated samples and a check on Batch 1 alone. You reopen your Jupyter notebook, hit Run All, and watch it crash on a renamed column, or worse, run cleanly and print a slightly different confidence interval than Table 2.
That failure is normal in standard notebooks. When Pimentel and colleagues tested roughly 1.4 million Jupyter notebooks from GitHub, only about 24% ran without errors and about 4% reproduced the same outputs. The culprits are almost always the same four things: unpinned package versions, hidden out-of-order cell state, unseeded randomness, and raw CSV files that quietly changed on disk.
Here is a practical five-step workflow to build a Jupyter notebook that survives a PI audit, a biostatistician's inspection, and a Reviewer 2 revision six months later, anchored in a real 80-sample preclinical cohort notebook you can run right now.
Download the verified files for this workflow: preclinical_cohort_study.csv (80 samples, SHA-256 91980dd47fbe9c31) and reviewer_proof_verified.ipynb (executed clean-start with zero errors).
Step 1: Lock study definitions in project notes before cell one
Most revision headaches start because study definitions live in someone's head instead of inside the workspace. Which endpoint is primary? Are protocol deviations excluded from the primary comparison or kept under Intention-to-Treat? How is change from baseline defined?
Before running your first analysis cell, write those rules once in your project brief or top Markdown cell: primary endpoint is day28_marker - baseline_marker, primary analysis is Intention-to-Treat across all 80 samples, and secondary sensitivity checks cover Per-Protocol and Batch 1 alone.
In Dalliance, project-level definitions live in a persistent brief that the assistant reads before every cell, so you make those calls once. For cell-level decisions, Dalliance prints how it read your prompt and underlines each assumption as a clickable control right next to the output. You can click an underlined assumption yourself in the interactive demo on dalliance.io before installing anything.
Step 2: Pin runtime versions and input file fingerprints
If a figure changes six months later, you need to know in five seconds whether the shift came from a pandas upgrade or from a labmate overwriting preclinical_cohort_study.csv.
Start Cell 1 by recording your runtime environment and hashing every input file before computing a single statistic. In reviewer_proof_verified.ipynb, Cell 2 outputs:
Python: 3.14.7 | pandas: 3.1.1 | numpy: 2.5.5 | scipy: 1.18.1
Input file: preclinical_cohort_study.csv | Rows: 80 | SHA-256: 91980dd47fbe9c31...
Dalliance handles this tracking automatically on every save by pinning Python versions, package versions, and data file fingerprints inside the .ipynb metadata. If someone modifies the source CSV months later and you reopen the notebook, you know immediately before trusting a rerun.
Step 3: Fix random seeds on every bootstrap or resampling cell
Bootstrap confidence intervals, permutation tests, and train-test splits drift on every run unless you seed the random number generator explicitly. Calling np.random.choice without a fixed seed guarantees that your 95% confidence interval moves by a few hundredths every time a reviewer re-executes the cell.
In reviewer_proof_verified.ipynb, every 2,000-iteration bootstrap uses np.random.default_rng(42). In Dalliance, running Verify scans for unseeded random calls and flags them before you submit, so a non-deterministic cell never sneaks into a manuscript supplement.
Step 4: Keep primary and Reviewer-2 sensitivity checks side by side
Instead of scrambling to rebuild an analysis six months after submission, run your primary Intention-to-Treat comparison and your obvious sensitivity checks in one clean function right inside the original notebook.
Here is the exact verified output from Cell 4 of reviewer_proof_verified.ipynb on preclinical_cohort_study.csv:
| Analysis | n (Treatment) | n (Control) | Mean diff (Day 28 - Baseline) | Bootstrap 95% CI low | Bootstrap 95% CI high | Welch p-value |
|---|---|---|---|---|---|---|
| Primary: Intention-to-Treat (all 80) | 40 | 40 | +9.54 | 6.48 | 12.44 | 1.88e-08 |
| Sensitivity: Per-Protocol (excl 5 deviated) | 37 | 38 | +10.95 | 8.14 | 13.55 | 5.96e-11 |
| Sensitivity: Batch_1 only | 30 | 30 | +11.28 | 8.06 | 14.52 | 9.11e-09 |
Every reviewer question you are likely to receive is already answered with exact, repeatable numbers. Excluding the 5 deviated samples moves the mean difference from +9.54 (95% CI 6.48 to 12.44, p = 1.88e-08) to +10.95 (95% CI 8.14 to 13.55, p = 5.96e-11). Restricting to Batch_1 (n = 30 per arm) gives +11.28 (95% CI 8.06 to 14.52, p = 9.11e-09). The treatment effect holds cleanly across all three cuts.
Here is the exact self-contained Python block executed in Cells 2 and 4 of the verified notebook:
import hashlib
import sys
import numpy as np
import pandas as pd
import scipy
from scipy import stats
csv_path = "preclinical_cohort_study.csv"
sha = hashlib.sha256(open(csv_path, "rb").read()).hexdigest()
df = pd.read_csv(csv_path)
df["delta"] = df["day28_marker"] - df["baseline_marker"]
print(f"Python: {sys.version.split()[0]} | pandas: {pd.__version__} | numpy: {np.__version__} | scipy: {scipy.__version__}")
print(f"Input file: {csv_path} | Rows: {len(df)} | SHA-256: {sha[:16]}...")
def compare_arms(sub, label, seed=42):
trt = sub.loc[sub["arm"] == "Treatment", "delta"].to_numpy()
ctl = sub.loc[sub["arm"] == "Control", "delta"].to_numpy()
diff = trt.mean() - ctl.mean()
_, p_welch = stats.ttest_ind(trt, ctl, equal_var=False)
rng_b = np.random.default_rng(seed)
boots = [
rng_b.choice(trt, len(trt), replace=True).mean() - rng_b.choice(ctl, len(ctl), replace=True).mean()
for _ in range(2000)
]
ci_lo, ci_hi = np.percentile(boots, [2.5, 97.5])
return {
"Analysis": label,
"n_trt": len(trt),
"n_ctl": len(ctl),
"Mean_diff": round(float(diff), 2),
"Boot_95CI_low": round(float(ci_lo), 2),
"Boot_95CI_high": round(float(ci_hi), 2),
"Welch_p": f"{p_welch:.2e}",
}
rows = [
compare_arms(df, "Primary: Intention-to-Treat (all 80)"),
compare_arms(df[df["protocol_status"] == "per_protocol"], "Sensitivity: Per-Protocol (excl 5 deviated)"),
compare_arms(df[df["batch"] == "Batch_1"], "Sensitivity: Batch_1 only"),
]
print(pd.DataFrame(rows).to_string(index=False))
Step 5: Verify from a clean start and hand off standard .ipynb files
Before you paste a single number into a manuscript table, restart your Python kernel and run every cell from top to bottom. Never trust a notebook whose cells were executed out of order while tweaking filters.
Dalliance builds this check directly into the workspace:
- Stale cell detection. Edit an upstream cleaning step and Dalliance marks every downstream cell stale so old variables cannot silently contaminate a later chart.
- One-click Verify with zero AI calls. Clicking Verify restarts Python from a clean start, reruns every cell in order, flags unseeded randomness, and highlights any cell whose output changed. No credits are spent during verification.
- Open handoff to anyone. Every notebook is a standard
.ipynbfile stored locally on Mac or Windows across x64 and Arm machines. Your PI, department biostatistician, or journal reviewer can open it in standard Jupyter or on GitHub without a Dalliance account, and saved cells rerun locally forever even if you have no credits or no active subscription. - Local files, zero desktop telemetry. Your raw CSVs and notebooks stay on your computer, and the desktop app sends zero telemetry, meaning no analytics, crash reports, or usage tracking. On each prompt, only your question and what the assistant reads go through Dalliance Cloud to the model provider. That covers column names, up to 15 rows of printed tables, charts it draws, and files it opens. Because Dalliance does not offer a HIPAA BAA today, use it for wet-lab, preclinical, genomics, biostatistics, and de-identified studies.
Make clean-start verification your lab default
You can run this workflow on your own cohort CSV today with Dalliance Starter for $0, giving you 100 one-time credits on verified email sign-up, no credit card required, local Python setup included, and saved notebooks that rerun free forever. For ongoing lab analysis across models from 18+ providers, including Opus-class models, Pro Annual is $199/year, or $16.58/month effective with two months free. You get 1,000 credits per month with rollover up to a 2,000-credit cap and a single Polar PDF invoice that carries your institution name, VAT number, and billing address, where you can include grant or department details. Buying for a research group? Request the 5-seat Lab Pack at $799/year via manual invoice at dalliance.io.