Presentation is loading. Please wait.

Presentation is loading. Please wait.

Introduction to Sequence Alignment PENCE Bioinformatics Research Group University of Alberta May 2001.

Similar presentations


Presentation on theme: "Introduction to Sequence Alignment PENCE Bioinformatics Research Group University of Alberta May 2001."— Presentation transcript:

1

2 Introduction to Sequence Alignment PENCE Bioinformatics Research Group University of Alberta May 2001

3 ©Duane Szafron 2000 2 Outline Sequence Alignment Full Matrix Algorithms Hirschberg’s Algorithm The FastLSA Algorithm Leading and Trailing Blanks

4 ©Duane Szafron 2000 3 Sequence Alignment Sequence alignment reduces to a problem of matching two strings by introducing gaps to maximize a scoring function. The scoring function favors similar characters in the same position, penalizes dissimilar characters and penalizes gaps. AGTATGCA ATTGATA AGT-ATGCA ATTGAT--A

5 ©Duane Szafron 2000 4 +2-2+2+2-2-2+2 = 3 2 Scoring Function There are many different scoring functions. Here is a simple one suitable for illustration, but not actually used: AGT-ATGCA ATTGAT--A –Exact match: +2 points –Different characters: -1 point –Gap: -2 points

6 ©Duane Szafron 2000 5 Scoring Ties There can be several optimal alignment solutions due to scoring ties. There are actually three optimal solutions in our example alignment: AGT-ATGCA ATTGAT--A 2-1+2-2+2+2-2-2+2 = 3 AGTATG-CA A-T-TGATA 2-2+2-2+2+2-2-1+2 = 3 AGTATGC-A A-T-TGATA 2-2+2-2+2+2-1-2+2 = 3

7 ©Duane Szafron 2000 6 Alignment Algorithms The goal is to find an optimal alignment for a given scoring function as quickly as possible, using a minimum amount of storage. We will look at three different kinds of algorithms: –Full Matrix algorithms like Needleman-Wunch and Smith-Waterman –The Hirschberg Algorithm –Fast linear space alignment (FastLSA)

8 ©Duane Szafron 2000 7 Matrix Representation A matrix is used to represent all possible alignments for a pair of sequences. There is a sequence along each axis. Each path from the top left corner to the bottom right corner represents an alignment solution.

9 ©Duane Szafron 2000 8 Alignments as Matrix Paths - A G T A T G C A - A T G A T A A A G T T T - G A A T T G - C - A A

10 ©Duane Szafron 2000 9 Other Alignment Matrix Paths - A G T A T G C A - A T G A T A A A G T T T - G A A T T G - C - A A A A G - T T A - T T G G - A C T A A

11 ©Duane Szafron 2000 10 Other Alignment Matrix Paths - A G T A T G C A - A T G A T A A A G T T T - G A A T T G - C - A A A A G - T T A - T T G G C A - T A A A A G - T T A - T T G G - A C T A A

12 ©Duane Szafron 2000 11 Matrix Alignment Algorithms A matrix algorithm uses a dynamic programming matrix to find an optimal solution. There are two phases to the algorithms: –FindScore –FindPath

13 ©Duane Szafron 2000 12 FindScore Description The FindScore phase applies the scoring matrix to all paths from the upper left to the lower right. Values are propagated left-to-right, from top-to-bottom. At the end, the lower right corner is the optimal score.

14 ©Duane Szafron 2000 13 FindScore Example -2 0 AGTATGCA- A T T G A T A - -4-6 -4-6 +2 -4 -2+20-2 -3 0 -6-5 -2 -8-4 -6 -10-11-12-13-14-12-16-18 -8-10-12-4 -9 -6-8-10-12 -8-10-12-14-16-8-10-12-14-16 -40-2-4-6-8-10-12-14-3+1+2-3-2-7-9-11 -40+1+20-2-4-6-8-6-20-2-4-6-8 -6-20-2-4-6-8-10-5+3+1+2-3-5-7 -8-4-3+10-2-4-6-70-2+20+4-3 -10-6-20-2+20-2-6-5+3+1+3+4 -12-8-4-3+10+1+2-11-70-2+50+1+2 -14-10-6-2+3+10-10-9-5+20+4+2+3 -6-2+3+1+20-2-4 -3+10-2-4 -8-40+1+20+4+20-10-6-20-2+20 -10-6-2+3+1+2+3+4-12-8-4-3+10+1 -12-8-40+1+5+3+1+2-14-10-6-2+3+1 -14-10-6-2+20+4+23-16-12-8-40-2+20

