Abstract
Background
Local alignment programs often calculate the probability that a match occurred by chance. The calculation of this probability may require a “finitesize” correction to the lengths of the sequences, as an alignment that starts near the end of either sequence may run out of sequence before achieving a significant score.
Findings
We present an improved finitesize correction that considers the distribution of sequence lengths rather than simply the corresponding means. This approach improves sensitivity and avoids substituting an ad hoc length for short sequences that can underestimate the significance of a match. We use a test set derived from ASTRAL to show improved ROC scores, especially for shorter sequences.
Conclusions
The new finitesize correction improves the calculation of probabilities for a local alignment. It is now used in the BLAST+ package and at the NCBI BLAST web site ( http://blast.ncbi.nlm.nih.gov webcite).
Background
Local alignments are an essential tool for biologists and often provide the first information about the function of an unknown nucleotide or protein sequence. An important question concerns the relationship of the score of a local alignment with the probability that the alignment occurred by chance. [Karlin and Altschul 1] developed an asymptotic theory for local alignments, assuming that no gaps are permitted. For two random sequences I and J of lengths m and n, respectively, the resulting distribution of the optimal alignment score approximates a Gumbel distribution [2]
The two statistical parameters in Equation (1) are λ, the scale parameter, and k, the prefactor.
Several authors [312] extended this framework to local alignments with gaps and showed that the Gumbel distribution from Equation (1) is still valid, though different values for λ and k are required. [Altschul 13] discussed the need for a “finitesize correction” to the lengths m and n to improve the accuracy of Equation (1). The resulting statistics are an integral part of the Basic Local Alignment Search Tool (BLAST) [14].
The following presentation emphasizes intuition over mathematical formality, to explain how the finitesize correction can account for the finite sequence lengths m and n to improve the accuracy of Equation (1). Let us begin with an optimal local alignment, which starts from score 0 and requires a nonzero sequence length within both I and J, before it achieves score y. Let L_{I} (y) (L_{J} (y)) be the required random lengths within both I (J), and let ( ) be the corresponding means. The main idea is that the optimal local alignment cannot start anywhere along the full length m (n) of sequence I (J), because there might be insufficient sequence to permit it to achieve the score y (Figure 1). The finitesize correction described in [13] and used in BLAST therefore replaced the area mn of the alignment matrix for Equation (1) by
Figure 1. Sequence alignment graph of two random sequences I and J of lengths m and n, respectively. The black circles are the initiation vertices of local alignment paths just remaining within the large rectangle of the sequence alignment graph before achieving the score y, i.e., the lower local alignment path has length L_{I} (y) within I; and the upper, length L_{J} (y) within J. The gray shaded area is therefore the (random) alignment rectangle that an optimal local alignment must start within to achieve the score y. Thus, if the black circles lie within the gray rectangle, the alignments achieve the score y within m × n alignment rectangle. If the black circles lie further outside the gray rectangle, the alignments do not achieve the score y within m × n alignment rectangle.
Equation (2) approximates the area within the alignment matrix where the optimal local alignment can start and on average still have enough space to exceed the score y. If m < l_{I} (y) or n < l_{J} (y), however, the resulting value in Equation (2) might become negative. The BLAST code for the old finitesize correction therefore set the corrected sequence length to an ad hoc value (typically 1). For very short query or database sequences, the ad hoc correction could underestimate the significance of an alignment by many orders of magnitude.
The purpose of this note is to present a new finitesize correction formula for the BLAST statistics. It avoids the ad hoc correction and improves on them by considering the (approximately normal) distributions of the random lengths L_{I} (y) and L_{J} (y) explicitly, and not just the corresponding means l_{I} (y) and l_{J} (y). We demonstrate below that the new finitesize correction is better than the older one, both in theory and in practice. All BLAST+ proteinprotein applications (i.e., BLASTP, BLASTX) use the new finitesize correction by default, starting with version 2.2.26.
Findings
New finitesize correction
As with the old finitesize correction, the expectation is approximated linearly:
Most practical scoring systems are symmetric, with s(A, B) = s(B, A) for any two letters A and B, and for a symmetric scoring matrix and symmetric sequence compositions, expectations corresponding to I and J are the same, e.g., l_{I} (y) = l_{J} (y) = l(y). For asymmetric scoring systems or asymmetric sequence compositions, however, the variates L_{I} (y) and L_{J} (y) can have different distributions, so the following retains the subscripts I and J.
The new finitesize correction replaces mn in Equation (1) by
where x^{+} = max{x,0}. Rather than taking the expectation ofL_{I} (y) and L_{J} (y) as in Equation (2), Equation (4) is the expected area within the alignment rectangle where an optimal local alignment can start and have enough random sequence length to reach the score y (Figure 1).
The practical computation of Equation (4) approximates the distribution of (L_{I}(y),L_{J} (y)) with a bivariate normal distribution, with means and ,variances var L_{I} (y) = v_{I} (y) and var L_{J} (y) = v_{J} (y), and covariance cov (L_{I}(y), L_{J} (y)) = c(y), all assumed to be linear in the score y, i.e.,
The estimation of the parameters a_{I}a_{J}α_{I}α_{J} and σ has mathematical depth and involves many unproved speculations, but involves a heuristic modeling of a random sequence alignment with Markov additive processes [15], ultimately with use of the renewalreward theorem. The Appendix presents formulas for computing a_{I}a_{J}α_{I}α_{J} and σ.
BLAST pvalues are relatively insensitive to the values of the intercepts b_{I}b_{J}β_{I}β_{J}, and τ, so the practical computation approximates them, as follows. Let a_{u} (α_{u}) be the value of a_{I} (α_{I}) for ungapped alignment. The mathematical theories for random walks and for renewals yield analytic formulas for a_{u} and α_{u}[16]. For an ungapped optimal alignment, the alignment length required to exceed the score y is the same within the sequences I and J, because it lacks gaps. Thus, a_{u} and α_{u} do not depend on the sequence (I or J) under consideration, so they contain no subscripts I or J. In a gapped alignment, let a gap of length 1 incurs a penalty G. The following uncontrolled approximations hold [17]:
Under the normal approximation, routine computation shows that Equation (4) is approximately
where , , and X is a standard normal variate. The final product is an uncontrolled independence approximation for the bivariate normal distribution.
Comparison of pvalues for the new and old finitesize corrections
We compared pvalues for the new finitesize correction with those for the old finitesize correction using the BLOSUM62 scoring matrix and affine gap penalty 11 + g. Hartmann used a rareevent simulation method to compute the local alignment score distribution for ranges that included small pvalues like p = 10^{−50}[18], thereby producing a theoretical standard for small pvalues.
Figure 2 plots relative errors in logarithmic scale against true pvalues for equal sequence lengths m = n = 40, 100, 200, and 400. Using Hartmann’s theoretical standard, the new finitesize correction outperforms as the pvalue decreases, sometimes by orders of magnitude.
Figure 2. Comparison of pvalues for the new and old finitesize corrections using the BLOSUM62 scoring matrix and 11 + g affine gap penalty for equal sequence lengths (m=n) 40, 100, 200, and 400. Figure 2 plots against p, where is the calculated pvalue and p is the pvalue from the simulation. Thus, a perfect pvalue estimate corresponds to the horizontal line y = 0. The red line shows the results from the new finitesize correction; the black line, the old finitesize correction.
Evaluation of accuracy
We evaluated the performance of the new finitesize correction using the ASTRAL SCOP 40 subset [19] of release 1.75 of the Structural Classification of Proteins (SCOP) [20] database. We sorted the SCOP domains by lexicographic order and used the even numbered sequences as our query set, but removed any query that was the sole member of the superfamily in ASTRAL 40. For a given query sequence, we considered any database sequence belonging to the same SCOP superfamily as a true positive, and any database sequence belonging to a different SCOP fold as a false positive. Following [21], in the retrieval list for each query, we censored all sequences belonging to the same fold but different superfamily, so those sequences contributed neither true or false positives to the retrieval.
We report the performance in terms of the Receiver Operator Characteristics (ROC). Specifically, we report the ROC_{n} score, which is obtained by pooling the results of all queries, ordering them by expect value, but only keeping results up the nth false positive [21]. The expect value for the database search was obtained from the pairwise pvalues using a lengthproportional correction that takes the ratio of the database length to the target sequence length into account [13].
As discussed above, the new finitesize correction should show the greatest improvement for short sequences. Therefore, we also produced ROC_{n} scores for different subsets of the SCOP database. One database subset has sequences shorter than the 25th percentile length (95 residues), and another has sequences shorter than the 50th percentile length (137 residues).
Table 1 presents ROC_{n} scores for the full database as well as the two subsets described above. These scores have an average of one false positive per query (4852), a threshold found useful in other studies (Altschul SF, private communication). The ROC4852 scores for the full database demonstrate a small improvement of the new finitesize correction over the older one. The subsets show a more impressive improvement. For the 50^{th} percentile subset, the ROC4852 score improves by 9%. For the 25^{th} percentile subset, the ROC4852 score shows a 13% improvement. In the 25^{th} percentile subset, the new finitesize correction produces roughly 12% more true positives overall at 4852 false positives than the old finitesize correction (Figure 3). These results confirm our expectation that the new finitesize correction will display greatest improvement in retrieval for short sequences.
Table 1. Retrieval accuracy for different subsets of SCOP database with the new and old finitesize correction
Figure 3. Number of true positives vs. number of false positives for both new and old finitesize corrections using short SCOP sequences as a database. The searched database was created from the shortest 25% of the ASTRAL 40 sequences for SCOP version 1.75 (see text).
To assess the significance of this improvement on BLAST searches, one may look to the length distribution of sequences in a heavily used protein BLAST database. The nonredundant (“nr”) database is the default protein database at the NCBI BLAST web site. Of the sequences in the nr database, 11% are 95 residues or shorter; and 21%, 137 residues or shorter. The new finitesize correction improves the retrieval accuracy for a noticeable fraction of the proteins in the nr database.
Conclusion
We have described a new finitesize correction. The new correction has a more rigorous derivation than the current finitesize correction and avoids the use of an ad hoc value for short sequences. We have tested the retrieval accuracy of the new finitesize correction on the gold standard SCOP set, and have shown that the improvement is most important for short sequences. This correction has been made part of the BLAST+ proteinprotein applications (e.g., BLASTP, BLASTX) as well as at the NCBI BLAST web site. In the future, we plan to implement this correction for nucleotidenucleotide comparisons.
Availability and requirements
Project Name: BLAST Statistical Parameters
Project home page: http://www.ncbi.nlm.nih.gov/CBBresearch/Spouge/html_ncbi/html/blast/ webcite
Operating systems: Windows, MacOSX, LINUX, UNIX
Programming language: C++
License: Public Domain (see http://www.ncbi.nlm.nih.gov/books/NBK22952/ webcite)
Any restrictions to use by nonacademics: None
Competing interests
The authors declare that they have no competing interests.
Authors’ contributions
YP, TM and JS drafted the manuscript. YP designed the pvalue evaluation method. SS implemented the new finitesize correction. NM integrated the correction into the BLAST+ code, ran tests, and calculated the ROC scores. JS devised the new finitesize correction. YP and SS are equal contribution first authors for this article. TLM and JLS are equal contribution last authors for this article. All authors read and approved the final manuscript.
Acknowledgements
We thank Greg Boratyn for help in running the accuracy evaluations with the SCOP set. This research was supported by the intramural research program of the NIH, National Library of Medicine.
Appendix
Let . Consider two semiinfinite random sequences, yielding alignment scores S_{i,j} at each vertex within their alignment graph. Define the edge maximum score . Let and for i ≥ 1. We call κ_{i} the i^{th} SALE (strict ascending ladder epoch) and the i^{th} SALE score. Let , the increment between the (i − 1)^{th} and i^{th} SALE scores.
Let and . We also define and . Let ΔI_{i} := I_{i} − I_{i−1}, the incremental sequence length between (i − 1)^{th} and i^{th} SALEs in sequence I, and ΔJ_{j} := J_{j} − J_{j−1}, the incremental sequence length between (j − 1)^{th} and j^{th} SALEs in sequence J. Last, we define , , and .
The formulas for computing a_{I}a_{J}α_{I}α_{J} and σ are:
where var^{*} and cov^{*} represent the variance and covariance associated with the probability measure underlying the expectation . In practice, for computational efficiency, we use importance sampling to estimate the parameters above [15]. The parameters are estimated separately at each SALE. We then apply asymptotic regression to estimate the values of a_{I}a_{J}α_{I}α_{J} and σ as i → ∞ in the equation above [22].
References

Karlin S, Altschul SF: Methods for assessing the statistical significance of molecular sequence features by using general scoring schemes.
Proc Natl Acad Sci U S A 1990, 87(6):22642268. PubMed Abstract  Publisher Full Text  PubMed Central Full Text

Galambos J: The asymptotic theory of extreme order statistics. New York: Wiley; 1978.

Mott R: Maximumlikelihoodestimation of the statistical distribution of SmithWaterman local sequence similarity scores.

Waterman MS, Vingron M: Rapid and accurate estimates of statistical significance for sequence data base searches.
Proc Natl Acad Sci U S A 1994, 91(11):46254628. PubMed Abstract  Publisher Full Text  PubMed Central Full Text

Altschul SF, Gish W: Local alignment statistics.
Methods Enzymol 1996, 266:460480. PubMed Abstract  Publisher Full Text

Bundschuh R: Rapid significance estimation in local sequence alignment with gaps.
J Comput Biol 2002, 9(2):243260. PubMed Abstract  Publisher Full Text

Chia N, Bundschuh R: A practical approach to significance assessment in alignment with gaps.
J Comput Biol 2006, 13(2):429441. PubMed Abstract  Publisher Full Text

Newberg LA: Significance of gapped sequence alignments.
J Comput Biol 2008, 15(9):11871194. PubMed Abstract  Publisher Full Text  PubMed Central Full Text

Agrawal A, Brendel VP, Huang X: Pairwise statistical significance and empirical determination of effective gap opening penalties for protein local sequence alignment.
Int J Computat Biol Drug Des 2008, 1(4):347367. Publisher Full Text

Poleksic A: Island method for estimating the statistical significance of profileprofile alignment scores.
BMC Bioinformatics 2009, 10:112. PubMed Abstract  BioMed Central Full Text  PubMed Central Full Text

Ortet P, Bastien O: Where does the alignment score distribution shape come from?

Agrawal A, Huang X: Pairwise statistical significance of local sequence alignment using sequencespecific and positionspecific substitution matrices.
IEEE/ACM Trans Comput Biol Bioinformatics 2011, 8(1):194205.

Altschul SF: Evaluating the statistical significance of multiple distinct local alignments. In Theoretical and computational methods in genome research. Edited by Suhai S. New York: Plenum Press; 1997:114.

Altschul SF, Madden TL, Schaffer AA, Zhang J, Zhang Z, Miller W, Lipman DJ: Gapped BLAST and PSIBLAST: a new generation of protein database search programs.
Nucleic Acids Res 1997, 25(17):33893402. PubMed Abstract  Publisher Full Text  PubMed Central Full Text

Park Y, Sheetlin S, Spouge JL: Estimating the gumbel scale parameter for local alignment of random sequences by importance sampling with stopping times.
Ann Stat 2009, 37(6A):36973714. PubMed Abstract  Publisher Full Text  PubMed Central Full Text

Asmussen S: Applied probability and queues. New York: Springer; 2003.

Altschul SF, Bundschuh R, Olsen R, Hwa T: The estimation of statistical parameters for local alignment score distributions.
Nucleic Acids Res 2001, 29(2):351361. PubMed Abstract  Publisher Full Text  PubMed Central Full Text

Hartmann AK: Sampling rare events: statistics of local sequence alignments.
Phys Rev E 2002., 65(5) Publisher Full Text

Chandonia JM, Hon G, Walker NS, Lo Conte L, Koehl P, Levitt M, Brenner SE: The ASTRAL Compendium in 2004.
Nucleic Acids Res 2004, 32:D189D192. PubMed Abstract  Publisher Full Text  PubMed Central Full Text

Murzin AG, Brenner SE, Hubbard T, Chothia C: SCOP  a structural classification of proteins database for the investigation of sequences and structures.
J Mol Biol 1995, 247(4):536540. PubMed Abstract  Publisher Full Text

Schaffer AA, Aravind L, Madden TL, Shavirin S, Spouge JL, Wolf YI, Koonin EV, Altschul SF: Improving the accuracy of PSIBLAST protein database searches with compositionbased statistics and other refinements.
Nucleic Acids Res 2001, 29(14):29943005. PubMed Abstract  Publisher Full Text  PubMed Central Full Text

Sheetlin S, Park Y, Spouge JL: Objective method for estimating asymptotic parameters, with an application to sequence alignment.
Phys Rev E 2011., 84(3) Publisher Full Text