[Phylobase-commits] r625 - in pkg: R man

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Tue Sep 8 23:39:11 CEST 2009


Author: regetz
Date: 2009-09-08 23:39:05 +0200 (Tue, 08 Sep 2009)
New Revision: 625

Modified:
   pkg/R/methods-phylo4.R
   pkg/man/phylo4-accessors.Rd
   pkg/man/phylo4-labels.Rd
Log:
revised edgeLabels and edgeLength accessors to return vectors in the
same order as rows of the edge matrix; updated documentation


Modified: pkg/R/methods-phylo4.R
===================================================================
--- pkg/R/methods-phylo4.R	2009-09-08 20:59:41 UTC (rev 624)
+++ pkg/R/methods-phylo4.R	2009-09-08 21:39:05 UTC (rev 625)
@@ -138,6 +138,7 @@
     nrow(x at edge)
 })
 
+# return edge matrix in its current order
 setMethod("edges", "phylo4", function(x, order, drop.root=FALSE, ...) {
   e <- x at edge
   if (drop.root) e <- e[!is.na(e[,1]),]
@@ -171,13 +172,16 @@
     !all(is.na(x at edge.length))
 })
 
+# return edge lengths in order by edgeIds (same order as edge matrix)
 setMethod("edgeLength", "phylo4", function(x, node) {
-    if (missing(node))
-        return(x at edge.length)
-    else {
+    ## [JR: below, using match for ordering rather than direct character
+    ## indexing b/c the latter is slow for vectors of a certain size]
+    elen <- x at edge.length[match(edgeId(x, "all"), names(x at edge.length))]
+    if (!missing(node)) {
         n <- getNode(x, node)
-        return(x at edge.length[match(n, x at edge[,2])])
+        elen <- elen[match(n, x at edge[,2])]
     }
+    return(elen)
 })
 
 setReplaceMethod("edgeLength", "phylo4", function(x, use.names=TRUE, ..., value) {
@@ -342,8 +346,11 @@
     length(x at edge.label) > 0
 })
 
+# return edge labels in order by edgeIds (same order as edge matrix)
 setMethod("edgeLabels", signature(x = "phylo4"), function(x) {
-    x at edge.label
+    ## [JR: below, using match for ordering rather than direct character
+    ## indexing b/c the latter is slow for vectors of a certain size]
+    x at edge.label[match(edgeId(x, "all"), names(x at edge.label))]
 })
 
 setReplaceMethod("edgeLabels", signature(object="phylo4", value="character"),

Modified: pkg/man/phylo4-accessors.Rd
===================================================================
--- pkg/man/phylo4-accessors.Rd	2009-09-08 20:59:41 UTC (rev 624)
+++ pkg/man/phylo4-accessors.Rd	2009-09-08 21:39:05 UTC (rev 625)
@@ -59,7 +59,7 @@
     tree has edge (branch) lengths}
   
   \item{edgeLength}{\code{signature(object = "phylo4")}: edge (branch)
-    lengths (or NULL if none)}
+    lengths (or NAs if missing) ordered according to the edge matrix}
  
   \item{nodeType}{\code{signature(object = "phylo4")}: named vector
     which has the type of node (internal, tip, root) for value, and the

Modified: pkg/man/phylo4-labels.Rd
===================================================================
--- pkg/man/phylo4-labels.Rd	2009-09-08 20:59:41 UTC (rev 624)
+++ pkg/man/phylo4-labels.Rd	2009-09-08 21:39:05 UTC (rev 625)
@@ -85,19 +85,20 @@
 \section{Methods}{
   \describe{
     \item{labels}{\code{signature(object = "phylo4")}: tip and/or
-      internal node labels}
+      internal node labels, ordered by node ID}
 
-    \item{tipLabels}{\code{signature(object = "phylo4")}: tip labels}
+    \item{tipLabels}{\code{signature(object = "phylo4")}: tip labels,
+      ordered by node ID}
     
     \item{hasNodeLabels}{\code{signature(object = "phylo4")}: whether
       tree has (internal) node labels}
     \item{nodeLabels}{\code{signature(object = "phylo4")}: internal
-      node labels}
+      node labels, ordered by node ID}
     
     \item{hasEdgeLabels}{\code{signature(object = "phylo4")}: whether
       tree has (internal) edge labels}
     \item{edgeLabels}{\code{signature(object = "phylo4")}: internal
-      edge labels}
+      edge labels, ordered according to the edge matrix}
   }
 }
 



More information about the Phylobase-commits mailing list