Pattern statistics on Markov chains and sensitivity to parameter estimation

Background: In order to compute pattern statistics in computational biology a Markov model is commonly used to take into account the sequence composition. Usually its parameter must be estimated. The aim of this paper is to determine how sensitive these statistics are to parameter estimation, and what are the consequences of this variability on pattern studies (finding the most over-represented words in a genome, the most significant common words to a set of sequences,...). Results: In the particular case where pattern statistics (overlap counting only) computed through binomial approximations we use the delta-method to give an explicit expression of σ, the standard deviation of a pattern statistic. This result is validated using simulations and a simple pattern study is also considered. Conclusion: We establish that the use of high order Markov model could easily lead to major mistakes due to the high sensitivity of pattern statistics to parameter estimation.


Background
In order to study pattern occurrences in biological sequences, simple frequencies are not relevant in most cases because of pattern overlapping structure as well as composition bias in the sequences. A common workaround consists to compute the significance of an observation assuming the sequence X = X 1 ... Xᐍ over the finite alphabet . (size k) is generated according to an order m ≥ 1 homogeneous, stationary and ergodic Markov model. Let π (size k m+1 ) defined by π(w, a) = (X m+1 = a|X 1 ...X m = w) ∀(w, a) ∈ m × (1) be the parameter of this Markov model, Π its transition matrix (note that we have Π = π only if m = 1) and μ its stationary distribution (defined by μ × Π = μ).
We then introduce the pattern statistic defined by where N is the random number of overlapping occurrences (i. e. X = aababaaba contains three overlapping occurrences of aba but only two non-overlapping ones) of a given fixed pattern on the random sequence X and N obs is an observation. 10 10 P E P E obs obs obs obs if if ⎨ ⎨ ⎩ ( ) 2 When π is known (and hence μ), several statistical methods are available to compute S: exact computations [1][2][3][4], Gaussian [5,6], binomial [7,8], compound Poisson [9][10][11] or large deviations approximations [12]. But in general, the parameter π is not available and must be estimated. Let us denote by N 0 (resp. N 1 ) the (overlap) frequencies of all words of size m (resp. m + 1) in the sequence Y = Y 1 ... We introduce now the following estimators which are known to be asymptotically equivalent with the MLE when n is large.
The quality of parameter estimation depends both on the number of parameters to estimate (k m+1 for an order m Markov model) and of the length (n) of the homogeneous sequence used for their estimation. When the same sequence (or set of sequences) is used both for observed frequencies and parameter estimation, m should not be greater than h -2 for a pattern of length h (as else, the observed frequency of the pattern will be included in the model). As literature often suggests to use the highest possible order, it is hence common to consider m = 6 or more (for a DNA pattern of size h ≥ 8). Moreover, because of the homogeneity assumption of the model, the considered genomes have often to be segmented first. As a result, the sequences length used for parameter estimations are often dramatically reduced by such segmentation (e. g. n = 10 5 to n = 10 6 at the very best for DNA sequences). It is hence quite common to encounter high order Markov models estimated on rather short sequences which could result in high sensitivity to parameter estimation.
Considering that Y is generated through a Markov model of parameter π, the main goal of this paper is to study the distribution of S N , the statistic S computed using the estimators μ N and π N , and the consequences of its variability in projects using pattern statistics. We first present in details how the delta-method can be used to get a Gaussian approximation for the distribution of S N (using a binomial approximation to compute the pattern statistics). Then these approximations are validated through simulations and, at last, we consider a classical pattern study (finding the most over-represented patterns of a given size) and we evaluate the detrimental effect of parameter estimations both in terms of true positive rate and rank accordance.

Distribution of N = (N 0 , N 1 )
As the estimators defined in (4) are expressed as functions of N 0 and N 1 we first study their distribution. Using a Gaussian approximation, we have where, for i, j ∈ {0, 1}, E i ∈ , and C i,j ∈ × with d i = k m+i . One can note that C 0,0 and C 1,1 are symmetric, and t (C 1,0 ) = C 0,1 (where t is the matrix transpose operator).
In the stationary case, exact expression of E and C can be computed according to [5].
Expectation is simply given ∀w ∈ m by In order to give more fluidity to this paper, the expression of the covariance matrix C have been moved in appendix A. Let us remark, before going forward that substituting N by E in (4) immediately gives

Delta method
Let us start with a simple case. We consider a single pattern which is over-represented (seen more than expected) so we have where the function F + also depends on the sequence length ᐍ and the considered pattern.
If F + is differentiate, the delta-method (a simple first order Taylor expansion around N = E, see [13]) provides the following approximation: 10 8 with obs P μ π and hence, using (7) we have for n large enough. The distribution of is therefore approximated by In consequence, computing σ requires both to compute C (done in appendix A) and ∇F + (E).

