Coerce phylogenetic trees to phyloXML documents, objects of class xml_document.

write_phyloxml(tree, ...)

# S3 method for phylo
write_phyloxml(tree, name = "A phylogenetic tree",
  description = "Some description", xmlns = "http://www.phyloxml.org",
  digits = 20, ...)

Arguments

tree

A phylogenetic tree.

...

Further arguments to be passed to the method (see details).

name

Character scalar. Name of the tree.

description

Character scalar. Description of the tree.

xmlns

Character scalar. Location of the default namespace (see the XML Namespaces section in w3schools).

digits

Integer scalar. Precision to use when writing numbers.

Value

An XML document (see xml2::read_xml)

Details

So far, this function has a method for phylo objects from the ape package. The following elements are supported:

  • Branch lengths as stored in edge.length

  • Labels, which are exported as name, as stored in tip.label and, if available, Node.label.

  • Tree topology as stored in edges

References

Han M.V. and Zmasek C.M. (2009) "phyloXML: XML for evolutionary biology and comparative genomics" BMC Bioinformatics, 10:356 doi:10.1186/1471-2105-10-356

See also

validate_phyloxml

Examples

# Random tree from the ape package ------------------------------------------ set.seed(1) x <- ape::rtree(5) x
#> #> Phylogenetic tree with 5 tips and 4 internal nodes. #> #> Tip labels: #> [1] "t3" "t4" "t1" "t2" "t5" #> #> Rooted; includes branch lengths.
write_phyloxml(x)
#> {xml_document} #> <phyloxml schemaLocation="http://www.phyloxml.org http://www.phyloxml.org/1.10/phyloxml.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://www.phyloxml.org"> #> [1] <phylogeny rooted="true">\n <name>A phylogenetic tree</name>\n <descrip ...