[Phylobase-commits] r585 - in pkg: R data inst/unitTests man

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Tue Aug 25 02:59:46 CEST 2009


Author: bbolker
Date: 2009-08-25 02:59:46 +0200 (Tue, 25 Aug 2009)
New Revision: 585

Modified:
   pkg/R/class-phylo4.R
   pkg/R/class-phylo4d.R
   pkg/data/geospiza.rda
   pkg/inst/unitTests/runit.prune.R
   pkg/man/phylo4-class.Rd
   pkg/man/phylo4d-class.Rd
Log:
added annotate slot to phylo4, metadata slot to phylo4d
tweaked runit.prune.R tests: checkEquals -> checkIdentical



Modified: pkg/R/class-phylo4.R
===================================================================
--- pkg/R/class-phylo4.R	2009-08-25 00:58:59 UTC (rev 584)
+++ pkg/R/class-phylo4.R	2009-08-25 00:59:46 UTC (rev 585)
@@ -5,7 +5,8 @@
                         node.label = "character",
                         tip.label = "character",
                         edge.label = "character",
-                        order = "character"),
+                        order = "character",
+                        annote = "list"),
          prototype = list(
                         edge = matrix(nrow = 0, ncol = 2,
                             dimname = list(NULL, c("ancestor", "descendant"))),
@@ -14,7 +15,8 @@
                         tip.label = character(0),
                         node.label = character(0),
                         edge.label = character(0),
-                        order = "unknown"
+                        order = "unknown",
+                        annote = list()
                        ),
          validity = checkPhylo4)
 
