Skip to content

Commit a57bff9

Browse files
Joel HellewellJoel Hellewell
authored andcommitted
Changes for second submission, needs neatening up
1 parent cb6b214 commit a57bff9

File tree

4 files changed

+105
-21
lines changed

4 files changed

+105
-21
lines changed

R/box_plot_max_weekly_cases.R

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,8 @@ box_plot_max_weekly_cases <- function(results = NULL,
132132
ggplot2::aes(label = label_extinct),
133133
col = "black", fill = "white",
134134
size = 4,
135-
point.padding = NA)
135+
point.padding = NA) +
136+
ggplot2::coord_cartesian(ylim=c(0,y_lim))
136137

137138

138139
return(plot)

R/figures2to4.R

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ make_figure_2a <- function() {
2828
out %<>% tidyr::gather("dist", "value", -x)
2929

3030

31-
means <- data.frame(x = c(3.83, 9.1),
31+
medians <- data.frame(x = c(3.43, 8.09),
3232
dist = c("delay_sars", "delay_wuhan")) %>%
3333
dplyr::mutate(dist = factor(dist,
3434
levels = c("delay_sars",
@@ -56,7 +56,7 @@ make_figure_2a <- function() {
5656
palette = "Set1") +
5757
ggplot2::scale_colour_brewer(guide = "none",
5858
palette = "Set1") +
59-
ggplot2::geom_vline(data = means,
59+
ggplot2::geom_vline(data = medians,
6060
ggplot2::aes(xintercept = x,
6161
col = as.factor(dist)),
6262
lty = 2,

R/supp_fig_9.R

Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
make_figure_S9 <- function(sweep_results = NULL){
2+
temp <- sweep_results %>% filter(index_R0 == 1.5,
3+
theta=="15%",
4+
delay == "SARS",
5+
prop.asym == 0,
6+
num.initial.cases==20,
7+
control_effectiveness == 0.8)
8+
9+
10+
ext_df <- temp$sims[[1]] %>% group_by(sim) %>%
11+
dplyr::filter(week %in% 12:16) %>%
12+
dplyr::summarise(extinct =
13+
ifelse(all(weekly_cases == 0 &
14+
cumulative < 5000),
15+
1, 0)) %>%
16+
dplyr::ungroup()
17+
18+
p1 <- full_join(temp$sims[[1]],ext_df) %>%
19+
filter(sim < 50) %>%
20+
ggplot(aes(x=week,y=cumulative,col=as.factor(extinct),group=sim)) + geom_line(alpha=0.6) +
21+
cowplot::theme_cowplot() + coord_cartesian(ylim=c(0,1000),xlim=c(0,16)) +
22+
scale_color_manual(name="Simulation controlled",values=c("dodgerblue1"),guide="none") +
23+
ylab("Cumulative cases") +
24+
ggtitle("R0 = 1.5") +
25+
xlab("Outbreak week")
26+
27+
28+
temp <- sweep_results %>% filter(index_R0 == 2.5,
29+
theta=="15%",
30+
delay == "SARS",
31+
prop.asym == 0,
32+
num.initial.cases==20,
33+
control_effectiveness == 0.8)
34+
35+
ext_df <- temp$sims[[1]] %>% group_by(sim) %>%
36+
dplyr::filter(week %in% 12:16) %>%
37+
dplyr::summarise(extinct =
38+
ifelse(all(weekly_cases == 0 &
39+
cumulative < 5000),
40+
1, 0)) %>%
41+
dplyr::ungroup()
42+
43+
p2 <- full_join(temp$sims[[1]],ext_df) %>%
44+
filter(sim < 50) %>%
45+
ggplot(aes(x=week,y=cumulative,col=as.factor(extinct),group=sim)) + geom_line(alpha=0.6) +
46+
cowplot::theme_cowplot() + coord_cartesian(ylim=c(0,1000),xlim=c(0,16)) +
47+
scale_color_manual(name="Simulation controlled",values=c("firebrick1","dodgerblue1"),labels=c("Uncontrolled","Controlled")) +
48+
ggtitle("R0 = 2.5") +
49+
ylab("Cumulative cases") +
50+
xlab("Outbreak week")
51+
52+
temp <- sweep_results %>% filter(index_R0 == 3.5,
53+
theta=="15%",
54+
delay == "SARS",
55+
prop.asym == 0,
56+
num.initial.cases==20,
57+
control_effectiveness == 0.8)
58+
59+
ext_df <- temp$sims[[1]] %>% group_by(sim) %>%
60+
dplyr::filter(week %in% 12:16) %>%
61+
dplyr::summarise(extinct =
62+
ifelse(all(weekly_cases == 0 &
63+
cumulative < 5000),
64+
1, 0)) %>%
65+
dplyr::ungroup()
66+
67+
p3 <- full_join(temp$sims[[1]],ext_df) %>%
68+
filter(sim < 50) %>%
69+
ggplot(aes(x=week,y=cumulative,col=as.factor(extinct),group=sim)) + geom_line(alpha=0.6) +
70+
cowplot::theme_cowplot() + coord_cartesian(ylim=c(0,1000),xlim=c(0,16)) +
71+
scale_color_manual(name="Simulation controlled",values=c("firebrick1","dodgerblue1"),labels=c("Uncontrolled","Controlled")) +
72+
ylab("Cumulative cases") +
73+
ggtitle("R0 = 3.5") +
74+
xlab("Outbreak week")
75+
p3
76+
p1 + p2 + p3 + patchwork::plot_layout(guides="collect")
77+
}
78+

inst/scripts/generate_figures.R

Lines changed: 23 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ ringbp::box_plot_max_weekly_cases(results = sweep_results, cap_cases = 5000,
5757
filt_control_effectiveness = 0.4,
5858
num_initial_cases = 20, flip_coords = FALSE,
5959
facet_scales = "fixed", record_params = F,
60-
prop_asym = 0, y_lim = 225)
60+
prop_asym = 0, y_lim = 125)
6161

6262
ggplot2::ggsave("inst/plots/fig_5.pdf", height = 7, width = 12,
6363
useDingbats = FALSE)
@@ -120,7 +120,7 @@ ringbp::box_plot_max_weekly_cases(results = sweep_results,
120120
num_initial_cases = 40,
121121
facet_scales = "fixed",
122122
record_params = F,
123-
y_lim = 450)
123+
y_lim = 200)
124124

125125
ggplot2::ggsave("inst/plots/S_fig_5_B.pdf", height = 5, width = 10,
126126
useDingbats = FALSE)
@@ -134,7 +134,7 @@ ringbp::box_plot_max_weekly_cases(results = sweep_results,
134134
num_initial_cases = 20,
135135
facet_scales = "fixed",
136136
record_params = F,
137-
y_lim = 1000)
137+
y_lim = 100)
138138

139139
ggplot2::ggsave("inst/plots/S_fig_5_C.pdf", height = 5, width = 10,
140140
useDingbats = FALSE)
@@ -176,19 +176,24 @@ ggplot2::ggsave("inst/plots/S_fig_7c.pdf", height = 5, width = 7,
176176
useDingbats = FALSE)
177177
ggplot2::ggsave("inst/plots/S_fig_7c.png", height = 5, width = 7)
178178

179-
## S6
180-
181-
ringbp::box_plot_max_weekly_cases(results = results_dispersion_flu,
182-
cap_cases = 5000,
183-
extinct_thresold = 0.05,
184-
filt_control_effectiveness = 0.4,
185-
num_initial_cases = 40,
186-
flip_coords = F,
187-
prop_asym = 0,
188-
facet_scales = "fixed",
189-
record_params = F,
190-
y_lim = 400)
191-
192-
ggplot2::ggsave("inst/plots/S_fig_6.pdf", height = 8, width = 12,
179+
make_figure_S9()
180+
ggplot2::ggsave("inst/plots/S_fig_9.pdf", height = 4.5, width = 11,
193181
useDingbats = FALSE)
194-
ggplot2::ggsave("inst/plots/S_fig_6.png", height = 8, width = 12)
182+
ggplot2::ggsave("inst/plots/S_fig_9.png", height = 4.5, width = 11)
183+
184+
# ## S6
185+
#
186+
# ringbp::box_plot_max_weekly_cases(results = results_dispersion_flu,
187+
# cap_cases = 5000,
188+
# extinct_thresold = 0.05,
189+
# filt_control_effectiveness = 0.4,
190+
# num_initial_cases = 40,
191+
# flip_coords = F,
192+
# prop_asym = 0,
193+
# facet_scales = "fixed",
194+
# record_params = F,
195+
# y_lim = 400)
196+
#
197+
# ggplot2::ggsave("inst/plots/S_fig_6.pdf", height = 8, width = 12,
198+
# useDingbats = FALSE)
199+
# ggplot2::ggsave("inst/plots/S_fig_6.png", height = 8, width = 12)

0 commit comments

Comments
 (0)