[Phylobase-commits] r329 - in pkg: R man tests

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Fri Dec 19 15:34:56 CET 2008


Author: bbolker
Date: 2008-12-19 15:34:56 +0100 (Fri, 19 Dec 2008)
New Revision: 329

Modified:
   pkg/R/class-phylo4.R
   pkg/R/methods-phylo4.R
   pkg/man/as-methods.Rd
   pkg/man/phylo4d.Rd
   pkg/man/printphylo4.Rd
   pkg/tests/misctests.R
Log:
  tweaks to docs and methods: still fixing glitches with empty labels etc.



Modified: pkg/R/class-phylo4.R
===================================================================
--- pkg/R/class-phylo4.R	2008-12-19 14:25:24 UTC (rev 328)
+++ pkg/R/class-phylo4.R	2008-12-19 14:34:56 UTC (rev 329)
@@ -54,8 +54,9 @@
     ##        node.label <- .genlab("N", nnodes)
     ## } else {
     if(is.null(node.label)) {
-      node.label <- character(nnodes)
-      is.na(node.label) <- TRUE
+      node.label <- character(0) ## empty node labels
+      ## node.label <- character(nnodes)
+      ## is.na(node.label) <- TRUE ## ???
     } else if (length(node.label) != nnodes)
       stop("the node labels are not consistent with the number of nodes")
     ## edge.label

Modified: pkg/R/methods-phylo4.R
===================================================================
--- pkg/R/methods-phylo4.R	2008-12-19 14:25:24 UTC (rev 328)
+++ pkg/R/methods-phylo4.R	2008-12-19 14:34:56 UTC (rev 329)
@@ -133,12 +133,17 @@
     x at node.label
 })
 
-setReplaceMethod("nodeLabels", "phylo4", function(object, ...,
-    value) {
-    object at node.label <- value
-    object
+setMethod("nodeNumbers", "phylo4", function(x) {
+    c(nTips(x)+1,x at edge[x at edge[,2]>nTips(x),2])
 })
 
+setReplaceMethod("nodeLabels", "phylo4",
+                 function(object, ..., value) {
+                   ## FIXME: test length!
+                   object at node.label <- value
+                   object
+                 })
+
 setMethod("edgeLabels", "phylo4", function(x) {
     x at edge.label
 })

Modified: pkg/man/as-methods.Rd
===================================================================
--- pkg/man/as-methods.Rd	2008-12-19 14:25:24 UTC (rev 328)
+++ pkg/man/as-methods.Rd	2008-12-19 14:34:56 UTC (rev 329)
@@ -83,9 +83,10 @@
 example(read.tree)
 ## round trip conversion 
 tree_in_phylo <- tree.owls                # tree is a phylo object 
-tree_in_phylo4 <- as(tree.owls,"phylo4")  # phylo converted to phylo4 
-tree_in_phylo4
-identical(tree_in_phylo,as(tree_in_phylo4,"phylo")) # test if phylo, and phlyo4 converted to phylo are identical
+(tree_in_phylo4 <- as(tree.owls,"phylo4"))  # phylo converted to phylo4 
+identical(tree_in_phylo,as(tree_in_phylo4,"phylo"))
+## test if phylo, and phlyo4 converted to phylo are identical
+## (no, because of dimnames)
 
 as(tree_in_phylo4, "phylog")      # conversion to phylog (ade4)
 as(tree_in_phylo4, "data.frame")  # conversion to data.frame

Modified: pkg/man/phylo4d.Rd
===================================================================
--- pkg/man/phylo4d.Rd	2008-12-19 14:25:24 UTC (rev 328)
+++ pkg/man/phylo4d.Rd	2008-12-19 14:34:56 UTC (rev 329)
@@ -120,7 +120,8 @@
 (exGeo4 <- phylo4d(geoTree, tip.data = rTipData, node.data = rNodeData,
                     merge.tip.node = FALSE))
 
-### Example with 'all.data'
+		    ### Example with 'all.data'
+nodeLabels(geoTree) <- as.character(nodeNumbers(geoTree))
 rAllData <- data.frame(randomTrait = rnorm(nTips(geoTree) + nNodes(geoTree)),
 row.names = c(labels(geoTree),nodeNumbers(geoTree)))
 

Modified: pkg/man/printphylo4.Rd
===================================================================
--- pkg/man/printphylo4.Rd	2008-12-19 14:25:24 UTC (rev 328)
+++ pkg/man/printphylo4.Rd	2008-12-19 14:34:56 UTC (rev 329)
@@ -38,7 +38,7 @@
 
 tree.phylo <- read.tree(text="((a,b),c);")
 tree <- as(tree.phylo, "phylo4")
-plot(tree,show.node=TRUE)
+##plot(tree,show.node=TRUE) ## plotting broken with empty node labels: FIXME
 tip.data <- data.frame(size=c(1,2,3), row.names=c("a", "b", "c"))
 treedata <- phylo4d(tree, tip.data)
 plot(treedata,ratio=.7,cent=FALSE,scale=FALSE)

Modified: pkg/tests/misctests.R
===================================================================
--- pkg/tests/misctests.R	2008-12-19 14:25:24 UTC (rev 328)
+++ pkg/tests/misctests.R	2008-12-19 14:34:56 UTC (rev 329)
@@ -67,3 +67,24 @@
             "conirostris","scandens")))
 
 plot(p2,show.node.label=TRUE)
+
+library(ape)
+example(read.tree)
+
+z <- as(tree.owls,"phylo4")
+
+example("phylo4d")
+obj1 <- obj2 <- obj3 <- phylo4d(as(tree.owls,"phylo4"),data.frame(wing=1:4,color=factor(c("b","w","b","b")), tail=runif(4)*10), use.tip.names=FALSE)
+
+obj2 at tip.data <- as.data.frame(obj2 at tip.data[,1])
+obj3 at tip.data <- cbind(obj1 at tip.data,obj2 at tip.data)
+obj4 <- obj1
+obj4$tip.data[2,3] <- NA
+obj4$tip.data[1,1] <- NA
+
+obj4 at node.label <- character(0)
+
+obj5 <- obj1
+tdata(obj4) <- subset(tdata(obj4),select=sapply(tdata(obj4),class)=="numeric")
+
+treePlot(obj4)



More information about the Phylobase-commits mailing list