]> git.donarmstrong.com Git - ape.git/blobdiff - man/read.tree.Rd
bug fix in mcmc.popsize()
[ape.git] / man / read.tree.Rd
index 75f4cb55355fd400abc4e3d19df314db2efd9650..1bf915cd8656ae2862457f8865806b473ff17f83 100644 (file)
@@ -2,8 +2,8 @@
 \alias{read.tree}
 \title{Read Tree File in Parenthetic Format}
 \usage{
-read.tree(file = "", text = NULL, tree.names = NULL,
-          skip = 0, comment.char = "#", ...)
+read.tree(file = "", text = NULL, tree.names = NULL, skip = 0,
+    comment.char = "#", keep.multi = FALSE, ...)
 }
 \arguments{
   \item{file}{a file name specified by either a variable of mode character,
@@ -24,7 +24,10 @@ read.tree(file = "", text = NULL, tree.names = NULL,
   \item{comment.char}{a single character, the remaining of the line
     after this character is ignored (this is passed directly to
     \code{scan()}).}
-  \item{...}{Further arguments to be passed to \code{scan()}.}
+  \item{keep.multi}{if \code{TRUE} and \code{tree.names = NULL} then
+    single trees are returned in \code{"multiPhylo"} format, with any
+    name that is present (see details). Default is \code{FALSE}.}
+  \item{\dots}{further arguments to be passed to \code{scan()}.}
 }
 \description{
   This function reads a file which contains one or several trees in
@@ -42,6 +45,10 @@ read.tree(file = "", text = NULL, tree.names = NULL,
   apparently not a valid Newick format. If there are two root edges
   (e.g., "(((A:1,B:1):10):10);"), then the tree is not read and an error
   message is issued.
+
+  If there are any characters preceding the first "(" in a line then
+  this is assigned to the name. This is returned when a "multiphylo"
+  object is returned and \code{tree.names = NULL}.
 }
 \value{
   an object of class \code{"phylo"} with the following components:
@@ -63,6 +70,8 @@ read.tree(file = "", text = NULL, tree.names = NULL,
 
   If several trees are read in the file, the returned object is of class
   \code{"multiPhylo"}, and is a list of objects of class \code{"phylo"}.
+  The name of each tree can be specified by \code{tree.names}, or can be
+  read from the file (see details).
 }
 \references{
   Felsenstein, J. The Newick tree format.
@@ -71,11 +80,11 @@ read.tree(file = "", text = NULL, tree.names = NULL,
   Olsen, G. Interpretation of the "Newick's 8:45" tree format standard.
   \url{http://evolution.genetics.washington.edu/phylip/newick_doc.html}
 
-  Paradis, E. (2006) Definition of Formats for Coding Phylogenetic Trees
-  in R. \url{http://ape.mpl.ird.fr/misc/FormatTreeR_4Dec2006.pdf}
+  Paradis, E. (2008) Definition of Formats for Coding Phylogenetic Trees
+  in R. \url{http://ape.mpl.ird.fr/misc/FormatTreeR_28July2008.pdf}
 }
 
-\author{Emmanuel Paradis \email{Emmanuel.Paradis@mpl.ird.fr}}
+\author{Emmanuel Paradis and Daniel Lawson \email{dan.lawson@bristol.ac.uk}}
 \seealso{
   \code{\link{write.tree}}, \code{\link{read.nexus}},
   \code{\link{write.nexus}}, \code{\link[base]{scan}} for the basic R
@@ -83,12 +92,13 @@ read.tree(file = "", text = NULL, tree.names = NULL,
 }
 \examples{
 ### An extract from Sibley and Ahlquist (1990)
-cat("(((Strix_aluco:4.2,Asio_otus:4.2):3.1,",
-   "Athene_noctua:7.3):6.3,Tyto_alba:13.5);",
-   file = "ex.tre", sep = "\n")
+cat("owls(((Strix_aluco:4.2,Asio_otus:4.2):3.1,Athene_noctua:7.3):6.3,Tyto_alba:13.5);", file = "ex.tre", sep = "\n")
 tree.owls <- read.tree("ex.tre")
 str(tree.owls)
 tree.owls
+tree.owls <- read.tree("ex.tre", keep.multi = TRUE)
+tree.owls
+names(tree.owls)
 unlink("ex.tre") # delete the file "ex.tre"
 ### Only the first three species using the option `text'
 TREE <- "((Strix_aluco:4.2,Asio_otus:4.2):3.1,Athene_noctua:7.3);"