comic phylogenetic tree with ggtree and comicR

[This article was first published on YGC » R, and kindly contributed to R-bloggers]. (You can report issue about the content on this page here)
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.

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 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.

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)