]> git.donarmstrong.com Git - ape.git/commitdiff
many changes.......
authorparadis <paradis@6e262413-ae40-0410-9e79-b911bd7a66b7>
Tue, 12 May 2009 13:54:52 +0000 (13:54 +0000)
committerparadis <paradis@6e262413-ae40-0410-9e79-b911bd7a66b7>
Tue, 12 May 2009 13:54:52 +0000 (13:54 +0000)
git-svn-id: https://svn.mpl.ird.fr/ape/dev/ape@72 6e262413-ae40-0410-9e79-b911bd7a66b7

26 files changed:
ChangeLog
DESCRIPTION
R/DNA.R
R/ace.R
R/balance.R
R/birthdeath.R
R/branching.times.R
R/cherry.R
R/compar.ou.R
R/dist.topo.R
R/drop.tip.R
R/gammaStat.R
R/is.binary.tree.R
R/is.ultrametric.R
R/klastorin.R
R/ltt.plot.R
R/mrca.R
R/pic.R
R/root.R
R/rotate.R
R/summary.phylo.R
R/vcv.phylo.R
R/which.edge.R
R/write.dna.R
R/write.tree.R
man/dist.dna.Rd

index c154531e28da2bf5fa2b973bfce9f08c33588c3f..d76cb8db266152314af17f8b51b17a2239a74428 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -8,6 +8,16 @@ BUG FIXES
 
     o read.tree() failed to read correctly the tree name(s).
 
