I realized after describing a method to overlay time since the root onto a phylomorphospace plot using a color gradient - I realized that there is a much easier way to do the same thing using the phytools function make.era.map. (To include the color legend, you should download the latest phytols version: phytools 0.3-07.)
Here's how to do it:
> # load phytools
> library(phytools)
> packageVersion("phytools")
[1] ‘0.3.7’
> # simulate a tree & add realistic looking labels
> tree<-pbtree(n=26,scale=100)
> tree$tip.label<-sapply(LETTERS[26:1],function(x) paste(x,". ",paste(sample(letters,6),collapse=""),sep=""), USE.NAMES=FALSE)
> # simulate data for our phylomorphospace
> X<-fastBM(tree,nsim=2)
> colnames(X)<-paste("V",1:2,sep="")
> # now add the era map
> tree<-make.era.map(tree,0:99)
> # choose the color scale
> colors<-rainbow(100,start=0,end=0.7)
> names(colors)<-1:100
> # check it
> plotSimmap(tree,colors,pts=FALSE,lwd=6)
> library(phytools)
> packageVersion("phytools")
[1] ‘0.3.7’
> # simulate a tree & add realistic looking labels
> tree<-pbtree(n=26,scale=100)
> tree$tip.label<-sapply(LETTERS[26:1],function(x) paste(x,". ",paste(sample(letters,6),collapse=""),sep=""), USE.NAMES=FALSE)
> # simulate data for our phylomorphospace
> X<-fastBM(tree,nsim=2)
> colnames(X)<-paste("V",1:2,sep="")
> # now add the era map
> tree<-make.era.map(tree,0:99)
> # choose the color scale
> colors<-rainbow(100,start=0,end=0.7)
> names(colors)<-1:100
> # check it
> plotSimmap(tree,colors,pts=FALSE,lwd=6)
> # plot phylomorphospace
> phylomorphospace(tree,X,colors=colors,node.by.map=TRUE, lwd=4,node.size=c(0,1.5),label="horizontal",xlim=c(-8,20))
> add.color.bar(cols=colors,leg=15,title="time since the root",subtitle="",lims=c(0,max(nodeHeights(tree))))
Click where you want to draw the bar
> phylomorphospace(tree,X,colors=colors,node.by.map=TRUE, lwd=4,node.size=c(0,1.5),label="horizontal",xlim=c(-8,20))
> add.color.bar(cols=colors,leg=15,title="time since the root",subtitle="",lims=c(0,max(nodeHeights(tree))))
Click where you want to draw the bar
Hi, I would like if is possible to correct when the names are overlapped?
ReplyDeleteThanks!