A time-stamped phylogeny of Influenza A H5N1 virus from this BEAST practical is included in the package directory.

suppressPackageStartupMessages(library(phyland))
suppressPackageStartupMessages(library(ggplot2))
tr <- read.nexus(file=paste(path.package("phyland"),"/H5N1_HA_mcc.nex",sep=""))
metadata <- read.table(file=paste(path.package("phyland"),"/H5N1_locs.txt",sep=""),sep="\t",stringsAsFactors=FALSE)
tr2 <- tr
yr <- unlist(lapply(strsplit(tr$tip.label,"_"),tail,1))
tr2$tip.label <- paste("A",seq(1,length(tr2$tip.label)),yr,metadata[match(tr$tip.label,metadata[,1]),2],sep="_")
tr2
tr2.phyland <- phylandml(tr2,delimiter="_",quiet=TRUE)
x <- tr2.phyland$coef[1:7]
effsizes <- data.frame(Deme=names(x),Ne=x)
o <- order(effsizes$Ne,decreasing=FALSE)
effsizes$Deme <- factor(effsizes$Deme,levels=effsizes$Deme[o])
ggplot(effsizes,aes(x=Deme,y=Ne))+geom_bar(stat="identity")+coord_flip()+scale_y_log10()
x <- tr2.phyland$coef[8:length(tr2.phyland$coef)]
migrates <- data.frame(Demes=names(x),Rate=x)
migrates <- migrates[migrates$Rate>1e-6,]
o <- order(migrates$Rate,decreasing=FALSE)
migrates$Demes <- factor(migrates$Demes,levels=migrates$Demes[o])
ggplot(migrates,aes(x=Demes,y=Rate))+geom_bar(stat="identity")+coord_flip()


emvolz-phylodynamics/phyland documentation built on May 4, 2019, 3:21 p.m.