Accurate Prediction of the Statistics of Repetitions in Random Sequences: A Case Study in Archaea Genomes

Repetitive patterns in genomic sequences have a great biological significance and also algorithmic implications. Analytic combinatorics allow to derive formula for the expected length of repetitions in a random sequence. Asymptotic results, which generalize previous works on a binary alphabet, are easily computable. Simulations on random sequences show their accuracy. As an application, the sample case of Archaea genomes illustrates how biological sequences may differ from random sequences.


INTRODUCTION
This paper provides combinatorial tools to distinguish biologically significant events from random repetitions in sequences. This is a key issue in several genomic problems as many repetitive structures can be found in genomes. One may cite microsatellites, retrotransposons, DNA transposons, long terminal repeats (LTR), long interspersed nuclear elements (LINE), ribosomal DNA, and short interspersed nuclear elements (SINE). In Treangen and Salzberg (2012), it is claimed that half of the genome consists of different types of repeats. Knowledge about the length of a maximal repeat is a key issue for assembly, notably the design of algorithms that rely upon de Bruijn graphs. In resequencing, it is a common assumption for aligners that any sequenced "read" should map to a single position in a genome: in the ideal case where no sequencing error occurs, this implies that the length of the reads is larger than the length of the maximal repetition. Average lengths of the repeats are given in Gu et al. (2000). Recently, heuristics have been proposed and implemented (Devillers and Schbath, 2012;Rizk et al., 2013;Chikhi and Medvedev, 2014).
A similar problem has been extensively studied: the prediction of the length of maximal common prefixes for words in a random set. Typical parameters are the background probability model, the size V of the alphabet, the length n of the sequence, and so on. Deviation from uniformity was studied for a uniform model as early as 1988 (Flajolet et al., 1988). A complexity index that captures the richness of the language is addressed in Janson et al. (2004). A distribution model, valid for binary alphabets and biased distributions, was introduced in Park et al. (2009), the so-called trie profile and extended to Patricia tries in Magner et al. (2014). The authors pointed out different "regimes" of randomness and a phase transition, by means of analytic combinatorics (Sedgewick and Flajolet, 2009). It was observed in Jacquet and Szpankowski (1994) that the average length of maximal common prefixes in a random set of n words is asymptotically equivalent to the average length of maximal repetitions in a random sequence of length n. Sets of words are considered below in the theoretical analysis. A comparison with the distribution of maximal repetitions in random sequences or real Archaea genomic sequences is presented in Section 3.
Our first goal is to extend results of Park et al. (2009) to the case of a general V-alphabet, including the special case {A, C, G, T} where V is 4. A second goal is to compare the results consistency with random data and real genomic data in the finite range.
To achieve the first goal, we rely on an alternative, and simpler, probabilistic and combinatorial approach that is interesting per se. It avoids generating functions and the Poissonization-dePoissonization cycle that is used in Park et al. (2009) and it extends to non-binary alphabets. In that case, there is no closed formula for the asymptotic behavior. Nevertheless, the Lagrange multipliers allow to derive it as the solution of an equation that can be computed numerically.
Explicit and computable bounds for the profile of a random set of n words are provided. Three domains can be observed. A first domain is defined by a threshold k for the length, called the completion length: any prefix with a length smaller than this threshold occurs at least twice. This threshold is extremely stable over the data sets and it is highly predictable. A similar phenomenon was observed for a uniform model in Fagin et al. (1979a) and a biased model (Mahmoud, 1992;Park et al., 2009). For larger lengths, some prefixes occur only once. In a second domain, called the transition phase, the number of maximal common prefixes is sublinear in the size n of the sequence: increasing first, then decreasing slowly, and, finally, dropping rapidly. In the third domain, for a length larger than some extinction length, almost no common prefix of that length occurs. Despite the fact that these bounds are asymptotic, a good convergence is shown in practice for random texts when a second-order term is known. Differences between the model and the observation are studied on the special case of Archaea genomes. A dependency to the GCcontent, which is a characteristic of each genome, is exhibited. Regimes and transitions are studied on these genomic data and theoretical results are confirmed, with a drift in the values of transition thresholds. Notably, the length of the largest repetitions is much larger than expected. This difference between the model and the observation arises from the occurrences of long repeated regions.
Section 2 is devoted to Main Results, to be proved in Section 4. First, some notations are introduced; then, an algebraic expression for the expectation of the number of maximal common prefixes in a sequence is derived in Theorem 2.1. Second, this expression is split between two sums that are computable in practical ranges. Then, it is shown that a Large Deviation principle applies. It yields first and second order asymptotic terms, and oscillations, that are provided in Theorem 2.2. A comparison between exact, approximate, and asymptotic expressions is presented in Section 3.

