[Phylobase-commits] r607 - pkg/R

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Sat Aug 29 05:15:36 CEST 2009


Author: pdc
Date: 2009-08-29 05:15:36 +0200 (Sat, 29 Aug 2009)
New Revision: 607

Modified:
   pkg/R/treePlot.R
Log:
Don't give tips an order by default when printing.  That only worked in the limited set of cases where tips were in preorder order.  Now tips now get plotted in the order of the tree when it's reordered.  

Modified: pkg/R/treePlot.R
===================================================================
--- pkg/R/treePlot.R	2009-08-27 23:08:31 UTC (rev 606)
+++ pkg/R/treePlot.R	2009-08-29 03:15:36 UTC (rev 607)
@@ -2,7 +2,7 @@
                      type = c('phylogram', 'cladogram', 'fan'), 
                      show.tip.label = TRUE,
                      show.node.label = FALSE, 
-                     tip.order = 1:nTips(phy),
+                     ## tip.order = 1:nTips(phy),
                      plot.data = is(phy, 'phylo4d'),
                      rot = 0,
                      tip.plot.fun = 'bubbles',
@@ -32,15 +32,17 @@
     Nedges <- nEdges(phy)
     Ntips  <- nTips(phy)
     
-    if(length(tip.order) != Ntips) {stop('tip.order must be the same length as nTips(phy)')}
-    if(is.numeric(tip.order)) {
-        tip.order <- tip.order
-    } else {
-        if(is.character(tip.order)) {
-            tip.order <- match(tip.order, tipLabels(phy))
-        }
-    }
     
+    ## if(length(tip.order) != Ntips) {stop('tip.order must be the same length as nTips(phy)')}
+    ## if(is.numeric(tip.order)) {
+    ##     tip.order <- tip.order
+    ## } else {
+    ##     if(is.character(tip.order)) {
+    ##         tip.order <- match(tip.order, phy at tip.labeli)
+    ##     }
+    ## }
+    tip.order <- NULL
+    
     ## TODO remove the false cladogram option?
     if(is.null(edgeLength(phy)) || type == 'cladogram') {
         phy at edge.length <- rep(1, Nedges)
@@ -214,7 +216,9 @@
     Nedges <- nrow(phy at edge) ## TODO switch to the accessor once stablized
     Ntips  <- nTips(phy)
     tips <- edge[, 2] <= Ntips
-    tip.order <- match(tip.order, edge[, 2][tips])
+    if(!is.null(tip.order)) {
+        tip.order <- match(tip.order, edge[, 2][tips])
+    }
     xx <- numeric(Nedges)
     yy <- numeric(Nedges)
 
@@ -233,7 +237,11 @@
     }
 
     ## Set y positions for terminal nodes and calculate remaining y positions
-    yy[tips][tip.order] <- seq(0, 1, length = Ntips)
+    if(!is.null(tip.order)) {
+        yy[tips][tip.order] <- seq(0, 1, length = Ntips)
+    } else {
+        yy[tips] <- seq(0, 1, length = Ntips)
+    }
     segs$h0y[tips] <- segs$h1y[tips] <- yy[tips]
     segs$v1y[tips] <- segs$v0y[tips] <- yy[tips]
     for(i in rev((Ntips + 1):nEdges(phy))) {
@@ -297,7 +305,7 @@
 phylobubbles <- function(type = type,
                         place.tip.label = "right", 
                         show.node.label = show.node.label, 
-                        tip.order = tip.order,
+                        tip.order = NULL,
                         rot = 0,
                         edge.color = edge.color, 
                         node.color = node.color, # TODO what do with node.color parameter
@@ -415,7 +423,7 @@
             layout.pos.col = 2, 
             layout.pos.row = 1
         ))
-        tt <- tipLabels(phy)
+        tt <- phy at tip.label # tipLabels(phy)
         grid.text(tt, 0.1, tys, just = 'left')
         upViewport()
     }



More information about the Phylobase-commits mailing list