From: paradis Date: Tue, 12 May 2009 13:54:52 +0000 (+0000) Subject: many changes....... X-Git-Url: https://git.donarmstrong.com/?a=commitdiff_plain;h=4ceef408de61dc86f0a93b0396aecc6e30cc0d70;p=ape.git many changes....... git-svn-id: https://svn.mpl.ird.fr/ape/dev/ape@72 6e262413-ae40-0410-9e79-b911bd7a66b7 --- diff --git a/ChangeLog b/ChangeLog index c154531..d76cb8d 100644 --- 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 diff --git a/DESCRIPTION b/DESCRIPTION index 9bd41dc..eeb4b87 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -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 diff --git a/R/DNA.R b/R/DNA.R index 007547e..7599265 100644 --- 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 0439600..b45a88e 100644 --- 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") diff --git a/R/balance.R b/R/balance.R index ebcc8d6..37b2671 100644 --- a/R/balance.R +++ b/R/balance.R @@ -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 diff --git a/R/birthdeath.R b/R/birthdeath.R index 469eef5..82decda 100644 --- a/R/birthdeath.R +++ b/R/birthdeath.R @@ -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 diff --git a/R/branching.times.R b/R/branching.times.R index 38c27df..509fd83 100644 --- a/R/branching.times.R +++ b/R/branching.times.R @@ -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] diff --git a/R/cherry.R b/R/cherry.R index 7b952b8..347465c 100644 --- a/R/cherry.R +++ b/R/cherry.R @@ -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)) } diff --git a/R/compar.ou.R b/R/compar.ou.R index 83e0d1c..6512e63 100644 --- a/R/compar.ou.R +++ b/R/compar.ou.R @@ -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))) { diff --git a/R/dist.topo.R b/R/dist.topo.R index b57fb0a..6741dcc 100644 --- a/R/dist.topo.R +++ b/R/dist.topo.R @@ -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) diff --git a/R/drop.tip.R b/R/drop.tip.R index c0bda8b..efa429a 100644 --- a/R/drop.tip.R +++ b/R/drop.tip.R @@ -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) diff --git a/R/gammaStat.R b/R/gammaStat.R index 1c9d981..8035a4d 100644 --- a/R/gammaStat.R +++ b/R/gammaStat.R @@ -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 diff --git a/R/is.binary.tree.R b/R/is.binary.tree.R index 54551a0..1bff336 100644 --- a/R/is.binary.tree.R +++ b/R/is.binary.tree.R @@ -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 diff --git a/R/is.ultrametric.R b/R/is.ultrametric.R index 76abc58..ae4c439 100644 --- a/R/is.ultrametric.R +++ b/R/is.ultrametric.R @@ -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.") diff --git a/R/klastorin.R b/R/klastorin.R index 78fe5cf..27ba6ef 100644 --- a/R/klastorin.R +++ b/R/klastorin.R @@ -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) diff --git a/R/ltt.plot.R b/R/ltt.plot.R index 6421e8b..15b53f8 100644 --- a/R/ltt.plot.R +++ b/R/ltt.plot.R @@ -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 diff --git a/R/mrca.R b/R/mrca.R index 4464672..4583bae 100644 --- 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 d6f2aa1..b3d2f66 100644 --- 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'.") diff --git a/R/root.R b/R/root.R index a11fa1e..832ab0f 100644 --- 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) diff --git a/R/rotate.R b/R/rotate.R index 520d677..9a59d96 100644 --- a/R/rotate.R +++ b/R/rotate.R @@ -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 diff --git a/R/summary.phylo.R b/R/summary.phylo.R index 54c2eaa..592050c 100644 --- a/R/summary.phylo.R +++ b/R/summary.phylo.R @@ -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, ...) diff --git a/R/vcv.phylo.R b/R/vcv.phylo.R index 09e4dc3..a51c6e4 100644 --- a/R/vcv.phylo.R +++ b/R/vcv.phylo.R @@ -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") diff --git a/R/which.edge.R b/R/which.edge.R index 0da0742..b640592 100644 --- a/R/which.edge.R +++ b/R/which.edge.R @@ -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) diff --git a/R/write.dna.R b/R/write.dna.R index 59712ea..eeedab5 100644 --- a/R/write.dna.R +++ b/R/write.dna.R @@ -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) diff --git a/R/write.tree.R b/R/write.tree.R index 058565c..1669e53 100644 --- a/R/write.tree.R +++ b/R/write.tree.R @@ -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) diff --git a/man/dist.dna.Rd b/man/dist.dna.Rd index 49571b1..b2c270a 100644 --- a/man/dist.dna.Rd +++ b/man/dist.dna.Rd @@ -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"},