[Phylobase-commits] r655 - in pkg: R data inst/doc man

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Tue Sep 22 08:06:24 CEST 2009


Author: regetz
Date: 2009-09-22 08:06:23 +0200 (Tue, 22 Sep 2009)
New Revision: 655

Modified:
   pkg/R/checkdata.R
   pkg/R/class-phylo4.R
   pkg/R/methods-phylo4.R
   pkg/R/prune.R
   pkg/R/setAs-Methods.R
   pkg/data/geospiza.rda
   pkg/inst/doc/phylobase.Rnw
   pkg/man/phylo4-class.Rd
   pkg/man/phylo4d-class.Rd
Log:
removed Nnode slot from phylo4 class definition, and updated code and
docs to reflect this change


Modified: pkg/R/checkdata.R
===================================================================
--- pkg/R/checkdata.R	2009-09-21 06:15:10 UTC (rev 654)
+++ pkg/R/checkdata.R	2009-09-22 06:06:23 UTC (rev 655)
@@ -16,7 +16,7 @@
 
     ## case of empty phylo4 object
     if(nrow(object at edge) == 0 && length(object at edge.length) == 0 &&
-       object at Nnode == 0 && length(object at node.label) == 0 &&
+       length(object at node.label) == 0 &&
        length(object at tip.label) == 0 && length(object at edge.label) == 0)
         return(TRUE)
 
@@ -32,10 +32,11 @@
       ## with numeric branch lengths except at the root
       if (sum(is.na(object at edge.length)) > 1)
         return("NAs in edge lengths")
-      ## Strip root edge branch lenght (if set to NA)
+      ## Strip root edge branch length (if set to NA)
       if (any(object at edge.length[!is.na(object at edge.length)] < 0))
         return("edge lengths must be non-negative")
     }
+    ##TODO fix this up somehow, or remove? (Nnode slot no longer exists)
     ## if (length(object at tip.label)+object at Nnode-1 != N) # does not work with multifurcations
     ##  return("number of tip labels not consistent with number of edges and nodes")
     ## check: tip numbers = (m+1):(m+n)

