+ CHANGES IN APE VERSION 2.3-4
+
+
+NEW FEATURES
+
+ o base.freq() has a new option 'freq' to return the counts; the
+ default is still to return the proportions.
+
+
+BUG FIXES
+
+ o seg.sites() did not handle ambiguous nucleotides correctly: they are
+ now ignored.
+
+
CHANGES IN APE VERSION 2.3-3
Package: ape
-Version: 2.3-3
-Date: 2009-09-09
+Version: 2.3-4
+Date: 2009-09-16
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>
if (is.list(x)) lapply(x, f) else f(x)
}
-base.freq <- function(x)
+base.freq <- function(x, freq = FALSE)
{
if (is.list(x)) x <- unlist(x)
n <- length(x)
- BF <- .C("BaseProportion", x, n, double(4),
+ BF <- .C("BaseProportion", x, n, double(4), freq,
DUP = FALSE, NAOK = TRUE, PACKAGE = "ape")[[3]]
names(BF) <- letters[c(1, 3, 7, 20)]
BF
\alias{base.freq}
\title{Base frequencies from DNA Sequences}
\usage{
-base.freq(x)
+base.freq(x, freq = FALSE)
}
\arguments{
\item{x}{a vector, a matrix, or a list which contains the DNA
sequences.}
+ \item{freq}{a logical specifying whether to return the proportions
+ (the default) or the absolute frequencies (counts).}
}
\description{
- This function computes the relative frequencies (i.e. percentages) of
+ This function computes the relative frequencies (i.e. proportions) of
the four DNA bases (adenine, cytosine, guanine, and thymidine) from a
sample of sequences.
}
computations.
}
\value{
- A numeric vector stoting the relative frequencies with names
+ A numeric vector storing the relative frequencies with names
\code{c("a", "c", "g", "t")}.
}
\author{Emmanuel Paradis \email{Emmanuel.Paradis@mpl.ird.fr}}
}
\details{
If the sequences are in a list, all the sequences must be of the same
- length.
+ length. Ambiguous nucleotides are ignored.
}
\value{
- A numeric vector giving the indices of the segregating sites.
+ A numeric (integer) vector giving the indices of the segregating
+ sites.
}
\author{Emmanuel Paradis \email{Emmanuel.Paradis@mpl.ird.fr}}
\note{
-/* dist_dna.c 2008-12-22 */
+/* dist_dna.c 2009-09-16 */
/* Copyright 2005-2008 Emmanuel Paradis
#define LN4 1.386294361119890572454
/* returns 8 if the base is known surely, 0 otherwise */
-#define KnownBase(a) a & 8
+#define KnownBase(a) (a & 8)
/* returns 1 if the base is adenine surely, 0 otherwise */
#define IsAdenine(a) a == 136
}
}
-void BaseProportion(unsigned char *x, int *n, double *BF)
+void BaseProportion(unsigned char *x, int *n, double *BF, int *freq)
{
int i, m;
}
}
}
- for (i = 0; i < 4; i++) BF[i] /= m;
+ if (! *freq) for (i = 0; i < 4; i++) BF[i] /= m;
}
void SegSites(unsigned char *x, int *n, int *s, int *seg)
basis = x[i];
i++;
while (i < *n * (j + 1)) {
- if (x[i] == basis) i++;
+ if (!KnownBase(x[i]) || x[i] == basis) i++;
else {
seg[j] = 1;
break;