Learn R Programming

phylobase (version 0.6.8)

as: Converting between phylo4/phylo4d and other phylogenetic tree formats

Description

Translation functions to convert between phylobase objects (phylo4 or phylo4d), and objects used by other comparative methods packages in R: ape objects (phylo, multiPhylo), ade4 objects (phylog, now deprecated), and to data.frame representation.

Arguments

Usage

as(object, class)

concept

  • phylo4 tree formats
  • convert tree formats
  • conversion between tree formats

See Also

generic as, phylo4, phylo4d, extractTree, the original phylog from the ade4 package and as.phylo from the ape package.

Examples

Run this code
trString <- "(((Strix_aluco:4.2,Asio_otus:4.2):3.1,Athene_noctua:7.3):6.3,Tyto_alba:13.5);"
tree.owls <- ape::read.tree(text=trString)
## round trip conversion
tree_in_phylo <- tree.owls                  # tree is a phylo object
(tree_in_phylo4 <- as(tree.owls,"phylo4"))  # phylo converted to phylo4
identical(tree_in_phylo,as(tree_in_phylo4,"phylo"))
## test if phylo, and phylo4 converted to phylo are identical
## (no, because of dimnames)

## Conversion to phylog (ade4)
as(tree_in_phylo4, "phylog")

## Conversion to data.frame
as(tree_in_phylo4, "data.frame")

## Conversion to phylo (ape) 
as(tree_in_phylo4, "phylo")

## Conversion to phylo4d, (data slots empty)    
as(tree_in_phylo4, "phylo4d")

Run the code above in your browser using DataLab