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

Load data

data ("HorseFlu")

Create basic figure

figure1 <- plot(HorseFlu,  orderBy="yardID",  colorBy="yardID",  what="shedding", size=3)

Customize legends

figure1 <- figure1 + scale_y_discrete("Yard identifier") + guides (col=guide_legend(ncol = 3))
## Scale for 'y' is already present. Adding another scale for 'y', which will replace the existing scale.
figure1 <- figure1 + scale_shape("Shedding data",  labels=paste ("sample", 1:6)) + labs (x="Collection date")

Display figure

figure1

In this figure, the time and temporal distributions are displayed. It shows where and when samples were collected over time. Each of the shapes represents a sample collected from the equines infected with influenza. The colored lines represents an individual yard from which the samples were collected.

H1N1 2009- Phylogeny of a Pandemic

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)
## Found more than one class "multiPhylo" in cache; using the first, from namespace 'OutbreakTools'
detach(FluH1N1pdm2009)

Create and display figure

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

Display Figure

figure2

This figure is of the H1N1 phylogenic tree. It illustrates the locations and periods of time of which the samples were collected. Furthermore, it gives representation of how the virus at each location point are related/connected to each other.

SIR Model of an Outbreak Simulation

Simulate outbreak

set.seed(1)
epi = simuEpi (N=100, beta = 0.005, D=50)

Create Basic Figure of Panel A

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

Display Figure of Panel A

figure3a

This figure is a graph of a stochastic SIR model. It illustrates the changes of susceptible, infected, and recovered individuals of the outbreak over time.

Network Model of an Outbreak Simulation

net = epi$x@contacts

Define color 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

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=0.75,
title="Date of infection", ncol=2, inset=c(-.02))

This figure is of a network model. It is is the form of a transmission tree. Each colored dot represents a host and its corresponding date of infection. The colors range from blue (earlier dates of the outbreak) to yellow (majority of the infections) to red (last days of the outbreak).

Neighbour-Joining Phylogenic Tree of an Outbreak Simulation

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

par(mar=rep(2,4))
bullseye(tre, tip.color=col.info$col, circ.bg=transp("grey",0.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")

This figure is of a neighbour-joining phylogenic tree. It illustrates the simulated DNA sequences from the first host (the root) until the last host. Each colored dot represents a host and its corresponding date of infection. The colors range from blue (earlier dates of the outbreak) to yellow (majority of the infections) to red (last days of the outbreak).