Statistical tests to identify appropriate types of nucleotide sequence recoding in molecular phylogenetics

Background Under a Markov model of evolution, recoding, or lumping, of the four nucleotides into fewer groups may permit analysis under simpler conditions but may unfortunately yield misleading results unless the evolutionary process of the recoded groups remains Markovian. If a Markov process is lumpable, then the evolutionary process of the recoded groups is Markovian. Results We consider stationary, reversible, and homogeneous Markov processes on two taxa and compare three tests for lumpability: one using an ad hoc test statistic, which is based on an index that is evaluated using a bootstrap approximation of its distribution; one that is based on a test proposed specifically for Markov chains; and one using a likelihood-ratio test. We show that the likelihood-ratio test is more powerful than the index test, which is more powerful than that based on the Markov chain test statistic. We also show that for stationary processes on binary trees with more than two taxa, the tests can be applied to all pairs. Finally, we show that if the process is lumpable, then estimates obtained under the recoded model agree with estimates obtained under the original model, whereas, if the process is not lumpable, then these estimates can differ substantially. We apply the new likelihood-ratio test for lumpability to two primate data sets, one with a mitochondrial origin and one with a nuclear origin. Conclusions Recoding may result in biased phylogenetic estimates because the original evolutionary process is not lumpable. Accordingly, testing for lumpability should be done prior to phylogenetic analysis of recoded data.


Introduction
When nucleotides intentionally are recoded to a 3-or 2state alphabet in order to focus on a subset of the possible types of substitutions (e.g., transversions [1][2][3]) or reduce compositional heterogeneity [4], it is no longer appropriate to use model-based phylogenetic methods that rely solely on time-reversible, 4-state Markov models. Instead, one needs to use a 3-or 2-state Markov model to approximate the evolutionary processes for the recoded sequence data. This requirement was first realised by Phillips and Penny [5], who used a time-reversible 2-state Markov model [6] to analyse RYrecoded nucleotide sequences, and Gibson et al. [7], who developed a time-reversible 3-state Markov model to analyse Y-recoded nucleotide sequences. Before these studies, other investigators had used RY-recoded nucleotide sequences to infer the evolutionary relationships among mammals [1][2][3] and among bacteria [4].
Recoding of nucleotides and/or amino acids has been used repeatedly in recent phylogenetic studies . However, the mathematical principles underpinning the recoding of nucleotides or amino acids have not yet been adequately examined. For example, it is not yet known whether the Markovian property is maintained after recoding and how this should be tested [32]. Without this knowledge, we may run the risk of using a promising procedure in a manner that turns out to be inappropriate for the data.
In this paper, we take a first step by considering tests for lumpability in a Markov model of evolution for pairs of homologous nucleotide sequences (we are aware of only one paper in the phylogenetic literature where the term lumpability is used [33], but there it was used in a different context). We only consider nucleotides but believe our tests could be generalized to encompass amino acids as well. We then illustrate the performance of our tests for lumpability using simulated and real data, and show that recoding of nucleotides should be used with caution when analysing DNA phylogenetically.

Methods
The theoretical basis for recoding nucleotides Let S = {A, C, G, T} be the set of nucleotides, and let S be a partition of S such that S = {S 1 , ..., S q }, where q <4. Then S is reduced by grouping, or lumping, some of the original states (i.e., A, C, G, and T) into one or two new states (i.e., R, Y, S, W, M, K, B, D, H, and V )-in molecular phylogenetics, this procedure has been called recoding [34]. Table 1 presents the 13 possible recoding schemes and partitions of S using notation established by the NC-IUB [35]. The 13 recoding schemes fall into three major grouping categories, as shown in Table 1.

