]> git.donarmstrong.com Git - ape.git/commitdiff
new option 'rotate.tree' in plot.phylo()
authorparadis <paradis@6e262413-ae40-0410-9e79-b911bd7a66b7>
Sat, 17 Dec 2011 10:08:27 +0000 (10:08 +0000)
committerparadis <paradis@6e262413-ae40-0410-9e79-b911bd7a66b7>
Sat, 17 Dec 2011 10:08:27 +0000 (10:08 +0000)
git-svn-id: https://svn.mpl.ird.fr/ape/dev/ape@174 6e262413-ae40-0410-9e79-b911bd7a66b7

DESCRIPTION
NEWS
R/plot.phylo.R
man/DNAbin.Rd
man/plot.phylo.Rd

index 2aec280e55a090b5a88affdc69dbeae897ad16d5..f63f9a38f2111ea6d3f6476b30c3710ddfccb877 100644 (file)
@@ -1,6 +1,6 @@
 Package: ape
 Version: 2.8-1
-Date: 2011-11-11
+Date: 2011-12-03
 Title: Analyses of Phylogenetics and Evolution
 Author: Emmanuel Paradis, Ben Bolker, Julien Claude, Hoa Sien Cuong, Richard Desper, Benoit Durand, Julien Dutheil, Olivier Gascuel, Christoph Heibl, Daniel Lawson, Vincent Lefort, Pierre Legendre, Jim Lemon, Yvonnick Noel, Johan Nylander, Rainer Opgen-Rhein, Andrei-Alin Popescu, Klaus Schliep, Korbinian Strimmer, Damien de Vienne
 Maintainer: Emmanuel Paradis <Emmanuel.Paradis@ird.fr>
diff --git a/NEWS b/NEWS
index 223169c57b1ff73d0570cb0d5c62f033d8900881..cc8d3af63c727603a15bf1ce227de83a0a10eace 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -1,6 +1,12 @@
                CHANGES IN APE VERSION 2.8-1
 
 
+NEW FEATURES
+
+    o plot.phylo() has a new option 'rotate.tree' to rotate unrooted,
+      fan or radial trees around the center of the plot.
+
+
 BUG FIXES
 
     o mantel.test() could return P-values > 1 with the default
index da5ebec9d1fb58e74b314da9f24dc6723dd46c28..32e5506903e412704b147b9e53705f68b4233f1a 100644 (file)
@@ -1,4 +1,4 @@
-## plot.phylo.R (2011-06-14)
+## plot.phylo.R (2011-12-03)
 
 ##   Plot Phylogenies
 
@@ -15,7 +15,7 @@ plot.phylo <-
              adj = NULL, srt = 0, no.margin = FALSE, root.edge = FALSE,
              label.offset = 0, underscore = FALSE, x.lim = NULL,
              y.lim = NULL, direction = "rightwards", lab4ut = "horizontal",
