From 41cdf69dd7d0b334a94575c857f0d4c91a61e86f Mon Sep 17 00:00:00 2001 From: paradis Date: Thu, 18 Sep 2008 14:37:04 +0000 Subject: [PATCH] fix a few bugs + correct some the man page of sh.test() git-svn-id: https://svn.mpl.ird.fr/ape/dev/ape@49 6e262413-ae40-0410-9e79-b911bd7a66b7 --- Changes | 9 ++++++++- DESCRIPTION | 2 +- R/DNA.R | 14 +++++++++++--- R/read.nexus.R | 18 ++++++++++-------- man/sh.test.Rd | 7 +++---- 5 files changed, 33 insertions(+), 17 deletions(-) diff --git a/Changes b/Changes index 988dd6f..0ca803e 100644 --- a/Changes +++ b/Changes @@ -12,11 +12,18 @@ BUG FIXES o prop.part() failed with a single tree with the default option 'check.labels = TRUE'. + o summary.DNAbin() failed to display correctly the summary of + sequence lengths with lists of sequences of 10,000 bases or more + (because summary.default uses 4 significant digits by default). + + o read.nexus() failed to read a file with a single tree with line + breaks in the Newick string. + OTHER CHANGES o The data sets bird.orders and bird.families are now stored as - Newick strings; e.g., the command data(bird.orders) calls + Newick strings; i.e., the command data(bird.orders) calls read.tree(). diff --git a/DESCRIPTION b/DESCRIPTION index 7d0413a..1b4f9b9 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,6 +1,6 @@ Package: ape Version: 2.2-2 -Date: 2008-07-22 +Date: 2008-09-17 Title: Analyses of Phylogenetics and Evolution Author: Emmanuel Paradis, Ben Bolker, Julien Claude, Hoa Sien Cuong, Richard Desper, Benoit Durand, Julien Dutheil, Olivier Gascuel, diff --git a/R/DNA.R b/R/DNA.R index e51f252..90e841b 100644 --- a/R/DNA.R +++ b/R/DNA.R @@ -1,4 +1,4 @@ -## DNA.R (2008-06-08) +## DNA.R (2008-08-07) ## Manipulations and Comparisons of DNA Sequences @@ -141,8 +141,16 @@ summary.DNAbin <- function(object, printlen = 6, digits = 3, ...) cat("Label:", nms, "\n\n") } else { cat(n, "DNA sequences in binary format stored in a list.\n\n") - cat("Summary of sequence lengths:\n") - print(summary(unlist(lapply(object, length)))) + tmp <- unlist(lapply(object, length)) + mini <- min(tmp) + maxi <- max(tmp) + if (mini == maxi) + cat("All sequences of same length:", maxi, "\n") + else { + cat("Mean sequence length:", round(mean(tmp), 3), "\n") + cat(" Shortest sequence:", mini, "\n") + cat(" Longest sequence:", maxi, "\n") + } TAIL <- "\n\n" if (printlen < n) { nms <- nms[1:printlen] diff --git a/R/read.nexus.R b/R/read.nexus.R index d252096..cbf0f20 100644 --- a/R/read.nexus.R +++ b/R/read.nexus.R @@ -1,4 +1,4 @@ -## read.nexus.R (2008-07-11) +## read.nexus.R (2008-09-17) ## Read Tree File in Nexus Format @@ -156,13 +156,15 @@ read.nexus <- function(file, tree.names = NULL) semico <- grep(";", tree) Ntree <- length(semico) ## are some trees on several lines? - if (any(diff(semico) != 1)) { - STRING <- character(Ntree) - s <- c(1, semico[-Ntree] + 1) - j <- mapply(":", s, semico) - for (i in 1:Ntree) - STRING[i] <- paste(tree[j[, i]], collapse = "") - } else STRING <- tree + if (Ntree == 1 && length(tree) > 1) STRING <- paste(tree, collapse = "") else { + if (any(diff(semico) != 1)) { + STRING <- character(Ntree) + s <- c(1, semico[-Ntree] + 1) + j <- mapply(":", s, semico) + for (i in 1:Ntree) + STRING[i] <- paste(tree[j[, i]], collapse = "") + } else STRING <- tree + } rm(tree) STRING <- gsub(" ", "", STRING) colon <- grep(":", STRING) diff --git a/man/sh.test.Rd b/man/sh.test.Rd index ec367cd..57e6a5d 100644 --- a/man/sh.test.Rd +++ b/man/sh.test.Rd @@ -7,8 +7,7 @@ sh.test(..., x, model = DNAmodel(), B = 100) \arguments{ \item{...}{either a series of objects of class \code{"phylo"} separated by commas, or a list containing such objects.} - \item{x}{a list, a matrix, or a data frame containing the (aligned) - DNA sequences.} + \item{x}{a list or a matrix containing the (aligned) DNA sequences.} \item{model}{the model to be fitted to each tree (as an object of \code{"DNAmodel"}).} \item{B}{the number of bootstrap replicates.} @@ -19,9 +18,9 @@ sh.test(..., x, model = DNAmodel(), B = 100) } \details{ The present implementation follows the original formulation of - Shimodaira and Hasegawa (1999). A difference is that the bootstrap + Shimodaira and Hasegawa (1999) with the difference that the bootstrap resampling is done on the original sequence data rather than the RELL - method as sugested by Shimodaira and Hasegawa. + method suggested by Shimodaira and Hasegawa. } \value{ a numeric vector with the P-value associated with each tree given in -- 2.39.5