Modified: pkg/R/class-phylo4.R
===================================================================
--- pkg/R/class-phylo4.R	2009-09-21 06:15:10 UTC (rev 654)
+++ pkg/R/class-phylo4.R	2009-09-22 06:06:23 UTC (rev 655)
@@ -1,7 +1,6 @@
 setClass("phylo4",
          representation(edge = "matrix",
                         edge.length = "numeric",
-                        Nnode = "integer",
                         node.label = "character",
                         tip.label = "character",
                         edge.label = "character",
@@ -11,7 +10,6 @@
                         edge = matrix(nrow = 0, ncol = 2,
                             dimname = list(NULL, c("ancestor", "descendant"))),
                         edge.length = numeric(0),
-                        Nnode = as.integer(0),
                         tip.label = character(0),
                         node.label = character(0),
                         edge.label = character(0),
@@ -140,7 +138,6 @@
     res <- new("phylo4")
     res at edge <- edge
     res at edge.length <- edge.length
-    res at Nnode <- nnodes
     res at tip.label <- tip.label
     res at node.label <- node.label
     res at edge.label <- edge.label

Modified: pkg/R/methods-phylo4.R
===================================================================
--- pkg/R/methods-phylo4.R	2009-09-21 06:15:10 UTC (rev 654)
+++ pkg/R/methods-phylo4.R	2009-09-22 06:06:23 UTC (rev 655)
@@ -78,9 +78,13 @@
 ### Node accessors
 #########################################################
 
-setMethod("nNodes", signature(x="phylo4"),
- function(x) {
-    x at Nnode
+setMethod("nNodes", signature(x="phylo4"), function(x) {
+    E <- edges(x, drop.root=TRUE)
+    if(nrow(E) == 0) {
+        return(0)
+    } else {
+        return(length(unique(E[, 1])))
+    }
 })
 
 setMethod("nodeType", signature(x="phylo4"),

Modified: pkg/R/prune.R
===================================================================
--- pkg/R/prune.R	2009-09-21 06:15:10 UTC (rev 654)
+++ pkg/R/prune.R	2009-09-22 06:06:23 UTC (rev 655)
@@ -108,7 +108,7 @@
 
     ## create and return new phylo4 object
     ## NOTE: a faster but looser approach would be to replace the slots
-    ## of x with their new values (including Nnode) and return x
+    ## of x with their new values and return x
     phylo4(x=edge.new, edge.length = edge.length.new, tip.label =
         tip.label.new, node.label = node.label.new, edge.label =
         edge.label.new, annote=x at annote)

Modified: pkg/R/setAs-Methods.R
===================================================================
--- pkg/R/setAs-Methods.R	2009-09-21 06:15:10 UTC (rev 654)
+++ pkg/R/setAs-Methods.R	2009-09-22 06:06:23 UTC (rev 655)
@@ -146,7 +146,7 @@
 ## BMB: redundant????
 ## setAs("phylo4d", "phylo", function(from, to) {
 ##     y <- list(edge = from at edge, edge.length = from at edge.length,
-##         Nnode = from at Nnode, tip.label = from at tip.label)
+##         Nnode = nNodes(from), tip.label = from at tip.label)
 ##     class(y) <- "phylo"
 ##     if (length(y$edge.length) == 0)
 ##         y$edge.length <- NULL

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

Modified: pkg/inst/doc/phylobase.Rnw
===================================================================
--- pkg/inst/doc/phylobase.Rnw	2009-09-21 06:15:10 UTC (rev 654)
+++ pkg/inst/doc/phylobase.Rnw	2009-09-22 06:06:23 UTC (rev 655)
@@ -366,7 +366,6 @@
     See below for further constraints on the edge matrix.}
 \item[edge.length]{numeric list of edge lengths
     (length $N$ (rooted) or $N-1$ (unrooted) or empty (length 0))}
-\item[Nnode]{integer, number of (internal) nodes}
 \item[tip.label]{character vector of tip labels (required), with     length=\# of tips. Tip labels need not be unique, but data-tree     matching with non-unique labels will cause an error}
 \item[node.label]{character vector of node labels, length=\# of
     internal nodes or 0 (if empty).  Node labels need not be unique, but data-tree matching with non-unique labels will cause an error}

Modified: pkg/man/phylo4-class.Rd
===================================================================
--- pkg/man/phylo4-class.Rd	2009-09-21 06:15:10 UTC (rev 654)
+++ pkg/man/phylo4-class.Rd	2009-09-22 06:06:23 UTC (rev 655)
@@ -13,7 +13,6 @@
   \describe{
     \item{\code{edge}:}{matrix of edges}
     \item{\code{edge.length}:}{numeric vector of edge lengths}
-    \item{\code{Nnode}:}{integer: number of nodes}
     \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
@@ -37,4 +36,4 @@
 
 \author{Ben Bolker, Thibaut Jombart}
 % \examples{}
-\keyword{classes}
\ No newline at end of file
+\keyword{classes}

Modified: pkg/man/phylo4d-class.Rd
===================================================================
--- pkg/man/phylo4d-class.Rd	2009-09-21 06:15:10 UTC (rev 654)
+++ pkg/man/phylo4d-class.Rd	2009-09-22 06:06:23 UTC (rev 655)
@@ -14,7 +14,6 @@
     \item{\code{edge}:}{Matrix of edges}
     \item{\code{edge.label}:}{Character vector of edge (branch) labels}
     \item{\code{edge.length}:}{Numeric vector of edge (branch) lengths}
-    \item{\code{Nnode}:}{Integer: number of nodes}
     \item{\code{node.data}:}{data frame for traits of internal
       nodes}
     \item{\code{node.label}:}{Character vector of node labels}



More information about the Phylobase-commits mailing list