Here’s a very quick tutorial on adding a time axis (using axis
from R base graphics) to an “arc” style plotted tree with phytools.
For the example, I’ll use a time-calibrated phylogenetic tree of 175 species of elapid snakes from Lee et al. (2016).
The tree is stored in the file elapidae.tre
.
## load packages
library(phytools)
library(plotrix)
elapidae.tree<-read.tree(file="elapidae.tre")
elapidae.tree
##
## Phylogenetic tree with 175 tips and 174 internal nodes.
##
## Tip labels:
## Calliophis_bivirgata, Calliophis_melanurus, Sinomicrurus_japonicus, Sinomicrurus_kelloggi, Sinomicrurus_macclellandi, Micruroides_euryxanthus, ...
##
## Rooted; includes branch lengths.
I’m going to set the arc height to be 40% of the total tree height using arc_height=0.4
.
To draw my time axis I’ll use the functions axis
(in base R) and draw.arc
(from plotrix).
arc_height<-0.4
h<-max(nodeHeights(elapidae.tree))
plotTree(elapidae.tree,type="arc",lwd=1,fsize=0.45,ftype="i",
arc_height=arc_height,ylim=c(-0.1*h,1.1*(1+arc_height)*h))
labs<-seq(0,h,by=5)
a1<-axis(1,pos=-0.02*h,at=h-labs+arc_height*h,
labels=labs,cex.axis=0.8,lwd=2,lend=2)
text(mean(a1),-0.23*h,"million years bp",font=3)
a2<-axis(1,pos=-0.02*h,at=-h+labs-arc_height*h,
labels=labs,cex.axis=0.8,lwd=2,lend=2)
text(mean(a2),-0.23*h,"million years bp",font=3)
draw.arc(0,0,radius=h-labs[2:length(labs)]+arc_height*h,
angle1=,angle2=pi,col=make.transparent("blue",0.4),
lty="dotted")
Cool.
No comments:
Post a Comment
Note: due to the very large amount of spam, all comments are now automatically submitted for moderation.