Single pattern
The exact expression of F + is computable through many different methods [1][2][3][4] but is too much complicated to derive explicitly ∇F + . To overcome this problem, we propose to consider an approximation of F + . As said in introduction, many kind of approximations are available (Gaussian, binomial, compound Poisson or large deviations). In this paper, we have chosen to use a binomial approximation as it provides an expression which is analytically differentiable and is known to be a good heuristic to the problem [8].
For a single non-degenerate pattern (i.e. a simple word) the probability for W to occur at a given position in the sequence and then we get where denotes the binomial distribution, with ᐍ h = ᐍh + 1 and where the β functions (complete and incomplete) and their relation to the binomial cumulative distribution function are described in appendix B.
Note that if we consider non-overlapping occurrences instead of overlapping ones, we can still use a binomial approximation for the distribution of N, but the expression of P(N) is more complicated as it involves the autocorrelation polynome of the pattern [14]. This point is not developed in this paper.
Replacing μ N and π N by their expression easily gives where A 1 (wa) counts occurrences of the word wa in W = w 1 ... w h and A 0 (w) counts occurrences of the word w in w 2 ... w h-1 . Note that in the particular case where h = m -1, all A 0 (w) are null and we simply get (n -m + l) × P (N) = N 1 (W).
Using the derivative properties of the incomplete beta function (see appendix B for more details) we hence get so all we need is to compute ∇P(N).
For all (w, a) ∈ m × we have and If we denote by the true probability for W to occur at a given position in the sequence X then we get, using (7) in (13), that for n large enough. We hence get Using equation (12) we finally get where and then, a computation of σ is possible by plug-in. Without considering the computation of E and C, the complexity of this approach is O(h) (where h is the size of the pattern).
When a degenerate pattern (finite set of words) is considered instead of a single word, it is easy to adapt this method by summing the contribution p of each word belonging to the pattern. This point is left to the reader.

Under-represented pattern
In the case of an under-represented pattern we have Using a binomial approximation we get and, by the same method than in the over-represented case we finally have where

Two distinct patterns
We consider now two patterns V and W instead of one and want to study the joint distribution of S N (V) and S N (W) their corresponding pattern statistics.
With a similar argument as in section "delta method", it is easy to show that where σ V (resp. σ W ) is the standard deviation σ for the pattern V (resp. W) and where where And after using results of sections "single pattern" and "under-represented pattern" we finally get where (resp. W) and G V (resp. W) are the constant Q (Q + and Q -) and the vector G for the pattern V (resp. W).

Simulations
It is also possible to study the empirical distribution of a S N (for one or more patterns) through simulations.
In order to do so, we first draw M independent sequences Y j = ... using an order m stationary Markov model For each j we get the frequencies N j = ( , ) (with complexity O(n) for each sequence) of the words of size m and m + 1 in the sequence Y j and use it to compute S j = (exact value or approximation). Complexity here depends on the statistical method used to compute S j (e.g. O(h) using a binomial approximation).
We now have a M -sample S 1 , ..., S M of S N from which we can easily estimate σ and thus, valid or invalid the approximation through the delta-method.
When used with large value of n (e.g. several millions or more), the complexity of this approach is slowed by the drawn of the sequences Y j . It is therefore possible to improve the method by simulating directly the frequencies N through (5). As this approximation has a very small impact on the distribution of S N (data not shown) it may dramatically speed-up the computations when considering large n or M. It is nevertheless important to point out that drawing a Gaussian vector size L requires to precompute the Choleski decomposition of its covariance matrix which could be a limiting factor when considering large L.

