-
Notifications
You must be signed in to change notification settings - Fork 0
/
README.Rmd
90 lines (73 loc) · 6.02 KB
/
README.Rmd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
---
output: github_document
---
<!-- README.md is generated from README.Rmd. Please edit that file -->
```{r, include = FALSE}
knitr::opts_chunk$set(
collapse = TRUE,
comment = "#>",
fig.path = "man/figures/README-",
out.width = "100%"
)
```
# MOdelling REpeat VACcination (morevac)
<!-- badges: start -->
<!-- badges: end -->
## Overview
To model the effects of repeated exposures to infectious diseases (e.g., infection and vaccination) over an individual’s lifetime, we developed a multi-annual, individual-based, stochastic model of infection and vaccination. This model and the associated functions comprise the `morevac` package. Our model incorporates three main components:
1. viral evolution, specifically antigenic drift of the infecting virus over time,
2. vaccine kinetics influencing the amount of protection conferred by the vaccine, namely antigenic match of the circulating strain and vaccine strain, waning, and take (defined as the proportion of individuals who receive the vaccine and have an immune response), and
3. individual level characteristics, such as age and prior exposure history. All three components are then used to inform an individual’s susceptibility to infection at each time point (here, considered to be one year).
The full model and assumptions are described by [Ainslie and Riley 2022](https://doi.org/10.1016/j.vaccine.2022.03.065).
![Figure 1. Model schematic of A) antigenic drift and vaccine update and B) individual susceptibility over time depending on exposure history. Colored regions in A represent the years in which a vaccine was used. The color change indicates that the vaccine was updated. The vertical red lines in B indicate an infections and the dashed vertical lines indicate vaccinations. Note the color of the vaccine lines in B match those in A indicating the match between the vaccine strain and cirulating virus and the impact of match or mismatch on susceptibility (black line in B). ](vignettes/figure0_new2.png)
## Installation
1. Install [R](http://cran.r-project.org)
2. Install the development version of serosolver from
[GitHub](https://github.com/seroanalytics/serosolver):
``` r
devtools::install_github("kylieainslie/morevac")
library(morevac)
```
## Example
```{r, load_packages, warning=FALSE, message=FALSE}
# load required packages
library(morevac)
library(rdist)
library(dplyr)
library(tidyr)
library(stringr)
library(ggplot2)
```
The function `mutiannual` initialises the population and then simulates infections and vaccinations over years within the population. By default, the model runs from 1820 to 2019 with a vaccination starting in 2000 with an assumed coverage of 50%. These assumptions can be changed using the arguments in `multiannual`.
```{r, run_model}
# run multi-annual model
out <- multiannual()
```
The output produced by `multiannual` is a named list that contains the following elements:
- `inf_history`: a named list of elements related to the infection histories of each individual, including
- `inf_hist_mat`: a matrix of infection histories, where each row represents each individual and columns represent years. A value of 1 in inf_hist_mat[1,j] indicates that person i had an infection in year j.
- `suscept_mat`: a matrix that contains an individuals susceptibility to infection over time. Values range from 0 (completely immune) to 1 (completely susceptible).
- `vac_history`: a named list of elements related to the vaccination histories of each individual, including
- `n`: number of individuals
- `vac_hist_mat`: a matrix of vaccination histories, where each row represents each individual and columns represent years. A value of 1 in vac_hist_mat[1,j] indicates that person i was vaccinated in year j.
- `v`: a matrix of the number of years since last vaccination. If never vaccinated the value of v = 999 and then increases each year until vaccination occurs. In the year that an individual was vaccinated v = 0.
- `ages`: matrix of each individual's age over time. We assume that an individual dies at age 80 and is then replaced by another person aged 0.
- `drift`: a named list of elements related to viral atigenic drift over time with the following elements:
- `drift`: a data frame with the cumulative amount of drift (drawn from an exponential distribution with rate specified by the user) over time. The data frame has two columns: `x` represents the year and `y` represents the cumulative drift from the first year.
- `antigenic_dist` a matrix with the antigenic distance over time as calculated by `pdist`.
- `vac_update`: an identity vector indicating in which years the vaccine formula should be updated (1 = yes, 0 = no).
- `gammas`: a vector of the protection conferred by vaccination. In years in which the vaccine formula is a perfect match to the virus strain, then gamma = 0.3. In years in which the vaccination is not a perfect match, the reduction in protection declines until the vaccine strain is updated again.
- `vac_this_year`: an identity vector indicating in which years vaccination should occur (1 = yes, 0 = no).
Most of the outputs produced by out or for housekeeping within the model and may not be relevant for the user.
```{r, model_output_summary, echo=FALSE}
str(out)
```
Using the output from `multiannual`, we can look at some of the model components graphically. For example, we can look at the attack rate over time using `plot_attack_rates` and using `out$inf_history$inf_hist_mat` as input. Note: the vaccination campaign begins in 2000.
```{r, attack_rates, results='hide', warning=FALSE, message=FALSE, fig.cap="Figure 1. Attack rates in the modelled population over time. The blue dashed line indicates the start of the vaccination program with an assumed coverage of 50%."}
# get attack rates
ar_out <- get_attack_rates(inf_history = out$inf_history$inf_hist_mat,
ages_mat = out$ages, years = 1820:2019)
# plot total attack rates
p_ar <- plot_attack_rates(dat = ar_out$attack_rates)
p_ar + geom_vline(xintercept = 2000, linetype = "dashed", color = "blue", linewidth = 1)
```