15 ©Duane Szafron 2000 14 FindPath Description The FindPath phase starts in the lower right corner. At each box, a direction is picked: up, left or diagonal based on the highest score that entered the box from those three directions. If two (or three) directions have equal scores both (all) are optimal paths.

16 ©Duane Szafron 2000 15 FindPath Example -2 0 AGTATGCA- A T T G A T A - -4-6 -4-6 +2 -4 -2+20-2 -3 0 -6-5 -2 -8-4 -6 -10-11-12-13-14-12-16-18 -8-10-12-4 -9 -6-8-10-12 -8-10-12-14-16-8-10-12-14-16 -40-2-4-6-8-10-12-14-3+1+2-3-2-7-9-11 -40+1+20-2-4-6-8-6-20-2-4-6-8 -6-20-2-4-6-8-10-5+3+1+2-3-5-7 -8-4-3+10-2-4-6-70-2+20+4-3 -10-6-20-2+20-2-6-5+3+1+3+4 -12-8-4-3+10+1+2-11-70-2+50+1+2 -14-10-6-2+3+10-10-9-5+20+4+2+3 -6-2+3+1+20-2-4 -3+10-2-4 -8-40+1+20+4+20-10-6-20-2+20 -10-6-2+3+1+2+3+4-12-8-4-3+10+1 -12-8-40+1+5+3+1+2-14-10-6-2+3+1 -14-10-6-2+20+4+23-16-12-8-40-2+20

17 ©Duane Szafron 2000 16 Cost of Full Matrix Algorithms A full matrix algorithm maintains the entire matrix in memory during both phases (FindScore and FindPath) of the algorithm. For sequences of length n and m, this takes nxm entries in memory. FindScore takes nxm operations (time). FindPath takes m+n operations (time). If we want to align two sequences of length 10,000, the storage space is prohibitive (100,000,000 entries).

18 ©Duane Szafron 2000 17 The Hirschberg Algorithm - 1 The Hirschberg algorithm is designed to take less space, but find the same optimal solutions. It splits one sequence into two and performs the FindScore algorithm on each half, working backwards on the second half sequence. It does not store all of the results in memory, just the current row of each half matrix (2xn entries instead of mxn entries).

19 ©Duane Szafron 2000 18 Hirschberg’s Algorithm At the end of the two FindScore computations, the final rows of each half matrix are used to find the optimal “crossing-point” of the two “half- alignments”. The complete algorithm is then called again on the two pairs of half sequences. This recursion continues until the lengths of the sequences being aligned is 1.

20 ©Duane Szafron 2000 19 Hirschberg FindScore Example AGTATGCA- A T T G A T A - - - -2 0 -4-6 -4-6 -8-10-12-14-16 +2-4 -3-6 0 -5-8 -2 +2-20-4-6-8-10-12-8-4-3+10+1+20

21 ©Duane Szafron 2000 20 Hirschberg FindScore Example AGTATGCA- A T T G A T A - - - -8-4-3+10+1+20 0 -2-4 -2-4 -6-8-10-12-14-16 -6+3-2+1+20-2-4 -600+30 -3-6-12+3

22 ©Duane Szafron 2000 21 ATGCA GATA GCA GATA GCA GATA ATT AGT ATT AGTAT ATT AGTAT Hirschberg Example Sub-problems There are two optimal splits of the sequences, colored pink and blue. However, the blue split generates two different optimal solutions, blue and white. GAT--A -ATGCA A-T-T AGTATG-CA GATA GC-A GATA ATT AGT A-T-T AGTAT

