]> git.donarmstrong.com Git - ape.git/commitdiff
small changed in add.scale.bar
authorparadis <paradis@6e262413-ae40-0410-9e79-b911bd7a66b7>
Wed, 16 Dec 2009 07:04:48 +0000 (07:04 +0000)
committerparadis <paradis@6e262413-ae40-0410-9e79-b911bd7a66b7>
Wed, 16 Dec 2009 07:04:48 +0000 (07:04 +0000)
git-svn-id: https://svn.mpl.ird.fr/ape/dev/ape@101 6e262413-ae40-0410-9e79-b911bd7a66b7

ChangeLog
DESCRIPTION
R/nj.R
R/scales.R
inst/doc/MoranI.pdf
man/add.scale.bar.Rd

index 61c911f870229067309416c0a28452b36005b004..02164f8d9ba77c712e08385fcffa7dede39713e6 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,18 @@
+               CHANGES IN APE VERSION 2.4-2
+
+
+NEW FEATURES
+
+    o add.scale.bar() has a new option 'ask' to draw interactively.
+
+
+BUG FIXES
+
+    o add.scale.bar() drew the bar outside the plotting region with the
+      default options with unrooted or radial trees.
+
+
+
                CHANGES IN APE VERSION 2.4-1
 
 
@@ -34,6 +49,9 @@ BUG FIXES
     o ace(type = "continuous", method = "ML") now avoids sigma² being
       negative (which resulted in an error).
 
+    o nj() crashed with NA/NaN in the distance matrix: an error in now
+      returned.
+
 
 
                CHANGES IN APE VERSION 2.4
index 37ec28380c2d8aec6ce6ce49fb50c14ac0fa8805..6609097aa4a00105640bb7088ec91d2c8c9e1348 100644 (file)
@@ -1,6 +1,6 @@
 Package: ape
-Version: 2.4-1
-Date: 2009-11-21
+Version: 2.4-2
+Date: 2009-12-16
 Title: Analyses of Phylogenetics and Evolution
 Author: Emmanuel Paradis, Ben Bolker, Julien Claude, Hoa Sien Cuong, Richard Desper, Benoit Durand, Julien Dutheil, Olivier Gascuel, Gangolf Jobb, Christoph Heibl, Daniel Lawson, Vincent Lefort, Pierre Legendre, Jim Lemon, Yvonnick Noel, Johan Nylander, Rainer Opgen-Rhein, Korbinian Strimmer, Damien de Vienne
 Maintainer: Emmanuel Paradis <Emmanuel.Paradis@ird.fr>
diff --git a/R/nj.R b/R/nj.R
index 2155f6b1f77d02a997558dc8adb44b2777b53e76..dada70e52a2a63b20777f98a6bee4ecfab65320e 100644 (file)
--- a/R/nj.R
+++ b/R/nj.R
@@ -1,4 +1,4 @@
-## nj.R (2009-07-10)
+## nj.R (2009-11-23)
 
 ##   Neighbor-Joining Tree Estimation
 
@@ -10,6 +10,8 @@
 nj <- function(X)
 {
     if (is.matrix(X)) X <- as.dist(X)
+    if (any(is.na(X)))
+        stop("missing values are not allowed in the distance matrix")
     N <- attr(X, "Size")
     labels <- attr(X, "Labels")
     if (is.null(labels)) labels <- as.character(1:N)
index 614db24540e46a4b0df02f7624e21abe165ec63d..2243278b19e8b94c9c6b6e652c32687eb39f9a92 100644 (file)
@@ -1,4 +1,4 @@
-## scales.R (2009-10-02)
+## scales.R (2009-12-16)
 
 ##   Add a Scale Bar or Axis to a Phylogeny Plot
 
@@ -10,7 +10,7 @@
 ## This file is part of the R-package `ape'.
 ## See the file ../COPYING for licensing issues.
 
-add.scale.bar <- function(x, y, length = NULL, ...)
+add.scale.bar <- function(x, y, length = NULL, ask = FALSE, ...)
 {
     lastPP <- get("last_plot.phylo", envir = .PlotPhyloEnv)
     direc <- lastPP$direction
@@ -22,24 +22,36 @@ add.scale.bar <- function(x, y, length = NULL, ...)
         length <- eval(parse(text = paste("1e", nb.digit, sep = "")))
     }
 
-    if (missing(x) || missing(y))
-        switch(direc,
-               "rightwards" = {
-                   x <- 0
-                   y <- 1
-               },
-               "leftwards" = {
-                   x <- max(lastPP$xx)
-                   y <- 1
-               },
-               "upwards" = {
-                   x <- max(lastPP$xx)
-                   y <- 0
-               },
-               "downwards" = {
-                   x <- 1
-                   y <- max(lastPP$yy)
-               })
+    if (ask) {
+        cat("\nClick where you want to draw the bar\n")
+        x <- unlist(locator(1))
+        y <- x[2]
+        x <- x[1]
+    } else if (missing(x) || missing(y)) {
+        if (lastPP$type %in% c("phylogram", "cladogram")) {
+            switch(direc,
+                   "rightwards" = {
+                       x <- 0
+                       y <- 1
+                   },
+                   "leftwards" = {
+                       x <- max(lastPP$xx)
+                       y <- 1
+                   },
+                   "upwards" = {
+                       x <- max(lastPP$xx)
+                       y <- 0
+                   },
+                   "downwards" = {
+                       x <- 1
+                       y <- max(lastPP$yy)
+                   })
+        } else {
+            direc <- "rightwards" # just to be sure for below
+            x <- lastPP$x.lim[1]
+            y <- lastPP$y.lim[1]
+        }
+    }
 
     switch(direc,
            "rightwards" = {
index 26a6a41b1231d1eea2cd80c76d619db78f779fe7..43204c11a2837457413c034ff89b71878c92e20a 100644 (file)
Binary files a/inst/doc/MoranI.pdf and b/inst/doc/MoranI.pdf differ
index 3736ca19c617dcff77a052425a73aaa10f2a2bf3..41dca6061d72f75a50fcacb0b161757e744da7cb 100644 (file)
@@ -2,13 +2,15 @@
 \alias{add.scale.bar}
 \title{Add a Scale Bar to a Phylogeny Plot}
 \usage{
-add.scale.bar(x, y, length = NULL, ...)
+add.scale.bar(x, y, length = NULL, ask = FALSE, ...)
 }
 \arguments{
   \item{x}{x location of the bar (can be left missing).}
   \item{y}{y location of the bar (can be left missing).}
   \item{length}{a numeric value giving the length of the scale bar. If
     none is supplied, a value is calculated from the data.}
+  \item{ask}{a logical; if \code{TRUE} the user is asked to click where
+    to draw the bar. The default is \code{FALSE}.}
   \item{\dots}{further arguments to be passed to \code{text}.}
 }
 \description{