



Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!




CS 502: Algorithms in Computational Biology Spring 2009
Lecturer: Tanya Berger-Wolf Scribe: Anushka Anand
This lecture finishes up the discussion on global sequence alignment by introducing an algorithm to compute the global alignment in linear space and it introduces the problem of local sequence alignment.
The biological/“real-world” question we were trying to answer is: How similar are two sequences? The answer has certain biological implications for the two individuals or species the sequences are taken from. It points to the distance between the species from an evolutionary perspective or between the individuals in terms of genetic mixing. The computational model we discussed is based on the edit distance of sequences where we search for the sequence alignment that minimizes mismatches. The Global Alignment Problem tries to find the longest path between vertices (0,0) and (n,m) in the edit distance graph. An example of two globally aligned sequences is in Figure 5.1.
Figure 5.1. Global Alignment of two DNA sequences
To find the best sequence alignment, the choice of the scoring matrix is crucial. A scoring matrix records the cost of mismatches on base pairs and gaps. Such matrices are determined by wet-lab experiments for particular species or groups based on mutation rates, experimental mismatch rates and such factors. The common matrices for protein sequence comparisons are Point Accepted Mutations (PAM)[1] and Block Substitution (BLOSUM)[2] which reflect the frequency with which amino acid x replaces amino acid y in evolutionarily related sequences [4]. The Needleman-Wunsch algorithm for global sequence alignment has quadratic computational space and time complexity O(mn) where m and n are the lengths of the two sequences, respectively. For the human genome with 5 billion base pairs this implies a space and time cost of O(25 ∗ 1018 ) which is impractical in terms of the space cost even for super-computers.
The limiting factor in computing alignments of large sequences using dynamic programming is the tables that are built that use O(mn) space when the input strings have lengths m and n. Computing just the score of an alignment can be done in linear space - the maximum space needed is 2m. The idea is that to compute the scores for row i we only need the values from the previous row, i − 1 and any rows before i − 1 can be discarded. This observation comes from the recurrences for similarity and can be followed in Figure 5.2 [5]. But we need more information to reconstruct the alignment!
Figure 5.2. Only the global alignment scores from the previous row are needed to compute scores in the next row. (The scoring function used assigns: +10 for a match, -2 for a mismatch, -5 for a gap)
Hirschberg[6] developed a space reduction method that works for many dynamic programming problems. The clever combination of the divide and conquer principle to the dynamic programming approach allows us to reduce the space cost from O(mn) to O(min(m, n)) while only doubling the worst-case time bound. Input: Strings v, w and scoring matrix δ Output: An alignment of sequences v and w whose alignment score is maximum among all possible align- ments. To compute the global alignment of two sequences v and w of lengths n and m respectively, we construct the edit distance graph based on the edit distance between each pair of characters in the two sequences as seen in Figure 5.3.
Figure 5.3. Edit distance graph for two sequences v and w showing the split into two subproblems
Let f (n, m) be the shortest path from the source node (0, 0) to the sink node (n, m) which corresponds to the path for the alignment that maximizes the alignment score (GAOP T (n, m)). Consequently we observe that if f (i, j) is the shortest path from node (0, 0) to node (i, j) then f (i, j) = GAOP T (i, j). We can compute the score matrix between the source (0, 0) and (i, j) row-wise in O(nm) time and O(m) space and save f (., j). The useful property of shortest paths used here is that they can be split into two parts and their combined path costs add up to the total shortest path cost. Let g(i, j) be the shortest path from node (i, j) to node (n, m). This can be computed by reversing the edges in the edit distance graph to preserve the cost of the
Now, we need to determine that the time complexity has not increased with the alterations in the algorithm to make it run in linear space.
Theorem 5.1. Let T(m,n) = maximum running time of an algorithm on strings of length at most m and n
T (m, n) ≤ 2 T (m,
n 2
) + O(mn) ⇒ T (m, n) = O(mn)
Proof: by induction on n O(mn) time to compute f (., n 2 ) and g(, n 2 ) and find the best index q. Then T (q, n 2 ) + T (m − q, n 2 ) time for two recursive calls. Choose a constant c so that: T (m, 2) ≤ cm and T (2, n) ≤ cn (base cases)
T (m, n) ≤ cmn + T (q,
n 2 ) + T (m − q,
n 2
T (m, n) ≤ cmn +
2 cqn 2
2 c(m − q)n 2 T (m, n) ≤ cmn + cqn − cqn + cmn T (m, n) ≤ 2 cmn
The biological/”real-world” question we were trying to answer is: Where is the same gene on these different sequences? Here we assume that the same genes look similar. There is much biological interest in finding sequence motifs which are regions of DNA that are similar for instance in cancer research to detect genes occurring in cancer patients and not in normal individuals. Also, two genes in different species may be similar over short conserved regions and dissimilar over remaining regions. For instance, Homeobox genes which are present in a large variety of species and regulate embryonic development, have a short region called the homeodomain that is highly conserved between species. A global alignment would not find the homeodomain because it would try to align the entire sequence. The Local Sequence Alignment Problem tries to find the longest path among paths between arbitrary vertices (i,j) and (i′, j′) in the edit distance graph. An example of two locally aligned sequences is in Figure 5.5.
Figure 5.5. Local Alignment of two DNA sequences
Input: Strings v, w and scoring matrix δ Output: Alignment of substrings of v and w whose alignment score is maximum among all possible align- ments of all possible substrings.
LAOP T = maxi,j,i′,j′ {maxalign(vij , wij )}
To get a local alignment, we could solve a “mini” global alignment. This straightforward but inefficient approach would find the longest path between every pair of vertices (i, j) and (i′, j′) and select the longest of the computed paths. The problem with that is the run time would be O(n^4 ) as there are about n^2 pairs of vertices (i, j) and computing an alignment starting at each of them takes O(n^2 ) time [4].
This dynamic programming algorithm is clever modification of the global alignment one studied earlier. Local alignment can be reduced to finding the longest paths from the source vertex (0,0) to every other vertex by adding edges of weight 0 in the edit distance graph. These edges make the source vertex a predecessor of every vertex in the graph and provide a ”free ride” from the source to any vertex (i,j). This, in essence, allows us to consider a substring of matches from any given vertex (i,j) when a mismatch is encountered and to any other vertex (i′, j′) as can be seen in Figure 5.6.
Figure 5.6. Local Alignment as a mini Global alignment due to 0 graph edges
A small difference in the recurrence reflects this transformation in the edit graph:
si,j = max
si− 1 ,j− 1 + δ(vi, wj ), si− 1 ,j + δ(vi, −), si,j− 1 + δ(−, wj )
The largest value of si,j over the whole edit distance graph is the score of the best local alignment. Here, to get a maximum of 0 implies that the scoring matrix used incorporates negative scores, for instance, gaps and substitutions may have negative scores while matches may have positive scores. As the algorithm is basically the same as the Needleman-Wunsch algorithm for global alignment, the computational complexity is similarly O(mn). Hirschberg’s linear space method for alignment can be ex- tended to solve the local alignment problem. The optimal local alignment of two sequences v and w identifies substrings α and β whose global alignment has a maximum score over all pairs of substrings. So, if we can find substrings α and β in linear space, their alignment can be found in linear space using Hirschberg’s method for global alignment [9]. The value of the optimal local alignment is found in the cell (i∗, j∗) containing the maximum score where the indices i∗^ and j∗^ specify the ends of strings α and β. The scores can be computed in linear time, row-wise where the algorithm stores the values for only two rows at a time. To find the starting positions of the two
[1] M.O. Dayhoff, R. Schwartz, and B.C. Orcutt. A model of Evolutionary Change in Proteins Atlas of protein sequence and structure, Vol. 5, supp. 3 ed., 345-358. National Biomedical Research Foundation,
[2] S. Henikoff and J. G. Henikoff. Amino acid substitution matrices from protein blocks. Proceedings of the National Academy of Science USA, 89(22):10915-10919, 1992.
[3] S.B. Needleman and C.D. Wunsch. A general method applicable to the search for similarities in the amino acid sequence of two proteins. Journal of Molecular Biology, Vol.48 (3): 443-53.
[4] Neil C. Jones and Pavel Pevzner. An Introduction to Bioinformatics Algorithms. Series on Computational Molecular Biology. MIT Press, 2004.
[5] Scott Emrich. Sequence Alignment - Linear Space and Heuristic Techniques. http://www.cse.nd.edu/ courses/cse40532/www/lecture5.pdf Accessed January 31, 2009.
[6] D. S. Hirschberg A linear space algorithm for computing maximal common subsequences. Communications of the ACM, Vol.18 (6), 341-343, 1975.
[7] Nancy Warter-Perez. Space Efficient Algorithms. http://instructional1.calstatela.edu/jmomand2/ 2008/curriculum/space_efficient_algorithms.ppt Accessed January 31, 2009.
[8] T.F. Smith and M.S. Waterman. Identification of Common Molecular Subsequences. Journal of Molecular Biology, Vol.147: 195197, 1981.
[9] Dan Gusfield. Algorithms in Strings, Trees and Sequences: Computer Science and Computational Biology. Cambridge University Press, 1997.