-
Notifications
You must be signed in to change notification settings - Fork 1
/
fig_overview.R
60 lines (53 loc) · 1.88 KB
/
fig_overview.R
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
suppressPackageStartupMessages({
require(data.table)
require(ggplot2)
require(ggh4x)
})
.debug <- "~/Dropbox/Covid-WHO-vax"
.args <- if (interactive()) sprintf(c(
"%s/inputs/scenarios.rds", "%s/outputs/quantiles.rds",
"%s/figures/overview.png"
), .debug) else commandArgs(trailingOnly = TRUE)
scn.dt <- readRDS(.args[1])
qs.dt <- readRDS(.args[2])
tarfile <- tail(.args, 1)
plot.dt <- qs.dt[scn.dt, on=.(scenarioId == id)]
plot.dt[order(simday), anniversary := round((simday - simday[1])/356), by = scenarioId ]
p.del <- ggplot(plot.dt[outcome == "cases" & start_date == "2021-01-01"]) +
facet_nested(tar_age + campaign_dur_days ~ vax_eff) +
aes(
anniversary, color = age,
linetype = factor(vax_imm_dur_yrs),
group = interaction(age, vax_imm_dur_yrs)
) +
geom_line(aes(y=cum.averted.md)) +
theme_minimal() +
scale_color_continuous("Age Category",guide = "legend") +
scale_linetype_manual(
"Vaccine Expected\nDurability (yrs)",
values = c(`2.5`="dotted", `5`="solid")
) + scale_x_continuous(
"Years since initial vaccination",
breaks = 0:10
) + scale_y_continuous(
"Cumulative cases averted (median)"
)
p.eff <- ggplot(plot.dt[outcome == "cases" & start_date == "2021-01-01"]) +
facet_nested(tar_age + campaign_dur_days ~ vax_eff) +
aes(
anniversary, color = age,
linetype = factor(vax_imm_dur_yrs),
group = interaction(age, vax_imm_dur_yrs)
) +
geom_line(aes(y=cum.eff.md)) +
theme_minimal() +
scale_color_continuous("Age Category",guide = "legend") +
scale_linetype_manual(
"Vaccine Expected\nDurability (yrs)",
values = c(`2.5`="dotted", `5`="solid")
) + scale_x_continuous(
"Years since initial vaccination",
breaks = 0:10
) + scale_y_continuous(
"Cumulative Effectiveness (cases, median)"
)