[Phylobase-commits] r428 - pkg/R

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Wed Apr 22 01:44:13 CEST 2009


Author: pdc
Date: 2009-04-22 01:44:13 +0200 (Wed, 22 Apr 2009)
New Revision: 428

Modified:
   pkg/R/class-phylo4.R
   pkg/R/setAs-Methods.R
Log:
Changes to fix ape compatibility.   
1. allow ape ordering for the @order.  
2. fix how we find the root node in as(x, 'phylo') 

Modified: pkg/R/class-phylo4.R
===================================================================
--- pkg/R/class-phylo4.R	2009-04-21 15:13:57 UTC (rev 427)
+++ pkg/R/class-phylo4.R	2009-04-21 23:44:13 UTC (rev 428)
@@ -22,7 +22,8 @@
 ## phylo4 constructor
 #####################
 
-phylo4_orderings <- c("unknown","preorder","postorder")
+# ape orderings should be allowed for so we can import trees from ape e.g. during subsetting
+phylo4_orderings <- c("unknown", "preorder", "postorder", "pruningwise", "cladewise")
 
 phylo4 <- function(edge, edge.length = NULL, tip.label = NULL, node.label = NULL, edge.label = NULL, order="unknown", ...){
 

Modified: pkg/R/setAs-Methods.R
===================================================================
--- pkg/R/setAs-Methods.R	2009-04-21 15:13:57 UTC (rev 427)
+++ pkg/R/setAs-Methods.R	2009-04-21 23:44:13 UTC (rev 428)
@@ -67,7 +67,8 @@
     if (inherits(from, "phylo4d"))
         warning("losing data while coercing phylo4d to phylo")
     brlen <- from at edge.length
-    rootpos <- which(nodeId(from, "all") == rootNode(from))
+    ## rootnode is only node with no ancestor
+    rootpos <- which(is.na(from at edge[, 1]))
     if (isRooted(from)) brlen <- brlen[-rootpos]
     edgemat <- unname(from at edge[-rootpos, ])
     y <- list(edge = edgemat,
@@ -78,7 +79,7 @@
     class(y) <- "phylo"
     if (from at order != 'unknown') {
         ## TODO postorder != pruningwise -- though quite similar
-        attr(y, 'order') <- switch(from at order, postorder = 'pruningwise',
+        attr(y, 'order') <- switch(from at order, postorder = 'unknown',
                                       preorder  = 'cladewise')
     }
     if (length(y$edge.length) == 0)



More information about the Phylobase-commits mailing list