Package: ape
Version: 3.0-2
-Date: 2012-04-02
+Date: 2012-04-05
Title: Analyses of Phylogenetics and Evolution
Author: Emmanuel Paradis, Ben Bolker, Julien Claude, Hoa Sien Cuong, Richard Desper, Benoit Durand, Julien Dutheil, Olivier Gascuel, Christoph Heibl, Daniel Lawson, Vincent Lefort, Pierre Legendre, Jim Lemon, Yvonnick Noel, Johan Nylander, Rainer Opgen-Rhein, Andrei-Alin Popescu, Klaus Schliep, Korbinian Strimmer, Damien de Vienne
Maintainer: Emmanuel Paradis <Emmanuel.Paradis@ird.fr>
triangMtds.c have been improved which should fix some bugs in
the corresponding functions.
+ o dist.gene() now coerces input data frame as matrix resulting in
+ much faster calculations (thanks to a suggestion by Markus
+ Schlegel).
+
CHANGES IN APE VERSION 3.0-1
-## dist.gene.R (2009-04-01)
+## dist.gene.R (2012-04-02)
## Pairwise Distances from Genetic Data
-## Copyright 2002-2009 Emmanuel Paradis
+## Copyright 2002-2012 Emmanuel Paradis
## This file is part of the R-package `ape'.
## See the file ../COPYING for licensing issues.
function(x, method = "pairwise", pairwise.deletion = FALSE,
variance = FALSE)
{
- if (!is.data.frame(x) && !is.matrix(x))
- stop("'x' should be a matrix or a data.frame")
+ if (is.data.frame(x)) x <- as.matrix(x) else { # suggestion by Markus Schlegel
+ if (!is.matrix(x))
+ stop("'x' should be a matrix or a data.frame")
+ }
method <- match.arg(method, c("pairwise", "percentage"))
if (!pairwise.deletion) {
n <- dim(x)
L <- n[2]
n <- n[1]
- D <- double(n*(n - 1)/2)
+ D <- double(n * (n - 1)/2)
if (pairwise.deletion) L <- D
- k <- 1
+ k <- 1L
for (i in 1:(n - 1)) {
for (j in (i + 1):n) {
y <- x[i, ] != x[j, ]
if (pairwise.deletion) L[k] <- sum(!is.na(y))
D[k] <- sum(y, na.rm = TRUE)
- k <- k + 1
+ k <- k + 1L
}
}
## L is either a single integer value if pairwise.deletion = FALSE,
if (variance) {
y <- if (method == "pairwise") L else 1
- attr(D, "variance") <- D*(y - D)/L
+ attr(D, "variance") <- D * (y - D)/L
}
D
}
variance = FALSE)
}
\arguments{
- \item{x}{a matrix or a data frame.}
+ \item{x}{a matrix or a data frame (will be coerced as a matrix).}
\item{method}{a character string specifying the method used to compute
the distances; two choices are available: \code{"pairwise"} and
\code{"percentage"}, or any unambiguous abbreviation of these.}
\code{\link{nj}}, \code{\link{bionj}}, \code{\link{fastme}},
\code{\link{njs}}, \code{\link{mvrs}}, \code{\link{SDM}}
}
+\examples{
+data(woodmouse)
+tr <- triangMtd(dist.dna(woodmouse))
+plot(tr)
+}
\keyword{models}
-/* mvr.c 2012-04-02 */
+/* mvr.c 2012-05-02 */
/* Copyright 2011-2012 Andrei-Alin Popescu */
eLenSum+=wi*(D[give_index(i,OTU2,n)]-D[give_index(i,OTU1,n)]);
}*/
- edge_length[k+1]=D[give_index(OTU1,OTU2,n)]/2 - edge_length[k];
+ edge_length[k+1]=D[give_index(OTU1,OTU2,n)] - edge_length[k];
A = D[smallest];
ij = 0;