23 ©Duane Szafron 2000 22 Hirschberg Recursion

24 ©Duane Szafron 2000 23 Hirschberg’s Algorithm Hirschberg’s algorithm takes only linear space - 2xn, instead of quadratic space - mxn. This means that aligning two sequences of length 10,000 would only require 20,000 entries instead of 100,000,000 entries. The disadvantage of this algorithm is that the time goes from mxn operations to about 2xmxn operations since many matrix computations must be redone.

25 ©Duane Szafron 2000 24 FastLSA Idea FastLSA improves Hirschberg by reducing the number of re-computations that need to be done. This makes the algorithm faster. There are three improvements to reduce computations: –Sequences are split on both axes, not just one. –Sequences are not just bisected, they are cut into several smaller pieces. –Scores on splitting lines are maintained.

26 ©Duane Szafron 2000 25 FastLSA - Algorithm Each sequences is split on both axes. FindScore is called on a region consisting of 3 quadrants (excluding the lower right). Scores are kept only on the bisecting lines. FastLSA is called recursively on the lower right quadrant and the optimal path is eventually returned for this quadrant. Recursive calls are made on part of 1 or 2 of the other 3 quadrants, depending on the path returned from the lower right quadrant.

27 ©Duane Szafron 2000 26 FastLSA - Stopping the Recursion When a block has size u*v < some B, stop the recursion and apply a full matrix algorithm to solve the block.

28 ©Duane Szafron 2000 27 FastLSA - Using Bisection FastLSA(DPM,rs,re,cs,ce) if ((re-rs)*(ce-cs) < B) FullMatrix(DPM,rs,re,cs,ce); return; else rm = (rs+re)/2; cm = (cs+ce)/2; FindScores(DPM,rs,rm,re,cs,cm,ce); FastLSA(DPM,rm,re,cm,ce); if (direction == diagonal) FastLSA(rs,rm,cs,cm) else if (direction == side) re = path.end.row; FastLSA(rm,re,cs,cm); if (direction == up) ce = path.end.column; FastLSA(rs,rm,cs,ce) else // direction == up ce = path.end.column; FastLSA(rs,rm,cm,ce); if (direction == side) re = path.end.row; FastLSA(rs,re,cs,cm); 1 1 1 1 2 2 2 2 3 33 2 3 E 2 4 44 4 E 2 2 5 55 5 E 2 2 2 E 1 1 1 6 6 6 6 7 77 7 E 6 6 6 8 88 8 E 6 6 E 1 1 1 9 9 9 9 10 10E 9 9 11 11E 9E 1E 1 269354781011

29 ©Duane Szafron 2000 28 FastLSA - cuts (k) = 4

30 ©Duane Szafron 2000 29 Using FastLSA If you don’t have enough memory to run a full-matrix algorithm, use FastLSA and pick your k-value based on your available memory. It will run faster than Hirschberg’s algorithm.

31 ©Duane Szafron 2000 30 Aligning Sub-sequences Sometimes you are trying to align a sub- sequence with a large sequence. In this case there should many leading and trailing gaps. AGATCTGATCGTAAGTCATTCGCATAATGCGT ----------GTACGTC--------------- AGATCTGATCGTAAGTCATTCGCATAATGCGT ----------GTA---C----G--T----C--... Score = 25*(-2) + 1*(-1) + 6*2 = -39 Score = 25*(-2) + 7*2 = -36

32 ©Duane Szafron 2000 31 Leading and Trailing Gaps To score this properly, we assign zero penalties to leading and trailing gaps. AGATCTGATCGTAAGTCATTCGCATAATGCGT ----------GTACGTC--------------- AGATCTGATCGTAAGTCATTCGCATAATGCGT ----------GTA---C----G--T----C--... Score = 25*(0) + 1*(-1) + 6*2 = 11 Score = 12*(0) 13*(-2) + 7*2 = -8

