[Phylobase-commits] r612 - in pkg: R man
noreply at r-forge.r-project.org
noreply at r-forge.r-project.org
Wed Sep 2 15:36:56 CEST 2009
Author: francois
Date: 2009-09-02 15:36:55 +0200 (Wed, 02 Sep 2009)
New Revision: 612
Modified:
pkg/R/readNexus.R
pkg/man/readNexus.Rd
Log:
fix bug in readNexus: check.node.data only available for class phylo and not phylo4, created option quiet in readNexus to increase speed in case of big trees, documented changes
Modified: pkg/R/readNexus.R
===================================================================
--- pkg/R/readNexus.R 2009-09-02 07:10:14 UTC (rev 611)
+++ pkg/R/readNexus.R 2009-09-02 13:36:55 UTC (rev 612)
@@ -1,7 +1,7 @@
readNexus <- function (file, simplify=TRUE, type=c("all", "tree", "data"),
char.all=FALSE, polymorphic.convert=TRUE,
- levels.uniform=TRUE,
- check.node.labels=c("keep", "drop", "asdata")) {
+ levels.uniform=TRUE, quiet=TRUE,
+ check.node.labels=c("keep", "drop", "asdata"), ...) {
## file = input nexus file
## simplify = if TRUE only keeps the first tree, if several trees are found in
@@ -16,6 +16,8 @@
## characters
## levels.uniform = if TRUE, categorical data are loaded with the same levels,
## even if one character is missing a state
+ ## quiet = if TRUE, returns the object without printing tree strings (printing
+ ## makes readNexus very slow in the cases of very big trees)
## check.node.labels = how to deal with node labels, to be passed to phylo4d
## constructor
@@ -49,7 +51,7 @@
## Finally ready to make the call...
intreesstring <- .Call("ReadTreesWithNCL", params,
PACKAGE="phylobase")
- print(intreesstring)
+ if(!quiet) print(intreesstring)
intreesphylolist <- read.nexustreestring(intreesstring);
if (length(intreesphylolist)>1 || !simplify) {
trees <- list()
@@ -62,11 +64,13 @@
check.node.labels <- "drop"
}
trees[[i]] <- phylo4d(intreesphylolist[[i]],
- check.node.labels=check.node.labels)
+ check.node.labels=check.node.labels,
+ ...)
}
else {
trees[[i]] <- phylo4(intreesphylolist[[i]],
- check.node.labels=check.node.labels)
+ check.node.labels=check.node.labels,
+ ...)
}
}
}
@@ -79,11 +83,13 @@
check.node.labels <- "drop"
}
trees <- phylo4d(intreesphylolist[[1]],
- check.node.labels=check.node.labels)
+ check.node.labels=check.node.labels,
+ ...)
}
else {
trees <- phylo4(intreesphylolist[[1]],
- check.node.labels=check.node.labels)
+ check.node.labels=check.node.labels,
+ ...)
}
}
}
@@ -98,19 +104,20 @@
if (length(intreesphylolist) > 1 || !simplify) {
output <- list()
for (i in 1:length(intreesphylolist)) {
- output[[i]] <- phylo4d(as(intreesphylolist[[i]], "phylo4"),
+ output[[i]] <- phylo4d(intreesphylolist[[i]],
tip.data = tipdata,
- check.node.labels=check.node.labels)
+ check.node.labels=check.node.labels,
+ ...)
}
}
else {
- output <- phylo4d(as(intreesphylolist[[1]], "phylo4"),
+ output <- phylo4d(intreesphylolist[[1]],
tip.data=tipdata,
- check.node.labels=check.node.labels)
+ check.node.labels=check.node.labels,
+ ...)
}
}
}
-
output
}
Modified: pkg/man/readNexus.Rd
===================================================================
--- pkg/man/readNexus.Rd 2009-09-02 07:10:14 UTC (rev 611)
+++ pkg/man/readNexus.Rd 2009-09-02 13:36:55 UTC (rev 612)
@@ -11,29 +11,53 @@
}
}
\usage{
- readNexus(file, simplify=TRUE, type=c("all","tree","data"),
- char.all=FALSE, polymorphic.convert=TRUE, levels.uniform=TRUE,
- check.node.labels=c("keep", "drop", "asdata"))
+ readNexus(file, simplify=TRUE, type=c("all", "tree", "data"),
+char.all=FALSE, polymorphic.convert=TRUE, levels.uniform=TRUE,
+quiet=TRUE, check.node.labels=c("keep", "drop", "asdata"), ...)
}
\arguments{
\item{file}{a Nexus file}
- \item{simplify}{If FALSE, returns a list. If TRUE, returns a list if there are multiple trees, a single object otherwise}
+ \item{simplify}{If FALSE, returns a list. If TRUE, returns a list if
+ there are multiple trees, a single object otherwise}
\item{type}{Determines which type of objects to return, if present}
- \item{char.all}{If TRUE, returns all characters, even those excluded in the NEXUS file}
- \item{polymorphic.convert}{If TRUE, converts polymorphic DNA characters to missing data}
- \item{levels.uniform}{If TRUE, uses the same levels for all characters}
- \item{check.node.labels}{Determines how the node labels in the Nexus files should be
- treated in the phylo4 object, see Details for more information.}
+ \item{char.all}{If TRUE, returns all characters, even those excluded
+ in the NEXUS file}
+ \item{polymorphic.convert}{If TRUE, converts polymorphic DNA
+ characters to missing data}
+ \item{levels.uniform}{If TRUE, uses the same levels for all
+ characters}
+ \item{quiet}{If FALSE the tree string is printed. This is mainly for
+ debugging purposes. This option can considerably slow down the
+ process if the tree is big or there are many trees in the file.}
+ \item{check.node.labels}{Determines how the node labels in the Nexus
+ files should be treated in the phylo4 object, see Details for more
+ information.}
+ \item{\dots}{Additional arguments to be passed to phylo4 or phylo4d
+ constructor (see details)}
}
\details{
The options for \code{check.node.labels} can take the values:
\describe{
- \item{keep}{the node labels of the Nexus file will be passed as node labels in the phylo4 object}
- \item{drop}{the node labels of the Nexus file will be ignored in the phylo4 object}
- \item{asdata}{the node labels will passed to the phylo4 object as data.}
+ \item{keep}{the node labels of the Nexus file will be passed as
+ node labels in the phylo4 object}
+ \item{drop}{the node labels of the Nexus file will be ignored in
+ the phylo4 object}
+ \item{asdata}{the node labels will passed to the phylo4 object as
+ data.}
}
- If you use the option \code{asdata} on a file with no node labels, a warning message is
- issued and by default \code{check.node.labels} takes the value \code{drop}.
+ If you use the option \code{asdata} on a file with no node labels, a
+ warning message is issued and by default \code{check.node.labels} takes
+ the value \code{drop}.
+
+ Depending on the context \code{readNexus} will call either the
+ \code{phylo4} or \code{phylo4d} constructor. The \code{phylo4d}
+ constructor will be used if \code{check.node.labels="asdata"} or if
+ \code{type="all"}; and the \code{phylo4} constructor will be used
+ otherwise. Additional arguments can be passed to the constructors such
+ as \code{annote}, \code{missing.data} or \code{extra.data}. See the
+ documentation of \link{phylo4-methods}, \link{phylo4d} and
+ \link{formatData} for the complete list of arguments.
+
}
\value{
A \linkS4class{phylo4} object if there is no data in the Nexus file
@@ -46,8 +70,9 @@
\seealso{the \linkS4class{phylo4d} class, the \linkS4class{phylo4} class}
\author{Brian O'Meara, Derrick Zwickl}
\note{
- This relies on Version 2.0 of the Nexus Class Library by Paul Lewis and Mark Holder. Tree reading
- is done initially using internal \code{APE} functions; these functions can be
- confused if tree names include the word (\dQuote{tree}) in them.
+ This relies on Version 2.0 of the Nexus Class Library by Paul Lewis
+ and Mark Holder. Tree reading is done initially using internal
+ \code{APE} functions; these functions can be confused if tree names
+ include the word (\dQuote{tree}) in them.
}
\keyword{misc}
More information about the Phylobase-commits
mailing list