generated from carpentries/workbench-template-rmd
-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 53e987e
Showing
56 changed files
with
7,218 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
--- | ||
title: "Contributor Code of Conduct" | ||
--- | ||
|
||
As contributors and maintainers of this project, | ||
we pledge to follow the [The Epiverse-TRACE Code of Conduct][coc]. | ||
|
||
<!-- | ||
Instances of abusive, harassing, or otherwise unacceptable behavior | ||
may be reported by following our [reporting guidelines][coc-reporting]. | ||
--> | ||
|
||
[coc-reporting]: https://forms.gle/guKqVXPk6K43jPn59 | ||
[coc]: https://github.com/epiverse-trace/.github/blob/main/CODE_OF_CONDUCT.md | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
--- | ||
title: "Licenses" | ||
--- | ||
|
||
## Instructional Material | ||
|
||
The tutorials in this repository are developed by Epiverse-TRACE, based on the [lesson template from the Carpentries](https://github.com/carpentries/workbench-template-rmd) (template under CC BY license). | ||
|
||
All Epiverse-TRACE | ||
instructional material is made available under the [Creative Commons | ||
Attribution license][cc-by-human]. The following is a human-readable summary of | ||
(and not a substitute for) the [full legal text of the CC BY 4.0 | ||
license][cc-by-legal]. | ||
|
||
You are free: | ||
|
||
- to **Share**---copy and redistribute the material in any medium or format | ||
- to **Adapt**---remix, transform, and build upon the material | ||
|
||
for any purpose, even commercially. | ||
|
||
The licensor cannot revoke these freedoms as long as you follow the license | ||
terms. | ||
|
||
Under the following terms: | ||
|
||
- **Attribution**---You must give appropriate credit (mentioning that your work | ||
is derived from work that is Copyright (c) Epiverse-TRACE, where | ||
practical, linking to <https://epiverse-trace.github.io/>), provide a [link to the | ||
license][cc-by-human], and indicate if changes were made. You may do so in | ||
any reasonable manner, but not in any way that suggests the licensor endorses | ||
you or your use. | ||
|
||
- **No additional restrictions**---You may not apply legal terms or | ||
technological measures that legally restrict others from doing anything the | ||
license permits. With the understanding that: | ||
|
||
Notices: | ||
|
||
* You do not have to comply with the license for elements of the material in | ||
the public domain or where your use is permitted by an applicable exception | ||
or limitation. | ||
* No warranties are given. The license may not give you all of the permissions | ||
necessary for your intended use. For example, other rights such as publicity, | ||
privacy, or moral rights may limit how you use the material. | ||
|
||
## Software | ||
|
||
Except where otherwise noted, the example programs and other software provided | ||
by Epiverse-TRACE are made available under the [OSI][osi]-approved [MIT | ||
license][mit-license]. | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy of | ||
this software and associated documentation files (the "Software"), to deal in | ||
the Software without restriction, including without limitation the rights to | ||
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies | ||
of the Software, and to permit persons to whom the Software is furnished to do | ||
so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
SOFTWARE. | ||
|
||
[cc-by-human]: https://creativecommons.org/licenses/by/4.0/ | ||
[cc-by-legal]: https://creativecommons.org/licenses/by/4.0/legalcode | ||
[mit-license]: https://opensource.org/licenses/mit-license.html | ||
[osi]: https://opensource.org |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,258 @@ | ||
--- | ||
title: 'Comparing public health outcomes of interventions' | ||
teaching: 45 # teaching time in minutes | ||
exercises: 30 # exercise time in minutes | ||
|
||
--- | ||
|
||
:::::::::::::::::::::::::::::::::::::: questions | ||
|
||
- How can I quantify the effect of an intervention? | ||
|
||
|
||
:::::::::::::::::::::::::::::::::::::::::::::::: | ||
|
||
::::::::::::::::::::::::::::::::::::: objectives | ||
|
||
- Compare intervention scenarios | ||
|
||
:::::::::::::::::::::::::::::::::::::::::::::::: | ||
|
||
::::::::::::::::::::::::::::::::::::: prereq | ||
|
||
## Prerequisites | ||
+ Complete tutorials [Simulating transmission](../episodes/simulating-transmission.md) and [Modelling interventions](../episodes/modelling-interventions.md) | ||
|
||
Learners should familiarise themselves with following concept dependencies before working through this tutorial: | ||
|
||
**Outbreak response** : [Intervention types](https://www.cdc.gov/nonpharmaceutical-interventions/). | ||
::::::::::::::::::::::::::::::::: | ||
|
||
|
||
## Introduction | ||
|
||
In this tutorial we will compare intervention scenarios against each other. To quantify the effect of the intervention we need to compare our intervention scenario to a counter factual scenario. The *counter factual* is the scenario in which nothing changes, often referred to as the 'do nothing' scenario. The counter factual scenario may include no interventions, or if we are investigating the potential impact of an additional intervention in the later stages of an outbreak there may be existing interventions in place. | ||
|
||
We must also decide what our *outcome of interest* is to make comparisons between intervention and counter factual scenarios. The outcome of interest can be: | ||
|
||
+ a model outcome, e.g. number of infections or hospitalisations, | ||
+ a metric such as the epidemic peak time or size, | ||
+ a measure that uses the model outcomes such as QALY/DALYs. | ||
|
||
|
||
:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: instructor | ||
|
||
In this tutorial we introduce the concept of the counter factual and how to compare scenarios (counter factual versus intervention) against each other. | ||
|
||
:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: | ||
|
||
## Vacamole model | ||
|
||
The Vacamole model is a deterministic model based on a system of ODEs in [Ainslie et al. 2022]( https://doi.org/10.2807/1560-7917.ES.2022.27.44.2101090) to describe the effect of vaccination on COVID-19 dynamics. The model consists of 11 compartments, individuals are classed as one of the following: | ||
|
||
+ susceptible, $S$, | ||
+ partial vaccination ($V_1$), fully vaccination ($V_2$), | ||
+ exposed, $E$ and exposed while vaccinated, $E_V$, | ||
+ infectious, $I$ and infectious while vaccinated, $I_V$, | ||
+ hospitalised, $H$ and hospitalised while vaccinated, $H_V$, | ||
+ dead, $D$, | ||
+ recovered, $R$. | ||
|
||
The diagram below describes the flow of individuals through the different compartments. | ||
|
||
<img src="fig/compare-interventions-rendered-unnamed-chunk-1-1.png" style="display: block; margin: auto;" /> | ||
|
||
|
||
::::::::::::::::::::::::::::::::::::: challenge | ||
|
||
## Running a counterfactual scenario using the Vacamole model | ||
|
||
1. Run the model with the default parameter values for the UK population assuming that : | ||
|
||
+ 1 in a million individual are infectious (and not vaccinated) at the start of the simulation | ||
+ The contact matrix for the United Kingdom has age bins: | ||
+ age between 0 and 20 years, | ||
+ age between 20 and 40, | ||
+ 40 years and over. | ||
+ There is no vaccination scheme in place | ||
|
||
2. Using the output, plot the number of deaths through time | ||
|
||
|
||
::::::::::::::::: hint | ||
|
||
### Vaccination code | ||
|
||
To run the model with no vaccination in place we can *either* create two vaccination objects (one for each dose) using `vaccination()` with the time start, time end and vaccination rate all set to 0, or we can use the `no_vaccination()` function to create a vaccination object for two doses with all values set to 0. | ||
|
||
|
||
```r | ||
no_vaccination <- no_vaccination(population = uk_population, doses = 2) | ||
``` | ||
:::::::::::::::::::::: | ||
|
||
::::::::::::::::: hint | ||
|
||
### HINT : Running the model with default parameter values | ||
|
||
We can run the Vacamole model with [default parameter values](https://epiverse-trace.github.io/epidemics/articles/vacamole.html#model-epidemic-using-vacamole) by just specifying the population object and number of time steps to run the model for: | ||
|
||
|
||
|
||
```r | ||
output <- model_vacamole_cpp( | ||
population = uk_population, | ||
vaccination = no_vaccination, | ||
time_end = 300 | ||
) | ||
``` | ||
|
||
:::::::::::::::::::::: | ||
|
||
|
||
|
||
::::::::::::::::: solution | ||
|
||
### SOLUTION | ||
|
||
1. Run the model | ||
|
||
|
||
```r | ||
polymod <- socialmixr::polymod | ||
contact_data <- socialmixr::contact_matrix( | ||
survey = polymod, | ||
countries = "United Kingdom", | ||
age.limits = c(0, 20, 40), | ||
symmetric = TRUE | ||
) | ||
``` | ||
|
||
```{.output} | ||
Using POLYMOD social contact data. To cite this in a publication, use the 'get_citation()' function | ||
``` | ||
|
||
```{.output} | ||
Removing participants that have contacts without age information. To change this behaviour, set the 'missing.contact.age' option | ||
``` | ||
|
||
```r | ||
# prepare contact matrix | ||
contact_matrix <- t(contact_data$matrix) | ||
|
||
# extract demography vector | ||
demography_vector <- contact_data$demography$population | ||
names(demography_vector) <- rownames(contact_matrix) | ||
|
||
# prepare initial conditions | ||
initial_i <- 1e-6 | ||
|
||
initial_conditions <- c( | ||
S = 1 - initial_i, | ||
V1 = 0, V2 = 0, | ||
E = 0, EV = 0, | ||
I = initial_i, IV = 0, | ||
H = 0, HV = 0, D = 0, R = 0 | ||
) | ||
|
||
initial_conditions <- rbind( | ||
initial_conditions, | ||
initial_conditions, | ||
initial_conditions | ||
) | ||
rownames(initial_conditions) <- rownames(contact_matrix) | ||
|
||
# prepare population object | ||
uk_population <- population( | ||
name = "UK", | ||
contact_matrix = contact_matrix, | ||
demography_vector = demography_vector, | ||
initial_conditions = initial_conditions | ||
) | ||
``` | ||
|
||
```{.error} | ||
Error in population(name = "UK", contact_matrix = contact_matrix, demography_vector = demography_vector, : could not find function "population" | ||
``` | ||
|
||
```r | ||
no_vaccination <- no_vaccination(population = uk_population, doses = 2) | ||
``` | ||
|
||
```{.error} | ||
Error in no_vaccination(population = uk_population, doses = 2): could not find function "no_vaccination" | ||
``` | ||
|
||
```r | ||
# run model | ||
output <- model_vacamole_cpp( | ||
population = uk_population, | ||
vaccination = no_vaccination, | ||
time_end = 300 | ||
) | ||
``` | ||
|
||
```{.error} | ||
Error in model_vacamole_cpp(population = uk_population, vaccination = no_vaccination, : could not find function "model_vacamole_cpp" | ||
``` | ||
|
||
2. Plot the number of deaths through time | ||
|
||
|
||
```r | ||
ggplot(output[output$compartment == "dead", ]) + | ||
geom_line( | ||
aes(time, value, colour = demography_group), | ||
linewidth = 1 | ||
) + | ||
scale_colour_brewer( | ||
palette = "Dark2", | ||
labels = rownames(contact_matrix), | ||
name = "Age group" | ||
) + | ||
scale_y_continuous( | ||
labels = scales::comma | ||
) + | ||
labs( | ||
x = "Simulation time (days)", | ||
y = "Individuals" | ||
) + | ||
theme( | ||
legend.position = "top" | ||
) + | ||
theme_bw( | ||
base_size = 15 | ||
) | ||
``` | ||
|
||
```{.error} | ||
Error in ggplot(output[output$compartment == "dead", ]): could not find function "ggplot" | ||
``` | ||
|
||
|
||
|
||
::::::::::::::::::::::::::: | ||
|
||
|
||
:::::::::::::::::::::::::::::::::::::::::::::::: | ||
|
||
|
||
|
||
## Comparing scenarios | ||
|
||
*Coming soon* | ||
|
||
|
||
|
||
## Challenge : Ebola outbreak analysis | ||
|
||
*Coming soon* | ||
|
||
|
||
|
||
|
||
::::::::::::::::::::::::::::::::::::: keypoints | ||
|
||
- The counter factual scenario must be defined to make comparisons | ||
|
||
:::::::::::::::::::::::::::::::::::::::::::::::: |
Oops, something went wrong.