-             tip.color = "black", plot = TRUE, ...)
+             tip.color = "black", plot = TRUE, rotate.tree = 0, ...)
 {
     Ntip <- length(x$tip.label)
     if (Ntip == 1) {
@@ -96,17 +96,7 @@ plot.phylo <-
     }
     ## 'z' is the tree in pruningwise order used in calls to .C
     z <- reorder(x, order = "pruningwise")
-###    edge.color <- rep(edge.color, length.out = Nedge)
-###    edge.width <- rep(edge.width, length.out = Nedge)
-###    edge.lty <- rep(edge.lty, length.out = Nedge)
-###    ## fix from Li-San Wang (2007-01-23):
-###    xe <- x$edge
-###    x <- reorder(x, order = "pruningwise")
-###    ereorder <- match(x$edge[, 2], xe[, 2])
-###    edge.color <- edge.color[ereorder]
-###    edge.width <- edge.width[ereorder]
-###    edge.lty <- edge.lty[ereorder]
-###    ## end of fix
+
     if (phyloORclado) {
         if (is.null(node.pos)) {
             node.pos <- 1
@@ -131,7 +121,9 @@ plot.phylo <-
         } else  {
             xx <- .nodeDepthEdgelength(Ntip, Nnode, z$edge, Nedge, z$edge.length)
         }
-    } else switch(type, "fan" = {
+    } else {
+    rotate.tree <- 2 * pi * rotate.tree/360
+    switch(type, "fan" = {
         ## if the tips are not in the same order in tip.label
         ## and in edge[, 2], we must reorder the angles: we
         ## use `xx' to store temporarily the angles
@@ -147,14 +139,15 @@ plot.phylo <-
             r <- .nodeDepth(Ntip, Nnode, z$edge, Nedge)
             r <- 1/r
         }
+        theta <- theta + rotate.tree
         xx <- r*cos(theta)
         yy <- r*sin(theta)
     }, "unrooted" = {
         nb.sp <- .nodeDepth(Ntip, Nnode, z$edge, Nedge)
         XY <- if (use.edge.length)
-            unrooted.xy(Ntip, Nnode, z$edge, z$edge.length, nb.sp)
+            unrooted.xy(Ntip, Nnode, z$edge, z$edge.length, nb.sp, rotate.tree)
         else
-            unrooted.xy(Ntip, Nnode, z$edge, rep(1, Nedge), nb.sp)
+            unrooted.xy(Ntip, Nnode, z$edge, rep(1, Nedge), nb.sp, rotate.tree)
         ## rescale so that we have only positive values
         xx <- XY$M[, 1] - min(XY$M[, 1])
         yy <- XY$M[, 2] - min(XY$M[, 2])
@@ -166,9 +159,9 @@ plot.phylo <-
         ## angle (1st compute the angles for the tips):
         yy <- c((1:Ntip)*2*pi/Ntip, rep(0, Nnode))
         Y <- .nodeHeight(Ntip, Nnode, z$edge, Nedge, yy)
-        xx <- X * cos(Y)
-        yy <- X * sin(Y)
-    })
+        xx <- X * cos(Y + rotate.tree)
+        yy <- X * sin(Y + rotate.tree)
+    })}
     if (phyloORclado) {
         if (!horizontal) {
             tmp <- yy
@@ -558,7 +551,7 @@ circular.plot <- function(edge, Ntip, Nnode, xx, yy, theta,
     }
 }
 
-unrooted.xy <- function(Ntip, Nnode, edge, edge.length, nb.sp)
+unrooted.xy <- function(Ntip, Nnode, edge, edge.length, nb.sp, rotate.tree)
 {
     foo <- function(node, ANGLE, AXIS) {
         ind <- which(edge[, 1] == node)
@@ -573,7 +566,7 @@ unrooted.xy <- function(Ntip, Nnode, edge, edge.length, nb.sp)
             yy[sons[i]] <<- h*sin(beta) + yy[node]
         }
         for (i in sons)
-          if (i > Ntip) foo(i, angle[i], axis[i])
+            if (i > Ntip) foo(i, angle[i], axis[i])
     }
     Nedge <- dim(edge)[1]
     yy <- xx <- numeric(Ntip + Nnode)
@@ -581,7 +574,7 @@ unrooted.xy <- function(Ntip, Nnode, edge, edge.length, nb.sp)
     ## `axis': the axis of each branch
     axis <- angle <- numeric(Ntip + Nnode)
     ## start with the root...
-    foo(Ntip + 1L, 2*pi, 0)
+    foo(Ntip + 1L, 2*pi, 0 + rotate.tree)
 
     M <- cbind(xx, yy)
     axe <- axis[1:Ntip] # the axis of the terminal branches (for export)
index e9535306f1ec2f4dd2a16f4d7b34fe73c7793707..eb6983ea48e8a6c669d662ffffd0cdba4387b871 100644 (file)
@@ -81,6 +81,9 @@
 \references{
   Paradis, E. (2007) A Bit-Level Coding Scheme for Nucleotides.
   \url{http://ape.mpl.ird.fr/misc/BitLevelCodingScheme_20April2007.pdf}
+
+  Paradis, E. (2012) \emph{Analysis of Phylogenetics and Evolution with
+  R (Second Edition)}. New York: Springer.
 }
 \author{Emmanuel Paradis}
 \seealso{
index 4fc43309151ce941e13a0aaf50bfc07d3ab99c59..f19db415317559caa2c338cf9d3b677b6ad6d3db 100644 (file)
@@ -9,7 +9,8 @@
     cex = par("cex"), adj = NULL, srt = 0, no.margin = FALSE,
     root.edge = FALSE, label.offset = 0, underscore = FALSE,
     x.lim = NULL, y.lim = NULL, direction = "rightwards",
-    lab4ut = "horizontal", tip.color = "black", plot = TRUE, ...)
+    lab4ut = "horizontal", tip.color = "black", plot = TRUE,
+    rotate.tree = 0, ...)
 \method{plot}{multiPhylo}(x, layout = 1, ...)
 }
 \arguments{
@@ -96,6 +97,9 @@
   \item{layout}{the number of trees to be plotted simultaneously.}
   \item{\dots}{further arguments to be passed to \code{plot} or to
     \code{plot.phylo}.}
+  \item{rotate.tree}{for "fan", "unrooted", or "radial" trees: the
+    rotation of the whole tree in degrees (negative values are
+    accepted).}
 }
 \description{
   These functions plot phylogenetic trees on the current graphical