MAIN RESULTS
It is assumed throughout this study that sequences and words are randomly generated according to a biased Bernoulli model on an alphabet of size V. Let p 1 , · · · , p V denote the probabilities of the V characters χ 1 , · · · ,χ V .

Enumeration
Definition 2.2. Given U a set of words and an integer k, k ≥ 2, a unique k-mer in U is a word wχ i of length k such that 1. w is a prefix of at least two words in U; 2. and wχ i is a prefix of a single word.
By convention, a unique 1-mer is a character χ i that is a prefix of a single word. Definition 2.3. Let U be a set of n words. For k ≥ 1, one denotes B(n, k) the number of unique k-mers in U.
One denotes µ(n, k − 1) the expectation of B(n, k) over all sets of n words.
Remark: It follows from Definition 2.2 that quantity B(n, k) is upper bounded by n. Observe that, for each random set U, it is the sum of a large number -V k -of correlated random variables. Expectation µ(n, k) is studied below and compared in Section 3 with B(n, k + 1).
Profiles of repetitions can be expressed as a combinatorial sum. Theorem 2.1. Given a length k, the expectation µ(n, k) satisfies: where Proof. A word wχ i is a unique (k + 1)-mer iff (i) w has length k and is the prefix of at least two words, including wχ i ; (ii) wχ i is not repeated.

Event (i) has probability
Event (ii), which is a sub-event of (i), has probability

