Learn R Programming

outbreaker (version 1.1-8)

simOutbreak: Simulation of pathogen genotypes during disease outbreaks

Description

The function simOutbreak implements simulations of disease outbreaks. The infectivity of cases is defined by a generation time distribution. The function as.igraph allows to convert simulated transmission trees into igraph objects.

Usage

simOutbreak(R0, infec.curve, n.hosts = 200, duration = 50,
  seq.length = 10000, mu.transi = 1e-04, mu.transv = mu.transi/2,
  rate.import.case = 0.01, diverg.import = 10, group.freq = 1,
  spatial = FALSE, disp = 0.1, area.size = 10, reach = 1,
  plot = spatial, stop.once.cleared = TRUE)

# S3 method for simOutbreak print(x, ...)

# S3 method for simOutbreak [(x, i, j, drop = FALSE)

# S3 method for simOutbreak labels(object, ...)

# S3 method for simOutbreak as.igraph(x, edge.col = "black", col.edge.by = "dist", vertex.col = "gold", edge.col.pal = NULL, annot = c("dist", "n.gen"), sep = "/", ...)

# S3 method for simOutbreak plot(x, y = NULL, edge.col = "black", col.edge.by = "dist", vertex.col = "gold", edge.col.pal = NULL, annot = c("dist", "n.gen"), sep = "/", ...)

Arguments

R0

the basic reproduction number; to use several groups, provide a vector with several values.

infec.curve

a numeric vector describing the individual infectiousness at time t=0, 1, …

n.hosts

the number of susceptible hosts at the begining of the outbreak

duration

the number of time steps for which simulation is run

seq.length

an integer indicating the length of the simulated haplotypes, in number of nucleotides.

mu.transi

the rate of transitions, in number of mutation per site and per time unit.

mu.transv

the rate of transversions, in number of mutation per site and per time unit.

rate.import.case

the rate at which cases are imported at each time step.

diverg.import

the number of time steps to the MRCA of all imported cases.

group.freq

the frequency of the different groups; to use several groups, provide a vector with several values.

spatial

a logical indicating if a spatial model should be used.

disp

the magnitude of dispersal (standard deviation of a normal distribution).

area.size

the size of the square area to be used for spatial simulations.

reach

the mean of the exponential kernel used to determine new infections.

plot

a logical indicating whether an animated plot of the outbreak should be displayed; only available with the spatial model.

stop.once.cleared

a logical indicating if the simulation should stop when the global force of infection is close to zero (<10^-12); TRUE by default.

x, object

simOutbreak objects.

further arguments to be passed to other methods

i, j, drop

i is a vector used for subsetting the object. For instance, i=1:3 will retain only the first three haplotypes of the outbreak. j and drop are only provided for compatibility, but not used.

edge.col

the color of the edges of the plotted graph; overridden by col.edge.by.

col.edge.by

a character indicating the type of information to be used to color the edges; currently, the only valid value is "dist" (distances, in number of mutations). Other values are ignored.

vertex.col

the colors to be used for the vertices (i.e., cases).

edge.col.pal

the color palette to be used for the edges; if NULL, a grey scale is used, with darker shades representing larger values.

annot

a character indicating the information to be used to annotate the edges; currently accepted values are "dist" (genetic distances, in number of mutations), and "n.gen" (number of generations between cases).

sep

a character used to separate fields used to annotate the edges, whenever more than one type of information is used for annotation.

y

present for compatibility with the generic 'plot' method. Currently not used.

col

the color of the vertices of the plotted graph.

Value

=== simOutbreak class === simOutbreak objects are lists containing the following slots:

  • n: the number of cases in the outbreak

  • dna: DNA sequences in the DNAbin matrix format

  • dates: infection dates

  • dynam: a data.frame containing, for each time step (row), the number of susceptible, infected, or recovered in the population.

  • id: a vector of integers identifying the cases

  • ances: a vector of integers identifying infectors ('ancestor')

  • nmut: the number of mutations corresponding to each ancestry

  • ngen: the number of generations corresponding to each ancestry

  • call: the matched call

Examples

Run this code
# NOT RUN {
# }
# NOT RUN {
dat <- list(n=0)

## simulate data with at least 30 cases
while(dat$n < 30){
   dat <- simOutbreak(R0 = 2, infec.curve = c(0, 1, 1, 1), n.hosts = 100)
}
dat

## plot first 30 cases
N <- dat$n
plot(dat[1:(min(N,30))], main="First 30 cases")
mtext(side=3, text="nb mutations / nb generations")

## plot a random subset (n=10) of the first cases
x <- dat[sample(1:min(N,30), 10, replace=FALSE)]
plot(x, main="Random sample of 10 of the first 30 cases")
mtext(side=3, text="nb mutations / nb generations")

## plot population dynamics
head(dat$dynam,15)
matplot(dat$dynam[1:max(dat$onset),],xlab="time",
   ylab="nb of individuals", pch=c("S","I","R"), type="b")


## spatial model
w <-  exp(-sqrt((1:40)))
x <- simOutbreak(2, w, spatial=TRUE,
                 duration=500, disp=0.1, reach=.2)

## spatial model, no dispersal
x <- simOutbreak(.5, w, spatial=TRUE,
                 duration=500, disp=0, reach=5)
# }
# NOT RUN {
# }

Run the code above in your browser using DataLab