[Phylobase-commits] r780 - in pkg: R man

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Fri Apr 2 03:13:39 CEST 2010


Author: pdc
Date: 2010-04-02 03:13:39 +0200 (Fri, 02 Apr 2010)
New Revision: 780

Modified:
   pkg/R/treePlot.R
   pkg/man/treePlot-methods.Rd
Log:
Add a 'rev' option to the tip.order parameter of treePlot.  Allows tip order to more easily be reversed.

Modified: pkg/R/treePlot.R
===================================================================
--- pkg/R/treePlot.R	2010-04-01 22:28:13 UTC (rev 779)
+++ pkg/R/treePlot.R	2010-04-02 01:13:39 UTC (rev 780)
@@ -35,7 +35,7 @@
     type   <- match.arg(type)
     Nedges <- nEdges(phy)
     Ntips  <- nTips(phy)
-    if(!is.null(tip.order)) {
+    if(!is.null(tip.order) && tip.order!="rev") {
         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
@@ -44,8 +44,8 @@
                 tip.order <- as.numeric(names(tipLabels(phy))[match(tip.order, tipLabels(phy))])
             }
         }
+        tip.order <- rev(tip.order)
     }
-    tip.order <- rev(tip.order)
     ## TODO remove the false cladogram option?
     if(!hasEdgeLength(phy) || type == 'cladogram') {
         edgeLength(phy) <- rep(1, Nedges)
@@ -242,7 +242,12 @@
 
     ## Set y positions for terminal nodes and calculate remaining y positions
     if(!is.null(tip.order)) {
-        yy[tips][match(tip.order, edge2[tips])] <- seq(0, 1, length = Ntips)
+        if(tip.order=="rev") {
+            yy[tips] <- seq(1, 0, length = Ntips)
+            tip.order <- rev(edge2[edge2 <= Ntips])
+        } else {
+            yy[tips][match(tip.order, edge2[tips])] <- seq(0, 1, length = Ntips)
+        }
     } else {
         yy[tips] <- seq(0, 1, length = Ntips)
         tip.order <- edge2[edge2 <= Ntips]

Modified: pkg/man/treePlot-methods.Rd
===================================================================
--- pkg/man/treePlot-methods.Rd	2010-04-01 22:28:13 UTC (rev 779)
+++ pkg/man/treePlot-methods.Rd	2010-04-02 01:13:39 UTC (rev 780)
@@ -29,7 +29,7 @@
   \item{type}{ A character string indicating the shape of plotted tree }
   \item{show.tip.label}{ Logical, indicating whether tip labels should be shown }
   \item{show.node.label}{ Logical, indicating whether node labels should be shown }
-  \item{tip.order}{A character vector of tip labels, indicating their order along the y axis (from top to bottom). Or, a numeric vector of tip node IDs indicating the order.}
+  \item{tip.order}{If NULL the tree is plotted with tips in preorder, if "rev" this is reversed. Otherwise, it is a character vector of tip labels, indicating their order along the y axis (from top to bottom). Or, a numeric vector of tip node IDs indicating the order.}
   \item{plot.data}{ Logical indicating whether \code{phylo4d} data should be plotted }
   \item{rot}{ Numeric indicating the rotation of the plot in degrees }
   \item{tip.plot.fun}{ A function used to generate plot at the each tip of the phylogenetic trees }



More information about the Phylobase-commits mailing list