A Combinatorial Expression
Definition 2.4. Given a k-mer w, let α denote k log n and k i denote the number of occurrences of character χ i in w. The objective function is The character distribution (k 1 , · · · , k V ) of a k-mer may be viewed as barycentric coordinates for a point β( . The order of β points on that interval allows for a classification of k-mers that is a key to this study.
Definition 2.5. A k-mer w is said • a transition k-mer if ρ(k 1 , · · · , k V ) ≥ 0 and its ancestor is a common k-mer; • a rare k-mer, otherwise.
Definition 2.6. Given a set U of n words and an integer k, let D k (n) denote the set of character distributions (k 1 , · · · , k V ) for rare and transition k-mers. Let E k (n) denote the set of character distributions for common k-mers.
The set D k (n) is the empty set if k < α min log n and is the set of character distributions (k 1 , · · · , k V ) if k > α max log n. Computation of (3) is split among the two sets D k (n) and E k (n). Computations show that the main contribution arises from transition k-mers. A probabilistic interpretation will be discussed in 2.4.
Notation: Let S(k) and T(k) be These sums S(k) and T(k) can be efficiently computed for moderate k, up to a few hundred, approximately. In practice, α max log n is below this threshold for the sizes of actual genomes and for their ordinary GC content value. The simulations in Section 3 show that this estimation is rather tight. Behavior and asymptotic estimates are derived and discussed in the next section.

Asymptotic Estimates
In this section, asymptotic estimates for (3) are derived. First, some characteristic functions are introduced. Then, it is observed that a Large Deviation Principle applies for the combinatorial sums to be computed and asymptotics for the dominating term follow. Amortized terms are also computed. It is shown in Section 3 that this second-order term cannot be neglected in the finite range.

Notations
For general alphabets, asymptotic behavior is a function of the solution of an equation and depends on domains whose bounds are defined below.

Asymptotic Results
Theorem 2.2. Given a length α log n, when n tends to ∞ the ratio log µ(n, α log n) log n satisfies: Proof. The key to the proof when α ranges in [α min , α max ] is that (16) The maximization problem rewrites as Frontiers in Bioengineering and Biotechnology | www.frontiersin.org June 2016 | Volume 4 | Article 35 The maximum value is .

S(k) satisfies again a Large Deviation Principle when α <ᾱ, which yields the asymptotic result in this range. For larger α, S(k)
is approximately (1 − σ 2 )n 1−α log 1 σ 2 that dominates T(k). Details for the proof, including the short and long lengths, are provided in Section 4.
Remark: The discussion will depend of the ratio α = k log n . Possible values for α range over a discrete set as they are constrained to be the ratio of an integer by the log of an integer. An interesting property is that, for any real α, the set T = {n ∈ N; α log n ∈ N} is either empty or infinite. Indeed, when T is non-empty, it contains all values n(α) p where n(α) denotes the minimum value of T. It is beyond the scope of this paper to establish the number of other possible solutions.

Domains
Different domains arise from this Theorem, which were observed in Park et al. (2009). Equalities ψ(α min ) = 0 and ψ(ᾱ) = 2 − αlog 1 σ 2 show that there is a continuity between domains. When α lies inside the domain [α min , α ext ], the ratio log µ(n,α log n) log n is positive and parameters µ(n, α log n) are sublinear in the size n of the text: some k-mers -mostly transition k-mers -are unique k-mers. Observe that the maximum value for ψ(α) is 1. When the Bernoulli model is uniform, this central domain is empty.
When the length is smaller than the completion length α min log n or greater than the extinction length α ext log n, the ratio log µ(n, α log n) log n is negative.

Oscillations
Parameters (k 1 , · · · , k V ) in the combinatorial sums are integers. As the optimum values (kθ i ) 1≤i≤V may not be integers, the practical maximum is a close point on the lattice (k 1 , · · · , k V ). The difference introduces a multiplicative factor that ranges in . This leads to a small oscillation of log µ(n, k). For large n, this contribution to log µ(n,k) log n becomes negligible. As mentioned above, the set of lengths n that are admissible for a given α is very sparse. Nevertheless, an approximate value may be used: for instance, for an integer k ′ , 1 very close to α. This oscillation phenomenon was first observed in Nicodème (2005).

Binary Alphabets
Results for binary alphabets in Park et al. (2009) steadily follow from Theorem 2.2. A rewriting of ψ leads to alternative expression (18). This explicit expression points out the dependency to the distances to α min and α max , and the behavior around these points. Corollary 2.1. Assume that the alphabet is binary. Then where A similar result holds for DNA sequences when the alphabet is 4-ary and the probability distribution satisfies p A = p T and p C = p G . Such a distribution is defined by its GC-content p G + p C .

A Probabilistic Interpretation
The main contribution to µ(n, k) arises from k-mers with an objective function close to 0, i.e., transition k-mers. Such k-mers exist in the transition phase [α min log n, α max log n] where they coexist with rare or common k-mers. Observe that this phase is shrinked when the Bernoulli model is uniform, as p min = p max and α min = α max . Therefore, most unique k-mers are concentrated on the two lengths ⌊α min log n⌋ and ⌈α min log n⌉, as observed initially in Fagin et al. (1979b).
Let k be some integer in the transition phase. First, the relative contribution of S(k) and T(k) to µ(n, k) varies with the length k. For lengths close to α min log n, most words are common and T(k) dominates S(k). When k increases, the proportion of common words decreases and the relative contribution of T(k) decreases.
Second, the dominating term in µ(n, k) arises from transition k-mers. Let w be a word of length k, the character distribution in w be (k 1 , · · · , k V ) and χ i be some character. The number of words that admit w or wχ i as a prefix fluctuates around the expectations nϕ(k 1 , · · · , k V ) and nϕ(k 1 , · · · , k V )p i , respectively. On the one hand, when word wχ i is a rare word, nϕ(k 1 , · · · , k V ) is less than 1. The smallest nϕ(k 1 , · · · , k V ) is, the less likely the actual number of occurrences of w is greater than 2 and the smallest the contribution of wχ i to S(k), and µ(n, k), is. On the other hand, let wχ i be a common k + 1-mer; w is a common k-mer and then nϕ(k 1 , · · · , k V ) is greater than 1. The largest nϕ(k 1 , · · · , k V ) is, the more likely the word wχ i is repeated and the smallest the contribution to T(k), and µ(n, k), is.
For a short length, i.e., k smaller than the completion length k min , all words are common. In a given sequence, most k-mers are repeated at least twice and there is (almost) no unique k-mers.
For a large length k, i.e., k greater than k max , all words are rare. Nevertheless the number of unique k-mers remains sublinear in n in the range [α max log n, α ext log n]: the sum of small contributions arising from a large number of possible words is significant.

EXPERIMENTS AND ANALYSIS
Simulations are presented for random and real data. For each simulation, a suffix tree (Ukkonen, 1995) is built, where each leaf represents a unique k-mer. For random cases, the Ukkonen's insertion step is iterated until a tree with exactly n leaves is build. This requires n + k ins insertions of symbols, where k ins > 0 is relatively small (there is a value of a few dozen in practice for considered n). One can observe that the event of having n leaves after n + k − 1 insertions corresponds to the fact that the trailing k-mer is unique in the sequence of length n + k − 1.
Even if a statistical bias exists, with respect to the case of a set of N random words analyzed in previous sections, this bias for respective values on k and n is below the numeric precision used for tables below.
Then, one simulation that is related to the case of a set of n random words, requires the generation of the order of N random symbols from a small alphabet, following a Bernoulli scheme. For this range of n, and even in the case of a hundred consecutive simulations, this corresponds to a regular use of a common random number generator (Knuth, 1998).
A first set of simulation deals with the case of random sequences over a binary alphabet, since the results can be compared with previous work. A second set addresses the case of random sequences over a quaternary alphabet {A, C, G, T} with a constrained distribution such that probabilities p A ≈ p T and p C ≈ p G as it is the case for DNA sequences (where the sum p C + p G is also known as the GC-content). Results on such random sequences are then compared with the sample biological sequence of an Archaea (Haloferax volcanii).
An implementation with a suffix array (Manber and Myers, 1993) allows for a compact representation and an efficient counting (Beller et al., 2013).

Statistical Behavior on Random Sets
Throughout experiments, every sample profile for a given sequence fluctuates very little around the expectation. Table 1 provides experimental results averaged over a hundred binary sequences. Short length with no observed unique k-mer is removed. Column 2 gives the mean of B(k + 1), i.e., the mean number of observed leaves at depth k + 1, over the set of a hundred simulations. Columns 3 to 5 give the computed values for S(k), T(k), and µ(k), using the expressions, equations (7-9).
The actual number of leaves B(n, k + 1) is very close to the average value µ(n, k), and simulations show that this is the general case when (only) a hundred simulations are performed: µ(n, k) is a very good prediction.
Observed lengths of extinction also show very little variations. In array below, each column gives n k , the number of sequences out of the one hundred sample set for which the longest repetition had length k. In the binary case, the predicted extinction length is between 56 and 57. It is noticeable that, in most cases, the observed depth is slightly smaller than this value. In Table 1, value 0.04 for µ(n, 61) means that one expects a total of four leaves at depth 60 over one hundred sequences. In that run, exists a total amount of 8. (13) given in Column 7 significantly overestimate the observed values in Column 6 that is computed directly from Column 2 and n. A first conclusion is that first-order asymptotics provide a poor prediction: next term is O

Tightness of the asymptotic estimates. Asymptotic estimates
that goes slowly to 0. 2. Tightness of the second-order asymptotics. Second term for the asymptotic ξ(α) ensures a much better approximation in Column 8. 3. Growth of asymptotic estimates. Observed values increase with length until k =k and then decrease. This is consistent with the variation of asymptotic values ψ(α).

Dependency to Probability Bias
Thresholds were computed for a given sequence length n and various probabilities. The more p max departs from 0.5, the value for the uniform model, the largest the extinction length is. The completion length, k min , slightly decreases, while the extinction length significantly increases. Nevertheless, this effect is limited when the largest probability p max remains in the range [0.5;0.7].
Dependency of thresholds to pmax for binary alphabets, n = 5,000,000.

Long Repetitions in Archaea Genomes
The experimental data set is the sequence from Haloferax volcanii DS2 chromosome, complete genome (Hartman et al., 2010). The alphabet is quaternary. Profile results are shown in Table 2. Sequence length is n = 2847757. The observed symbol frequencies are p A = 0.1655; p C = 0.3334; p G = 0.3330; p T = 0.1681. Therefore, observed GC-content is 0.6664. Parameters for an approximate degenerated quaternary model are p A = p T = p min = 0.1668; p C = p G = p max = 0.3332;p = 0.2645; and log n = 14.8620. The thresholds for the domain are α min = 0.5584α = 0.7520ᾱ = 0.8079 αmax = 0.9099 αext = 1.5609 k min =8.30k = 11.18k = 12.01 kmax = 13.52 kext = 23.20 Statistics on one hundred random sequences with same parameters are shown in Table 3. GC-content is 0.6664. Extinction level is provided in Table 4. Observe first a good match between the observed values, the predicted values for µ(n, k), and the asymptotic values for random data. As shown for binary alphabets,
Interestingly, the behavior for short lengths and in the transition phase is similar to the random behavior. Observation and prediction have the same order of magnitude. In particular, the number of unique k-mers is maximum for lengthk where observation and prediction coincide. For a real genome and a length k smaller than k min , observed B(n, k + 1) is larger than predicted µ(n, k). This indicates, at a level k + 1 where completion is expected, more leaves in the real trie, more missing words at level k + 2. Simultaneously, less internal nodes occur at level k + 1 because the total sum is constant and equal to V k+1 .
The effect of (non-random) repetitions is more sensible in the decreasing domain. First, the number of unique k-mers decreases much more slowly than expected for lengths larger than k max . A significant gap can be observed around extinction level k ext . The decrease rate, which was around 0.02-0.04 drops to 0.007 and then becomes even lower. Finally, the extinction level is much larger than the predicted value 23: the largest repetition is 1395 bp long.
To evaluate the contribution of long repetitions, one may erase the longest ones. When a word w is repeated, any proper suffix of w is also repeated. Consequently, once the longest repeated word is erased, one unique k-mer (only) disappears for each length larger than the length of the second largest subsequence (here, 935). The profile remains far from the random profile. This observation is still true if the 10 longest subsequences are erased.

Lagrange Multipliers
Lagrange multipliers method allows to maximize an expression under constraints. To compute (17), one sets Two constraints are given: An intermediary function ϕ α (τ 1 , · · · τ V ) is defined In order to maximize ϕ under these two constraints, ϕ function is derived with respect to each random variable τ i . This yields V equations 1 + log θ i + λ α + τ α β i = 0.
Two indices i min and i max are chosen that satisfy β i min ̸ = β i max . For instance Solving equation (24) with indices i min and i max yields Remaining equations rewrite: Using the constraint   and an expression for θ i min follows. Therefore Equation 25 rewrites: Finally, Equation (10). .
When α >α, sumS(k) rewrites 1 −S(k) wherē This sum satisfies a Large Deviation Principle and that is negative.

CONCLUSION
This paper describes the behavior of the number of unique or repeated k-mers in a random sequence, on a general alphabet. Derivation relies on a combination of analytic combinatorics and on Lagrange multipliers. It simplifies an approach provided for binary alphabets and allows to address larger alphabets, including the quaternary alphabets, such as DNA alphabet. Precise asymptotic estimates are provided and a probabilistic interpretation is given. They are validated on random simulated data and shown to be valid in the finite range. Therefore, they provide a valuable tool to estimate a suitable read length for assembly purposes and tune parameters for assembly algorithms. Real genomes significantly depart from the random behavior for long repetitions. The general shape of the trie profile is observed, with a maximum of the number of unique k-mers at the expected length. However, for real genomes, a number of very short k-mers are missing and, on the contrary, one observes a number of very long repetitions. Besides these events, the behaviors are rather similar.
In the future, it is worth extending the method to generalized Patricia tries, Markov models and approximate repetitions.