Tajima Relative Rate Test of Molecular Clock
This function tests the hypothesis of a molecular evolutionary clock (i.e., a constant rate of molecular evolution) between two samples using an outgroup sample. It can be applied to both nucleotide and amino acid sequences.
rr.test(x, y, out)
x, y |
a single DNA sequence (object class |
out |
a single DNA sequence to be used as outgroup. |
a list with two numeric values: Chi
(Chi-squared statistic) and
Pval
(the P-value).
Alastair Potts potts.a@gmail.com
Tajima, F. (1993) Simple methods for testing molecular clock hypothesis. Genetics, 135, 599–607. (Equation 4)
require(ape) data(woodmouse) rr.test(x = woodmouse[2, ], y = woodmouse[3, ], out = woodmouse[1, ]) # Test all pairs in a sample: outgroup <- woodmouse[1, ] n <- nrow(woodmouse) cc <- combn(2:n, 2) FUN <- function(x) rr.test(woodmouse[x[1], ], woodmouse[x[2], ], outgroup)$Pval OUT <- apply(cc, 2, FUN) ### two ways to arrange the output: RES <- matrix(NA, n - 1, n - 1) RES[row(RES) > col(RES)] <- OUT RES <- t(RES) RES[row(RES) > col(RES)] <- OUT RES <- t(RES) dimnames(RES) <- list(2:n, 2:n) RES <- as.dist(RES) ### 2nd method: class(OUT) <- "dist" attr(OUT, "Labels") <- as.character(2:15) attr(OUT, "Size") <- n - 1L attr(OUT, "Diag") <- attr(OUT, "Upper") <- FALSE ### they are the same: all(OUT == RES)
Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.