diff --git a/NAMESPACE b/NAMESPACE index 0c02565..c585871 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -12,7 +12,6 @@ export(outbreak_step) export(parameter_sweep) export(rename_variables_for_plotting) export(scenario_sim) -export(sub_plot) importFrom(cowplot,panel_border) importFrom(cowplot,theme_minimal_hgrid) importFrom(data.table,data.table) @@ -28,25 +27,18 @@ importFrom(dplyr,ungroup) importFrom(furrr,future_map) importFrom(furrr,future_options) importFrom(ggplot2,aes) -importFrom(ggplot2,coord_cartesian) importFrom(ggplot2,coord_flip) importFrom(ggplot2,facet_grid) -importFrom(ggplot2,facet_wrap) -importFrom(ggplot2,geom_line) -importFrom(ggplot2,geom_point) importFrom(ggplot2,ggplot) importFrom(ggplot2,ggtitle) importFrom(ggplot2,labs) importFrom(ggplot2,scale_fill_gradient) -importFrom(ggplot2,scale_x_continuous) importFrom(ggplot2,scale_x_discrete) importFrom(ggplot2,scale_y_continuous) importFrom(ggplot2,stat_summary) importFrom(ggplot2,theme) importFrom(ggplot2,theme_bw) importFrom(ggplot2,vars) -importFrom(ggplot2,xlab) -importFrom(ggplot2,ylab) importFrom(ggrepel,geom_label_repel) importFrom(magrittr,"%>%") importFrom(purrr,map2) diff --git a/R/aux_functions.R b/R/aux_functions.R index f8ce2ee..072e6b0 100644 --- a/R/aux_functions.R +++ b/R/aux_functions.R @@ -76,77 +76,3 @@ detect_extinct <- function(outbreak_df_week = NULL, cap_cases = NULL, week_ran dplyr::ungroup() } - - -#' Create sub-plot for supplementary figures -#' -#' @param theta.in character filtering value for theta -#' @param delay.in character filtering value for delay -#' @param prop.asym.in numeric filtering value for proportion of asymptomatic cases -#' @param num.initial.cases.in integer filtering value for number of initial cases -#' @param index_R0.in numeric filtering value for community R0 value -#' @param res.in data.table of results from parameter sweep -#' @param facet.by the column name to facet the plot by. -#' @param col.by the column name to use for colours in the plot. -#' -#' @export -#' @importFrom dplyr filter mutate -#' @importFrom ggplot2 ggplot aes geom_line geom_point facet_wrap ylab xlab scale_x_continuous scale_y_continuous coord_cartesian -#' @importFrom cowplot panel_border -#' -#' -sub_plot <- function(theta.in = "15%", - delay.in = "SARS", - prop.asym.in = 0, - num.initial.cases.in = 20, - index_R0.in = 2.5, - res.in = NULL, - facet.by = NULL, - col.by = NULL) { - - col.by <- ggplot2::ensym(col.by) - - res.in %>% - dplyr::filter(theta %in% theta.in, - delay %in% delay.in, - prop.asym %in% prop.asym.in, - num.initial.cases %in% num.initial.cases.in, - index_R0 %in% index_R0.in) %>% - # Ugly factor re-naming - dplyr::mutate(num.initial.cases = factor(num.initial.cases, - levels = c(5, 20, 40), - labels = c("5 cases", - "20 cases", - "40 cases"))) %>% - dplyr::mutate(delay = factor(delay, - levels = c("SARS", "Wuhan"), - labels = c("Short isolation delay", - "Long isolation delay"))) %>% - dplyr::mutate(prop.asym = factor(prop.asym, - levels = c(0, 0.1), - labels = c("No asymptomatic cases ", - "10% cases asmyptomatic"))) %>% - dplyr::mutate(theta = factor(theta, - levels = c("<1%", "15%", "30%"), - labels = c("<1% trans. pre-onset", - "15% trans. pre-onset", - "30% trans. pre-onset"))) %>% - # Put plot together - ggplot2::ggplot(ggplot2::aes(x = control_effectiveness, - y = pext, - color = as.factor(!!col.by))) + - ggplot2::geom_line(size = 0.75) + - ggplot2::geom_point(shape = 21, - col = "black", - ggplot2::aes(fill = as.factor(!!col.by)), size = 3) + - ggplot2::facet_wrap(as.formula(paste(". ~", facet.by))) + - ggplot2::ylab("Simulated outbreaks controlled (%)") + - ggplot2::xlab("Contacts traced (%)") + - ggplot2::scale_x_continuous(breaks = seq(0, 1, 0.2), - labels = seq(0, 100, 20)) + - ggplot2::scale_y_continuous(breaks = seq(0, 1, 0.2), - labels = seq(0, 100, 20)) + - cowplot::panel_border() + - ggplot2::coord_cartesian(ylim = c(0, 1)) - -} diff --git a/man/sub_plot.Rd b/man/sub_plot.Rd deleted file mode 100644 index 560e7ba..0000000 --- a/man/sub_plot.Rd +++ /dev/null @@ -1,37 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/aux_functions.R -\name{sub_plot} -\alias{sub_plot} -\title{Create sub-plot for supplementary figures} -\usage{ -sub_plot( - theta.in = "15\%", - delay.in = "SARS", - prop.asym.in = 0, - num.initial.cases.in = 20, - index_R0.in = 2.5, - res.in = NULL, - facet.by = NULL, - col.by = NULL -) -} -\arguments{ -\item{theta.in}{character filtering value for theta} - -\item{delay.in}{character filtering value for delay} - -\item{prop.asym.in}{numeric filtering value for proportion of asymptomatic cases} - -\item{num.initial.cases.in}{integer filtering value for number of initial cases} - -\item{index_R0.in}{numeric filtering value for community R0 value} - -\item{res.in}{data.table of results from parameter sweep} - -\item{facet.by}{the column name to facet the plot by.} - -\item{col.by}{the column name to use for colours in the plot.} -} -\description{ -Create sub-plot for supplementary figures -}