ape (version 1.1-1)

as.phylo: Conversion between "phylo" and "hclust" trees

Description

The function as.phylo.hclust (short form as.phylo) converts a clustering tree computed using hclust into a phylogenetic tree, i.e. into an object of class "phylo". The function as.hclust.phylo (short form as.hclust) converts a phylogenetic tree into a "hclust" object.

Usage

as.phylo(hc)
as.phylo.hclust(hc)
as.hclust.phylo(phy)

Arguments

hc
an object of class "hclust"), i.e. a clustering tree computed using hclust.
phy
a phylogenetic tree, i.e. an object of class "phy". To be converted into a "hclust" object the phylogenetic tree needs to be ultra-metric and binary.

Value

  • An object of class "hclust" or "phylo", respectively.

See Also

hclust, as.hclust, is.binary.tree, is.ultrametric.

Examples

Run this code
library(ape)
library(mva) # for hclust and example data set

# create hclust object
data(USArrests)
hclust.tree<-hclust(dist(USArrests[1:6,]))
plot(hclust.tree)

# convert into phylo object
phylo.tree <- as.phylo(hclust.tree)
phylo.tree
plot(phylo.tree)

# phylogenetic tree is ultrametric and binary 
is.ultrametric(phylo.tree)
is.binary.tree(phylo.tree)

# convert back into hclust object
converted.tree <- as.hclust(phylo.tree)
plot(converted.tree)

Run the code above in your browser using DataCamp Workspace