+    o boot.phylo() now treats correctly data frames.
+
+
+OTHER CHANGES
+
+    o [.multiPhylo and [.DNAbin now respect the original class.
+
+    o Instances of the form class(phy) == "phylo" have been replaced
+      by inherits(phy, "phylo").
+
 
 
                CHANGES IN APE VERSION 2.3
index 9bd41dc80ad2f69ab88ddad4cb9bc0de0d35526c..eeb4b873c1d9a45da60d8c14d2ec0e9a133d74db 100644 (file)
@@ -1,6 +1,6 @@
 Package: ape
 Version: 2.3-1
-Date: 2009-04-27
+Date: 2009-05-10
 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/DNA.R b/R/DNA.R
index 007547e5a9a2ba8b079808d370243b627fee71d5..7599265ea7ba08f3792cfd3fc5034b0b75889b61 100644 (file)
--- a/R/DNA.R
+++ b/R/DNA.R
@@ -1,8 +1,8 @@
-## DNA.R (2008-12-22)
+## DNA.R (2009-05-10)
 
 ##   Manipulations and Comparisons of DNA Sequences
 
-## Copyright 2002-2008 Emmanuel Paradis
+## Copyright 2002-2009 Emmanuel Paradis
 
 ## This file is part of the R-package `ape'.
 ## See the file ../COPYING for licensing issues.
@@ -14,7 +14,7 @@ del.gaps <- function(x)
         if (length(i)) x[-i] else x
     }
 
-    if (class(x) != "DNAbin") x <- as.DNAbin(x)
+    if (!inherits(x, "DNAbin")) x <- as.DNAbin(x)
     if (is.matrix(x)) {
         n <- dim(x)[1]
         y <- vector("list", n)
@@ -50,6 +50,7 @@ as.alignment <- function(x)
 
 "[.DNAbin" <- function(x, i, j, drop = TRUE)
 {
+    oc <- oldClass(x)
     class(x) <- NULL
     if (is.matrix(x)) {
         if (nargs() == 2 && !missing(i)) ans <- x[i]
@@ -63,12 +64,12 @@ as.alignment <- function(x)
         if (missing(i)) i <- 1:length(x)
         ans <- x[i]
     }
-    structure(ans, class = "DNAbin")
+    class(ans) <- oc
+    ans
 }
 
 as.matrix.DNAbin <- function(x, ...)
 {
-    if (is.matrix(x)) return(x)
     if (is.list(x)) {
         if (length(unique(unlist(lapply(x, length)))) != 1)
           stop("DNA sequences in list not of the same length.")
diff --git a/R/ace.R b/R/ace.R
index 0439600832a0f1018af4b75974ea11703f2a6e02..b45a88e2009cc5ee252c2e1e1246c6db0162423f 100644 (file)
--- a/R/ace.R
+++ b/R/ace.R
@@ -1,6 +1,6 @@
-## ace.R (2009-03-22)
+## ace.R (2009-05-10)
 
-##     Ancestral Character Estimation
+##   Ancestral Character Estimation
 
 ## Copyright 2005-2009 Emmanuel Paradis and Ben Bolker
 
@@ -11,7 +11,7 @@ ace <- function(x, phy, type = "continuous", method = "ML", CI = TRUE,
                 model = if (type == "continuous") "BM" else "ER",
                 scaled = TRUE, kappa = 1, corStruct = NULL, ip = 0.1)
 {
-    if (class(phy) != "phylo")
+    if (!inherits(phy, "phylo"))
       stop('object "phy" is not of class "phylo".')
     if (is.null(phy$edge.length))
         stop("tree has no branch lengths")
index ebcc8d6cc40e8fdf9f8f4dff9e44d0c67e44b511..37b2671e0645e5641a93a00074f8bdda1aa7bd9a 100644 (file)
@@ -1,8 +1,8 @@
-## balance.R (2006-10-04)
+## balance.R (2009-05-10)
 
 ##   Balance of a Dichotomous Phylogenetic Tree
 
-## Copyright 2002-2006 Emmanuel Paradis
+## Copyright 2002-2009 Emmanuel Paradis
 
 ## This file is part of the R-package `ape'.
 ## See the file ../COPYING for licensing issues.
@@ -10,7 +10,7 @@
 balance <- function(phy)
 {
 ### the tree must be in cladewise order
-    if (class(phy) != "phylo")
+    if (!inherits(phy, "phylo"))
       stop('object "phy" is not of class "phylo"')
     N <- length(phy$tip.label)
     nb.node <- phy$Nnode
index 469eef5d4089de159da3edad877904d70ccc0584..82decda388a03454f9b988e1f5dd9f39de834846 100644 (file)
@@ -1,4 +1,4 @@
-## birthdeath.R (2007-10-30)
+## birthdeath.R (2009-05-10)
 
 ##   Estimation of Speciation and Extinction Rates
 ##             with Birth-Death Models
@@ -6,14 +6,14 @@
 ## birthdeath: standard model
 ## bd.ext: extended version
 
-## Copyright 2002-2007 Emmanuel Paradis
+## Copyright 2002-2009 Emmanuel Paradis
 
 ## This file is part of the R-package `ape'.
 ## See the file ../COPYING for licensing issues.
 
 birthdeath <- function(phy)
 {
-    if (class(phy) != "phylo") stop('object "phy" is not of class "phylo"')
+    if (!inherits(phy, "phylo")) stop('object "phy" is not of class "phylo"')
     N <- length(phy$tip.label)
     x <- c(NA, branching.times(phy))
     dev <- function(a, r) {
@@ -80,7 +80,7 @@ print.birthdeath <- function(x, ...)
 
 bd.ext <- function(phy, S)
 {
-    if (class(phy) != "phylo") stop('object "phy" is not of class "phylo"')
+    if (!inherits(phy, "phylo")) stop('object "phy" is not of class "phylo"')
     if (!is.null(names(S))) {
         if (all(names(S) %in% phy$tip.label)) S <- S[phy$tip.label]
         else warning('the names of argument "S" and the names of the tip labels
index 38c27dfffa71571f21b27cb1a00cfb25e633e827..509fd83cddf450545c7ca5ef5c67df2f90a5a336 100644 (file)
@@ -1,8 +1,8 @@
-## branching.times.R (2006-10-04)
+## branching.times.R (2009-05-10)
 
 ##    Branching Times of a Phylogenetic Tree
 
-## Copyright 2002-2006 Emmanuel Paradis
+## Copyright 2002-2009 Emmanuel Paradis
 
 ## This file is part of the R-package `ape'.
 ## See the file ../COPYING for licensing issues.
@@ -10,7 +10,7 @@
 branching.times <- function(phy)
 {
 ### the tree must be in cladewise order
-    if (class(phy) != "phylo")
+    if (!inherits(phy, "phylo"))
       stop('object "phy" is not of class "phylo"')
     n <- length(phy$tip.label)
     N <- dim(phy$edge)[1]
index 7b952b87e74cbaa06b55ebe97ad6224c8f4719c0..347465cfa094a085bdbbbce7a536e9135ea957e7 100644 (file)
@@ -1,18 +1,18 @@
-## cherry.R (2006-10-03)
+## cherry.R (2009-05-10)
 
 ##     Number of Cherries and Null Models of Trees
 
-## Copyright 2002-2006 Emmanuel Paradis
+## Copyright 2002-2009 Emmanuel Paradis
 
 ## This file is part of the R-package `ape'.
 ## See the file ../COPYING for licensing issues.
 
 cherry <- function(phy)
 {
-    if (class(phy) != "phylo") stop("object \"phy\" is not of class \"phylo\"")
+    if (!inherits(phy, "phylo")) stop('object "phy" is not of class "phylo"')
     n <- length(phy$tip.label)
     nb.node <- phy$Nnode
-    if (nb.node != n - 1) stop("\"phy\" is not fully dichotomous")
+    if (nb.node != n - 1) stop('"phy" is not fully dichotomous')
     if (n < 4) stop("not enough tips in your phylogeny for this analysis")
     cherry <- sum(tabulate(phy$edge[, 1][phy$edge[, 2] <= n]) == 2)
     small.n <- n < 20
@@ -39,16 +39,14 @@ cherry <- function(phy)
 
 f.cherry.yule <- function(n, k)
 {
-    P <- if (k == 0 || k > floor(n/2)) 0 else if (n == 4) if (k == 1) 2/3 else if (k == 2) 1/3 else 0
-             else (1 - 2*(k - 1)/(n - 1))*f.cherry.yule(n - 1, k - 1) +
-              2*k/(n - 1)*f.cherry.yule(n - 1, k)
-    P
+    if (k == 0 || k > floor(n/2)) 0 else if (n == 4) if (k == 1) 2/3 else if (k == 2) 1/3 else 0
+    else (1 - 2*(k - 1)/(n - 1))*f.cherry.yule(n - 1, k - 1) +
+        2*k/(n - 1)*f.cherry.yule(n - 1, k)
 }
 
 f.cherry.uniform <- function(n, k)
 {
-    P <- if (k == 0 || k > floor(n/2)) 0 else if (n == 4) if (k == 1) 4/5 else if (k == 2) 1/5 else 0
-        else if (k == 1) 0 else (gamma(n + 1)*gamma(n - 2 + 1)*gamma(n - 4 + 1) * 2^(n-2*k)) /
-            (gamma(n - 2*k + 1)*gamma(2*n - 4 + 1)*gamma(k + 1)*gamma(k - 2 + 1))
-    P
+    if (k == 0 || k > floor(n/2)) 0 else if (n == 4) if (k == 1) 4/5 else if (k == 2) 1/5 else 0
+    else if (k == 1) 0 else (gamma(n + 1)*gamma(n - 2 + 1)*gamma(n - 4 + 1) * 2^(n-2*k)) /
+        (gamma(n - 2*k + 1)*gamma(2*n - 4 + 1)*gamma(k + 1)*gamma(k - 2 + 1))
 }
index 83e0d1cf5ab5eb0d939caac0a370a9884bc153d6..6512e63d24042e8ab728414c5a1123c9115a4481 100644 (file)
@@ -1,15 +1,15 @@
-## compar.ou.R (2006-10-05)
+## compar.ou.R (2009-05-10)
 
 ##   Ornstein--Uhlenbeck Model for Continuous Characters
 
-## Copyright 2005-2006 Emmanuel Paradis
+## Copyright 2005-2009 Emmanuel Paradis
 
 ## This file is part of the R-package `ape'.
 ## See the file ../COPYING for licensing issues.
 
 compar.ou <- function(x, phy, node = NULL, alpha = NULL)
 {
-    if (class(phy) != "phylo")
+    if (!inherits(phy, "phylo"))
       stop('object "phy" is not of class "phylo".')
     if (!is.numeric(x)) stop("'x' must be numeric.")
     if (!is.null(names(x))) {
index b57fb0a591535817da88b108448da12f308faefd..6741dcc8415f5ee1c33c1055aa58aa1e5fa55a49 100644 (file)
@@ -1,9 +1,9 @@
-## dist.topo.R (2008-07-18)
+## dist.topo.R (2009-05-10)
 
 ##      Topological Distances, Tree Bipartitions,
 ##   Consensus Trees, and Bootstrapping Phylogenies
 
-## Copyright 2005-2008 Emmanuel Paradis
+## Copyright 2005-2009 Emmanuel Paradis
 
 ## This file is part of the R-package `ape'.
 ## See the file ../COPYING for licensing issues.
@@ -168,8 +168,8 @@ prop.clades <- function(phy, ..., part = NULL)
 
 boot.phylo <- function(phy, x, FUN, B = 100, block = 1, trees = FALSE)
 {
-    if (is.list(x)) {
-        if (class(x) == "DNAbin") x <- as.matrix(x)
+    if (is.list(x) && !is.data.frame(x)) {
+        if (inherits(x, "DNAbin")) x <- as.matrix(x)
         else {
             nm <- names(x)
             n <- length(x)
index c0bda8bc15042186f101ac7f548e7fc1fb20dd34..efa429af446223f5838cfe58930d9bed17fc2395 100644 (file)
@@ -1,4 +1,4 @@
-## drop.tip.R (2009-03-22)
+## drop.tip.R (2009-05-10)
 
 ##   Remove Tips in a Phylogenetic Tree
 
@@ -74,7 +74,7 @@ extract.clade <- function(phy, node, root.edge = 0)
 drop.tip <-
     function(phy, tip, trim.internal = TRUE, subtree = FALSE, root.edge = 0)
 {
-    if (class(phy) != "phylo")
+    if (!inherits(phy, "phylo"))
         stop('object "phy" is not of class "phylo"')
     phy <- reorder(phy)
     Ntip <- length(phy$tip.label)
index 1c9d9812ee673315f0bafa33baf4070813bac8c2..8035a4ddbb0cfb379ef6b90b0056e658ad138b49 100644 (file)
@@ -1,15 +1,15 @@
-## gammaStat.R (2006-10-04)
+## gammaStat.R (2009-05-10)
 
 ##   Gamma-Statistic of Pybus and Harvey
 
-## Copyright 2002-2006 Emmanuel Paradis
+## Copyright 2002-2009 Emmanuel Paradis
 
 ## This file is part of the R-package `ape'.
 ## See the file ../COPYING for licensing issues.
 
 gammaStat <- function(phy)
 {
-    if (class(phy) != "phylo") stop('object "phy" is not of class "phylo"')
+    if (!inherits(phy, "phylo")) stop('object "phy" is not of class "phylo"')
     N <- length(phy$tip.label)
     bt <- sort(branching.times(phy))
     g <- rev(c(bt[1], diff(bt))) # internode intervals are from past to present
index 54551a07a85438f80c5b11c7589e0e727cbac122..1bff336d470d00603f61b555ad058c0d6e88e62e 100644 (file)
@@ -1,5 +1,5 @@
 ## is.binary.tree.R (2002-09-12) [modified by EP 2005-05-31, 2005-08-18,
-##                                2006-10-04]
+##                                2006-10-04, 2009-05-10]
 
 ##    Tests whether a given phylogenetic tree is binary
 
@@ -10,7 +10,7 @@
 
 is.binary.tree <- function(phy)
 {
-    if (class(phy) != "phylo") stop('object "phy" is not of class "phylo"')
+    if (!inherits(phy, "phylo")) stop('object "phy" is not of class "phylo"')
     ## modified by EP so that it works without edge lengths too (2005-05-31):
     nb.tip <- length(phy$tip.label)
     nb.node <- phy$Nnode
index 76abc58503889c55cfff9ba951569826e9b671c1..ae4c43937ea6f08ea6a8cae0afcf7d40a684195a 100644 (file)
@@ -1,4 +1,4 @@
-## is.ultrametric.R (2009-03-09)
+## is.ultrametric.R (2009-05-10)
 
 ##   Test if a Tree is Ultrametric
 
@@ -9,7 +9,7 @@
 
 is.ultrametric <- function(phy, tol = .Machine$double.eps^0.5)
 {
-    if (class(phy) != "phylo")
+    if (!inherits(phy, "phylo"))
       stop('object "phy" is not of class "phylo".')
     if (is.null(phy$edge.length))
       stop("the tree has no branch lengths.")
index 78fe5cfc4ba9f4f0b6fc77eb35b78393574896cf..27ba6eff4a64933ef10851ad0a989376088f2d5e 100644 (file)
@@ -46,7 +46,7 @@ klastorin_nTips <- function()
 
 klastorin <- function(phy)
 {
-    if (class(phy) != "phylo")
+    if (!inherits(phy, "phylo"))
       stop("object \"phy\" is not of class \"phylo\"")
     ## added by EP for the new coding of "phylo" (2006-10-04):
     phy <- new2old.phylo(phy)
index 6421e8b0d9f1366648e432e23c4ad22d63223ca0..15b53f8744e59dc8110f7bd3501f8bf8ea8998a4 100644 (file)
@@ -1,15 +1,15 @@
-## ltt.plot.R (2008-12-20)
+## ltt.plot.R (2009-05-10)
 
 ##    Lineages Through Time Plot
 
-## Copyright 2002-2008 Emmanuel Paradis
+## Copyright 2002-2009 Emmanuel Paradis
 
 ## This file is part of the R-package `ape'.
 ## See the file ../COPYING for licensing issues.
 
 ltt.plot <- function(phy, xlab = "Time", ylab = "N", ...)
 {
-    if (class(phy) != "phylo") stop('object "phy" is not of class "phylo"')
+    if (!inherits(phy, "phylo")) stop('object "phy" is not of class "phylo"')
     if (!is.binary.tree(phy)) phy <- multi2di(phy)
     time <- sort(branching.times(phy), decreasing = TRUE)
     N <- 1:(length(time) + 1)
@@ -35,7 +35,7 @@ mltt.plot <- function(phy, ..., dcol = TRUE, dlty = FALSE, legend = TRUE,
         y <- 1:length(x)
         cbind(x, y)
     }
-    if (class(phy) == "phylo") {
+    if if (inherits(phy, "phylo")) { # if a tree of class "phylo"
         TREES <- list(ltt.xy(phy))
         names(TREES) <- deparse(substitute(phy))
     } else { # a list of trees
index 4464672c5a343ccbbe30a4efc9932daea1194256..4583bae24ea9797dd4d1d11acb042b8a5e7ed1e7 100644 (file)
--- a/R/mrca.R
+++ b/R/mrca.R
@@ -1,15 +1,15 @@
-## mrca.R (2006-10-12)
+## mrca.R (2009-05-10)
 
 ##   Find Most Recent Common Ancestors Between Pairs
 
-## Copyright 2005-2006 Emmanuel Paradis
+## Copyright 2005-2009 Emmanuel Paradis
 
 ## This file is part of the R-package `ape'.
 ## See the file ../COPYING for licensing issues.
 
 mrca <- function(phy, full = FALSE)
 {
-    if (class(phy) != "phylo") stop('object "phy" is not of class "phylo"')
+    if (!inherits(phy, "phylo")) stop('object "phy" is not of class "phylo"')
     ##    if (!is.rooted(phy)) stop("the tree must be rooted.")
     ## Get all clades:
     nb.tip <- length(phy$tip.label)
diff --git a/R/pic.R b/R/pic.R
index d6f2aa18bbea2a449a7d64e43616099a9969e1d9..b3d2f6680edd0dc9a94d5ff8cabf66c45d81487a 100644 (file)
--- a/R/pic.R
+++ b/R/pic.R
@@ -1,15 +1,15 @@
-## pic.R (2006-10-29)
+## pic.R (2009-05-10)
 
 ##   Phylogenetically Independent Contrasts
 
-## Copyright 2002-2006 Emmanuel Paradis
+## Copyright 2002-2009 Emmanuel Paradis
 
 ## This file is part of the R-package `ape'.
 ## See the file ../COPYING for licensing issues.
 
 pic <- function(x, phy, scaled = TRUE, var.contrasts = FALSE)
 {
-    if (class(phy) != "phylo")
+    if (!inherits(phy, "phylo"))
       stop("object 'phy' is not of class \"phylo\"")
     if (is.null(phy$edge.length))
       stop("your tree has no branch lengths: you may consider setting them equal to one, or using the function `compute.brlen'.")
index a11fa1e73d521a61dcddbe3f5bc863fef778109d..832ab0f544ba0ef235870701ceb12798552b6b3c 100644 (file)
--- a/R/root.R
+++ b/R/root.R
@@ -1,15 +1,15 @@
-## root.R (2008-06-12)
+## root.R (2009-05-10)
 
 ##   Root of Phylogenetic Trees
 
-## Copyright 2004-2008 Emmanuel Paradis
+## Copyright 2004-2009 Emmanuel Paradis
 
 ## This file is part of the R-package `ape'.
 ## See the file ../COPYING for licensing issues.
 
 is.rooted <- function(phy)
 {
-    if (!"phylo" %in% class(phy))
+    if (!inherits(phy, "phylo"))
       stop('object "phy" is not of class "phylo"')
     if (!is.null(phy$root.edge)) return(TRUE)
     else
@@ -20,7 +20,7 @@ is.rooted <- function(phy)
 
 unroot <- function(phy)
 {
-    if (class(phy) != "phylo")
+    if (!inherits(phy, "phylo"))
       stop('object "phy" is not of class "phylo"')
     if (dim(phy$edge)[1] < 3)
       stop("cannot unroot a tree with two edges.")
@@ -64,7 +64,7 @@ unroot <- function(phy)
 
 root <- function(phy, outgroup, node = NULL, resolve.root = FALSE)
 {
-    if (class(phy) != "phylo")
+    if (!inherits(phy, "phylo"))
       stop('object "phy" is not of class "phylo"')
     ord <- attr(phy, "order")
     if (!is.null(ord) && ord == "pruningwise") phy <- reorder(phy)
index 520d677d8d96369cdc8ba953d6fd432f62757018..9a59d96262aac42439ff101f4ad1cd05a9034238 100644 (file)
@@ -28,7 +28,7 @@ rotate <- function(phy, node, polytom = c(1,2)){
                }
 # function starts here 
 # definitions
-       if (class(phy) != "phylo") # is phy of class phylo?
+       if (!inherits(phy, "phylo")) # is phy of class phylo?
         stop("object \"phy\" is not of class \"phylo\"")
     nb.tips <- length(phy$tip.label) # number of tiplabels
        max.int.node <- phy$Nnode+nb.tips # number of last internal node
index 54c2eaa51e3f30f317adadc7a135c4f8fd9b1f34..592050cfe844731d5212f4fd05d05ea76ba91a48 100644 (file)
@@ -1,31 +1,31 @@
-## summary.phylo.R (2008-04-22)
+## summary.phylo.R (2009-05-10)
 
 ##   Print Summary of a Phylogeny
 
-## Copyright 2003-2008 Emmanuel Paradis, and 2006 Ben Bolker
+## Copyright 2003-2009 Emmanuel Paradis, and 2006 Ben Bolker
 
 ## This file is part of the R-package `ape'.
 ## See the file ../COPYING for licensing issues.
 
 Ntip <- function(phy)
 {
-    if (class(phy) != "phylo")
-      stop('object "phy" is not of class "phylo"')
+    if (!inherits(phy, "phylo"))
+        stop('object "phy" is not of class "phylo"')
     length(phy$tip.label)
 }
 
 Nnode <- function(phy, internal.only = TRUE)
 {
-    if (class(phy) != "phylo")
-      stop('object "phy" is not of class "phylo"')
+    if (!inherits(phy, "phylo"))
+        stop('object "phy" is not of class "phylo"')
     if (internal.only) return(phy$Nnode)
     phy$Nnode + length(phy$tip.label)
 }
 
 Nedge <- function(phy)
 {
-    if (class(phy) != "phylo")
-      stop('object "phy" is not of class "phylo"')
+    if (!inherits(phy, "phylo"))
+        stop('object "phy" is not of class "phylo"')
     dim(phy$edge)[1]
 }
 
@@ -134,9 +134,10 @@ print.multiPhylo <- function(x, details = FALSE, ...)
 
 "[.multiPhylo" <- function(x, i)
 {
+    oc <- oldClass(x)
     class(x) <- NULL
     structure(x[i], TipLabel = attr(x, "TipLabel"),
-              class = "multiPhylo")
+              class = oc)
 }
 
 str.multiPhylo <- function(object, ...)
index 09e4dc3248bb4b356cce6b585ac1c160e976c93e..a51c6e4c35f243376237dc82cd9ee9c892474a93 100644 (file)
@@ -1,15 +1,15 @@
-## vcv.phylo.R (2006-10-04)
+## vcv.phylo.R (2009-05-10)
 
 ##   Phylogenetic Variance-Covariance or Correlation Matrix
 
-## Copyright 2002-2006 Emmanuel Paradis
+## Copyright 2002-2009 Emmanuel Paradis
 
 ## This file is part of the R-package `ape'.
 ## See the file ../COPYING for licensing issues.
 
 vcv.phylo <- function(phy, model = "Brownian", cor = FALSE)
 {
-    if (class(phy) != "phylo")
+    if (!inherits(phy, "phylo"))
       stop('object "phy" is not of class "phylo"')
     if (is.null(phy$edge.length))
       stop("the tree has no branch lengths")
index 0da0742247e2a4f1a4d895db51ecb188d782de65..b6405927b8a56d4fbb1792a2219d4434e7cd5af1 100644 (file)
@@ -1,8 +1,8 @@
-## which.edge.R (2007-09-11)
+## which.edge.R (2009-05-10)
 
 ##   Identifies Edges of a Tree
 
-## Copyright 2004-2007 Emmanuel Paradis
+## Copyright 2004-2009 Emmanuel Paradis
 
 ## This file is part of the R-package `ape'.
 ## See the file ../COPYING for licensing issues.
@@ -28,7 +28,7 @@ getMRCA <- function(phy, tip)
 
 which.edge <- function(phy, group)
 {
-    if (class(phy) != "phylo")
+    if (!inherits(phy, "phylo"))
       stop('object "phy" is not of class "phylo"')
     if (is.character(group))
       group <- which(phy$tip.label %in% group)
index 59712eafb182d1be4410d582fce08c4a99a5f160..eeedab5732219fa09d469c9495f9ed201747080e 100644 (file)
@@ -1,8 +1,8 @@
-## write.dna.R (2008-07-03)
+## write.dna.R (2009-05-10)
 
 ##   Write DNA Sequences in a File
 
-## Copyright 2003-2008 Emmanuel Paradis
+## Copyright 2003-2009 Emmanuel Paradis
 
 ## This file is part of the R-package `ape'.
 ## See the file ../COPYING for licensing issues.
@@ -13,7 +13,7 @@ write.dna <- function(x, file, format = "interleaved", append = FALSE,
 {
     format <- match.arg(format, c("interleaved", "sequential", "fasta"))
     phylip <- if (format %in% c("interleaved", "sequential")) TRUE else FALSE
-    if (class(x) == "DNAbin") x <- as.character(x)
+    if (inherits(x, "DNAbin")) x <- as.character(x)
     aligned <- TRUE
     if (is.matrix(x)) {
         N <- dim(x)
index 058565c1364fbe4c1437620e0f4740ae9ef934b1..1669e535ae66f1f937b3e53017c98ae4382a3d42 100644 (file)
@@ -1,4 +1,4 @@
-## write.tree.R (2009-03-23)
+## write.tree.R (2009-05-10)
 
 ##   Write Tree File in Parenthetic Format
 
@@ -39,7 +39,7 @@ write.tree <-
     }
     if (output.tree.names)
         names(tree) <- checkLabel(names(tree))
-    if (class(phy) == "multiPhylo") {
+    if (inherits(phy, "multiPhylo")) {
         write.tree(phy[[1]], file = file, append = append,
                    digits = digits, tree.names = names[1])
         if (length(phy) > 1)
@@ -47,7 +47,7 @@ write.tree <-
                 append = TRUE, digits = digits, tree.names = names(phy)[i])
         return(invisible(NULL))
     }
-    if (class(phy) != "phylo")
+    if (!inherits(phy, "phylo"))
         stop("object \"phy\" is not of class \"phylo\"")
     brl <- !is.null(phy$edge.length)
     nodelab <- !is.null(phy$node.label)
index 49571b17ee657dafb09e819ac29f5068efcfa043..b2c270a3bf8dfa8845a304f9b924f98912389cdd 100644 (file)
@@ -7,7 +7,9 @@ dist.dna(x, model = "K80", variance = FALSE,
          base.freq = NULL, as.matrix = FALSE)
 }
 \arguments{
-  \item{x}{a matrix or a list containing the DNA sequences.}
+  \item{x}{a matrix or a list containing the DNA sequences; this must be
+    of class \code{"DNAbin"} (use \code{\link{as.DNAbin}} is they are
+    stored as character).}
   \item{model}{a character string specifying the evlutionary model to be
     used; must be one of \code{"raw"}, \code{"N"}, \code{"JC69"},
     \code{"K80"} (the default), \code{"F81"}, \code{"K81"},