<p><div><div><div><div data-width="100" data-show-faces="false" data-send="true" data-layout="button_count" data-height="21" data-href="https://www.r-bloggers.com/phylomoji-with-ggtree-and-emojifont/"></div></div><div></div></div><div></div></div>
<div>
(This article was first published on <strong><a href="https://guangchuangyu.github.io/2017/05/phylomoji-with-ggtree-and-emojifont"> R on Guangchuang YU</a></strong>, and kindly contributed to <a rel="nofollow" href="https://www.r-bloggers.com/">R-bloggers)</a> </div>
<p>With ggtree (Yu et al. 2017), it is very easy to create phylomoji. Emoji is internally supported by ggtree.</p>
<h2>Use emoji in taxa labels</h2>
<pre><code>library(ggtree)
tree_text &lt;- &quot;(((((cow, (whale, dolphin)), (pig2, boar)), camel), fish), seedling);&quot;
x &lt;- read.tree(text=tree_text)
ggtree(x, linetype=&quot;dashed&quot;, color='firebrick') +
    xlim(NA, 7) + ylim(NA, 8.5) +
    geom_tiplab(aes(color=label), parse='emoji', size=14, vjust=0.25) +
    labs(title=&quot;phylomoji&quot;, caption=&quot;powered by ggtree + emojifont&quot;)
</code></pre>
<p><img alt="" src="https://i2.wp.com/guangchuangyu.github.io/blog_images/R/emojifont/phylomoji_files/figure-markdown_github/unnamed-chunk-2-1.png?w=456&ssl=1" data-recalc-dims="1"></p>
<pre><code>p &lt;- ggtree(x, layout='circular') +
    geom_tiplab2(aes(color=label), parse='emoji', size=12, vjust=0.25)
print(p)
</code></pre>
<p><img alt="" src="https://i0.wp.com/guangchuangyu.github.io/blog_images/R/emojifont/phylomoji_files/figure-markdown_github/unnamed-chunk-3-1.png?w=456&ssl=1" data-recalc-dims="1"></p>
<pre><code>open_tree(p, angle=200)
</code></pre>
<p><img alt="" src="https://i1.wp.com/guangchuangyu.github.io/blog_images/R/emojifont/phylomoji_files/figure-markdown_github/unnamed-chunk-4-1.png?w=456&ssl=1" data-recalc-dims="1"></p>
<pre><code>open_tree(p, angle=60) %>% rotate_tree(-75)
</code></pre>
<p><img alt="" src="https://i0.wp.com/guangchuangyu.github.io/blog_images/R/emojifont/phylomoji_files/figure-markdown_github/unnamed-chunk-4-2.png?w=456&ssl=1" data-recalc-dims="1"></p>
<h2>Labeling clades using emoji</h2>
<pre><code>set.seed(123)
tr &lt;- rtree(30)
ggtree(tr) + xlim(NA, 5) +
    geom_cladelabel(node=41, label=&quot;chicken&quot;, parse=&quot;emoji&quot;,
                    fontsize=12, align=TRUE, color=&quot;firebrick&quot;) +
    geom_cladelabel(node=51, label=&quot;duck&quot;, parse=&quot;emoji&quot;,
                    fontsize=12, align=TRUE, color=&quot;steelblue&quot;) +
    geom_cladelabel(node=32, label=&quot;family&quot;, parse=&quot;emoji&quot;,
                    fontsize=12, align=TRUE, color=&quot;darkkhaki&quot;)
</code></pre>
<p><img alt="" src="https://i1.wp.com/guangchuangyu.github.io/blog_images/R/emojifont/phylomoji_files/figure-markdown_github/unnamed-chunk-5-1.png?w=456&ssl=1" data-recalc-dims="1"></p>
<h2>Apple Color Emoji</h2>
<p>Although <code>R</code>’s graphical devices don’t support <code>AppleColorEmoji</code> font, it’s still possible to use it. We can export the <code>plot</code> to <code>svg</code> file and render it in <code>Safari</code>.</p>
<pre><code>library(ggimage)
library(gridSVG)
p &lt;-  ggtree(x, size=2) + geom_tiplab(size=20, parse='emoji') +
    xlim(NA, 7) + ylim(NA, 8.5) +
    geom_phylopic(image=&quot;79ad5f09-cf21-4c89-8e7d-0c82a00ce728&quot;,
                  color=&quot;firebrick&quot;, alpha = .3, size=Inf)

