Learn R Programming

OutbreakTools (version 0.1-16)

make.phylo: Obtain phylogenies from outbreak data

Description

The function make.phylo is used to obtain phylogenies for each of the genes sequenced in an '>obkData object. Phylogenetic trees can optionally be plotted before being returned. Colors are used to distinguish samples, individuals, dates, or any other requested information. make.phylo is a wrapper for functions from the ape package: dist.dna for computing genetic distances, and specific methods for getting trees such as nj.

Usage

make.phylo(x, …)

# S4 method for obkData make.phylo(x, locus=NULL, result=c("obkData","multiPhylo"), model = "N", pairwise.deletion = FALSE, method=nj, plot=FALSE, ask=TRUE,…)

Arguments

x

an '>obkData object.

result

a character string indicating the type of result to be returned; if obkData, then the phylogenies are stored in x@trees, possibly removing previous phylogenies; if multiPhylo, the result is a list of phylo objects with the class multiPhylo.

locus

a character or integer vector indicating the loci to be used; if NULL, all loci are used, producing one phylogeny each; see get.dna.

model, pairwise.deletion

arguments passed to dist.dna.

method

a function producing phylogenetic trees with the class phylo (ape package) from a distance matrix with class dist; examples include nj, bionj, fastme.bal, and fastme.ols.

plot

a logical indicating whether plots of the trees should be produced.

ask

a logical indicating whether user input must be waited for before drawing new plots.

further graphical arguments to be passed to plot.phylo.

Value

A obkData with new phylogenies, or a list with class multiPhylo.

See Also

read.annotated.tree and read.annotated.nexus to read annotated phylogenies into phylo objects.

Examples

Run this code
# NOT RUN {
## Example using simulate outbreak ##

set.seed(3)
x <- simuEpi(N = 200, D = 20, beta = 0.002, nu = 0.1, mu = 0.002)$x
get.trees(x) # no tree here

## GET TREE AND DISPLAY IT
x <- make.phylo(x, plot=TRUE)
get.trees(x) # newly created trees


## DISPLAY TREE USING PLOTGGPHY

## root tree to first case ##
if(require(ape)){
tre <- root(get.trees(x)[[1]],1)
}

## plot tree, use color for dates ##
par(mar=c(1,1,4,1))
plot(tre, edge.width=2, type="fan", show.tip=FALSE)
title("NJ tree of a simulated outbreak")
mtext("each disk indicates 1 mutation from the root")

# }

Run the code above in your browser using DataLab