{"id":367,"date":"2016-08-09T12:33:36","date_gmt":"2016-08-09T10:33:36","guid":{"rendered":"https:\/\/blogs.fu-berlin.de\/gruenstaeudl\/?p=367"},"modified":"2016-08-09T12:41:48","modified_gmt":"2016-08-09T10:41:48","slug":"loading-beast-node-statistics-in-r","status":"publish","type":"post","link":"https:\/\/blogs.fu-berlin.de\/gruenstaeudl\/2016\/08\/09\/loading-beast-node-statistics-in-r\/","title":{"rendered":"Loading BEAST node statistics in R"},"content":{"rendered":"<p><strong>The issue with hardcoding data formats<\/strong><\/p>\n<p>Various phylogenetic analyses in <em>R<\/em> work on the ultrametric trees generated by the popular software <em>BEAST<\/em>. In order to load such trees (including their node metadata) into R, the R packages <a href=\"https:\/\/www.christophheibl.de\/Rpackages.html\" target=\"_blank\"><em>phyloch<\/em><\/a> and, more recently, <a href=\"https:\/\/cran.r-project.org\/web\/packages\/ips\/index.html\" target=\"_blank\"><em>ips<\/em><\/a> provide useful tree and data parsers. Specifically, the parsing of the input trees is conducted with function <em>read.beast()<\/em>, which reads NEXUS files as saved by the BEAST components (e.g., <em>TreeAnnotator<\/em>) or related software.<\/p>\n<p>Recently, I realized that node metadata can only be loaded with the above-mentioned R function if the tree name in the NEXUS tree definition line starts with &#8220;<em>TREE1&#8243;<\/em>. This specification is hard-coded in the dependent function <em>extractBEASTstats()<\/em>, which parses the node metadata from each tree.<\/p>\n<p>See lines 2 and 3 of function extractBEASTstats():<\/p>\n<div style=\"background-color: #ffebdb\">\n<p style=\"padding-left: 30px\"><code>X &lt;- X[grep(\"tree TREE1[[:space:]]+=\", X)]<br \/>\nX &lt;- gsub(\"tree TREE1[[:space:]]+= \\\\[&amp;R\\\\] \", \"\", X)<br \/>\n<\/code><\/p>\n<\/div>\n<p>I am not certain if there is a convention that all tree names in BEAST-generated NEXUS files must start with the string &#8220;<em>TREE1&#8243;<\/em>. However, future data parsers for BEAST should probably avoid this specific condition, as successful parsing should not depend on a specific tree name.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>The issue with hardcoding data formats Various phylogenetic analyses in R work on the ultrametric trees generated by the popular software BEAST. In order to load such trees (including their node metadata) into R, the R packages phyloch and, more recently, ips provide useful tree and data parsers. Specifically, the parsing of the input trees [&hellip;]<\/p>\n","protected":false},"author":2306,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[57598],"tags":[],"class_list":["post-367","post","type-post","status-publish","format-standard","hentry","category-bioinformatics"],"_links":{"self":[{"href":"https:\/\/blogs.fu-berlin.de\/gruenstaeudl\/wp-json\/wp\/v2\/posts\/367","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blogs.fu-berlin.de\/gruenstaeudl\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blogs.fu-berlin.de\/gruenstaeudl\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blogs.fu-berlin.de\/gruenstaeudl\/wp-json\/wp\/v2\/users\/2306"}],"replies":[{"embeddable":true,"href":"https:\/\/blogs.fu-berlin.de\/gruenstaeudl\/wp-json\/wp\/v2\/comments?post=367"}],"version-history":[{"count":7,"href":"https:\/\/blogs.fu-berlin.de\/gruenstaeudl\/wp-json\/wp\/v2\/posts\/367\/revisions"}],"predecessor-version":[{"id":374,"href":"https:\/\/blogs.fu-berlin.de\/gruenstaeudl\/wp-json\/wp\/v2\/posts\/367\/revisions\/374"}],"wp:attachment":[{"href":"https:\/\/blogs.fu-berlin.de\/gruenstaeudl\/wp-json\/wp\/v2\/media?parent=367"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blogs.fu-berlin.de\/gruenstaeudl\/wp-json\/wp\/v2\/categories?post=367"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blogs.fu-berlin.de\/gruenstaeudl\/wp-json\/wp\/v2\/tags?post=367"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}