[Phylobase-commits] r135 - pkg/R

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Mon Mar 3 17:03:26 CET 2008


Author: jombart
Date: 2008-03-03 17:03:26 +0100 (Mon, 03 Mar 2008)
New Revision: 135

Modified:
   pkg/R/plot.R
Log:
Data are re-ordered like tips.


Modified: pkg/R/plot.R
===================================================================
--- pkg/R/plot.R	2008-03-02 22:35:14 UTC (rev 134)
+++ pkg/R/plot.R	2008-03-03 16:03:26 UTC (rev 135)
@@ -29,12 +29,12 @@
 ################
 setMethod("plot", signature(x="phylo4d",y="missing"), 
           function(x, treetype=c("phylogram","cladogram"), symbol=c("circles", "squares"), center=TRUE, scale=TRUE, legend=TRUE, grid=TRUE, box=TRUE, show.tip.label=TRUE, show.node.label=TRUE, show.var.label=TRUE, ratio.tree=1/3, font=3, tip.label=x at tip.label, var.label=colnames(x at tip.data), cex.symbol=1, cex.label=1, cex.legend=1, ...)
-          {
-              
-              ## preliminary stuff and checks
-              if (is.character(chk <- check_phylo4(x)))
-                stop("bad phylo4d object: ",chk)
+      {
 
+    ## preliminary stuff and checks
+    if (is.character(chk <- check_phylo4(x)))
+        stop("bad phylo4d object: ",chk)
+
     if(!require(ape)) stop("the ape package is required")
     ## if(ncol(tdata(x,which="tip")) == 0) stop("no data in this phylo4d object")
     
@@ -61,7 +61,11 @@
     ## keep only numeric data
     dat <- dat[isNum]
     var.label <- var.label[isNum]
-   
+    ## order data like tips
+    E <- edges(x)
+    tips.ord <- E[,2][!E[,2] %in% E[,1]]
+    dat <- dat[tips.ord,,FALSE]
+    tip.label <- tip.label[tips.ord] # reorder tip labels
     ## centring / scaling
     dat <- as.data.frame(scale(dat,center=center,scale=scale))
     



More information about the Phylobase-commits mailing list