[Phylobase-commits] r225 - branches/pdcgsoc/misc

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Sat Aug 2 11:18:11 CEST 2008


Author: pdc
Date: 2008-08-02 11:18:11 +0200 (Sat, 02 Aug 2008)
New Revision: 225

Modified:
   branches/pdcgsoc/misc/temp.R
Log:
bug fixes and simplifications

Modified: branches/pdcgsoc/misc/temp.R
===================================================================
--- branches/pdcgsoc/misc/temp.R	2008-08-02 09:17:29 UTC (rev 224)
+++ branches/pdcgsoc/misc/temp.R	2008-08-02 09:18:11 UTC (rev 225)
@@ -12,18 +12,17 @@
                      node.color = 'black',
                      tip.color  = 'black', 
                      edge.width = 1 ## TODO currently only one width is allowed allow many?
-                     ## tip.plot.fun = function() {}
             )
-    {
+{
     phy.orig <- phy
-    Nedges   <- nrow(phy at edges)
+    Nedges   <- nrow(phy at edge)
     Ntips    <- length(phy at tip.label)
     
     if (type == 'phylogram') {
         xxyy <- phyloXXYY(phy, tip.order)
         ## because we may reoder the tip, we need to update the phy objec
         phy <- xxyy$phy
-        segs <- segs(phy, XXYY = xxyy$xxyy)
+        segs <- segs(phy, XXYY = xxyy)
     }
     
     eindex <- match(phy at edge[,2], phy.orig at edge[,2])
@@ -78,7 +77,7 @@
             phy at tip.label[tindex], 
             x = rep(0, Ntips), 
             ## TODO yuck!!
-            y = xxyy$xxyy$yy[phy at edge[, 2] %in% tindex], 
+            y = xxyy$yy[phy at edge[, 2] %in% tindex], 
             rot = rot, just = 'left', gp = gpar(col = tip.color[tindex])
             )
         popViewport()
@@ -93,7 +92,7 @@
             layout.pos.col = 3, 
             name = 'data_plots'))
         ## TODO should plots float at tips, or only along edge?
-        for(i in xxyy$xxyy$yy[which(phy at edge[, 2] <= Ntips)]) {
+        for(i in xxyy$yy[which(phy at edge[, 2] <= Ntips)]) {
             pushViewport(viewport(
                 y = i, 
                 height = unit(1, 'snpc'), 
@@ -123,6 +122,8 @@
 
 phyloXXYY <- function(phy, tip.order = NULL) {
     ## initalize the output
+    Nedges <- nrow(phy at edge)
+    Ntips  <- length(phy at tip.label)
     xxyy = list(
         yy = rep(NA, Nedges), 
         xx = numeric(Nedges), 
@@ -137,7 +138,7 @@
         ## 0, 1, length.out = Ntips) 
     # } else {
         ## reoder the phylo and assign even y spacing to the tips
-        phy <- reorder(phy)
+        phy <- reorder(phy, 'pruningwise')
         xxyy$yy[phy at edge[, 2] <= Ntips] <- seq(
             0, 1, length.out = Ntips
         )
@@ -183,14 +184,14 @@
     xxyy <- calc.node.xy(Ntips + 1, phy, xxyy)
     ## scale the x values
     xxyy$xx <- xxyy$xx / max(xxyy$xx)
-    list(xxyy = xxyy, phy = phy)
+    c(xxyy, phy = list(phy))
 }
 
 segs <- function(phy, XXYY) {
-    treelen <- rep(NA, Nedges + 1)
+    treelen <- rep(NA, nrow(phy at edge) + 1)
     segs <- list(v0x = treelen, v0y = treelen, v1x = treelen, v1y = treelen,
                  h0x = treelen, h0y = treelen, h1x = treelen, h1y = treelen)
-    troot <- Ntips + 1
+    troot <- length(phy at tip.label) + 1
 
     get.coor <- function(node, segs) {
         if(any(phy at edge[, 2] == node) == FALSE) {
@@ -224,15 +225,16 @@
     get.coor(troot, segs)
 }
 
+phylobubbles <- function(XXYY) {
+    phy <- XXYY$phy
+    
+}
+
 ## How do we translate this info into a plot?
 ## Test code
 out <- phyloXXYY(foo <- as(rcoal(3), 'phylo4'))
 data(geospiza)
 ## TODO true arbitary functions with data from associated data frames
-## grid.points(
-##     x = rep(1:ncol(geospiza at tip.data), 
-##     nrow(geospiza at tip.data))/ncol(geospiza at tip.data) - .2, 
-##     y = scale(geospiza at tip.data))
 
 treePlot(
     geospiza, 



More information about the Phylobase-commits mailing list