The evolutionary process for two homologous nucleotide sequences
Consider two nucleotide sequences, A and B, each with n independently evolving sites, which have diverged under Markovian conditions from their common ancestor on a rooted, 2-tipped tree. Let π 0 denote the initial probability vector of the nucleotide frequencies, such that π T 0 = (π 0 1 , π 0 2 , π 0 3 , π 0 4 ) , where, for convenience of notation, we will use the subscripts 1, 2, 3, 4 to denote A, G, C, T . Over each edge of this tree, there is a substitution process, X(t) and Y(t), respectively, described by the transition probabilities Let f ij (t) denote the theoretical joint probability of a site being in state i in A and state j in B at time t: Now, let F(t) = {f ij (t)} denote the joint probability matrix and let P X (t) and P Y (t) denote the transition probability matrices of X(t) and Y(t). In practice, the two matrices cannot be identified from F(t) without some assumptions about the evolutionary processes of the sequences A and B. We assume that the processes are globally stationary, reversible, and homogeneous (SRH) (for definitions, see [36][37][38][39], and, in more detail, [40]). Given these assumptions, take P X (t) = P Y (t) = P(t) and, if π X and π Y denote the equilibrium probability distributions of the processes X(t) and Y(t), take π X = π Y = π 0 = π and write Π = diag(π). Then, from (1), we get F(t) = P (t) T ΠP(t). The transition probability matrix can be expressed by an instantaneous rate matrix R, such that P π T R = 0 T , where π T is the equilibrium distribution of R [40]. Furthermore, the instantaneous rate matrix can take the form R = SΠ, where S is a symmetric matrix with s ij ≥ 0 for i ≠ j, and s ii = − 4 i =j s ij π j /π i [40]. The matrices R and P(t) can be written in terms of the Table 1 The 13 ways of reducing a 4-letter state space ( S ) to a 3-or 2-letter state space S . eigenvector decomposition of Π 1/2 SΠ 1/2 = LΛL T . In other words and where Λ is a diagonal matrix with columns containing the eigenvalues of Π 1/2 SΠ 1/2 and L is a matrix with columns containing its right eigenvectors. The joint probability matrix is then symmetric and Note that under these assumptions, there are only nine free parameters to be estimated: six free parameters for the off-diagonal elements of S (define s T = (s 12 , s 13 , s 14 , s 23 , s 24 , s 34 )) and three free parameters for π (because π 4 = 1 − 3 i=1 π i ). The time t can be fixed at 1 since modifying it is equivalent to modifying the sparameters.
Let N denote the 4 × 4 divergence matrix for A and B, such that N = {n ij }, where n ij represents the number of homologous sites that are in state i in A and state j in B. Under the model, the vector of elements of N has a multinomial distribution with parameters n and F(t); its expected value is thus E(N) = nF(t). Because the parameters s and π are in a one-to-one relation with the elements of F, the maximum-likelihood estimates of s and π can be obtained from the eigenvector decomposition and whereL andˆ

Lumpable Markov chains
The following probabilities can be defined for any given S = {S 1 , · · ·, S q }, where q <4, such that a lumped process, X (t) , with a smaller number of states, is generated with transition probabilities and initial probabilities π = P[X (0) = k] = P[X(0) ∈ S k ] . By definition [41,42], a Markov process is lumpable if, for every starting vector π, the lumped process, defined in (7), is a Markov chain whose transition probabilities do not depend on the choice of π. A necessary and sufficient condition for X'(t) to be lumpable with respect to a partition S is that for every pair of subsets, S k and S l , j∈S l P ij (t) , has the same value for every state i in S k [41,42]. Accordingly, if X'(t) is lumpable, then the transition probabilities for X'(t) for any given pair of subsets in S are If the Markov chain is lumpable, the lumped transition matrix P'(t) can be expressed as a matrix function of P(t) as follows: where V is a 4 × q matrix, where q is the number of states in the lumped process, such that the l-th column of V is a vector with 1's in the components corresponding to states in S l and 0's otherwise, and is a q × 4 matrix whose k-th row is a probability vector with non-zero elements corresponding to the states in S k . A useful necessary and sufficient condition for lumpability [41,42] is In the case of nucleotides, the second column of Table 2 gives the conditions required for lumpability of four nucleotides.
We note that under certain conditions, such as those considered by the JC [43] and F81 [44] models, all recodings are lumpable. Conditions under which recoding of nucleotides are possible for the K2P [45] and HKY [46] models are given in Table 3.2 of [32].

Tests for lumpability
We consider three possible tests: An ad hoc test based on a parametric bootstrap for an index of departure from the lumpability condition [32]; a test based on a test for lumpability in Markov chains [47]; and a likelihood-ratio test.

