650 likes | 801 Vues
Dynamic Programming for Pairwise Alignment. Dr Alexei Drummond Department of Computer Science alexei@cs.auckland.ac.nz. BIOSCI 359, Semester 2, 2006. Dynamic Programming. method for solving combinatorial optimisation problems guaranteed to give optimal solution
E N D
Dynamic Programmingfor Pairwise Alignment Dr Alexei Drummond Department of Computer Science alexei@cs.auckland.ac.nz BIOSCI 359, Semester 2, 2006
Dynamic Programming • method for solving combinatorial optimisation problems • guaranteed to give optimal solution • generalisation of “divide-and-conquer” • relies on “Principle of Optimality” i.e. sub-optimal solution of subproblem cannot be part of optimal solution of original problem instance.
Principle of Optimality Auckland Te Kuiti Wellington
Principle of Optimality Auckland Te Kuiti Wellington
Key to efficiency • computation is carried out bottom-up • store solutions to subproblems in a table • all possible subproblems solved once each, beginning with smallest subproblems • work up to original problem instance • only optimal solutions to subproblems are used to compute solution to problem at next level • DO NOT carry out computation in recursive, top-down manner • same subproblems would be solved many times
Pairwise alignment Sequences x = a c g g t s y = a w g c c t t Alignment x¢ = a – c g g – t s y¢ = a w – g c c t t
Scoring • Numeric score associated with each column • Total score = sum of column scores • Column types: • Identical (+ve) (2) Conservative (+ve) (3) Non-conservative (-ve) (4) Gap (-ve) x¢ = a – c g g– t s y¢ = a w – g cc t t
Gap penalties • Linear score:g(g) = -gd gap penality • Affine score:g(g) = -d- (g-1)e gap-open penality gap-extension penalty y¢ ---------- x¢ g
BLOSUM50 matrix “Blocks Amino Acid Substitution Matrix”
Needleman & Wunsch algorithm • Dynamic programming algorithm for global alignment • Needleman & Wunsch (‘70), modified Gotoh (‘82) • Assumptions: • Linear gap score d • Symmetric scoring matrix S • s(a,b) = s(b,a) score from lining up a and b • s(a,-) = s(-,a) = -d score from lining up a with -
Principle of Optimality Given sequences: Define: F(i,j) = score of best alignment between and
Principle of Optimality Optimal alignment
Principle of Optimality Optimal alignment Looks like ……
Principle of Optimality Optimal alignment Looks like …… or ……………
Principle of Optimality Optimal alignment Looks like …… or …………… or ……………
Principle of Optimality Optimal alignment Looks like …… or …………… or …………… so ……………
Principle of Optimality Basis:
Filling up table Y F matrix 0 1 2 n 0 1 2 X m
Filling up table Y F matrix 0 1 2 n 0 1 2 X m
Filling up table Y F matrix 0 1 2 n 0 1 2 X m
Filling up table Y F matrix 0 1 2 n 0 1 2 X m
Filling up table Y F matrix 0 1 2 n 0 1 2 X m
Filling up table Y F matrix 0 1 2 n 0 1 2 X m
Filling up table Y F matrix 0 1 2 n 0 1 2 X m
Filling up table Y F matrix 0 1 2 n 0 1 2 X m
Filling up table Y F matrix 0 1 2 n 0 1 2 X m
Filling up table Y F matrix 0 1 2 n 0 1 2 X m
Filling up table Y F matrix 0 1 2 n 0 1 2 X m
Filling up table Y F matrix 0 1 2 n 0 1 2 X m
Filling up table Y F matrix 0 1 2 n 0 1 2 X m
Filling up table Y F matrix 0 1 2 n 0 1 2 Optimal alignment score X m
Constructing alignment Y F matrix 0 1 2 n 0 1 2 Optimal alignment score X m
Example Y F matrix 0 1 2 n 0 1 2 Optimal alignment score X m
Example Y F matrix 0 1 2 n 0 1 2 Optimal alignment score X m Y Alignment X
Example Y F matrix 0 1 2 n 0 1 2 Optimal alignment score X m Y Alignment X
Example Y F matrix 0 1 2 n 0 1 2 Optimal alignment score X m Y Alignment X
Example Y F matrix 0 1 2 n 0 1 2 Optimal alignment score X m Y Alignment X
Example Y F matrix 0 1 2 n 0 1 2 Optimal alignment score X m Y Alignment X
Example Y F matrix 0 1 2 n 0 1 2 Optimal alignment score X m Y Alignment X
Example Y F matrix 0 1 2 n 0 1 2 Optimal alignment score X m Y Alignment X
Example Y F matrix 0 1 2 n 0 1 2 Optimal alignment score X m Y Alignment X
Example Y F matrix 0 1 2 n 0 1 2 Optimal alignment score X m Y Alignment X
Example Y F matrix 0 1 2 n 0 1 2 Optimal alignment score X m Y Alignment X
Example Y F matrix 0 1 2 n 0 1 2 Optimal alignment score X m Y Alignment X
Time and space 0 1 2 n 0 1 2 F matrix m table entries space Each entry computed in constant time time
Smith & Waterman algorithm Computes local alignment. i.e. look for best alignment of subsequences of X and Y, ignoring scores of regions on either side Y X Best subsequence alignment
Principle of Optimality Given sequences DefineF(i,j) = score of best suffix alignment between and N.B. Includes empty alignment with score 0
Dynamic Programming recurrences Optimal alignment Looks like …… or …………… or …………… or ……………
Principle of Optimality so …… Basis: