P.01 · Case study
Viral dynamics pipeline
The code behind my first paper. It fits a model of SARS-CoV-2 infection to viral load data from 30 macaques and measures how much the drug favipiravir changes each part of the infection.
- Role
- First author, all code
- Where
- TCU · Dr. Hana Dobrovolny
- Stack
- Python · NumPy · SciPy · pandas · Matplotlib
- Year
- 2026
01 — The question
Favipiravir slows SARS-CoV-2 down, but which part of the infection does it change? Fewer cells getting infected, less virus made per cell, or faster clearance? And do you reach the same answer if you fit each animal on its own or fit the average of each group? The second question is the one in the paper's title.
02 — The data
Thirty cynomolgus macaques, each with a viral load measured over the days after infection.
03 — The model
A target-cell-limited model with an eclipse phase. Healthy cells (T) get infected, wait in an eclipse stage (I₁), start producing virus (I₂), and die. Five numbers control the whole curve: the infection rate β, eclipse rate k, cell death rate δ, virus production p and clearance c.
dT/dt = −βTV dI₁/dt = βTV − kI₁ dI₂/dt = kI₁ − δI₂ dV/dt = pI₂ − cV
From those I also compute R₀ = βp / (cδ), the number of cells one infected cell goes on to infect, and the infecting time √(2 / pβ). You can try the model yourself in Fig. R1 on the main page.
04 — The pipeline
- 01Fit every animalMulti-start Nelder-Mead, then an L-BFGS-B polish inside log-scale bounds
- 02Bootstrap each fit1,000 residual-bootstrap replicates per animal, run in parallel
- 03Fit the group averagesGeometric-mean curve per group, 1,000 replicates, Mann-Whitney tests against control
- 04–09FiguresHistograms, violin plots, per-group fits, R₀ and infecting time
- 10Corner plots34 joint-distribution plots for the supplementary material
05 — What was hard
Local minima
One starting guess often got stuck on a bad fit. Each animal now starts from six spread-out guesses and keeps the best result.
Fits that never finish
Some parameter combinations made the solver hang. Every guess runs on a timer and gets skipped if it takes too long.
30,000 bootstrap fits
That is too slow to run in one sitting, so the bootstrap runs across all CPU cores and saves a checkpoint every 50 replicates. An interrupted run picks up where it stopped.
Uneven group sizes
Groups of 5 and 10 animals are hard to compare fairly. The tests average over 100 random subsamples of 10 from each bootstrap distribution.