This page describes functions for visualizing trees in ape. The code is HERE. Examples are given at the bottom of this page.
There is no help page at the moment: information are given below, and all feedback is welcome.
treevizPDF(x, ..., height = NULL, width = 10, new = FALSE)
- x: a tree (of class "phylo")
- ...: arguments passed to plot.phylo
- height: the height in inches of the PDF file, calculated by default so labels do not overlap
- width: the width in inches of the PDF file
- new: whether to open a new PDF viewer
Because R's graphical window is not scrollable, plotting a large tree results in unreadable tip labels because they overlap too much (or are too small if you play with 'cex'). This function opens a PDF viewer (typically Acrobat Reader) with the tree plotted in a fully scrollable window.
The 'dot-dot-dot' argument comes second so that you can use this function as you'd do with plot.phylo (eg, treevizPDF(tr, "c", FALSE)). The usual arguments of plot.phylo can be used (except 'y.lim' which is used internally).
I found that it works pretty well: the limitation seems to be the PDF viewer. With Acrobat Reader, the paper size seems limited to 200 inches, so this works fine with up to about 1050 tips. With evince (Gnome PDF viewer) this is OK up to 3000 tips.
treevizGL(x, edge.color = "orange", tip.color = "black")
- x: a tree (of class "phylo")
- edge.color: color used for the edges
- tip.color: color used for the tip labels
This function has pretty much the same goal than the previous one, but using the 'rgl' package. The functionality is reduced: only a fully triangular cladogram can be plotted and colouring is the same for all edges or tip labels. The only limitation is with the time needed to calculate all the coordinates. It takes a few seconds to plot a tree with 100,000 tips, though its manipulation with the mouse is quite slowed-down. This is very experimental.
Examples:
source("treeviz.R")
## or: source("https://emmanuelparadis.github.io/treeviz/treeviz.R")
tr <- rtree(1e3)
treevizPDF(tr)
treevizGL(tr)
tr <- rtree(1e4)
treevizGL(tr)