simuEpi: Simulate an epidemic following a SIR model

Description Usage Arguments Value Author(s) Examples

View source: R/simuEpi.R

Description

Simulate an epidemic following a SIR model, together with a transmission tree and a set of sequences consistent with the trajectory of the epidemic.

Usage

1
2
  simuEpi(N = 1000, D = 10, beta = 0.001, nu = 0.1, L = 1000, mu =
          0.001, plot=TRUE, makePhyloTree=FALSE)

Arguments

N

Size of the population

D

Duration of simulation

beta

Rate of infection

nu

Rate of recovery

L

Length of genetic sequences

mu

Probability of mutation per base per transmission event

plot

logical indicating whether or not to plot the SIR trajectory over time and save it in the output.

makePhyloTree

Logical; whether to create a neighbour-joining tree from the simulated sequences.

Value

A list containing the SIR dynamics ($dynamics), an obkData of the outbreak ($x), and an optional ggplot graphic ($plot).

Author(s)

Original version by Xavier Didelot and Caroline Colijn. Graphics modification by Thibaut Jombart.

Examples

 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
## Not run: 
## Simulate an outbreak of 200 individuals over 20 time steps ##
set.seed(3)

x <- simuEpi(N = 200, D = 20, beta = 0.002, nu = 0.1, mu = 0.002)

## x is a list:
class(x)
names(x)

## x$dynamics contains demographic info
x$dynamics

## x$plot is a ggplot object
class(x$plot)
x$plot

## x$x is the obkData object
summary(x$x)
plotIndividualTimeline(x$x, colorBy="DateInfected")


## Same, with a phylogenetic tree
x <- simuEpi(N = 200, D = 20, beta = 0.002, nu = 0.1, mu = 0.002,
             plot=TRUE, makePhyloTree=TRUE)

plotggphy(x$x, ladderize=TRUE, show.tip=TRUE,
      branch.unit="year", tip.label.size=4)

## End(Not run)

Example output

Loading required package: ggplot2
Loading required package: network
network: Classes for Relational Data
Version 1.14-377 created on 2019-03-04.
copyright (c) 2005, Carter T. Butts, University of California-Irvine
                    Mark S. Handcock, University of California -- Los Angeles
                    David R. Hunter, Penn State University
                    Martina Morris, University of Washington
                    Skye Bender-deMoll, University of Washington
 For citation information, type citation("network").
 Type help("network-package") to get started.

Loading required package: knitr
 OutbreakTools 0.1-16 has been loaded

[1] "list"
[1] "x"        "dynamics" "plot"    
   Susceptible Infected Recovered       date
1          199        1         0 2000-01-01
2          199        1         0 2000-01-02
3          199        1         0 2000-01-03
4          199        1         0 2000-01-04
5          198        2         0 2000-01-05
6          198        1         1 2000-01-06
7          198        1         1 2000-01-07
8          197        1         2 2000-01-08
9          197        1         2 2000-01-09
10         196        2         2 2000-01-10
11         196        2         2 2000-01-11
12         194        4         2 2000-01-12
13         194        4         2 2000-01-13
14         193        5         2 2000-01-14
15         189        8         3 2000-01-15
16         184       13         3 2000-01-16
17         182       13         5 2000-01-17
18         179       16         5 2000-01-18
19         176       17         7 2000-01-19
20         168       22        10 2000-01-20
[1] "gg"     "ggplot"
Dataset of 32 individuals with...
== @individuals ==
individuals information
  32 entries

== @dna ==
32 sequences across 1 loci, 32 individuals, from 2000-01-01 to 2000-01-20
length of concatenated alignment: 1000 nucleotides
Attached meta data:
  32 entries,  32 individuals, from 2000-01-01 to 2000-01-20
  recorded fields are:
  <locus> class: character,  1 unique values,  frequency range: [32;32],  0 NAs

== @contacts ==
31 contacts between 32 individuals

== @trees ==
0 phylogenetic trees with 0 tips

Warning message:
`show_guide` has been deprecated. Please use `show.legend` instead. 

OutbreakTools documentation built on Oct. 6, 2017, 1:03 a.m.