33 ©Duane Szafron 2000 32 Implementing Leading Gaps 0 0 0 AGTATGCA- A T T G A T A - 000 00 +2 0 -2 0+20 0 -2 -2 +2 0 -2-2-2+2-2 -3 +2 0 -3+2 0000000000 00-2-30-2-3 0+1+2-2+4-2 00+1+20+4+20-2 0-2+20-2 0 0-2+20-2-4 +3+1+2+3+1 0-4-3+10+1-30-2+20+4+20 0-6-20-2+20-2+2-5+3+1+3+4 00-2-3+10+1+2+1+2+50+1+2 0-20 +3+10+20+40 +2+3 0-2+3+1+2+3+1-2-4-3+10+1 0-40+1+20+4+20-2-6-20-2+20 0 0+3+1+2+3+4-20 -3+10+1 00 +2+1+5+3+1+2-2 0 +3+1 0+200+4+3+4+23-20 +2+1+20

34 ©Duane Szafron 2000 33 New optimal path - same score 3 0 0 0 AGTATGCA- A T T G A T A - 000 00 +2 0 -2 0+20 0 -2 -2 +2 0 -2-2-2+2-2 -3 +2 0 -3+2 0000000000 00-2-30-2-3 0+1+2-2+4-2 00+1+20+4+20-2 0-2+20-2 0 0-2+20-2-4 +3+1+2+3+1 0-4-3+10+1-30-2+20+4+20 0-6-20-2+20-2+2-5+3+1+3+4 00-2-3+10+1+2+1+2+50+1+2 0-20 +3+10+20+40 +2+3 0-2+3+1+2+3+1-2-4-3+10+1 0-40+1+20+4+20-2-6-20-2+20 0 0+3+1+2+3+4-20 -3+10+1 00 +2+1+5+3+1+2-2 0 +3+1 0+200+4+3+4+23-20 +2+1+20 A - G - T - A A T T - T G G C A - T A A

35 ©Duane Szafron 2000 34 Implementing trailing Gaps 0 0 0 AGTATGCA- A T T G A T A - 000 00 +2 0 -2 0+20 0 -2 -2 +2 0 -2-2-2+2-20 -3 +2 0 -3+2 0000000000 00-2-30-2-3 +2+1+2-2+4-2 00+1+20+4+20 -2 0-2+20-2 0 0-2+20-2+2 +3+1+2+3+1 0-4-3+10+1+20-2+20+4+20 0-6-20-2+20 -5+3+1+3+4 00-2-3+10+1+4+1+2+50+1+2 0-20 +3+1+4+20+40 +2+3 0-2+3+1+2+3+1+2-2-4-3+10+1 0-40+1+20+4+2 -2-6-20-2+20 0 0+3+1+2+3+4-20 -3+10+1 00 +2+1+5+3+1+4-2 0 +3+1 0+2 +4 0+2 +4

36 ©Duane Szafron 2000 35 New optimal paths - new score 4 0 0 0 AGTATGCA- A T T G A T A - 000 00 +2 0 -2 0+20 0 -2 -2 +2 0 -2-2-2+2-20 -3 +2 0 -3+2 0000000000 00-2-30-2-3 +2+1+2-2+4-2 00+1+20+4+20 -2 0-2+20-2 0 0-2+20-2+2 +3+1+2+3+1 0-4-3+10+1+20-2+20+4+20 0-6-20-2+20 -5+3+1+3+4 00-2-3+10+1+4+1+2+50+1+2 0-20 +3+1+4+20+40 +2+3 0-2+3+1+2+3+1+2-2-4-3+10+1 0-40+1+20+4+2 -2-6-20-2+20 0 0+3+1+2+3+4-20 -3+10+1 00 +2+1+5+3+1+4-2 0 +3+1 0+2 +4 0+2 +4 A - G - T - A A T T G T C G A A - T - A - A - T - T - G A A G - T T A A T - G - C - A -


Download ppt "Introduction to Sequence Alignment PENCE Bioinformatics Research Group University of Alberta May 2001."

Similar presentations


Ads by Google