Travis build status Build status Coverage status

knitr::opts_chunk$set(
  collapse = TRUE,
  comment = "#>",
  fig.path = "man/figures/README-",
  out.width = "100%"
)

rphyloxml

rphyloxml provides access to the phyloXML file format. For now, the only functions that are implemented in the package are:

This package has been motivated to be used with the javascript library jsPhyloSVG, for which we are currently developing an R package with the same name that provides an htmlwidget here.

Installation

You can install rphyloxml from github with:

# install.packages("devtools")
devtools::install_github("USCBiostats/rphyloxml")

Writing phyloXML files

In the following example, we create a random tree using the rtree function from the ape package, and later on coerce it into a phyloXML document using write_phyloxml.

library(ape)
library(rphyloxml)
set.seed(12)

x <- rtree(3)
x
z <- write_phyloxml(x)
z

You can get a "nicer" view of it by doing the following:

cat(as.character(z))

And to store the document, you just need to use xml2 (which is what powers the package) as follows:

xml2::write_xml(z, "mynicetree.xml")

Reading XML files

We will read the file amphibian_tree_of_life_Frost_DR_2006.xml available in both the package and the phyloxml website.

# Reading from the package files
fn <- system.file("phyloxml/amphibian_tree_of_life_Frost_DR_2006.xml", package="rphyloxml")
xmltree <- read_phyloxml(fn)

str(xmltree, 4)
# We can coerce this into a mulitphylo list
(apetree <- phyloxml2phylo(xmltree))[[1]]
plot(apetree, cex=.25)


USCbiostats/rphyloxml documentation built on Nov. 2, 2020, 11:38 a.m.