-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathS1.Rmd
206 lines (153 loc) · 5.7 KB
/
S1.Rmd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
---
title: "S1"
output:
html_document:
toc: true
toc_float:
smooth_scroll: FALSE
number_sections: true
bibliography: references.bib
---
```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE, message = FALSE, warning = FALSE)
library(dplyr)
library(ggplot2)
library(kableExtra)
library(patchwork)
library(pomp)
library(purrr)
library(readr)
library(readsdr)
library(stringr)
library(tictoc)
library(tidyr)
source("./R_scripts/plots.R")
source("./R_scripts/R0_estimation.R")
pop_val <- 17475415
beta_vals <- 0.724637681 * c(1, 1.5, 2)
bio_df <- read_csv("./Data/bio_params.csv",
show_col_types = FALSE)
bio_params <- as.list(bio_df$Value)
names(bio_params) <- bio_df$Parameter
```
This electronic supplementary material supports the results presented in the
main text regarding the **no-intervention** sub-models (*SEI3R* and *SEI3RD*).
Specifically, this HTML file is the rendered version of a dynamic document
(R markdown) containing the *R* code that simulates the models and produces
the plots shown in the main text. Additionally, this file includes supplementary
information to complement the discussion in the main text.
# Basic reproduction number ($\Re_0$)
In this section, we illustrate the procedure to derive an analytical expression
for the *SEI3R*'s basic reproduction number via the next-generation matrix
method. This method consists of rewriting the rates of infected states in the
form of two matrices. One matrix corresponds to the rate of appearance of new
infections ($V$ matrix), and the other one to the rate of transitions between
compartments of infected individuals ($F$ matrix). The product between $F$ and
$V^{-1}$ is known as the next-generation matrix, whose largest eigenvalue
(spectral radius) corresponds to $\Re_0$. We obtain the analytical expressions
using *Mathematica* (see *R0.nb* file in the Github repository).
## $F$ matrix
```{r, message = FALSE}
F_matrix <- read_csv("./Data/NI_F_matrix.csv", show_col_types = FALSE)
c_names <- colnames(F_matrix)
c_names[1] <- ""
colnames(F_matrix) <- c_names
F_matrix |>
kbl(escape = FALSE) |> kable_styling(full_width = FALSE)
```
## $V$ matrix
```{r, message = FALSE}
F_matrix <- read_csv("./Data/NI_V_matrix.csv", show_col_types = FALSE)
c_names <- colnames(F_matrix)
c_names[1] <- ""
colnames(F_matrix) <- c_names
F_matrix |>
kbl(escape = FALSE) |> kable_styling(full_width = FALSE)
```
## Spectral radius
\begin{equation}
\Re_0 = \beta \left(\omega \left(\frac{1}{\gamma }+\frac{1}{\nu
}\right) + \frac{\eta -\eta \omega }{\kappa }\right)
\end{equation}
# Simulations
## SEI3R
We simulate the SEI3R model ~1000 times to produce Fig 2 in the main text.
```{r}
set.seed(1550)
samples <- runif(997, beta_vals[[1]], beta_vals[[3]])
betas <- c(samples, beta_vals) |> sort()
c_df <- data.frame(par_beta = betas)
```
```{r}
mdl <- read_xmile("./models/1A_SEI3R.stmx",
const_list = bio_params)
fn <- "./saved_objects/1A_sens.rds"
if(!file.exists(fn)) {
# Without mortality (SEI3R)
wo_mort <- sd_sensitivity_run(mdl$deSolve_components,
consts_df = c_df,
integ_method = "rk4", start_time = 0,
stop_time = 150,
timestep = 1 / 16,
multicore = TRUE)
SEI3R_df <- wo_mort |> select(time, C, iter, par_beta)
saveRDS(SEI3R_df, fn)
} else SEI3R_df <- readRDS(fn)
```
```{r}
SEI3R_df <- SEI3R_df |>
mutate(c = C / pop_val,
model = "SEI3R")
```
```{r}
g <- plot_fig_02(SEI3R_df)
ggsave("./plots/Fig_02_Attack_rate.pdf", plot = g,
height = 3, width = 5)
```
## SEI3RD
We compare the simulations from the *SEI3R* against those produced by a similar
model that accounts for disease-induced mortality (*SEI3RD*). This comparison
indicates that the dynamics created by both models are nearly equivalent at a
mortality level similar to that of the 1918 influenza pandemic
[@Taubenberger_Morens_2006]. This comparison is not performed to indicate that
the number of deaths is negligible. In fact, the *SEI3RD* estimates between
*290 000* and *360 000* disease-induced deaths. However, omitting
disease-induced mortality does not compromise the overall insights derived from
this work and facilitates the incorporation of additional structures.
```{r}
mdl2 <- read_xmile("./models/1B_SEI3RD.stmx",
const_list = c(bio_params,
list(par_rho = 0.025)))
```
```{r}
fn <- "./saved_objects/1B_sens.rds"
if(!file.exists(fn)) {
# With mortality (SEI3RD)
mort_df <- sd_sensitivity_run(mdl2$deSolve_components,
consts_df = c_df,
integ_method = "rk4", start_time = 0,
stop_time = 150,
timestep = 1 / 16,
multicore = TRUE)
SEI3RD_df <- mort_df |> select(time, C, iter, par_beta)
saveRDS(SEI3RD_df, fn)
} else SEI3RD_df <- readRDS(fn)
```
```{r}
SEI3RD_df <- SEI3RD_df |>
mutate(c = C / pop_val,
model = "SEI3RD")
```
```{r, fig.cap = "Fig 1. Comparison between the SEI3R and the SEI3RD", fig.height = 4}
df <- bind_rows(SEI3R_df, SEI3RD_df)
plot_fig_02(df)
```
### Final size
To further illustrate that incorporating disease-induced mortality does not
substantially impact the dynamics of the within-host profile, we compare the
attack rates obtained from both variants at day 150.
```{r, fig.cap = "Fig 2. Distribution of the final size by model"}
df2 <- df |> filter(time == 150)
plot_final_size(df2)
```
# References