I just discovered an interesting
geofacet, that supports arranging facet panels that mimics geographic topoloty.
After playing with it, I realized that it is not only for visualizing
geo-related data, but also can be fun for presenting data to mimics pixel art.
With ggtree (Yu et al. 2017), it is very easy to create phylomoji. Emoji is internally supported by ggtree.
library(ggtree) tree_text <- "(((((cow, (whale, dolphin)), (pig2, boar)), camel), fish), seedling);" x <- read.tree(text=tree_text) ggtree(x, linetype="dashed", color='firebrick') + xlim(NA, 7) + ylim(NA, 8.5) + geom_tiplab(aes(color=label), parse='emoji', size=14, vjust=0.25) + labs(title="phylomoji", caption="powered by ggtree + emojifont")
I have splitted
ggtree to 2 packages,
ggtree is mainly focus on visualization and annotation, while
treeio focus on parsing and exporting tree files. Here is a welcome message from
treeio that you can convert
ggtree output to tree object which can be exported as newick or nexus file if you want.
ggplot2, output of
ggtree is actually a
ggplot object. The
ggtree object can be rendered as graph by
as.treedata to convert
ggtree object to
For GSEA analysis, we are familar with the above figure which shows the running enrichment score. But for most of the software, it lack of visualization method to summarize the whole enrichment result.
This is a question from ggtree google group:
Dear ggtree team,
how can I apply a geom_xxx to only one facet panel? For example if i want to get
geom_text()in the dot panel? I cant see the
facet_grid(. ~ var)function call, so I don’t know which subsetting to use. I have already read http://stackoverflow.com/questions/29873155/geom-text-and-facets-not-working
tr <- rtree(30) d1 <- data.frame(id=tr$tip.label, val=rnorm(30, sd=3)) p <- ggtree(tr) p2 <- facet_plot(p, panel="dot", data=d1, geom=geom_point, aes(x=val), color='firebrick') d2 <- data.frame(id=tr$tip.label, value = abs(rnorm(30, mean=100, sd=50))) p3 <- facet_plot(p2, panel='bar', data=d2, geom=geom_segment, aes(x=0, xend=value, y=y, yend=y), size=3, color='steelblue') + theme_tree2()
If this can be done, we can create even more comprehensive tree plots.
Here are the outputs produced by
Coloring edges in ggtree is quite easy, as we can map the color to numerical or categorical values via the
aes(color=VAR) syntax. For user’s own data, it is also easy as
ggtree provide the
%<+% operator to attach user data.
Plotting pies on ggplot/ggmap is not an easy task, as ggplot2 doesn’t provide native pie geom. The pie we produced in ggplot2 is actually a barplot transform to polar coordination. This make it difficult if we want to produce a map like the above screenshot, which was posted by Tyler Rinker, the author of R package pacman.
A question on biostars asking how to generate the following figure:
This can be quite easy to implement in ggtree, I can write a
geom layer to layout the alignment. As ggbio already provides many
geom for genomic data and I don’t want to re-invent the wheel, I decided to try
ggtree+ggbio. This is also the beauty of
R that packages complete each others.