-
Notifications
You must be signed in to change notification settings - Fork 1
/
base_report.Rmd.j2
339 lines (257 loc) · 13.6 KB
/
base_report.Rmd.j2
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
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
---
title: "{{ single_state }} Scenario Report"
author: "[AUTHOR NAMES]"
output:
html_document:
df_print: paged
fig_caption: true
theme: journal
bibliography: ReportReferences.bib
params:
config_file: "config.yml"
---
Prepared by [Johns Hopkins ID Dynamics](https://iddynamics.jhsph.edu/) Working Group
Updated `r Sys.Date()`
**FOR PLANNING PURPOSES ONLY: NOT A FORECAST**
```{r setup, include=F}
## Block with general knitr options, libray load, etc. Nothing specific to the project.
knitr::opts_knit$set(root.dir = "../..") ##Assumes we are in a subdirectory of notebooks
knitr::opts_chunk$set(
echo = FALSE,
fig.align = "center",
message = FALSE,
warning = FALSE,
error = TRUE,
cache.lazy = FALSE,
bitmapType = "cairo"
)
knitr::opts_knit$set(eval.after = 'fig.cap') ##Allows us to set a variable to figure caption in the block
options(scipen=999)
#Preamble
library(tidyverse)
library(covidcommon)
library(report.generation)
```
```{r load_config}
reportStateUSPS <- "{{ single_state }}"
## Block loads the config file and geodata
config <- covidcommon:::load_config(params$config_file)
geodata <- load_geodata_file(file.path(config$spatial_setup$base_path, config$spatial_setup$geodata),
geoid_len=5)
included_geoids <- (geodata %>% filter(stateUSPS==reportStateUSPS))$geoid
```
```{r load_shapefile}
## Load shapefile
shp <- load_shape_file(filename = file.path(config$spatial_setup$base_path, config$spatial_setup$shapefile_name),
to_lower = TRUE,
geoid_len = 5)
```
[OVERALL SUMMARY TEXT GOES HERE]
<!-- Default figure is the -->
```{r load_hosp_data}
###Load state totalsk for the hospital.
scn_dirs <- paste(config$name,config$interventions$scenarios,sep='_')
state_hosp_totals <- list()
for (i in 1:length(config$hospitalization$parameters$p_death_names)) {
state_hosp_totals[[i]] <- load_hosp_geocombined_totals(scn_dirs,
config$report$formatting$scenario_labels,
name_filter= config$hospitalization$parameters$p_death_names[i],
incl_geoids=included_geoids,
geoid_len=5) %>%
mutate(pdeath=config$hospitalization$parameters$p_death[i])
}
state_hosp_totals <- dplyr::bind_rows(state_hosp_totals)
```
```{r summary_fig, summary_fig, fig.cap="**Fig. 1**: Peak hospitalizations for 15 realizations from [LIST SCENARIOS AND COLORS]"}
plot_ts_hosp_state_sample(state_hosp_totals,
scenario_labels = config$report$formatting$scenario_labels,
scenario_cols = config$report$formatting$scenario_colors,
sim_start_date = config$start_date,
sim_end_date = config$end_date,
pdeath_level = 0.01)
```
```{r}
## Load peak infections by specific date
inf_geounit_peaks <- load_inf_geounit_peaks_date(scn_dirs,
display_date = config$report$formatting$display_dates[1],
scenariolabels = config$report$formatting$scenario_labels,
incl_geoids = included_geoids,
geoid_len = 5)
```
```{r}
###Load cumulative infections on specific dates
scn_dirs <- paste(config$name,config$interventions$scenarios,sep='_')
cum_inf_dates <- load_cum_inf_geounit_dates(scn_dirs,
display_dates = config$report$formatting$display_dates,
scenariolabels = config$report$formatting$scenario_labels,
incl_geoids=included_geoids,
geoid_len=5)
```
```{r}
###Load cumulative hospitalizations on specific dates
scn_dirs <- paste(config$name,config$interventions$scenarios,sep='_')
for (i in 1:length(config$hospitalization$parameters$p_death_names)) {
cum_hosp_dates <- load_cum_hosp_geounit_date(scn_dirs,
name_filter = config$hospitalization$parameters$p_death_names[i],
display_date = config$report$formatting$display_dates,
scenariolabels = config$report$formatting$scenario_labels,
incl_geoids=included_geoids,
geoid_len=5) %>%
mutate(pdeath=config$hospitalization$parameters$p_death[i])
}
```
```{r}
## Load peak hosp_curr by specific date
for (i in 1:length(config$hospitalization$parameters$p_death_names)) {
hosp_geounit_peaks <- load_hosp_geounit_peak_date(scn_dirs,
max_var = "hosp_curr",
name_filter= config$hospitalization$parameters$p_death_names[i],
display_date = config$report$formatting$display_dates[1],
scenariolabels = config$report$formatting$scenario_labels,
incl_geoids = included_geoids,
geoid_len = 5) %>%
mutate(pdeath=config$hospitalization$parameters$p_death[i])
}
```
## State Level Results
### Summary
[DESCRIPTION OF REPORT AND SCENARIOS]
```{r}
make_scn_time_summary_table(state_hosp_totals%>%filter(pdeath==.01), config$report$formatting$display_dates)
```
### Diversity of Possible Outcomes
```{r death_histograms, fig.cap = cap}
##Chunk plots the distribution of hospitalizations at multiple time points
show_dates <- config$report$formatting$display_dates
hist_plts <- list()
for (i in 1:length(show_dates)) {
hist_plts[[i]] <- plot_hist_incidHosp_state(state_hosp_totals,
scenario_labels = config$report$formatting$scenario_labels,
scenario_cols = config$report$formatting$scenario_colors,
sim_start_date = config$start_date,
summary_date = show_dates[i],
pdeath_level = 0.01)
}
ggpubr::ggarrange(plotlist=hist_plts, nrow=1)
cap <- "**Fig 2**: Distribution of total hospitalizations by scenario at XXX time points, [LIST TIME POINTS]."
```
<!-- #### plot-ts-inc-state -->
<!-- ```{r plot-ts-inc-state} -->
<!-- plot_ts_incid_inf_state_sample(hosp_state_totals, -->
<!-- num_sim = 15, -->
<!-- # pdeath_level = , ## default is high -->
<!-- scenario_labels = config$report$formatting$scenario_labels, -->
<!-- scenario_cols = config$report$formatting$scenario_colors, -->
<!-- sim_start_date = config$start_date, -->
<!-- sim_end_date = config$end_date, -->
<!-- plot_intervention = config$report$plot_settings$plot_intervention, ## may not make sense to plot interventions if there are multiple intervention periods -->
<!-- interv_start_date = config$interventions$settings$Wuhan$period_start_date, ## N.B. these are currently hard-coded to Wuhan like settings -->
<!-- interv_end_date = config$interventions$settings$Wuhan$period_start_date) -->
<!-- ``` -->
<!-- `r #make_fig_captions("ts_incid_inf_state_sample", scenario_nums = length(config$report$formatting$scenario_labels), interv_start_date = config$interventions$settings$Wuhan$period_start_date, interv_end_date = config$interventions$settings$Wuhan$period_end_date, sim_start_date = config$start_date, sim_end_date = config$end_date, location_name = config$report_location_name, figure_num = 1)` -->
<!-- #### plot-ts-death -->
<!-- ```{r plot-ts-death} -->
<!-- plot_ts_incid_death_state_sample_allPdeath( -->
<!-- hosp_state_totals, -->
<!-- num_sims = 15, -->
<!-- scenario_labels = config$report$formatting$scenario_labels, -->
<!-- scenario_cols = config$report$formatting$scenario_colors, -->
<!-- pdeath_labels = config$report$formatting$pdeath_labels[3], -->
<!-- sim_start_date = config$start_date, -->
<!-- sim_end_date = config$end_date, -->
<!-- plot_intervention = config$report$plot_settings$plot_intervention, -->
<!-- interv_start_date = config$interventions$settings$Wuhan$period_start_date, -->
<!-- interv_end_date = config$interventions$settings$Wuhan$period_end_date -->
<!-- ) -->
<!-- ``` -->
<!-- `r #make_fig_captions("ts_incid_death_state_sample_allPdeath", scenario_nums = length(config$report$formatting$scenario_labels), interv_start_date = config$interventions$settings$Wuhan$period_start_date, interv_end_date = config$interventions$settings$Wuhan$period_end_date, sim_start_date = config$start_date, sim_end_date = config$end_date, location_name = config$report_location_name, figure_num = 1)` -->
<!-- #### plot-hist-incidHosp-state -->
<!-- ```{r plot-hist-incidHosp-state} -->
<!-- plot_hist_incidHosp_state( -->
<!-- hosp_state_totals, -->
<!-- # pdeath_level = , ## default is high -->
<!-- scenario_labels = config$report$formatting$scenario_labels, -->
<!-- scenario_cols = config$report$formatting$scenario_colors, -->
<!-- sim_start_date = config$start_date, -->
<!-- summary_date = "2020-05-14" -->
<!-- ) #ls# choose date for cumulative final size histogram of hosp occupancy -->
<!-- ``` -->
`r #make_fig_captions("hist_incidHosp_state", scenario_nums = length(config$report$formatting$scenario_labels), interv_start_date = config$interventions$settings$Wuhan$period_end_date, interv_end_date = config$interventions$settings$Wuhan$period_end_date, sim_start_date = config$start_date, sim_end_date = config$end_date, state = config$report_location_name, figure_num = 1)`
<!-- #### plot-line-hospPeak-time-county -->
<!-- ```{r plot-line-hospPeak-time-county} -->
<!-- plot_line_hospPeak_time_county( -->
<!-- hosp_cty_peaks, -->
<!-- cty_names, -->
<!-- scenario = config$report$formatting$scenario_labels[1], -->
<!-- scenario_labels = config$report$formatting$scenario_labels[1], -->
<!-- scenario_cols = config$report$formatting$scenario_colors[1], -->
<!-- start_date = config$start_date, -->
<!-- end_date = config$end_date -->
<!-- ) ## choose date for cumulative final size histogram of hosp occupancy -->
<!-- ``` -->
<!-- `r #make_fig_captions("line_hospPeak_time_county", scenario_nums = length(config$report$formatting$scenario_labels), interv_start_date = config$interventions$settings$Wuhan$period_end_date, interv_end_date = config$interventions$settings$Wuhan$period_end_date, sim_start_date = config$start_date, sim_end_date = config$end_date, location_name = config$report_location_name, figure_num = 1)` -->
<!-- `r #make_fig_captions("county_attack_rate_map", scenario_nums = length(config$report$formatting$scenario_labels), interv_start_date = config$interventions$settings$Wuhan$period_end_date, interv_end_date = config$interventions$settings$Wuhan$period_end_date, sim_start_date = config$start_date, sim_end_date = config$end_date, location_name = config$report_location_name, figure_num = 1)` -->
## Scenario Summaries
### Scenario 1: [Scenario Name]
[BRIEF SCENARIO DESCRIPTION]
[STATE LEVEL SCENARIO SUMMARY TABLE]
```{r}
make_scn_state_table(config$report$formatting$scenario_labels[1],
state_hosp_totals,
table_dates = config$report$formatting$display_dates,
pdeath_labels = config$report$formatting$pdeath_labels,
pdeath_filecode = config$hospitalization$parameters$p_death)
```
```{r}
ARmap1 <- plot_geounit_attack_rate_map(cum_inf_dates,
geodata,
shp,
scenariolabel = config$report$formatting$scenario_labels[1],
display_date = config$report$formatting$display_dates[1],
viridis_palette = "plasma")
ARmap2 <- plot_geounit_attack_rate_map(cum_inf_dates,
geodata,
shp,
scenariolabel = config$report$formatting$scenario_labels[1],
display_date = config$report$formatting$display_dates[2],
viridis_palette = "viridis")
ARmap3 <- plot_geounit_attack_rate_map(cum_inf_dates,
geodata,
shp,
scenariolabel = config$report$formatting$scenario_labels[1],
display_date = config$report$formatting$display_dates[3],
viridis_palette = "cividis")
cowplot::plot_grid(ARmap1, ARmap2, ARmap3, ncol=3)
```
[MULTI PANEL SCENARIO SUMMARY FIG]
## Appendix 1: Methods
<!-- ```{r plot-model-param-distr} -->
<!-- ## NOT WORKING - CHECK WITH JOSH BC HE WROTE THE FIG CODE -->
<!-- layout(mat = matrix(c(1,1,2,2, -->
<!-- 3,3,4,4, -->
<!-- 5,5,6,6, -->
<!-- 7,7,8,8 -->
<!-- ), nrow=4, byrow=TRUE)) -->
<!-- for(i in 1:length(config$report$plot_settings$parameters_to_display)){ -->
<!-- plot_model_parameter_distributions(config$report$plot_settings$parameters_to_display[[i]], config) -->
<!-- } -->
<!-- ``` -->
### Pipeline Overview
```{r, child=reference_chunk("PipelineDescription.Rmd")}
```
### Technical Details
#### SEIR Model
```{r, child=reference_chunk("SEIRModelDesc.Rmd")}
```
### Limitations
```{r, child=reference_chunk("limitations.Rmd")}
```
### Key Sources
```{r, child=reference_chunk("key_sources.Rmd")}
```
## Appendix 2: Supplemental State Level Tables
## Appendix 3: Detailed County Level Results
## Appendix 4: Team
```{r, child=reference_chunk("DevelopmentTeam.Rmd")}
```
## Bibliography