Markov chain test
A c 2 test to determine whether a Markov chain is lumpable with respect to a partition S is available [47]. The test is based on the comparison of observed transition frequencies to their respective theoretical counterparts under the null hypothesis that the chain is lumpable. The approach does not make any assumption about reversibility or stationarity of the process. The authors used a matrix of transition counts, {n ij }, to estimate the transition probabilities p ij , where n ij represents the number of transitions into state j from state i in one step, so the number of steps in the Markov chain is n •• , where the subscript • indicates summation. Now, if we start from our divergence matrix N, where n ij represents the number of sites that are in state i for sequence A and state j in sequence B, and the SRH assumptions are kept, either A or B can be assumed to be the original sequence at time 0, whereas the other one can be assumed to be the observed sequence at time 2 (since we took the edge lengths to be 1). Take A as the ancestral sequence, then the divergence matrix N has the same properties as a transition count matrix, and we can proceed as described in [47]. A transition probability from i to S l is where l = 1, ..., q. From the definition of a lumpable process (7), if the Markovian process is lumpable with respect to S , then where g k is the number of states that are part of the subset S k , and k = 1, ..., q. Therefore, g il = P kl (2) if the process is lumpable and the null hypothesis of lumpability can be expressed as H 0 : g il = P kl (2) for all i ∈ S k . Given the divergence matrix, N, estimates g il and P kl (2) arê where N = {n kl } is the divergence matrix of the recoded nucleotide sequences. Jernigan and Baran [47] obtained the test statistic
This maximization needs a new approach. We construct an orthogonal matrix, A, such that where y is the response constraint vector, defined such that two values of y are zero corresponding to the two constraints. The matrix A will, in the case of partitions into two groups of two, contain π, so to emphasise this possible dependence, write y = g(s|π). Also write s = A −1 y = g −1 (y|π). Then L(π ,s) = max π ,y L(π , g −1 (y|π )). The optimization process is done in two steps: the values of s, if dependent of π, are optimized given the original π set, then the π vector is optimized given the optimized values of s. This process is repeated until convergence is achieved.
From these two log-likelihood values, a log likelihoodratio, LR, can be calculated with Under the null hypothesis of lumpability, 2 × LR is distributed as a c 2 variable with 2 degrees of freedom. The joint probability distribution was calculated by the steps given in (2), (3), and (4); then, assuming a nucleotide sequence of length n = 1500, 5000 divergence matrices were calculated by Monte Carlo simulations assuming that N i is multinomial with parameters (n, F(1)) for i = 1, . . . , 5000.

Assessment of accuracy
The accuracy of each test for lumpability was verified using a PP plot displaying the distribution of observed P-values, obtained from each test, plotted against the expected P-values, obtained from the uniform distribution. The linear relationship between these two sets of P-values (Figure 1) confirms the accuracy of the tests.

Comparisons of power
The power of each test was compared for each recoding scheme under non-lumpable conditions. To do this, we used π T = (0.1, 0.2, 0.3, 0.4) and values of s that yield increasing values of h, as in (9), generated 3000 divergence matrices using Monte Carlo simulation, and then calculated the three test statistics and their corresponding P-values, using the procedures explained above, for each value of h. The power at the 5% level, is then equal to the proportion of observed P-values less than 0.05. Figure 2 shows the power curves for RY recodingsimilar power curves were obtained for the other 12 recoding schemes (results not shown). All of these results indicate that the likelihood-ratio test is the most powerful of the tests considered, followed by the Index test and, finally, by the Markov Chain test.

Cases with more than 2 homologous sequences
For general cases involving more than 2 homologous sequences, we can test for lumpability in all pairs of sequences by using the methods described above under the assumption that the evolutionary process is SRH over the whole tree (i.e., the process is globally SRH). For example, in the case of an alignment with seven sequences, there will be 21 P-values. A PP-plot with these P-values should yield a straight line when the data are lumpable, and deviations from this expectation when the processes are not lumpable. However, the observed P-values are not independent, so we need to show that this condition is not cause for concern for the dots in a PP-plot to be on a straight line. We give a simplified argument taken from [48]. Consider a set of observed P-values P 1 , . . ., P n , which, if all the null hypotheses are true, are identically distributed as uniform random variables on (0, 1). Let p be any value between 0 and 1, let I(P j < p) take the value 1 if I P j < p be the number of observed P-values less than p. Then E(I(P j < p)) = P (P j < p) = p and so the expected number of P-values less than p is E(N p ) = np. This implies that the plot of the observed P-values will lie approximately on a straight line. The dependence will cause some clustering of the observed P-values but the PP-plot will remain useful in indicating whether there is evidence against some of the hypotheses.
The PP-plots shown in Figure 3 were obtained from alignments of nucleotides generated under lumpable or non-lumpable conditions, with respect to RY recoding, on the tree shown in Figure 4 before being analysed using the likelihood-ratio test. From these two plots, it is clear that the test is able to identify cases where sequences have evolved under non-lumpable conditions.

