Skip to content
Branch: master
Find file Copy path
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
263 lines (155 sloc) 7.97 KB
```{r, echo = FALSE}
collapse = TRUE,
comment = "#>",
echo = TRUE
Welcome to the *epicontacts* package!
[![Travis-CI Build Status](](
[![Build status](](
[![Coverage Status](](
[![CRAN Downloads](](
[![Downloads from Rstudio mirror](](
# Installing the package
To install the current stable, CRAN version of the package, type:
```{r install, eval = FALSE}
To benefit from the latest features and bug fixes, install the development, *github* version of the package using:
```{r install2, eval = FALSE}
Note that this requires the package *devtools* installed.
# What does it do?
The main features of the package include:
* **`epicontacts`:** a new S3 class for storing linelists and contacts data
* **`make_epicontacts`:** a constructor for the new `epicontacts` class
* **`get_id`:** access unique IDs in an `epicontacts` with various options
* **`get_pairwise`**: extract attributes of record(s) in contacts database using
information provided in the linelist data of an `epicontacts` object.
* **`get_degree`:** access degree of cases in `epicontacts` with various options
* **`x[i,j,contacts]`:** subset an `epicontacts` object by retaining specified
* **`thin`:** retains matching cases in linelist / contacts
* **`summary`:** summary for `epicontacts` objects
* **`plot`:** plot for `epicontacts` objects; various types of plot are
available; default to `vis_epicontacts`
* **`vis_epicontacts`:** plot an `epicontacts` object using `visNetwork `
* **`as.igraph.epicontacts`:** create an `igraph` object from an epicontacts object
* **`get_clusters`:** assign clusters and corresponding cluster sizes to
linelist of an epicontacts object (clusters being groups of connected
* **`subset_clusters_by_id`**: subset an `epicontacts` object based on a IDs of
cases of interest.
* **`subset_clusters_by_size`**: subset an `epicontacts` object based on size(s)
of clusters (clusters being groups of connected individuals/nodes).
* **`graph3D`**: 3D graph from an `epicontacts` object.
# Resources
## Vignettes
An overview of *epicontacts* is provided below in the worked example below.
More detailed tutorials are distributed as vignettes with the package:
```{r, vignettes2, eval = FALSE}
vignette("overview", package="epicontacts")
vignette("customize_plot", package="epicontacts")
vignette("epicontacts_class", package="epicontacts")
## Websites
The following websites are available:
- The official *epicontacts* website, providing an overview of the package's functionalities, up-to-date tutorials and documentation: <br>
- The *epicontacts* project on *github*, useful for developers, contributors, and users wanting to post issues, bug reports and feature requests: <br>
- The *epicontacts* page on CRAN: <br>
## Getting help online
Bug reports and feature requests should be posted on *github* using the [*issue*]( system. All other questions should be posted on the **RECON forum**: <br>
# A quick overview
The following worked example provides a brief overview of the package's
functionalities. See the [*vignettes section*](#vignettes) for more detailed
## Obtaining an *epicontacts* object
*epicontacts* need two types of data:
- a **linelist**, i.e. a spreadsheet documenting cases where columns are
variables and rows correspond to unique cases
- a **list of edges**, defining connections between cases, identified by their
unique identifier
There does not need to be an one-to-one correspondance between cases documented
in the linelist and those appearing in the contacts. However, links will be made
between the two sources of data whenever unique identifiers match. This will be
especially handy when subsetting data, or when characterising contacts in terms
of 'node' (case) properties.
We illustrate the construction of an *epicontacts* using contact data from a
Middle East Respiratory Syndrom coronavirus (MERS CoV) from South Korea in 2015,
available as the dataset `mers_korea_2015` in the package *outbreaks*.
x <- make_epicontacts(linelist = mers_korea_2015$linelist,
contacts = mers_korea_2015$contacts,
directed = TRUE)
In practice, the linelist and contacts will usually be imported from a text file
(e.g. .txt, .csv) or a spreadsheet (e.g. .ods, .xls) using usual import
functions (e.g. `read.table`, `read.csv`, `gdata::read.xls`).
## Simple analyses
First, we plot the *epicontacts* object:
```{r, eval = FALSE}
plot(x, selector = FALSE)
<img src="" width="600px">
This is a screenshot of the actual plot. For interactive graphs, see the [introductory vignette](
We can look for patterns of contacts between genders:
```{r, eval = FALSE}
plot(x, "sex", col_pal = spectral)
<img src="" width="600px">
There is no obvious signs of non-random mixing patterns, but this is worth
testing. The function `get_pairwise` is particularly useful for this. In its
basic form, it reports nodes of attributes for all contacts. For instance:
```{r, check_gender}
get_pairwise(x, attribute = "sex")
However, one can specify the function to be used to compare the attributes of
connected nodes; for instance:
```{r, test_gender}
sex_tab <- get_pairwise(x, attribute = "sex", f = table)
Indeed, there are no patterns of association between genders. We can also use
this function to compute delays between dates. For instance, to get the
distribution of the serial interval (delay between primary and secondary onset):
```{r, si}
si <- get_pairwise(x, attribute = "dt_onset")
hist(si, col = "grey", border = "white", nclass = 30,
xlab = "Time to secondary onset (days)",
main = "Distribution of the serial interval")
# Contributors (by alphabetic order):
- [Finlay Campbell](
- [Thomas Crellen](
- [Thibaut Jombart](
- [Nistara Randhawa](
- Bertrand Sudre
See details of contributions on: <br>
Contributions are welcome via **pull requests**.
Please note that this project is released with a [Contributor Code of Conduct]( By participating in this project you agree to abide by its terms.
**Maintainer:** Finlay Campbell (f.campbell15@imperial)
You can’t perform that action at this time.