]> git.donarmstrong.com Git - ape.git/blob - man/read.nexus.Rd
d12f4d29f019ef3cb859a202bfb301058e2847ec
[ape.git] / man / read.nexus.Rd
1 \name{read.nexus}
2 \alias{read.nexus}
3 \title{Read Tree File in Nexus Format}
4 \usage{
5 read.nexus(file, tree.names = NULL)
6 }
7 \arguments{
8   \item{file}{a file name specified by either a variable of mode character,
9     or a double-quoted string.}
10   \item{tree.names}{if there are several trees to be read, a vector of
11     mode character that gives names to the individual trees; if
12     \code{NULL} (the default), the trees are named \code{"tree1"},
13     \code{"tree2"}, ...}
14 }
15 \description{
16   This function reads one or several trees in a NEXUS file.
17 }
18 \details{
19   The present implementation tries to follow as much as possible the
20   NEXUS standard. Only the block ``TREES'' is read; the other data can be
21   read with other functions (e.g., \code{\link{read.dna}},
22   \code{\link[base]{read.table}}, ...). A trace of the original data is
23   kept with the attribute \code{"origin"} (see below).
24
25   `read.nexus' tries to represent correctly trees with a badly
26   represented root edge (i.e. with an extra pair of parentheses). For
27   instance, the tree "((A:1,B:1):10);" will be read like "(A:1,B:1):10;"
28   but a warning message will be issued in the former case as this is
29   apparently not a valid Newick format. If there are two root edges
30   (e.g., "(((A:1,B:1):10):10);"), then the tree is not read and an error
31   message is issued.
32 }
33 \value{
34   an object of class \code{"phylo"} with the following components:
35   \item{edge}{a two-column matrix of mode character where each row
36     represents an edge of the tree; the nodes and the tips are
37     symbolized with numbers (these numbers are not treated as numeric,
38     hence the mode character); the nodes are represented with negative
39     numbers (the root being \code{"-1"}), and the tips are represented with
40     positive numbers. For each row, the first column gives the
41     ancestor. This representation allows an easy manipulation of the
42     tree, particularly if it is rooted.}
43   \item{edge.length}{a numeric vector giving the lengths of the
44     branches given by \code{edge}.}
45   \item{tip.label}{a vector of mode character giving the names of the
46     tips; the order of the names in this vector corresponds to the
47     (positive) number in \code{edge}.}
48   \item{node.label}{(optional) a vector of mode character giving the
49     names of the nodes (set to \code{NULL} if not available in the file).}
50   \item{root.edge}{(optional) a numeric value giving the length of the
51     branch at the root is it exists (\code{NULL} otherwise).}
52
53   If several trees are read in the file, the returned object is of class
54   \code{"multiPhylo"}, and is a list of objects of class \code{"phylo"}.
55
56   An attribute \code{"origin"} is further given to the returned object
57   which gives the name of the source file (with its path). This is used
58   to write a tree in a NEXUS file where all the original data must be
59   written (not only the tree) in accordance to the specifications of
60   Maddison et al. (1997).
61 }
62 \references{
63   Maddison, D. R., Swofford, D. L. and Maddison, W. P. (1997) NEXUS: an
64   extensible file format for systematic information. \emph{Systematic
65     Biology}, \bold{46}, 590--621.
66 }
67 \author{Emmanuel Paradis \email{Emmanuel.Paradis@mpl.ird.fr}}
68 \seealso{
69   \code{\link{read.tree}}, \code{\link{write.nexus}},
70   \code{\link{write.tree}}, \code{\link{read.nexus.data}},
71   \code{\link{write.nexus.data}}
72 }
73 \keyword{manip}
74 \keyword{IO}