<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Xsmas | Miao Sun | 孙苗</title><link>https://cactusolo.github.io/tag/xsmas/</link><atom:link href="https://cactusolo.github.io/tag/xsmas/index.xml" rel="self" type="application/rss+xml"/><description>Xsmas</description><generator>Wowchemy (https://wowchemy.com)</generator><language>en-us</language><copyright>© {2018-2026} Miao Sun</copyright><lastBuildDate>Mon, 17 Dec 2018 00:00:00 +0000</lastBuildDate><image><url>https://cactusolo.github.io/media/icon_huedaf1db70dd9a5ae8fb7d95bfd1a4abe_1318_512x512_fill_lanczos_center_3.png</url><title>Xsmas</title><link>https://cactusolo.github.io/tag/xsmas/</link></image><item><title>Plotting Christmas Tree</title><link>https://cactusolo.github.io/post/christmas_tree/</link><pubDate>Mon, 17 Dec 2018 00:00:00 +0000</pubDate><guid>https://cactusolo.github.io/post/christmas_tree/</guid><description>&lt;p>I saw a figure of all potential Christmas tree 🎄 at 🐦 &lt;a href="https://twitter.com/Polypompholyx/status/1074351911581728770?s=05" target="_blank" rel="noopener">Polypompholyx’s Tweet&lt;/a>.&lt;/p>
&lt;p>It looks strange for my first impression. So I did a quick check from &lt;a href="https://tree.opentreeoflife.org/opentree/argus/opentree10.4@ott93302" target="_blank" rel="noopener">Open Tree&lt;/a>. This looks much better!&lt;/p>
&lt;p>See code below:&lt;/p>
&lt;pre>&lt;code class="language-{r">rm(list=ls())
# install.packages(&amp;quot;rotl&amp;quot;)
# install.packages(&amp;quot;ape&amp;quot;)
#loading libraries
library(&amp;quot;rotl&amp;quot;) #for querying open tree database
library(&amp;quot;ape&amp;quot;) #for tree manipulation
#First I preapred a table for those potential **Christmas Trees** with first column is common names,a nd second column is the scientific names
# then we read in the table as a query list to the Open Tree
query &amp;lt;- read.csv(&amp;quot;XsmasTree.csv&amp;quot;, header=TRUE, sep=&amp;quot;,&amp;quot;, stringsAsFactors=FALSE, quote=&amp;quot;&amp;quot;)
# check what our table look like this
head(query)
# query names and get ottid
species &amp;lt;- tnrs_match_names(names = query$Scientific_name_rept.)
# check results
head(species)
# fix fuzzy match on row 16, then updated it
new_species&amp;lt;- update(species, row_number=16, new_ott_id = 248313)
# checking object
head(new_species)
species &amp;lt;- new_species
species.ottid &amp;lt;- ott_id(species)
# extracting the phylogeny summarized in the Open tree
tree &amp;lt;- tol_induced_subtree(ott_ids=species$ott_id, label_format = &amp;quot;name&amp;quot;)
# make it looks good
tree &amp;lt;- ladderize(tree)
plot.phylo(tree, cex=0.8)
# rename the tree tip labels
query[[2]][16] &amp;lt;- &amp;quot;Picea pungens&amp;quot; #remove one extra space
query[[2]] &amp;lt;- gsub(pattern=&amp;quot;\\s&amp;quot;, &amp;quot;_&amp;quot;, query[[2]])
new_label &amp;lt;- paste0(tree$tip.label,&amp;quot;(&amp;quot;, query[[1]][match(tree$tip.label, query[[2]])], &amp;quot;)&amp;quot;)
new_tree &amp;lt;- tree
new_tree$tip.label &amp;lt;- new_label
#png(&amp;quot;The Tree of Christams Tree.png&amp;quot;)
#plot(new_tree, cex=0.7)
#dev.off()
#write.tree(new_tree, &amp;quot;renamed_Xsmas_tree.tre&amp;quot;)
#plot a prettier tree
plot.phylo(new_tree, edge.color = &amp;quot;dark green&amp;quot;, edge.width = 2, tip.color = &amp;quot;red&amp;quot;,
label.offset = 0.5, main=&amp;quot;The Tree of Christmas Tree&amp;quot;, col.main=&amp;quot;red&amp;quot;)
mtext(&amp;quot;---source from Open Tree&amp;quot;, col=&amp;quot;dark green&amp;quot;, 3)
&lt;/code>&lt;/pre>
&lt;p>
&lt;figure id="figure-tree-of-xsmas-trees">
&lt;div class="d-flex justify-content-center">
&lt;div class="w-100" >&lt;img alt="Tree of Xsmas Trees" srcset="
/post/christmas_tree/Rplot02_hu02779b9926964c9250097458591aa486_83480_93923b561ccfa9c0f48976415955c100.png 400w,
/post/christmas_tree/Rplot02_hu02779b9926964c9250097458591aa486_83480_74f59a8b12e6cebfe68cadddb82a7773.png 760w,
/post/christmas_tree/Rplot02_hu02779b9926964c9250097458591aa486_83480_1200x1200_fit_lanczos_3.png 1200w"
src="https://cactusolo.github.io/post/christmas_tree/Rplot02_hu02779b9926964c9250097458591aa486_83480_93923b561ccfa9c0f48976415955c100.png"
width="414"
height="456"
loading="lazy" data-zoomable />&lt;/div>
&lt;/div>&lt;figcaption>
Tree of Xsmas Trees
&lt;/figcaption>&lt;/figure>
❄️ 🎅 🌵 🔔 ☃️ 🌲&lt;/p></description></item></channel></rss>