]> git.donarmstrong.com Git - ape.git/commitdiff
various changes and fixes
authorparadis <paradis@6e262413-ae40-0410-9e79-b911bd7a66b7>
Fri, 2 Oct 2009 09:35:07 +0000 (09:35 +0000)
committerparadis <paradis@6e262413-ae40-0410-9e79-b911bd7a66b7>
Fri, 2 Oct 2009 09:35:07 +0000 (09:35 +0000)
git-svn-id: https://svn.mpl.ird.fr/ape/dev/ape@94 6e262413-ae40-0410-9e79-b911bd7a66b7

ChangeLog
R/DNA.R
R/scales.R
R/write.nexus.data.R
Thanks
man/add.scale.bar.Rd

index 4f860f9260e7a1a132c40f8bc280b3a6174ae14c..402cf950ff587b3fb54fe40fb26c9f6e2e28f369 100644 (file)
--- 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 72e12582617e0927bdc5d9a2a884d5784b6c46fb..c751c5088812c96c893666233c83db0db91ff906 100644 (file)
--- 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
index 01f23f5fe96c8e263baf0f319284353de9b5b2ce..378f985cc4c434e3104c2a3498844aba991540a2 100644 (file)
 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, ...)
index b165e4234235d99e6d2ff0a6026b5e1ceae7ceef..deae1f80eac01ce6bac7b970e4ea2b41261c34c8 100644 (file)
         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 da83d4fe6e86011d347a7d5ddb4e89a0bf9d0c73..5d1b3f972020e72de44f9cd3fdfae07b0337d679 100644 (file)
--- 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.
index 57a1daafd5bbd6aba6a40ee534ed29b56874d040..3736ca19c617dcff77a052425a73aaa10f2a2bf3 100644 (file)
@@ -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}}).