phylo4-methods {phylobase} | R Documentation |
phylo4
is a generic constructor that creates a phylogenetic
tree object for use in phylobase methods. Phylobase contains functions
for input of phylogenetic trees and data, manipulation of these
objects including pruning and subsetting, and plotting. The phylobase
package also contains translation functions to forms used in other
comparative phylogenetic method packages.
## S4 method for signature 'matrix': phylo4(x, edge.length = NULL, tip.label = NULL, node.label = NULL, edge.label = NULL, order="unknown", annote=list()) ## S4 method for signature 'phylo': phylo4(x, check.node.labels = c("keep", "drop"), annote=list())
x |
a matrix of edges or an object of class phylo (see
above) |
edge |
A numeric, two-column matrix with as many rows as branches in the phylogeny. |
edge.length |
Edge (branch) length. (Optional) |
tip.label |
A character vector of species names (names of "tip" nodes). (Optional) |
node.label |
A character vector of internal node names. (Optional) |
edge.label |
A character vector of edge (branch) names. (Optional) |
order |
character: tree ordering (allowable values are
listed in phylo4_orderings , currently "unknown", "preorder"
(="cladewise" in ape ), and "postorder", with "cladewise"
and "pruningwise" also allowed for compatibility with ape ) |
check.node.labels |
if x is of class phylo , either
"keep" (the default) or "drop" node labels. This argument is useful
if the phylo object has non-unique node labels. |
annote |
any additional annotation data to be passed to the new object |
The minimum information necessary to create a phylobase tree object is a valid edge matrix. The edge matrix describes the topology of the phylogeny. Each row describes a branch of the phylogeny, with the (descendant) node number in column 2 and its ancestor's node number in column 1. These numbers are used internally and must be unique for each node.
The labels designate either nodes or edges. The vector
node.label
names internal nodes, and together with
tip.label
, name all nodes in the tree. The vector
edge.label
names all branches in the tree. All label
vectors are optional, and if they are not given,
internally-generated labels will be assigned. The labels, whether
user-specified or internally generated, must be unique as they
are used to join species data with phylogenetic trees.
phylo
Translation functions are available from many valid tree formats. See coerce-methods.
phylobase team
coerce-methods
for translation functions. The
phylo4 class, the formatData
function to check the validity of phylo4
objects. See also the
phylo4d
constructor, and phylo4d
class.
# a three species tree: mytree <- phylo4(x=matrix(data=c(4,1, 4,5, 5,2, 5,3, 0,4), ncol=2, byrow=TRUE), tip.label=c("speciesA", "speciesB", "speciesC")) mytree plot(mytree) # another way to specify the same tree: mytree <- phylo4(x=cbind(c(4, 4, 5, 5, 0), c(1, 5, 2, 3, 4)), tip.label=c("speciesA", "speciesB", "speciesC")) # another way: mytree <- phylo4(x=rbind(c(4, 1), c(4, 5), c(5, 2), c(5, 3), c(0, 4)), tip.label=c("speciesA", "speciesB", "speciesC")) # with branch lengths: mytree <- phylo4(x=rbind(c(4, 1), c(4, 5), c(5, 2), c(5, 3), c(0, 4)), tip.label=c("speciesA", "speciesB", "speciesC"), edge.length=c(1, .2, .8, .8, NA)) plot(mytree)