@@ -104,7 +106,7 @@
 ## first arg is a matrix
 setMethod("phylo4", "matrix",
     function(x, edge.length = NULL, tip.label = NULL, node.label = NULL,
-             edge.label = NULL, order="unknown", ...) {
+             edge.label = NULL, order="unknown", annote = list(), ...) {
 
     ## edge
     edge <- x
@@ -143,6 +145,7 @@
     res at node.label <- node.label
     res at edge.label <- edge.label
     res at order <- order
+    res at annote <- annote
 
     ## checkPhylo4 will return a character string if object is
     ##  bad, otherwise TRUE
@@ -152,10 +155,11 @@
 
 ## first arg is a phylo
 setMethod("phylo4", c("phylo"), function(x, check.node.labels=c("keep",
-  "drop")){
+  "drop"), annote=list()){
 
   check.node.labels <- match.arg(check.node.labels)
   if (check.node.labels == "drop") x$node.label <- NULL
+  ## FIXME: annote is silently dropped here
   res <- as(x, "phylo4")
 
   return(res)

Modified: pkg/R/class-phylo4d.R
===================================================================
--- pkg/R/class-phylo4d.R	2009-08-25 00:58:59 UTC (rev 584)
+++ pkg/R/class-phylo4d.R	2009-08-25 00:59:46 UTC (rev 585)
@@ -3,10 +3,12 @@
 ## extend: phylo with data
 setClass("phylo4d",
          representation(tip.data="data.frame",
-                        node.data="data.frame"),
+                        node.data="data.frame",
+                        metadata = "list"),
 
          prototype = list( tip.data = data.frame(NULL),
-           node.data = data.frame(NULL) ),
+           node.data = data.frame(NULL),
+           metadata = list()),
 
          validity = checkPhylo4,
          contains="phylo4")
@@ -24,7 +26,8 @@
 
 ## Core part that takes care of the data
 .phylo4Data <- function(x, tip.data=NULL, node.data=NULL, all.data=NULL,
-                        match.data=TRUE, merge.data=TRUE, rownamesAsLabels=FALSE,
+                        match.data=TRUE, merge.data=TRUE,
+                        rownamesAsLabels=FALSE,
                         ...) {
 
     ## Make sure that data provided are a data frame
@@ -151,6 +154,7 @@
 setMethod("phylo4d", "phylo4",
           function(x, tip.data=NULL, node.data=NULL, all.data=NULL,
                    match.data=TRUE, merge.data=TRUE, rownamesAsLabels=FALSE,
+                   metadata = list(),
                    ...) {
 
     ## Creating new phylo4d object
@@ -171,24 +175,26 @@
 
     res at tip.data <- tmpData$tip.data
     res at node.data <- tmpData$node.data
-
+    res at metadata <- metadata
     return(res)
 })
 
 
 ## first arg is a matrix of edges
 setMethod("phylo4d", c("matrix"),
-          function(x, tip.data=NULL, node.data=NULL, all.data=NULL, ...) {
+          function(x, tip.data=NULL, node.data=NULL, all.data=NULL,
+                   metadata = list(), ...) {
     tree <- phylo4(x, ...)
-    res <- phylo4d(tree, tip.data, node.data, all.data, ...)
+    res <- phylo4d(tree, tip.data, node.data, all.data, metadata, ...)
     return(res)
 })
 
 ## first arg is a phylo
-setMethod("phylo4d", c("phylo"),
+setMethod("phylo4d", "phylo",
           function(x, tip.data=NULL,
                    node.data=NULL, all.data=NULL,
-                   check.node.labels=c("keep", "drop", "asdata"), ...) {
+                   check.node.labels=c("keep", "drop", "asdata"),
+                   annote=list(), metadata=list(), ...) {
 
     check.node.labels <- match.arg(check.node.labels)
 
@@ -208,8 +214,10 @@
         res <- addData(res, node.data=nlab.data, pos="before", match.data=FALSE)
     }
     else {
-        tree <- phylo4(x, check.node.labels=check.node.labels)
-        res <- phylo4d(tree, tip.data, node.data, all.data, ...)
+        tree <- phylo4(x, check.node.labels=check.node.labels, annote=annote)
+        res <- phylo4d(tree, tip.data=tip.data, node.data=node.data,
+                       all.data=all.data,
+                       metadata=metadata, ...)
     }
 
     return(res)

Modified: pkg/data/geospiza.rda
===================================================================
(Binary files differ)

Modified: pkg/inst/unitTests/runit.prune.R
===================================================================
--- pkg/inst/unitTests/runit.prune.R	2009-08-25 00:58:59 UTC (rev 584)
+++ pkg/inst/unitTests/runit.prune.R	2009-08-25 00:59:46 UTC (rev 585)
@@ -17,7 +17,8 @@
 
 test.prune.phylo4d <- function() {
     # function(phy, tip, trim.internal = TRUE, subtree = FALSE, ...)
-    checkEquals(geospiza, prune(geospiza, character(0)))
+    ## checkEquals(geospiza, prune(geospiza, character(0))) ## FAILS??
+    checkIdentical(geospiza, prune(geospiza, character(0)))
 }
 
 test.prune.phylo <- function() {

Modified: pkg/man/phylo4-class.Rd
===================================================================
--- pkg/man/phylo4-class.Rd	2009-08-25 00:58:59 UTC (rev 584)
+++ pkg/man/phylo4-class.Rd	2009-08-25 00:59:46 UTC (rev 585)
@@ -15,7 +15,7 @@
 \section{Objects from the Class}{
   Phylogenetic tree objects can be created by calls to the \code{\link{phylo4}} constructor function.
   Translation functions from other phylogenetic packages are also available. See \code{\link{coerce-methods}}.
-  }
+}
 \section{Slots}{
   \describe{
     \item{\code{edge}:}{matrix of edges}
@@ -24,10 +24,14 @@
     \item{\code{tip.label}:}{character vector of tip labels}
     \item{\code{root.edge}:}{integer: root edge (NA if none)}
     \item{\code{order}:}{character: tree ordering (allowable values are
-      listed in \code{phylo4_orderings}, currently "unknown", "preorder"
-      (="cladewise" in \code{ape}), and "postorder", with "cladewise"
-      and "pruningwise" also allowed for compatibility with \code{ape})} }
-  }
+      listed in \code{phylo4_orderings}, currently "unknown",
+      "preorder" (="cladewise" in \code{ape}), and "postorder",
+      with "pruningwise" and "cladewise" also allowed for compatibility with
+      \code{ape})}
+      \item{\code{annote}:}{annotation data for tree (currently
+      unstructured/unused by methods)}
+    }
+}
 \section{Methods}{
   \describe{
     \item{\$}{\code{signature(x = "phylo4")}: extract a slot}

Modified: pkg/man/phylo4d-class.Rd
===================================================================
--- pkg/man/phylo4d-class.Rd	2009-08-25 00:58:59 UTC (rev 584)
+++ pkg/man/phylo4d-class.Rd	2009-08-25 00:59:46 UTC (rev 585)
@@ -46,6 +46,10 @@
       listed in \code{phylo4_orderings}, currently "unknown", "preorder"
       (="cladewise" in \code{ape}), and "postorder", with "cladewise"
       and "pruningwise" also allowed for compatibility with \code{ape})}
+    \item{\code{annote}:}{annotation data for tree (currently
+      unstructured/unused by methods)}
+    \item{\code{metadata}:}{metadata for node/tip data (currently
+      unstructured/unused by methods)}
   }
 }
 \section{Methods}{



More information about the Phylobase-commits mailing list