Two different people (Marcio Pie and a student whose name has somehow slipped my mind - please identify yourself!) independently suggested to me recently that I could use a similar approach to that employed when overlaying a posterior density map from stochastic mapping on a phylomorphospace to project time since the root of the tree onto a phylomorphospace. In theory, this would help overcome the difficulty that all temporal information about the phylogeny is lost when it is projected into morphospace.
Well, this is quite easy** (**that is, easy only because I've already programmed all the pieces in phytools) to do. Here's a hack using simulated data.
First let's load phytools & simulate tree & data:
Loading required package: phytools
> packageVersion("phytools")
[1] ‘0.2.93’
> # simulate tree & data
> tree<-pbtree(n=30,scale=100)
> X<-fastBM(tree,nsim=2)
AA<-contMap(tree,X[,1])
> H<-nodeHeights(tree)
> h<-max(H)
> for(i in 1:nrow(H)) names(AA$tree$maps[[i]])<- round((H[i,1]+cumsum(AA$tree$maps[[i]]))/h*1000)
> # check to verify that temporal information is correct
> plot(AA,legend=FALSE)
> add.color.bar(2,AA$cols,title="time from the root", lims=c(0,h),digits=1)
Click where you want to draw the bar
The final step (add.color.bar(...)) is the biggest hack of all as it only works because I artfully positioned it close enough to the x axis so that the bottom legend text is hidden!
Try it out!
Very useful, thank you Liam! A nice addition could be to change the color vector to reflect the official geologic timescale RGB codes (https://engineering.purdue.edu/Stratigraphy/charts/rgb.html).
ReplyDeleteLars. The best way to do this in phytools would be to combine make.era.map and phylomorphospace a mapped character. (Actually, this is also a better way to create the plot I just showed.) - Liam
DeleteAlso - Lars, do you happen to have the start & end points (say, in mybp) of each of the named geological time periods and the RGB code in a text or .csv file? I would be very interested in that. Thanks! Liam
DeleteHave been watching this with interest (although I don't know why I'm interested. So I can have a tree that goes from Darker Green to Less Dark Green? Stupid lower Paleozoic color choices... grumble...). Anyway, I don't have a csv, Liam, but you should be able to grab what you want from the table here pretty easily:
ReplyDeletehttps://en.wikipedia.org/wiki/Period_%28geology%29
Wiki's stuff is all based on the newest 2013 timescale.
David. I need name,start,end,color. Normally, I would assemble that myself - but it is grant writing time right now, so it'll have to wait until after Aug. 2. - Liam
DeleteI'm happy to help compiling the data (unless David has already done it?). Thanks for looking into this!
ReplyDeleteNo, I haven't compiled it. I forgot all about this, since I have also been busy working on a proposal, too.
ReplyDelete