Learn R Programming

OutbreakTools (version 0.1-16)

simuEpi: Simulate an epidemic following a SIR model

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

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).

Examples

Run this code
# 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)
# }

Run the code above in your browser using DataLab