Lecture-7-Dynamic Programming Global-Sequence Alignment
Lecture-7-Dynamic Programming Global-Sequence Alignment
Algorithms:
Dynamic Programming
• The two sequences are written out as column and row headings of a
two-dimensional matrix.
• By searching for the set of highest scores in this matrix, the best
alignment can be accurately obtained.
Global alignment method
• Needleman & Wunsch were the first to propose this method.
1. Initialization
3. Traceback
4. Alignment
Global alignment method
1. Initialization: It is the 1st step in the global alignment dynamic programming
approach, where a matrix with (M+1) columns and (N+1) rows is created.
(M and N) correspond to the size of the sequences to be aligned.
2. Matrix filling (scoring): We fill the matrix with the highest possible scores.
3. Traceback: Move from the last corner and follow the arrow.
1. 1st row and 1st column should correspond to the two sequences.
3. Put scores for each category (if Match: +1, if Mismatch: -1, if Gap: -2)
4. 1st column and last row should be first filled with scores or values.
5. The direction of our scoring or value placement should be from lower left to
upper right diagonally.
Initialization
2 Sequences
• GCTA (Sequence 1)
• TCG (Sequence 2)
• We need to do the alignment
GAP 0
GAP T C G
RULES
• 1st row and 1st column should correspond to the two sequences.
• Fill 1st block with a gap and “0”.
• Put scores for each category (Match: +1, Mismatch: -1, Gap: -2)
Initialization
G
Sequences
C
• GCTA
• TCG
T • We need to do
the alignment
A ?
GAP 0
GAP T C G
RULES
• 1st row and 1st column should correspond to the two sequences.
• Fill 1st block with a gap or “0”.
• Put scores for each category (Match: +1, Mismatch: -1, Gap: -2)
Direction of arrow
• Box beside (add the value of beside box with gap score of -2)
• Box bottom (add the value of bottom box with gap score of -2)
• Diagonal box (Match/Mismatch criteria), if match add +1 or -1 with diagonal box value
• Then only keep the highest value & arrow direction.
Matrix Filling / Scoring
C-1
GAP 0 -2 -4 -6 R-4
GAP T C G
RULES
• Column-1 (C-1) and Row-4 (R-4) have to be filled up first.
• Now, simply add the value of “gap” i.e. “-2”.
• Put scores for each category (Match: +1, Mismatch: -1, Gap: -2)
• Direction of arrow
• Box beside (add the value of beside box with gap score of -2)
• Box bottom (add the value of bottom box with gap score of -2)
• Diagonal box (Match/Mismatch criteria), if match add +1 or -1 with diagonal box value
• Then only keep the highest value & arrow direction.
Matrix Filling / Scoring
C-1
G -8
C -6
T -4
A -2
GAP 0 -2 -4 -6 R-4
GAP T C G
RULES
• Column-1 (C-1) and Row-4 (R-4) have to be filled up first.
• Now, simply add the value of “gap” i.e. “-2”.
• Put scores for each category (Match: +1, Mismatch: -1, Gap: -2)
• Direction of arrow
• Box beside (add the value of beside box with gap score of -2)
• Box bottom (add the value of bottom box with gap score of -2)
• Diagonal box (Match/Mismatch criteria), if match add +1 or -1 with diagonal box value
• Then only keep the highest value & arrow direction.
Matrix Filling / Scoring
G -8 X X X
C -6 X X X
T -4 X X X
A -2 X X X
GAP 0 -2 -4 -6
GAP T C G
RULES
• Column-1 (C-1) and Row-4 (R-4) have to be filled up first.
• Now, simply add the value of “gap” i.e. “-2”.
• Put scores for each category (Match: +1, Mismatch: -1, Gap: -2)
• Direction of arrow
• Box beside (add the value of beside box with gap score of -2)
• Box bottom (add the value of bottom box with gap score of -2)
• Diagonal box (Match/Mismatch criteria), if match add +1 or -1 with diagonal box value
• Then only keep the highest value & arrow direction.
Matrix Filling / Scoring
G -8 X X X
C -6 X X X
T -4 X X X
-4
A -2 -4 X X
GAP 0 -2 -4 -6
GAP T C G
RULES
• Put scores for each category (Match: +1, Mismatch: -1, Gap: -2)
• Direction of arrow
• Box beside (add the value of beside box with gap score of -2)
• Box bottom (add the value of bottom box with gap score of -2)
• Diagonal box (Match/Mismatch criteria), if match add +1 or -1 with diagonal box value
• Then only keep the highest value & arrow direction.
Matrix Filling / Scoring
G -8 X X X
C -6 X X X
T -4 X X X
-4
A -2 0-1= -1 -4 X X
GAP 0 -2 -4 -6
GAP T C G
RULES
• Put scores for each category (Match: +1, Mismatch: -1, Gap: -2)
• Direction of arrow
• Box beside (add the value of beside box with gap score of -2)
• Box bottom (add the value of bottom box with gap score of -2)
• Diagonal box (Match/Mismatch criteria), if match add +1 or -1 with diagonal box value
• Then only keep the highest value & arrow direction.
Matrix Filling / Scoring
G -8 X X X
C -6 X X X
T -4 X X X
• -1 is greater.
GAP 0 -2 -4 -6 • So, we will delete -4
• We will score this box
with -1
GAP T C G • Specify the direction
RULES
• Put scores for each category (Match: +1, Mismatch: -1, Gap: -2)
• Direction of arrow
• Box beside (add the value of beside box with gap score of -2)
• Box bottom (add the value of bottom box with gap score of -2)
• Diagonal box (Match/Mismatch criteria), if match add +1 or -1 with diagonal box value
• Then only keep the highest value & arrow direction.
Matrix Filling / Scoring
G -8 X X X
C -6 X X X
T -4 X X X
-1-2= (-3)
A -2 -1 -4-2= (-6) X
-2-1= (-3)
GAP 0 -2 -4 -6
GAP T C G
RULES
• Put scores for each category (Match: +1, Mismatch: -1, Gap: -2)
• Direction of arrow
• Box beside (add the value of beside box with gap score of -2)
• Box bottom (add the value of bottom box with gap score of -2)
• Diagonal box (Match/Mismatch criteria), if match add +1 or -1 with diagonal box value
• Then only keep the highest value & arrow direction.
Matrix Filling / Scoring
G -8 X X X
C -6 X X X
T -4 X X X
-3 -5
A -2 -1
-3 -5 -8
GAP 0 -2 -4 -6
GAP T C G
RULES
• Put scores for each category (Match: +1, Mismatch: -1, Gap: -2)
• Direction of arrow
• Box beside (add the value of beside box with gap score of -2)
• Box bottom (add the value of bottom box with gap score of -2)
• Diagonal box (Match/Mismatch criteria), if match add +1 or -1 with diagonal box value
• Then only keep the highest value & arrow direction (here 2).
Matrix Filling / Scoring
G -8 X X X
C -6 X X X
T -4 X X X
A -2 -1 -3 -5
GAP 0 -2 -4 -6
GAP T C G
RULES
• Put scores for each category (Match: +1, Mismatch: -1, Gap: -2)
• Direction of arrow
• Box beside (add the value of beside box with gap score of -2)
• Box bottom (add the value of bottom box with gap score of -2)
• Diagonal box (Match/Mismatch criteria), if match add +1 or -1 with diagonal box value
• Then only keep the highest value & arrow direction (here 2).
Matrix Filling / Scoring
G -8 X X X
C -6 X X X
-6
T -4 X X
-1 -3
A -2 -1 -3 -5
SCORING
GAP 0 -2 -4 -6
• -1 is greater.
• So, we will delete -6 and -3
GAP T C G • We will score this box with -1
RULES
• Put scores for each category (Match: +1, Mismatch: -1, Gap: -2)
• Direction of arrow
• Box beside (add the value of beside box with gap score of -2)
• Box bottom (add the value of bottom box with gap score of -2)
• Diagonal box (Match/Mismatch criteria), if match add +1 or -1 with diagonal box value
• Then only keep the highest value & arrow direction (here 2).
Matrix Filling / Scoring
G -8 X X X
C -6 X X X
T -4 -1 X X
A -2 -1 -3 -5
GAP 0 -2 -4 -6
GAP T C G
RULES
• Put scores for each category (Match: +1, Mismatch: -1, Gap: -2)
• Direction of arrow
• Box beside (add the value of beside box with gap score of -2)
• Box bottom (add the value of bottom box with gap score of -2)
• Diagonal box (Match/Mismatch criteria), if match add +1 or -1 with diagonal box value
• Then only keep the highest value & arrow direction (here 2).
Matrix Filling / Scoring
G -8 -5 -2 +1
C -6 -3 0 -2
T -4 -1 -2 -4
A -2 -1 -3 -5
GAP 0 -2 -4 -6
GAP T C G
RULES
• Put scores for each category (Match: +1, Mismatch: -1, Gap: -2)
• Direction of arrow
• Box beside (add the value of beside box with gap score of -2)
• Box bottom (add the value of bottom box with gap score of -2)
• Diagonal box (Match/Mismatch criteria), if match add +1 or -1 with diagonal box value
• Then only keep the highest value & arrow direction (here 2).
Tracebacking
G -8 -5 -2 +1
C -6 -3 0 -2
T -4 -1 -2 -4
A -2 -1 -3 -5
GAP 0 -2 -4 -6
GAP T C G
Tracebacking
• From the highest value of the matrix, we need to trace down to the starting value i.e. 0.
Tracebacking
G -8 -5 -2 +1
C -6 -3 0 -2
T -4 -1 -2 -4
A -2 -1 -3 -5
GAP 0 -2 -4 -6
GAP T C G
Tracebacking
• Based on the direction of the previous blue arrow & from where the value is coming,
we need to now come down in each box.
C -6 -3 0 -2
T -4 -1 -2 -4
A -2 -1 -3 -5
GAP 0 -2 -4 -6
GAP T C G
Tracebacking
• Based on the direction of previous blue arrow, we need to now come down in each box.
C -6 -3 0 -2
T -4 -1 -2 -4
A -2 -1 -3 -5
GAP 0 -2 -4 -6
GAP T C G
• We need to look for the traceback arrow in green color and its direction.
C -6 -3 0 -2 A T C G
[GAP] T C G
T -4 -1 -2 -4 This is the Alignment
A -2 -1 -3 -5
GAP 0 -2 -4 -6
GAP T C G
Alignment
• We need to look for the traceback arrow in green color and its direction.
C -6 -3 0 -2 A T C [GAP]
[GAP] T C G
T -4 -1 -2 -4
This is the Alignment
A -2 -1 -3 -5
GAP 0 -2 -4 -6
GAP T C G
Alignment
• We need to look for the traceback arrow in green color and its direction.
C -6 -3 0 -2 A T C G
[GAP] T C G
T -4 -1 -2 -4
= (-2) + (1) + (1) + (1)
A -2 -1 -3 -5 = (+1)
GAP 0 -2 -4 -6
GAP T C G
Alignment
• To check the accuracy of the alignment again, we need to compare the alignment
value with the highest score of the matrix.
• (+1) is matching with the highest score of the matrix i.e. (+1)
• That indicates the alignment is correct.
• This cross-checking is important.
Next class:
• We will go through “Scoring matrices”.
• PAM matrices.
• BLOSUM matrices
Thank you