p
ps = grid.export(&quot;emoji.svg&quot;, addClass=T)
</code></pre>
<p><img alt="" src="https://i1.wp.com/guangchuangyu.github.io/blog_images/R/emojifont/apple_emoji2.png?w=456&ssl=1" data-recalc-dims="1"></p>
<h2>Further reading</h2>
<p>Please visit ggtree homepage, <a target="_blank" rel="nofollow" href="https://guangchuangyu.github.io/ggtree">https://guangchuangyu.github.io/ggtree</a>, to find out more.</p>
<h1>References</h1>
<p>Yu, Guangchuang, David Smith, Huachen Zhu, Yi Guan, and Tommy Tsan-Yuk Lam. 2017. “Ggtree: An R Package for Visualization and Annotation of Phylogenetic Trees with Their Covariates and Other Associated Data.” <em>Methods in Ecology and Evolution</em> 8 (1): 28–36. doi:<a target="_blank" rel="nofollow" href="https://doi.org/10.1111/2041-210X.12628">10.<sup>1111</sup>⁄<sub>2041</sub>-210X.12628</a>.</p>
<p></p>
<div data-badge-popover="right" data-doi="10.1111/2041-210X.12628" data-badge-type="donut"></div>
<p>
<div>
<div>To <strong>leave a comment</strong> for the author, please follow the link and comment on their blog: <strong><a href="https://guangchuangyu.github.io/2017/05/phylomoji-with-ggtree-and-emojifont"> R on Guangchuang YU</a></strong>.</div>
<hr>
<a rel="nofollow" href="https://www.r-bloggers.com/">R-bloggers.com</a> offers <strong><a rel="nofollow" href="https://feedburner.google.com/fb/a/mailverify?uri=RBloggers">daily e-mail updates</a></strong> about <a title="The R Project for Statistical Computing" rel="nofollow" href="https://www.r-project.org/">R</a> news and <a title="R tutorials" rel="nofollow" href="https://www.r-bloggers.com/search/tutorial">tutorials</a> on topics such as: <a title="Data science" rel="nofollow" href="https://www.r-bloggers.com/search/data%20science">Data science</a>, <a title="Big Data" rel="nofollow" href="https://www.r-bloggers.com/search/Big%20Data">Big Data, <a title="R jobs" rel="nofollow" href="https://www.r-users.com/">R jobs</a>, visualization (<a title="ggplot and ggplot2 tutorials" rel="nofollow" href="https://www.r-bloggers.com/search/ggplot2">ggplot2</a>, <a title="Boxplots using lattice and ggplot2 tutorials" rel="nofollow" href="https://www.r-bloggers.com/search/boxplot">Boxplots</a>, <a title="Maps and gis" rel="nofollow" href="https://www.r-bloggers.com/search/map">maps</a>, <a title="Animation in R" rel="nofollow" href="https://www.r-bloggers.com/search/animation">animation</a>), programming (<a title="RStudio IDE for R" rel="nofollow" href="https://www.r-bloggers.com/search/RStudio">RStudio</a>, <a title="Sweave and literate programming" rel="nofollow" href="https://www.r-bloggers.com/search/sweave">Sweave</a>, <a title="LaTeX in R" rel="nofollow" href="https://www.r-bloggers.com/search/LaTeX">LaTeX</a>, <a title="SQL and databases" rel="nofollow" href="https://www.r-bloggers.com/search/SQL">SQL</a>, <a title="Eclipse IDE for R" rel="nofollow" href="https://www.r-bloggers.com/search/eclipse">Eclipse</a>, <a title="git and github, Version Control System" rel="nofollow" href="https://www.r-bloggers.com/search/git">git</a>, <a title="Large data in R using Hadoop" rel="nofollow" href="https://www.r-bloggers.com/search/hadoop">hadoop</a>, <a title="Web Scraping of google, facebook, yahoo, twitter and more using R" rel="nofollow" href="https://www.r-bloggers.com/search/Web+Scraping">Web Scraping</a>) statistics (<a title="Regressions and ANOVA analysis tutorials" rel="nofollow" href="https://www.r-bloggers.com/search/regression">regression</a>, <a title="principal component analysis tutorial" rel="nofollow" href="https://www.r-bloggers.com/search/PCA">PCA</a>, <a title="Time series" rel="nofollow" href="https://www.r-bloggers.com/search/time+series">time series</a>, <a title="finance trading" rel="nofollow" href="https://www.r-bloggers.com/search/trading">trading</a>) and more...
<img height="1" alt="" width="1" src="http://feeds.feedburner.com/~r/RBloggers/~4/4TBc4fey5zw"></a></div>