From: paradis Date: Fri, 2 Oct 2009 09:35:07 +0000 (+0000) Subject: various changes and fixes X-Git-Url: https://git.donarmstrong.com/?p=ape.git;a=commitdiff_plain;h=5de3d16fdc60bcbab2ae04933bca4ab931ed48f8 various changes and fixes git-svn-id: https://svn.mpl.ird.fr/ape/dev/ape@94 6e262413-ae40-0410-9e79-b911bd7a66b7 --- diff --git a/ChangeLog b/ChangeLog index 4f860f9..402cf95 100644 --- a/ChangeLog +++ b/ChangeLog @@ -15,6 +15,9 @@ BUG FIXES o plot(phy, root.edge = TRUE) failed if there was no $root.edge in the tree: the argument is now ignored. + o add.scale.bar() failed when 'x' and 'y' were given (thanks to Janet + Young for the fix). + OTHER CHANGES @@ -28,6 +31,10 @@ OTHER CHANGES o The argument 'adj' in [node][tip][edge]labels() now works when using 'pie' or 'thermo'. + o A more informative message error is now returned by dist.dna() when + 'model' is badly specified (partial matching of this argument is + done now). + o Deprecated functions are now listed in a help page: see help("ape-defunct") with the quotes. diff --git a/R/DNA.R b/R/DNA.R index 72e1258..c751c50 100644 --- a/R/DNA.R +++ b/R/DNA.R @@ -1,4 +1,4 @@ -## DNA.R (2009-09-18) +## DNA.R (2009-10-02) ## Manipulations and Comparisons of DNA Sequences @@ -292,7 +292,10 @@ dist.dna <- function(x, model = "K80", variance = FALSE, gamma = FALSE, { MODELS <- c("RAW", "JC69", "K80", "F81", "K81", "F84", "T92", "TN93", "GG95", "LOGDET", "BH87", "PARALIN", "N") - imod <- which(MODELS == toupper(model)) + imod <- pmatch(toupper(model), MODELS) + if (is.na(imod)) + stop(paste("'model' must be one of:", + paste("\"", MODELS, "\"", sep = "", collapse = " "))) if (imod == 11 && variance) { warning("computing variance temporarily not available for model BH87.") variance <- FALSE diff --git a/R/scales.R b/R/scales.R index 01f23f5..378f985 100644 --- a/R/scales.R +++ b/R/scales.R @@ -13,41 +13,51 @@ add.scale.bar <- function(x, y, length = NULL, ...) { lastPP <- get("last_plot.phylo", envir = .PlotPhyloEnv) + direc <- lastPP$direction if (is.null(length)) { nb.digit <- - if (lastPP$direction %in% c("rightwards", "leftwards")) diff(range(lastPP$xx)) + if (direc %in% c("rightwards", "leftwards")) diff(range(lastPP$xx)) else diff(range(lastPP$yy)) nb.digit <- ceiling(log10(nb.digit)) - 2 length <- eval(parse(text = paste("1e", nb.digit, sep = ""))) } - if (missing(x) || missing(y)) { - switch(lastPP$direction, + + if (missing(x) || missing(y)) + switch(direc, "rightwards" = { x <- 0 y <- 1 - segments(x, y, x + length, y) - text(x + length * 1.1, y, as.character(length), adj = c(0, 0.5), ...) }, "leftwards" = { x <- max(lastPP$xx) y <- 1 - segments(x - length, y, x, y) - text(x - length * 1.1, y, as.character(length), adj = c(1, 0.5), ...) }, "upwards" = { x <- max(lastPP$xx) y <- 0 - segments(x, y, x, y + length) - text(x, y + length * 1.1, as.character(length), adj = c(0, 0.5), srt = 90, ...) }, "downwards" = { x <- 1 y <- max(lastPP$yy) - segments(x, y - length, x, y) - text(x, y - length * 1.1, as.character(length), adj = c(0, 0.5), srt = 270, ...) - } - ) - } + }) + + switch(direc, + "rightwards" = { + segments(x, y, x + length, y) + text(x + length * 1.1, y, as.character(length), adj = c(0, 0.5), ...) + }, + "leftwards" = { + segments(x - length, y, x, y) + text(x - length * 1.1, y, as.character(length), adj = c(1, 0.5), ...) + }, + "upwards" = { + segments(x, y, x, y + length) + text(x, y + length * 1.1, as.character(length), adj = c(0, 0.5), srt = 90, ...) + }, + "downwards" = { + segments(x, y - length, x, y) + text(x, y - length * 1.1, as.character(length), adj = c(0, 0.5), srt = 270, ...) + }) } axisPhylo <- function(side = 1, ...) diff --git a/R/write.nexus.data.R b/R/write.nexus.data.R index b165e42..deae1f8 100644 --- a/R/write.nexus.data.R +++ b/R/write.nexus.data.R @@ -126,7 +126,7 @@ fcat("BEGIN DATA;\n") fcat(indent,"DIMENSIONS", " ", NTAX, " ", NCHAR, ";\n") if (format %in% c("dna", "protein")) { - fcat(indent, "FORMAT", " ", MISSING, " ", GAP, " ", DATATYPE, " ", INTERLEAVE, ";\n") + fcat(indent, "FORMAT", " ", DATATYPE, " ", MISSING, " ", GAP, " ", INTERLEAVE, ";\n") # from François Michonneau (2009-10-02) } fcat(indent,"MATRIX\n") print.matrix(x) diff --git a/Thanks b/Thanks index da83d4f..5d1b3f9 100644 --- a/Thanks +++ b/Thanks @@ -7,8 +7,8 @@ comments, or bug reports: thanks to all of you! Significant bug fixes were provided by Cécile Ané, James Bullard, Éric Durand, Olivier François, Rich FitzJohn, Bret Larget, Nick Matzke, Michael Phelan, Elizabeth Purdom, Dan Rabosky, Klaus Schliep, Tim -Wallstrom, Li-San Wang, Yan Wong, and Peter Wragg. Contact me if I -forgot someone. +Wallstrom, Li-San Wang, Yan Wong, Peter Wragg, and Janet Young. Contact +me if I forgot someone. Kurt Hornik, of the R Core Team, helped in several occasions to fix some problems and bugs. diff --git a/man/add.scale.bar.Rd b/man/add.scale.bar.Rd index 57a1daa..3736ca1 100644 --- a/man/add.scale.bar.Rd +++ b/man/add.scale.bar.Rd @@ -9,7 +9,7 @@ add.scale.bar(x, y, length = NULL, ...) \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{...}{further arguments to be passed to \code{text}.} + \item{\dots}{further arguments to be passed to \code{text}.} } \description{ This function adds a horizontal bar giving the scale of the branch @@ -19,9 +19,9 @@ add.scale.bar(x, y, length = NULL, ...) \details{ By default, the bar is placed in a corner of the graph depending on the direction of the tree. Otherwise both \code{x} and \code{y} must - be specified (if only one is given it is ignored). + be specified (if only one is given it is ignored). - The further arguments (\code{...}) are used to format the text. They + The further arguments (\code{\dots}) are used to format the text. They may be \code{font}, \code{cex}, \code{col}, and so on (see examples below, and the help page on \code{\link[graphics]{text}}).