Lineage through time(LTT plot)

597 views
Skip to first unread message

fateme moein

unread,
Jul 12, 2017, 9:05:58 AM7/12/17
to beast-users
Hello to All,

Sorry if this question is not exactly related to BEAST software, I have done ltt plot via ape and phytool, but I would like to change the x-axis to geo time classification.

I was wondering if anyone have an idea which R-script to use to add geo time.

Thanks

Fatemeh

Santiago Sánchez

unread,
Jul 12, 2017, 1:21:57 PM7/12/17
to beast...@googlegroups.com
Hi Fatemeh,

There is a package called "geoscale" which has a couple of plotting functions that add a geological scale. Personally, I find them of little use, however the package includes a data set of geological ages "data(timescales)" . You can use these to add a scale to your own plot. For instance, you could do something like:

library(geoscale)
library(phytools)

set.seed(1)

# generate LTT plot and tree data
tr <- pbtree(n=100) # simulate tree
tr$edge.length * 10 -> tr$edge.length # increase edge lengths
bt <- ltt.plot.coords(tr) # LTT plot data
bt.log <- cbind(time=bt[,"time"],N=log(bt[,"N"])) # convert to log

# prepare time scale data
data(timescales)
timescales$ICS2015 -> ts # select data set
ts[ ts$Type == "Epoch",] -> ts.epoch # get only data for epoch
which.min(abs(ts.epoch$End - abs(min(bt[,1])))) -> min.date # get the epoch with is closer to the root of the tree
# generate your vector data
start <- ts.epoch$Start[1:min.date]
end <- ts.epoch$End[1:min.date]
midpoint <- ts.epoch$Midpoint[1:min.date]
abbrev <- ts.epoch$Abbrev[1:min.date]
# remove the holocene (useless)
end <- end[-1]
start <- start[-1]
midpoint <- midpoint[-1]
abbrev <- abbrev[-1]
# make vectors negative
end <- -end
start <- -start
midpoint <- -midpoint
# generate a binary (1,0) vector to make a two-color vector
rep(c(1,0),length(start))[1:length(start)] -> col.fac

# plot with no data
plot(bt.log, xlim=c(min(start),0), ylim=c(0,max(bt.log[,"N"]+1)), type="n", ylab="lineages", xlab="time")
# add rectangles
rect(start, rep(0,length(start)), end, rep(log(max(bt[,"N"])),length(start)), col=c("grey","white")[factor(col.fac)], border=F)
# add LTT plot
lines(x=bt[,"time"], y=log(bt[,"N"]), type="b", col="red")
# add labels
text(x=midpoint, y=max(log(bt[,"N"]))+0.5, labels=abbrev, cex=0.5)

This code should generate a plot like the one attached.

Hope this helps.
Cheers,
Santiago


--
You received this message because you are subscribed to the Google Groups "beast-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to beast-users...@googlegroups.com.
To post to this group, send email to beast...@googlegroups.com.
Visit this group at https://groups.google.com/group/beast-users.
For more options, visit https://groups.google.com/d/optout.
--
==========================
Santiago Sanchez-Ramirez, PhD
Postdoctoral Associate
Ecology and Evolutionary Biology
University of Toronto
==========================
Rplot.pdf

Jinmin Chen

unread,
Nov 27, 2017, 12:45:55 PM11/27/17
to beast-users
Dear All,

For lineage-through-time (LTT) plot, how can we visualize the accumulation of lineages within different regions (see attached)?

Best wishes.

Chen
ltt.jpg

Santiago Sánchez

unread,
Nov 27, 2017, 7:55:24 PM11/27/17
to beast...@googlegroups.com
Hi Jinmin,

This is more a question for R users (e.g. r-sig-phylo) than for BEAST users, but here it goes..

First you need to do ancestral state reconstruction on your tree based on traits for your different regions. Then, you can extract which nodes were inferred with the highest probability for the different regions. Afterwards, simply retrieve the node ages of each of the different regions and then plot. This is rather straight forward to do in R, but will require some knowledge R coding and use of functions from the APE package.

Sorry for the short answer..

Good luck,
Santiago

--
You received this message because you are subscribed to the Google Groups "beast-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to beast-users...@googlegroups.com.
To post to this group, send email to beast...@googlegroups.com.
Visit this group at https://groups.google.com/group/beast-users.
For more options, visit https://groups.google.com/d/optout.
Reply all
Reply to author
Forward
0 new messages