flip function is a feature request from ggtree user. It accepts a tree view and two node numbers and exchange the positions of the selected clades.

require(ggtree)
set.seed(2015-07-01)
tr <- rtree(30)
p <- ggtree(tr) + geom_text(aes(label=node))
gridExtra::grid.arrange(p, flip(p, 38, 33), ncol=2)

Continue reading

ggtree with funny fonts

showtext is a neat solution to use various types of fonts in R graphs and make it easy to use funny fonts. With showtext, we can draw phylogenetic tree with different types of fonts even with symbolic/icon fonts.

require(showtext)

font.add.google("Gochi Hand", "gochi")
font.add.google("Rock Salt", "rock")

link = "http://img.dafont.com/dl/?f=wm_people_1";
download.file(link, "wmpeople1.zip", mode = "wb");
unzip("wmpeople1.zip");
font.add("wmpeople1", "wmpeople1.TTF");

link = "http://img.dafont.com/dl/?f=emoticons";
download.file(link, "emoticons.zip", mode = "wb");
unzip("emoticons.zip");
font.add("emoticons", "emoticons.ttf");


showtext.auto()
set.seed(2015-05-14)

library(ggplot2)
library(ggtree)

tree <- rtree(30)
ggtree(tree, color="darkgreen") + geom_tiplab(family="gochi") + theme_classic() +
theme(axis.text.x=element_text(size=rel(4), family="emoticons", color="firebrick")) +
scale_y_continuous(breaks=seq(0, 30, 4), labels=letters[c(12:17, 20, 21)]) +
theme(axis.text.y=element_text(size=rel(4), family="wmpeople1", color="#FDAC4F")) +
annotate("text", x=2, y=18, label="Have fun with ggtree!",
family="rock", angle=30, size=12, color="steelblue")

Continue reading

ggtree - updating a tree view

I am very exciting that I have received very positive feedback from Ahmed Moustafa and Simon Frost.

ggtree now has equipped with a lot of new features. This time, I would like to introduce the replace operator, %<%. Suppose we have build a tree view using ggtree with multiple layers, we don’t need to run the code again to build a new tree view with another tree. In ggtree, we provides an operator, %<%, for updating tree view.

Continue reading

ggtree in Bioconductor 3.1

I am very glad that ggtree is now available via Bioconductor. This is my 6th Bioconductor package. ggtree now supports parsing output files from BEAST, PAML, HYPHY, EPA and PPLACER and can annotate phylogenetic tree directly using plot methods.

Continue reading

When I need to annotate nucleotide substitutions in the phylogenetic tree, I found that all the software are designed to display the tree but not annotating it. Some of them may support annotating the tree with specific data such as bootstrap values, but they are restricted to a few supported data types. It is hard/impossible to inject user specific data.

Continue reading

Author's picture

Guangchuang Yu

Bioinformatics Professor @ SMU

Bioinformatics Professor

Guangzhou