-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathREADME.Rmd
76 lines (46 loc) · 4.87 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
---
output: github_document
---
<!-- README.md is generated from README.Rmd. Please edit that file -->
```{r setup, include = FALSE}
library(knitr)
```
# Synthetic contact matrices for 200 countries
<!-- badges: start -->
[![DOI](https://zenodo.org/badge/770713133.svg)](https://zenodo.org/doi/10.5281/zenodo.11365942)
<!-- badges: end -->
This analysis pipeline produces csv files of synthetic contact matrices generated for all countries listed in the United Nations' World Population Prospects (2017), using the [`conmat`](https://github.com/idem-lab/conmat) package.[^readme-1]
The `conmat` package is motivated by the contact matrices generated in [Prem, Cook, and Jit (2017)](https://doi.org/10.1371/journal.pcbi.1005697).
These instructions will assist you in downloading the csv files for synthetic contact matrices, and to modify the analysis pipeline to suit your own needs.
[^readme-1]: For more information on the `conmat` package, refer to its [documentation](https://idem-lab.github.io/conmat/dev/index.html).
## Download synthetic contact matrices
You can download the synthetic contact matrices by navigating to our [Zenodo repository](https://zenodo.org/records/11365943) and downloading the zip file. The contact matrices can be found in the folder **output-contact-matrices**.
Each csv file is named in the convention `{Country}_{Environment}_2015.csv`; for example, `AUS_work_2015.csv`. Country names are in ISO-3 format. The five environments for each country are: home, school, work, other, and all.
Alternatively, if you would like to load specific contact matrices, here is how you would do so for Australia in all settings:
```{r, results = "hide", message = FALSE}
library(readr)
url <- "https://raw.githubusercontent.com/idem-lab/syncomat/main/output-contact-matrices/AUS_all_2015.csv"
aus_all_cm <- read_csv(url)
```
The following is how the synthetic contact matrix looks for Australia in all settings, with the columns being "age group from" and the rows being "age group to."
```{r, echo = FALSE}
colnames(aus_all_cm)[1] <- "age_groups"
kable(
aus_all_cm,
digits = 5)
```
Each cell is the expected number of people that an individual will have contact with per day. In the contact matrix above, the number 2.36549 in the first column and first row indicates that we expect a 0-5 year old to be in contact with two other 0-5 year olds per day. The number 1.27998 in the first column, seventh row (30-35 age group) indicates that a 0-5 year old is, on average, in contact with one 30-35 year old per day.
## Running the analysis pipeline
To run this analysis pipeline, you would need to be familiar with the `targets` workflow.[^readme-2] This pipeline also utilises `renv`.[^readme-5]
[^readme-2]: For information on the `targets` workflow, refer to the `targets` [user manual](https://books.ropensci.org/targets/).
[^readme-5]: For information on how `renv` works, refer to the Introduction to `renv` [vignette](https://rstudio.github.io/renv/articles/renv.html). For a quick overview, refer to its [website](https://rstudio.github.io/renv/index.html).
First, download the zip file of this analysis pipeline from our [Zenodo repository](https://zenodo.org/records/11365943). Open the project in a new RStudio session.
Once you've opened the project in a new RStudio session, you will be prompted to run `renv::restore()`. Run `renv::restore()` to install the packages used in this analysis to your workspace. If you then come across issues, run `renv::status()`. Also run `?renv::status()` for advice on resolving these issues.
Open the `_targets.R` file, and run all lines of code under the **Set-up** section to load the R packages required for this pipeline. You can then run `tar_make()` to run the entire pipeline.
If you need more information about the pipeline, the [**Methodology**](https://github.com/idem-lab/syncomat/blob/main/Methodology.md) page will explain each target object and how you can modify each object to suit your own analysis needs.
This pipeline takes approximately 13 minutes[^readme-4] to run, which will generate contact matrices for 200 countries.
[^readme-4]: This pipeline took 13 minutes to run on a computer equipped with an Intel Core i7-8565U and 16 GB of RAM running a 64-bit version of Windows.
## Data sources
The age-specific population data that forms the basis for this analysis were derived from the [`wpp_age()`](https://epiforecasts.io/socialmixr/reference/wpp_age.html) function in the [`socialmixr`](https://epiforecasts.io/socialmixr/) package, which uses data from the [`wpp2017`](https://cran.r-project.org/web/packages/wpp2017/index.html) package.
## Notes
The contact matrices created are transposed in comparison to those discussed by [Prem, Cook, and Jit (2017)](https://doi.org/10.1371/journal.pcbi.1005697) and [Mossong et al. (2008)](https://doi.org/10.1371/journal.pmed.0050074). In other words, the rows are "age group to" and the columns are "age group from".