490 likes | 649 Views
Pairwise sequence Alignment. Types of Alignment • Global alignment: Aligning the whole sequences • Appropriate when aligning two very closely related sequencs • Local alignment: Aligning certain regions in the sequences • Appropriate for aligning multi-domain protein sequences
E N D
Pairwise sequence Alignment
Types of Alignment • Global alignment: Aligning the whole sequences • Appropriate when aligning two very closely relatedsequencs • Local alignment: Aligning certain regions in the sequences • Appropriate for aligning multi-domain proteinsequences • It is important to use the “appropriate” type Distinction between global and local alignments of two sequences.
How do we compute the best alignment? AGTGCCCTGGAACCCTGACGGTGGGTCACAAAACTTCTGGA Too many possible alignments: >> 2N (exercise) AGTGACCTGGGAAGACCCTGACCCTGGGTCACAAAACTC
Sequence Alignment AGGCTATCACCTGACCTCCAGGCCGATGCCC TAGCTATCACGACCGCGGTCGATTTGCCCGAC -AGGCTATCACCTGACCTCCAGGCCGA--TGCCC--- TAG-CTATCAC--GACCGC--GGTCGATTTGCCCGAC Definition Given two strings x = x1x2...xM, y = y1y2…yN, an alignment is an assignment of gaps to positions 0,…, M in x, and 0,…, N in y, so as to line up each letter in one sequence with either a letter, or a gapin the other sequence
Alignment is additive Observation: The score of aligning x1……xM y1……yN is additive Say that x1…xi xi+1…xM aligns to y1…yj yj+1…yN The two scores add up: F(x[1:M], y[1:N]) = F(x[1:i], y[1:j]) + F(x[i+1:M], y[j+1:N])
DP Algorithms for PairwiseAlignment The number of all possible pairwise alignments (if gaps are allowed) is exponential in the length of the sequences • Therefore, the approach of “score every possible alignment and choose the best” is infeasible in practice • Efficient algorithms for pairwise alignment have been devised using dynamic programming (DP)
Two kinds of sequence alignment: global and local We will first consider the global alignment algorithm of Needleman and Wunsch (1970). We will then explore the local alignment algorithm of Smith and Waterman (1981). Finally, we will consider BLAST, a heuristic version of Smith-Waterman. We will cover BLAST in detail on Monday. Page 63
Global alignment with the algorithm of Needleman and Wunsch (1970) • • Two sequences can be compared in a matrix • along x- and y-axes. • • If they are identical, a path along a diagonal • can be drawn • • Find the optimal subpaths, and add them up to achieve • the best score. This involves • --adding gaps when needed • --allowing for conservative substitutions • --choosing a scoring system (simple or complicated) • N-W is guaranteed to find optimal alignment(s) Page 63
İnitial stage of filling in the DP Sm and Sn m+1 x n+1 9 x 10 The sequences are written across the top and down the left side of a matrix, respectively, An extra row and column labeled “gap” are added to allow the alignment to begin with a gap of any length in either sequence. The gap rows are filled with penalty scores for gaps of increasing lengths, as indicated. A zero is placed in the upper right box corresponding to no gaps in either sequence. columns rows
Gap=-8 Gap=-4
Three steps to global alignment with the Needleman-Wunsch algorithm [1] set up a matrix [2] score the matrix [3] identify the optimal alignment(s) Page 63
Four possible outcomes in aligning two sequences 1 2 [1] identity (stay along a diagonal) [2] mismatch (stay along a diagonal) [3] gap in one sequence (move vertically!) [4] gap in the other sequence (move horizontally!) Page 64
x (x1x2...xm) and y(y1y2...yn) The matrix has (m+1) rows labeled 0➝m and (n+1)columns labeled 0➝n The rows correspond to the residues of sequence x, andthe columns correspond to the residues of sequence y y S0,0 + s(x1,y1) = 0+s(I,T)=0-1=-1 S1,0 + g = -8-8=-16 S0,1 + g = -8-8=-16 x
s11 is the score for an a1-b1 match added to 0 in the upper left position Trial values for s12 are calculated and the maximum score is chosen. Trial 1 is to add the score for the a1-b2 match to s11 and subtract a penalty for a gap of size 1. The other three trials shown by arrows include gap penalties and so likely cannot yield a higher score than trial 1.
Global alignment of two protein sequences by the Needleman-Wunsch algorithm withenhancements by Smith and Waterman. • sequence 1 = MNALSDRT and • sequence 2 = MGSDRTTET. • Notice the subsequence SDRT in the two sequences which one might expect to be aligned if the sequences are aligned properly. JMB, 1970
-12 is the penalty for opening the gap in the alignment, and -4 is the penalty for each additional sequence character in the gap. Use PAM250 M M S0,0 + s(x1,y1) = 0+s(M,M)=0+6=6 S1,0 + g = -12-12=-24 S0,1 + g = -12-12=-24 M - - M S1,1 = - M M -
sequence 1 M -N A L S D R T sequence 2 M G S D R T T E T score 6 -12 1 0 -3 1 0 -1 3 = -5 sequence 1 M N A - L S D R T sequence 2 M G S D R T T E T score 6 -12 1 0 -3 1 0 -1 3 = -5
H E A G A W G H E - E - P - - A W - H E A E Optimal alignment:
t a c g - c a a - - - a c g t g a a t t
t - - a c g c a - - a a c g t g - - a a t t
Example 4 - T G C A T - A - A T - C - T G A T Alignment:
Tracing back a solution (II) The algorithm is called with PRINT-LCS(b,V,n,m)
Computing Distance di-1,j + 1 di,j-1 + 1 di-1,j-1 , if vi=wj di,j=min Only deletions/insertions are allowed
Needleman-Wunsch: dynamic programming N-W is guaranteed to find optimal alignments, although the algorithm does not search all possible alignments. It is an example of a dynamic programming algorithm: an optimal path (alignment) is identified by incrementally extending optimal subpaths. Thus, a series of decisions is made at each step of the alignment to find the pair of residues with the best score. Page 67
Local sequence alignment • Suppose, we have a long DNA sequence (e.g., 4000 bp) and we want to compare it with the complete yeast genome (12.5M bp). • What if only a portion of our query, say 200 bp length, has strong similarity to a gene in yeast. • Can we find this 200 bp portion using (semi) global alignment? Probably not. Because, we are trying to align the complete 4000 bp sequence, thus a random alignment may get a better score than the one that aligns 200 bp portion to the similar gene in yeast.
Global alignment versus local alignment Global alignment (Needleman-Wunsch) extends from one end of each sequence to the other Local alignment finds optimally matching regions within two sequences (“subsequences”) Local alignment is almost always used for database searches such as BLAST. It is useful to find domains (or limited regions of homology) within sequences Smith and Waterman (1981) solved the problem of performing optimal local sequence alignment. Other methods (BLAST, FASTA) are faster but less thorough. Page 69
How the Smith-Waterman algorithm works Set up a matrix between two proteins (size m+1, n+1) No values in the scoring matrix can be negative! S > 0 The score in each cell is the maximum of four values: [1] s(i-1, j-1) + the new score at [i,j] (a match or mismatch) [2] s(i,j-1) – gap penalty [3] s(i-1,j) – gap penalty [4] zero Page 69
Local alignemnt The major difference between this scoring matrix and the Needleman-Wunsch matrix is that there are no negative scores in the Smith-Waterman scoring matrix. The effect of this change is that an alignment can begin anywhere without receiving a negative penalty from a previously low- scoring alignment. sequence 1 S D R T sequence 2 S D R T score 2 4 6 3 = 15
Example Linear gap model Gap = -1 Match = 4 Mismatch = -2 Q: E Q L L K A L E F K L P: K V L E F G Y - E Q L L K A L E F K L - K V L E F G Y
Example Linear gap model Gap = -1 Match = 4 Mismatch = -2 Q: E Q L L K A L E F K L P: K V L E F G Y - E Q L L K A L E F K L - K V L E F G Y
Example Linear gap model Gap = -1 Match = 4 Mismatch = -2 Q: E Q L L K A L E F K L P: K V L E F G Y - E Q L L K A L E F K L - K V L E F G Y
Example Linear gap model Gap = -1 Match = 4 Mismatch = -2 Q: E Q L L K A L E F K L P: K V L E F G Y - E Q L L K A L E F K L - K V L E F G Y
Example Alignment Q: E Q L L K A L E F K L P: K V L E F G Y Q: K A - L E F P: K - V L E F - E Q L L K A L E F K L - K V L E F G Y
Example Alignment Q: E Q L L K A L E F K L P: K V L E F G Y Q: K - A L E F P: K V - L E F - E Q L L K A L E F K L - K V L E F G Y
Example Alignment Q: E Q L L K A L E F K L P: K V L E F G Y Q: K A L E F P: K V L E F - E Q L L K A L E F K L - K V L E F G Y
Another Example Linear gap model Gap = -4 Match = +5 Mismatch = -4 Find the local alignment between: Q: G C T G G A A G G C A T P: G C A G A G C A C G Q P
Another Example Q’s subsequence: G A A G – G C A P’s subsequence: G C A G A G C A Q P