- Research
- Open access
- Published:

# Pattern statistics on Markov chains and sensitivity to parameter estimation

*Algorithms for Molecular Biology*
**volume 1**, Article number: 17 (2006)

## Abstract

### 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 \mathcal{A}. (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*) ∈ \mathcal{A}^{m}× \mathcal{A} (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

S=\{\begin{array}{rr}\hfill -{\mathrm{log}}_{10}\mathbb{P}(N\ge {N}_{\text{obs}})& \hfill \text{if}{N}_{\text{obs}}\ge \mathbb{E}[N]\\ \hfill {\mathrm{log}}_{10}\mathbb{P}(N\le {N}_{\text{obs}})& \hfill \text{if}{N}_{\text{obs}}\mathbb{E}[N]\end{array}\left(2\right)

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.

When *π* is known (and hence *μ*), several statistical methods are available to compute *S*: exact computations [1–4], Gaussian [5, 6], binomial [7, 8], compound Poisson [9–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} ... *Y*_{
n
}, then the Maximum-Likelihood Estimator (MLE) of *π* is given by

\begin{array}{cc}\widehat{\pi}(w,a)=\frac{{N}_{1}(wa)}{{\displaystyle {\sum}_{b\in \mathcal{A}}{N}_{1}(wb)}}& \forall (w,a)\in {\mathcal{A}}^{m}\times \mathcal{A}\end{array}(3)

and the MLE of *μ* (as a function of *π*) is therefore defined by \widehat{\mu} × \widehat{\Pi} = \widehat{\mu} where \widehat{\Pi} is the transition matrix associated to \widehat{\pi}

We introduce now the following estimators

\begin{array}{cccc}{\mu}_{N}(w)=\frac{{N}_{0}(w)}{n-m+1}& and& {\pi}_{N}(w,a)=\frac{{N}_{1}(wa)}{{N}_{0}(w)}& \forall (w,a)\in {\mathcal{A}}^{m}\times \end{array}\mathcal{A}(4)

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.

## Materials and methods

### 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
}∈ {\mathbb{R}}^{{d}_{i}}, and **C**_{
i,j
}∈ {\mathbb{R}}^{{d}_{i}} × {\mathbb{R}}^{{d}_{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* ∈ \mathcal{A}^{m}by

**E**_{0}(*w*) = (*n* - *m* + 1) *μ*(*w*) **E**_{1} (*wa*) = (*n* - *m*) *μ*(*w*)Π(*w*, *a*) ∀(*w*, *a*) ∈ \mathcal{A}^{m}× \mathcal{A} (6)

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

\begin{array}{ccc}{\mu}_{E}=\mu & \text{and}& {\pi}_{E}=\left(1-\frac{1}{n-m+1}\right)\pi \left(7\right)\end{array}

### 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

\begin{array}{lll}{S}_{N}=-{\mathrm{log}}_{10}{F}^{+}(N)\hfill & \text{with}\hfill & {F}^{+}(N)\triangleq {\mathbb{P}}_{{\mu}_{N},{\pi}_{N}}(N\ge {N}_{\text{obs}})\hfill \end{array}\left(8\right)

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:

and hence, using (7) we have

for *n* large enough. The distribution of \widehat{S} is therefore approximated by

(*S*_{
N
}) ≃ \mathcal{N} (*S*, *σ*^{2}) (11)

with

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–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) *W* = *w*_{1} ... *w*_{
h
}(*w*_{
i
}∈ \mathcal{A}) with *h* ≥ *m* - 1 we first denote by

*P*(**N**) = *μ*_{
N
}(*w*_{1} ... *w*_{
m
}) × *π*_{
N
}(*w*_{1} ... *w*_{
m
}, *w*_{m+1}) × ... × *π*_{
N
}(*w*_{h-m}... *w*_{h-1}, *w*_{
h
}) (13)

the probability for *W* to occur at a given position in the sequence and then we get

{F}^{+}(N)\simeq \mathbb{P}(\mathcal{B}({\ell}_{h},P(N))\ge {N}_{obs})=\frac{\beta (P(N),{N}_{\text{obs}},{\ell}_{h}-{N}_{obs}+1)}{\beta ({N}_{obs},{\ell}_{h}-{N}_{obs}+1)}(14)

where \mathcal{B} 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 auto-correlation polynome of the pattern [14]. This point is not developed in this paper.

Replacing *μ*_{
N
}and *π*_{
N
}by their expression easily gives

P(N)=\frac{1}{n-m+1}{\displaystyle \prod _{w\in {\mathcal{A}}^{m}}\frac{{\displaystyle {\prod}_{a\in \mathcal{A}}{N}_{1}{(wa)}^{{A}_{1}(wa)}}}{{N}_{0}{(w)}^{{A}_{0}(w)}}}(15)

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

\nabla {F}^{+}(N)\simeq \frac{P{(N)}^{{N}_{\text{obs}}-1}{(1-P(N))}^{{\ell}_{h}-{N}_{\text{obs}}}}{\beta ({N}_{\text{obs}},{\ell}_{h}-{N}_{\text{obs}}+1)}\times \nabla P(N)\left(16\right)

so all we need is to compute ∇*P*(**N**).

For all (*w*, *a*) ∈ \mathcal{A}^{m}× \mathcal{A} we have

\frac{\partial P(N)}{\partial {N}_{0}(w)}=-\frac{{A}_{0}(w)}{{N}_{0}(w)}\times P(N)\left(17\right)

and

\frac{\partial P(N)}{\partial {N}_{1}(w)}=-\frac{{A}_{1}(wa)}{{N}_{1}(wa)}\times P(N)\left(18\right)

If we denote by

*P* = *μ* (*w*_{1} ... *w*_{
m
}) × *π* (*w*_{1} ... *w*_{
m
}, *w*_{m+1}) × ... × *π* (*w*_{h-m}... *w*_{h-1}, *w*_{
h
}) (19)

the *true* probability for *W* to occur at a given position in the sequence *X* then we get, using (7) in (13), that

P(E)=p\times {\left(1-\frac{1}{n-m+1}\right)}^{h-m}\simeq p\left(20\right)

for *n* large enough. We hence get

\nabla {F}^{+}(E)\simeq \frac{{p}^{{N}_{\text{obs}}}{(1-p)}^{{\ell}_{h}-{N}_{\text{obs}}}}{\beta ({N}_{\text{obs}},{\ell}_{h}-{N}_{\text{obs}}+1)}\times G\left(21\right)

where ^{t}**G** = [^{t}**G**_{0} ^{t}**G**_{1}] is defined by

\begin{array}{lll}{G}_{0}(w)=-\frac{{A}_{0}(w)}{{E}_{0}(w)}\hfill & \text{and}\hfill & {G}_{1}(wa)=-\frac{{A}_{1}(wa)}{{E}_{1}(wa)}\hfill \end{array}\left(22\right)

Using equation 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

### 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 {Q}_{V}^{\epsilon} (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}= {Y}_{1}^{j} ... {Y}_{n}^{j} using an order *m* stationary Markov model of parameters *π*. Complexity of this step is *O*(*M* × *n*).

For each *j* we get the frequencies **N**^{j}= ({N}_{0}^{j},{N}_{1}^{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}= {S}_{{N}^{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*.

## Results and discussion

### Validation

#### Simple case

Let us start with a simple case: a binary alphabet \mathcal{A} = {a, b} (*k* = 2) with an order *m* = 1 Markov model

\pi =\left(\begin{array}{cc}0.3& 0.7\\ 0.6& 0.4\end{array}\right)\left(33\right)

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

*p* = *μ*(a) Π (a,b)^{2} Π (b,a)^{2} = 8.142 × 10^{-2} (34)

so \mathbb{E}[*N*(ababa)] = (ℓ - 4)*p* = 813.8 ≃ 0.66 × *N*_{obs} and hence the pattern is over-represented. Its statistic (using binomial approximation) is

S\simeq -{\mathrm{log}}_{10}\mathbb{P}(\mathcal{B}(\ell -5+1,p)\ge {N}_{obs})=43.74285(35)

We have

{Q}^{+}=\frac{{p}^{{N}_{\text{obs}}-1}{(1-p)}^{\ell -4-{N}_{\text{obs}}}}{\mathrm{ln}(10)\beta (p,{N}_{\text{obs}},\ell -3-{N}_{\text{obs}})}=193.3258\left(36\right)

and

and

Finally, we get

As our pattern statistics is the decimal logarithm of the p-value, *σ* = 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 \widehat{\sigma} for several values of *N*_{obs}. We can see that our theoretical values of *σ* fits very well to the empirical ones.

The equation 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 and we get that

\begin{array}{ccc}E(n)=O(n)& \text{and}& G(n)=O\left(\frac{1}{n}\right)\end{array}\left(40\right)

Using equations and in appendix A we also get that **C** = **M** + **O** + ^{t}**EE** with

**M**(*n*) = *O*(*n*^{2}) and **O**(*n*) = *O*(*n*) (41)

so finally

\sigma (n)\simeq \tilde{\sigma}(n)={Q}^{+}\times \sqrt{A+\frac{B}{n}}\left(42\right)

for large *n*, with

and

We can see on fig. 3 that \tilde{\sigma} 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 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 situation 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.

**Algorithm 1** simulations for one experiment in the practical case

1: estimate the order *m* parameter *π* (and *μ*) from the original sequence. Although these parameters are estimated, they are considered as the true parameters;

2: compute *S* = -log_{10} ℙ(*N* ≥ *N*_{obs});

3: compute *σ* using approximation (23)

4: **for** *j* = 1 ... 1 000 **do**

5: draw a random sequence *Y* = *Y*_{1} ... *Y*_{
n
}according to and order *m* stationary Markov model of parameter *π*;

6: compute **N** the frequency vector of all size *m* and size *m* + 1 words in *Y*;

7: compute *S*^{j}= *S*_{
N
}= -log_{10} ℙ(*N* ≥ *N*_{obs});

8: **end for**

9: compute \widehat{S} (resp. \widehat{\sigma}) the mean (resp. standard deviation) of the sample *S*^{1},..., *S*^{j}.

We can see on table 1 the results for *E. coli*. For each Markov model considered, our approximation of *σ* is very close to the empiric ones and, as with figure 1, the Gaussian distribution fit well to the empiric one (data not shown). Table 2 shows the same behaviour with *M. genitalium* except for *m* = 5 where \widehat{\sigma} 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 :

P(N)=\frac{{N}_{1}(\text{agctac})\times {N}_{1}(\text{gctacg})\times {N}_{1}(\text{ctacgt})}{(\ell -m+1)\times {N}_{0}(\text{gctac})\times {N}_{0}(\text{ctacg})}

and as ℙ(**N**_{1} (agctac) = 0) ≃ 2.26 × 10^{-6}, ℙ(**N**_{1} (gctacg) = 0) ≃ 1.35 × 10^{-1} and ℙ(**N**_{1} (ctacgt) = 0) ≃ 1.24 × 10^{-4} we will have *P*(**N**) = 0 roughly 14% of the time. This happened 123 times in our sample of size 1 000, each time preventing to compute *S*_{
N
}. The sample is hence biased and \widehat{S} and \widehat{\sigma} are therefore not accurate.

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 statistical 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.

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).

For each estimates \widehat{\mu} and \widehat{\pi}, we can compute \stackrel{\_}{\text{REF}} the 100 most over-represented octamers in the genome using the statistic \widehat{S} and compare it to the truth. In order to do so, we first compute the true positive rate (TP rate) defined by the rate of common words in \stackrel{\_}{\text{REF}} and REF, and the rank accordance rate (RA rate) defined by the Kendall's tau [[15], Chapter 13] between *S* and \widehat{S} ranks of {\stackrel{\_}{\text{REF}} ∪ REF}. Such statistic is in the range [-1,1] and has the value 1 for the complete rank accordance and the value -1 for the complete rank discordance.

As in the section "practical case", we consider two genomes: *Escherichia coli* K12 (ℓ = *n* = 4639675) and *Mycoplasma genitalium* (ℓ = *n* = 580076). For each Markov model order *m* from 1 to 6, we estimate *π* on the sequence (by maximum of likelihood), compute the REF list and then draw a sample of \stackrel{\_}{\text{REF}} from which we get estimates for the expectation of TP and RA rates.

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 \widehat{S} 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 \widehat{S}.

It is clear that our approximation of *σ* using the delta-method relies one two major assumptions: 1) the distribution of **N** is Gaussian; 2) *F*^{+} is regular enough (*e.g*. not 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.

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.

## 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.

For any word *w* (of size *h*_{
w
}), we introduce the following notation for *h*_{
w
}≤ *i* ≤ *n*

{I}_{i}(w)={\mathbb{I}}_{\left\{wendinpositioni\right\}}={\mathbb{I}}_{\{{Y}_{i-{h}_{w}+1}^{i}=w\}}(45)

where {Y}_{i}^{j} = *Y*_{
i
}... *Y*_{
j
}for all *i* ≤ *j*. If *h*_{
w
}≥ *m*, we denote by

p(w)=\mu ({w}_{1}^{m})\Pi ({w}_{1}^{m},{w}_{m+1})\mathrm{...}\Pi ({w}_{{h}_{w}-m}^{h-1},{w}_{h})(46)

the probability to see one occurrence of *w* at a given position in the sequence. At last, if we consider another word *v* (of size *h*_{
v
}= *m*) and if *h*_{
w
}= *m*, we denote by

{\Pi}_{\delta}(v,w)={\displaystyle \sum _{x\in {\mathcal{A}}^{\delta}}p(vxw)}(47)

the probability to see occurrences of *v* and *w* separated by a gap of length δ.

For any words *v* an *w* (to simplify, we suppose that *h*_{
v
}≥ *h*_{
w
}) then, for all δ ∈ \mathbb{Z} and

max(*h*_{
v
}, *h*_{
w
}- δ) ≤ *i* ≤ min(*n*, *n* - δ) we have

[*I*_{
i
}(*v*) *I*_{i+δ}(*w*)] = *D*_{δ} (*v*, *w*) (48)

which do not depend on *i*.

It is therefore easy to show that

\begin{array}{cc}\mathbb{E}[N(v)N(w)]={\displaystyle \sum _{i={h}_{v}}^{n}{\displaystyle \sum _{\delta ={h}_{w}-i}^{n-i}{D}_{\delta}(v,w)}}& \left(49\right)\\ ={\displaystyle \sum _{\delta ={h}_{w}-n}^{n-{h}_{v}}{N}_{\delta}{D}_{\delta}(v,w)}& \left(50\right)\\ =M(v,w)+O(v,m)& \left(51\right)\end{array}

where the main part (2*n* - *h*_{
v
}- *h*_{
w
}+ 2 terms) is given by

M(v,w)={\displaystyle \sum _{\delta ={h}_{v}}^{n-{h}_{w}}{N}_{-\delta}{D}_{-\delta}}(v,w)+{\displaystyle \sum _{\delta ={h}_{w}}^{n-{h}_{v}}{N}_{\delta}{D}_{\delta}}(v,w)(52)

and the overlapping part (*h*_{
v
}+ *h*_{
w
}- 1 terms) by

and with

{N}_{\delta}=\{\begin{array}{ll}n-{h}_{w}+1+\delta \hfill & \delta \in [{h}_{w}-n,{h}_{w}-{h}_{v}[\hfill \\ n-{h}_{v}+1\hfill & \delta \in [{h}_{w}-{h}_{v},0]\hfill \\ n-{h}_{v}+1-\delta \hfill & \delta \in ]0,n-{h}_{v}]\hfill \end{array}(54)

As we have

**C**(*v*, *w*) = **M** (*v*, *w*) + **O** (*v*, *w*) - **E** (*v*) **E** (*w*) (55)

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

\begin{array}{c}M(v,w)={\displaystyle \sum _{\delta =m}^{n-m}{N}_{-\delta}\mu (w){\Pi}_{\delta -m+1}(w,v)}\\ +{\displaystyle \sum _{\delta =m}^{n-m}{N}_{\delta}\mu (v){\Pi}_{\delta -m+1}(v,w)}\end{array}(56)

(2*n* - 2*m* + 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

\begin{array}{l}M(v,w)\simeq \mu (v)\mu (w){\displaystyle \sum _{\delta =r}^{n-m}({N}_{-\delta}+{N}_{\delta})}\\ +{\displaystyle \sum _{\delta =m}^{r-1}{N}_{-\delta}\mu (w){\Pi}_{\delta -m+1}}(w,v)\\ +{\displaystyle \sum _{\delta =m}^{r-1}{N}_{\delta}\mu (v){\Pi}_{\delta -m+1}}(v,w)(57)\end{array}

which has only 2*r* - 2*m* + 1 terms.

And for the overlapping part we get

\begin{array}{l}O(v,w)={N}_{0}\times \mu (v)\times {\mathbb{I}}_{\{v=w\}}\\ +{\displaystyle \sum _{\delta =1}^{m-1}{N}_{-\delta}}\times p(w{v}_{m-\delta +1}^{m})\times {\mathbb{I}}_{\left\{{v}_{1}^{m-\delta}={w}_{1+\delta}^{m}\right\}}\\ +{\displaystyle \sum _{\delta =1}^{m-1}{N}_{\delta}\times p(v{w}_{m-\delta +1}^{m})}\times {\mathbb{I}}_{\left\{{v}_{1+\delta}^{m}={w}_{1}^{m-\delta}\right\}}(58)\end{array}

which has 2*m* + 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.

In the particular case of an order one Markov model (*m* = 1), we give here the complete expressions of **M** and **O**.

For all *a*, *b*, *c*, *d* ∈ \mathcal{A}, we have

\begin{array}{l}M(a,b)\simeq (n-r+1)(n-r)\mu (a)\mu (b)\\ +{\displaystyle \sum _{\delta =1}^{r-1}(n-\delta )\left(\mu (b){\Pi}^{\delta}(b,a)+\mu (a){\Pi}^{\delta}(a,b)\right)(59)}\end{array}

**O** (*a*, *b*) = *nμ*(*a*) \mathbb{I}_{{a = b}} (60)

\begin{array}{l}\frac{M(ab,c)}{\Pi (a,b)}\simeq (n-r)(n-r-1)\mu (a)\mu (c)\\ +{\displaystyle \sum _{\delta =1}^{r-1}(n-\delta -1)\left(\mu (c){\Pi}^{\delta}(c,a)+\mu (a){\Pi}^{\delta}(b,c)\right)(61)}\end{array}

\frac{O(ab,c)}{\Pi (a,b)}=(n-1)\mu (a)({\mathbb{I}}_{\{a=c\}}+{\mathbb{I}}_{\{b=c\}})(62)

\begin{array}{l}\frac{M(ab,cd)}{\Pi (a,b)\Pi (c,d)}\simeq (n-r-1)(n-r-2)\mu (a)\mu (c)\\ +{\displaystyle \sum _{\delta =1}^{r-1}(n-\delta -2)\left(\mu (c){\Pi}^{\delta}(d,a)+\mu (a){\Pi}^{\delta}(b,c)\right)(63)}\end{array}

\begin{array}{l}\frac{O(ab,cd)}{\Pi (a,b)}=(n-1)\mu (a){\mathbb{I}}_{\{ab=cd\}}\\ +(n-2)\Pi (c,d)\left(\mu (c){\mathbb{I}}_{\{a=d\}}+\mu (a){\mathbb{I}}_{\{b=c\}}\right)(64)\end{array}

With the example given in section "validation" we get for the expectation

= [4615.4 5384.6] (65)

and

= [1384.5 3230.4 3230.4 2153.6] (66)

The magnitude of the second eigenvalue of Π is *λ* = 0.3, then rank *r* = 19 give a relative error < 10 ^{-10} and we get for the covariance

and

{C}_{1,1}=\left[\begin{array}{cccc}1536.8& -390.0& -390.0& -756.9\\ -390.0& 581.2& 581.0& -772.2\\ -390.0& 581.0& 581.2& -772.2\\ -756.9& -772.2& -772.2& 2301.4\end{array}\right](69)

## Appendix B

The beta function is defined by

for all *a*, *b* > 0. The incomplete beta function for all *x* ∈ [0,1] is then defined by

\beta (x,a,b)={\displaystyle {\int}_{0}^{x}{t}^{a-1}}{(1-t)}^{b-1}dt(71)

and

\begin{array}{cc}{\beta}^{-}(x,a,b)=\beta (a,b)-\beta (x,a,b)& \left(72\right)\\ ={\displaystyle {\int}_{x}^{1}{t}^{a-1}}{(1-t)}^{b-1}dt& \left(73\right)\end{array}

Using a continued fraction representation, these functions can be quickly numerically evaluated in *O*(\sqrt{\mathrm{max}(a,b)}) in the worst case [15, Chapter 6].

A great interest of this function is that it is connected to the cumulative distribution function of a binomial distribution by the following relation:

\mathbb{P}(\mathcal{B}(n,p)\ge k)=\frac{\beta (p,k,n-k+1)}{\beta (k,n-k+1)}(74)

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

\frac{\partial \beta (x,a,b)}{\partial x}={x}^{a-1}{(1-x)}^{b-1}(75)

## Appendix C

We give here the complete expression of *σ* for a single pattern in the special case of an order *m* = 0 homogeneous Markov model of parameter *μ*.

The MLE of *μ* is given by

{\mu}_{N}=\frac{{N}_{1}}{n}(76)

where **N**_{1} is the frequency of all letters.

A Gaussian approximation gives

(**N**_{1}) ≃ \mathcal{N} (**E**_{1}, **C**_{1,1}) (77)

with **E**_{1} = *nμ* and, for all *a*, *b* ∈ \mathcal{A},

**C**_{1,1} (*a, b*) = *nμ* (*a*) \mathbb{I}_{a = b}- *nμ*(*a*) × *nμ*(*b*) (78)

We have also

P(N)=\frac{1}{{n}^{h}}{\displaystyle \prod _{a\in \mathcal{A}}{N}_{1}{(a)}^{{A}_{1}(a)}}(79)

which implies for all *a* ∈ \mathcal{A} that

So finally we get

where *Q* is either defined by equation if the pattern is over-represented or by equation if under-represented.

## References

Atteson W: Calculating the exact probability of language-like patterns in biomolecular sequences. Pro 6th Int Conf on Intelligent Systems for Molecular Biology. 1998, 17-24.

Régnier M, Szpankowski W: On pattern frequency occurrences in a Markovian sequence. Algorithmica. 1998, 22 (4): 631-649. 10.1007/PL00009244.

Robin S, Daudin JJ: Exact distribution of word occurrences in a random sequence of letters. J App Prob. 1999, 36: 179-193. 10.1239/jap/1032374240.

Nuel G: Effective p-value computations using Finite Markov Chain Imbedding (FMCI): application to local score and to pattern statistics. Algorithms Mol Biol. 2006, 1 (1): 5-

Kleffe J, Borodovski M: First and second moment of counts of words in random text generated by Markov chains. Comp Applic Biosci. 1992, 8: 443-441.

Prum B, Rodolphe F, de Turckheim E: Finding words with unexpected frequencies in DNA sequences. J R Statist Soc B. 1995, 11: 190-192.

van Helden J, André B, Collado-Vides J: Extracting Regulatory Sites from the Upstream Region of Yeast Genes by Computational Analysis of Oligonucleotide Frequencies. J Mol Biol. 1998, 281: 827-842.

Nuel G: S-SPatt: Simple Statististics for Patterns on Markov chains. Bioinformatics. 2005, 21 (13): 3051-3052.

Chrysaphinou O, Papastavridis S: A limit theorem on the number of overlapping appearances of a pattern in a sequence of independent trials. Proba Theory Relat Fields. 1988, 79 (1): 129-143. 10.1007/BF00319109.

Arratia R, Goldstein L, Gordon L: Poisson approximation and the Chen-Stein method. Stat Sci. 1990, 5 (4): 403-434.

Schbath S: Compound Poisson approximation of word counts in DNA sequences. ESAIM Probab Stat. 1995, 1: 1-16. 10.1051/ps:1997100.

Nuel G: LD-SPatt: Large Deviations Statistics for Patterns on Markov Chains. J Comput Biol. 2004, 11 (6): 1023-1033.

Oehlert GW: A note on the delta method. American Statistician. 1992, 46: 27-29. 10.2307/2684406.

Reinert G, Schbath S, Waterman M: Chapter 6: Statistics on words with applications to biological sequences. Applied Combinatorics on Words. 2005, Cambridge Universtity Press

Press WH, Teukolsky SA, Vetterling WT, Flannery BP: Numerical Recipes in C. 1988, Cambridge Universtity Press, 2

## Author information

### Authors and Affiliations

### Corresponding author

## Additional information

### Competing interests

The author declares that he has no competing interests.

## Authors’ original submitted files for images

Below are the links to the authors’ original submitted files for images.

## Rights and permissions

This article is published under license to BioMed Central Ltd. This is an Open Access article distributed under the terms of the Creative Commons Attribution License (http://creativecommons.org/licenses/by/2.0), which permits unrestricted use, distribution, and reproduction in any medium, provided the original work is properly cited.

## About this article

### Cite this article

Nuel, G. Pattern statistics on Markov chains and sensitivity to parameter estimation.
*Algorithms Mol Biol* **1**, 17 (2006). https://doi.org/10.1186/1748-7188-1-17

Received:

Accepted:

Published:

DOI: https://doi.org/10.1186/1748-7188-1-17