[Phylobase-commits] r471 - branches/fm-branch/src/ncl pkg/R pkg/inst/doc pkg/man
noreply at r-forge.r-project.org
noreply at r-forge.r-project.org
Tue Aug 18 20:08:03 CEST 2009
Author: bbolker
Date: 2009-08-18 20:08:03 +0200 (Tue, 18 Aug 2009)
New Revision: 471
Modified:
branches/fm-branch/src/ncl/configure
pkg/R/checkdata.R
pkg/R/class-phylo4.R
pkg/R/class-phylo4d.R
pkg/R/methods-phylo4.R
pkg/R/methods-phylo4d.R
pkg/R/phylo4.R
pkg/R/setAs-Methods.R
pkg/inst/doc/phylobase.Rnw
pkg/man/check.phylo4d.Rd
Log:
replacement of which= argument with type= argument for node type
replacement of which= with node= for node
documentation tweaking
Modified: branches/fm-branch/src/ncl/configure
===================================================================
--- branches/fm-branch/src/ncl/configure 2009-08-18 18:06:31 UTC (rev 470)
+++ branches/fm-branch/src/ncl/configure 2009-08-18 18:08:03 UTC (rev 471)
@@ -5505,7 +5505,7 @@
else
ac_cv_header_stdc=no
fi
-rm -rf conftest*
+rm -f conftest*
fi
@@ -5526,7 +5526,7 @@
else
ac_cv_header_stdc=no
fi
-rm -rf conftest*
+rm -f conftest*
fi
@@ -6510,7 +6510,7 @@
# Check to see that the pipe works correctly.
pipe_works=no
- rm -rf conftest*
+ rm -f conftest*
cat > conftest.$ac_ext <<EOF
#ifdef __cplusplus
extern "C" {
@@ -6607,7 +6607,7 @@
echo "$progname: failed program was:" >&5
cat conftest.$ac_ext >&5
fi
- rm -rf conftest* conftst*
+ rm -f conftest* conftst*
# Do not use the global_symbol_pipe unless it works.
if test "$pipe_works" = yes; then
@@ -6681,7 +6681,7 @@
no_glob_subst='s/\*/\\\*/g'
# Constants:
-rm="rm -rf"
+rm="rm -f"
# Global variables:
default_ofile=libtool
@@ -20560,7 +20560,6 @@
CXXFLAGS_WARNINGS="$CXXFLAGS_WARNINGS"
CXXFLAGS_OPTIM_SPEED="-O3 -ffast-math"
CXXFLAGS_OPTIM_SIZE="-Os -ffast-math"
- CXXFLAGS_USE_FPIC="-fPIC" ## T Jombart/phylobase hack
fi
case "$build_os" in
darwin*) CXXFLAGS_WARNINGS="$CXXFLAGS_WARNINGS -Wno-long-double";;
@@ -20570,13 +20569,13 @@
if test "x$CXXFLAGS_OPTIM_SIZE" = "x"; then
CXXFLAGS_OPTIM_SIZE=$CXXFLAGS_OPTIM_SPEED
fi
- ## T Jombart/phylobase hack: add CXXFLAGS_USE_FPIC
- CXXFLAGS="$CXXFLAGS $CXXFLAGS_OPTIM_SPEED $CXXFLAGS_WARNINGS $CXXFLAGS_USE_FPIC"
+ CXXFLAGS="$CXXFLAGS $CXXFLAGS_OPTIM_SPEED $CXXFLAGS_WARNINGS"
+
# Checks for libraries.
# Checks for header files.
@@ -20648,7 +20647,7 @@
else
ac_cv_header_stdc=no
fi
-rm -rf conftest*
+rm -f conftest*
fi
@@ -20669,7 +20668,7 @@
else
ac_cv_header_stdc=no
fi
-rm -rf conftest*
+rm -f conftest*
fi
@@ -21678,6 +21677,7 @@
# endif
#endif
+#include <limits.h>
#include <stdlib.h>
#ifdef HAVE_UNISTD_H
@@ -21824,14 +21824,17 @@
/* This test makes some buggy mktime implementations loop.
Give up after 60 seconds; a mktime slower than that
isn't worth using anyway. */
- alarm (5);
+ alarm (60);
- for (time_t_max = 1; 0 < time_t_max; time_t_max *= 2)
- continue;
- time_t_max--;
- if ((time_t) -1 < 0)
- for (time_t_min = -1; (time_t) (time_t_min * 2) < 0; time_t_min *= 2)
- continue;
+ for (;;)
+ {
+ t = (time_t_max << 1) + 1;
+ if (t <= time_t_max)
+ break;
+ time_t_max = t;
+ }
+ time_t_min = - ((time_t) ~ (time_t) 0 == (time_t) -1) - time_t_max;
+
delta = time_t_max / 997; /* a suitable prime number */
for (i = 0; i < N_STRINGS; i++)
{
@@ -21846,10 +21849,12 @@
&& mktime_test ((time_t) (60 * 60 * 24))))
return 1;
- for (j = 1; 0 < j; j *= 2)
+ for (j = 1; ; j <<= 1)
if (! bigtime_test (j))
return 1;
- if (! bigtime_test (j - 1))
+ else if (INT_MAX / 2 < j)
+ break;
+ if (! bigtime_test (INT_MAX))
return 1;
}
return ! (irix_6_4_bug () && spring_forward_gap () && year_2050_test ());
@@ -22406,8 +22411,7 @@
fi
-#ac_config_files="$ac_config_files Makefile example/Makefile example/ncltest/Makefile example/nclsimplest/Makefile example/basiccmdline/Makefile example/normalizer/Makefile ncl/Makefile test/Makefile"
-ac_config_files="$ac_config_files Makefile ncl/Makefile"
+ac_config_files="$ac_config_files Makefile example/Makefile example/ncltest/Makefile example/nclsimplest/Makefile example/basiccmdline/Makefile example/normalizer/Makefile ncl/Makefile test/Makefile"
cat >confcache <<\_ACEOF
# This file is a shell script that caches the results of configure
Modified: pkg/R/checkdata.R
===================================================================
--- pkg/R/checkdata.R 2009-08-18 18:06:31 UTC (rev 470)
+++ pkg/R/checkdata.R 2009-08-18 18:08:03 UTC (rev 471)
@@ -147,25 +147,25 @@
return(TRUE)
}
-formatData <- function(phy, dt, which=c("tip", "internal", "all"),
+formatData <- function(phy, dt, type=c("tip", "internal", "all"),
match.data=TRUE, label.type=c("rownames", "column"),
label.column=1, missing.data=c("fail", "warn", "OK"),
extra.data=c("warn", "OK", "fail")
) {
- which <- match.arg(which)
+ type <- match.arg(type)
label.type <- match.arg(label.type)
stopifnot(label.column %in% 1:ncol(dt))
missing.data <- match.arg(missing.data)
extra.data <- match.arg(extra.data)
- nr <- switch(which,
+ nr <- switch(type,
tip = nTips(phy),
internal = nNodes(phy),
all = nTips(phy)+nNodes(phy))
tmpDt <- array(, dim=c(nr, ncol(dt)),
- dimnames=list(nodeId(phy, which), colnames(dt)))
+ dimnames=list(nodeId(phy, type), colnames(dt)))
tmpDt <- data.frame(tmpDt)
if(match.data) {
@@ -181,8 +181,8 @@
ndDt <- unlist(ndDt)
## Make sure that data are matched to appropriate nodes
- if(which != "all") {
- switch(which,
+ if(type != "all") {
+ switch(type,
tip = {
if(any(names(ndDt) %in% labels(phy, "internal")))
stop("You are trying to match tip data to internal ",
@@ -199,7 +199,7 @@
## Check differences
extra <- names(ndDt[is.na(ndDt)])
- mssng <- nodeId(phy, which)[! nodeId(phy, which) %in% ndDt]
+ mssng <- nodeId(phy, type)[! nodeId(phy, type) %in% ndDt]
if(length(mssng) > 0 && missing.data != "OK") {
msg <- "The following nodes are not found in the dataset: "
Modified: pkg/R/class-phylo4.R
===================================================================
--- pkg/R/class-phylo4.R 2009-08-18 18:06:31 UTC (rev 470)
+++ pkg/R/class-phylo4.R 2009-08-18 18:08:03 UTC (rev 471)
@@ -23,19 +23,19 @@
#####################
.createLabels <- function(value, ntips, nnodes, use.names = TRUE,
- which = c("tip", "internal", "allnode")) {
+ type = c("tip", "internal", "allnode")) {
- which <- match.arg(which)
+ type <- match.arg(type)
## set up final length of object to return
- lgthRes <- switch(which, tip=ntips, internal=nnodes, allnode=ntips+nnodes)
+ lgthRes <- switch(type, tip=ntips, internal=nnodes, allnode=ntips+nnodes)
## create NA character vector of node labels
res <- character(lgthRes)
is.na(res) <- TRUE
## create internal names
- names(res) <- switch(which,
+ names(res) <- switch(type,
tip = 1:ntips,
internal = seq(from=ntips+1, length=lgthRes),
allnode = 1:(ntips+nnodes))
@@ -44,7 +44,7 @@
## if no values are provided
if(missing(value) || is.null(value) || all(is.na(value))) {
## tip labels can't be NULL
- if(!identical(which, "internal")) {
+ if(!identical(type, "internal")) {
tipLbl <- .genlab("T", ntips)
res[1:ntips] <- tipLbl
}
@@ -128,11 +128,11 @@
## tip.label
tip.label <- .createLabels(value=tip.label, ntips=ntips, nnodes=nnodes,
- which="tip")
+ type="tip")
## node.label
node.label <- .createLabels(node.label, ntips=ntips, nnodes=nnodes,
- which="internal")
+ type="internal")
## fill in the result
res <- new("phylo4")
Modified: pkg/R/class-phylo4d.R
===================================================================
--- pkg/R/class-phylo4d.R 2009-08-18 18:06:31 UTC (rev 470)
+++ pkg/R/class-phylo4d.R 2009-08-18 18:08:03 UTC (rev 471)
@@ -54,15 +54,15 @@
## Replacing node labels by node numbers and formatting the data to make sure
## they have the correct dimensions
if(!is.null(all.data) && all(dim(all.data) > 0))
- all.data <- formatData(x, all.data, which="all",
+ all.data <- formatData(x, all.data, type="all",
match.data=match.data, ...)
if(!is.null(tip.data) && all(dim(tip.data) > 0))
- tip.data <- formatData(x, tip.data, which="tip",
+ tip.data <- formatData(x, tip.data, type="tip",
match.data=match.data, ...)
if(!is.null(node.data) && all(dim(node.data) > 0))
- node.data <- formatData(x, node.data, which="internal",
+ node.data <- formatData(x, node.data, type="internal",
match.data=match.data, ...)
## Merging dataset
Modified: pkg/R/methods-phylo4.R
===================================================================
--- pkg/R/methods-phylo4.R 2009-08-18 18:06:31 UTC (rev 470)
+++ pkg/R/methods-phylo4.R 2009-08-18 18:08:03 UTC (rev 471)
@@ -109,12 +109,12 @@
}
})
-setMethod("nodeId", "phylo4", function(x, which=c("internal","tip","allnode")) {
- which <- match.arg(which)
+setMethod("nodeId", "phylo4", function(x, type=c("internal","tip","allnode")) {
+ type <- match.arg(type)
tipNid <- x at edge[x at edge[,2]<=nTips(x),2]
allNid <- unique(as.vector(x at edge))
intNid <- allNid[! allNid %in% tipNid]
- nid <- switch(which,
+ nid <- switch(type,
internal = intNid,
tip = tipNid,
allnode = allNid)
@@ -145,14 +145,14 @@
!all(is.na(x at edge.length))
})
-setMethod("edgeLength", "phylo4", function(x, which) {
+setMethod("edgeLength", "phylo4", function(x, node) {
if (!hasEdgeLength(x))
NULL
else {
- if (missing(which))
+ if (missing(node))
return(x at edge.length)
else {
- n <- getNode(x, which)
+ n <- getNode(x, node)
return(x at edge.length[match(n, x at edge[,2])])
}
}
@@ -205,10 +205,10 @@
### Label accessors
#########################################################
-setMethod("labels", "phylo4", function(object, which = c("tip",
+setMethod("labels", "phylo4", function(object, type = c("tip",
"internal", "allnode"), ...) {
- which <- match.arg(which)
- switch(which,
+ type <- match.arg(type)
+ switch(type,
tip = object at tip.label[as.character(nodeId(object, "tip"))],
internal = {
if (hasNodeLabels(object)) {
@@ -228,24 +228,24 @@
setReplaceMethod("labels",
signature(object="phylo4", value="character"),
- function(object, which = c("tip", "internal", "allnode"),
+ function(object, type = c("tip", "internal", "allnode"),
use.names=FALSE, ..., value) {
- which <- match.arg(which)
+ type <- match.arg(type)
- ob <- switch(which,
+ ob <- switch(type,
## If 'tip'
tip = {
object at tip.label <- .createLabels(value, nTips(object),
nNodes(object), use.names,
- which="tip")
+ type="tip")
object
},
## If 'internal'
internal = {
object at node.label <- .createLabels(value, nTips(object),
nNodes(object), use.names,
- which="internal")
+ type="internal")
object
},
## If 'allnode'
@@ -255,21 +255,21 @@
nodVal <- value[names(value) %in% nodeId(object, "internal")]
object at tip.label <- .createLabels(tipVal, nTips(object),
nNodes(object), use.names,
- which="tip")
+ type="tip")
object at node.label <- .createLabels(nodVal, nTips(object),
nNodes(object), use.names,
- which="internal")
+ type="internal")
}
else {
ntips <- nTips(object)
nedges <- nTips(object) + nNodes(object)
object at tip.label <- .createLabels(value[1:ntips], nTips(object),
nNodes(object), use.names,
- which="tip")
+ type="tip")
object at node.label <- .createLabels(value[(ntips+1):nedges],
nTips(object),
nNodes(object), use.names,
- which="internal")
+ type="internal")
}
object
})
@@ -287,23 +287,23 @@
})
setMethod("nodeLabels", "phylo4", function(object) {
- labels(object, which="internal")
+ labels(object, type="internal")
})
setReplaceMethod("nodeLabels", signature(object="phylo4", value="character"),
function(object, ..., value) {
- labels(object, which="internal", ...) <- value
+ labels(object, type="internal", ...) <- value
object
})
### Tip labels
setMethod("tipLabels", "phylo4", function(object) {
- labels(object, which="tip")
+ labels(object, type="tip")
})
setReplaceMethod("tipLabels", signature(object="phylo4", value="character"),
function(object, ..., value) {
- labels(object, which="tip", ...) <- value
+ labels(object, type="tip", ...) <- value
return(object)
})
Modified: pkg/R/methods-phylo4d.R
===================================================================
--- pkg/R/methods-phylo4d.R 2009-08-18 18:06:31 UTC (rev 470)
+++ pkg/R/methods-phylo4d.R 2009-08-18 18:08:03 UTC (rev 471)
@@ -3,7 +3,7 @@
setMethod("show", "phylo4d", function(object) printphylo4(object))
setMethod("tdata", "phylo4d",
- function(x, which=c("tip", "internal", "allnode"),
+ function(x, type=c("tip", "internal", "allnode"),
label.type=c("row.names","column"),
empty.columns=TRUE, ...) {
@@ -11,10 +11,10 @@
## Note: the function checks for unique labels. It's currently unecessary
## but could be useful in the future if non-unique labels are allowed.
- which <- match.arg(which)
+ type <- match.arg(type)
label.type <- match.arg(label.type)
- if (which == "tip") {
+ if (type == "tip") {
if (all(dim(x at tip.data) == 0)) {
return(x at tip.data)
}
@@ -37,7 +37,7 @@
}
}
- if (which == "internal") {
+ if (type == "internal") {
if (all(dim(x at node.data)==0)) {
return(x at node.data)
}
@@ -65,7 +65,7 @@
}
}
- if (which == "allnode") {
+ if (type == "allnode") {
## node data
if (all(dim(x at node.data) == 0)) { # empty data
if (!hasNodeLabels(x)) {
@@ -119,11 +119,11 @@
})
setReplaceMethod("tdata", "phylo4d",
- function(object, which = c("tip", "internal", "allnode"), ...,
+ function(object, type = c("tip", "internal", "allnode"), ...,
value) {
- which <- match.arg(which)
+ type <- match.arg(type)
- tmpData <- switch(which,
+ tmpData <- switch(type,
tip = .phylo4Data(object, tip.data=value, ...),
internal = .phylo4Data(object, node.data=value, ...),
allnode = .phylo4Data(object, all.data=value, ...))
Modified: pkg/R/phylo4.R
===================================================================
--- pkg/R/phylo4.R 2009-08-18 18:06:31 UTC (rev 470)
+++ pkg/R/phylo4.R 2009-08-18 18:08:03 UTC (rev 471)
@@ -61,7 +61,7 @@
setGeneric("labels")
setGeneric("labels<-",
- function(object, which, ..., value) {
+ function(object, type, ..., value) {
standardGeneric("labels<-")
})
@@ -83,7 +83,7 @@
standardGeneric("tipLabels<-")
})
-setGeneric("nodeId", function(x, which=c("internal", "tip", "all")) {
+setGeneric("nodeId", function(x, type=c("internal", "tip", "all")) {
standardGeneric("nodeId")
})
Modified: pkg/R/setAs-Methods.R
===================================================================
--- pkg/R/setAs-Methods.R 2009-08-18 18:06:31 UTC (rev 470)
+++ pkg/R/setAs-Methods.R 2009-08-18 18:08:03 UTC (rev 471)
@@ -166,7 +166,7 @@
edge.length <- rep(NA, nrow(E))
}
- label <- labels(x,which="all")
+ label <- labels(x,type="all")
label <- label[match(node, names(label))]
d <- data.frame(label, node, ancestor=ancestr, edge.length,
Modified: pkg/inst/doc/phylobase.Rnw
===================================================================
--- pkg/inst/doc/phylobase.Rnw 2009-08-18 18:06:31 UTC (rev 470)
+++ pkg/inst/doc/phylobase.Rnw 2009-08-18 18:08:03 UTC (rev 471)
@@ -131,7 +131,7 @@
Print node numbers (in edge matrix order):
<<nodenumbergeodata>>=
-nodeId(g1, which='allnode')
+nodeId(g1, type='allnode')
@
Print edge labels (also empty in this case --- therefore
Modified: pkg/man/check.phylo4d.Rd
===================================================================
--- pkg/man/check.phylo4d.Rd 2009-08-18 18:06:31 UTC (rev 470)
+++ pkg/man/check.phylo4d.Rd 2009-08-18 18:08:03 UTC (rev 471)
@@ -1,66 +1,64 @@
\name{checkPhylo4d}
-\alias{checkData}
-\alias{attachData}
-\title{Validity checking for phylo4d objects}
+\alias{formatData}
+\alias{addData,phylo4d-method}
+\title{Data addition and validity checking for phylo4d objects}
\description{
Basic checks on the validity of S4 phylogenetic plus data objects
(i.e. \linkS4class{phylo4d} objects).
}
-\usage{
-checkData(object, label.type = c("row.names", "column"),
-label.column = 1, use.tip.names=TRUE, missing.tip.data=c("fail","OK","warn"),
-extra.tip.data=c("fail","OK","warn"), default.tip.names=c("warn","OK","fail"),
-use.node.names=FALSE, missing.node.data=c("OK","warn","fail"),
-extra.node.data=c("OK","warn","fail"), default.node.names=c("warn","OK","fail"),
-non.unique.tips=c("warn", "OK", "fail"), non.unique.nodes=c("warn", "OK", "fail"), \dots)
+\section{Methods}{
+ \describe{
+ \item{addData}{\code{signature(x = "phylo4d")}: add data}
+ }
+ }
-attachData(object, label.type = c("row.names", "column"), label.column = 1,
-use.tip.names = TRUE, use.node.names = FALSE,\dots)
+ \usage{
+formatData(phy, dt, type=c("tip", "internal", "all"),
+ match.data=TRUE, label.type=c("rownames", "column"),
+ label.column=1, missing.data=c("fail", "warn", "OK"),
+ extra.data=c("warn", "OK", "fail"))
+\S4method{addData}{phylo4d}(x, tip.data=NULL, node.data=NULL,
+ all.data=NULL, pos=c("after", "before"),
+ merge.data=TRUE, match.data=TRUE,
+ \dots)
}
-
\arguments{
- \item{object}{A phylo4d object}
- \item{label.type}{Obtain labels for matching data to tree labels from the row.names or a column of the data? (default=\code{row.names})}
- \item{label.column}{If label.type="column", number or name of column to use for matching data to tree labels (default=\code{1})}
- \item{use.tip.names}{Use tip data names if present (default=\code{TRUE})}
- \item{missing.tip.data}{Can tip data taxa be a subset of tree taxa? (default=\code{fail})}
- \item{extra.tip.data}{Can tip data taxa be a superset of tree taxa? (default=\code{fail})}
- \item{default.tip.names}{Do tip data have the default (uninformative) names? (default=\code{warn})}
- \item{use.node.names}{Use node data names if present
- (default=\code{FALSE})}
- \item{missing.node.data}{Can node data taxa be a subset of tree taxa?
- (default=\code{OK})}
- \item{extra.node.data}{Can node data taxa be a superset of tree taxa?
- (default=\code{OK})}
- \item{default.node.names}{Do tip data have the default (uninformative) names?
- (default=\code{warn})}
- \item{non.unique.tips}{Can you attach data to non-unique tip? (default=\code{warn})}
- \item{non.unique.nodes}{Can you attach data to non-unique nodes? (default=\code{warn})}
- \item{\dots}{Further arguments (for consistency)}
+ \item{x}{A phylo4d object}
+ \item{phy}{A phylo4 object}
+ \item{dt}{a data frame or matrix}
+ \item{type}{type of data to attach}
+ \item{label.type}{stuff}
+ \item{label.column}{stuff}
+ \item{missing.data}{action to take if there are missing data/labels don't match}
+ \item{extra.data}{action to take if there are extra data/labels don't match}
+ \item{tip.data}{a data frame, matching tree tips}
+ \item{node.data}{a data frame, matching tree internal nodes}
+ \item{all.data}{a data frame, matching all tree nodes (tips and internal nodes)}
+ \item{pos}{add data columns before or after existing data?}
+ \item{merge.data}{stuff}
+ \item{match.data}{stuff}
+ \item{\dots}{stuff}
}
\value{
- \code{checkData} returns an error string (describing problems) or \code{TRUE} if everything is OK. If option \code{fail} is specified and a problem is encountered, returns an error string. If option \code{warn} is specified and a problem is encountered, returns \code{TRUE} plus a warning message.
-
By default, tip data names are used to attach the tip data to the tree, must be present, and must match the set of tree taxa exactly. By default node data names are not used to attach the data to the tree, and thus node data names are not required.
- \code{attachData} returns the phylo4 object with tipdata and nodedata (if present) attached to the phylo4 tree.
+ \code{addData} returns the phylo4 object with tipdata and nodedata (if present) attached to the phylo4 tree.
}
\details{
- \code{checkData} checks validity of a phylo4d object. For tipdata and nodedata, checks
+ \code{formatData} checks validity of a phylo4d object. For tipdata and nodedata, checks
for presence of tip and node names, whether tip or node data taxa and tree taxa are an
exact match, and whether tip or node data taxa are a superset or subset of the tree
taxa. By default, if several tip or node labels are non-unique, they all receive the same
value. This is only true if you use names to attach data to your tree. You can prevent
this behavior by changing the value of the arguments \code{non.unique.tips} and
\code{non.unique.nodes} to \code{fail}.
-
- \code{attachData} takes a phylo4d object that has been checked, and attaches the tipdata and nodedata to the object. This involves the data being subset to include only the taxa present in the tree, with missing data taxa assigned NA values. The data are sorted to match the order of the tip.labels of the tree to allow use with comparative analysis functions.
}
\seealso{the \code{\link{phylo4d}} constructor, the \linkS4class{phylo4d} class. See also the \code{\link{checkPhylo4}}, the \code{\link{phylo4}} constructor and the \linkS4class{phylo4} class. See \code{\link{coerce-methods}} for translation functions.}
\author{Steven Kembel \email{skembel at berkeley.edu}}
\examples{
-require(ape)
-#generate a tree and some data
+require(ape) ## for rcoal
+## generate a tree and some data
+set.seed(1)
p3 <- rcoal(5)
dat <- data.frame(a = rnorm(5), b = rnorm(5), row.names = p3$tip.label)
dat.defaultnames <- dat
More information about the Phylobase-commits
mailing list