Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.
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.
1 2 3 | library(ggplot2) library(ggtree) ggtree(rtree(15)) %<% rtree(30) |
It supports different layout.
1 | ggtree(rtree(15), layout="unrooted", ladderize=FALSE) %<% rtree(45) |
It is chainable.
1 2 3 | ggtree(rtree(15), layout="cladogram", ladderize=FALSE) %<% rtree(30) %<% rtree(45) |
It also supports multiple layers.
1 2 3 | (ggtree(rtree(15), layout="fan") + geom_point(aes(shape=isTip, color=isTip))) %<% rtree(40) |
In the final example, we parse rst file from BaseML output and annotate the tree with marginal_AA_subs.
1 2 3 4 5 6 | rstfile <- system.file("extdata/PAML_Baseml", "rst", package="ggtree") tipfas <- system.file("extdata", "pa.fas", package="ggtree") rst <- read.paml_rst(rstfile, tipfas) p <- plot(rst, annotation="marginal_AA_subs", annotation.color="steelblue") print(p) |
We have ancestral sequences inferred from CodeML with the same tree. We can use this new data to update the tree view.
1 2 3 | rstfile <- system.file("extdata/PAML_Codeml", "rst", package="ggtree") rst <- read.paml_rst(rstfile, tipfas) p %<% rst |
In these two figures, we can found that they have different evolution distances, and substitutions inferred from BASEML and CODEML are slightly different.
PS: wanna to generate a lovely heart using ggplot2, click here and here.
Related Posts
R-bloggers.com offers daily e-mail updates about R news and tutorials about learning R and many other topics. Click here if you're looking to post or find an R/data-science job.
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.