ggtree for microbiome data

ggtree can parse many software outputs and the evolution evidences inferred by these software can be used directly for tree annotation. ggtree not only works as an infrastructure that enables evolutionary data that inferred by commonly used software packages to be used in R, but also serves as a general tree visualization and annotation tool for the R community as it supports many S3/S4 objects defined by other R packages.

phyloseq for microbiome data

phyloseq class defined in the phyloseq package was designed for microbiome data. phyloseq package implemented plot_tree function using ggplot2. Although the function was implemented by ggplot2 and we can use theme, scale_color_manual etc for customization, the most valuable part of ggplot2, adding layer, is missing. plot_tree only provides limited parameters to control the output graph and it is hard to add layer unless user has expertise in both phyloseq and ggplot2.

ggtree paper published

Today ggtree received 100 stars on and I found the paper was online at the same day by the tweet:

identify method for ggtree

We are happy to announce that ggtree supports interactive tree annotation/manipulation by implementing an identify method. Users can click on a node to highlight a clade, to label or rotate it etc.

Here is an example of highlighting clades using geom_hilight with identify:

[Bioc 33] NEWS of my BioC packages

Today is my birthday and it happened to be the release day of Bioconductor 3.3. It’s again the time to reflect what I’ve done in the past year.

embed images in ggplot2 via subview and annotate a phylogenetic tree with images using inset function

I extended the subview function to support embed image file in a ggplot object.

d = data.frame(x=rnorm(10), y=rnorm(10))

imgfile <- tempfile(, fileext=".png")
              destfile=imgfile, mode='wb')

p = ggplot(d, aes(x, y))
subview(p, imgfile, x=d$x[1], y=d$y[1]) + geom_point(size=5)

tweets of ggtree

ggtree supports phylip tree format

Phylip is also a widely used tree format, which contains taxa sequences with Newick tree text.

In ggtree, we can use read.phylip() function to parse the file and use ggtree() to visualize the tree.

label edge number in ggtree

This is a question from ggtree user. In ape and phytools, it’s easy to label edge using the edgelabels function.

tr = rtree(30)
plot(tr, main="ape")

Annotate a phylogenetic tree with insets

ggtree implemented a function, subview, that can add subplots on a ggplot2 object. It had successful applied to plot pie graphs on map.

tr <- rtree(30)
tr <- groupClade(tr, node=45)
p <- ggtree(tr, aes(color=group)) + geom_tippoint()
cpos <- get_clade_position(p, node=45)
p1 <- p + geom_hilight(node=45)
p2 <- with(cpos, p+xlim(xmin, xmax*1.01)+ylim(ymin, ymax))
with(cpos, subview(p2+geom_tiplab(), p1+theme_transparent(), x=xmin+(xmax-xmin)*.15, y=ymin+(ymax-ymin)*.85))

News of ggtree

A new version of ggtree that works with ggplot2 (version >= 2.0.0) is now availabel.

new layers

Some functions, add_legend, hilight, annotation_clade and annotation_clade2 were removed. Instead we provide layer functions, geom_treescale, geom_hilight and geom_cladelabel. You can use + operator to add layers using these layer functions.

In addtion, we provide geom_point2, geom_text2 and geom_segment2 which works exactly as geom_point, geom_text and geom_segment except they allow ggtree users to do subsetting.