The effect of non-lumpability on phylogenetic estimates
If a process is lumpable with respect to a given recoding scheme (e.g., RY), then we can obtain F q (t) = V T P(t)V and from this, using (2,3) and (4), we can further obtain the transition matrix of the process X'(t), where Π q = V T ΠV . If the process is not lumpable with respect to that recoding scheme, then X'(t) is not a Markov process and, although we can calculate P q (t), it is not the transition matrix of the process X'(t).
In either case, the matrix P'(t) = UP(t)V can be defined and, if the process X(t) is lumpable, then P'(t) = P q (t). On the other hand, if X(t) is not lumpable, the elements of P'(t) are still given as P kl (t) = P(X (t) = l|X (0) = k) , but P'(t) is no longer a transition matrix of X'(t). Conveniently, we can compare P'(1), the true conditional probability matrix at t = 1, with P q (1), the false transition  matrix at t = 1, thus allowing us to examine the effect of non-lumpability. Figure 5 illustrates the effect on phylogenetic estimates. Figure 5a shows the tree used to simulate alignments of 3000 nucleotides under a time-reversible 4-state Markov model with π T = (0.2, 0.3, 0.2, 0.3) and s T = (0.2, 0.1, 0.3, 0.3, 1.0, 0.2). As can be seen from the πand s-vectors, the lumpable condition is met for RY-recoding but not for KM-recoding. Figures 5b and 5c display the corresponding tree with the edge lengths adjusted according to, respectively, the RY-and KM-recoding schemes.
Every edge in the tree obtained from the RY-recoded data is shorter than the corresponding edge in the tree obtained from the original data. However, because the original process was lumpable with respect to RY-recoding, the relative length of each edge in the two trees is the same, the difference being equal to a scale factor  Every edge in the tree obtained from the KM-recoded data is also shorter than the corresponding edge in the tree obtained from the original data, but the relative length of each edge in the two trees differ, the reason being that the process generating the original data was not lumpable with respect to KM-recoding. Figures 5d, 5e, and 5f show the corresponding results for the data generated by Monte Carlo simulation. The three trees display the same characteristics as those shown in Figures 5a, 5b, and 5c, while also showing some variation in the edge lengths that is due to the random nature of the data and the finite sample size. Hence, although recoding of nucleotides might be useful for a variety of reasons, using recoded data, without having tested for lumpability first, might lead to biased phylogenetic estimates.

Example 1 -Primate mitochondrial DNA
In a previous study [37], a set of mitochondrial nucleotide sequences of hominoid origin were found to to fit the GTR model [49], implying that the data are consistent with evolution under globally SRH conditions. We applied the likelihood-ratio test to these data. Figure 6 shows the PP-plots from tests for lumpability for RY recoding, indicating non-lumpability, and AGY recoding, indicating lumpability.

Example 2 -Primate nuclear DNA
In a previous study [50], a~9.3kb fragment of X chromosomal DNA was obtained from 26 species of primates and analysed phylogenetically using the HKY model. In so doing, the authors implicitly assumed evolution under globally SRH conditions. We wanted to apply the likelihood-ratio test to these data, so we obtained the same 26 sequences from GenBank [51], aligned them using MAFFT [52] (with the linsi option invoked), and, using SeaView [53], removed all columns with gaps and/or ambiguous characters. The resulting alignment contained 6913 sites from the 26 species. We then applied the matched-pairs test of symmetry [38] to the data to determine whether the sequences were consistent with evolution under globally SRH conditions. The PP-plot in Figure 7 clearly shows that the data are consistent with evolution under these conditions. Hence, it is appropriate to use our likelihood-ratio test to determine whether any  of the recoding schemes would retain the Markovian properties of the original data. Figure 8 presents the PPplots from the likelihood-ratio test for lumpability for RY-recoding, showing strong evidence against lumpability, and for the SW-recoding, which provided the least evidence against lumpability. It is evident that no recoding should be applied to these data.

Conclusions
Bias in estimates of phylogenetic parameters can occur when recoding of nucleotides or amino acids is used to transform data associated with models of evolution, which are not lumpable with respect to the recoding scheme used. A test proposed in this paper, which is based on a likelihood-ratio test, can yield an indication of whether the same results for estimable parameters can be expected from fitting a given model of evolution and its recoded version to the data.