- n <- dim(x)
- s <- n[2]
- n <- n[1]
- ans <- .C("SegSites", x, as.integer(n), as.integer(s),
- integer(s), PACKAGE = "ape")
- which(as.logical(ans[[4]]))
-}
-
-nuc.div <- function(x, variance = FALSE, pairwise.deletion = FALSE)
-{
- if (pairwise.deletion && variance)
- warning("cannot compute the variance of nucleotidic diversity\nwith pairwise deletion: try 'pairwise.deletion = FALSE' instead.")
-
- n <- dim(x)
- s <- n[2]
- n <- n[1]
-
- ## <FIXME> this should be safely deleted
- if (!pairwise.deletion) {
- keep <- .C("GlobalDeletionDNA", x, as.integer(n),
- as.integer(s), as.integer(rep(1, s)),
- PACKAGE = "ape")[[4]]
- x <- x[, as.logical(keep)]
- s <- dim(x)[2]
- }
- ## </FIXME>
-
- ans <- .C("NucleotideDiversity", x, as.integer(n), as.integer(s),
- as.integer(pairwise.deletion), double(1), PACKAGE = "ape")[[5]]
-
- if (variance) {
- var <- (n + 1)*ans/(3*(n + 1)*s) + 2*(n^2 + n + 3)*ans/(9*n*(n - 1))
- ans <- c(ans, var)