as {phylobase}R Documentation

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), and to data.frame representation.

Usage

as(object, class)

Arguments

object
a tree of class phylo4, phylo or phylog, or tree and data object of class phylo4d.
class
the name of the class to which tree should be coerced (e.g., "phylo4" or "data.frame").

Methods

Coerce from one object class to another using as(object, "class"), where the object is of the old class and the returned object is of the new class "class". The as function examines the class of object and the new "class" specified to choose the proper conversion without additional information from the user. Conversions exist for combinations:

phylobase to phylobase formats:

as(object, "phylo4d")
where object is of class phylo4 and returns an object of class phylo4d, with empty data.
as(object, "phylo4")
where object is of class phylo4d and returns an object of class phylo4. If data are dropped during the conversion, a warning message is produced. A similar conversion can be done by using the function extractTree, but in this case, no error message is produced.

phylobase to ape formats:

as(object, "phylo")
where object is of class phylo4 or phylo4d and returns an object of class phylo. If data are dropped during the conversion from a phylo4d object, a warning message is produced.
as(object, "multiPhylo")
~~Not implemented yet. where object is of class multiPhylo4 and returns an object of class multiPhylo.

ape to phylobase formats:

as(object, "phylo4")
where object is of class phylo and returns an object of class phylo4.
as(object, "phylo4d")
where object is of class phylo and returns an object of class phylo4d, with empty data.
as(object, "multiPhylo4")
~~Not implemented yet. where object is of class multiPhylo and returns an object of class multiPhylo4.

phylobase to ade4 formats:

as(object, "phylog")
where object is of class phylo4 and returns an object of class phylog.

phylobase format to data.frame:

as(object, "data.frame")
where object is of class phylo4 or phylo4d and returns an object of class data.frame, with data included in the case of phylo4d.

Author(s)

Ben Bolker, Thibaut Jombart, Marguerite Butler, Steve Kembel

See Also

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

Examples

tree.owls <- read.tree(text="(((Strix_aluco:4.2,Asio_otus:4.2):3.1,Athene_noctua:7.3):6.3,Tyto_alba:13.5);")
## 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")

[Package phylobase version 0.5 Index]