Validation
Simple case Let us start with a simple case: a binary alphabet = {a, b} (k = 2) with an order m = 1 Markov model which stationary distribution is μ = (6/13,7/13) and we work on a sequence of length n = 10 000.
The first thing to do is to compute E and C (see appendix A for details). Now, we consider the pattern W = ababa occurring N obs = 1221 times in a sequence of length ᐍ = n = 10 000. We have hence the pattern is over-represented. Its statistic (using binomial approximation) is We have and and Finally, we get As our pattern statistics is the decimal logarithm of the pvalue, σ = 6 means that the ratio of the estimated p-value over the true one could easily range from 10 -12 (10 -2 × σ ) to 10 12 (10 2 × σ ) which is huge.
We can see on fig. 1 the empirical distribution of S N compared to the theoretical distribution. Even if the two distributions are closely related, an adjustment test (Kolmogorov-Smirnov) shows that they are different.
In the fig. 2 we compare σ to its estimator for several values of N obs . We can see that our theoretical values of σ fits very well to the empirical ones.
The equation (39) gives an explicit expression of σ as a product of two terms. Once the pattern and the true parameter π are fixed, the first term (Q) depends only on ᐍ and N obs while the second one only depends on the length n of the sequence used for the parameter estimation (see appendix C for an explicit expression of σ in the particular case of an order 0 Markov model).
To study the variations of σ(n) as a function of n we therefore need to study G(n) and C(n). Using equations (6) and (22) we get that Using equations (57) and (58) in appendix A we also get that so finally for large n, with and We can see on fig. 3 that is not a very good approximation of σ for small n, but, as the approximation is far easier to compute (and trivial to invert) than the true value, this can be useful when we need to compute a minimum length n to obtain a given σ.
We also see on the same figure that σ grows rapidly when n decreases. For example, we get σ Ӎ 20 for n = 5000 (while equation (35) gives S Ӎ 264.4).
As we consider here a binary alphabet (k = 2) and a first order Markov model (m = 1) we have only k m (k -1) = 2 parameters to estimate with a sample of size n = 5000 (so we have 2500 sample per parameter). Although this situ-  σ ation seems quite comfortable, the sensitivity to parameter estimation appears in fact to be so large that we could have a factor 10 40 between the true p-value and its estimate.

Practical case
We have seen with our first example that our approximation works very well in a simple case. Will this hold with more practical cases?
To answer this question, let us consider the following experimental design: • one pattern: W = acgtacgt; • two genomes: Escherichia coli K12 (ᐍ = n = 4639675) and Mycoplasma genitalium (ᐍ = n = 580076); • five Markov orders: m = 1 to m = 5 (larger m are not considered since the computation of C becomes then intractable).
As the sequence lengths and compositions of the two considered genomes differ a lot, we have to take a different value of N obs for each organism: N obs = 30 for M. genitalium and N obs = 150 for E. coli. Proceeding as indicated in section "simulations", we use the algorithm 1 for each experiment.  Table 2 shows the same behaviour with M. genitalium except for m = 5 where differs slightly more than in the other cases from its theoretical value. To understand this phenomenon, let us first recall the expression of P(N) for m = 5 using equation (15) What happen now if we use another statistical method to compute the pattern statistics. As the binomial approximation is supposed to be close to the exact solution, we expect the standard deviation obtained with other statisti-  Comparison of σ and .
is estimated with a sample of size 1 000 and N obs takes its values from 900 to 1 900. The solid line represents the theoretical values and the circles the empirical ones. The statistic S is used on the x-axis. n = ᐍ = 10 000. σσσ cal methods to remain close to σ. In table 3, we compare the empirical results using binomial approximations (like above) but also compound Poisson or large deviations approximations. Both empirical means and standard deviations are close to the theoretical ones thus validating the method.

Choice of a Markov model order
Through the computation of σ we can measure the sensitivity of pattern statistics to parameter estimations. A very natural question is then, how this variability could affect a pattern statistic study, and, as this variability grows with the Markov model order, how to choose this parameter. Comparison of σ(n) and (n)

σ σ σ
We propose here to consider the case of a very simple pattern study: we want to find the 100 most over-represented octamers (DNA words of size 8) in a given genome.
Assuming the true parameter π (and hence μ) is known, we can compute REF = {W 1 ,..., W 100 }, the list of these words (ordered by decreasing statistics, so that the most over-represented one is the first one). Results are given in tables 4 and 5. We can see that, surprisingly, the TP rate could be very low even for long genome such as E. coli when high order Markov model (m = 6) are used. Of course, these rates are even worse on M. genitalium whose genome is ten times smaller than the first one. It is also clear that the RA rate is more affected by the variability induced by parameter estimation than the TP rate.
Based on these results, we conclude that our pattern study requires a sample size per free parameter of at least a few thousands if we want reliable results. In our examples this has for consequence that the Markov order should not be greater than 4 (or 5 at the very most) for E. coli and 3 (or 4 at the very most) on M. genitalium without resulting in important errors.

