Learn R Programming

aphylo (version 0.3-3)

as.phylo: Extensions to the as.phylo function

Description

This function takes an edgelist and recodes (relabels) the nodes following ape's coding convention.

Usage

# S3 method for matrix
as.phylo(x, edge.length = NULL, root.edge = NULL, ...)

# S3 method for aphylo as.phylo(x, ...)

Value

An integer matrix of the same dimmension as edges with the following aditional attribute:

labels

Named integer vector of size n. Original labels of the edgelist where the first n are leaf nodes, n+1 is the root node, and the reminder are the internal nodes.

Arguments

x

Either an edgelist or an object of class aphylo.

edge.length

A vector with branch lengths (optional).

root.edge

A numeric scalar with the length for the root node (optional).

...

Further arguments passed to the method.

Examples

Run this code

# A simple example ----------------------------------------------------------
# This tree has a coding different from ape's

mytree <- matrix(c(1, 2, 1, 3, 2, 4, 2, 5), byrow = TRUE, ncol=2)
mytree

ans <- as.phylo(mytree)
ans
plot(ans)


Run the code above in your browser using DataLab