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.

Continue reading

use emoji font in R

![](http://guangchuangyu.github.io/blog_images/2015/Screenshot 2015-12-16 10.55.49.png)

I have played with emoji in R for a while. My solution of using it is different from what implemented in emoGG.

emoGG is a good attemp to add emoji in ggplot2. It render emoji picture (png) and creat a layer, geom_emoji, to add emoji.

In my opinion, emoji should be treated as ordinary font in user interface, albeit it maynot be true internally.

It would be more flexible if we can use emoji as ordinary font and in this way user don’t need to learn extra stuff.

Continue reading

subsetting data in ggtree

Subsetting is commonly used in ggtree as we would like to for example separating internal nodes from tips. We may also want to display annotation to specific node(s)/tip(s).

Some software may stored clade information (e.g. bootstrap value) as internal node labels. Indeed we want to manipulate such information and taxa labels separately.

In current ggplot2 (version=1.0.1, access date:2015-09-23), it support subset. For instance:

Continue reading

subview

I implemented a function, subview, in ggtree that make it easy to embed a subplot in ggplot.

An example is shown below:

library(ggplot2)
library(ggtree)

dd <- data.frame(x=LETTERS[1:3], y=1:3)
pie <- ggplot(dd, aes(x=1, y, fill=x)) + 
	geom_bar(stat="identity", width=1) + 
	coord_polar(theta="y") + theme_tree() + 
	xlab(NULL) + ylab(NULL) + 
	theme_transparent()

x <- sample(2:9)
y <- sample(2:9)
width <- sample(seq(0.05, 0.15, length.out=length(x)))
height <- width

p <- ggplot(data=data.frame(x=c(0, 10), y=c(0, 10)), aes(x, y))+geom_blank()
print(p)
for (i in seq_along(x)) {
	p %<>% subview(pie, x[i], y[i], width[i], height[i])
	print(p)
}

Continue reading

Author's picture

Guangchuang Yu

Bioinformatics Professor @ SMU

Bioinformatics Professor

Guangzhou