Conclusion
The delta-method allows us to approximate the distribution of by a Gaussian distribution. This first requires to compute the expectation and covariance matrix of frequencies and then to study the derivative of a function which is specific of the method used to compute the pattern statistics. In the case of the binomial approximations, we have found an explicit expression of σ the standard deviation of .
It is clear that our approximation of σ using the deltamethod relies one two major assumptions: 1) the distribution of N is Gaussian; 2) F + is regular enough (e.g. not  We consider the pattern W = acgtacgt with N obs = 30. The sequence length is ᐍ = 580076, we use an order m = 3 Markov model and a sample of size M = 1 000. The pattern statistics are computed (from left to right) through binomial, compound Poisson or large deviations approximations. Sσ too steep) around E. When m grows, E closes to the boundary of the definition range of F + hence degrading assumption 2. Moreover, it is well known that Gaussian approximations for word frequencies become weaker when the expected numbers of their occurrences become smaller, thus degrading assumption 1. It is therefore obvious that our approximation of σ will get less and less reliable as m grows.

SσŜσŜσ
However, the approximation of σ has been validated through simulations and appears to be very reliable (even for m = 5 or 6). As pattern statistics computed through binomial approximations are close to the exact statistics [8], the value of σ should not differ a lot when another statistical method is used. We have compared our approximations to the empiric distribution obtained using compound Poisson and large deviations approximations and, as expected, our approximations remains quite reliable even for these statistical methods.
The variability due to parameter estimation is of course related to the Markov model order m and to the size k of the alphabet (as we have k m+1 parameters for this model) and to the length n of the sequence used for this estimation. For example, considering an order m = 6 model with n = 4639675 (Escherichia coli K12 complete genome) requires to estimate 3 × 4 6 = 4096 free parameters which results roughly in 400 observation per free parameter. Although this situation seems quite comfortable, we have seen with our simulations that it leads an unacceptable variability for pattern statistics.
As literature often advices to use the highest possible Markov order for a given pattern problem (which means m = h -2 for pattern of size h) it is easy to understand that such a practice could have very detrimental effects on the computed statistics unless huge data are available for estimation purpose. Even if we consider the more reasonable attitude to choose m using the classical framework of model selection (e.g. using the Akaike Information Criterion -AIC -) we get m = 5 for Mycoplasma genitalium and m = 6 for Escherichia coli K12 hence resulting in both cases in the same catastrophic results in terms of false positive and even worse ones in terms of ranking.
Moreover, we assumed here that our model was homogeneous all along the considered sequences. This is obviously completely false when complete genomes are considered. So it is more likely that the sample size n would be far smaller than a million on classical pattern studies (even of human genomes for example). As a result, the variability we pointed out in this paper will have a considerable detrimental effect on most studies unless the Markov order is carefully set.
In order to do so, we advice to compute our approximation of σ each time a pattern statistic is produced and then to evaluate, either by simulation (like in this paper) or by a theoretical work the impact of this variability on the considered study.

Competing interests
The author declares that he has no competing interests.

Appendix A
We give here the expression of the covariance matrix C introduced in section "distribution of N = (N 0 , N 1 )". The sequence Y (of length n) is generated by an homogeneous, stationary and ergodic order m Markov model of parameter π and stationary distribution μ. We want to compute the covariance of the vector N of random frequencies of size m and m + 1 words. Both quantities are estimated with 1 000 simulations. We consider the 1 00 most over-represented octamers, the sequence length is ᐍ = 580076. The last row gives the sample size per free parameter (length n of the sequence divided by the number k m (k -1) of parameters). Both quantities are estimated with 1 000 simulations. We consider the 1 00 most over-represented octamers, the sequence length is ᐍ = 4639675. The last row gives the sample size per free parameter (length n of the sequence divided by the number k m (k -1) of parameters).
For any word w (of size h w ), we introduce the following notation for For any words v an w (to simplify, we suppose that h v ≥ h w ) then, for all δ ∈ and which do not depend on i.
It is therefore easy to show that where the main part (2n -h v -h w + 2 terms) is given by and the overlapping part (h v + h w -1 terms) by and with As we have the problem is hence to compute M and O for all pairs of size m or m + 1 words. In order to simplify, we will just treat here the case of a pair of size m words (other cases can be derived from this special case).
For the main part we obtain (2n -2m + 2 terms). As P k (v, w) quickly converges toward μ(w) when k grows (convergence speed is given by λ k where λ is the magnitude of the second eigenvalue of the transition matrix Π). So there exists a rank r ≥ m such as which has only 2r -2m + 1 terms.
And for the overlapping part we get which has 2m + 1 terms.
So the overall complexity for the computation of one term of C is hence O(r) where the value of r is directly connected to the magnitude λ of the second eigenvalue of the transition matrix. A great interest of this function is that it is connected to the cumulative distribution function of a binomial distribution by the following relation: with (n, k) ∈ * × , 0 ≤ k ≤ n and p ∈ [0,1].
Finally, let us remark that the incomplete beta function is differentiable in x and that

Appendix C
We give here the complete expression of σ for a single pat-