comic phylogenetic tree with ggtree and comicR

September 7, 2015
By

(This article was first published on YGC » R, and kindly contributed to R-bloggers)

ggtree applies the concepts of grammar of graphic in phylogenetic tree presentation and make it easy to add multiple layers of text and even figures above a 🌲.

Here, I cartoonize a phylogenetic tree generated by ggtree with comicR, which is a funny package to generate comic (xkcd-like) graph in R. Have fun with ggtree and comicR.

?View Code RSPLUS
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
library(htmltools)
library(XML)
library(gridSVG)
library(comicR)
 
library(ggplot2)
library(ggtree)
 
p <- ggtree(rtree(30), layout="fan")  + 
   geom_text(aes(label=label, angle=angle), size=5, color="purple", vjust=-0.3)
 
 
p
svg <- grid.export(name="")$svg
tagList(
      tags$div(
        id = "ggtree_comic",
        tags$style("#ggtree_comic text {font-family:Chalkduster;}"),
        HTML(saveXML(svg)),
        comicR("#ggtree_comic", ff=5)
      )
    ) %>% html_print

Related Posts

To leave a comment for the author, please follow the link and comment on their blog: YGC » R.

R-bloggers.com offers daily e-mail updates about R news and tutorials on topics such as: Data science, Big Data, R jobs, visualization (ggplot2, Boxplots, maps, animation), programming (RStudio, Sweave, LaTeX, SQL, Eclipse, git, hadoop, Web Scraping) statistics (regression, PCA, time series, trading) and more...



If you got this far, why not subscribe for updates from the site? Choose your flavor: e-mail, twitter, RSS, or facebook...

Comments are closed.

Sponsors

Never miss an update!
Subscribe to R-bloggers to receive
e-mails with the latest R posts.
(You will not see this message again.)

Click here to close (This popup will not appear again)