From noreply at r-forge.r-project.org Tue May 6 22:16:38 2014 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Tue, 6 May 2014 22:16:38 +0200 (CEST) Subject: [Phylobase-commits] r930 - pkg/R Message-ID: <20140506201638.E721F1873E4@r-forge.r-project.org> Author: francois Date: 2014-05-06 22:16:38 +0200 (Tue, 06 May 2014) New Revision: 930 Modified: pkg/R/checkdata.R Log: added test for reticulation (apparently forgotten) Modified: pkg/R/checkdata.R =================================================================== --- pkg/R/checkdata.R 2014-04-09 20:05:13 UTC (rev 929) +++ pkg/R/checkdata.R 2014-05-06 20:16:38 UTC (rev 930) @@ -69,12 +69,12 @@ ## Storage of error/warning messages err <- wrn <- character(0) - + ## Matrix is integer if (!is.integer(object at edge)) { err <- c(err, "Edge matrix needs to be integer.") } - + ## Matrix doesn't have NAs if (any(is.na(object at edge))) { err <- c(err, "Edge matrix cannot have NAs at this time.", @@ -102,6 +102,16 @@ res <- checkTreeCpp(object, opts=opt) + if (hasRetic(object)) { + msg <- "Tree is reticulated." + if (identical(opt$retic, "fail")) { + err <- c(err, msg) + } + if (identical(opt$retic, "warn")) { + wrn <- c(wrn, msg) + } + } + if (hasEdgeLength(object) && any(is.na(edgeLength(object)))) { naElen <- names(which(is.na(object at edge.length))) if (! identical(naElen, edgeId(object, "root"))) From noreply at r-forge.r-project.org Tue May 6 22:24:43 2014 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Tue, 6 May 2014 22:24:43 +0200 (CEST) Subject: [Phylobase-commits] r931 - pkg/R Message-ID: <20140506202443.D97B4187610@r-forge.r-project.org> Author: francois Date: 2014-05-06 22:24:43 +0200 (Tue, 06 May 2014) New Revision: 931 Modified: pkg/R/subset-methods.R Log: change to accommodate upgrade to roxygen2 4.0.0 Modified: pkg/R/subset-methods.R =================================================================== --- pkg/R/subset-methods.R 2014-05-06 20:16:38 UTC (rev 930) +++ pkg/R/subset-methods.R 2014-05-06 20:24:43 UTC (rev 931) @@ -224,7 +224,7 @@ ##' @aliases [,phylo4,missing,missing-method setMethod("[", signature(x="phylo4", i="missing", j="missing", drop="missing"), function(x, i, j, ..., drop) { - x + return(x) }) ##### -------- phylo4d '[' methods From noreply at r-forge.r-project.org Tue May 6 22:25:41 2014 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Tue, 6 May 2014 22:25:41 +0200 (CEST) Subject: [Phylobase-commits] r932 - pkg/R Message-ID: <20140506202541.A1080187619@r-forge.r-project.org> Author: francois Date: 2014-05-06 22:25:41 +0200 (Tue, 06 May 2014) New Revision: 932 Modified: pkg/R/phylobase-package.R Log: fixed formatting Modified: pkg/R/phylobase-package.R =================================================================== --- pkg/R/phylobase-package.R 2014-05-06 20:24:43 UTC (rev 931) +++ pkg/R/phylobase-package.R 2014-05-06 20:25:41 UTC (rev 932) @@ -29,8 +29,10 @@ ##' using the NEXUS Class Library (\url{http://ncl.sourceforge.net/}) ##' } ##' -##' @section History: -##' \code{phylobase} was started during a Hackathlon at NEScent on December 10-14 2007. +##' @section History: +##' +##' \code{phylobase} was started during a Hackathlon at NESCent on +##' December 10-14 2007. ##' ##' Peter Cowan was a Google Summer of Code fellow in 2008 and ##' developed all the code for plotting. From noreply at r-forge.r-project.org Tue May 6 22:26:32 2014 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Tue, 6 May 2014 22:26:32 +0200 (CEST) Subject: [Phylobase-commits] r933 - pkg/R Message-ID: <20140506202632.8A800187628@r-forge.r-project.org> Author: francois Date: 2014-05-06 22:26:32 +0200 (Tue, 06 May 2014) New Revision: 933 Modified: pkg/R/phylobase.options.R pkg/R/zzz.R Log: changing default to fail for reticulated trees as they are not supported enough currently Modified: pkg/R/phylobase.options.R =================================================================== --- pkg/R/phylobase.options.R 2014-05-06 20:25:41 UTC (rev 932) +++ pkg/R/phylobase.options.R 2014-05-06 20:26:32 UTC (rev 933) @@ -44,6 +44,9 @@ current <- lapply(current, function(foo) { foo <- match.arg(foo, c("warn", "fail", "ok")) }) + if (!identical(current$retic, "fail")) { + stop("Currently reticulated trees are not handled by phylobase.") + } ## options are always global env <- asNamespace("phylobase") assign(".phylobase.Options", current, envir = env) Modified: pkg/R/zzz.R =================================================================== --- pkg/R/zzz.R 2014-05-06 20:25:41 UTC (rev 932) +++ pkg/R/zzz.R 2014-05-06 20:26:32 UTC (rev 933) @@ -1,6 +1,6 @@ ".phylobase.Options" <- - list(retic = "warn", + list(retic = "fail", singleton = "warn", multiroot = "warn", poly = "ok", From noreply at r-forge.r-project.org Tue May 6 22:26:51 2014 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Tue, 6 May 2014 22:26:51 +0200 (CEST) Subject: [Phylobase-commits] r934 - pkg/man Message-ID: <20140506202651.6DD1B18762C@r-forge.r-project.org> Author: francois Date: 2014-05-06 22:26:51 +0200 (Tue, 06 May 2014) New Revision: 934 Modified: pkg/man/MRCA.Rd pkg/man/addData-methods.Rd pkg/man/ancestors.Rd pkg/man/checkPhylo4.Rd pkg/man/edgeLength-methods.Rd pkg/man/edges-accessors.Rd pkg/man/extractTree.Rd pkg/man/formatData.Rd pkg/man/geospiza.Rd pkg/man/getNode-methods.Rd pkg/man/labels-methods.Rd pkg/man/multiPhylo-class.Rd pkg/man/nTips-methods.Rd pkg/man/nodeId-methods.Rd pkg/man/owls4.Rd pkg/man/pdata-class.Rd pkg/man/pdata.Rd pkg/man/phylo4-class.Rd pkg/man/phylo4-methods.Rd pkg/man/phylo4d-accessors.Rd pkg/man/phylo4d-class.Rd pkg/man/phylo4d-methods.Rd pkg/man/phyloXXYY.Rd pkg/man/phylobase-package.Rd pkg/man/phylobase.options.Rd pkg/man/phylobubbles.Rd pkg/man/phylomat-class.Rd pkg/man/plotOneTree.Rd pkg/man/print-methods.Rd pkg/man/readNexus.Rd pkg/man/reorder-methods.Rd pkg/man/root-methods.Rd pkg/man/setAs-methods.Rd pkg/man/shortestPath-methods.Rd pkg/man/subset-methods.Rd pkg/man/summary-methods.Rd pkg/man/tdata-methods.Rd pkg/man/tip.data.plot.Rd pkg/man/treePlot-methods.Rd pkg/man/treeStructure-methods.Rd Log: update docs Modified: pkg/man/MRCA.Rd =================================================================== --- pkg/man/MRCA.Rd 2014-05-06 20:26:32 UTC (rev 933) +++ pkg/man/MRCA.Rd 2014-05-06 20:26:51 UTC (rev 934) @@ -1,3 +1,4 @@ +% Generated by roxygen2 (4.0.0): do not edit by hand \docType{methods} \name{MRCA} \alias{MRCA} @@ -12,10 +13,9 @@ \S4method{MRCA}{phylo}(phy, ...) } \arguments{ - \item{phy}{a phylogenetic tree in phylo4, phylo4d or - phylo format.} +\item{phy}{a phylogenetic tree in phylo4, phylo4d or phylo format.} - \item{...}{a vector of nodes} +\item{...}{a vector of nodes} } \value{ the node corresponding to the most recent common ancestor @@ -24,18 +24,17 @@ Most Recent Common Ancestor (MRCA) of 2 or more nodes. } \details{ -Given some nodes (i.e., tips and/or internal), this -function returns the node corresponding to the most recent -common ancestor. +Given some nodes (i.e., tips and/or internal), this function +returns the node corresponding to the most recent common ancestor. -If \code{phy} is a \code{phylo4} or \code{phylo4d} object, -the nodes can contain both numeric or character values that -will be used by \code{getNode} to retrieve the correct -node. However, if \code{phy} is a \code{phylo} object, the -nodes must be a numeric vector. +If \code{phy} is a \code{phylo4} or \code{phylo4d} object, the +nodes can contain both numeric or character values that will be +used by \code{getNode} to retrieve the correct node. However, if +\code{phy} is a \code{phylo} object, the nodes must be a numeric +vector. -With \code{phylo4} and \code{phylo4d} objects, if a single -node is provided, it will be returned. +With \code{phylo4} and \code{phylo4d} objects, if a single node is +provided, it will be returned. } \examples{ data(geospiza) Modified: pkg/man/addData-methods.Rd =================================================================== --- pkg/man/addData-methods.Rd 2014-05-06 20:26:32 UTC (rev 933) +++ pkg/man/addData-methods.Rd 2014-05-06 20:26:51 UTC (rev 934) @@ -1,3 +1,4 @@ +% Generated by roxygen2 (4.0.0): do not edit by hand \docType{methods} \name{addData} \alias{addData} @@ -15,51 +16,46 @@ all.data = NULL, merge.data = TRUE, pos = c("after", "before"), ...) } \arguments{ - \item{x}{a phylo4 or a phylo4d object} +\item{x}{a phylo4 or a phylo4d object} - \item{tip.data}{a data frame (or object to be coerced to - one) containing only tip data} +\item{tip.data}{a data frame (or object to be coerced to one) containing +only tip data} - \item{node.data}{a data frame (or object to be coerced to - one) containing only node data} +\item{node.data}{a data frame (or object to be coerced to one) containing +only node data} - \item{all.data}{a data frame (or object to be coerced to - one) containing both tip and node data} +\item{all.data}{a data frame (or object to be coerced to one) containing +both tip and node data} - \item{merge.data}{if both \code{tip.data} and - \code{node.data} are provided, it determines whether - columns with common names will be merged together - (default TRUE). If FALSE, columns with common names will - be preserved separately, with ".tip" and ".node" appended - to the names. This argument has no effect if - \code{tip.data} and \code{node.data} have no column names - in common.} +\item{merge.data}{if both \code{tip.data} and \code{node.data} are provided, +it determines whether columns with common names will be merged together +(default TRUE). If FALSE, columns with common names will be preserved +separately, with ".tip" and ".node" appended to the names. This argument has +no effect if \code{tip.data} and \code{node.data} have no column names in +common.} - \item{pos}{should the new data provided be bound - \code{before} or \code{after} the pre-existing data?} +\item{pos}{should the new data provided be bound \code{before} or +\code{after} the pre-existing data?} - \item{\dots}{additional arguments to be passed to - \link{formatData}} +\item{\dots}{additional arguments to be passed to \link{formatData}} } \value{ \code{addData} returns a \code{phylo4d} object. } \description{ -\code{addData} adds data to a \code{phylo4} (converting it -in a \code{phylo4d} object) or to a \code{phylo4d} object +\code{addData} adds data to a \code{phylo4} (converting it in a +\code{phylo4d} object) or to a \code{phylo4d} object } \details{ -Rules for matching data to tree nodes are identical to -those used by the \code{\link{phylo4d}} constructor. +Rules for matching data to tree nodes are identical to those used by the +\code{\link{phylo4d}} constructor. -If any column names in the original data are the same as -columns in the new data, ".old" is appended to the former -column names and ".new" is appended to the new column -names. +If any column names in the original data are the same as columns in the new +data, ".old" is appended to the former column names and ".new" is appended +to the new column names. -The option \code{pos} is ignored (silently) if \code{x} is -a \code{phylo4} object. It is provided for compatibility -reasons. +The option \code{pos} is ignored (silently) if \code{x} is a \code{phylo4} +object. It is provided for compatibility reasons. } \examples{ data(geospiza) Modified: pkg/man/ancestors.Rd =================================================================== --- pkg/man/ancestors.Rd 2014-05-06 20:26:32 UTC (rev 933) +++ pkg/man/ancestors.Rd 2014-05-06 20:26:51 UTC (rev 934) @@ -1,3 +1,4 @@ +% Generated by roxygen2 (4.0.0): do not edit by hand \name{ancestor} \alias{ancestor} \alias{ancestors} @@ -17,72 +18,70 @@ ancestors(phy, node, type = c("all", "parent", "ALL")) } \arguments{ - \item{phy}{a \linkS4class{phylo4} object (or one - inheriting from \linkS4class{phylo4}, e.g. a - \linkS4class{phylo4d} object)} +\item{phy}{a \linkS4class{phylo4} object (or one inheriting from +\linkS4class{phylo4}, e.g. a \linkS4class{phylo4d} object)} - \item{node}{either an integer corresponding to a node ID - number, or a character corresponding to a node label; for - \code{ancestors} and \code{descendants}, this may be a - vector of multiple node numbers or names} +\item{node}{either an integer corresponding to a node ID number, or a +character corresponding to a node label; for \code{ancestors} and +\code{descendants}, this may be a vector of multiple node numbers or names} - \item{type}{(\code{ancestors}) specify whether to return - just direct ancestor ("parent"), all ancestor nodes - ("all"), or all ancestor nodes including self ("ALL"); - (\code{descendants}) specify whether to return just - direct descendants ("children"), all extant descendants - ("tips"), or all descendant nodes ("all")} +\item{type}{(\code{ancestors}) specify whether to return just direct +ancestor ("parent"), all ancestor nodes ("all"), or all ancestor nodes +including self ("ALL"); (\code{descendants}) specify whether to return just +direct descendants ("children"), all extant descendants ("tips"), or all +descendant nodes ("all")} - \item{include.self}{whether to include self in list of - siblings} +\item{include.self}{whether to include self in list of siblings} - \item{\dots}{a list of node numbers or names, or a vector - of node numbers or names} +\item{\dots}{a list of node numbers or names, or a vector of node numbers or +names} } \value{ -\describe{ \item{\code{ancestors}}{ return a named vector -(or a list of such vectors in the case of multiple input -nodes) of the ancestors and descendants of a node} - -\item{\code{descendants}}{ return a named vector (or a list +\describe{ +\item{\code{ancestors}}{ return a named vector (or a list of such vectors in the case of multiple input nodes) of the ancestors and descendants of a node} +\item{\code{descendants}}{ return a named vector (or a list of +such vectors in the case of multiple input nodes) of the ancestors +and descendants of a node} + \item{\code{ancestor}}{ \code{ancestor} is analogous to -\code{ancestors(\dots{}, type="parent")} (i.e. direct -ancestor only), but returns a single concatenated vector in -the case of multiple input nodes} +\code{ancestors(\dots{}, type="parent")} (i.e. direct ancestor +only), but returns a single concatenated vector in the case of +multiple input nodes} -\item{\code{children}}{is analogous to -\code{descendants(\dots{}, type="children")} (i.e. direct -descendants only), but is not currently intended to be used -with multiple input nodes } +\item{\code{children}}{is analogous to \code{descendants(\dots{}, +type="children")} (i.e. direct descendants only), but is not +currently intended to be used with multiple input nodes } -\item{\code{siblings}}{ returns sibling nodes (children of -the same parent)} } +\item{\code{siblings}}{ returns sibling nodes (children of the same +parent)} } +} \description{ -Functions for describing relationships among phylogenetic -nodes (i.e. internal nodes or tips). +Functions for describing relationships among phylogenetic nodes (i.e. +internal nodes or tips). } \details{ -\code{ancestors} and \code{descendants} can take -\code{node} vectors of arbitrary length, returning a list -of output vectors if the number of valid input nodes is -greater than one. List element names are taken directly -from the input node vector. +\code{ancestors} and \code{descendants} can take \code{node} vectors of +arbitrary length, returning a list of output vectors if the number of valid +input nodes is greater than one. List element names are taken directly from +the input node vector. -If any supplied nodes are not found in the tree, the -behavior currently varies across functions. \itemize{ \item -Invalid nodes are automatically omitted by \code{ancestors} +If any supplied nodes are not found in the tree, the behavior currently +varies across functions. +\itemize{ +\item Invalid nodes are automatically omitted by \code{ancestors} and \code{descendants}, with a warning. -\item \code{ancestor} will return \code{NA} for any invalid -nodes, with a warning. +\item \code{ancestor} +will return \code{NA} for any invalid nodes, with a warning. -\item Both \code{children} and \code{siblings} will return -an empty vector, again with a warning. } +\item Both \code{children} and \code{siblings} will return an empty +vector, again with a warning. } +} \examples{ data(geospiza) nodeLabels(geospiza) <- LETTERS[1:nNodes(geospiza)] @@ -103,7 +102,7 @@ sumEdgeLength(geospiza, ancestors(geospiza, "fortis", type="ALL")) } \seealso{ -\code{\link[ape]{mrca}}, in the ape package, gives a list -of all subtrees +\code{\link[ape]{mrca}}, in the ape package, gives a list of all +subtrees } Modified: pkg/man/checkPhylo4.Rd =================================================================== --- pkg/man/checkPhylo4.Rd 2014-05-06 20:26:32 UTC (rev 933) +++ pkg/man/checkPhylo4.Rd 2014-05-06 20:26:51 UTC (rev 934) @@ -1,3 +1,4 @@ +% Generated by roxygen2 (4.0.0): do not edit by hand \name{checkPhylo4} \alias{checkPhylo4} \alias{checkPhylo4Data} @@ -7,59 +8,50 @@ checkPhylo4(object) } \arguments{ - \item{object}{A prospective phylo4 or phylo4d object} +\item{object}{A prospective phylo4 or phylo4d object} } \value{ -As required by \code{\link[methods]{validObject}}, returns -an error string (describing problems) or TRUE if everything -is OK. +As required by \code{\link[methods]{validObject}}, returns an error +string (describing problems) or TRUE if everything is OK. } \description{ Basic checks on the validity of S4 phylogenetic objects } \note{ -These functions are only intended to be called by other -phylobase functions. +These functions are only intended to be called by other phylobase functions. -\code{checkPhylo4} is an (inflexible) wrapper for -\code{checkTree}. The rules for \code{phylo4} objects -essentially follow those for \code{phylo} objects from the -\code{ape} package, which are in turn defined in -\url{http://ape.mpl.ird.fr/misc/FormatTreeR_28July2008.pdf}. -These are essentially that: \itemize{ \item if the tree has -edge lengths defined, the number of edge lengths must match -the number of edges; \item the number of tip labels must -match the number of tips; \item in a tree with \code{ntips} -tips and \code{nnodes} (total) nodes, nodes 1 to -\code{ntips} must be tips \item if the tree is rooted, the -root must be node number \code{ntips+1} and the root node -must be the first row of the edge matrix \item tip labels, -node labels, edge labels, edge lengths must have proper -internal names (i.e. internal names that match the node -numbers they document) \item tip and node labels must be -unique } +\code{checkPhylo4} is an (inflexible) wrapper for \code{checkTree}. The +rules for \code{phylo4} objects essentially follow those for \code{phylo} +objects from the \code{ape} package, which are in turn defined in +\url{http://ape.mpl.ird.fr/misc/FormatTreeR_28July2008.pdf}. These are +essentially that: \itemize{ \item if the tree has edge lengths defined, the +number of edge lengths must match the number of edges; \item the number of +tip labels must match the number of tips; \item in a tree with \code{ntips} +tips and \code{nnodes} (total) nodes, nodes 1 to \code{ntips} must be tips +\item if the tree is rooted, the root must be node number \code{ntips+1} and +the root node must be the first row of the edge matrix \item tip labels, +node labels, edge labels, edge lengths must have proper internal names (i.e. +internal names that match the node numbers they document) \item tip and node +labels must be unique } -You can alter some of the default options by using the -function \code{phylobase.options}. +You can alter some of the default options by using the function +\code{phylobase.options}. For \code{phylo4d} objects, \code{checkTree} also calls -\code{checkPhylo4Data} to check the validity of the data -associated with the tree. It ensures that (1) the data -associated with the tree have the correct dimensions, (2) -that the row names for the data are correct. +\code{checkPhylo4Data} to check the validity of the data associated with the +tree. It ensures that (1) the data associated with the tree have the correct +dimensions, (2) that the row names for the data are correct. } \author{ Ben Bolker, Steven Kembel, Francois Michonneau } \seealso{ -the \code{\link{phylo4}} constructor and -\linkS4class{phylo4} class; \code{\link{formatData}}, the -\code{\link{phylo4d}} constructor and the -\linkS4class{phylo4d} class do checks for the data -associated with trees. See \code{\link{coerce-methods}} -for translation functions and -\code{\link{phylobase.options} to change some of the -default options of the validator.} +the \code{\link{phylo4}} constructor and \linkS4class{phylo4} +class; \code{\link{formatData}}, the \code{\link{phylo4d}} constructor and +the \linkS4class{phylo4d} class do checks for the data associated with +trees. See \code{\link{coerce-methods}} for translation functions and +\code{\link{phylobase.options} to change some of the default options of the +validator.} } \keyword{misc} Modified: pkg/man/edgeLength-methods.Rd =================================================================== --- pkg/man/edgeLength-methods.Rd 2014-05-06 20:26:32 UTC (rev 933) +++ pkg/man/edgeLength-methods.Rd 2014-05-06 20:26:51 UTC (rev 934) @@ -1,3 +1,4 @@ +% Generated by roxygen2 (4.0.0): do not edit by hand \docType{methods} \name{hasEdgeLength} \alias{depthTips} @@ -45,52 +46,47 @@ \S4method{isUltrametric}{phylo4}(x, tol = .Machine$double.eps^0.5) } \arguments{ - \item{x}{a \code{phylo4} or \code{phylo4d} object.} +\item{x}{a \code{phylo4} or \code{phylo4d} object.} - \item{value}{a numeric vector indicating the new values - for the edge lengths} +\item{value}{a numeric vector indicating the new values for the edge lengths} - \item{node}{optional numeric or character vector - indicating the nodes for which edge} +\item{node}{optional numeric or character vector indicating the +nodes for which edge} - \item{use.names}{should the the name attributes of - \code{value} be used to match the length to a given - edge.} +\item{use.names}{should the the name attributes of \code{value} be +used to match the length to a given edge.} - \item{tol}{the tolerance to decide whether all the tips - have the same depth to test if the tree is ultrametric. - Default is \code{.Machine$double.eps^0.5}.} +\item{tol}{the tolerance to decide whether all the tips have the +same depth to test if the tree is ultrametric. Default is +\code{.Machine$double.eps^0.5}.} - \item{\dots}{optional arguments (none used at present).} +\item{\dots}{optional arguments (none used at present).} } \value{ \describe{ -\item{hasEdgeLength}{whether or not the object has edge -lengths (logical)} +\item{hasEdgeLength}{whether or not the object has edge lengths +(logical)} \item{edgeLength}{a named vector of the edge length for the object} -\item{nodeDepth}{a named vector indicating the -\dQuote{depth} (the distance between the root and the tip) -of each tip.} +\item{nodeDepth}{a named vector indicating the \dQuote{depth} (the +distance between the root and the tip) of each tip.} -\item{isUltrametric}{whether or not the tree is ultrametric -(all the tips are have the same depth (distance from the -root) (logical)} +\item{isUltrametric}{whether or not the tree is ultrametric (all +the tips are have the same depth (distance from the root) (logical)} -\item{sumEdgeLength}{the sum of the edge lengths for a set -of nodes (intended to be used with \code{ancestors} or -\code{descendants})} } +\item{sumEdgeLength}{the sum of the edge lengths for a set of +nodes (intended to be used with \code{ancestors} or \code{descendants})} } +} \description{ -These functions give information about and allow -replacement of edge lengths. +These functions give information about and allow replacement of edge lengths. } \details{ -The \code{edgeLength} function returns the edge length in -the same order as the edges in the matrix. +The \code{edgeLength} function returns the edge length in the same +order as the edges in the matrix. } \examples{ data(geospiza) Modified: pkg/man/edges-accessors.Rd =================================================================== --- pkg/man/edges-accessors.Rd 2014-05-06 20:26:32 UTC (rev 933) +++ pkg/man/edges-accessors.Rd 2014-05-06 20:26:51 UTC (rev 934) @@ -1,3 +1,4 @@ +% Generated by roxygen2 (4.0.0): do not edit by hand \docType{methods} \name{edges} \alias{edgeOrder} @@ -27,31 +28,29 @@ \S4method{terminalEdges}{phylo4}(x) } \arguments{ - \item{x}{a \code{phylo4} or \code{phylo4d} object.} +\item{x}{a \code{phylo4} or \code{phylo4d} object.} - \item{drop.root}{logical (default FALSE), should the edge - connecting the root be included in the edge matrix?} +\item{drop.root}{logical (default FALSE), should the edge +connecting the root be included in the edge matrix?} - \item{\dots}{Optional arguments used by specific methods. - (None used at present).} +\item{\dots}{Optional arguments used by specific methods. (None +used at present).} } \value{ -\describe{ \item{\code{edges}}{returns the edge matrix that -represent the ancestor-descendant relationships among the -nodes of the tree.} +\describe{ +\item{\code{edges}}{returns the edge matrix that represent the +ancestor-descendant relationships among the nodes of the tree.} -\item{\code{edgeOrder}}{returns the order in which the edge -matrix is in.} +\item{\code{edgeOrder}}{returns the order in which the edge matrix +is in.} -\item{\code{internalEdges}}{returns a logical vector -indicating internal edges (edges that connect an internal -node to another). This vector is named with the -\code{edgeId}}. +\item{\code{internalEdges}}{returns a logical vector indicating +internal edges (edges that connect an internal node to +another). This vector is named with the \code{edgeId}}. -\item{\code{terminalEdges}}{returns a logical vector -indicating terminal edges (edges that connect an internal -node to a tip). This vector is named with the \code{edgeId} -}} +\item{\code{terminalEdges}}{returns a logical vector indicating +terminal edges (edges that connect an internal node to a +tip). This vector is named with the \code{edgeId} }} } \description{ Access or modify information about the edges. Modified: pkg/man/extractTree.Rd =================================================================== --- pkg/man/extractTree.Rd 2014-05-06 20:26:32 UTC (rev 933) +++ pkg/man/extractTree.Rd 2014-05-06 20:26:51 UTC (rev 934) @@ -1,3 +1,4 @@ +% Generated by roxygen2 (4.0.0): do not edit by hand \name{extractTree} \alias{extractTree} \title{Get tree from tree+data object} @@ -5,22 +6,21 @@ extractTree(from) } \arguments{ - \item{from}{a \code{phylo4d} object, containing a - phylogenetic tree plus associated phenotypic data. - Created by the \code{phylo4d()} function.} +\item{from}{a \code{phylo4d} object, containing a phylogenetic +tree plus associated phenotypic data. Created by the +\code{phylo4d()} function.} } \description{ Extracts a \code{phylo4} tree object from a \code{phylo4d} tree+data object. } \details{ -\code{extractTree} extracts just the phylogeny from a -tree+data object. The phylogeny contains the topology (how -the nodes are linked together), the branch lengths (if -any), and any tip and/or node labels. This may be useful -for extracting a tree from a \code{phylo4d} object, and -associating with another phenotypic dataset, or to convert -the tree to another format. +\code{extractTree} extracts just the phylogeny from a tree+data +object. The phylogeny contains the topology (how the nodes are +linked together), the branch lengths (if any), and any tip and/or +node labels. This may be useful for extracting a tree from a +\code{phylo4d} object, and associating with another phenotypic +dataset, or to convert the tree to another format. } \examples{ tree.phylo <- ape::read.tree(text = "((a,b),c);") Modified: pkg/man/formatData.Rd =================================================================== --- pkg/man/formatData.Rd 2014-05-06 20:26:32 UTC (rev 933) +++ pkg/man/formatData.Rd 2014-05-06 20:26:51 UTC (rev 934) @@ -1,3 +1,4 @@ +% Generated by roxygen2 (4.0.0): do not edit by hand \name{formatData} \alias{formatData} \title{Format data for use in phylo4d objects} @@ -8,85 +9,80 @@ extra.data = c("warn", "OK", "fail"), keep.all = TRUE) } \arguments{ - \item{phy}{a valid \code{phylo4} object} +\item{phy}{a valid \code{phylo4} object} - \item{dt}{a data frame, matrix, vector, or factor} +\item{dt}{a data frame, matrix, vector, or factor} - \item{type}{type of data to attach} +\item{type}{type of data to attach} - \item{match.data}{(logical) should the rownames of the - data frame be used to be matched against tip and internal - node identifiers? See details.} +\item{match.data}{(logical) should the rownames of the data frame +be used to be matched against tip and internal node identifiers? +See details.} - \item{rownamesAsLabels}{(logical), should the row names - of the data provided be matched only to labels (TRUE), or - should any number-like row names be matched to node - numbers (FALSE and default)} +\item{rownamesAsLabels}{(logical), should the row names of the +data provided be matched only to labels (TRUE), or should any +number-like row names be matched to node numbers (FALSE and +default)} - \item{label.type}{character, \code{rownames} or - \code{column}: should the labels be taken from the row - names of \code{dt} or from the \code{label.column} column - of \code{dt}?} +\item{label.type}{character, \code{rownames} or \code{column}: +should the labels be taken from the row names of \code{dt} or from +the \code{label.column} column of \code{dt}?} - \item{label.column}{if \code{label.type=="column"}, - column specifier (number or name) of the column - containing tip labels} +\item{label.column}{if \code{label.type=="column"}, column +specifier (number or name) of the column containing tip labels} - \item{missing.data}{action to take if there are missing - data or if there are data labels that don't match} +\item{missing.data}{action to take if there are missing data or if +there are data labels that don't match} - \item{extra.data}{action to take if there are extra data - or if there are labels that don't match} +\item{extra.data}{action to take if there are extra data or if +there are labels that don't match} - \item{keep.all}{(logical), should the returned data have - rows for all nodes (with NA values for internal rows when - type='tip', and vice versa) (TRUE and default) or only - rows corresponding to the type argument} +\item{keep.all}{(logical), should the returned data have rows for +all nodes (with NA values for internal rows when type='tip', and +vice versa) (TRUE and default) or only rows corresponding to the +type argument} } \value{ \code{formatData} returns a data frame having node numbers -as row names. The data frame is also formatted to have the -correct dimension given the \code{phylo4} object provided. +as row names. The data frame is also formatted to have the correct +dimension given the \code{phylo4} object provided. } \description{ -Associates data with tree nodes and applies consistent -formatting rules. +Associates data with tree nodes and applies consistent formatting +rules. } \details{ -\code{formatData} is an internal function that should not -be called directly by the user. It is used to format data -provided by the user before associating it with a tree, and -is called internally by the \code{phylo4d}, \code{tdata}, -and \code{addData} methods. However, users may pass -additional arguments to these methods in order to control -how the data are matched to nodes. +\code{formatData} is an internal function that should not be +called directly by the user. It is used to format data provided by +the user before associating it with a tree, and is called +internally by the \code{phylo4d}, \code{tdata}, and \code{addData} +methods. However, users may pass additional arguments to these +methods in order to control how the data are matched to nodes. -Rules for matching rows of data to tree nodes are -determined jointly by the \code{match.data} and -\code{rownamesAsLabels} arguments. If \code{match.data} is -TRUE, data frame rows will be matched exclusively against -tip and node labels if \code{rownamesAsLabels} is also -TRUE, whereas any all-digit row names will be matched -against tip and node numbers if \code{rownamesAsLabels} is -FALSE (the default). If \code{match.data} is FALSE, -\code{rownamesAsLabels} has no effect, and row matching is -purely positional with respect to the order returned by -\code{nodeId(phy, type)}. +Rules for matching rows of data to tree nodes are determined +jointly by the \code{match.data} and \code{rownamesAsLabels} +arguments. If \code{match.data} is TRUE, data frame rows will be +matched exclusively against tip and node labels if +\code{rownamesAsLabels} is also TRUE, whereas any all-digit row +names will be matched against tip and node numbers if +\code{rownamesAsLabels} is FALSE (the default). If +\code{match.data} is FALSE, \code{rownamesAsLabels} has no effect, +and row matching is purely positional with respect to the order +returned by \code{nodeId(phy, type)}. -\code{formatData} (1) converts labels provided in the data -into node numbers, (2) makes sure that the data are -appropriately matched against tip and/or internal nodes, -(3) checks for differences between data and tree, (4) -creates a data frame with the correct dimensions given a -tree. +\code{formatData} (1) converts labels provided in the data into +node numbers, (2) makes sure that the data are appropriately +matched against tip and/or internal nodes, (3) checks for +differences between data and tree, (4) creates a data frame with +the correct dimensions given a tree. } \author{ Francois Michonneau } \seealso{ the \code{\link{phylo4d}} constructor, the -\linkS4class{phylo4d} class. See -\code{\link{coerce-methods}} for translation functions. +\linkS4class{phylo4d} class. See \code{\link{coerce-methods}} for +translation functions. } \keyword{misc} Modified: pkg/man/geospiza.Rd =================================================================== --- pkg/man/geospiza.Rd 2014-05-06 20:26:32 UTC (rev 933) +++ pkg/man/geospiza.Rd 2014-05-06 20:26:51 UTC (rev 934) @@ -1,3 +1,4 @@ +% Generated by roxygen2 (4.0.0): do not edit by hand \docType{data} \name{geospiza} \alias{geospiza} @@ -11,12 +12,12 @@ Dolph Schluter via Luke Harmon } \description{ -Phylogenetic tree and morphological data for Darwin's -finches, in different formats +Phylogenetic tree and morphological data for Darwin's finches, in different +formats } \note{ -Stolen from Luke Harmon's Geiger package, to avoid -unnecessary dependencies +Stolen from Luke Harmon's Geiger package, to avoid unnecessary +dependencies } \examples{ data(geospiza) Modified: pkg/man/getNode-methods.Rd =================================================================== --- pkg/man/getNode-methods.Rd 2014-05-06 20:26:32 UTC (rev 933) +++ pkg/man/getNode-methods.Rd 2014-05-06 20:26:51 UTC (rev 934) @@ -1,3 +1,4 @@ +% Generated by roxygen2 (4.0.0): do not edit by hand \docType{methods} \name{getNode} \alias{getEdge} @@ -20,70 +21,57 @@ missing = c("warn", "OK", "fail")) } \arguments{ - \item{x}{a \linkS4class{phylo4} object (or one inheriting - from \linkS4class{phylo4}, e.g. a \linkS4class{phylo4d} - object)} +\item{x}{a \linkS4class{phylo4} object (or one inheriting from +\linkS4class{phylo4}, e.g. a \linkS4class{phylo4d} object)} - \item{node}{either an integer vector corresponding to - node ID numbers, or a character vector corresponding to - node labels; if missing, all nodes appropriate to the - specified type will be returned by \code{getNode}, and - all edges appropriate to the specified type will be - returned by \code{getEdge}.} +\item{node}{either an integer vector corresponding to node ID numbers, or a +character vector corresponding to node labels; if missing, all nodes +appropriate to the specified type will be returned by \code{getNode}, and +all edges appropriate to the specified type will be returned by +\code{getEdge}.} - \item{type}{(\code{getNode}) specify whether to return - nodes matching "all" tree nodes (default), only "tip" - nodes, or only "internal" nodes; (\code{nodeId, edgeId}) - specify whether to return "all" tree nodes, or only those - corresponding to "tip", "internal", or "root" nodes; - (\code{getEdge}) specify whether to look up edges based - on their descendant node ("descendant") or ancestral node - ("ancestor")} +\item{type}{(\code{getNode}) specify whether to return nodes matching "all" +tree nodes (default), only "tip" nodes, or only "internal" nodes; +(\code{nodeId, edgeId}) specify whether to return "all" tree nodes, or only +those corresponding to "tip", "internal", or "root" nodes; (\code{getEdge}) +specify whether to look up edges based on their descendant node +("descendant") or ancestral node ("ancestor")} - \item{missing}{what to do if some requested node IDs or - names are not in the tree: warn, do nothing, or stop with - an error} +\item{missing}{what to do if some requested node IDs or names are not in the +tree: warn, do nothing, or stop with an error} } \value{ -\item{list("getNode")}{returns a named integer vector of -node IDs, in the order of input nodes if provided, -otherwise in nodeId order} \item{list("getEdge")}{returns a -named character vector of edge IDs, in the order of input -nodes if provide, otherwise in nodeId order} -\item{list("nodeId")}{returns an unnamed integer vector of -node IDs, in ascending order} -\item{list("getEdge")}{returns an unnamed character vector +\item{list("getNode")}{returns a named integer vector of node IDs, +in the order of input nodes if provided, otherwise in nodeId order} +\item{list("getEdge")}{returns a named character vector of edge IDs, in the +order of input nodes if provide, otherwise in nodeId order} +\item{list("nodeId")}{returns an unnamed integer vector of node IDs, in +ascending order} \item{list("getEdge")}{returns an unnamed character vector of edge IDs, in edge matrix order} } \description{ -Functions for retrieving node and edge IDs (possibly with -corresponding labels) from a phylogenetic tree. +Functions for retrieving node and edge IDs (possibly with corresponding +labels) from a phylogenetic tree. } \details{ -\code{getNode} and \code{getEdge} are primarily intended -for looking up the IDs either of nodes themselves or of -edges associated with those nodes. Note that they behave -quite differently. With \code{getNode}, any input nodes are -looked up against tree nodes of the specified type, and -those that match are returned as numeric node IDs with node -labels (if they exist) as element names. With -\code{getEdge}, any input nodes are looked up against edge -ends of the specified type, and those that match are -returned as character edge IDs with the corresponding node -ID as element names. +\code{getNode} and \code{getEdge} are primarily intended for looking up the +IDs either of nodes themselves or of edges associated with those nodes. Note +that they behave quite differently. With \code{getNode}, any input nodes are +looked up against tree nodes of the specified type, and those that match are [TRUNCATED] To get the complete diff run: svnlook diff /svnroot/phylobase -r 934 From noreply at r-forge.r-project.org Tue May 6 22:27:46 2014 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Tue, 6 May 2014 22:27:46 +0200 (CEST) Subject: [Phylobase-commits] r935 - in pkg: inst/unitTests tests/testthat Message-ID: <20140506202746.54525187632@r-forge.r-project.org> Author: francois Date: 2014-05-06 22:27:46 +0200 (Tue, 06 May 2014) New Revision: 935 Added: pkg/tests/testthat/test.checkdata.R Removed: pkg/inst/unitTests/runit.checkdata.R Log: converted checkdata tests to testthat Deleted: pkg/inst/unitTests/runit.checkdata.R =================================================================== --- pkg/inst/unitTests/runit.checkdata.R 2014-05-06 20:26:51 UTC (rev 934) +++ pkg/inst/unitTests/runit.checkdata.R 2014-05-06 20:27:46 UTC (rev 935) @@ -1,69 +0,0 @@ -# -# --- Test checkdata.R --- -# - -if (Sys.getenv("RCMDCHECK") == FALSE) { - pth <- file.path(getwd(), "..", "inst", "nexusfiles") -} else { - pth <- system.file(package="phylobase", "nexusfiles") -} -## co1.nex -- typical output from MrBayes. Contains 2 identical trees, the first -## one having posterior probabilities as node labels -co1File <- file.path(pth, "co1.nex") - -# create phylo4 object with a full complement of valid slots -ancestor <- as.integer(c(6,7,7,6,8,0,8,9,9)) -descendant <- as.integer(c(7,1,2,8,3,6,9,4,5)) -edge <- cbind(ancestor, descendant) -nid.tip <- 1:5 -nid.int <- 6:9 -nid.all <- c(nid.tip, nid.int) -lab.tip <- paste("t", nid.tip, sep="") -lab.int <- paste("n", nid.int, sep="") -lab.all <- c(lab.tip, lab.int) -elen <- descendant/10 -elab <- paste("e", ancestor, descendant, sep="-") -phy <- phylo4(x=edge, tip.label=lab.tip, node.label=lab.int, - edge.length=elen, edge.label=elab) - -op <- phylobase.options() - -checkPhylo4 <- function() { -} - -checkTree <- function() { - ## test polytomies - phylobase.options(poly="fail") - checkException(readNexus(file=co1File, check.node.labels="drop")) - phylobase.options(op) - - ## test retic - phylobase.options(retic="fail") - edgeRetic <- rbind(edge, c(6, 3)) - checkException(phy <- phylo4(x=edgeRetic)) - phylobase.options(op) - - ## test multiroot - phylobase.options(multiroot="fail") - edgeMultiRoot <- rbind(edge, c(7, 0)) - checkException(phy <- phylo4(x=edgeMultiRoot)) - phylobase.options(op) - - ## test singleton - phylobase.options(singleton="fail") - edgeSingleton <- cbind(c(9,7,7,6,6,8,8,10,10,0), 1:10) - checkException(phylo4(x=edgeSingleton)) - phylobase.options(op) -} - -checkPhylo4Data <- function() { -} - -formatData <- function() { - # 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"), rownamesAsLabels=FALSE) -} - - Copied: pkg/tests/testthat/test.checkdata.R (from rev 880, pkg/inst/unitTests/runit.checkdata.R) =================================================================== --- pkg/tests/testthat/test.checkdata.R (rev 0) +++ pkg/tests/testthat/test.checkdata.R 2014-05-06 20:27:46 UTC (rev 935) @@ -0,0 +1,70 @@ +# +# --- Test checkdata.R --- +# + +if (Sys.getenv("RCMDCHECK") == FALSE) { + pth <- file.path(getwd(), "..", "inst", "nexusfiles") +} else { + pth <- system.file(package="phylobase", "nexusfiles") +} +## co1.nex -- typical output from MrBayes. Contains 2 identical trees, the first +## one having posterior probabilities as node labels +co1File <- file.path(pth, "co1.nex") + +# create phylo4 object with a full complement of valid slots +ancestor <- as.integer(c(6,7,7,6,8,0,8,9,9)) +descendant <- as.integer(c(7,1,2,8,3,6,9,4,5)) +edge <- cbind(ancestor, descendant) +nid.tip <- 1:5 +nid.int <- 6:9 +nid.all <- c(nid.tip, nid.int) +lab.tip <- paste("t", nid.tip, sep="") +lab.int <- paste("n", nid.int, sep="") +lab.all <- c(lab.tip, lab.int) +elen <- descendant/10 +elab <- paste("e", ancestor, descendant, sep="-") +phy <- phylo4(x=edge, tip.label=lab.tip, node.label=lab.int, + edge.length=elen, edge.label=elab) + +op <- phylobase.options() + +context("test phylo4 validator/phylobase.options()") + +test_that("test polytomies", { + phylobase.options(poly="fail") + expect_error(readNexus(file=co1File, check.node.labels="drop")) + phylobase.options(op) +}) + +test_that("test retic", { + phylobase.options(retic="fail") + edgeRetic <- rbind(edge, c(6, 3)) + expect_error(phy <- phylo4(x=edgeRetic)) + phylobase.options(op) +}) + +test_that("test multiroot", { + phylobase.options(multiroot="fail") + edgeMultiRoot <- rbind(edge, c(0, 7)) + expect_error(phy <- phylo4(x=edgeMultiRoot)) + phylobase.options(op) +}) + +test_that("test singleton", { + phylobase.options(singleton="fail") + edgeSingleton <- cbind(c(9,7,7,6,6,8,8,10,10,0), 1:10) + expect_error(phylo4(x=edgeSingleton)) + phylobase.options(op) +}) + +## checkPhylo4Data <- function() { +## } + +## formatData <- function() { +## # 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"), rownamesAsLabels=FALSE) +## } + + From noreply at r-forge.r-project.org Tue May 6 22:28:21 2014 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Tue, 6 May 2014 22:28:21 +0200 (CEST) Subject: [Phylobase-commits] r936 - pkg Message-ID: <20140506202821.6A01B187639@r-forge.r-project.org> Author: francois Date: 2014-05-06 22:28:21 +0200 (Tue, 06 May 2014) New Revision: 936 Modified: pkg/DESCRIPTION Log: added explicit option for roxygen to avoid warning Modified: pkg/DESCRIPTION =================================================================== --- pkg/DESCRIPTION 2014-05-06 20:27:46 UTC (rev 935) +++ pkg/DESCRIPTION 2014-05-06 20:28:21 UTC (rev 936) @@ -1,3 +1,4 @@ +Roxygen: list(wrap = FALSE) Package: phylobase Type: Package Title: Base package for phylogenetic structures and comparative data From noreply at r-forge.r-project.org Wed May 7 16:56:51 2014 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Wed, 7 May 2014 16:56:51 +0200 (CEST) Subject: [Phylobase-commits] r937 - in pkg: inst/unitTests tests/testthat Message-ID: <20140507145651.957F3187493@r-forge.r-project.org> Author: francois Date: 2014-05-07 16:56:51 +0200 (Wed, 07 May 2014) New Revision: 937 Added: pkg/tests/testthat/test.class-phylo4.R Removed: pkg/inst/unitTests/runit.class-phylo4.R Log: moved/convert class-phylo4 tests Deleted: pkg/inst/unitTests/runit.class-phylo4.R =================================================================== --- pkg/inst/unitTests/runit.class-phylo4.R 2014-05-06 20:28:21 UTC (rev 936) +++ pkg/inst/unitTests/runit.class-phylo4.R 2014-05-07 14:56:51 UTC (rev 937) @@ -1,99 +0,0 @@ -# -# --- Test class-phylo4.R --- -# - -op <- phylobase.options() - -test.phylo4.matrix <- function() { - edge <- structure(c(6L, 7L, 8L, 8L, 9L, 9L, 7L, 6L, 7L, 8L, 1L, 9L, - 2L, 3L, 4L, 5L), .Dim = c(8, 2)) - edge.length <- c(0.2, 0.5, 0.2, 0.15, 0.1, 0.1, 0.7, 1) - tip.label <- paste("t", 1:5, sep="") - node.label <- paste("n", 1:4, sep="") - edge.label <- paste("e", 1:8, sep="") - order="preorder" - annote <- list(x="annotation") - phy <- phylo4(edge, edge.length=edge.length, tip.label=tip.label, - node.label=node.label, edge.label=edge.label, order=order, - annote=annote) - - # test each slot - checkIdentical(edge, unname(edges(phy))) - checkIdentical(edge.length, unname(edgeLength(phy))) - checkIdentical(4L, nNodes(phy)) - checkIdentical(tip.label, unname(tipLabels(phy))) - checkIdentical(node.label, unname(nodeLabels(phy))) - checkIdentical(edge.label, unname(edgeLabels(phy))) - checkIdentical(order, edgeOrder(phy)) - checkIdentical(annote, phy at annote) - - # test improper cases - #checkException(phylo4(edge, edge.length=999)) # recycling is allowed? - checkException(phylo4(edge, tip.label=999)) - checkException(phylo4(edge, node.label=999)) - #checkException(phylo4(edge, edge.label=999)) # recycling is allowed? - checkException(phylo4(edge, order="invalid order")) - checkException(phylo4(edge, annote="invalid annotation")) -} - - -# note: this method mostly just wraps phylo->phylo4 coercion, which is -# tested more thoroughly in runit.setAs-methods.R; focus here is on -# annote and check.node.labels arguments -test.phylo4.phylo <- function() { - tr <- ape::read.tree(text="(((t1:0.2,(t2:0.1,t3:0.1):0.15):0.5,t4:0.7):0.2,t5:1):0.4;") - - - ## - ## annote - ## - - annote <- list(x="annotation") - phy <- phylo4(tr, annote=annote) - checkIdentical(annote, phy at annote) - - ## - ## check.node.labels - ## - - # case 0: no node labels - phy <- phylo4(tr) - checkTrue(!hasNodeLabels(phy)) - - # case 1: keep unique character labels - tr$node.label <- paste("n", 1:4, sep="") - phy <- phylo4(tr, check.node.labels="keep") - checkIdentical(tr$node.label, unname(nodeLabels(phy))) - # keeping node labels should be the default - checkIdentical(phy, phylo4(tr)) - - # case 2: keep unique number-like character labels - tr$node.label <- as.character(1:4) - phy <- phylo4(tr, check.node.labels="keep") - checkIdentical(tr$node.label, unname(nodeLabels(phy))) - - # case 3: keep unique numeric labels, but convert to character - tr$node.label <- as.numeric(1:4) - phy <- phylo4(tr, check.node.labels="keep") - checkIdentical(as.character(tr$node.label), unname(nodeLabels(phy))) - - # case 4: must drop non-unique labels - tr$node.label <- rep("x", 4) - ## with options allow.duplicated.labels="fail" - phylobase.options(allow.duplicated.labels="fail") - checkException(phylo4(tr)) - checkException(phylo4(tr, check.node.labels="keep")) - phylobase.options(op) - ## test dropping node labels - phy <- phylo4(tr, check.node.labels="drop") - checkTrue(!hasNodeLabels(phy)) - ## with options allow.duplicated.labels="ok" - phylobase.options(allow.duplicated.labels="ok") - phy <- phylo4(tr) - checkIdentical(unname(nodeLabels(phy)), tr$node.label) - phy <- phylo4(tr, check.node.labels="keep") - checkIdentical(unname(nodeLabels(phy)), tr$node.label) - phy <- phylo4(tr, check.node.labels="drop") - checkTrue(!hasNodeLabels(phy)) - phylobase.options(op) -} Copied: pkg/tests/testthat/test.class-phylo4.R (from rev 880, pkg/inst/unitTests/runit.class-phylo4.R) =================================================================== --- pkg/tests/testthat/test.class-phylo4.R (rev 0) +++ pkg/tests/testthat/test.class-phylo4.R 2014-05-07 14:56:51 UTC (rev 937) @@ -0,0 +1,101 @@ +# +# --- Test class-phylo4.R --- +# + +op <- phylobase.options() + +context("test phylo4 class") + +test_that("building from matrix works", { + edge <- structure(c(6L, 7L, 8L, 8L, 9L, 9L, 7L, 6L, 7L, 8L, 1L, 9L, + 2L, 3L, 4L, 5L), .Dim = c(8, 2)) + edge.length <- c(0.2, 0.5, 0.2, 0.15, 0.1, 0.1, 0.7, 1) + tip.label <- paste("t", 1:5, sep="") + node.label <- paste("n", 1:4, sep="") + edge.label <- paste("e", 1:8, sep="") + order <- "preorder" + annote <- list(x="annotation") + phy <- phylo4(edge, edge.length=edge.length, tip.label=tip.label, + node.label=node.label, edge.label=edge.label, order=order, + annote=annote) + + ## test each slot + expect_equal(edge, unname(edges(phy))) + expect_equal(edge.length, unname(edgeLength(phy))) + expect_equal(4L, nNodes(phy)) + expect_equal(tip.label, unname(tipLabels(phy))) + expect_equal(node.label, unname(nodeLabels(phy))) + expect_equal(edge.label, unname(edgeLabels(phy))) + expect_equal(order, edgeOrder(phy)) + expect_equal(annote, phy at annote) + + ## test improper cases + ## expect_error(phylo4(edge, edge.length=999)) # recycling is allowed? FM (20140506: yes) + expect_error(phylo4(edge, tip.label=999)) + expect_error(phylo4(edge, node.label=999)) + ## expect_error(phylo4(edge, edge.label=999)) # recycling is allowed? FM (20140506: yes) + expect_error(phylo4(edge, order="invalid order")) + expect_error(phylo4(edge, annote="invalid annotation")) +}) + + +## note: this method mostly just wraps phylo->phylo4 coercion, which is +## tested more thoroughly in runit.setAs-methods.R; focus here is on +## annote and check.node.labels arguments + +test_that("phylo4 can be built from phylo (tests on what's not done in setAs tests)", { + tr <- ape::read.tree(text="(((t1:0.2,(t2:0.1,t3:0.1):0.15):0.5,t4:0.7):0.2,t5:1):0.4;") + + ## + ## annote + ## + + annote <- list(x="annotation") + phy <- phylo4(tr, annote=annote) + expect_equal(annote, phy at annote) + + ## + ## check.node.labels + ## + + # case 0: no node labels + phy <- phylo4(tr) + expect_true(!hasNodeLabels(phy)) + + # case 1: keep unique character labels + tr$node.label <- paste("n", 1:4, sep="") + phy <- phylo4(tr, check.node.labels="keep") + expect_equal(tr$node.label, unname(nodeLabels(phy))) + # keeping node labels should be the default + expect_equal(phy, phylo4(tr)) + + # case 2: keep unique number-like character labels + tr$node.label <- as.character(1:4) + phy <- phylo4(tr, check.node.labels="keep") + expect_equal(tr$node.label, unname(nodeLabels(phy))) + + # case 3: keep unique numeric labels, but convert to character + tr$node.label <- as.numeric(1:4) + phy <- phylo4(tr, check.node.labels="keep") + expect_equal(as.character(tr$node.label), unname(nodeLabels(phy))) + + # case 4: must drop non-unique labels + tr$node.label <- rep("x", 4) + ## with options allow.duplicated.labels="fail" + phylobase.options(allow.duplicated.labels="fail") + expect_error(phylo4(tr)) + expect_error(phylo4(tr, check.node.labels="keep")) + phylobase.options(op) + ## test dropping node labels + phy <- phylo4(tr, check.node.labels="drop") + expect_true(!hasNodeLabels(phy)) + ## with options allow.duplicated.labels="ok" + phylobase.options(allow.duplicated.labels="ok") + phy <- phylo4(tr) + expect_equal(unname(nodeLabels(phy)), tr$node.label) + phy <- phylo4(tr, check.node.labels="keep") + expect_equal(unname(nodeLabels(phy)), tr$node.label) + phy <- phylo4(tr, check.node.labels="drop") + expect_true(!hasNodeLabels(phy)) + phylobase.options(op) +}) From noreply at r-forge.r-project.org Wed May 7 16:57:10 2014 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Wed, 7 May 2014 16:57:10 +0200 (CEST) Subject: [Phylobase-commits] r938 - in pkg: inst/unitTests tests/testthat Message-ID: <20140507145710.2BEE918749B@r-forge.r-project.org> Author: francois Date: 2014-05-07 16:57:09 +0200 (Wed, 07 May 2014) New Revision: 938 Added: pkg/tests/testthat/test.class-phylo4d.R Removed: pkg/inst/unitTests/runit.class-phylo4d.R Log: moved/converted class-phylo4d tests Deleted: pkg/inst/unitTests/runit.class-phylo4d.R =================================================================== --- pkg/inst/unitTests/runit.class-phylo4d.R 2014-05-07 14:56:51 UTC (rev 937) +++ pkg/inst/unitTests/runit.class-phylo4d.R 2014-05-07 14:57:09 UTC (rev 938) @@ -1,291 +0,0 @@ -# -# --- Test class-phylo4d.R --- -# - -# create ape::phylo version of a simple tree for testing -## require(ape) ## messes badly with edges()! -nwk <- "((t1:0.1,t2:0.2)n7:0.7,(t3:0.3,(t4:0.4,t5:0.5)n9:0.9)n8:0.8)n6:0.6;" -tr <- ape::read.tree(text=nwk) - -# create analogous phylo4 object with a full complement of valid slots -ancestor <- as.integer(c(6,7,7,6,8,0,8,9,9)) -descendant <- as.integer(c(7,1,2,8,3,6,9,4,5)) -edge <- cbind(ancestor, descendant) -nid.tip <- 1:5 -nid.int <- 6:9 -nid.all <- c(nid.tip, nid.int) -lab.tip <- paste("t", nid.tip, sep="") -lab.int <- paste("n", nid.int, sep="") -lab.all <- c(lab.tip, lab.int) -elen <- descendant/10 -elab <- paste("e", ancestor, descendant, sep="-") -phy <- phylo4(x=edge, tip.label=lab.tip, node.label=lab.int, - edge.length=elen, edge.label=elab) - -# create altered version such that each slot is out of order with -# respect to all others; methods should be able to handle this -phy.alt <- phy -phy.alt at label <- rev(phy at label) -phy.alt at edge <- phy at edge[c(6:9, 1:5), ] -phy.alt at edge.length <- phy at edge.length[c(7:9, 1:6)] -phy.alt at edge.label <- phy at edge.label[c(8:9, 1:7)] - -# create data to add to phylo4 to create phylo4d, but with data rows out -# of order -set.seed(1) -nid.tip.r <- sample(nid.tip) -nid.int.r <- sample(nid.int) -nid.all.r <- sample(c(nid.tip, nid.int)) -allDt <- data.frame(a=letters[nid.all.r], b=10*nid.all.r) -tipDt <- data.frame(c=letters[nid.tip.r], d=10*nid.tip.r) -nodDt <- data.frame(c=letters[nid.int.r], e=10*nid.int.r) -## set row.names as numeric node IDs (may be changed in tests below) -row.names(allDt) <- nid.all.r -row.names(tipDt) <- nid.tip.r -row.names(nodDt) <- nid.int.r - -#----------------------------------------------------------------------- - -test.phylo4d.phylo4 <- function() { - - ## case 1: add data matching only on row position - row.names(allDt) <- NULL - row.names(tipDt) <- NULL - row.names(nodDt) <- NULL - - ## these should fail because row.names don't match nodes - checkException(phylo4d(phy.alt, tip.data=tipDt, rownamesAsLabels=TRUE)) - checkException(phylo4d(phy.alt, node.data=nodDt)) - - ## brute force: no matching; with tip data - phyd <- phylo4d(phy.alt, tip.data=tipDt, match.data=FALSE) - checkIdentical(phyd at data, data.frame(tipDt, - row.names=nid.tip)) - checkIdentical(tdata(phyd, "tip"), data.frame(tipDt, - row.names=lab.tip)) - - ## brute force: no matching; with node data - phyd <- phylo4d(phy.alt, node.data=nodDt, match.data=FALSE) - checkIdentical(phyd at data, data.frame(nodDt, - row.names=nid.int)) - checkIdentical(tdata(phyd, "internal"), data.frame(nodDt, - row.names=lab.int)) - - ## brute force: no matching; with all.data - phyd <- phylo4d(phy.alt, all.data=allDt, match.data=FALSE) - checkIdentical(phyd at data, data.frame(allDt, - row.names=nid.all)) - checkIdentical(tdata(phyd, "all"), data.frame(allDt, - row.names=lab.all)) - - ## brute force: no matching; with tip & node data - ## no merging (data names don't match) - phyd <- phylo4d(phy.alt, tip.data=tipDt["d"], node.data=nodDt["e"], - match.data=FALSE) - checkIdentical(phyd at data, data.frame(rbind(data.frame(tipDt["d"], - e=NA_real_), data.frame(d=NA_real_, nodDt["e"])), - row.names=nid.all)) - checkIdentical(tdata(phyd, "tip"), data.frame(tipDt["d"], e=NA_real_, - row.names=lab.tip)) - checkIdentical(tdata(phyd, "internal"), data.frame(d=NA_real_, nodDt["e"], - row.names=lab.int)) - - ## brute force: no matching; with tip & node data - ## merging (common data names) - phyd <- phylo4d(phy.alt, tip.data=tipDt["c"], node.data=nodDt["c"], - match.data=FALSE) - checkIdentical(phyd at data, data.frame(rbind(tipDt["c"], nodDt["c"]), - row.names=nid.all)) - checkIdentical(tdata(phyd, "tip"), data.frame(c=factor(tipDt$c, - levels=letters[nid.all]), row.names=lab.tip)) - checkIdentical(tdata(phyd, "internal"), data.frame(c=factor(nodDt$c, - levels=letters[nid.all]), row.names=lab.int)) - - ## case 2: add data matching on numeric (node ID) row.names - row.names(allDt) <- nid.all.r - row.names(tipDt) <- nid.tip.r - row.names(nodDt) <- nid.int.r - - ## match with node numbers, tip data - phyd <- phylo4d(phy.alt, tip.data=tipDt) - checkIdentical(phyd at data, data.frame(tipDt[order(nid.tip.r),], - row.names=nid.tip)) - checkIdentical(tdata(phyd, "tip"), data.frame(tipDt[order(nid.tip.r),], - row.names=lab.tip)) - - ## match with node numbers, node data - phyd <- phylo4d(phy.alt, node.data=nodDt) - checkIdentical(phyd at data, data.frame(nodDt[order(nid.int.r),], - row.names=nid.int)) - checkIdentical(tdata(phyd, "internal"), data.frame(nodDt[order(nid.int.r),], - row.names=lab.int)) - - ## match with node numbers, tip & node data, no merge - phyd <- phylo4d(phy.alt, tip.data=tipDt["d"], node.data=nodDt["e"]) - checkIdentical(phyd at data, data.frame(rbind(data.frame( - d=tipDt[order(nid.tip.r), "d"], e=NA_real_), - data.frame(d=NA_real_, e=nodDt[order(nid.int.r), "e"])), - row.names=nid.all)) - checkIdentical(tdata(phyd, "tip"), data.frame(d=tipDt[order(nid.tip.r), "d"], - e=NA_real_, row.names=lab.tip)) - checkIdentical(tdata(phyd, "internal"), data.frame(d=NA_real_, - e=nodDt[order(nid.int.r), "e"], row.names=lab.int)) - - ## match with node numbers, tip & all data - phyd <- phylo4d(phy.alt, tip.data=tipDt, all.data=allDt) - merged <- data.frame(merge(allDt[order(nid.all.r),], - tipDt[order(nid.tip.r),], all=TRUE, by=0)[-1]) - checkIdentical(phyd at data, data.frame(merged, row.names=nid.all)) - checkIdentical(tdata(phyd, "all"), data.frame(merged, row.names=lab.all)) - - ## match with node numbers, node & all data - phyd <- phylo4d(phy.alt, node.data=nodDt, all.data=allDt) - merged <- data.frame(merge(allDt[order(nid.all.r),], - nodDt[order(nid.int.r),], all=TRUE, by=0)[-1]) - checkIdentical(phyd at data, data.frame(merged, row.names=nid.all)) - checkIdentical(tdata(phyd, "all"), data.frame(merged, row.names=lab.all)) - - ## match with node numbers, tip, node & all data - phyd <- phylo4d(phy.alt, tip.data=tipDt, node.data=nodDt, all.data=allDt) - # merge alldata with common tip and node data - m1 <- data.frame(merge(allDt, rbind(tipDt["c"], nodDt["c"]), - all=TRUE, by=0)[-1]) - # merge distinct columns of tipdata and nodedata - m2 <- data.frame(merge(tipDt["d"], nodDt["e"], all=TRUE, by=0)[-1]) - # ...now merge these together - merged <- data.frame(merge(m1, m2, by=0)[-1]) - checkIdentical(phyd at data, data.frame(merged, - row.names=nid.all)) - checkIdentical(tdata(phyd, "tip"), data.frame(merged[nid.tip,], - row.names=lab.tip, check.names=FALSE)) - checkIdentical(tdata(phyd, "internal"), data.frame(merged[nid.int,], - row.names=lab.int, check.names=FALSE)) - checkIdentical(tdata(phyd, "all"), data.frame(merged, row.names=lab.all)) - - ## as above, but without merging common tip and node column - phyd <- phylo4d(phy.alt, tip.data=tipDt, node.data=nodDt, - all.data=allDt, merge.data=FALSE) - m3 <- data.frame(merge(tipDt, nodDt, all=TRUE, by=0, - suffix=c(".tip", ".node"))[-1]) - merged <- data.frame(merge(allDt, m3, by=0)[-1]) - checkIdentical(phyd at data, data.frame(merged, - row.names=nid.all)) - checkIdentical(tdata(phyd, "tip"), data.frame(merged[nid.tip,], - row.names=lab.tip, check.names=FALSE)) - checkIdentical(tdata(phyd, "internal"), data.frame(merged[nid.int,], - row.names=lab.int, check.names=FALSE)) - checkIdentical(tdata(phyd, "all"), data.frame(merged, row.names=lab.all)) - - ## case 3: add data matching on character (label) row.names for tips - row.names(tipDt) <- c(lab.tip, lab.int)[nid.tip.r] - row.names(nodDt) <- c(lab.tip, lab.int)[nid.int.r] - - ## match with names, tip data - phyd <- phylo4d(phy.alt, tip.data=tipDt) - checkIdentical(phyd at data, data.frame(tipDt[order(nid.tip.r),], - row.names=nid.tip)) - checkIdentical(tdata(phyd, "tip"), data.frame(tipDt[order(nid.tip.r),], - row.names=lab.tip)) - - ## case 4: add data matching on mixed rowname types (for tips and - ## for internal nodes) - row.names(allDt)[match(nid.tip.r, nid.all.r)] <- lab.tip[nid.tip.r] - row.names(allDt)[match(nid.int.r, nid.all.r)] <- nid.int.r - - ## match with names for tips and numbers for nodes with all data - phyd <- phylo4d(phy.alt, all.data=allDt) - checkIdentical(tdata(phyd, "all"), data.frame(allDt[match(nid.all, - nid.all.r),], row.names=lab.all)) - checkIdentical(tdata(phyd, "tip"), data.frame(allDt[match(nid.tip, - nid.all.r),], row.names=lab.tip)) - checkIdentical(tdata(phyd, "internal"), data.frame(allDt[match(nid.int, - nid.all.r),], row.names=lab.int)) - checkIdentical(phyd at data, data.frame(allDt[match(nid.all, nid.all.r),], - row.names=nid.all)) - -} - -test.phylo4d.matrix <- function() { -} - -# note: this method mostly does phylo4(phylo), then phylo4d(phylo4), -# then addData methods, which are tested more thoroughly elsewhere; -# focus here is on metadata and check.node.labels="asdata" arguments -test.phylo4d.phylo <- function() { - # function(x, tip.data=NULL, node.data=NULL, all.data=NULL, - # check.node.labels=c("keep", "drop", "asdata"), annote=list(), - # metadata=list(), ...) - - # show that method basically just wraps phylo4d("phylo4") - phyd.tr <- phylo4d(tr, tip.data=tipDt, node.data=nodDt, - all.data=allDt, match.data=TRUE, merge.data=TRUE) - checkTrue(class(phyd.tr)=="phylo4d") - phyd.phy <- phylo4d(phy.alt, tip.data=tipDt, node.data=nodDt, - all.data=allDt, match.data=TRUE, merge.data=TRUE) - # reorder for edge order consistency, then test each slot (except - # edge labels, b/c phylo object has none) - phyd.tr <- reorder(phyd.tr) - phyd.phy <- reorder(phyd.phy) - checkIdentical(edges(phyd.tr), edges(phyd.phy)) - checkIdentical(edgeLength(phyd.tr), edgeLength(phyd.phy)) - checkIdentical(nNodes(phyd.tr), nNodes(phyd.phy)) - checkIdentical(tipLabels(phyd.tr), tipLabels(phyd.phy)) - checkIdentical(nodeLabels(phyd.tr), nodeLabels(phyd.phy)) - checkIdentical(edgeOrder(phyd.tr), edgeOrder(phyd.phy)) - checkIdentical(phyd.tr at annote, phyd.phy at annote) - # other misc checks - checkEquals(phylo4d(phylo4(tr)), phylo4d(tr)) - checkEquals(phylo4d(phylo4(tr, check.node.labels="drop")), - phylo4d(tr, check.node.labels="drop")) - - ## - ## metadata - ## - - metadata <- list(x="metadata") - phyd <- phylo4d(tr, metadata=metadata) - checkIdentical(metadata, phyd at metadata) - - ## - ## check.node.labels - ## - - # case 0: no node labels - tr$node.label <- NULL - phyd <- phylo4d(tr) - checkTrue(!hasNodeLabels(phyd)) - - # case 1: convert character labels as data - tr$node.label <- paste("n", 1:4, sep="") - phyd <- phylo4d(tr, check.node.labels="asdata") - checkTrue(!hasNodeLabels(phyd)) - checkEquals(tdata(phyd, "internal")$labelValues, as.factor(tr$node.label)) - - # case 2: convert number-like characters labels to numeric data - tr$node.label <- as.character(1:4) - phyd <- phylo4d(tr, check.node.labels="asdata") - checkTrue(!hasNodeLabels(phyd)) - checkIdentical(tdata(phyd, "internal")$labelValues, - as.numeric(tr$node.label)) - - # case 3: convert numeric labels to numeric data - tr$node.label <- as.numeric(1:4) - phyd <- phylo4d(tr, check.node.labels="asdata") - checkTrue(!hasNodeLabels(phyd)) - checkIdentical(tdata(phyd, "internal")$labelValues, tr$node.label) - - # case 4: non-unique labels can be converted to data - tr$node.label <- rep(99, 4) - phyd <- phylo4d(tr) - checkIdentical(unname(nodeLabels(phyd)), as.character(tr$node.label)) - phyd <- phylo4d(tr, check.node.labels="asdata") - checkTrue(!hasNodeLabels(phyd)) - checkIdentical(tdata(phyd, "internal", label.type="column")$labelValues, tr$node.label) -} - -## phylo4d->phylo4d is currently unallowed -test.phylo4d.phylo4d <- function() { - phyd <- phylo4d(phy) - checkException(phylo4d(phyd)) -} - Copied: pkg/tests/testthat/test.class-phylo4d.R (from rev 880, pkg/inst/unitTests/runit.class-phylo4d.R) =================================================================== --- pkg/tests/testthat/test.class-phylo4d.R (rev 0) +++ pkg/tests/testthat/test.class-phylo4d.R 2014-05-07 14:57:09 UTC (rev 938) @@ -0,0 +1,294 @@ +# +# --- Test class-phylo4d.R --- +# + +## create ape::phylo version of a simple tree for testing +nwk <- "((t1:0.1,t2:0.2)n7:0.7,(t3:0.3,(t4:0.4,t5:0.5)n9:0.9)n8:0.8)n6:0.6;" +tr <- ape::read.tree(text=nwk) + +# create analogous phylo4 object with a full complement of valid slots +ancestor <- as.integer(c(6,7,7,6,8,0,8,9,9)) +descendant <- as.integer(c(7,1,2,8,3,6,9,4,5)) +edge <- cbind(ancestor, descendant) +nid.tip <- 1:5 +nid.int <- 6:9 +nid.all <- c(nid.tip, nid.int) +lab.tip <- paste("t", nid.tip, sep="") +lab.int <- paste("n", nid.int, sep="") +lab.all <- c(lab.tip, lab.int) +elen <- descendant/10 +elab <- paste("e", ancestor, descendant, sep="-") +phy <- phylo4(x=edge, tip.label=lab.tip, node.label=lab.int, + edge.length=elen, edge.label=elab) + +# create altered version such that each slot is out of order with +# respect to all others; methods should be able to handle this +phy.alt <- phy +phy.alt at label <- rev(phy at label) +phy.alt at edge <- phy at edge[c(6:9, 1:5), ] +phy.alt at edge.length <- phy at edge.length[c(7:9, 1:6)] +phy.alt at edge.label <- phy at edge.label[c(8:9, 1:7)] + +# create data to add to phylo4 to create phylo4d, but with data rows out +# of order +set.seed(1) +nid.tip.r <- sample(nid.tip) +nid.int.r <- sample(nid.int) +nid.all.r <- sample(c(nid.tip, nid.int)) +allDt <- data.frame(a=letters[nid.all.r], b=10*nid.all.r) +tipDt <- data.frame(c=letters[nid.tip.r], d=10*nid.tip.r) +nodDt <- data.frame(c=letters[nid.int.r], e=10*nid.int.r) +## set row.names as numeric node IDs (may be changed in tests below) +row.names(allDt) <- nid.all.r +row.names(tipDt) <- nid.tip.r +row.names(nodDt) <- nid.int.r + +#----------------------------------------------------------------------- + +context("test phylo4d class") + +test_that("phylo4d can be built from phylo4", { + + ## case 1: add data matching only on row position + row.names(allDt) <- NULL + row.names(tipDt) <- NULL + row.names(nodDt) <- NULL + + ## these should fail because row.names don't match nodes + expect_error(phylo4d(phy.alt, tip.data=tipDt, rownamesAsLabels=TRUE)) + expect_error(phylo4d(phy.alt, node.data=nodDt)) + + ## brute force: no matching; with tip data + phyd <- phylo4d(phy.alt, tip.data=tipDt, match.data=FALSE) + expect_equal(phyd at data, data.frame(tipDt, + row.names=nid.tip)) + expect_equal(tdata(phyd, "tip"), data.frame(tipDt, + row.names=lab.tip)) + + ## brute force: no matching; with node data + phyd <- phylo4d(phy.alt, node.data=nodDt, match.data=FALSE) + expect_equal(phyd at data, data.frame(nodDt, + row.names=nid.int)) + expect_equal(tdata(phyd, "internal"), data.frame(nodDt, + row.names=lab.int)) + + ## brute force: no matching; with all.data + phyd <- phylo4d(phy.alt, all.data=allDt, match.data=FALSE) + expect_equal(phyd at data, data.frame(allDt, + row.names=nid.all)) + expect_equal(tdata(phyd, "all"), data.frame(allDt, + row.names=lab.all)) + + ## brute force: no matching; with tip & node data + ## no merging (data names don't match) + phyd <- phylo4d(phy.alt, tip.data=tipDt["d"], node.data=nodDt["e"], + match.data=FALSE) + expect_equal(phyd at data, data.frame(rbind(data.frame(tipDt["d"], + e=NA_real_), data.frame(d=NA_real_, nodDt["e"])), + row.names=nid.all)) + expect_equal(tdata(phyd, "tip"), data.frame(tipDt["d"], e=NA_real_, + row.names=lab.tip)) + expect_equal(tdata(phyd, "internal"), data.frame(d=NA_real_, nodDt["e"], + row.names=lab.int)) + + ## brute force: no matching; with tip & node data + ## merging (common data names) + phyd <- phylo4d(phy.alt, tip.data=tipDt["c"], node.data=nodDt["c"], + match.data=FALSE) + expect_equal(phyd at data, data.frame(rbind(tipDt["c"], nodDt["c"]), + row.names=nid.all)) + expect_equal(tdata(phyd, "tip"), data.frame(c=factor(tipDt$c, + levels=letters[nid.all]), row.names=lab.tip)) + expect_equal(tdata(phyd, "internal"), data.frame(c=factor(nodDt$c, + levels=letters[nid.all]), row.names=lab.int)) + + ## case 2: add data matching on numeric (node ID) row.names + row.names(allDt) <- nid.all.r + row.names(tipDt) <- nid.tip.r + row.names(nodDt) <- nid.int.r + + ## match with node numbers, tip data + phyd <- phylo4d(phy.alt, tip.data=tipDt) + expect_equal(phyd at data, data.frame(tipDt[order(nid.tip.r),], + row.names=nid.tip)) + expect_equal(tdata(phyd, "tip"), data.frame(tipDt[order(nid.tip.r),], + row.names=lab.tip)) + + ## match with node numbers, node data + phyd <- phylo4d(phy.alt, node.data=nodDt) + expect_equal(phyd at data, data.frame(nodDt[order(nid.int.r),], + row.names=nid.int)) + expect_equal(tdata(phyd, "internal"), data.frame(nodDt[order(nid.int.r),], + row.names=lab.int)) + + ## match with node numbers, tip & node data, no merge + phyd <- phylo4d(phy.alt, tip.data=tipDt["d"], node.data=nodDt["e"]) + expect_equal(phyd at data, data.frame(rbind(data.frame( + d=tipDt[order(nid.tip.r), "d"], e=NA_real_), + data.frame(d=NA_real_, e=nodDt[order(nid.int.r), "e"])), + row.names=nid.all)) + expect_equal(tdata(phyd, "tip"), data.frame(d=tipDt[order(nid.tip.r), "d"], + e=NA_real_, row.names=lab.tip)) + expect_equal(tdata(phyd, "internal"), data.frame(d=NA_real_, + e=nodDt[order(nid.int.r), "e"], row.names=lab.int)) + + ## match with node numbers, tip & all data + phyd <- phylo4d(phy.alt, tip.data=tipDt, all.data=allDt) + merged <- data.frame(merge(allDt[order(nid.all.r),], + tipDt[order(nid.tip.r),], all=TRUE, by=0)[-1]) + expect_equal(phyd at data, data.frame(merged, row.names=nid.all)) + expect_equal(tdata(phyd, "all"), data.frame(merged, row.names=lab.all)) + + ## match with node numbers, node & all data + phyd <- phylo4d(phy.alt, node.data=nodDt, all.data=allDt) + merged <- data.frame(merge(allDt[order(nid.all.r),], + nodDt[order(nid.int.r),], all=TRUE, by=0)[-1]) + expect_equal(phyd at data, data.frame(merged, row.names=nid.all)) + expect_equal(tdata(phyd, "all"), data.frame(merged, row.names=lab.all)) + + ## match with node numbers, tip, node & all data + phyd <- phylo4d(phy.alt, tip.data=tipDt, node.data=nodDt, all.data=allDt) + # merge alldata with common tip and node data + m1 <- data.frame(merge(allDt, rbind(tipDt["c"], nodDt["c"]), + all=TRUE, by=0)[-1]) + # merge distinct columns of tipdata and nodedata + m2 <- data.frame(merge(tipDt["d"], nodDt["e"], all=TRUE, by=0)[-1]) + # ...now merge these together + merged <- data.frame(merge(m1, m2, by=0)[-1]) + expect_equal(phyd at data, data.frame(merged, + row.names=nid.all)) + expect_equal(tdata(phyd, "tip"), data.frame(merged[nid.tip,], + row.names=lab.tip, check.names=FALSE)) + expect_equal(tdata(phyd, "internal"), data.frame(merged[nid.int,], + row.names=lab.int, check.names=FALSE)) + expect_equal(tdata(phyd, "all"), data.frame(merged, row.names=lab.all)) + + ## as above, but without merging common tip and node column + phyd <- phylo4d(phy.alt, tip.data=tipDt, node.data=nodDt, + all.data=allDt, merge.data=FALSE) + m3 <- data.frame(merge(tipDt, nodDt, all=TRUE, by=0, + suffix=c(".tip", ".node"))[-1]) + merged <- data.frame(merge(allDt, m3, by=0)[-1]) + expect_equal(phyd at data, data.frame(merged, + row.names=nid.all)) + expect_equal(tdata(phyd, "tip"), data.frame(merged[nid.tip,], + row.names=lab.tip, check.names=FALSE)) + expect_equal(tdata(phyd, "internal"), data.frame(merged[nid.int,], + row.names=lab.int, check.names=FALSE)) + expect_equal(tdata(phyd, "all"), data.frame(merged, row.names=lab.all)) + + ## case 3: add data matching on character (label) row.names for tips + row.names(tipDt) <- c(lab.tip, lab.int)[nid.tip.r] + row.names(nodDt) <- c(lab.tip, lab.int)[nid.int.r] + + ## match with names, tip data + phyd <- phylo4d(phy.alt, tip.data=tipDt) + expect_equal(phyd at data, data.frame(tipDt[order(nid.tip.r),], + row.names=nid.tip)) + expect_equal(tdata(phyd, "tip"), data.frame(tipDt[order(nid.tip.r),], + row.names=lab.tip)) + + ## case 4: add data matching on mixed rowname types (for tips and + ## for internal nodes) + row.names(allDt)[match(nid.tip.r, nid.all.r)] <- lab.tip[nid.tip.r] + row.names(allDt)[match(nid.int.r, nid.all.r)] <- nid.int.r + + ## match with names for tips and numbers for nodes with all data + phyd <- phylo4d(phy.alt, all.data=allDt) + expect_equal(tdata(phyd, "all"), data.frame(allDt[match(nid.all, + nid.all.r),], row.names=lab.all)) + expect_equal(tdata(phyd, "tip"), data.frame(allDt[match(nid.tip, + nid.all.r),], row.names=lab.tip)) + expect_equal(tdata(phyd, "internal"), data.frame(allDt[match(nid.int, + nid.all.r),], row.names=lab.int)) + expect_equal(phyd at data, data.frame(allDt[match(nid.all, nid.all.r),], + row.names=nid.all)) + +}) + +## test.phylo4d.matrix <- function() { +## } + +# note: this method mostly does phylo4(phylo), then phylo4d(phylo4), +# then addData methods, which are tested more thoroughly elsewhere; +# focus here is on metadata and check.node.labels="asdata" arguments + +test_that("phylo4d can be built from phylo object", { + # function(x, tip.data=NULL, node.data=NULL, all.data=NULL, + # check.node.labels=c("keep", "drop", "asdata"), annote=list(), + # metadata=list(), ...) + + ## show that method basically just wraps phylo4d("phylo4") + phyd.tr <- phylo4d(tr, tip.data=tipDt, node.data=nodDt, + all.data=allDt, match.data=TRUE, merge.data=TRUE) + expect_true(class(phyd.tr)=="phylo4d") + phyd.phy <- phylo4d(phy.alt, tip.data=tipDt, node.data=nodDt, + all.data=allDt, match.data=TRUE, merge.data=TRUE) + # reorder for edge order consistency, then test each slot (except + # edge labels, b/c phylo object has none) + phyd.tr <- reorder(phyd.tr) + phyd.phy <- reorder(phyd.phy) + expect_equal(edges(phyd.tr), edges(phyd.phy)) + expect_equal(edgeLength(phyd.tr), edgeLength(phyd.phy)) + expect_equal(nNodes(phyd.tr), nNodes(phyd.phy)) + expect_equal(tipLabels(phyd.tr), tipLabels(phyd.phy)) + expect_equal(nodeLabels(phyd.tr), nodeLabels(phyd.phy)) + expect_equal(edgeOrder(phyd.tr), edgeOrder(phyd.phy)) + expect_equal(phyd.tr at annote, phyd.phy at annote) + # other misc checks + expect_equal(phylo4d(phylo4(tr)), phylo4d(tr)) + expect_equal(phylo4d(phylo4(tr, check.node.labels="drop")), + phylo4d(tr, check.node.labels="drop")) + + ## + ## metadata + ## + + metadata <- list(x="metadata") + phyd <- phylo4d(tr, metadata=metadata) + expect_equal(metadata, phyd at metadata) + + ## + ## check.node.labels + ## + + # case 0: no node labels + tr$node.label <- NULL + phyd <- phylo4d(tr) + expect_true(!hasNodeLabels(phyd)) + + # case 1: convert character labels as data + tr$node.label <- paste("n", 1:4, sep="") + phyd <- phylo4d(tr, check.node.labels="asdata") + expect_true(!hasNodeLabels(phyd)) + expect_equal(tdata(phyd, "internal")$labelValues, as.factor(tr$node.label)) + + # case 2: convert number-like characters labels to numeric data + tr$node.label <- as.character(1:4) + phyd <- phylo4d(tr, check.node.labels="asdata") + expect_true(!hasNodeLabels(phyd)) + expect_equal(tdata(phyd, "internal")$labelValues, + as.numeric(tr$node.label)) + + # case 3: convert numeric labels to numeric data + tr$node.label <- as.numeric(1:4) + phyd <- phylo4d(tr, check.node.labels="asdata") + expect_true(!hasNodeLabels(phyd)) + expect_equal(tdata(phyd, "internal")$labelValues, tr$node.label) + + # case 4: non-unique labels can be converted to data + tr$node.label <- rep(99, 4) + phyd <- phylo4d(tr) + expect_equal(unname(nodeLabels(phyd)), as.character(tr$node.label)) + phyd <- phylo4d(tr, check.node.labels="asdata") + expect_true(!hasNodeLabels(phyd)) + expect_equal(tdata(phyd, "internal", label.type="column")$labelValues, tr$node.label) +}) + +## phylo4d->phylo4d is currently unallowed + +test_that("phylo4d to phylo4d throws error", { + phyd <- phylo4d(phy) + expect_error(phylo4d(phyd)) +}) + From noreply at r-forge.r-project.org Wed May 7 16:57:43 2014 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Wed, 7 May 2014 16:57:43 +0200 (CEST) Subject: [Phylobase-commits] r939 - in pkg: inst/unitTests tests/testthat Message-ID: <20140507145743.EEA2518749D@r-forge.r-project.org> Author: francois Date: 2014-05-07 16:57:43 +0200 (Wed, 07 May 2014) New Revision: 939 Added: pkg/tests/testthat/test.formatData.R Removed: pkg/inst/unitTests/runit.formatData.R Log: moved/converted formatData tests Deleted: pkg/inst/unitTests/runit.formatData.R =================================================================== --- pkg/inst/unitTests/runit.formatData.R 2014-05-07 14:57:09 UTC (rev 938) +++ pkg/inst/unitTests/runit.formatData.R 2014-05-07 14:57:43 UTC (rev 939) @@ -1,459 +0,0 @@ -# -# --- Test formatData.R --- -# - -# create phylo4 object with a full complement of valid slots -ancestor <- as.integer(c(6,7,7,6,8,0,8,9,9)) -descendant <- as.integer(c(7,1,2,8,3,6,9,4,5)) -edge <- cbind(ancestor, descendant) -nid.tip <- 1:5 -nid.int <- 6:9 -nid.all <- c(nid.tip, nid.int) -lab.tip <- paste("t", nid.tip, sep="") -lab.int <- paste("n", nid.int, sep="") -lab.all <- c(lab.tip, lab.int) -elen <- descendant/10 -elab <- paste("e", ancestor, descendant, sep="-") -phy <- phylo4(x=edge, tip.label=lab.tip, node.label=lab.int, - edge.length=elen, edge.label=elab) - -# create altered version such that each slot is out of order with -# respect to all others; methods should be able to handle this -phy.alt <- phy -phy.alt at label <- rev(phy at label) -phy.alt at edge <- phy at edge[c(6:9, 1:5), ] -phy.alt at edge.length <- phy at edge.length[c(7:9, 1:6)] -phy.alt at edge.label <- phy at edge.label[c(8:9, 1:7)] - -# create data to add to phylo4 to create phylo4d, but with data rows out -# of order -set.seed(1) -nid.tip.r <- sample(nid.tip) -nid.int.r <- sample(nid.int) -nid.all.r <- sample(c(nid.tip, nid.int)) -allDt <- data.frame(a=letters[nid.all.r], b=10*nid.all.r) -tipDt <- data.frame(c=letters[nid.tip.r], d=10*nid.tip.r) -nodDt <- data.frame(c=letters[nid.int.r], e=10*nid.int.r) -## set row.names as numeric node IDs (may be changed in tests below) -row.names(allDt) <- nid.all.r -row.names(tipDt) <- nid.tip.r -row.names(nodDt) <- nid.int.r - -#----------------------------------------------------------------------- - -test.formatData <- function() { - # function(phy, dt, type=c("tip", "internal", "all"), - # match.data=TRUE, rownamesAsLabels=FALSE, - # label.type=c("rownames", "column"), label.column=1, - # missing.data=c("fail", "warn", "OK"), - # extra.data=c("warn", "OK", "fail"), keep.all=TRUE - - ## vector data coerced to data.frame (colname dt) - checkIdentical(phylobase:::formatData(phy.alt, 1:5), - phylobase:::formatData(phy.alt, data.frame(dt=1:5))) - ## list of vector data coerced to data.frame (colnames as given) - checkIdentical(phylobase:::formatData(phy.alt, list(a=1:5, b=6:10)), - phylobase:::formatData(phy.alt, data.frame(a=1:5, b=6:10))) - ## factor data coerced to data.frame (colname dt) - checkIdentical(phylobase:::formatData(phy.alt, factor(letters[1:5])), - phylobase:::formatData(phy.alt, data.frame(dt=letters[1:5]))) - ## matrix data coerced to data.frame (colnames V1, V2) - checkIdentical(phylobase:::formatData(phy.alt, matrix(1:10, ncol=2)), - phylobase:::formatData(phy.alt, data.frame(V1=1:5, V2=6:10))) - ## matrix data coerced to data.frame (colname as given) - checkIdentical(phylobase:::formatData(phy.alt, matrix(1:10, ncol=2, - dimnames=list(NULL, c("a", "b")))), - phylobase:::formatData(phy.alt, data.frame(a=1:5, b=6:10))) - ## error if dt is, say, a phylo4 object - checkException(phylobase:::formatData(phy.alt, phy.alt)) - - ## error if column number is out of range - checkException(phylobase:::formatData(phy.alt, data.frame(a=1:5, - lab=rev(nid.tip)), type="tip", match.data=FALSE, - label.type="column", label.column=3), - data.frame(a=c(1:5, rep(NA, 4)), lab=c(rev(nid.tip), rep(NA, - 4)), row.names=nid.all)) - ## error if column name is wrong - checkException(phylobase:::formatData(phy.alt, data.frame(a=1:5, - lab=rev(nid.tip)), type="tip", match.data=FALSE, - label.type="column", label.column="foo"), - data.frame(a=c(1:5, rep(NA, 4)), lab=c(rev(nid.tip), rep(NA, - 4)), row.names=nid.all)) - - - # - # matching options - # - - ## don't match (purely positional) - checkIdentical(phylobase:::formatData(phy.alt, data.frame(a=1:5, - row.names=rev(nid.tip)), type="tip", match.data=FALSE), - data.frame(a=c(1:5, rep(NA, 4)), row.names=nid.all)) - ## match on rownames (node numbers) - checkIdentical(phylobase:::formatData(phy.alt, data.frame(a=1:5, - row.names=rev(nid.tip)), type="tip", match.data=TRUE), - data.frame(a=c(5:1, rep(NA, 4)), row.names=nid.all)) - checkIdentical(phylobase:::formatData(phy.alt, data.frame(a=1:5, - row.names=rev(nid.tip)), type="tip"), data.frame(a=c(5:1, - rep(NA, 4)), row.names=nid.all)) - ## match on rownames (labels) - checkIdentical(phylobase:::formatData(phy.alt, data.frame(a=1:5, - row.names=rev(lab.tip)), type="tip", match.data=TRUE), - data.frame(a=c(5:1, rep(NA, 4)), row.names=nid.all)) - ## match on rownames (mixed node numbers and labels) - checkIdentical(phylobase:::formatData(phy.alt, data.frame(a=1:5, - row.names=c(rev(lab.tip)[1:3], rev(nid.tip)[4:5])), - type="tip", match.data=TRUE), - data.frame(a=c(5:1, rep(NA, 4)), row.names=nid.all)) - ## but fails if rownamesAsLabels is TRUE - checkException(phylobase:::formatData(phy.alt, data.frame(a=1:5, - row.names=c(rev(lab.tip)[1:3], rev(nid.tip)[4:5])), - type="tip", match.data=TRUE, rownamesAsLabels=TRUE)) - - # - # label.type="column" and label.column=2 - # - - ## should ignore label (purely positional) and retain a label col - checkIdentical(phylobase:::formatData(phy.alt, data.frame(a=1:5, - lab=rev(nid.tip)), type="tip", match.data=FALSE, - label.type="column", label.column=2), - data.frame(a=c(1:5, rep(NA, 4)), lab=c(rev(nid.tip), rep(NA, - 4)), row.names=nid.all)) - ## match on label column (node numbers) - checkIdentical(phylobase:::formatData(phy.alt, data.frame(a=1:5, - lab=rev(nid.tip)), type="tip", match.data=TRUE, - label.type="column", label.column=2), - data.frame(a=c(5:1, rep(NA, 4)), row.names=nid.all)) - checkIdentical(phylobase:::formatData(phy.alt, data.frame(a=1:5, - lab=rev(nid.tip)), type="tip", - label.type="column", label.column=2), - data.frame(a=c(5:1, rep(NA, 4)), row.names=nid.all)) - ## match on label column (labels) - checkIdentical(phylobase:::formatData(phy.alt, data.frame(a=1:5, - lab=rev(lab.tip)), type="tip", match.data=TRUE, - label.type="column", label.column=2), - data.frame(a=c(5:1, rep(NA, 4)), row.names=nid.all)) - checkIdentical(phylobase:::formatData(phy.alt, data.frame(a=1:5, - lab=rev(lab.tip)), type="tip", match.data=TRUE, - label.type="column", label.column="lab"), - data.frame(a=c(5:1, rep(NA, 4)), row.names=nid.all)) - ## match on label column (mixed node numbers and labels) - checkIdentical(phylobase:::formatData(phy.alt, data.frame(a=1:5, - lab=c(rev(lab.tip)[1:3], rev(nid.tip)[4:5])), type="tip", - match.data=TRUE, label.type="column", label.column=2), - data.frame(a=c(5:1, rep(NA, 4)), row.names=nid.all)) - ## but fails if rownamesAsLabels is TRUE - checkException(phylobase:::formatData(phy.alt, data.frame(a=1:5, - lab=c(rev(lab.tip)[1:3], rev(nid.tip)[4:5])), - type="tip", match.data=TRUE, rownamesAsLabels=TRUE, - label.type="column", label.column=2)) - - ## try to match internal nodes when type='tips' - checkException(phylobase:::formatData(phy.alt, data.frame(a=1:5, row.names=4:8), - type="tip")) - ## and vice versa - checkException(phylobase:::formatData(phy.alt, data.frame(a=6:9, row.names=1:4), - type="internal")) - - # - # missing.data - # - - ## force error conditions - checkException(phylobase:::formatData(phy.alt, data.frame(a=1:3), type="tip")) - checkException(phylobase:::formatData(phy.alt, data.frame(a=1:3), type="tip", - missing.data="fail")) - options(warn=3) - checkException(phylobase:::formatData(phy.alt, data.frame(a=1:3), type="tip", - missing.data="warn")) - options(warn=0) - ## missing data with matching - checkIdentical(phylobase:::formatData(phy.alt, data.frame(a=rev(nid.tip)[-1], - row.names=rev(nid.tip)[-1]), type="tip", missing.data="OK"), - data.frame(a=c(nid.tip[-5], rep(NA, 5)))) - checkIdentical(phylobase:::formatData(phy.alt, data.frame(a=rev(nid.int)[-1], - row.names=rev(nid.int)[-1]), type="internal", missing.data="OK"), - data.frame(a=c(rep(NA, 5), nid.int[-4], NA))) - checkIdentical(phylobase:::formatData(phy.alt, data.frame(a=rev(nid.all)[-1], - row.names=rev(nid.all)[-1]), type="all", missing.data="OK"), - data.frame(a=c(nid.all[-9], NA))) - ## missing data without matching - checkIdentical(phylobase:::formatData(phy.alt, data.frame(a=rev(nid.tip)[-1]), - type="tip", match.data=FALSE, missing.data="OK"), - data.frame(a=c(rev(nid.tip)[-1], rep(NA, 5)))) - checkIdentical(phylobase:::formatData(phy.alt, data.frame(a=rev(nid.int)[-1]), - type="internal", match.data=FALSE, missing.data="OK"), - data.frame(a=c(rep(NA, 5), rev(nid.int)[-1], NA))) - checkIdentical(phylobase:::formatData(phy.alt, data.frame(a=rev(nid.all)[-1]), - type="all", match.data=FALSE, missing.data="OK"), - data.frame(a=c(rev(nid.all)[-1], NA))) - - # - # extra.data - # - - ## force error conditions - checkException(phylobase:::formatData(phy.alt, data.frame(a=1:3), type="tip", - missing.data="fail")) - options(warn=3) - checkException(phylobase:::formatData(phy.alt, data.frame(a=0:5, row.names=0:5), - type="tip", missing="warn")) - checkException(phylobase:::formatData(phy.alt, data.frame(a=0:5, row.names=0:5), - type="tip")) - options(warn=0) - ## extra data with matching - checkIdentical(phylobase:::formatData(phy.alt, data.frame(a=c(0L, rev(nid.tip)), - row.names=c(0, rev(nid.tip))), type="tip", extra.data="OK"), - data.frame(a=c(nid.tip, rep(NA, 4)))) - checkIdentical(phylobase:::formatData(phy.alt, data.frame(a=c(0L, rev(nid.int)), - row.names=c(0, rev(nid.int))), type="internal", extra.data="OK"), - data.frame(a=c(rep(NA, 5), nid.int))) - checkIdentical(phylobase:::formatData(phy.alt, data.frame(a=c(0L, rev(nid.all)), - row.names=c(0, rev(nid.all))), type="all", extra.data="OK"), - data.frame(a=nid.all)) - ## extra data without matching - checkIdentical(phylobase:::formatData(phy.alt, data.frame(a=1:15), - type="tip", match.data=FALSE, extra.data="OK"), - data.frame(a=c(1:5, rep(NA, 4)))) - checkIdentical(phylobase:::formatData(phy.alt, data.frame(a=1:15), - type="internal", match.data=FALSE, extra.data="OK"), - data.frame(a=c(rep(NA, 5), 1:4))) - checkIdentical(phylobase:::formatData(phy.alt, data.frame(a=1:15), - type="all", match.data=FALSE, extra.data="OK"), - data.frame(a=c(1:9))) - - ## allow both extra.data and missing.data - checkIdentical(phylobase:::formatData(phy.alt, data.frame(a=0:3, row.names=0:3), - type="tip", extra.data="OK", missing.data="OK"), - data.frame(a=c(1:3, rep(NA, 6)))) - - # - # keep.all - # - - ## keep all rows - checkIdentical(phylobase:::formatData(phy.alt, data.frame(a=1:5, - row.names=nid.tip), type="tip", keep.all=TRUE), - data.frame(a=c(1:5, rep(NA, 4)), row.names=nid.all)) - checkIdentical(phylobase:::formatData(phy.alt, data.frame(a=1:5, - row.names=nid.tip), type="tip"), - data.frame(a=c(1:5, rep(NA, 4)), row.names=nid.all)) - checkIdentical(phylobase:::formatData(phy.alt, data.frame(a=6:9, - row.names=nid.int), type="internal", keep.all=TRUE), - data.frame(a=c(rep(NA, 5), 6:9), row.names=nid.all)) - checkIdentical(phylobase:::formatData(phy.alt, data.frame(a=6:9, - row.names=nid.int), type="internal"), - data.frame(a=c(rep(NA, 5), 6:9), row.names=nid.all)) - ## only keep 'type' rows - checkIdentical(phylobase:::formatData(phy.alt, data.frame(a=1:5, - row.names=nid.tip), type="tip", keep.all=FALSE), - data.frame(a=c(1:5), row.names=nid.tip)) - checkIdentical(phylobase:::formatData(phy.alt, data.frame(a=6:9, - row.names=nid.int), type="internal", keep.all=FALSE), - data.frame(a=c(6:9), row.names=nid.int)) - -} - -test.formatDataWithDup <- function() { - - ## Saving default options - op <- phylobase.options() - - ## Changing default options - phylobase.options(allow.duplicated.labels="ok") - - ## Creating phylo4 object with duplicated labels - phy.dup <- phy.alt - tipLabels(phy.dup)[2] <- tipLabels(phy.dup)[1] - - ## vector data coerced to data.frame (colname dt) - checkIdentical(phylobase:::formatData(phy.dup, 1:5), - phylobase:::formatData(phy.dup, data.frame(dt=1:5))) - ## list of vector data coerced to data.frame (colnames as given) - checkIdentical(phylobase:::formatData(phy.dup, list(a=1:5, b=6:10)), - phylobase:::formatData(phy.dup, data.frame(a=1:5, b=6:10))) - ## factor data coerced to data.frame (colname dt) - checkIdentical(phylobase:::formatData(phy.dup, factor(letters[1:5])), - phylobase:::formatData(phy.dup, data.frame(dt=letters[1:5]))) - ## matrix data coerced to data.frame (colnames V1, V2) - checkIdentical(phylobase:::formatData(phy.dup, matrix(1:10, ncol=2)), - phylobase:::formatData(phy.dup, data.frame(V1=1:5, V2=6:10))) - ## matrix data coerced to data.frame (colname as given) - checkIdentical(phylobase:::formatData(phy.dup, matrix(1:10, ncol=2, - dimnames=list(NULL, c("a", "b")))), - phylobase:::formatData(phy.dup, data.frame(a=1:5, b=6:10))) - ## error if dt is, say, a phylo4 object - checkException(phylobase:::formatData(phy.dup, phy.dup)) - - # - # matching options - # - - ## don't match (purely positional) - checkIdentical(phylobase:::formatData(phy.dup, data.frame(a=1:5, - row.names=rev(nid.tip)), type="tip", match.data=FALSE), - data.frame(a=c(1:5, rep(NA, 4)), row.names=nid.all)) - ## match on rownames (node numbers) - checkIdentical(phylobase:::formatData(phy.dup, data.frame(a=1:5, - row.names=rev(nid.tip)), type="tip", match.data=TRUE), - data.frame(a=c(5:1, rep(NA, 4)), row.names=nid.all)) - checkIdentical(phylobase:::formatData(phy.dup, data.frame(a=1:5, - row.names=rev(nid.tip)), type="tip"), data.frame(a=c(5:1, - rep(NA, 4)), row.names=nid.all)) - ## match on rownames (labels) - checkIdentical(phylobase:::formatData(phy.dup, data.frame(a=c(1,3,4,5), - row.names=rev(lab.tip[-2])), type="tip", match.data=TRUE), - data.frame(a=c(5,5,4,3,1, rep(NA, 4)), row.names=nid.all)) - ## match on rownames (mixed node numbers and labels) - checkIdentical(phylobase:::formatData(phy.dup, data.frame(a=c(1,2,3,4,5), - row.names=c(rev(lab.tip)[1:3], rev(nid.tip)[4:5])), - type="tip", match.data=TRUE), - data.frame(a=c(5,4,3,2,1, rep(NA, 4)), row.names=nid.all)) - ## but fails if rownamesAsLabels is TRUE - checkException(phylobase:::formatData(phy.dup, data.frame(a=1:5, - row.names=c(rev(lab.tip)[1:3], rev(nid.tip)[4:5])), - type="tip", match.data=TRUE, rownamesAsLabels=TRUE)) - - # - # label.type="column" and label.column=2 - # - - ## should ignore label (purely positional) and retain a label col - checkIdentical(phylobase:::formatData(phy.dup, data.frame(a=1:5, - lab=rev(nid.tip)), type="tip", match.data=FALSE, - label.type="column", label.column=2), - data.frame(a=c(1:5, rep(NA, 4)), lab=c(rev(nid.tip), rep(NA, - 4)), row.names=nid.all)) - ## match on label column (node numbers) - checkIdentical(phylobase:::formatData(phy.dup, data.frame(a=1:5, - lab=rev(nid.tip)), type="tip", match.data=TRUE, - label.type="column", label.column=2), - data.frame(a=c(5:1, rep(NA, 4)), row.names=nid.all)) - checkIdentical(phylobase:::formatData(phy.dup, data.frame(a=1:5, - lab=rev(nid.tip)), type="tip", - label.type="column", label.column=2), - data.frame(a=c(5:1, rep(NA, 4)), row.names=nid.all)) - ## match on label column (labels) - checkIdentical(phylobase:::formatData(phy.dup, data.frame(a=1:4, - lab=rev(lab.tip[-2])), type="tip", match.data=TRUE, - label.type="column", label.column=2), - data.frame(a=as.integer(c(4, 4:1, rep(NA, 4))), row.names=nid.all)) - ## match on label column (mixed node numbers and labels) - checkIdentical(phylobase:::formatData(phy.dup, data.frame(a=1:5, - lab=c(rev(lab.tip)[1:3], rev(nid.tip)[4:5])), type="tip", - match.data=TRUE, label.type="column", label.column=2), - data.frame(a=c(5:1, rep(NA, 4)), row.names=nid.all)) - ## but fails if rownamesAsLabels is TRUE - checkException(phylobase:::formatData(phy.dup, data.frame(a=1:5, - lab=c(rev(lab.tip)[1:3], rev(nid.tip)[4:5])), - type="tip", match.data=TRUE, rownamesAsLabels=TRUE, - label.type="column", label.column=2)) - - ## try to match internal nodes when type='tips' - checkException(phylobase:::formatData(phy.dup, data.frame(a=1:5, row.names=4:8), - type="tip")) - ## and vice versa - checkException(phylobase:::formatData(phy.dup, data.frame(a=6:9, row.names=1:4), - type="internal")) - - # - # missing.data - # - - ## force error conditions - checkException(phylobase:::formatData(phy.dup, data.frame(a=1:3), type="tip")) - checkException(phylobase:::formatData(phy.dup, data.frame(a=1:3), type="tip", - missing.data="fail")) - options(warn=3) - checkException(phylobase:::formatData(phy.dup, data.frame(a=1:3), type="tip", - missing.data="warn")) - options(warn=0) - ## missing data with matching - checkIdentical(phylobase:::formatData(phy.dup, data.frame(a=rev(nid.tip)[-1], - row.names=rev(nid.tip)[-1]), type="tip", missing.data="OK"), - data.frame(a=c(nid.tip[-5], rep(NA, 5)))) - checkIdentical(phylobase:::formatData(phy.dup, data.frame(a=rev(nid.int)[-1], - row.names=rev(nid.int)[-1]), type="internal", missing.data="OK"), - data.frame(a=c(rep(NA, 5), nid.int[-4], NA))) - checkIdentical(phylobase:::formatData(phy.dup, data.frame(a=rev(nid.all)[-1], - row.names=rev(nid.all)[-1]), type="all", missing.data="OK"), - data.frame(a=c(nid.all[-9], NA))) - ## missing data without matching - checkIdentical(phylobase:::formatData(phy.dup, data.frame(a=rev(nid.tip)[-1]), - type="tip", match.data=FALSE, missing.data="OK"), - data.frame(a=c(rev(nid.tip)[-1], rep(NA, 5)))) - checkIdentical(phylobase:::formatData(phy.dup, data.frame(a=rev(nid.int)[-1]), - type="internal", match.data=FALSE, missing.data="OK"), - data.frame(a=c(rep(NA, 5), rev(nid.int)[-1], NA))) - checkIdentical(phylobase:::formatData(phy.dup, data.frame(a=rev(nid.all)[-1]), - type="all", match.data=FALSE, missing.data="OK"), - data.frame(a=c(rev(nid.all)[-1], NA))) - - # - # extra.data - # - - ## force error conditions - checkException(phylobase:::formatData(phy.dup, data.frame(a=1:3), type="tip", - missing.data="fail")) - options(warn=3) - checkException(phylobase:::formatData(phy.dup, data.frame(a=0:5, row.names=0:5), - type="tip", missing="warn")) - checkException(phylobase:::formatData(phy.dup, data.frame(a=0:5, row.names=0:5), - type="tip")) - options(warn=0) - ## extra data with matching - checkIdentical(phylobase:::formatData(phy.dup, data.frame(a=c(0L, rev(nid.tip)), - row.names=c(0, rev(nid.tip))), type="tip", extra.data="OK"), - data.frame(a=c(nid.tip, rep(NA, 4)))) - checkIdentical(phylobase:::formatData(phy.dup, data.frame(a=c(0L, rev(nid.int)), - row.names=c(0, rev(nid.int))), type="internal", extra.data="OK"), - data.frame(a=c(rep(NA, 5), nid.int))) - checkIdentical(phylobase:::formatData(phy.dup, data.frame(a=c(0L, rev(nid.all)), - row.names=c(0, rev(nid.all))), type="all", extra.data="OK"), - data.frame(a=nid.all)) - ## extra data without matching - checkIdentical(phylobase:::formatData(phy.dup, data.frame(a=1:15), - type="tip", match.data=FALSE, extra.data="OK"), - data.frame(a=c(1:5, rep(NA, 4)))) - checkIdentical(phylobase:::formatData(phy.dup, data.frame(a=1:15), - type="internal", match.data=FALSE, extra.data="OK"), - data.frame(a=c(rep(NA, 5), 1:4))) - checkIdentical(phylobase:::formatData(phy.dup, data.frame(a=1:15), - type="all", match.data=FALSE, extra.data="OK"), - data.frame(a=c(1:9))) - - ## allow both extra.data and missing.data - checkIdentical(phylobase:::formatData(phy.dup, data.frame(a=0:3, row.names=0:3), - type="tip", extra.data="OK", missing.data="OK"), - data.frame(a=c(1:3, rep(NA, 6)))) - - # - # keep.all - # - - ## keep all rows - checkIdentical(phylobase:::formatData(phy.dup, data.frame(a=1:5, - row.names=nid.tip), type="tip", keep.all=TRUE), - data.frame(a=c(1:5, rep(NA, 4)), row.names=nid.all)) - checkIdentical(phylobase:::formatData(phy.dup, data.frame(a=1:5, - row.names=nid.tip), type="tip"), - data.frame(a=c(1:5, rep(NA, 4)), row.names=nid.all)) - checkIdentical(phylobase:::formatData(phy.dup, data.frame(a=6:9, - row.names=nid.int), type="internal", keep.all=TRUE), - data.frame(a=c(rep(NA, 5), 6:9), row.names=nid.all)) - checkIdentical(phylobase:::formatData(phy.dup, data.frame(a=6:9, - row.names=nid.int), type="internal"), - data.frame(a=c(rep(NA, 5), 6:9), row.names=nid.all)) - ## only keep 'type' rows - checkIdentical(phylobase:::formatData(phy.dup, data.frame(a=1:5, - row.names=nid.tip), type="tip", keep.all=FALSE), - data.frame(a=c(1:5), row.names=nid.tip)) - checkIdentical(phylobase:::formatData(phy.dup, data.frame(a=6:9, - row.names=nid.int), type="internal", keep.all=FALSE), - data.frame(a=c(6:9), row.names=nid.int)) - - ## restoring default options - phylobase.options(op) -} Copied: pkg/tests/testthat/test.formatData.R (from rev 927, pkg/inst/unitTests/runit.formatData.R) =================================================================== --- pkg/tests/testthat/test.formatData.R (rev 0) +++ pkg/tests/testthat/test.formatData.R 2014-05-07 14:57:43 UTC (rev 939) @@ -0,0 +1,488 @@ +# +# --- Test formatData.R --- +# + +# create phylo4 object with a full complement of valid slots +ancestor <- as.integer(c(6,7,7,6,8,0,8,9,9)) +descendant <- as.integer(c(7,1,2,8,3,6,9,4,5)) +edge <- cbind(ancestor, descendant) +nid.tip <- 1:5 +nid.int <- 6:9 +nid.all <- c(nid.tip, nid.int) +lab.tip <- paste("t", nid.tip, sep="") +lab.int <- paste("n", nid.int, sep="") +lab.all <- c(lab.tip, lab.int) +elen <- descendant/10 +elab <- paste("e", ancestor, descendant, sep="-") +phy <- phylo4(x=edge, tip.label=lab.tip, node.label=lab.int, + edge.length=elen, edge.label=elab) + +# create altered version such that each slot is out of order with +# respect to all others; methods should be able to handle this +phy.alt <- phy +phy.alt at label <- rev(phy at label) +phy.alt at edge <- phy at edge[c(6:9, 1:5), ] +phy.alt at edge.length <- phy at edge.length[c(7:9, 1:6)] +phy.alt at edge.label <- phy at edge.label[c(8:9, 1:7)] + +# create data to add to phylo4 to create phylo4d, but with data rows out +# of order +set.seed(1) +nid.tip.r <- sample(nid.tip) +nid.int.r <- sample(nid.int) +nid.all.r <- sample(c(nid.tip, nid.int)) +allDt <- data.frame(a=letters[nid.all.r], b=10*nid.all.r) +tipDt <- data.frame(c=letters[nid.tip.r], d=10*nid.tip.r) +nodDt <- data.frame(c=letters[nid.int.r], e=10*nid.int.r) +## set row.names as numeric node IDs (may be changed in tests below) +row.names(allDt) <- nid.all.r +row.names(tipDt) <- nid.tip.r +row.names(nodDt) <- nid.int.r + +#----------------------------------------------------------------------- + +context("test formatData") + +## function(phy, dt, type=c("tip", "internal", "all"), +## match.data=TRUE, rownamesAsLabels=FALSE, +## label.type=c("rownames", "column"), label.column=1, +## missing.data=c("fail", "warn", "OK"), +## extra.data=c("warn", "OK", "fail"), keep.all=TRUE + +test_that("works with data.frame", { + ## vector data coerced to data.frame (colname dt) + expect_equal(phylobase:::formatData(phy.alt, 1:5), + phylobase:::formatData(phy.alt, data.frame(dt=1:5))) +}) + +test_that("works with lists of vector", { + ## list of vector data coerced to data.frame (colnames as given) + expect_equal(phylobase:::formatData(phy.alt, list(a=1:5, b=6:10)), + phylobase:::formatData(phy.alt, data.frame(a=1:5, b=6:10))) +}) + +test_that("works factors", { + ## factor data coerced to data.frame (colname dt) + expect_equal(phylobase:::formatData(phy.alt, factor(letters[1:5])), + phylobase:::formatData(phy.alt, data.frame(dt=letters[1:5]))) +}) + +test_that("works with data.frame and 2 columns", { + ## matrix data coerced to data.frame (colnames V1, V2) + expect_equal(phylobase:::formatData(phy.alt, matrix(1:10, ncol=2)), + phylobase:::formatData(phy.alt, data.frame(V1=1:5, V2=6:10))) +}) + +test_that("works with data.frame colname as given", { + ## matrix data coerced to data.frame (colname as given) + expect_equal(phylobase:::formatData(phy.alt, matrix(1:10, ncol=2, + dimnames=list(NULL, c("a", "b")))), + phylobase:::formatData(phy.alt, data.frame(a=1:5, b=6:10))) +}) + +test_that("fails with non-supported objects (i.e. a phylo4)", { + ## error if dt is, say, a phylo4 object + expect_error(phylobase:::formatData(phy.alt, phy.alt)) +}) + +test_that("fails with column number is out of range", { + ## error if column number is out of range + expect_error(phylobase:::formatData(phy.alt, data.frame(a=1:5, + lab=rev(nid.tip)), type="tip", match.data=FALSE, + label.type="column", label.column=3)) +}) + +test_that("fails with column name is wrong", { + ## error if column name is wrong + expect_error(phylobase:::formatData(phy.alt, data.frame(a=1:5, + lab=rev(nid.tip)), type="tip", match.data=FALSE, + label.type="column", label.column="foo")) +}) + + +## +## matching options +## + +test_that("matching options work as expected", { + ## don't match (purely positional) + expect_equal(phylobase:::formatData(phy.alt, data.frame(a=1:5, + row.names=rev(nid.tip)), type="tip", match.data=FALSE), + data.frame(a=c(1:5, rep(NA, 4)), row.names=nid.all)) + ## match on rownames (node numbers) + expect_equal(phylobase:::formatData(phy.alt, data.frame(a=1:5, + row.names=rev(nid.tip)), type="tip", match.data=TRUE), + data.frame(a=c(5:1, rep(NA, 4)), row.names=nid.all)) + expect_equal(phylobase:::formatData(phy.alt, data.frame(a=1:5, + row.names=rev(nid.tip)), type="tip"), data.frame(a=c(5:1, + rep(NA, 4)), row.names=nid.all)) + ## match on rownames (labels) + expect_equal(phylobase:::formatData(phy.alt, data.frame(a=1:5, + row.names=rev(lab.tip)), type="tip", match.data=TRUE), + data.frame(a=c(5:1, rep(NA, 4)), row.names=nid.all)) + ## match on rownames (mixed node numbers and labels) + expect_equal(phylobase:::formatData(phy.alt, data.frame(a=1:5, + row.names=c(rev(lab.tip)[1:3], rev(nid.tip)[4:5])), + type="tip", match.data=TRUE), + data.frame(a=c(5:1, rep(NA, 4)), row.names=nid.all)) + ## but fails if rownamesAsLabels is TRUE + expect_error(phylobase:::formatData(phy.alt, data.frame(a=1:5, + row.names=c(rev(lab.tip)[1:3], rev(nid.tip)[4:5])), + type="tip", match.data=TRUE, rownamesAsLabels=TRUE)) +}) + +## +## label.type="column" and label.column=2 +## + +test_that("label.type=column works", { + ## should ignore label (purely positional) and retain a label col + expect_equal(phylobase:::formatData(phy.alt, data.frame(a=1:5, + lab=rev(nid.tip)), type="tip", match.data=FALSE, + label.type="column", label.column=2), + data.frame(a=c(1:5, rep(NA, 4)), lab=c(rev(nid.tip), rep(NA, + 4)), row.names=nid.all)) + ## match on label column (node numbers) + expect_equal(phylobase:::formatData(phy.alt, data.frame(a=1:5, + lab=rev(nid.tip)), type="tip", match.data=TRUE, + label.type="column", label.column=2), + data.frame(a=c(5:1, rep(NA, 4)), row.names=nid.all)) + expect_equal(phylobase:::formatData(phy.alt, data.frame(a=1:5, + lab=rev(nid.tip)), type="tip", + label.type="column", label.column=2), + data.frame(a=c(5:1, rep(NA, 4)), row.names=nid.all)) + ## match on label column (labels) + expect_equal(phylobase:::formatData(phy.alt, data.frame(a=1:5, + lab=rev(lab.tip)), type="tip", match.data=TRUE, + label.type="column", label.column=2), + data.frame(a=c(5:1, rep(NA, 4)), row.names=nid.all)) + expect_equal(phylobase:::formatData(phy.alt, data.frame(a=1:5, + lab=rev(lab.tip)), type="tip", match.data=TRUE, + label.type="column", label.column="lab"), + data.frame(a=c(5:1, rep(NA, 4)), row.names=nid.all)) + ## match on label column (mixed node numbers and labels) + expect_equal(phylobase:::formatData(phy.alt, data.frame(a=1:5, + lab=c(rev(lab.tip)[1:3], rev(nid.tip)[4:5])), type="tip", + match.data=TRUE, label.type="column", label.column=2), + data.frame(a=c(5:1, rep(NA, 4)), row.names=nid.all)) + ## but fails if rownamesAsLabels is TRUE + expect_error(phylobase:::formatData(phy.alt, data.frame(a=1:5, + lab=c(rev(lab.tip)[1:3], rev(nid.tip)[4:5])), + type="tip", match.data=TRUE, rownamesAsLabels=TRUE, + label.type="column", label.column=2)) + ## try to match internal nodes when type='tips' + expect_error(phylobase:::formatData(phy.alt, data.frame(a=1:5, row.names=4:8), + type="tip")) + ## and vice versa + expect_error(phylobase:::formatData(phy.alt, data.frame(a=6:9, row.names=1:4), + type="internal")) +}) + +## +## missing.data +## + +test_that("behaves as expected with missing data", { + ## force error conditions + expect_error(phylobase:::formatData(phy.alt, data.frame(a=1:3), type="tip")) + expect_error(phylobase:::formatData(phy.alt, data.frame(a=1:3), type="tip", + missing.data="fail")) + options(warn=3) + expect_error(phylobase:::formatData(phy.alt, data.frame(a=1:3), type="tip", + missing.data="warn")) + options(warn=0) + ## missing data with matching + expect_equal(phylobase:::formatData(phy.alt, data.frame(a=rev(nid.tip)[-1], + row.names=rev(nid.tip)[-1]), type="tip", missing.data="OK"), + data.frame(a=c(nid.tip[-5], rep(NA, 5)))) + expect_equal(phylobase:::formatData(phy.alt, data.frame(a=rev(nid.int)[-1], + row.names=rev(nid.int)[-1]), type="internal", missing.data="OK"), + data.frame(a=c(rep(NA, 5), nid.int[-4], NA))) + expect_equal(phylobase:::formatData(phy.alt, data.frame(a=rev(nid.all)[-1], + row.names=rev(nid.all)[-1]), type="all", missing.data="OK"), + data.frame(a=c(nid.all[-9], NA))) + ## missing data without matching + expect_equal(phylobase:::formatData(phy.alt, data.frame(a=rev(nid.tip)[-1]), + type="tip", match.data=FALSE, missing.data="OK"), + data.frame(a=c(rev(nid.tip)[-1], rep(NA, 5)))) + expect_equal(phylobase:::formatData(phy.alt, data.frame(a=rev(nid.int)[-1]), + type="internal", match.data=FALSE, missing.data="OK"), + data.frame(a=c(rep(NA, 5), rev(nid.int)[-1], NA))) + expect_equal(phylobase:::formatData(phy.alt, data.frame(a=rev(nid.all)[-1]), + type="all", match.data=FALSE, missing.data="OK"), + data.frame(a=c(rev(nid.all)[-1], NA))) +}) + +## +## extra.data +## + +test_that("works as expected with extra data", { + ## force error conditions + expect_error(phylobase:::formatData(phy.alt, data.frame(a=1:3), type="tip", + missing.data="fail")) + options(warn=3) + expect_error(phylobase:::formatData(phy.alt, data.frame(a=0:5, row.names=0:5), + type="tip", missing="warn")) + expect_error(phylobase:::formatData(phy.alt, data.frame(a=0:5, row.names=0:5), + type="tip")) + options(warn=0) + ## extra data with matching + expect_equal(phylobase:::formatData(phy.alt, data.frame(a=c(0L, rev(nid.tip)), + row.names=c(0, rev(nid.tip))), type="tip", extra.data="OK"), + data.frame(a=c(nid.tip, rep(NA, 4)))) + expect_equal(phylobase:::formatData(phy.alt, data.frame(a=c(0L, rev(nid.int)), + row.names=c(0, rev(nid.int))), type="internal", extra.data="OK"), + data.frame(a=c(rep(NA, 5), nid.int))) + expect_equal(phylobase:::formatData(phy.alt, data.frame(a=c(0L, rev(nid.all)), + row.names=c(0, rev(nid.all))), type="all", extra.data="OK"), + data.frame(a=nid.all)) + ## extra data without matching + expect_equal(phylobase:::formatData(phy.alt, data.frame(a=1:15), [TRUNCATED] To get the complete diff run: svnlook diff /svnroot/phylobase -r 939 From noreply at r-forge.r-project.org Wed May 7 16:58:18 2014 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Wed, 7 May 2014 16:58:18 +0200 (CEST) Subject: [Phylobase-commits] r940 - in pkg: inst/unitTests tests/testthat Message-ID: <20140507145818.B95EA1874AB@r-forge.r-project.org> Author: francois Date: 2014-05-07 16:58:18 +0200 (Wed, 07 May 2014) New Revision: 940 Added: pkg/tests/testthat/test.methods-oldclasses.R Removed: pkg/inst/unitTests/runit.methods-oldclasses.R Log: moved/converted methods-oldclasses tests Deleted: pkg/inst/unitTests/runit.methods-oldclasses.R =================================================================== --- pkg/inst/unitTests/runit.methods-oldclasses.R 2014-05-07 14:57:43 UTC (rev 939) +++ pkg/inst/unitTests/runit.methods-oldclasses.R 2014-05-07 14:58:18 UTC (rev 940) @@ -1,8 +0,0 @@ -# -# --- Test methods-oldclasses.R --- -# - -test.reorder.phylo <- function() { - # function(x, order = 'cladewise') -} - Copied: pkg/tests/testthat/test.methods-oldclasses.R (from rev 880, pkg/inst/unitTests/runit.methods-oldclasses.R) =================================================================== --- pkg/tests/testthat/test.methods-oldclasses.R (rev 0) +++ pkg/tests/testthat/test.methods-oldclasses.R 2014-05-07 14:58:18 UTC (rev 940) @@ -0,0 +1,8 @@ +# +# --- Test methods-oldclasses.R --- +# + +#test.reorder.phylo <- function() { +# # function(x, order = 'cladewise') +#} + From noreply at r-forge.r-project.org Wed May 7 16:58:41 2014 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Wed, 7 May 2014 16:58:41 +0200 (CEST) Subject: [Phylobase-commits] r941 - in pkg: inst/unitTests tests/testthat Message-ID: <20140507145841.E8E2C1874B1@r-forge.r-project.org> Author: francois Date: 2014-05-07 16:58:41 +0200 (Wed, 07 May 2014) New Revision: 941 Added: pkg/tests/testthat/test.prune.R Removed: pkg/inst/unitTests/runit.prune.R Log: moved/converted prune tests Deleted: pkg/inst/unitTests/runit.prune.R =================================================================== --- pkg/inst/unitTests/runit.prune.R 2014-05-07 14:58:18 UTC (rev 940) +++ pkg/inst/unitTests/runit.prune.R 2014-05-07 14:58:41 UTC (rev 941) @@ -1,16 +0,0 @@ -# -# --- Test prune.R --- -# - -data(geospiza) -gtree <- extractTree(geospiza) - -test.prune.phylo4 <- function() { - # function(phy, tip, trim.internal = TRUE, subtree = FALSE, ...) - checkIdentical(gtree, prune(gtree, character(0))) -} - -test.prune.phylo4d <- function() { - # function(phy, tip, trim.internal = TRUE, subtree = FALSE, ...) - checkIdentical(geospiza, prune(geospiza, character(0))) -} Copied: pkg/tests/testthat/test.prune.R (from rev 880, pkg/inst/unitTests/runit.prune.R) =================================================================== --- pkg/tests/testthat/test.prune.R (rev 0) +++ pkg/tests/testthat/test.prune.R 2014-05-07 14:58:41 UTC (rev 941) @@ -0,0 +1,18 @@ +# +# --- Test prune.R --- +# + +data(geospiza) +gtree <- extractTree(geospiza) + +context("prune") + +test_that("prune works on phylo4 objects", { + # function(phy, tip, trim.internal = TRUE, subtree = FALSE, ...) + expect_equal(gtree, prune(gtree, character(0))) +}) + +test_that("prune works on phylo4d objects", { + # function(phy, tip, trim.internal = TRUE, subtree = FALSE, ...) + expect_equal(geospiza, prune(geospiza, character(0))) +}) From noreply at r-forge.r-project.org Wed May 7 16:59:10 2014 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Wed, 7 May 2014 16:59:10 +0200 (CEST) Subject: [Phylobase-commits] r942 - in pkg: inst/unitTests tests/testthat Message-ID: <20140507145911.0B50C1874B9@r-forge.r-project.org> Author: francois Date: 2014-05-07 16:59:10 +0200 (Wed, 07 May 2014) New Revision: 942 Added: pkg/tests/testthat/test.setAs-Methods.R Removed: pkg/inst/unitTests/runit.setAs-Methods.R Log: moved/converted setAs-Methods tests Deleted: pkg/inst/unitTests/runit.setAs-Methods.R =================================================================== --- pkg/inst/unitTests/runit.setAs-Methods.R 2014-05-07 14:58:41 UTC (rev 941) +++ pkg/inst/unitTests/runit.setAs-Methods.R 2014-05-07 14:59:10 UTC (rev 942) @@ -1,161 +0,0 @@ -# -# --- Test setAs-Methods.R --- -# - -# create ape::phylo version of a simple tree for testing -nwk <- "((t1:0.1,t2:0.2)n7:0.7,(t3:0.3,(t4:0.4,t5:0.5)n9:0.9)n8:0.8)n6:0.6;" -tr <- ape::read.tree(text=nwk) - -# create analogous phylo4 object with a full complement of valid slots -ancestor <- as.integer(c(6,7,7,6,8,0,8,9,9)) -descendant <- as.integer(c(7,1,2,8,3,6,9,4,5)) -edge <- cbind(ancestor, descendant) -nid.tip <- 1:5 -nid.int <- 6:9 -lab.tip <- paste("t", nid.tip, sep="") -lab.int <- paste("n", nid.int, sep="") -elen <- descendant/10 -elab <- paste("e", ancestor, descendant, sep="-") -phy <- phylo4(x=edge, tip.label=lab.tip, node.label=lab.int, - edge.length=elen, edge.label=elab) - -# create altered version such that each slot is out of order with -# respect to all others; methods should be able to handle this -phy.alt <- phy -phy.alt at label <- rev(phy at label) -phy.alt at edge <- phy at edge[c(6:9, 1:5), ] -phy.alt at edge.length <- phy at edge.length[c(7:9, 1:6)] -phy.alt at edge.label <- phy at edge.label[c(8:9, 1:7)] - -#----------------------------------------------------------------------- - -test.phylo.As.phylo4 <- function() { - # simple case - as.phy <- as(tr, "phylo4") - checkTrue(class(as.phy)=="phylo4") - checkIdentical(tr$edge, unname(edges(as.phy, drop.root=TRUE))) - checkIdentical(tr$tip.label, unname(tipLabels(as.phy))) - checkIdentical(tr$node.label, unname(nodeLabels(as.phy))) - # TODO: ape keeps the root edge length in $root.edge - #checkIdentical(tr$edge.length, unname(edgeLength(as.phy))) - checkIdentical("preorder", edgeOrder(as.phy)) - - # test preservation of order attribute - as.phy <- as(reorder(tr, "cladewise"), "phylo4") - checkIdentical("preorder", edgeOrder(as.phy)) - as.phy <- as(reorder(tr, "pruningwise"), "phylo4") - checkIdentical("postorder", edgeOrder(as.phy)) - - # test phylo import when only 2 tips - tr2 <- ape::drop.tip(tr, 3:ape::Ntip(tr)) - checkEquals(nTips(as(tr2, "phylo4")), 2) - checkEquals(nNodes(as(tr2, "phylo4")), 1) - - # simple roundtrip test - phy <- as(tr, "phylo4") - checkEquals(tr, as(phy, "phylo")) -} - -# note: this method mostly just wraps phylo->phylo4 coercion (tested -# above) and phylo4d("phylo4") method (tested in runit.class-phylo4d.R) -test.phylo.As.phylo4d <- function() { - checkIdentical(as(tr, "phylo4d"), phylo4d(tr)) - phyd <- as(tr, "phylo4d") - checkTrue(class(phyd)=="phylo4d") - # simple roundtrip test - phyd <- as(tr, "phylo4d") - checkEquals(tr, as(phyd, "phylo")) -} - -test.multiPhylo.As.multiPhylo4 <- function() { -} - -test.multiPhylo4.As.multiPhylo <- function() { -} - -test.phylo4.As.phylo <- function() { -# note: checkEquals("phylo") uses all.equal.phylo() - - # phylo tree in unknown order - checkEquals(suppressWarnings(as(phy, "phylo")), tr) - # ...now check for warning for unknown order - opt <- options(warn=3) - checkException(as(phy, "phylo")) - options(opt) - - # phylo tree in cladewise order - tr.cladewise <- reorder(tr, "cladewise") - phy.c <- as(tr.cladewise, "phylo4") - checkEquals(as(phy.c, "phylo"), tr.cladewise) - - # phylo tree in pruningwise order - tr.pruningwise <- reorder(tr, "pruningwise") - phy.p <- as(tr.pruningwise, "phylo4") - checkEquals(as(phy.p, "phylo"), tr.pruningwise) - - # after transforming the jumbled tree to phylo and back, edge matrix - # and edge slots should still be in the original order, but node slots - # should be back in nodeId order - phy.r <- reorder(phy.alt) - phy.roundtrip.r <- reorder(as(as(phy.alt, "phylo"), "phylo4")) - checkIdentical(edges(phy.roundtrip.r), edges(phy.r)) - checkIdentical(edgeLength(phy.roundtrip.r), edgeLength(phy.r)) - checkIdentical(labels(phy.roundtrip.r), labels(phy.r)) - -} - -# this coerce method is defined implicitly -test.phylo4d.As.phylo <- function() { -# note: checkEquals("phylo") uses all.equal.phylo() - - # phylo tree in unknown order - phyd <- as(tr, "phylo4d") - tipData(phyd) <- data.frame(x=1:5, row.names=tipLabels(phyd)) - checkEquals(as(phyd, "phylo"), tr) - # ...now check for warning for unknown order - opt <- options(warn=3) - checkException(as(phyd, "phylo")) - options(opt) - - # phylo tree in cladewise order - tr.cladewise <- reorder(tr, "cladewise") - phyd <- as(tr.cladewise, "phylo4d") - tipData(phyd) <- data.frame(x=1:5, row.names=tipLabels(phyd)) - checkEquals(as(phyd, "phylo"), tr.cladewise) - # ...now check for warning for dropping data - opt <- options(warn=3) - checkException(as(phyd, "phylo")) - options(opt) - - # phylo tree in pruningwise order - tr.pruningwise <- reorder(tr, "pruningwise") - phyd <- as(tr.pruningwise, "phylo4d") - tipData(phyd) <- data.frame(x=1:5, row.names=tipLabels(phyd)) - checkEquals(as(phyd, "phylo"), tr.pruningwise) -} - -test.phylo4.As.phylog <- function() { -} - -test.phylo4ToDataFrame <- function() { - phy.show <- phylobase:::.phylo4ToDataFrame(phy.alt, "pretty") - checkIdentical(phy.show$label, c(lab.tip, lab.int)) - checkIdentical(phy.show$node, c(nid.tip, nid.int)) - checkIdentical(phy.show$ancestor, ancestor[match(c(nid.tip, nid.int), - descendant)]) - checkIdentical(phy.show$edge.length, sort(elen)) - checkIdentical(phy.show$node.type, factor(unname(nodeType(phy)))) -} - -## core functionality is already tested in test..phylo4ToDataFrame() -test.phylo4.As.data.frame <- function() { - # rooted tree - checkTrue(is.data.frame(as(phy, "data.frame"))) - - # unrooted tree - tru <- ape::unroot(tr) - phyu <- as(tru, "phylo4") - # should probably check that this coercion results in something - # *correct*, not just that it produces a data.frame - checkTrue(is.data.frame(as(phyu, "data.frame"))) -} Copied: pkg/tests/testthat/test.setAs-Methods.R (from rev 880, pkg/inst/unitTests/runit.setAs-Methods.R) =================================================================== --- pkg/tests/testthat/test.setAs-Methods.R (rev 0) +++ pkg/tests/testthat/test.setAs-Methods.R 2014-05-07 14:59:10 UTC (rev 942) @@ -0,0 +1,153 @@ +# +# --- Test setAs-Methods.R --- +# + +# create ape::phylo version of a simple tree for testing +nwk <- "((t1:0.1,t2:0.2)n7:0.7,(t3:0.3,(t4:0.4,t5:0.5)n9:0.9)n8:0.8)n6:0.6;" +tr <- ape::read.tree(text=nwk) + +# create analogous phylo4 object with a full complement of valid slots +ancestor <- as.integer(c(6,7,7,6,8,0,8,9,9)) +descendant <- as.integer(c(7,1,2,8,3,6,9,4,5)) +edge <- cbind(ancestor, descendant) +nid.tip <- 1:5 +nid.int <- 6:9 +lab.tip <- paste("t", nid.tip, sep="") +lab.int <- paste("n", nid.int, sep="") +elen <- descendant/10 +elab <- paste("e", ancestor, descendant, sep="-") +phy <- phylo4(x=edge, tip.label=lab.tip, node.label=lab.int, + edge.length=elen, edge.label=elab) + +# create altered version such that each slot is out of order with +# respect to all others; methods should be able to handle this +phy.alt <- phy +phy.alt at label <- rev(phy at label) +phy.alt at edge <- phy at edge[c(6:9, 1:5), ] +phy.alt at edge.length <- phy at edge.length[c(7:9, 1:6)] +phy.alt at edge.label <- phy at edge.label[c(8:9, 1:7)] + +#----------------------------------------------------------------------- + +context("setAs methods") + +test_that("phylo to phylo4", { + # simple case + as.phy <- as(tr, "phylo4") + expect_true(class(as.phy)=="phylo4") + expect_equal(tr$edge, unname(edges(as.phy, drop.root=TRUE))) + expect_equal(tr$tip.label, unname(tipLabels(as.phy))) + expect_equal(tr$node.label, unname(nodeLabels(as.phy))) + # TODO: ape keeps the root edge length in $root.edge + #expect_equal(tr$edge.length, unname(edgeLength(as.phy))) + expect_equal("preorder", edgeOrder(as.phy)) + + ## test preservation of order attribute + as.phy <- as(reorder(tr, "cladewise"), "phylo4") + expect_equal("preorder", edgeOrder(as.phy)) + as.phy <- as(reorder(tr, "pruningwise"), "phylo4") + expect_equal("postorder", edgeOrder(as.phy)) + + ## test phylo import when only 2 tips + tr2 <- ape::drop.tip(tr, 3:ape::Ntip(tr)) + expect_equal(nTips(as(tr2, "phylo4")), 2) + expect_equal(nNodes(as(tr2, "phylo4")), 1) + + ## simple roundtrip test + phy <- as(tr, "phylo4") + expect_equal(tr, as(phy, "phylo")) +}) + +# note: this method mostly just wraps phylo->phylo4 coercion (tested +# above) and phylo4d("phylo4") method (tested in runit.class-phylo4d.R) +test_that("phylo to phylo4d", { + expect_equal(as(tr, "phylo4d"), phylo4d(tr)) + phyd <- as(tr, "phylo4d") + expect_true(class(phyd)=="phylo4d") + # simple roundtrip test + phyd <- as(tr, "phylo4d") + expect_warning(phyo <- as(phyd, "phylo")) + expect_equal(tr, phyo) +}) + +## test.multiPhylo.As.multiPhylo4 <- function() { +## } + +## test.multiPhylo4.As.multiPhylo <- function() { +## } + +test_that("phylo4 to phylo", { + ## phylo tree in unknown order + expect_equal(suppressWarnings(as(phy, "phylo")), tr) + # ...now check for warning for unknown order + expect_warning(as(phy, "phylo")) + + # phylo tree in cladewise order + tr.cladewise <- reorder(tr, "cladewise") + phy.c <- as(tr.cladewise, "phylo4") + expect_equal(as(phy.c, "phylo"), tr.cladewise) + + # phylo tree in pruningwise order + tr.pruningwise <- reorder(tr, "pruningwise") + phy.p <- as(tr.pruningwise, "phylo4") + expect_equal(suppressWarnings(as(phy.p, "phylo")), tr.pruningwise) + + # after transforming the jumbled tree to phylo and back, edge matrix + # and edge slots should still be in the original order, but node slots + # should be back in nodeId order + phy.r <- reorder(phy.alt) + phy.roundtrip.r <- reorder(as(suppressWarnings(as(phy.alt, "phylo")), "phylo4")) + expect_equal(edges(phy.roundtrip.r), edges(phy.r)) + expect_equal(edgeLength(phy.roundtrip.r), edgeLength(phy.r)) + expect_equal(labels(phy.roundtrip.r), labels(phy.r)) +}) + +## this coerce method is defined implicitly +test_that("phylo to phylo4d", { + ## phylo tree in unknown order + phyd <- as(tr, "phylo4d") + tipData(phyd) <- data.frame(x=1:5, row.names=tipLabels(phyd)) + expect_equal(suppressWarnings(as(phyd, "phylo")), tr) + ## ...now check for warning for unknown order + expect_warning(as(phyd, "phylo")) + + ## phylo tree in cladewise order + tr.cladewise <- reorder(tr, "cladewise") + phyd <- as(tr.cladewise, "phylo4d") + tipData(phyd) <- data.frame(x=1:5, row.names=tipLabels(phyd)) + expect_equal(suppressWarnings(as(phyd, "phylo")), tr.cladewise) + ## ...now check for warning for dropping data + expect_warning(as(phyd, "phylo")) + + ## phylo tree in pruningwise order + tr.pruningwise <- reorder(tr, "pruningwise") + phyd <- as(tr.pruningwise, "phylo4d") + tipData(phyd) <- data.frame(x=1:5, row.names=tipLabels(phyd)) + expect_equal(suppressWarnings(as(phyd, "phylo")), tr.pruningwise) +}) + +##test.phylo4.As.phylog <- function() { +##} + +test_that("phylo4 to data.frame", { + phy.show <- phylobase:::.phylo4ToDataFrame(phy.alt, "pretty") + expect_equal(phy.show$label, c(lab.tip, lab.int)) + expect_equal(phy.show$node, c(nid.tip, nid.int)) + expect_equal(phy.show$ancestor, ancestor[match(c(nid.tip, nid.int), + descendant)]) + expect_equal(phy.show$edge.length, sort(elen)) + expect_equal(phy.show$node.type, factor(unname(nodeType(phy)))) +}) + +## core functionality is already tested in test..phylo4ToDataFrame() +test_that("phylo4 to data.frame", { + ## rooted tree + expect_true(is.data.frame(as(phy, "data.frame"))) + + ## unrooted tree + tru <- ape::unroot(tr) + phyu <- as(tru, "phylo4") + # should probably check that this coercion results in something + # *correct*, not just that it produces a data.frame + expect_true(is.data.frame(as(phyu, "data.frame"))) +}) From noreply at r-forge.r-project.org Thu May 8 00:11:45 2014 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Thu, 8 May 2014 00:11:45 +0200 (CEST) Subject: [Phylobase-commits] r943 - in pkg: inst/unitTests tests/testthat Message-ID: <20140507221145.197D81846A6@r-forge.r-project.org> Author: francois Date: 2014-05-08 00:11:44 +0200 (Thu, 08 May 2014) New Revision: 943 Added: pkg/tests/testthat/test.phylobase.options.R Removed: pkg/inst/unitTests/runit.phylobase.options.R Log: move/update phylobase.options tests Deleted: pkg/inst/unitTests/runit.phylobase.options.R =================================================================== --- pkg/inst/unitTests/runit.phylobase.options.R 2014-05-07 14:59:10 UTC (rev 942) +++ pkg/inst/unitTests/runit.phylobase.options.R 2014-05-07 22:11:44 UTC (rev 943) @@ -1,24 +0,0 @@ - -### -### phylobase.options -### - -op <- phylobase.options() -test.phylobase.options <- function() { - - ## test match.arg - checkException(phylobase.options(retic="test")) - no <- phylobase.options(retic="f") - checkIdentical(no$retic, "fail") - phylobase.options(op) - - ## test multiple args - no <- phylobase.options(retic="f", poly="f") - checkIdentical(no$retic, "fail") - checkIdentical(no$poly, "fail") - phylobase.options(op) - - ## check some failures - checkException(phylobase.options(1)) - checkException(phylobase.options("foobar"="foo")) -} Copied: pkg/tests/testthat/test.phylobase.options.R (from rev 880, pkg/inst/unitTests/runit.phylobase.options.R) =================================================================== --- pkg/tests/testthat/test.phylobase.options.R (rev 0) +++ pkg/tests/testthat/test.phylobase.options.R 2014-05-07 22:11:44 UTC (rev 943) @@ -0,0 +1,32 @@ + +### +### phylobase.options +### + +context("phylobase.options()") + +test_that("test of match.arg", { + op <- phylobase.options() + ## test match.arg + expect_error(phylobase.options(retic="test")) + no <- phylobase.options(retic="f") + expect_equal(no$retic, "fail") + phylobase.options(op) +}) + +test_that("test of multiple arguments", { + op <- phylobase.options() + ## test multiple args + no <- phylobase.options(retic="f", poly="f") + expect_equal(no$retic, "fail") + expect_equal(no$poly, "fail") + phylobase.options(op) +}) + +test_that("test some failures", { + op <- phylobase.options() + ## check some failures + expect_error(phylobase.options(1)) + expect_error(phylobase.options("foobar"="foo")) + phylobase.options(op) +}) From noreply at r-forge.r-project.org Thu May 8 00:13:01 2014 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Thu, 8 May 2014 00:13:01 +0200 (CEST) Subject: [Phylobase-commits] r944 - in pkg: inst/unitTests tests/testthat Message-ID: <20140507221301.1C986186946@r-forge.r-project.org> Author: francois Date: 2014-05-08 00:13:00 +0200 (Thu, 08 May 2014) New Revision: 944 Added: pkg/tests/testthat/test.pdata.R Removed: pkg/inst/unitTests/runit.pdata.R Log: move/update pdata tests Deleted: pkg/inst/unitTests/runit.pdata.R =================================================================== --- pkg/inst/unitTests/runit.pdata.R 2014-05-07 22:11:44 UTC (rev 943) +++ pkg/inst/unitTests/runit.pdata.R 2014-05-07 22:13:00 UTC (rev 944) @@ -1,21 +0,0 @@ -# -# --- Test pdata.R --- -# - -test.pdata <- function() { - # function(data,type,comment,metadata) -} - -test.check_pdata <- function() { -} - -test.extract.pdata <- function() { - # test "[" and "[[" -} - -test.assign.pdata <- function() { - # test "[<-" and "[[<-" -} - -test.plot.pdata <- function() { -} Copied: pkg/tests/testthat/test.pdata.R (from rev 880, pkg/inst/unitTests/runit.pdata.R) =================================================================== --- pkg/tests/testthat/test.pdata.R (rev 0) +++ pkg/tests/testthat/test.pdata.R 2014-05-07 22:13:00 UTC (rev 944) @@ -0,0 +1,21 @@ +# +# --- Test pdata.R --- +# + +## test.pdata <- function() { +## # function(data,type,comment,metadata) +## } + +## test.check_pdata <- function() { +## } + +## test.extract.pdata <- function() { +## # test "[" and "[[" +## } + +## test.assign.pdata <- function() { +## # test "[<-" and "[[<-" +## } + +## test.plot.pdata <- function() { +## } From noreply at r-forge.r-project.org Thu May 8 00:14:15 2014 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Thu, 8 May 2014 00:14:15 +0200 (CEST) Subject: [Phylobase-commits] r945 - in pkg: inst/unitTests tests/testthat Message-ID: <20140507221415.BE46F186984@r-forge.r-project.org> Author: francois Date: 2014-05-08 00:14:15 +0200 (Thu, 08 May 2014) New Revision: 945 Added: pkg/tests/testthat/test.phylo4.R Removed: pkg/inst/unitTests/runit.phylo4.R Log: move/update phylo4 tests Deleted: pkg/inst/unitTests/runit.phylo4.R =================================================================== --- pkg/inst/unitTests/runit.phylo4.R 2014-05-07 22:13:00 UTC (rev 944) +++ pkg/inst/unitTests/runit.phylo4.R 2014-05-07 22:14:15 UTC (rev 945) @@ -1,11 +0,0 @@ -# -# --- Test phylo4.R --- -# - -# phylo4.R is mostly used to set generics, so no testing needed - -# one non-exported method: -test..genlab <- function() { - # use phylobase:::.genlab -} - Copied: pkg/tests/testthat/test.phylo4.R (from rev 880, pkg/inst/unitTests/runit.phylo4.R) =================================================================== --- pkg/tests/testthat/test.phylo4.R (rev 0) +++ pkg/tests/testthat/test.phylo4.R 2014-05-07 22:14:15 UTC (rev 945) @@ -0,0 +1,11 @@ +# +# --- Test phylo4.R --- +# + +# phylo4.R is mostly used to set generics, so no testing needed + +# one non-exported method: +## test..genlab <- function() { +## # use phylobase:::.genlab +## } + From noreply at r-forge.r-project.org Thu May 8 15:08:33 2014 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Thu, 8 May 2014 15:08:33 +0200 (CEST) Subject: [Phylobase-commits] r946 - pkg/tests/testthat Message-ID: <20140508130833.27A5718715E@r-forge.r-project.org> Author: francois Date: 2014-05-08 15:08:32 +0200 (Thu, 08 May 2014) New Revision: 946 Added: pkg/tests/testthat/test.subset.R Log: move/convert all test to testthat Copied: pkg/tests/testthat/test.subset.R (from rev 880, pkg/inst/unitTests/runit.subset.R) =================================================================== --- pkg/tests/testthat/test.subset.R (rev 0) +++ pkg/tests/testthat/test.subset.R 2014-05-08 13:08:32 UTC (rev 946) @@ -0,0 +1,133 @@ +## +## --- Test subset.R --- +## + +## create phylo4 object with a full complement of valid slots +ancestor <- as.integer(c(6,7,7,6,8,0,8,9,9)) +descendant <- as.integer(c(7,1,2,8,3,6,9,4,5)) +edge <- cbind(ancestor, descendant) +nid.tip <- 1:5 +nid.int <- 6:9 +nid.all <- c(nid.tip, nid.int) +lab.tip <- paste("t", nid.tip, sep="") +lab.int <- paste("n", nid.int, sep="") +elen <- descendant/10 +elab <- paste("e", ancestor, descendant, sep="-") +phy <- phylo4(x=edge, tip.label=lab.tip, node.label=lab.int, + edge.length=elen, edge.label=elab) + +## create altered version such that each slot is out of order with +## respect to all others; methods should be able to handle this +phy.alt <- phy +phy.alt at label <- rev(phy at label) +phy.alt at edge <- phy at edge[c(6:9, 1:5), ] +phy.alt at edge.length <- phy at edge.length[c(7:9, 1:6)] +phy.alt at edge.label <- phy at edge.label[c(8:9, 1:7)] + +## now create phylo4d by adding data (with node IDs as row.names) +phyd.alt <- as(phy.alt, "phylo4d") +allDt <- data.frame(a=letters[nid.all], b=10*nid.all, row.names=nid.all) +tdata(phyd.alt, "all") <- allDt + +## create altered version such that data slots are out of order with +## respect to all others; methods should be able to handle this +nid.tip.r <- c(2,5,4,3,1) +nid.int.r <- c(8,7,9,6) +nid.all.r <- c(nid.tip.r, nid.int.r) +phyd.alt at data <- phyd.alt at data[rank(nid.all.r), ] + +#----------------------------------------------------------------------- + +context("subset and friends") + +## Also be testing "[" phylo4 methods here +test_that("subset on phylo4", { + # subset 2 tips + phy.sub2 <- subset(phy.alt, tips.include=c(2, 5)) + expect_equal(tipLabels(phy.sub2), setNames(c("t2", "t5"), c("1", "2"))) + expect_equal(nodeLabels(phy.sub2), setNames(c("n6"), c("3"))) + expect_equal(edgeLength(phy.sub2), + setNames(c(0.6, 0.9, 2.2), c("0-3", "3-1", "3-2"))) + expect_equal(subset(phy.alt, tips.exclude=c(1, 3, 4)), phy.sub2) + expect_equal(subset(phy.alt, tips.include=c("t2", "t5")), phy.sub2) + expect_equal(subset(phy.alt, tips.exclude=c("t1", "t3", "t4")), phy.sub2) + # subset 4 tips + phy.sub4 <- subset(phy.alt, tips.include=c(1, 2, 4, 5)) + expect_equal(tipLabels(phy.sub4), + setNames(c("t1", "t2", "t4", "t5"), c("1", "2", "3", "4"))) + expect_equal(nodeLabels(phy.sub4), + setNames(c("n6", "n7", "n9"), c("5", "6", "7"))) + expect_equal(edgeLength(phy.sub4), + setNames(c(0.6, 0.4, 0.5, 0.7, 0.1, 0.2, 1.7), + c("0-5", "7-3", "7-4", "5-6", "6-1", "6-2", "5-7"))) + expect_equal(subset(phy.alt, tips.exclude=3), phy.sub4) + expect_equal(subset(phy.alt, tips.include=c("t1", "t2", "t4", "t5")), + phy.sub4) + expect_equal(subset(phy.alt, tips.exclude="t3"), phy.sub4) + # check variants that should all return the original object + expect_equal(phy.alt, subset(phy.alt)) + expect_equal(phy.alt, subset(phy.alt, tipLabels(phy.alt))) + expect_equal(phy.alt, subset(phy.alt, seq_len(nTips(phy.alt)))) + expect_equal(phy.alt, phy.alt[tipLabels(phy.alt)]) + expect_equal(phy.alt, phy.alt[seq_len(nTips(phy.alt))]) + expect_equal(phy.alt, phy.alt[TRUE]) + # error if only one valid tip requested + expect_error(subset(phy, tips.include="t1")) + expect_error(suppressWarnings(subset(phy, tips.include=c("t1", "t999")))) + # error if zero valid tips requested + expect_error(suppressWarnings(subset(phy, tips.include="t999"))) + # error if more than one subset criteria are supplied + expect_error(subset(phyd, tips.include="t1", tips.exclude="t3")) +}) + +## Also testing "[" phylo4d methods here +##TODO get rid of some tests that are pretty much redundant with the +##above, and add tests focused more on tree data +test_that("subset on phylo4d", { + ## subset 2 tips + phyd.sub2 <- subset(phyd.alt, tips.include=c(2, 5)) + expect_equal(tipLabels(phyd.sub2), setNames(c("t2", "t5"), c("1", "2"))) + expect_equal(nodeLabels(phyd.sub2), setNames(c("n6"), c("3"))) + expect_equal(edgeLength(phyd.sub2), + setNames(c(0.6, 0.9, 2.2), c("0-3", "3-1", "3-2"))) + expect_equal(subset(phyd.alt, tips.exclude=c(1, 3, 4)), phyd.sub2) + expect_equal(subset(phyd.alt, tips.include=c("t2", "t5")), phyd.sub2) + expect_equal(subset(phyd.alt, tips.exclude=c("t1", "t3", "t4")), phyd.sub2) + ## subset 4 tips + phyd.sub4 <- subset(phyd.alt, tips.include=c(1, 2, 4, 5)) + expect_equal(tipLabels(phyd.sub4), + setNames(c("t1", "t2", "t4", "t5"), c("1", "2", "3", "4"))) + expect_equal(nodeLabels(phyd.sub4), + setNames(c("n6", "n7", "n9"), c("5", "6", "7"))) + expect_equal(edgeLength(phyd.sub4), + setNames(c(0.6, 0.4, 0.5, 0.7, 0.1, 0.2, 1.7), + c("0-5", "7-3", "7-4", "5-6", "6-1", "6-2", "5-7"))) + expect_equal(subset(phyd.alt, tips.exclude=3), phyd.sub4) + expect_equal(subset(phyd.alt, tips.include=c("t1", "t2", "t4", "t5")), + phyd.sub4) + expect_equal(subset(phyd.alt, tips.exclude="t3"), phyd.sub4) + ## check variants that should all return the original object + expect_equal(phyd.alt, subset(phyd.alt)) + expect_equal(phyd.alt, subset(phyd.alt, tipLabels(phyd.alt))) + expect_equal(phyd.alt, subset(phyd.alt, seq_len(nTips(phyd.alt)))) + expect_equal(phyd.alt, phyd.alt[tipLabels(phyd.alt)]) + expect_equal(phyd.alt, phyd.alt[seq_len(nTips(phyd.alt))]) + expect_equal(phyd.alt, phyd.alt[TRUE]) + ## error if only one valid tip requested + expect_error(subset(phyd.alt, tips.include="t1")) + expect_error(suppressWarnings(subset(phyd.alt, tips.include=c("t1", "t999")))) + ## error if zero valid tips requested + expect_error(suppressWarnings(subset(phyd.alt, tips.include="t999"))) + # subset tips that include an NA value + ##TODO uncomment this after tdata is working right with scrambled order + ## tdata(phyd.alt)["t5", "a"] <- NA + ## tdata(phyd.sub2)["t5", "a"] <- NA + ## expect_equal(phyd.sub2, subset(phyd.alt, tips.include=c(2, 5))) +}) + +test_that("subset on extractTree", { + # extract phylo4 from itself + expect_equal(phy.alt, extractTree(phy.alt)) + # extract phylo4 from phylo4d + expect_equal(phy.alt, extractTree(phyd.alt)) +}) From noreply at r-forge.r-project.org Thu May 8 15:09:02 2014 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Thu, 8 May 2014 15:09:02 +0200 (CEST) Subject: [Phylobase-commits] r947 - pkg/tests/testthat Message-ID: <20140508130902.5852C1800B4@r-forge.r-project.org> Author: francois Date: 2014-05-08 15:09:02 +0200 (Thu, 08 May 2014) New Revision: 947 Added: pkg/tests/testthat/test.tbind.R Log: move/convert tbind to testthat Copied: pkg/tests/testthat/test.tbind.R (from rev 880, pkg/inst/unitTests/runit.tbind.R) =================================================================== --- pkg/tests/testthat/test.tbind.R (rev 0) +++ pkg/tests/testthat/test.tbind.R 2014-05-08 13:09:02 UTC (rev 947) @@ -0,0 +1,8 @@ +## # +## # --- Test tbind.R --- +## # + +## test.tbind <- function() { +## # function(...,checkData=TRUE) +## } + From noreply at r-forge.r-project.org Thu May 8 15:09:23 2014 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Thu, 8 May 2014 15:09:23 +0200 (CEST) Subject: [Phylobase-commits] r948 - pkg/tests/testthat Message-ID: <20140508130923.1DE83181036@r-forge.r-project.org> Author: francois Date: 2014-05-08 15:09:22 +0200 (Thu, 08 May 2014) New Revision: 948 Added: pkg/tests/testthat/test.treePlot.R Log: move/convert treePlot to testthat Copied: pkg/tests/testthat/test.treePlot.R (from rev 880, pkg/inst/unitTests/runit.treePlot.R) =================================================================== --- pkg/tests/testthat/test.treePlot.R (rev 0) +++ pkg/tests/testthat/test.treePlot.R 2014-05-08 13:09:22 UTC (rev 948) @@ -0,0 +1,30 @@ +## +## --- Test treePlot.R --- +## + +## test.treePlot <- function() { +## } + +## test.plotOneTree <- function() { +## } + +## test.phyloXXYY <- function() { +## # function(phy, tip.order = NULL) +## } + +## test..bubLegendGrob <- function() { +## } + +## test.drawDetails.bubLegend <- function() { +## } + +## test.phylobubbles <- function() { +## } + +## test.tip.data.plot <- function() { +## } + +## test.plot.phylo4 <- function() { +## # signature(x='phylo4', y='missing') +## } + From noreply at r-forge.r-project.org Thu May 8 15:13:17 2014 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Thu, 8 May 2014 15:13:17 +0200 (CEST) Subject: [Phylobase-commits] r949 - pkg/tests/testthat Message-ID: <20140508131317.E34AF187177@r-forge.r-project.org> Author: francois Date: 2014-05-08 15:13:17 +0200 (Thu, 08 May 2014) New Revision: 949 Added: pkg/tests/testthat/test.treestruc.R Log: move/convert treestruc to testthat Copied: pkg/tests/testthat/test.treestruc.R (from rev 880, pkg/inst/unitTests/runit.treestruc.R) =================================================================== --- pkg/tests/testthat/test.treestruc.R (rev 0) +++ pkg/tests/testthat/test.treestruc.R 2014-05-08 13:13:17 UTC (rev 949) @@ -0,0 +1,30 @@ +# +# --- Test treestruc.R functions --- +# + +context("tree structures") + +test_that("hasPoly", { + # construct simple polytomy + owls <- ape::read.tree(text = + "((Strix_aluco:4.2,Asio_otus:4.2):3.1,Athene_noctua:7.3);") + owls$edge <- matrix(c(4,4,4,1,2,3), ncol=2) + owls$Nnode <- 1 + owls$edge.length <- owls$edge.length[-4] + tr <- as(owls, "phylo4") + expect_true(hasPoly(tr)) + # test against empty tree + expect_true(!hasPoly(new("phylo4"))) +}) + + +test_that("hasSingle", { + # test against empty tree + expect_true(!hasSingle(new("phylo4"))) +}) + +test_that("hasRetic", { + # test against empty tree + expect_true(!hasRetic(new("phylo4"))) +}) + From noreply at r-forge.r-project.org Thu May 8 15:40:05 2014 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Thu, 8 May 2014 15:40:05 +0200 (CEST) Subject: [Phylobase-commits] r950 - pkg/inst Message-ID: <20140508134005.8718F181036@r-forge.r-project.org> Author: francois Date: 2014-05-08 15:40:05 +0200 (Thu, 08 May 2014) New Revision: 950 Removed: pkg/inst/unitTests/ Log: delete unitTests directory From noreply at r-forge.r-project.org Thu May 8 16:46:53 2014 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Thu, 8 May 2014 16:46:53 +0200 (CEST) Subject: [Phylobase-commits] r951 - in pkg: . man Message-ID: <20140508144653.8587F186D3C@r-forge.r-project.org> Author: francois Date: 2014-05-08 16:46:52 +0200 (Thu, 08 May 2014) New Revision: 951 Modified: pkg/NAMESPACE pkg/man/MRCA.Rd pkg/man/ancestors.Rd pkg/man/checkPhylo4.Rd pkg/man/edgeLength-methods.Rd pkg/man/edges-accessors.Rd pkg/man/extractTree.Rd pkg/man/formatData.Rd pkg/man/geospiza.Rd pkg/man/getNode-methods.Rd pkg/man/labels-methods.Rd pkg/man/multiPhylo-class.Rd pkg/man/nTips-methods.Rd pkg/man/nodeId-methods.Rd pkg/man/owls4.Rd pkg/man/pdata-class.Rd pkg/man/pdata.Rd pkg/man/phylo4-class.Rd pkg/man/phylo4-methods.Rd pkg/man/phylo4d-accessors.Rd pkg/man/phylo4d-class.Rd pkg/man/phylo4d-methods.Rd pkg/man/phyloXXYY.Rd pkg/man/phylobase-package.Rd pkg/man/phylobase.options.Rd pkg/man/phylobubbles.Rd pkg/man/phylomat-class.Rd pkg/man/plotOneTree.Rd pkg/man/print-methods.Rd pkg/man/readNexus.Rd pkg/man/reorder-methods.Rd pkg/man/root-methods.Rd pkg/man/setAs-methods.Rd pkg/man/shortestPath-methods.Rd pkg/man/subset-methods.Rd pkg/man/summary-methods.Rd pkg/man/tdata-methods.Rd pkg/man/tip.data.plot.Rd pkg/man/treePlot-methods.Rd pkg/man/treeStructure-methods.Rd Log: update docs, and NAMESPACE after bug fix in roxygen2 Modified: pkg/NAMESPACE =================================================================== --- pkg/NAMESPACE 2014-05-08 13:40:05 UTC (rev 950) +++ pkg/NAMESPACE 2014-05-08 14:46:52 UTC (rev 951) @@ -1,3 +1,5 @@ +# Generated by roxygen2 (4.0.0.99): do not edit by hand + export("edgeLabels<-") export("edgeLength<-") export("labels<-") Modified: pkg/man/MRCA.Rd =================================================================== --- pkg/man/MRCA.Rd 2014-05-08 13:40:05 UTC (rev 950) +++ pkg/man/MRCA.Rd 2014-05-08 14:46:52 UTC (rev 951) @@ -1,4 +1,4 @@ -% Generated by roxygen2 (4.0.0): do not edit by hand +% Generated by roxygen2 (4.0.0.99): do not edit by hand \docType{methods} \name{MRCA} \alias{MRCA} Modified: pkg/man/ancestors.Rd =================================================================== --- pkg/man/ancestors.Rd 2014-05-08 13:40:05 UTC (rev 950) +++ pkg/man/ancestors.Rd 2014-05-08 14:46:52 UTC (rev 951) @@ -1,4 +1,4 @@ -% Generated by roxygen2 (4.0.0): do not edit by hand +% Generated by roxygen2 (4.0.0.99): do not edit by hand \name{ancestor} \alias{ancestor} \alias{ancestors} Modified: pkg/man/checkPhylo4.Rd =================================================================== --- pkg/man/checkPhylo4.Rd 2014-05-08 13:40:05 UTC (rev 950) +++ pkg/man/checkPhylo4.Rd 2014-05-08 14:46:52 UTC (rev 951) @@ -1,4 +1,4 @@ -% Generated by roxygen2 (4.0.0): do not edit by hand +% Generated by roxygen2 (4.0.0.99): do not edit by hand \name{checkPhylo4} \alias{checkPhylo4} \alias{checkPhylo4Data} Modified: pkg/man/edgeLength-methods.Rd =================================================================== --- pkg/man/edgeLength-methods.Rd 2014-05-08 13:40:05 UTC (rev 950) +++ pkg/man/edgeLength-methods.Rd 2014-05-08 14:46:52 UTC (rev 951) @@ -1,4 +1,4 @@ -% Generated by roxygen2 (4.0.0): do not edit by hand +% Generated by roxygen2 (4.0.0.99): do not edit by hand \docType{methods} \name{hasEdgeLength} \alias{depthTips} Modified: pkg/man/edges-accessors.Rd =================================================================== --- pkg/man/edges-accessors.Rd 2014-05-08 13:40:05 UTC (rev 950) +++ pkg/man/edges-accessors.Rd 2014-05-08 14:46:52 UTC (rev 951) @@ -1,4 +1,4 @@ -% Generated by roxygen2 (4.0.0): do not edit by hand +% Generated by roxygen2 (4.0.0.99): do not edit by hand \docType{methods} \name{edges} \alias{edgeOrder} Modified: pkg/man/extractTree.Rd =================================================================== --- pkg/man/extractTree.Rd 2014-05-08 13:40:05 UTC (rev 950) +++ pkg/man/extractTree.Rd 2014-05-08 14:46:52 UTC (rev 951) @@ -1,4 +1,4 @@ -% Generated by roxygen2 (4.0.0): do not edit by hand +% Generated by roxygen2 (4.0.0.99): do not edit by hand \name{extractTree} \alias{extractTree} \title{Get tree from tree+data object} Modified: pkg/man/formatData.Rd =================================================================== --- pkg/man/formatData.Rd 2014-05-08 13:40:05 UTC (rev 950) +++ pkg/man/formatData.Rd 2014-05-08 14:46:52 UTC (rev 951) @@ -1,4 +1,4 @@ -% Generated by roxygen2 (4.0.0): do not edit by hand +% Generated by roxygen2 (4.0.0.99): do not edit by hand \name{formatData} \alias{formatData} \title{Format data for use in phylo4d objects} Modified: pkg/man/geospiza.Rd =================================================================== --- pkg/man/geospiza.Rd 2014-05-08 13:40:05 UTC (rev 950) +++ pkg/man/geospiza.Rd 2014-05-08 14:46:52 UTC (rev 951) @@ -1,4 +1,4 @@ -% Generated by roxygen2 (4.0.0): do not edit by hand +% Generated by roxygen2 (4.0.0.99): do not edit by hand \docType{data} \name{geospiza} \alias{geospiza} Modified: pkg/man/getNode-methods.Rd =================================================================== --- pkg/man/getNode-methods.Rd 2014-05-08 13:40:05 UTC (rev 950) +++ pkg/man/getNode-methods.Rd 2014-05-08 14:46:52 UTC (rev 951) @@ -1,4 +1,4 @@ -% Generated by roxygen2 (4.0.0): do not edit by hand +% Generated by roxygen2 (4.0.0.99): do not edit by hand \docType{methods} \name{getNode} \alias{getEdge} Modified: pkg/man/labels-methods.Rd =================================================================== --- pkg/man/labels-methods.Rd 2014-05-08 13:40:05 UTC (rev 950) +++ pkg/man/labels-methods.Rd 2014-05-08 14:46:52 UTC (rev 951) @@ -1,4 +1,4 @@ -% Generated by roxygen2 (4.0.0): do not edit by hand +% Generated by roxygen2 (4.0.0.99): do not edit by hand \docType{methods} \name{phylo4-labels} \alias{edgeLabels} Modified: pkg/man/multiPhylo-class.Rd =================================================================== --- pkg/man/multiPhylo-class.Rd 2014-05-08 13:40:05 UTC (rev 950) +++ pkg/man/multiPhylo-class.Rd 2014-05-08 14:46:52 UTC (rev 951) @@ -1,4 +1,4 @@ -% Generated by roxygen2 (4.0.0): do not edit by hand +% Generated by roxygen2 (4.0.0.99): do not edit by hand \docType{class} \name{multiPhylo-class} \alias{multiPhylo-class} Modified: pkg/man/nTips-methods.Rd =================================================================== --- pkg/man/nTips-methods.Rd 2014-05-08 13:40:05 UTC (rev 950) +++ pkg/man/nTips-methods.Rd 2014-05-08 14:46:52 UTC (rev 951) @@ -1,4 +1,4 @@ -% Generated by roxygen2 (4.0.0): do not edit by hand +% Generated by roxygen2 (4.0.0.99): do not edit by hand \docType{methods} \name{nTips} \alias{nEdges} Modified: pkg/man/nodeId-methods.Rd =================================================================== --- pkg/man/nodeId-methods.Rd 2014-05-08 13:40:05 UTC (rev 950) +++ pkg/man/nodeId-methods.Rd 2014-05-08 14:46:52 UTC (rev 951) @@ -1,4 +1,4 @@ -% Generated by roxygen2 (4.0.0): do not edit by hand +% Generated by roxygen2 (4.0.0.99): do not edit by hand \docType{methods} \name{nodeId} \alias{edgeId} Modified: pkg/man/owls4.Rd =================================================================== --- pkg/man/owls4.Rd 2014-05-08 13:40:05 UTC (rev 950) +++ pkg/man/owls4.Rd 2014-05-08 14:46:52 UTC (rev 951) @@ -1,4 +1,4 @@ -% Generated by roxygen2 (4.0.0): do not edit by hand +% Generated by roxygen2 (4.0.0.99): do not edit by hand \docType{data} \name{owls4} \alias{owls4} Modified: pkg/man/pdata-class.Rd =================================================================== --- pkg/man/pdata-class.Rd 2014-05-08 13:40:05 UTC (rev 950) +++ pkg/man/pdata-class.Rd 2014-05-08 14:46:52 UTC (rev 951) @@ -1,4 +1,4 @@ -% Generated by roxygen2 (4.0.0): do not edit by hand +% Generated by roxygen2 (4.0.0.99): do not edit by hand \docType{class} \name{pdata-class} \alias{[,pdata,ANY,ANY,ANY-method} Modified: pkg/man/pdata.Rd =================================================================== --- pkg/man/pdata.Rd 2014-05-08 13:40:05 UTC (rev 950) +++ pkg/man/pdata.Rd 2014-05-08 14:46:52 UTC (rev 951) @@ -1,4 +1,4 @@ -% Generated by roxygen2 (4.0.0): do not edit by hand +% Generated by roxygen2 (4.0.0.99): do not edit by hand \name{pdata} \alias{check_pdata} \alias{pdata} Modified: pkg/man/phylo4-class.Rd =================================================================== --- pkg/man/phylo4-class.Rd 2014-05-08 13:40:05 UTC (rev 950) +++ pkg/man/phylo4-class.Rd 2014-05-08 14:46:52 UTC (rev 951) @@ -1,4 +1,4 @@ -% Generated by roxygen2 (4.0.0): do not edit by hand +% Generated by roxygen2 (4.0.0.99): do not edit by hand \docType{class} \name{phylo4-class} \alias{phylo4-class} Modified: pkg/man/phylo4-methods.Rd =================================================================== --- pkg/man/phylo4-methods.Rd 2014-05-08 13:40:05 UTC (rev 950) +++ pkg/man/phylo4-methods.Rd 2014-05-08 14:46:52 UTC (rev 951) @@ -1,4 +1,4 @@ -% Generated by roxygen2 (4.0.0): do not edit by hand +% Generated by roxygen2 (4.0.0.99): do not edit by hand \docType{methods} \name{phylo4-methods} \alias{phylo4} Modified: pkg/man/phylo4d-accessors.Rd =================================================================== --- pkg/man/phylo4d-accessors.Rd 2014-05-08 13:40:05 UTC (rev 950) +++ pkg/man/phylo4d-accessors.Rd 2014-05-08 14:46:52 UTC (rev 951) @@ -1,4 +1,4 @@ -% Generated by roxygen2 (4.0.0): do not edit by hand +% Generated by roxygen2 (4.0.0.99): do not edit by hand \docType{methods} \name{hasTipData} \alias{hasNodeData} Modified: pkg/man/phylo4d-class.Rd =================================================================== --- pkg/man/phylo4d-class.Rd 2014-05-08 13:40:05 UTC (rev 950) +++ pkg/man/phylo4d-class.Rd 2014-05-08 14:46:52 UTC (rev 951) @@ -1,4 +1,4 @@ -% Generated by roxygen2 (4.0.0): do not edit by hand +% Generated by roxygen2 (4.0.0.99): do not edit by hand \docType{class} \name{phylo4d-class} \alias{phylo4d-class} Modified: pkg/man/phylo4d-methods.Rd =================================================================== --- pkg/man/phylo4d-methods.Rd 2014-05-08 13:40:05 UTC (rev 950) +++ pkg/man/phylo4d-methods.Rd 2014-05-08 14:46:52 UTC (rev 951) @@ -1,4 +1,4 @@ -% Generated by roxygen2 (4.0.0): do not edit by hand +% Generated by roxygen2 (4.0.0.99): do not edit by hand \docType{methods} \name{phylo4d} \alias{phylo4d} Modified: pkg/man/phyloXXYY.Rd =================================================================== --- pkg/man/phyloXXYY.Rd 2014-05-08 13:40:05 UTC (rev 950) +++ pkg/man/phyloXXYY.Rd 2014-05-08 14:46:52 UTC (rev 951) @@ -1,4 +1,4 @@ -% Generated by roxygen2 (4.0.0): do not edit by hand +% Generated by roxygen2 (4.0.0.99): do not edit by hand \name{phyloXXYY} \alias{phyloXXYY} \title{Calculate node x and y coordinates} Modified: pkg/man/phylobase-package.Rd =================================================================== --- pkg/man/phylobase-package.Rd 2014-05-08 13:40:05 UTC (rev 950) +++ pkg/man/phylobase-package.Rd 2014-05-08 14:46:52 UTC (rev 951) @@ -1,4 +1,4 @@ -% Generated by roxygen2 (4.0.0): do not edit by hand +% Generated by roxygen2 (4.0.0.99): do not edit by hand \docType{package} \name{phylobase-package} \alias{phylobase} Modified: pkg/man/phylobase.options.Rd =================================================================== --- pkg/man/phylobase.options.Rd 2014-05-08 13:40:05 UTC (rev 950) +++ pkg/man/phylobase.options.Rd 2014-05-08 14:46:52 UTC (rev 951) @@ -1,4 +1,4 @@ -% Generated by roxygen2 (4.0.0): do not edit by hand +% Generated by roxygen2 (4.0.0.99): do not edit by hand \name{phylobase.options} \alias{phylobase.options} \title{Set or return options of phylobase} Modified: pkg/man/phylobubbles.Rd =================================================================== --- pkg/man/phylobubbles.Rd 2014-05-08 13:40:05 UTC (rev 950) +++ pkg/man/phylobubbles.Rd 2014-05-08 14:46:52 UTC (rev 951) @@ -1,4 +1,4 @@ -% Generated by roxygen2 (4.0.0): do not edit by hand +% Generated by roxygen2 (4.0.0.99): do not edit by hand \name{phylobubbles} \alias{phylobubbles} \title{Bubble plots for phylo4d objects} Modified: pkg/man/phylomat-class.Rd =================================================================== --- pkg/man/phylomat-class.Rd 2014-05-08 13:40:05 UTC (rev 950) +++ pkg/man/phylomat-class.Rd 2014-05-08 14:46:52 UTC (rev 951) @@ -1,4 +1,4 @@ -% Generated by roxygen2 (4.0.0): do not edit by hand +% Generated by roxygen2 (4.0.0.99): do not edit by hand \docType{class} \name{phylomat-class} \alias{as_phylo4vcov} Modified: pkg/man/plotOneTree.Rd =================================================================== --- pkg/man/plotOneTree.Rd 2014-05-08 13:40:05 UTC (rev 950) +++ pkg/man/plotOneTree.Rd 2014-05-08 14:46:52 UTC (rev 951) @@ -1,4 +1,4 @@ -% Generated by roxygen2 (4.0.0): do not edit by hand +% Generated by roxygen2 (4.0.0.99): do not edit by hand \name{plotOneTree} \alias{plotOneTree} \title{Plot a phylo4 object} Modified: pkg/man/print-methods.Rd =================================================================== --- pkg/man/print-methods.Rd 2014-05-08 13:40:05 UTC (rev 950) +++ pkg/man/print-methods.Rd 2014-05-08 14:46:52 UTC (rev 951) @@ -1,4 +1,4 @@ -% Generated by roxygen2 (4.0.0): do not edit by hand +% Generated by roxygen2 (4.0.0.99): do not edit by hand \docType{methods} \name{print} \alias{head} Modified: pkg/man/readNexus.Rd =================================================================== --- pkg/man/readNexus.Rd 2014-05-08 13:40:05 UTC (rev 950) +++ pkg/man/readNexus.Rd 2014-05-08 14:46:52 UTC (rev 951) @@ -1,4 +1,4 @@ -% Generated by roxygen2 (4.0.0): do not edit by hand +% Generated by roxygen2 (4.0.0.99): do not edit by hand \docType{methods} \name{Import Nexus and Newick files} \alias{Import Nexus and Newick files} Modified: pkg/man/reorder-methods.Rd =================================================================== --- pkg/man/reorder-methods.Rd 2014-05-08 13:40:05 UTC (rev 950) +++ pkg/man/reorder-methods.Rd 2014-05-08 14:46:52 UTC (rev 951) @@ -1,4 +1,4 @@ -% Generated by roxygen2 (4.0.0): do not edit by hand +% Generated by roxygen2 (4.0.0.99): do not edit by hand \docType{methods} \name{reorder-methods} \alias{reorder} Modified: pkg/man/root-methods.Rd =================================================================== --- pkg/man/root-methods.Rd 2014-05-08 13:40:05 UTC (rev 950) +++ pkg/man/root-methods.Rd 2014-05-08 14:46:52 UTC (rev 951) @@ -1,4 +1,4 @@ -% Generated by roxygen2 (4.0.0): do not edit by hand +% Generated by roxygen2 (4.0.0.99): do not edit by hand \docType{methods} \name{isRooted} \alias{isRooted} Modified: pkg/man/setAs-methods.Rd =================================================================== --- pkg/man/setAs-methods.Rd 2014-05-08 13:40:05 UTC (rev 950) +++ pkg/man/setAs-methods.Rd 2014-05-08 14:46:52 UTC (rev 951) @@ -1,4 +1,4 @@ -% Generated by roxygen2 (4.0.0): do not edit by hand +% Generated by roxygen2 (4.0.0.99): do not edit by hand \docType{methods} \name{setAs} \alias{as} Modified: pkg/man/shortestPath-methods.Rd =================================================================== --- pkg/man/shortestPath-methods.Rd 2014-05-08 13:40:05 UTC (rev 950) +++ pkg/man/shortestPath-methods.Rd 2014-05-08 14:46:52 UTC (rev 951) @@ -1,4 +1,4 @@ -% Generated by roxygen2 (4.0.0): do not edit by hand +% Generated by roxygen2 (4.0.0.99): do not edit by hand \docType{methods} \name{shortestPath} \alias{shortestPath} Modified: pkg/man/subset-methods.Rd =================================================================== --- pkg/man/subset-methods.Rd 2014-05-08 13:40:05 UTC (rev 950) +++ pkg/man/subset-methods.Rd 2014-05-08 14:46:52 UTC (rev 951) @@ -1,4 +1,4 @@ -% Generated by roxygen2 (4.0.0): do not edit by hand +% Generated by roxygen2 (4.0.0.99): do not edit by hand \docType{methods} \name{subset-methods} \alias{[} Modified: pkg/man/summary-methods.Rd =================================================================== --- pkg/man/summary-methods.Rd 2014-05-08 13:40:05 UTC (rev 950) +++ pkg/man/summary-methods.Rd 2014-05-08 14:46:52 UTC (rev 951) @@ -1,4 +1,4 @@ -% Generated by roxygen2 (4.0.0): do not edit by hand +% Generated by roxygen2 (4.0.0.99): do not edit by hand \docType{methods} \name{summary-methods} \alias{nodeType} Modified: pkg/man/tdata-methods.Rd =================================================================== --- pkg/man/tdata-methods.Rd 2014-05-08 13:40:05 UTC (rev 950) +++ pkg/man/tdata-methods.Rd 2014-05-08 14:46:52 UTC (rev 951) @@ -1,4 +1,4 @@ -% Generated by roxygen2 (4.0.0): do not edit by hand +% Generated by roxygen2 (4.0.0.99): do not edit by hand \docType{methods} \name{tdata} \alias{nodeData} Modified: pkg/man/tip.data.plot.Rd =================================================================== --- pkg/man/tip.data.plot.Rd 2014-05-08 13:40:05 UTC (rev 950) +++ pkg/man/tip.data.plot.Rd 2014-05-08 14:46:52 UTC (rev 951) @@ -1,4 +1,4 @@ -% Generated by roxygen2 (4.0.0): do not edit by hand +% Generated by roxygen2 (4.0.0.99): do not edit by hand \name{tip.data.plot} \alias{tip.data.plot} \title{Plotting trees and associated data} Modified: pkg/man/treePlot-methods.Rd =================================================================== --- pkg/man/treePlot-methods.Rd 2014-05-08 13:40:05 UTC (rev 950) +++ pkg/man/treePlot-methods.Rd 2014-05-08 14:46:52 UTC (rev 951) @@ -1,4 +1,4 @@ -% Generated by roxygen2 (4.0.0): do not edit by hand +% Generated by roxygen2 (4.0.0.99): do not edit by hand \docType{methods} \name{treePlot-methods} \alias{plot} Modified: pkg/man/treeStructure-methods.Rd =================================================================== --- pkg/man/treeStructure-methods.Rd 2014-05-08 13:40:05 UTC (rev 950) +++ pkg/man/treeStructure-methods.Rd 2014-05-08 14:46:52 UTC (rev 951) @@ -1,4 +1,4 @@ -% Generated by roxygen2 (4.0.0): do not edit by hand +% Generated by roxygen2 (4.0.0.99): do not edit by hand \docType{methods} \name{hasSingle} \alias{hasPoly}