From c7f9b3874cb260f73fe4857ae55db4e41a0e90a3 Mon Sep 17 00:00:00 2001 From: Bisaloo <10783929+Bisaloo@users.noreply.github.com> Date: Thu, 21 Mar 2024 13:42:44 +0000 Subject: [PATCH] =?UTF-8?q?Deploying=20to=20gh-pages=20from=20@=20epiverse?= =?UTF-8?q?-trace/episoap@a44eda57a04a42fc9a23aaaf29491c42e9e18a10=20?= =?UTF-8?q?=F0=9F=9A=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apple-touch-icon-120x120.png | Bin 17363 -> 17363 bytes apple-touch-icon-152x152.png | Bin 23394 -> 23394 bytes apple-touch-icon-180x180.png | Bin 28615 -> 28615 bytes apple-touch-icon-60x60.png | Bin 6453 -> 6453 bytes apple-touch-icon-76x76.png | Bin 9320 -> 9320 bytes apple-touch-icon.png | Bin 28615 -> 28615 bytes articles/pipelines.html | 66 +++++++++++++++++------------------ favicon-16x16.png | Bin 1290 -> 1290 bytes favicon-32x32.png | Bin 2516 -> 2516 bytes index.html | 17 +++++---- pkgdown.yml | 2 +- search.json | 2 +- 12 files changed, 42 insertions(+), 45 deletions(-) diff --git a/apple-touch-icon-120x120.png b/apple-touch-icon-120x120.png index 4173791f9efd3be76370c7a87d62740af0b2a817..e55cc7bd530b5bd1c0ae54d4843dc37b42bf07e5 100644 GIT binary patch delta 59 zcmccI&Um?pwp F`2c$;6Yc;2 delta 59 zcmccI&Um??a diff --git a/apple-touch-icon-152x152.png b/apple-touch-icon-152x152.png index 81315d8cc7c7e49c09c0cf7b2c785a82d8a5b511..16b7f64b6863d0c2bc8670851a7717596fafd583 100644 GIT binary patch delta 59 zcmaE~jq%Yo#tAiST71*i&+*&XWEjP7Vq|4#qHSPcWniFcT+u%HP?Qp~SV-Oh>&c&^ F@&R-%6c7La delta 59 zcmaE~jq%Yo#tAiS!Ya-aZYXVRGK}Ikw6rod(>5@$GBBvLvrL7V2(nnwH0JVq|4#rfpzgWni#rP3F4E>iJ5@VuwFo6q+27 GpAP_*f)zpl delta 59 zcmX?ppYiy8#tAiS!m1|IUu@afG%b(c(9+7-T-(6F%D~{hr_rU!>iJ5@V(Ub@@+L>* G=K}zts}!{W diff --git a/apple-touch-icon-60x60.png b/apple-touch-icon-60x60.png index 290d7a4d1e58458d64d1846b0131a6c490a3c1d4..74a5f23930f1e6b03f590dacc01888f5ae687c33 100644 GIT binary patch delta 57 zcmdmLwAE-r4VxC%#6uC`8=F`p_)Uzg3=Omm46FDmjZG{P{DziR#zxu(237_Jy@j%+lc!23A&dRdS$cBvF^PNt D_O%h+ diff --git a/apple-touch-icon-76x76.png b/apple-touch-icon-76x76.png index 4405bad5af9bc7231c78e3e46cc7e6fe3d9fdc30..10125ad601fa1c5843eb515420488d33a647603d 100644 GIT binary patch delta 57 zcmaFi@xo(54VxDCv!fXYH#V6o^P3o185(LE7+4t?lyiqGOg^Ekge=Au_I}RfpUU|F DN$?XB delta 57 zcmaFi@xo(54V$o{@h_dV8=K6P`3)_tjE%Jo46Fny{>lhPvv|7 DCKnQ1 diff --git a/apple-touch-icon.png b/apple-touch-icon.png index 6204b381a7abb20aeaae5e663b4b7cfc27d503fd..8ddb0e90848d461c0bbc429715c5656af8fecf18 100644 GIT binary patch delta 59 zcmX?ppYiy8#tAiST7uHcC+^h?d03oG%b(c(9+7-LfgQ=%D_OA(aCzUdcG2}SVYXP_Q?_X F`2cP$6IlQN diff --git a/articles/pipelines.html b/articles/pipelines.html index 9b8e8799..c33ed363 100644 --- a/articles/pipelines.html +++ b/articles/pipelines.html @@ -160,7 +160,7 @@

Transmissibility pipelineTransmissibility pipelineTransmissibility pipelineTransmissibility pipelinef+j<$;_rDkyNcIzgeGIhmqgJ$jZn>+rYrez+m;B`jp98EK0~?w;mq9F?lvi FJ^;kz5nuoS delta 59 zcmeC;>f+j<$;>9KZ237_Jyr)YpOg7InstallationUsage

Reports are provided a rmarkdown templates. You can load them either via RStudio graphical interface

-
-Graphical interface to open a soap rmarkdown template in RStudio
Graphical interface to open a soap rmarkdown template in RStudio
-
-

or by running:

+
Graphical interface to open a soap rmarkdown template in RStudio

or by running:

 rmarkdown::draft(file = "myreport.Rmd", template = "transmissibility", package = "episoap")

To get a list of the template reports available in this package, you can run:

@@ -122,11 +121,11 @@

Usage

System dependencies

You may need to install system dependencies:

-
# macOS
-brew install libsodium cmake
-
-# Linux (Debian based)
-apt install libsodium-dev cmake
+
# macOS
+brew install libsodium cmake
+
+# Linux (Debian based)
+apt install libsodium-dev cmake
diff --git a/pkgdown.yml b/pkgdown.yml index 1aa2f4a2..951a24f4 100644 --- a/pkgdown.yml +++ b/pkgdown.yml @@ -5,7 +5,7 @@ articles: pipelines: pipelines.html design: design.html episoap: episoap.html -last_built: 2024-03-21T13:19Z +last_built: 2024-03-21T13:42Z urls: reference: https://epiverse-trace.github.io/episoap/reference article: https://epiverse-trace.github.io/episoap/articles diff --git a/search.json b/search.json index 1593bba1..aaaf422a 100644 --- a/search.json +++ b/search.json @@ -1 +1 @@ -[{"path":"https://epiverse-trace.github.io/episoap/CONTRIBUTING.html","id":null,"dir":"","previous_headings":"","what":"Contributing to episoap","title":"Contributing to episoap","text":"outlines propose change episoap. detailed info contributing , epiverse-trace packages, please see development contributing guide.","code":""},{"path":"https://epiverse-trace.github.io/episoap/CONTRIBUTING.html","id":"updating-or-creating-rmarkdown-templates","dir":"","previous_headings":"","what":"Updating or creating Rmarkdown templates","title":"Contributing to episoap","text":"main value episoap package Rmarkdown templates provides. section details proceed wish update one existing templates add new one. adding new code, whether form new template, updating existing template, please try hardcode settings parameters possible. want reports usable ---box many contexts possible.","code":""},{"path":"https://epiverse-trace.github.io/episoap/CONTRIBUTING.html","id":"template-location","dir":"","previous_headings":"","what":"Template location","title":"Contributing to episoap","text":"documented relevant RStudio documentation page, Rmarkdown templates located specific folder: inst/rmarkdown/templates/.","code":""},{"path":"https://epiverse-trace.github.io/episoap/CONTRIBUTING.html","id":"adding-a-new-template","dir":"","previous_headings":"Template location","what":"Adding a new template","title":"Contributing to episoap","text":"self-contained generic pipeline can used many contexts, kind epidemic pathogen, contribute new template. Follow instructions relevant RStudio documentation page . specific conventions templates provided package: packages used report cited end document data read folder named data/ templates include diagram indicating workflow provided package (example transmissibility report) alternative branches pipeline provided child Rmarkdown documents contained rmdchunks folder. child documents can called main document following chunk:","code":"```{r, child=paste0(\"rmdchunks/\", params$alternative_branch, \".Rmd\")} ```"},{"path":"https://epiverse-trace.github.io/episoap/CONTRIBUTING.html","id":"editing-an-existing-template","dir":"","previous_headings":"Template location","what":"Editing an existing template","title":"Contributing to episoap","text":"way welcome new templates, can fix, improve refine existing template editing files relevant folder inst/rmarkdown/templates/.","code":""},{"path":"https://epiverse-trace.github.io/episoap/CONTRIBUTING.html","id":"pull-request-process","dir":"","previous_headings":"","what":"Pull request process","title":"Contributing to episoap","text":"Fork package clone onto computer. haven’t done , recommend using usethis::create_from_github(\"epiverse-trace/data_pipelines\", fork = TRUE). Install development dependencies devtools::install_dev_deps(), make sure package passes R CMD check running devtools::check(). R CMD check doesn’t pass cleanly, ’s good idea ask help continuing. Create Git branch pull request (PR). recommend using usethis::pr_init(\"brief-description--change\"). Make changes, commit git, create PR running usethis::pr_push(), following prompts browser. title PR briefly describe change. body PR contain Fixes #issue-number. user-facing changes, add bullet top NEWS.md (.e. just first header). Follow style described https://style.tidyverse.org/news.html.","code":""},{"path":"https://epiverse-trace.github.io/episoap/CONTRIBUTING.html","id":"code-style","dir":"","previous_headings":"","what":"Code style","title":"Contributing to episoap","text":"New code follow tidyverse style guide. can use styler package apply styles, please don’t restyle code nothing PR. use roxygen2, Markdown syntax, documentation. use testthat unit tests. Contributions test cases included easier accept.","code":""},{"path":"https://epiverse-trace.github.io/episoap/CONTRIBUTING.html","id":"code-of-conduct","dir":"","previous_headings":"","what":"Code of Conduct","title":"Contributing to episoap","text":"Please note episoap project released Contributor Code Conduct. contributing project agree abide terms.","code":""},{"path":"https://epiverse-trace.github.io/episoap/LICENSE.html","id":null,"dir":"","previous_headings":"","what":"MIT License","title":"MIT License","text":"Copyright (c) 2023 episoap authors Permission hereby granted, free charge, person obtaining copy software associated documentation files (“Software”), deal Software without restriction, including without limitation rights use, copy, modify, merge, publish, distribute, sublicense, /sell copies Software, permit persons Software furnished , subject following conditions: copyright notice permission notice shall included copies substantial portions Software. SOFTWARE PROVIDED “”, WITHOUT WARRANTY KIND, EXPRESS IMPLIED, INCLUDING LIMITED WARRANTIES MERCHANTABILITY, FITNESS PARTICULAR PURPOSE NONINFRINGEMENT. EVENT SHALL AUTHORS COPYRIGHT HOLDERS LIABLE CLAIM, DAMAGES LIABILITY, WHETHER ACTION CONTRACT, TORT OTHERWISE, ARISING , CONNECTION SOFTWARE USE DEALINGS SOFTWARE.","code":""},{"path":"https://epiverse-trace.github.io/episoap/articles/design.html","id":"package-and-version-management","dir":"Articles","previous_headings":"","what":"Package and version management","title":"Design principles","text":"Breaking changes R package updates one major sources non-reproducibility headaches R users levels. guard users , also ensure provided templates work box, throughout time given episoap version CRAN, pin specific versions dependencies, via renv. recognize approach practical situations, particular, differs dependency management framework R python packages. However, believe best trade-usability, maintainability flexibility context pipeline templates: ensures pipelines work long-term, independently release timings machine-specific characteristics (particular pre-existing package library) doesn’t blur lines package installation package loading steps doesn’t interfere user existing package library. words, doesn’t permanently modify system settings. can read dedicated issue context behind choice possible downsides.","code":""},{"path":"https://epiverse-trace.github.io/episoap/articles/design.html","id":"pinned-version-updates","dir":"Articles","previous_headings":"Package and version management","what":"Pinned version updates","title":"Design principles","text":"avoid forcing users deal obsolete package versions, update template code work latest CRAN version package, just updating episoap CRAN running renv::embed() Rmarkdown files.","code":""},{"path":"https://epiverse-trace.github.io/episoap/articles/episoap.html","id":"loading-reports","dir":"Articles","previous_headings":"","what":"Loading reports","title":"Introduction to episoap: A Store of Outbreak Analytics Pipelines","text":"Reports provided rmarkdown templates. can load either via RStudio graphical interface running: get list template reports available package, can run:","code":"rmarkdown::draft( file = \"myreport.Rmd\", template = \"transmissibility\", package = \"episoap\" ) episoap::list_templates() #> [1] \"transmissibility\""},{"path":"https://epiverse-trace.github.io/episoap/articles/episoap.html","id":"customising-reports","dir":"Articles","previous_headings":"","what":"Customising reports","title":"Introduction to episoap: A Store of Outbreak Analytics Pipelines","text":"reports classic rmarkdown files. familiar rmarkdown literate programming, can edit piece report see fit. users want ready--use solution, reports already set provide multiple options analysis box. example, transmissibility report, can choose estimate reproduction number data different tools, EpiEstim EpiNow2. achieved changing value rt_estimator parameter. , can done graphical interface using ‘Knit parameters’ button RStudio: running: Alternatively, can also directly value various parameters rmarkdown::render() call:","code":"# Load template in temporary directory for this vignette. You will probably # wish to save it somewhere else. rmarkdown::draft( file = file.path(tempdir(), \"myreport\"), template = \"transmissibility\", package = \"episoap\", edit = FALSE ) # Get a graphical interface to select the parameters to use in this report rmarkdown::render( input = file.path(tempdir(), \"myreport\", \"myreport.Rmd\"), output_file = \"custom_report.html\", params = \"ask\", quiet = TRUE ) # Report using EpiEstim to estimate Rt rmarkdown::render( input = file.path(tempdir(), \"myreport\", \"myreport.Rmd\"), output_file = \"EpiEstim_report.html\", params = list(rt_estimator = \"EpiEstim\"), quiet = TRUE ) # Report using R0 to estimate Rt rmarkdown::render( input = file.path(tempdir(), \"myreport\", \"myreport.Rmd\"), output_file = \"EpiNow2_report.html\", params = list(rt_estimator = \"EpiNow2\"), quiet = TRUE )"},{"path":[]},{"path":"https://epiverse-trace.github.io/episoap/articles/pipelines.html","id":"transmissibility-pipeline","dir":"Articles","previous_headings":"","what":"Transmissibility pipeline","title":"List of included pipelines","text":"template estimating transmissibility (.e., fast disease spreads) stratified population. performs basic descriptive analyses, uses different approaches estimating transmissibility.","code":"--- title: \"Estimating transmissibility with population stratification\" author: Thibaut Jombart, Hugo Gruson date: \"`r Sys.Date()`\" output: rmarkdown::html_document: code_folding: \"hide\" link-citations: no params: epicurve_unit: label: \"An integer or character indicating the (fixed) size of the time interval used for computing the incidence. Passed as the `interval` argument in `incidence2::incidence()`.\" value: \"week\" incomplete_days: label: \"Number of days to exclude from the estimation of Rt since data is likely to still be incomplete.\" value: 7 r_estim_window: label: \"Number of days to include to get the latest observed value of Rt.\" value: 21 use_epiparameter_database: label: \"Should the serial interval distribution be extracted directly from the epiparameter package?\" value: FALSE disease_name: label: \"Name of the disease of interest, also used to select diseases in the epiparameter database if `use_parameter_database = TRUE`.\" value: \"COVID-19\" si_mean: label: \"Mean of the distribution for serial interval if not using value from epiparameter. Ignored if `use_epiparameter_database = TRUE`.\" value: 4.2 si_sd: label: \"Standard deviation of the distribution for serial interval if not using value from epiparameter. Ignored if `use_epiparameter_database = TRUE`.\" value: 4.9 si_dist: label: \"Choice of probability distribution for serial interval if not using value from epiparameter. Ignored if `use_epiparameter_database = TRUE`.\" value: \"gamma\" choices: [\"beta\", \"binom\", \"cauchy\", \"chisq\", \"exp\", \"f\", \"gamma\", \"geom\", \"hyper\", \"lnorm\", \"logis\", \"nbinom\", \"norm\", \"pois\", \"smirnov\", \"t\", \"tukey\", \"unif\", \"weibull\", \"wilcox\"] data_file: label: \"Name of file containing the count data over time\" value: \"data/covid_hosp_uk_20201024.xlsx\" input: file rt_estimator: label: \"Which R package to use for Rt estimation\" value: \"i2extras\" choices: [\"EpiEstim\", \"EpiNow2\", \"i2extras\", \"R0\"] bibliography: - grateful-refs.bib --- ```{r lockfile, include = FALSE, message = FALSE} renv::use( \"MASS@7.3-59\", \"Matrix@1.6-3\", \"R.methodsS3@1.8.2\", \"R.oo@1.25.0\", \"R.utils@2.12.3\", \"R6@2.5.1\", \"RColorBrewer@1.1-3\", \"Rcpp@1.0.11\", \"askpass@1.2.0\", \"backports@1.4.1\", \"base64enc@0.1-3\", \"bit64@4.0.5\", \"bit@4.0.5\", \"bslib@0.6.1\", \"cachem@1.0.8\", \"callr@3.7.3\", \"cellranger@1.1.0\", \"checkmate@2.3.0\", \"cli@3.6.1\", \"clipr@0.8.0\", \"colorspace@2.1-0\", \"commonmark@1.9.0\", \"cpp11@0.4.7\", \"crayon@1.5.2\", \"curl@5.1.0\", \"data.table@1.14.8\", \"digest@0.6.33\", \"distcrete@1.0.3\", \"distributional@0.3.2\", \"dplyr@1.1.4\", \"ellipsis@0.3.2\", \"epiverse-trace/episoap\", # nolint \"epitrix@0.4.0\", \"epiverse-trace/epiparameter@328706e\", # nolint \"evaluate@0.23\", \"fansi@1.0.5\", \"farver@2.1.1\", \"fastmap@1.1.1\", \"fontawesome@0.5.2\", \"forcats@1.0.0\", \"foreign@0.8-85\", \"fs@1.6.3\", \"generics@0.1.3\", \"ggplot2@3.5.0\", \"glue@1.6.2\", \"grateful@0.2.4\", \"grates@1.1.0\", \"gtable@0.3.4\", \"haven@2.5.3\", \"highr@0.10\", \"hms@1.1.3\", \"htmltools@0.5.7\", \"httpuv@1.6.12\", \"httr@1.4.7\", \"incidence2@2.2.3\", \"isoband@0.2.7\", \"janitor@2.2.0\", \"jquerylib@0.1.4\", \"jsonlite@1.8.7\", \"kableExtra@1.3.4\", \"knitr@1.45\", \"labeling@0.4.3\", \"later@1.3.1\", \"lattice@0.21-8\", \"lifecycle@1.0.4\", \"linelist@1.0.0\", \"lubridate@1.9.3\", \"magrittr@2.0.3\", \"memoise@2.0.1\", \"mgcv@1.9-0\", \"mime@0.12\", \"munsell@0.5.0\", \"nlme@3.1-163\", \"numDeriv@2016.8-1.1\", \"openssl@2.1.1\", \"pillar@1.9.0\", \"pkgconfig@2.0.3\", \"prettyunits@1.2.0\", \"processx@3.8.2\", \"progress@1.2.2\", \"promises@1.2.1\", \"ps@1.7.5\", \"purrr@1.0.2\", \"rappdirs@0.3.3\", \"readr@2.1.4\", \"readxl@1.4.3\", \"rematch@2.0.0\", \"remotes@2.4.2.1\", \"renv@1.0.3\", \"rio@1.0.1\", \"rlang@1.1.2\", \"rmarkdown@2.25\", \"rstudioapi@0.15.0\", \"rvest@1.0.3\", \"sass@0.4.7\", \"scales@1.3.0\", \"selectr@0.4-2\", \"shiny@1.8.0\", \"snakecase@0.11.1\", \"sodium@1.3.1\", \"sourcetools@0.1.7-1\", \"stringi@1.8.2\", \"stringr@1.5.1\", \"svglite@2.1.2\", \"sys@3.4.2\", \"systemfonts@1.0.5\", \"tibble@3.2.1\", \"tidyr@1.3.0\", \"tidyselect@1.2.0\", \"timechange@0.2.0\", \"tinytex@0.49\", \"tzdb@0.4.0\", \"utf8@1.2.4\", \"vctrs@0.6.5\", \"viridisLite@0.4.2\", \"vroom@1.6.4\", \"webshot@0.5.5\", \"withr@2.5.2\", \"writexl@1.4.2\", \"xfun@0.41\", \"xml2@1.3.5\", \"xtable@1.8-4\", \"yaml@2.3.7\" ) ``` ```{r settings, echo = FALSE} knitr::opts_chunk$set( fig.width = 9, fig.height = 5, dpi = 90, collapse = TRUE, message = FALSE, warning = FALSE, out.width = \"100%\" ) ``` # Outline of the report ## Estimating transmissibility from stratified population This report provides a template for estimating transmissibility (i.e., how fast a disease spreads) from a stratified population. It performs basic descriptive analyses, and uses different approaches for estimating transmissibility. The key steps of the report include: * importing the data from an external file * identifying key variables in the data * producing global and stratified epidemic curves * estimating the growth rate and doubling time from epidemic curves * estimating the instantaneous reproduction number from epidemic curves ```{r} knitr::include_graphics(\"transmissibility_pipeline.svg\") ``` # Data preparation ## Loading libraries The following code loads required packages; missing packages will be installed automatically, but will require a working internet connection for the installation to be successful. ```{r} library(dplyr) library(ggplot2) library(forcats) library(purrr) library(tidyr) library(rio) library(linelist) library(janitor) library(kableExtra) library(incidence2) library(grateful) library(epiparameter) # episoap is already installed since this is where this document comes from library(episoap) ``` ```{r} custom_grey <- \"#505B5B\" green_grey <- \"#5E7E80\" pale_green <- \"#B2D1CC\" dark_green <- \"#005C5D\" dark_pink <- \"#B45D75\" theme_set(theme_episoap()) ``` ## Importing the data To illustrate the different analyses, we use real data reporting daily numbers of COVID-19 hospitalisations in England as of the 24 October 2020, broken down to the hospital and National Health Service (NHS) region level. The data is available online from the NHS England's [website](https://www.england.nhs.uk/statistics/statistical-work-areas/covid-19-hospital-activity/). The dataset analysed here is a simplified version, providing incidence of hospital admissions by NHS trust. The data file is named \"*covid_hosp_uk_20201024.xlsx*\" and is located in the *data/* folder. To adapt this report to another dataset, change the name of the file in the `data_file` parameter at the top of this document. ```{r} data_path <- params$data_file ``` ```{r} dat_raw <- data_path %>% import() %>% tibble() %>% # rio (via readxl) tends to use POSIXct for what is encoded as Date in the # original data file. # But POSIXct is not a good format to work with dates, as discussed in # https://github.com/reconverse/incidence2/issues/105 mutate(across(where(\\(x) inherits(x, \"POSIXct\")), as.Date)) ``` Once imported into __R__, the dataset called `dat` includes: * `date`: the date of admission * `region`: the NHS region * `org_name`: the full name of the NHS trust * `org_code`: a short code for the NHS trust * `n`: number of new, confirmed COVID-19 cases admitted, including inpatients who tested positive on that day, and new admissions with a positive test ## Identifying key data __Note__: this is not used for now, as there is no integration of linelist with other existing tools. Here we identify the key data needed in the analyses, including: * the dates to be used, here, dates of hospital admission * the strata of the population, here, coarse geographic locations (NHS regions) * the case counts; this would not be needed if the data was a raw linelist, and not already aggregated counts ```{r} date_var <- \"date\" group_var <- \"region\" count_var <- \"n\" dat <- dat_raw %>% make_linelist( date_admission = date_var, location = group_var, counts = count_var, allow_extra = TRUE ) ``` # Descriptive analyses ## Epidemic curves This section creates epidemic curves (\"_epicurves_\"), with or without stratification. ```{r} # convert daily incidence into weekly incidence using incidence2 dat_i <- dat_raw %>% incidence(\"date\", interval = params$epicurve_unit, counts = count_var, groups = group_var ) # general variables for automatic customisation of plots n_groups <- dplyr::n_distinct(get_groups(dat_i)[[1]]) small_counts <- max(get_count_value(dat_i)) < 20 ``` ```{r fig.height = 5 / 3 * n_groups} dat_i %>% plot(alpha = 1, nrow = n_groups) + labs(title = \"Incidence of cases over time\") ``` ## Numbers of cases This graph shows the total number of cases per group: ```{r } total_cases <- dat %>% tags_df() %>% select(location, counts) %>% group_by(location) %>% summarise(cases = sum(counts)) %>% mutate(location = fct_reorder( .f = location, .x = cases )) ggplot(total_cases, aes(x = cases, y = location)) + geom_col(fill = green_grey) + labs(x = \"Total number of cases\", y = NULL) total_cases %>% mutate( percentage = sprintf(\"%.2f%%\", cases / sum(cases) * 100) ) %>% adorn_totals() %>% mutate(cases = format(cases, scientific = FALSE, big.mark = \" \")) %>% set_names(toupper) %>% kbl() %>% kable_paper(\"striped\", font_size = 18, full_width = FALSE) ``` # Serial interval distribution ## Explanations The _serial interval_ ($si$) is the delay between the date of symptom onsets of primary case and the secondary cases they have infected. Because this delay varies from one transmission pair to another, we will characterise this variation using a probability distribution. This distribution is a key input to methods use for estimating the reproduction number ($R$). Here, we assume that the mean and standard deviation of the $si$ is known, and provided as an input by the user. We model the $si$ distribution as a discretized Gamma. ## Results ```{r, eval = params$use_epiparameter_database} si_epidist <- epidist_db( disease = params$disease_name, epi_dist = \"serial_interval\", single_epidist = TRUE, subset = is_parameterised ) si_params <- get_parameters(si_epidist) si_dist <- family(si_epidist) si_mean <- si_params[\"mean\"] si_sd <- si_params[\"sd\"] ``` ```{r, eval = !params$use_epiparameter_database} si_mean <- params$si_mean si_sd <- params$si_sd si_dist <- params$si_dist si_epidist <- epidist( disease = params$disease_name, epi_dist = \"serial_interval\", prob_distribution = params$si_dist, summary_stats = create_epidist_summary_stats(mean = params$si_mean, sd = params$si_sd) ) ``` ```{r} si <- discretise(si_epidist) si_x <- seq(1L, to = quantile(si, 0.999), by = 1L) ``` ```{r} ggplot( data.frame(delay = si_x, prob = si$prob_dist$d(si_x)), aes(x = delay, y = prob) ) + geom_col(fill = green_grey) + labs( title = \"Serial interval distribution\", x = \"Days from primary to secondary onset\", y = \"Probability\", subtitle = sprintf( \"%s distribution | mean: %.1f days ; sd: %.1f days\", si_dist, si_mean, si_sd ) ) ``` # Growth rate ($r$) and reproduction number ($R$) ```{r} last_date <- dat %>% pull(date) %>% max() # version using keep_first and keep_last from i2extras days_to_keep <- params$incomplete_days + params$r_estim_window i_recent <- dat_raw %>% incidence(\"date\", counts = count_var, groups = group_var ) %>% keep_last(days_to_keep) %>% # keep data for fitting keep_first(params$r_estim_window) # remove incomplete data ``` ```{r} dat_i_day <- dat_raw %>% incidence(\"date\", interval = \"daily\", counts = count_var, groups = group_var ) %>% keep_first(n_distinct(.$date_index) - params$incomplete_days) ``` ```{r, child=paste0(\"rmdchunks/\", params$rt_estimator, \".Rmd\")} ``` ```{r} cite_packages(output = \"paragraph\", out.dir = \".\", pkgs = \"Session\") ```"},{"path":"https://epiverse-trace.github.io/episoap/authors.html","id":null,"dir":"","previous_headings":"","what":"Authors","title":"Authors and Citation","text":"Hugo Gruson. Author, maintainer, copyright holder. Thibaut Jombart. Author. Carmen Tamayo. Author. data.org. Funder.","code":""},{"path":"https://epiverse-trace.github.io/episoap/authors.html","id":"citation","dir":"","previous_headings":"","what":"Citation","title":"Authors and Citation","text":"Gruson H, Jombart T, Tamayo C (2024). episoap: Store Outbreak Analytics Pipelines. R package version 0.0.0.9000, https://github.com/epiverse-trace/episoap, https://epiverse-trace.github.io/episoap.","code":"@Manual{, title = {episoap: A Store of Outbreak Analytics Pipelines}, author = {Hugo Gruson and Thibaut Jombart and Carmen Tamayo}, year = {2024}, note = {R package version 0.0.0.9000, https://github.com/epiverse-trace/episoap}, url = {https://epiverse-trace.github.io/episoap}, }"},{"path":"https://epiverse-trace.github.io/episoap/index.html","id":"episoap-a-store-of-outbreak-analytics-pipelines-","dir":"","previous_headings":"","what":"A Store of Outbreak Analytics Pipelines","title":"A Store of Outbreak Analytics Pipelines","text":"package provides store curated outbreak analytics pipelines rmarkdown reports.","code":""},{"path":"https://epiverse-trace.github.io/episoap/index.html","id":"target-audience","dir":"","previous_headings":"","what":"Target audience","title":"A Store of Outbreak Analytics Pipelines","text":"analyses largely automated, use outbreak analyst. basic R literacy required adapt report datasets.","code":""},{"path":"https://epiverse-trace.github.io/episoap/index.html","id":"installation","dir":"","previous_headings":"","what":"Installation","title":"A Store of Outbreak Analytics Pipelines","text":"can install development version soap GitHub :","code":"# install.packages(\"devtools\") devtools::install_github(\"epiverse-trace/episoap\")"},{"path":"https://epiverse-trace.github.io/episoap/index.html","id":"usage","dir":"","previous_headings":"","what":"Usage","title":"A Store of Outbreak Analytics Pipelines","text":"Reports provided rmarkdown templates. can load either via RStudio graphical interface running: get list template reports available package, can run:","code":"rmarkdown::draft(file = \"myreport.Rmd\", template = \"transmissibility\", package = \"episoap\") episoap::list_templates() #> [1] \"transmissibility\""},{"path":"https://epiverse-trace.github.io/episoap/index.html","id":"system-dependencies","dir":"","previous_headings":"Usage","what":"System dependencies","title":"A Store of Outbreak Analytics Pipelines","text":"may need install system dependencies:","code":"# macOS brew install libsodium cmake # Linux (Debian based) apt install libsodium-dev cmake"},{"path":"https://epiverse-trace.github.io/episoap/index.html","id":"related-projects","dir":"","previous_headings":"","what":"Related projects","title":"A Store of Outbreak Analytics Pipelines","text":"project overlap R packages: {sitrep} Applied Epi organisation. stated goals approaches can appear similar, episoap {sitrep} actually two different projects. {sitrep} reports specific (providing, e.g., reports specific disease although generic template development), thus detailed. also opinionated sense provide single analysis path situation, based extensive experience MSF. episoap hand offers generic approach, emphasis alternative paths can take within single analysis.","code":""},{"path":"https://epiverse-trace.github.io/episoap/index.html","id":"acknowledgements","dir":"","previous_headings":"","what":"Acknowledgements","title":"A Store of Outbreak Analytics Pipelines","text":"Thanks Sam Abbott pointing issues way EpiNow2 used transmissibility pipeline (#35) package logo derivative pipeline logo, provided flaticon user “Eucalyp” free personal commercial use attribution.","code":""},{"path":"https://epiverse-trace.github.io/episoap/reference/list_templates.html","id":null,"dir":"Reference","previous_headings":"","what":"List available rmarkdown templates — list_templates","title":"List available rmarkdown templates — list_templates","text":"List available rmarkdown templates","code":""},{"path":"https://epiverse-trace.github.io/episoap/reference/list_templates.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"List available rmarkdown templates — list_templates","text":"","code":"list_templates()"},{"path":"https://epiverse-trace.github.io/episoap/reference/list_templates.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"List available rmarkdown templates — list_templates","text":"character vector containing list rmarkdown included package","code":""},{"path":"https://epiverse-trace.github.io/episoap/reference/list_templates.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"List available rmarkdown templates — list_templates","text":"","code":"list_templates() #> [1] \"transmissibility\""},{"path":"https://epiverse-trace.github.io/episoap/reference/theme_episoap.html","id":null,"dir":"Reference","previous_headings":"","what":"A custom ggplot2 theme for episoap reports — theme_episoap","title":"A custom ggplot2 theme for episoap reports — theme_episoap","text":"custom ggplot2 theme episoap reports","code":""},{"path":"https://epiverse-trace.github.io/episoap/reference/theme_episoap.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"A custom ggplot2 theme for episoap reports — theme_episoap","text":"","code":"theme_episoap()"},{"path":"https://epiverse-trace.github.io/episoap/reference/theme_episoap.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"A custom ggplot2 theme for episoap reports — theme_episoap","text":"ggplot2 theme object","code":""},{"path":"https://epiverse-trace.github.io/episoap/reference/theme_episoap.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"A custom ggplot2 theme for episoap reports — theme_episoap","text":"","code":"library(ggplot2) ggplot(mtcars, aes(wt, mpg)) + geom_point() + labs(title = \"Fuel economy declines as weight increases\") + theme_episoap()"}] +[{"path":"https://epiverse-trace.github.io/episoap/CONTRIBUTING.html","id":null,"dir":"","previous_headings":"","what":"Contributing to episoap","title":"Contributing to episoap","text":"outlines propose change episoap. detailed info contributing , epiverse-trace packages, please see development contributing guide.","code":""},{"path":"https://epiverse-trace.github.io/episoap/CONTRIBUTING.html","id":"updating-or-creating-rmarkdown-templates","dir":"","previous_headings":"","what":"Updating or creating Rmarkdown templates","title":"Contributing to episoap","text":"main value episoap package Rmarkdown templates provides. section details proceed wish update one existing templates add new one. adding new code, whether form new template, updating existing template, please try hardcode settings parameters possible. want reports usable ---box many contexts possible.","code":""},{"path":"https://epiverse-trace.github.io/episoap/CONTRIBUTING.html","id":"template-location","dir":"","previous_headings":"","what":"Template location","title":"Contributing to episoap","text":"documented relevant RStudio documentation page, Rmarkdown templates located specific folder: inst/rmarkdown/templates/.","code":""},{"path":"https://epiverse-trace.github.io/episoap/CONTRIBUTING.html","id":"adding-a-new-template","dir":"","previous_headings":"Template location","what":"Adding a new template","title":"Contributing to episoap","text":"self-contained generic pipeline can used many contexts, kind epidemic pathogen, contribute new template. Follow instructions relevant RStudio documentation page . specific conventions templates provided package: packages used report cited end document data read folder named data/ templates include diagram indicating workflow provided package (example transmissibility report) alternative branches pipeline provided child Rmarkdown documents contained rmdchunks folder. child documents can called main document following chunk:","code":"```{r, child=paste0(\"rmdchunks/\", params$alternative_branch, \".Rmd\")} ```"},{"path":"https://epiverse-trace.github.io/episoap/CONTRIBUTING.html","id":"editing-an-existing-template","dir":"","previous_headings":"Template location","what":"Editing an existing template","title":"Contributing to episoap","text":"way welcome new templates, can fix, improve refine existing template editing files relevant folder inst/rmarkdown/templates/.","code":""},{"path":"https://epiverse-trace.github.io/episoap/CONTRIBUTING.html","id":"pull-request-process","dir":"","previous_headings":"","what":"Pull request process","title":"Contributing to episoap","text":"Fork package clone onto computer. haven’t done , recommend using usethis::create_from_github(\"epiverse-trace/data_pipelines\", fork = TRUE). Install development dependencies devtools::install_dev_deps(), make sure package passes R CMD check running devtools::check(). R CMD check doesn’t pass cleanly, ’s good idea ask help continuing. Create Git branch pull request (PR). recommend using usethis::pr_init(\"brief-description--change\"). Make changes, commit git, create PR running usethis::pr_push(), following prompts browser. title PR briefly describe change. body PR contain Fixes #issue-number. user-facing changes, add bullet top NEWS.md (.e. just first header). Follow style described https://style.tidyverse.org/news.html.","code":""},{"path":"https://epiverse-trace.github.io/episoap/CONTRIBUTING.html","id":"code-style","dir":"","previous_headings":"","what":"Code style","title":"Contributing to episoap","text":"New code follow tidyverse style guide. can use styler package apply styles, please don’t restyle code nothing PR. use roxygen2, Markdown syntax, documentation. use testthat unit tests. Contributions test cases included easier accept.","code":""},{"path":"https://epiverse-trace.github.io/episoap/CONTRIBUTING.html","id":"code-of-conduct","dir":"","previous_headings":"","what":"Code of Conduct","title":"Contributing to episoap","text":"Please note episoap project released Contributor Code Conduct. contributing project agree abide terms.","code":""},{"path":"https://epiverse-trace.github.io/episoap/LICENSE.html","id":null,"dir":"","previous_headings":"","what":"MIT License","title":"MIT License","text":"Copyright (c) 2023 episoap authors Permission hereby granted, free charge, person obtaining copy software associated documentation files (“Software”), deal Software without restriction, including without limitation rights use, copy, modify, merge, publish, distribute, sublicense, /sell copies Software, permit persons Software furnished , subject following conditions: copyright notice permission notice shall included copies substantial portions Software. SOFTWARE PROVIDED “”, WITHOUT WARRANTY KIND, EXPRESS IMPLIED, INCLUDING LIMITED WARRANTIES MERCHANTABILITY, FITNESS PARTICULAR PURPOSE NONINFRINGEMENT. EVENT SHALL AUTHORS COPYRIGHT HOLDERS LIABLE CLAIM, DAMAGES LIABILITY, WHETHER ACTION CONTRACT, TORT OTHERWISE, ARISING , CONNECTION SOFTWARE USE DEALINGS SOFTWARE.","code":""},{"path":"https://epiverse-trace.github.io/episoap/articles/design.html","id":"package-and-version-management","dir":"Articles","previous_headings":"","what":"Package and version management","title":"Design principles","text":"Breaking changes R package updates one major sources non-reproducibility headaches R users levels. guard users , also ensure provided templates work box, throughout time given episoap version CRAN, pin specific versions dependencies, via renv. recognize approach practical situations, particular, differs dependency management framework R python packages. However, believe best trade-usability, maintainability flexibility context pipeline templates: ensures pipelines work long-term, independently release timings machine-specific characteristics (particular pre-existing package library) doesn’t blur lines package installation package loading steps doesn’t interfere user existing package library. words, doesn’t permanently modify system settings. can read dedicated issue context behind choice possible downsides.","code":""},{"path":"https://epiverse-trace.github.io/episoap/articles/design.html","id":"pinned-version-updates","dir":"Articles","previous_headings":"Package and version management","what":"Pinned version updates","title":"Design principles","text":"avoid forcing users deal obsolete package versions, update template code work latest CRAN version package, just updating episoap CRAN running renv::embed() Rmarkdown files.","code":""},{"path":"https://epiverse-trace.github.io/episoap/articles/episoap.html","id":"loading-reports","dir":"Articles","previous_headings":"","what":"Loading reports","title":"Introduction to episoap: A Store of Outbreak Analytics Pipelines","text":"Reports provided rmarkdown templates. can load either via RStudio graphical interface running: get list template reports available package, can run:","code":"rmarkdown::draft( file = \"myreport.Rmd\", template = \"transmissibility\", package = \"episoap\" ) episoap::list_templates() #> [1] \"transmissibility\""},{"path":"https://epiverse-trace.github.io/episoap/articles/episoap.html","id":"customising-reports","dir":"Articles","previous_headings":"","what":"Customising reports","title":"Introduction to episoap: A Store of Outbreak Analytics Pipelines","text":"reports classic rmarkdown files. familiar rmarkdown literate programming, can edit piece report see fit. users want ready--use solution, reports already set provide multiple options analysis box. example, transmissibility report, can choose estimate reproduction number data different tools, EpiEstim EpiNow2. achieved changing value rt_estimator parameter. , can done graphical interface using ‘Knit parameters’ button RStudio: running: Alternatively, can also directly value various parameters rmarkdown::render() call:","code":"# Load template in temporary directory for this vignette. You will probably # wish to save it somewhere else. rmarkdown::draft( file = file.path(tempdir(), \"myreport\"), template = \"transmissibility\", package = \"episoap\", edit = FALSE ) # Get a graphical interface to select the parameters to use in this report rmarkdown::render( input = file.path(tempdir(), \"myreport\", \"myreport.Rmd\"), output_file = \"custom_report.html\", params = \"ask\", quiet = TRUE ) # Report using EpiEstim to estimate Rt rmarkdown::render( input = file.path(tempdir(), \"myreport\", \"myreport.Rmd\"), output_file = \"EpiEstim_report.html\", params = list(rt_estimator = \"EpiEstim\"), quiet = TRUE ) # Report using R0 to estimate Rt rmarkdown::render( input = file.path(tempdir(), \"myreport\", \"myreport.Rmd\"), output_file = \"EpiNow2_report.html\", params = list(rt_estimator = \"EpiNow2\"), quiet = TRUE )"},{"path":[]},{"path":"https://epiverse-trace.github.io/episoap/articles/pipelines.html","id":"transmissibility-pipeline","dir":"Articles","previous_headings":"","what":"Transmissibility pipeline","title":"List of included pipelines","text":"template estimating transmissibility (.e., fast disease spreads) stratified population. performs basic descriptive analyses, uses different approaches estimating transmissibility.","code":"--- title: \"Estimating transmissibility with population stratification\" author: Thibaut Jombart, Hugo Gruson date: \"`r Sys.Date()`\" output: rmarkdown::html_document: code_folding: \"hide\" link-citations: no params: epicurve_unit: label: \"An integer or character indicating the (fixed) size of the time interval used for computing the incidence. Passed as the `interval` argument in `incidence2::incidence()`.\" value: \"week\" incomplete_days: label: \"Number of days to exclude from the estimation of Rt since data is likely to still be incomplete.\" value: 7 r_estim_window: label: \"Number of days to include to get the latest observed value of Rt.\" value: 21 use_epiparameter_database: label: \"Should the serial interval distribution be extracted directly from the epiparameter package?\" value: FALSE disease_name: label: \"Name of the disease of interest, also used to select diseases in the epiparameter database if `use_parameter_database = TRUE`.\" value: \"COVID-19\" si_mean: label: \"Mean of the distribution for serial interval if not using value from epiparameter. Ignored if `use_epiparameter_database = TRUE`.\" value: 4.2 si_sd: label: \"Standard deviation of the distribution for serial interval if not using value from epiparameter. Ignored if `use_epiparameter_database = TRUE`.\" value: 4.9 si_dist: label: \"Choice of probability distribution for serial interval if not using value from epiparameter. Ignored if `use_epiparameter_database = TRUE`.\" value: \"gamma\" choices: [\"beta\", \"binom\", \"cauchy\", \"chisq\", \"exp\", \"f\", \"gamma\", \"geom\", \"hyper\", \"lnorm\", \"logis\", \"nbinom\", \"norm\", \"pois\", \"smirnov\", \"t\", \"tukey\", \"unif\", \"weibull\", \"wilcox\"] data_file: label: \"Name of file containing the count data over time\" value: \"data/covid_hosp_uk_20201024.xlsx\" input: file rt_estimator: label: \"Which R package to use for Rt estimation\" value: \"i2extras\" choices: [\"EpiEstim\", \"EpiNow2\", \"i2extras\", \"R0\"] bibliography: - grateful-refs.bib --- ```{r lockfile, include = FALSE, message = FALSE} renv::use( \"MASS@7.3-59\", \"Matrix@1.6-3\", \"R.methodsS3@1.8.2\", \"R.oo@1.25.0\", \"R.utils@2.12.3\", \"R6@2.5.1\", \"RColorBrewer@1.1-3\", \"Rcpp@1.0.12\", \"askpass@1.2.0\", \"backports@1.4.1\", \"base64enc@0.1-3\", \"bit64@4.0.5\", \"bit@4.0.5\", \"bslib@0.6.1\", \"cachem@1.0.8\", \"callr@3.7.5\", \"cellranger@1.1.0\", \"checkmate@2.3.1\", \"cli@3.6.2\", \"clipr@0.8.0\", \"colorspace@2.1-0\", \"commonmark@1.9.1\", \"cpp11@0.4.7\", \"crayon@1.5.2\", \"curl@5.2.1\", \"data.table@1.14.8\", \"digest@0.6.35\", \"distcrete@1.0.3\", \"distributional@0.3.2\", \"dplyr@1.1.4\", \"ellipsis@0.3.2\", \"epiverse-trace/episoap\", # nolint \"epiverse-trace/epiparameter@328706e\", # nolint \"evaluate@0.23\", \"fansi@1.0.6\", \"farver@2.1.1\", \"fastmap@1.1.1\", \"fontawesome@0.5.2\", \"forcats@1.0.0\", \"foreign@0.8-86\", \"fs@1.6.3\", \"generics@0.1.3\", \"ggplot2@3.5.0\", \"glue@1.7.0\", \"grateful@0.2.4\", \"grates@1.1.0\", \"gtable@0.3.4\", \"haven@2.5.4\", \"highr@0.10\", \"hms@1.1.3\", \"htmltools@0.5.7\", \"httpuv@1.6.14\", \"httr@1.4.7\", \"incidence2@2.2.3\", \"isoband@0.2.7\", \"janitor@2.2.0\", \"jquerylib@0.1.4\", \"jsonlite@1.8.8\", \"kableExtra@1.3.4\", \"knitr@1.45\", \"labeling@0.4.3\", \"later@1.3.2\", \"lattice@0.21-8\", \"lifecycle@1.0.4\", \"linelist@1.1.0\", \"lubridate@1.9.3\", \"magrittr@2.0.3\", \"memoise@2.0.1\", \"mgcv@1.9-1\", \"mime@0.12\", \"munsell@0.5.0\", \"nlme@3.1-163\", \"numDeriv@2016.8-1.1\", \"openssl@2.1.1\", \"pillar@1.9.0\", \"pkgconfig@2.0.3\", \"prettyunits@1.2.0\", \"processx@3.8.4\", \"progress@1.2.3\", \"promises@1.2.1\", \"ps@1.7.6\", \"purrr@1.0.2\", \"rappdirs@0.3.3\", \"readr@2.1.4\", \"readxl@1.4.3\", \"rematch@2.0.0\", \"remotes@2.4.2.1\", \"renv@1.0.3\", \"rio@1.0.1\", \"rlang@1.1.3\", \"rmarkdown@2.26\", \"rstudioapi@0.15.0\", \"rvest@1.0.4\", \"sass@0.4.9\", \"scales@1.3.0\", \"selectr@0.4-2\", \"shiny@1.8.0\", \"snakecase@0.11.1\", \"sourcetools@0.1.7-1\", \"stringi@1.8.3\", \"stringr@1.5.1\", \"svglite@2.1.3\", \"sys@3.4.2\", \"systemfonts@1.0.6\", \"tibble@3.2.1\", \"tidyr@1.3.0\", \"tidyselect@1.2.0\", \"timechange@0.2.0\", \"tinytex@0.50\", \"tzdb@0.4.0\", \"utf8@1.2.4\", \"vctrs@0.6.5\", \"viridisLite@0.4.2\", \"vroom@1.6.5\", \"webshot@0.5.5\", \"withr@3.0.0\", \"writexl@1.4.2\", \"xfun@0.42\", \"xml2@1.3.6\", \"xtable@1.8-4\", \"yaml@2.3.8\" ) ``` ```{r settings, echo = FALSE} knitr::opts_chunk$set( fig.width = 9, fig.height = 5, dpi = 90, collapse = TRUE, message = FALSE, warning = FALSE, out.width = \"100%\" ) ``` # Outline of the report ## Estimating transmissibility from stratified population This report provides a template for estimating transmissibility (i.e., how fast a disease spreads) from a stratified population. It performs basic descriptive analyses, and uses different approaches for estimating transmissibility. The key steps of the report include: * importing the data from an external file * identifying key variables in the data * producing global and stratified epidemic curves * estimating the growth rate and doubling time from epidemic curves * estimating the instantaneous reproduction number from epidemic curves ```{r} knitr::include_graphics(\"transmissibility_pipeline.svg\") ``` # Data preparation ## Loading libraries The following code loads required packages; missing packages will be installed automatically, but will require a working internet connection for the installation to be successful. ```{r} library(dplyr) library(ggplot2) library(forcats) library(purrr) library(tidyr) library(rio) library(linelist) library(janitor) library(kableExtra) library(incidence2) library(grateful) library(epiparameter) # episoap is already installed since this is where this document comes from library(episoap) ``` ```{r} custom_grey <- \"#505B5B\" green_grey <- \"#5E7E80\" pale_green <- \"#B2D1CC\" dark_green <- \"#005C5D\" dark_pink <- \"#B45D75\" theme_set(theme_episoap()) ``` ## Importing the data To illustrate the different analyses, we use real data reporting daily numbers of COVID-19 hospitalisations in England as of the 24 October 2020, broken down to the hospital and National Health Service (NHS) region level. The data is available online from the NHS England's [website](https://www.england.nhs.uk/statistics/statistical-work-areas/covid-19-hospital-activity/). The dataset analysed here is a simplified version, providing incidence of hospital admissions by NHS trust. The data file is named \"*covid_hosp_uk_20201024.xlsx*\" and is located in the *data/* folder. To adapt this report to another dataset, change the name of the file in the `data_file` parameter at the top of this document. ```{r} data_path <- params$data_file ``` ```{r} dat_raw <- data_path %>% import() %>% tibble() %>% # rio (via readxl) tends to use POSIXct for what is encoded as Date in the # original data file. # But POSIXct is not a good format to work with dates, as discussed in # https://github.com/reconverse/incidence2/issues/105 mutate(across(where(\\(x) inherits(x, \"POSIXct\")), as.Date)) ``` Once imported into __R__, the dataset called `dat` includes: * `date`: the date of admission * `region`: the NHS region * `org_name`: the full name of the NHS trust * `org_code`: a short code for the NHS trust * `n`: number of new, confirmed COVID-19 cases admitted, including inpatients who tested positive on that day, and new admissions with a positive test ## Identifying key data __Note__: this is not used for now, as there is no integration of linelist with other existing tools. Here we identify the key data needed in the analyses, including: * the dates to be used, here, dates of hospital admission * the strata of the population, here, coarse geographic locations (NHS regions) * the case counts; this would not be needed if the data was a raw linelist, and not already aggregated counts ```{r} date_var <- \"date\" group_var <- \"region\" count_var <- \"n\" dat <- dat_raw %>% make_linelist( date_admission = date_var, location = group_var, counts = count_var, allow_extra = TRUE ) ``` # Descriptive analyses ## Epidemic curves This section creates epidemic curves (\"_epicurves_\"), with or without stratification. ```{r} # convert daily incidence into weekly incidence using incidence2 dat_i <- dat_raw %>% incidence(\"date\", interval = params$epicurve_unit, counts = count_var, groups = group_var ) # general variables for automatic customisation of plots n_groups <- dplyr::n_distinct(get_groups(dat_i)[[1]]) small_counts <- max(get_count_value(dat_i)) < 20 ``` ```{r fig.height = 5 / 3 * n_groups} dat_i %>% plot(alpha = 1, nrow = n_groups) + labs(title = \"Incidence of cases over time\") ``` ## Numbers of cases This graph shows the total number of cases per group: ```{r } total_cases <- dat %>% tags_df() %>% select(location, counts) %>% group_by(location) %>% summarise(cases = sum(counts)) %>% mutate(location = fct_reorder( .f = location, .x = cases )) ggplot(total_cases, aes(x = cases, y = location)) + geom_col(fill = green_grey) + labs(x = \"Total number of cases\", y = NULL) total_cases %>% mutate( percentage = sprintf(\"%.2f%%\", cases / sum(cases) * 100) ) %>% adorn_totals() %>% mutate(cases = format(cases, scientific = FALSE, big.mark = \" \")) %>% set_names(toupper) %>% kbl() %>% kable_paper(\"striped\", font_size = 18, full_width = FALSE) ``` # Serial interval distribution ## Explanations The _serial interval_ ($si$) is the delay between the date of symptom onsets of primary case and the secondary cases they have infected. Because this delay varies from one transmission pair to another, we will characterise this variation using a probability distribution. This distribution is a key input to methods use for estimating the reproduction number ($R$). Here, we assume that the mean and standard deviation of the $si$ is known, and provided as an input by the user. We model the $si$ distribution as a discretized Gamma. ## Results ```{r, eval = params$use_epiparameter_database} si_epidist <- epidist_db( disease = params$disease_name, epi_dist = \"serial_interval\", single_epidist = TRUE, subset = is_parameterised ) si_params <- get_parameters(si_epidist) si_dist <- family(si_epidist) si_mean <- si_params[\"mean\"] si_sd <- si_params[\"sd\"] ``` ```{r, eval = !params$use_epiparameter_database} si_mean <- params$si_mean si_sd <- params$si_sd si_dist <- params$si_dist si_epidist <- epidist( disease = params$disease_name, epi_dist = \"serial_interval\", prob_distribution = params$si_dist, summary_stats = create_epidist_summary_stats(mean = params$si_mean, sd = params$si_sd) ) ``` ```{r} si <- discretise(si_epidist) si_x <- seq(1L, to = quantile(si, 0.999), by = 1L) ``` ```{r} ggplot( data.frame(delay = si_x, prob = si$prob_dist$d(si_x)), aes(x = delay, y = prob) ) + geom_col(fill = green_grey) + labs( title = \"Serial interval distribution\", x = \"Days from primary to secondary onset\", y = \"Probability\", subtitle = sprintf( \"%s distribution | mean: %.1f days ; sd: %.1f days\", si_dist, si_mean, si_sd ) ) ``` # Growth rate ($r$) and reproduction number ($R$) ```{r} last_date <- dat %>% pull(date) %>% max() # version using keep_first and keep_last from i2extras days_to_keep <- params$incomplete_days + params$r_estim_window i_recent <- dat_raw %>% incidence(\"date\", counts = count_var, groups = group_var ) %>% keep_last(days_to_keep) %>% # keep data for fitting keep_first(params$r_estim_window) # remove incomplete data ``` ```{r} dat_i_day <- dat_raw %>% incidence(\"date\", interval = \"daily\", counts = count_var, groups = group_var ) %>% keep_first(n_distinct(.$date_index) - params$incomplete_days) ``` ```{r, child=paste0(\"rmdchunks/\", params$rt_estimator, \".Rmd\")} ``` ```{r} cite_packages(output = \"paragraph\", out.dir = \".\", pkgs = \"Session\") ```"},{"path":"https://epiverse-trace.github.io/episoap/authors.html","id":null,"dir":"","previous_headings":"","what":"Authors","title":"Authors and Citation","text":"Hugo Gruson. Author, maintainer, copyright holder. Thibaut Jombart. Author. Carmen Tamayo. Author. data.org. Funder.","code":""},{"path":"https://epiverse-trace.github.io/episoap/authors.html","id":"citation","dir":"","previous_headings":"","what":"Citation","title":"Authors and Citation","text":"Gruson H, Jombart T, Tamayo C (2024). episoap: Store Outbreak Analytics Pipelines. R package version 0.0.0.9000, https://github.com/epiverse-trace/episoap, https://epiverse-trace.github.io/episoap.","code":"@Manual{, title = {episoap: A Store of Outbreak Analytics Pipelines}, author = {Hugo Gruson and Thibaut Jombart and Carmen Tamayo}, year = {2024}, note = {R package version 0.0.0.9000, https://github.com/epiverse-trace/episoap}, url = {https://epiverse-trace.github.io/episoap}, }"},{"path":"https://epiverse-trace.github.io/episoap/index.html","id":"episoap-a-store-of-outbreak-analytics-pipelines-","dir":"","previous_headings":"","what":"A Store of Outbreak Analytics Pipelines","title":"A Store of Outbreak Analytics Pipelines","text":"package provides store curated outbreak analytics pipelines rmarkdown reports.","code":""},{"path":"https://epiverse-trace.github.io/episoap/index.html","id":"target-audience","dir":"","previous_headings":"","what":"Target audience","title":"A Store of Outbreak Analytics Pipelines","text":"analyses largely automated, use outbreak analyst. basic R literacy required adapt report datasets.","code":""},{"path":"https://epiverse-trace.github.io/episoap/index.html","id":"installation","dir":"","previous_headings":"","what":"Installation","title":"A Store of Outbreak Analytics Pipelines","text":"can install development version soap GitHub :","code":"# install.packages(\"devtools\") devtools::install_github(\"epiverse-trace/episoap\")"},{"path":"https://epiverse-trace.github.io/episoap/index.html","id":"usage","dir":"","previous_headings":"","what":"Usage","title":"A Store of Outbreak Analytics Pipelines","text":"Reports provided rmarkdown templates. can load either via RStudio graphical interface Graphical interface open soap rmarkdown template RStudio running: get list template reports available package, can run:","code":"rmarkdown::draft(file = \"myreport.Rmd\", template = \"transmissibility\", package = \"episoap\") episoap::list_templates() #> [1] \"transmissibility\""},{"path":"https://epiverse-trace.github.io/episoap/index.html","id":"system-dependencies","dir":"","previous_headings":"Usage","what":"System dependencies","title":"A Store of Outbreak Analytics Pipelines","text":"may need install system dependencies:","code":"# macOS brew install libsodium cmake # Linux (Debian based) apt install libsodium-dev cmake"},{"path":"https://epiverse-trace.github.io/episoap/index.html","id":"related-projects","dir":"","previous_headings":"","what":"Related projects","title":"A Store of Outbreak Analytics Pipelines","text":"project overlap R packages: {sitrep} Applied Epi organisation. stated goals approaches can appear similar, episoap {sitrep} actually two different projects. {sitrep} reports specific (providing, e.g., reports specific disease although generic template development), thus detailed. also opinionated sense provide single analysis path situation, based extensive experience MSF. episoap hand offers generic approach, emphasis alternative paths can take within single analysis.","code":""},{"path":"https://epiverse-trace.github.io/episoap/index.html","id":"acknowledgements","dir":"","previous_headings":"","what":"Acknowledgements","title":"A Store of Outbreak Analytics Pipelines","text":"Thanks Sam Abbott pointing issues way EpiNow2 used transmissibility pipeline (#35) package logo derivative pipeline logo, provided flaticon user “Eucalyp” free personal commercial use attribution.","code":""},{"path":"https://epiverse-trace.github.io/episoap/reference/list_templates.html","id":null,"dir":"Reference","previous_headings":"","what":"List available rmarkdown templates — list_templates","title":"List available rmarkdown templates — list_templates","text":"List available rmarkdown templates","code":""},{"path":"https://epiverse-trace.github.io/episoap/reference/list_templates.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"List available rmarkdown templates — list_templates","text":"","code":"list_templates()"},{"path":"https://epiverse-trace.github.io/episoap/reference/list_templates.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"List available rmarkdown templates — list_templates","text":"character vector containing list rmarkdown included package","code":""},{"path":"https://epiverse-trace.github.io/episoap/reference/list_templates.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"List available rmarkdown templates — list_templates","text":"","code":"list_templates() #> [1] \"transmissibility\""},{"path":"https://epiverse-trace.github.io/episoap/reference/theme_episoap.html","id":null,"dir":"Reference","previous_headings":"","what":"A custom ggplot2 theme for episoap reports — theme_episoap","title":"A custom ggplot2 theme for episoap reports — theme_episoap","text":"custom ggplot2 theme episoap reports","code":""},{"path":"https://epiverse-trace.github.io/episoap/reference/theme_episoap.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"A custom ggplot2 theme for episoap reports — theme_episoap","text":"","code":"theme_episoap()"},{"path":"https://epiverse-trace.github.io/episoap/reference/theme_episoap.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"A custom ggplot2 theme for episoap reports — theme_episoap","text":"ggplot2 theme object","code":""},{"path":"https://epiverse-trace.github.io/episoap/reference/theme_episoap.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"A custom ggplot2 theme for episoap reports — theme_episoap","text":"","code":"library(ggplot2) ggplot(mtcars, aes(wt, mpg)) + geom_point() + labs(title = \"Fuel economy declines as weight increases\") + theme_episoap()"}]