Skip to content

Commit

Permalink
Changes for second submission, needs neatening up
Browse files Browse the repository at this point in the history
  • Loading branch information
Joel Hellewell authored and Joel Hellewell committed Feb 19, 2020
1 parent cb6b214 commit a57bff9
Show file tree
Hide file tree
Showing 4 changed files with 105 additions and 21 deletions.
3 changes: 2 additions & 1 deletion R/box_plot_max_weekly_cases.R
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,8 @@ box_plot_max_weekly_cases <- function(results = NULL,
ggplot2::aes(label = label_extinct),
col = "black", fill = "white",
size = 4,
point.padding = NA)
point.padding = NA) +
ggplot2::coord_cartesian(ylim=c(0,y_lim))


return(plot)
Expand Down
4 changes: 2 additions & 2 deletions R/figures2to4.R
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ make_figure_2a <- function() {
out %<>% tidyr::gather("dist", "value", -x)


means <- data.frame(x = c(3.83, 9.1),
medians <- data.frame(x = c(3.43, 8.09),
dist = c("delay_sars", "delay_wuhan")) %>%
dplyr::mutate(dist = factor(dist,
levels = c("delay_sars",
Expand Down Expand Up @@ -56,7 +56,7 @@ make_figure_2a <- function() {
palette = "Set1") +
ggplot2::scale_colour_brewer(guide = "none",
palette = "Set1") +
ggplot2::geom_vline(data = means,
ggplot2::geom_vline(data = medians,
ggplot2::aes(xintercept = x,
col = as.factor(dist)),
lty = 2,
Expand Down
78 changes: 78 additions & 0 deletions R/supp_fig_9.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
make_figure_S9 <- function(sweep_results = NULL){
temp <- sweep_results %>% filter(index_R0 == 1.5,
theta=="15%",
delay == "SARS",
prop.asym == 0,
num.initial.cases==20,
control_effectiveness == 0.8)


ext_df <- temp$sims[[1]] %>% group_by(sim) %>%
dplyr::filter(week %in% 12:16) %>%
dplyr::summarise(extinct =
ifelse(all(weekly_cases == 0 &
cumulative < 5000),
1, 0)) %>%
dplyr::ungroup()

p1 <- full_join(temp$sims[[1]],ext_df) %>%
filter(sim < 50) %>%
ggplot(aes(x=week,y=cumulative,col=as.factor(extinct),group=sim)) + geom_line(alpha=0.6) +
cowplot::theme_cowplot() + coord_cartesian(ylim=c(0,1000),xlim=c(0,16)) +
scale_color_manual(name="Simulation controlled",values=c("dodgerblue1"),guide="none") +
ylab("Cumulative cases") +
ggtitle("R0 = 1.5") +
xlab("Outbreak week")


temp <- sweep_results %>% filter(index_R0 == 2.5,
theta=="15%",
delay == "SARS",
prop.asym == 0,
num.initial.cases==20,
control_effectiveness == 0.8)

ext_df <- temp$sims[[1]] %>% group_by(sim) %>%
dplyr::filter(week %in% 12:16) %>%
dplyr::summarise(extinct =
ifelse(all(weekly_cases == 0 &
cumulative < 5000),
1, 0)) %>%
dplyr::ungroup()

p2 <- full_join(temp$sims[[1]],ext_df) %>%
filter(sim < 50) %>%
ggplot(aes(x=week,y=cumulative,col=as.factor(extinct),group=sim)) + geom_line(alpha=0.6) +
cowplot::theme_cowplot() + coord_cartesian(ylim=c(0,1000),xlim=c(0,16)) +
scale_color_manual(name="Simulation controlled",values=c("firebrick1","dodgerblue1"),labels=c("Uncontrolled","Controlled")) +
ggtitle("R0 = 2.5") +
ylab("Cumulative cases") +
xlab("Outbreak week")

temp <- sweep_results %>% filter(index_R0 == 3.5,
theta=="15%",
delay == "SARS",
prop.asym == 0,
num.initial.cases==20,
control_effectiveness == 0.8)

ext_df <- temp$sims[[1]] %>% group_by(sim) %>%
dplyr::filter(week %in% 12:16) %>%
dplyr::summarise(extinct =
ifelse(all(weekly_cases == 0 &
cumulative < 5000),
1, 0)) %>%
dplyr::ungroup()

p3 <- full_join(temp$sims[[1]],ext_df) %>%
filter(sim < 50) %>%
ggplot(aes(x=week,y=cumulative,col=as.factor(extinct),group=sim)) + geom_line(alpha=0.6) +
cowplot::theme_cowplot() + coord_cartesian(ylim=c(0,1000),xlim=c(0,16)) +
scale_color_manual(name="Simulation controlled",values=c("firebrick1","dodgerblue1"),labels=c("Uncontrolled","Controlled")) +
ylab("Cumulative cases") +
ggtitle("R0 = 3.5") +
xlab("Outbreak week")
p3
p1 + p2 + p3 + patchwork::plot_layout(guides="collect")
}

41 changes: 23 additions & 18 deletions inst/scripts/generate_figures.R
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ ringbp::box_plot_max_weekly_cases(results = sweep_results, cap_cases = 5000,
filt_control_effectiveness = 0.4,
num_initial_cases = 20, flip_coords = FALSE,
facet_scales = "fixed", record_params = F,
prop_asym = 0, y_lim = 225)
prop_asym = 0, y_lim = 125)

ggplot2::ggsave("inst/plots/fig_5.pdf", height = 7, width = 12,
useDingbats = FALSE)
Expand Down Expand Up @@ -120,7 +120,7 @@ ringbp::box_plot_max_weekly_cases(results = sweep_results,
num_initial_cases = 40,
facet_scales = "fixed",
record_params = F,
y_lim = 450)
y_lim = 200)

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

ggplot2::ggsave("inst/plots/S_fig_5_C.pdf", height = 5, width = 10,
useDingbats = FALSE)
Expand Down Expand Up @@ -176,19 +176,24 @@ ggplot2::ggsave("inst/plots/S_fig_7c.pdf", height = 5, width = 7,
useDingbats = FALSE)
ggplot2::ggsave("inst/plots/S_fig_7c.png", height = 5, width = 7)

## S6

ringbp::box_plot_max_weekly_cases(results = results_dispersion_flu,
cap_cases = 5000,
extinct_thresold = 0.05,
filt_control_effectiveness = 0.4,
num_initial_cases = 40,
flip_coords = F,
prop_asym = 0,
facet_scales = "fixed",
record_params = F,
y_lim = 400)

ggplot2::ggsave("inst/plots/S_fig_6.pdf", height = 8, width = 12,
make_figure_S9()
ggplot2::ggsave("inst/plots/S_fig_9.pdf", height = 4.5, width = 11,
useDingbats = FALSE)
ggplot2::ggsave("inst/plots/S_fig_6.png", height = 8, width = 12)
ggplot2::ggsave("inst/plots/S_fig_9.png", height = 4.5, width = 11)

# ## S6
#
# ringbp::box_plot_max_weekly_cases(results = results_dispersion_flu,
# cap_cases = 5000,
# extinct_thresold = 0.05,
# filt_control_effectiveness = 0.4,
# num_initial_cases = 40,
# flip_coords = F,
# prop_asym = 0,
# facet_scales = "fixed",
# record_params = F,
# y_lim = 400)
#
# ggplot2::ggsave("inst/plots/S_fig_6.pdf", height = 8, width = 12,
# useDingbats = FALSE)
# ggplot2::ggsave("inst/plots/S_fig_6.png", height = 8, width = 12)

0 comments on commit a57bff9

Please sign in to comment.