Load packages

#Load packages
library ("OutbreakTools")
## Loading required package: ggplot2
## Loading required package: network
## network: Classes for Relational Data
## Version 1.13.0 created on 2015-08-31.
## 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-13 has been loaded
library ("ggplot2")
library ("ape")
library ("adegenet")
## Loading required package: ade4
## 
##    /// adegenet 2.0.0 is loaded ////////////
## 
##    > overview: '?adegenet'
##    > tutorials/doc/questions: 'adegenetWeb()' 
##    > bug reports/feature resquests: adegenetIssues()
library ("adephylo")
## 
## Attaching package: 'adephylo'
## 
## The following object is masked from 'package:ade4':
## 
##     orthogram
  1. Figure for the timeline of samples of the Newborn equine influenza outbreak
#Load data
data ("HorseFlu")
#Create basic figure
figure1 <- plot (HorseFlu, orderBy="yardID", colorBy="yardID",
                 what="shedding", size=3)
#Customize legends
figure1 <- figure1 + scale_color_discrete ("Yard identifier") +
  guides (col=guide_legend (ncol = 3))
figure1 <- figure1 + scale_shape ("shedding data", labels=paste ("sample", 
  1:6)) + labs (x="collection date")
#Display figure
figure1

This figure displays the time of locations (yards) that samples were collected during the influenza outbreak. Individual are reprensented by horizontal lines, and samples are represented by symbols.

  1. Generate the phylogeny tree of pandemic influenza H1N1
#Load data
data ("FluH1N1pdm2009")
attach (FluH1N1pdm2009)
## The following object is masked from package:datasets:
## 
##     trees

Create OBKDATA Object

x <- new ("obkData", individuals = individuals, dna = FluH1N1pdm2009$dna,
          dna.individualID = samples$individualID, dna.date = samples$date,
          trees = FluH1N1pdm2009$trees)
detach (FluH1N1pdm2009)

Create figure

figure2 <- plotggphy (x, ladderize = TRUE, branch.unit = "year", major.breaks
    = "2 month", axis.date.format = "%b%Y", tip.color = "location", tip.size=3, 
    tip.alpha=0.75)

Display figure

figure2

Phylogenic tree of pandemic influenza H1N1 sequences. It shows the geographic and temporal distribution of hemagglutinin segments samples and how closely related they are.

3.a Generate epidemic curves of an outbreak using SIR epidemic model

set.seed (1)
epi <- simuEpi (N=100, beta=.005, D=50)

Create basic figure - Panel A

figure3a <- epi$plot + labs (y="Number of individuals")

Panel A Display figure

figure3a

This figure represent a stochastic SIR model that was used to simulate the outbreak. It shows the number of susceptible, infected, and recovered overtime.

Create basic figure - Panel B

net <- epi$x@contacts

Define colors and annotations

dates <- get.data(epi$x, "DateInfected")
days <- as.integer(dates-min(dates))
col.info <- any2col(days, col.pal=seasun)
col.graph <- col.info$col[as.numeric(get.individuals(net))]
annot <- min(dates) + col.info$leg.txt
annot <- format(annot, "%b %d")

Display figure - Panel B

par(mar=c(.2,1,1,0.2),xpd=TRUE)
plot(net, vertex.cex=1.5, vertex.col=col.graph)
legend ("topleft", fill=col.info$leg.col, leg=annot, bg=transp ("white"),cex=1,
title="Date of infection", ncol=2, inset=c(-.02))

The transmission tree shows the disease dynamics as it spread overtime. Blue dots represent early cases and the red ones represent late cases.

Build neighbor joining tree - Panel C

tre <- nj(dist.dna (get.dna (epi$x)$locus.1))
tre <- ladderize (tre) # ladderize the tree
tre <- root (tre,1) # root tree to first case

Display figure - Panel C

par (mar=rep (2,4))
bullseye (tre, tip.color=col.info$col, circ.bg=transp ("grey",.1), font=2)
legend ("bottomright", fill=col.info$leg.col, leg=annot,
        bg=transp ("white"),cex=1, title="Date of infection", ncol=2, inset=c(-.02))
box ("figure")

The neighbour-joining phylogeny shows ladder and root connexions to the first case.