Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion episodes/compare-interventions.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ output_baseline <- epidemics::model_default(

+ 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:
Learners should familiarise themselves with the following concept dependencies before working through this tutorial:

**Outbreak response**: [Intervention types](https://www.cdc.gov/nonpharmaceutical-interventions/).
:::::::::::::::::::::::::::::::::
Expand Down
10 changes: 5 additions & 5 deletions episodes/contact-matrices.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ However, when contact matrices are estimated from surveys or other sources, the
- Recall bias: Different age groups may have different abilities to remember and report contacts accurately
- Reporting bias: Some groups may systematically over- or under-report their contacts
- Sampling uncertainty: Limited sample sizes can lead to statistical variations
[(Prem et al 2021)](https://doi.org/10.1371/journal.pcbi.1009098)
[(Prem et al. 2021)](https://doi.org/10.1371/journal.pcbi.1009098)

If `symmetric` is set to TRUE, the `contact_matrix()` function will internally use an average of reported contacts to ensure the resulting total number of contacts are symmetric.

Expand Down Expand Up @@ -227,7 +227,7 @@ Contact matrices can be used in a wide range of epidemiological analyses, they c
+ to calculate the basic reproduction number while accounting for different rates of contacts between age groups [(Funk et al. 2019)](https://doi.org/10.1186/s12916-019-1413-7),
+ to calculate final size of an epidemic, as in the R package `{finalsize}`,
+ to assess the impact of interventions finding the relative change between pre and post intervention contact matrices to calculate the relative difference in $R_0$ [(Jarvis et al. 2020)](https://doi.org/10.1186/s12916-020-01597-8),
+ and in mathematical models of transmission within a population, to account for group specific contact patterns.
+ and in mathematical models of transmission within a population, to account for group-specific contact patterns.


However, all of these applications require us to perform some additional calculations using the contact matrix. Specifically, there are two main calculations we often need to do:
Expand Down Expand Up @@ -304,7 +304,7 @@ When simulating an epidemic, we often want to ensure that the average number of

Rather than just using the raw number of contacts, we can instead normalise the contact matrix to make it easier to work in terms of $R_0$. In particular, we normalise the matrix by scaling it so that if we were to calculate the average number of secondary cases based on this normalised matrix, the result would be 1 (in mathematical terms, we are scaling the matrix so the largest eigenvalue is 1). This transformation scales the entries but preserves their relative values.

In the case of the above model, we want to define $\beta C_{i,j}$ so that the model has a specified valued of $R_0$. If the entry of the contact matrix $C[i,j]$ represents the contacts of population $i$ with $j$, it is equivalent to `contacts_byage$matrix[i,j]`, and the maximum eigenvalue of this matrix represents the typical magnitude of contacts, not typical magnitude of transmission. We must therefore normalise the matrix $C$ so the maximum eigenvalue is one; we call this matrix $C_{normalised}$. Because the rate of recovery is $\gamma$, individuals will be infectious on average for $1/\gamma$ days. So $\beta$ as a model input is calculated from $R_0$, the scaling factor and the value of $\gamma$ (i.e. mathematically we use the fact that the dominant eigenvalue of the matrix $R_0 \times C_{normalised}$ is equal to $\beta / \gamma$).
In the case of the above model, we want to define $\beta C_{i,j}$ so that the model has a specified valued of $R_0$. If the entry of the contact matrix $C[i,j]$ represents the contacts of population $i$ with $j$, it is equivalent to `contacts_byage$matrix[i,j]`, and the maximum eigenvalue of this matrix represents the typical magnitude of contacts, not the typical magnitude of transmission. We must therefore normalise the matrix $C$ so the maximum eigenvalue is one; we call this matrix $C_{normalised}$. Because the rate of recovery is $\gamma$, individuals will be infectious on average for $1/\gamma$ days. So $\beta$ as a model input is calculated from $R_0$, the scaling factor and the value of $\gamma$ (i.e. mathematically we use the fact that the dominant eigenvalue of the matrix $R_0 \times C_{normalised}$ is equal to $\beta / \gamma$).

```{r}
contacts_byage_matrix <- t(contacts_byage$matrix)
Expand Down Expand Up @@ -365,15 +365,15 @@ We can use contact matrices from `socialmixr` with mathematical models in the R

### Contact groups

In the example above the dimension of the contact matrix will be the same as the number of age groups i.e. if there are 3 age groups then the contact matrix will have 3 rows and 3 columns. Contact matrices can be used for other groups as long as the dimension of the matrix matches the number of groups.
In the example above the dimension of the contact matrix will be the same as the number of age groups, i.e. if there are 3 age groups then the contact matrix will have 3 rows and 3 columns. Contact matrices can be used for other groups as long as the dimension of the matrix matches the number of groups.

For example, we might have a meta population model with two geographic areas. Then our contact matrix would be a 2 x 2 matrix with entries representing the contact between and within the geographic areas.



## Summary

In this tutorial, we have learnt the definition of the contact matrix, how they are estimated and how to access social contact data from `socialmixr`. In the next tutorial, we will learn how to use the R package `{epidemics}` to generate disease trajectories from mathematical models with contact matrices from `socialmixr`.
In this tutorial, we have learnt the definition of the contact matrix, how they are estimated and how to access social contact data using `{contactsurveys}` and `{socialmixr}`. In the next tutorial, we will learn how to use the R package `{epidemics}` to generate disease trajectories from mathematical models, with contact matrices using `socialmixr`.

::::::::::::::::::::::::::::::::::::: keypoints

Expand Down
8 changes: 4 additions & 4 deletions episodes/modelling-interventions.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ library(epidemics)

+ Complete tutorial on [Simulating transmission](../episodes/simulating-transmission.md).

Learners should also familiarise themselves with following concept dependencies before working through this tutorial:
Learners should also familiarise themselves with the following concept dependencies before working through this tutorial:

**Outbreak response**: [Intervention types](https://www.cdc.gov/nonpharmaceutical-interventions/).

Expand Down Expand Up @@ -379,7 +379,7 @@ Then continue with the livecoding.

## Pharmaceutical interventions

Pharmaceutical interventions (PIs) are measures such as vaccination and mass treatment programs. In the previous section, we integrated the interventions into the model by reducing parameter values during specific period of time window in which these intervention set to take place. In the case of vaccination, we assume that after the intervention, individuals are no longer susceptible and should be classified into a different disease state. Therefore, we specify the rate at which individuals are vaccinated and track the number of vaccinated individuals over time.
Pharmaceutical interventions (PIs) are measures such as vaccination and mass treatment programs. In the previous section, we integrated the interventions into the model by reducing parameter values during a specific time period in which these intervention are set to take place. In the case of vaccination, we assume that after the intervention, some or all individuals are no longer susceptible and should be classified into a different disease state. Therefore, we specify the rate at which individuals are vaccinated and track the number of vaccinated individuals over time.

The diagram below shows the SEIRV model implemented using `model_default()` where susceptible individuals are vaccinated and then move to the $V$ class.

Expand Down Expand Up @@ -429,9 +429,9 @@ $$
\end{aligned}
$$

Individuals in age group ($i$) at specific time dependent ($t$) are vaccinated at rate ($\nu_{i,t}$). The other SEIR components of these equations are described in the tutorial [simulating transmission](../episodes/simulating-transmission.md#simulating-disease-spread).
Individuals in age group ($i$) at specific time dependent ($t$) are vaccinated at rate ($\nu_{i,t}$). The other SEIR components of these equations are described in the tutorial [simulating transmission](../episodes/simulating-transmission.md#simulating-disease-spread).

To explore the effect of vaccination we need to create a vaccination object to pass as an input into `model_default()` that includes age groups specific vaccination rate `nu` and age groups specific start and end times of the vaccination program (`time_begin` and `time_end`).
To explore the effect of vaccination we need to create a vaccination object to pass as an input into `model_default()` that includes age-group-specific vaccination rate `nu` and age-group-specific start and end times of the vaccination program (`time_begin` and `time_end`).

Here we will assume all age groups are vaccinated at the same rate 0.01 and that the vaccination program starts on day 40 and continue to be in place for 150 days.

Expand Down
12 changes: 6 additions & 6 deletions episodes/simulating-transmission.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ webshot::install_phantomjs(force = TRUE)

+ Complete tutorial on [contact matrices](../episodes/contact-matrices.md).

Learners should familiarise themselves with following concept dependencies before working through this tutorial:
Learners should familiarise themselves with the following concept dependencies before working through this tutorial:

**Mathematical Modelling**: [Introduction to infectious disease models](https://doi.org/10.1038/s41592-020-0856-2), [state variables](../learners/reference.md#state), [model parameters](../learners/reference.md#parsode), [initial conditions](../learners/reference.md#initial), [differential equations](../learners/reference.md#ordinary).

Expand All @@ -57,7 +57,7 @@ go to the [main setup page](../learners/setup.md#software-setup).

## Introduction

Mathematical models are useful tools for generating future trajectories of disease spread. In this tutorial, we will use the R package `{epidemics}` to generate disease trajectories of an influenza strain with pandemic potential. By the end of this tutorial, you will be able to generate the trajectory below showing the number of infectious individuals in different age categories over time.
Mathematical models are useful tools for generating trajectories of disease spread. In this tutorial, we will use the R package `{epidemics}` to generate disease trajectories of an influenza strain with pandemic potential. By the end of this tutorial, you will be able to generate the trajectory below showing the number of infectious individuals in different age categories over time.

In this tutorial we are going to learn how to use the `{epidemics}` package to simulate disease trajectories and access to social contact data with `{socialmixr}`. We'll use `{dplyr}`, `{ggplot2}` and the pipe `%>%` to connect some of their functions, so let's also call to the `{tidyverse}` package:

Expand Down Expand Up @@ -142,7 +142,7 @@ $$
\end{aligned}
$$

Individuals in age group ($i$) move from the susceptible state ($S_i$) to the exposed state ($E_i$) via age-specific contacts with infectious individuals in all groups $\beta S_i \sum_j C_{i,j} I_j/N_j$. The contact matrix $C$ allows for heterogeneity in contacts between age groups. They then move to the infectious state at a rate $\alpha$ and recover at a rate $\gamma$. Note that this model assumes no loss of immunity (there are no flows out of the recovered state), which may not be applicable for all diseases as some allow for reinfection.
Individuals in age group ($i$) move from the susceptible state ($S_i$) to the exposed state ($E_i$) via age-specific contacts with infectious individuals in all groups $\beta S_i \sum_j C_{i,j} I_j/N_j$. The contact matrix $C$ allows for heterogeneity in contacts between age groups. They then move to the infectious state at a rate $\alpha$ and recover at a rate $\gamma$. Note that this model assumes no loss of immunity (meaning there are no flows out of the recovered state), which may not be applicable to all diseases. Immunity wanes more rapidly for certain infections, allowing for reinfection.

The model parameters are:

Expand Down Expand Up @@ -284,9 +284,9 @@ We combine the three initial conditions vectors into one matrix,
```{r initial_conditions}
# combine the initial conditions into a matrix class object
initial_conditions <- rbind(
initial_conditions_inf, # age group 1 (only group with infectious)
initial_conditions_free, # age group 2
initial_conditions_free # age group 3
initial_conditions_inf, # age group [0,20) (only group with infectious)
initial_conditions_free, # age group [20, 40)
initial_conditions_free # age group 40+
)

# use contact matrix to assign age group names
Expand Down
2 changes: 1 addition & 1 deletion episodes/vaccine-comparisons.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ exercises: 20

+ Complete tutorials [Simulating transmission](../episodes/simulating-transmission.md), [Modelling interventions](../episodes/modelling-interventions.md) and [Comparing public health outcomes of interventions](../episodes/compare-interventions.md).

Learners should familiarise themselves with following concept dependencies before working through this tutorial:
Learners should familiarise themselves with the following concept dependencies before working through this tutorial:

**Outbreak response**: [Intervention types](https://www.cdc.gov/nonpharmaceutical-interventions/).
:::::::::::::::::::::::::::::::::
Expand Down
6 changes: 3 additions & 3 deletions learners/setup.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

## Motivation

**Outbreaks** of infectious diseases can appear as a result of different pathogens, and in different contexts, but they typically lead to similar public health questions, from understanding patterns of transmission and severity to examining the effect of control measures ([Cori et al. 2017](https://royalsocietypublishing.org/doi/10.1098/rstb.2016.0371#d1e605)). We can relate each of these public health questions to a series of outbreak data analysis tasks. The more efficiently and reliably we can perform these tasks, the faster and more accurately we can answer the underlying questions.
**Outbreaks** of infectious diseases can appear as a result of different pathogens, and in different contexts, but they typically lead to similar public health questions, from understanding patterns of transmission and severity, to examining the effect of control measures ([Cori et al. 2017](https://royalsocietypublishing.org/doi/10.1098/rstb.2016.0371#d1e605)). We can relate each of these public health questions to a series of outbreak data analysis tasks. The more efficiently and reliably we can perform these tasks, the faster and more accurately we can answer the underlying questions.

Epiverse-TRACE aims to provide a software ecosystem for [**outbreak analytics**](reference.md#outbreakanalytics) with integrated, generalisable and scalable community-driven software. We support the development of new R packages, help link together existing tools to make them more user-friendly, and contribute to a community of practice, spanning field epidemiologists, data scientists, lab researchers, health agency analysts, software engineers and more.

Expand All @@ -13,7 +13,7 @@
Our tutorials are built around an outbreak analysis pipeline split into three stages: **Early tasks**, **Middle tasks** and **Late tasks**. The outputs of tasks completed in earlier stages commonly feed into the tasks required for later ones.


![An overview of the tutorial topics arranged by the three stages of outbreak analytics.](https://epiverse-trace.github.io/task_pipeline-minimal.svg)

Check warning on line 16 in learners/setup.md

View workflow job for this annotation

GitHub Actions / Build markdown source files if valid

[image missing alt-text]: https://epiverse-trace.github.io/task_pipeline-minimal.svg

Each stage has its tutorial website and each tutorial website consists of a set of episodes covering different topics.

Expand All @@ -36,15 +36,15 @@

Our strategy is to gradually incorporate specialised **R packages** into a traditional analysis pipeline. These packages should fill the gaps in these epidemiology-specific tasks in response to outbreaks.

![In **R**, the fundamental unit of shareable code is the **package**. A package bundles together code, data, documentation, and tests and is easy to share with others ([Wickham and Bryan, 2023](https://r-pkgs.org/introduction.html))](episodes/fig/pkgs-hexlogos-2.png).

Check warning on line 39 in learners/setup.md

View workflow job for this annotation

GitHub Actions / Build markdown source files if valid

[image missing alt-text]: episodes/fig/pkgs-hexlogos-2.png

:::::::::::::::::::::::::::: prereq

This content assumes intermediate R knowledge. This tutorials are for you if:
This content assumes intermediate R knowledge. These tutorials are for you if:

- You can read data into R, transform and reshape data, and make a wide variety of graphs.
- You are familiar with functions from `{dplyr}`, `{tidyr}`, and `{ggplot2}`.
- You can use the magrittr pipe `%>%` and/or native pipe `|>`.
- You can use the `{magrittr}` pipe `%>%` and/or native pipe `|>`.


We expect learners to have some exposure to basic Statistical, Mathematical and Epidemic theory concepts, but NOT intermediate or expert familiarity with modeling.
Expand Down
Loading