]> git.donarmstrong.com Git - ape.git/blob - man/as.phylo.Rd
4b757ac08960f10cad988410766009abd197827a
[ape.git] / man / as.phylo.Rd
1 \name{as.phylo}
2 \alias{as.phylo}
3 \alias{as.phylo.hclust}
4 \alias{as.phylo.phylog}
5 \alias{as.hclust.phylo}
6 \alias{old2new.phylo}
7 \alias{new2old.phylo}
8 \title{Conversion Among Tree Objects}
9 \usage{
10 as.phylo(x, ...)
11 \method{as.phylo}{hclust}(x, ...)
12 \method{as.phylo}{phylog}(x, ...)
13 \method{as.hclust}{phylo}(x, ...)
14 old2new.phylo(phy)
15 new2old.phylo(phy)
16 }
17 \arguments{
18   \item{x}{an object to be converted into another class.}
19   \item{\dots}{further arguments to be passed to or from other methods.}
20   \item{phy}{an object of class \code{"phylo"}.}
21 }
22 \description{
23   \code{as.phylo} is a generic function which converts an object into a
24   tree of class \code{"phylo"}. There are currently two methods for this
25   generic for objects of class \code{"hclust"} and of class
26   \code{"phylog"} (implemented in the package ade4).
27   \code{as.hclust.phylo} is a method of the generic
28   \code{\link[stats]{as.hclust}} which converts an object of class
29   \code{"phylo"} into one of class \code{"hclust"}. This can used to
30   convert an object of class \code{"phylo"} into one of class
31   \code{"dendrogram"} (see examples).
32
33   \code{old2new.phylo} and \code{new2old.phylo} are utility functions
34   for converting between the old and new coding of the class
35   \code{"phylo"}.
36 }
37 \value{
38   An object of class \code{"hclust"} or \code{"phylo"}.
39 }
40 \author{Emmanuel Paradis \email{Emmanuel.Paradis@mpl.ird.fr}}
41 \seealso{
42   \code{\link[stats]{hclust}}, \code{\link[stats]{as.hclust}},
43   \code{\link[stats]{dendrogram}}, \code{\link[ade4]{phylog}},
44   \code{\link{as.phylo.formula}}
45 }
46 \examples{
47 data(bird.orders)
48 hc <- as.hclust(bird.orders)
49 tr <- as.phylo(hc)
50 identical(bird.orders, tr) # FALSE, but...
51 all.equal(bird.orders, tr) # ... TRUE
52
53 ### shows the three plots for tree objects:
54 dend <- as.dendrogram(hc)
55 layout(matrix(c(1:3, 3), 2, 2))
56 plot(bird.orders, font = 1)
57 plot(hc)
58 par(mar = c(8, 0, 0, 0)) # leave space for the labels
59 plot(dend)
60
61 ### how to get (nearly) identical plots with
62 ### plot.phylo and plot.dendrogram:
63 layout(matrix(1:2, 2, 1))
64 plot(bird.orders, font = 1, no.margin = TRUE)
65 par(mar = c(0, 0, 0, 8))
66 plot((dend), horiz = TRUE)
67 layout(matrix(1, 1, 1))
68 }
69 \keyword{manip}