From: paradis Date: Wed, 16 Dec 2009 07:04:48 +0000 (+0000) Subject: small changed in add.scale.bar X-Git-Url: https://git.donarmstrong.com/?p=ape.git;a=commitdiff_plain;h=b6251dc651f595cd4f7fe8a76f36a6d4d841b54d small changed in add.scale.bar git-svn-id: https://svn.mpl.ird.fr/ape/dev/ape@101 6e262413-ae40-0410-9e79-b911bd7a66b7 --- diff --git a/ChangeLog b/ChangeLog index 61c911f..02164f8 100644 --- 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 diff --git a/DESCRIPTION b/DESCRIPTION index 37ec283..6609097 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -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 diff --git a/R/nj.R b/R/nj.R index 2155f6b..dada70e 100644 --- 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) diff --git a/R/scales.R b/R/scales.R index 614db24..2243278 100644 --- a/R/scales.R +++ b/R/scales.R @@ -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" = { diff --git a/inst/doc/MoranI.pdf b/inst/doc/MoranI.pdf index 26a6a41..43204c1 100644 Binary files a/inst/doc/MoranI.pdf and b/inst/doc/MoranI.pdf differ diff --git a/man/add.scale.bar.Rd b/man/add.scale.bar.Rd index 3736ca1..41dca60 100644 --- a/man/add.scale.bar.Rd +++ b/man/add.scale.bar.Rd @@ -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{