Using Dynamic Programming To Align Sequences

Slides:



Advertisements
Similar presentations
Sequence Alignments with Indels Evolution produces insertions and deletions (indels) – In addition to substitutions Good example: MHHNALQRRTVWVNAY MHHALQRRTVWVNAY-
Advertisements

Eugene W.Myers and Webb Miller. Outline Introduction Gotoh's algorithm O(N) space Gotoh's algorithm Main algorithm Implementation Conclusion.
Hidden Markov Models (1)  Brief review of discrete time finite Markov Chain  Hidden Markov Model  Examples of HMM in Bioinformatics  Estimations Basic.
Alignment methods Introduction to global and local sequence alignment methods Global : Needleman-Wunch Local : Smith-Waterman Database Search BLAST FASTA.
C E N T R F O R I N T E G R A T I V E B I O I N F O R M A T I C S V U E Alignments 1 Sequence Analysis.
S. Maarschalkerweerd & A. Tjhang1 Probability Theory and Basic Alignment of String Sequences Chapter
Space Efficient Alignment Algorithms and Affine Gap Penalties
Space Efficient Alignment Algorithms Dr. Nancy Warter-Perez June 24, 2005.
Sequence Alignment Algorithms in Computational Biology Spring 2006 Edited by Itai Sharon Most slides have been created and edited by Nir Friedman, Dan.
CS 5263 Bioinformatics Lecture 5: Affine Gap Penalties.
1-month Practical Course Genome Analysis (Integrative Bioinformatics & Genomics) Lecture 3: Pair-wise alignment Centre for Integrative Bioinformatics VU.
Developing Pairwise Sequence Alignment Algorithms Dr. Nancy Warter-Perez.
Developing Pairwise Sequence Alignment Algorithms Dr. Nancy Warter-Perez June 23, 2005.
Expected accuracy sequence alignment
Alignment methods and database searching April 14, 2005 Quiz#1 today Learning objectives- Finish Dotter Program analysis. Understand how to use the program.
Developing Pairwise Sequence Alignment Algorithms Dr. Nancy Warter-Perez June 23, 2004.
Sequence Alignment Oct 9, 2002 Joon Lee Genomics & Computational Biology.
Developing Pairwise Sequence Alignment Algorithms Dr. Nancy Warter-Perez May 20, 2003.
BNFO 602 Multiple sequence alignment Usman Roshan.
Finding the optimal pairwise alignment We are interested in finding the alignment of two sequences that maximizes the similarity score given an arbitrary.
Alignment II Dynamic Programming
Dynamic Programming. Pairwise Alignment Needleman - Wunsch Global Alignment Smith - Waterman Local Alignment.
Developing Pairwise Sequence Alignment Algorithms Dr. Nancy Warter-Perez May 10, 2005.
Pairwise alignment Computational Genomics and Proteomics.
FA05CSE182 CSE 182-L2:Blast & variants I Dynamic Programming
Class 2: Basic Sequence Alignment
LCS and Extensions to Global and Local Alignment Dr. Nancy Warter-Perez June 26, 2003.
TM Biological Sequence Comparison / Database Homology Searching Aoife McLysaght Summer Intern, Compaq Computer Corporation Ballybrit Business Park, Galway,
Developing Pairwise Sequence Alignment Algorithms
Bioiformatics I Fall Dynamic programming algorithm: pairwise comparisons.
CS 5263 Bioinformatics Lecture 4: Global Sequence Alignment Algorithms.
Pair-wise Sequence Alignment What happened to the sequences of similar genes? random mutation deletion, insertion Seq. 1: 515 EVIRMQDNNPFSFQSDVYSYG EVI.
Pairwise alignments Introduction Introduction Why do alignments? Why do alignments? Definitions Definitions Scoring alignments Scoring alignments Alignment.
Dynamic Programming. Well known algorithm design techniques:. –Divide-and-conquer algorithms Another strategy for designing algorithms is dynamic programming.
Pairwise Sequence Alignment BMI/CS 776 Mark Craven January 2002.
Cédric Notredame (19/10/2015) Using Dynamic Programming To Align Sequences Cédric Notredame.
Lecture 6. Pairwise Local Alignment and Database Search Csc 487/687 Computing for bioinformatics.
CS 5263 Bioinformatics Lecture 6: Sequence Alignment Statistics.
Expected accuracy sequence alignment Usman Roshan.
Sequence Alignments with Indels Evolution produces insertions and deletions (indels) – In addition to substitutions Good example: MHHNALQRRTVWVNAY MHHALQRRTVWVNAY-
Sequence Alignment Tanya Berger-Wolf CS502: Algorithms in Computational Biology January 25, 2011.
Space Efficient Alignment Algorithms and Affine Gap Penalties Dr. Nancy Warter-Perez.
Pairwise sequence alignment Lecture 02. Overview  Sequence comparison lies at the heart of bioinformatics analysis.  It is the first step towards structural.
DNA, RNA and protein are an alien language
Pairwise Sequence Alignment (cont.) (Lecture for CS397-CXZ Algorithms in Bioinformatics) Feb. 4, 2004 ChengXiang Zhai Department of Computer Science University.
Dynamic programming with more complex models When gaps do occur, they are often longer than one residue.(biology) We can still use all the dynamic programming.
4.2 - Algorithms Sébastien Lemieux Elitra Canada Ltd.
Learning to Align: a Statistical Approach
CS502: Algorithms in Computational Biology
Pairwise sequence comparison
INTRODUCTION TO BIOINFORMATICS
Introduction to Dynamic Programming
The ideal approach is simultaneous alignment and tree estimation.
Sequence comparison: Local alignment
Biology 162 Computational Genetics Todd Vision Fall Aug 2004
Lecture 5: Local Sequence Alignment Algorithms
Introduction to bioinformatics 2007
Global, local, repeated and overlaping
Sequence Alignment 11/24/2018.
SMA5422: Special Topics in Biotechnology
Pairwise sequence Alignment.
#7 Still more DP, Scoring Matrices
Intro to Alignment Algorithms: Global and Local
Lecture 14 Algorithm Analysis
BCB 444/544 Lecture 7 #7_Sept5 Global vs Local Alignment
Pairwise Alignment Global & local alignment
Sequence Alignment Algorithms Morten Nielsen BioSys, DTU
A T C.
Sequence Alignment Tutorial #2
Dynamic Programming.
Presentation transcript:

Using Dynamic Programming To Align Sequences Cédric Notredame

Our Scope Understanding the DP concept Coding a Global and a Local Algorithm Aligning with Affine gap penalties Saving memory Sophisticated variants…

Outline -Coding Dynamic Programming with Non-affine Penalties -Turning a global algorithm into a local Algorithm -Adding affine penalties -Using A Divide and conquer Strategy -Tailoring DP to your needs: -The repeated Matches Algorithm -Double Dynamic Programming

Global Alignments Without Affine Gap penalties Dynamic Programming

How To align Two Sequences With a Gap Penalty, A Substitution matrix and Not too Much Time Dynamic Programming

A bit of History… -DP invented in the 50s by Bellman -Programming  Tabulation -Re-invented in 1970 by Needlman and Wunsch -It took 10 year to find out…

The Foolish Assumption The score of each column of the alignment is independent from the rest of the alignment It is possible to model the relationship between two sequences with: -A substitution matrix -A simple gap penalty

The Principle of DP If you extend optimally an optimal alignment of two sub-sequences, the result remains an optimal alignment X-XX XXXX X - Deletion Alignment Insertion ? +

Finding the score of i,j -Sequence 1: [1-i] -Sequence 2: [1-j] -The optimal alignment of [1-i] vs [1-j] can finish in three different manners: - X X X -

Finding the score of i,j + + + 1…i 1…j-1 - j Three ways to build the alignment 1…i 1…j 1…i-1 1…j-1 i j + 1…i-1 1…j i - +

Finding the score of i,j 1…i 1…j In order to Compute the score of All we need are the scores of: 1…i-1 1…j 1…i-1 1…j-1 1…i 1…j-1

Formalizing the algorithm 1…j-1 - X + F(i,j-1) + Gep 1…i-1 1…j-1 X F(i,j)= best F(i-1,j-1) + Mat[i,j] + F(i-1,j) + Gep 1…i-1 1…j X - +

Arranging Everything in a Table - F A S T 1…I-1 1…J-1 1…I 1…J-1 1…I-1 1…J 1…I 1…J

Taking Care of the Limits The DP strategy relies on the idea that ALL the cells in your table have the same environment… This is NOT true of ALL the cells!!!! In a Dynamic Programming strategy, the most delicate part is to take care of the limits: -what happens when you start -what happens when you finish

Taking Care of the Limits -1 F - -2 FA -- -3 FAT --- - F A T - -1 F - F -2 FA -- A -3 FAS --- S Match=2 MisMatch=-1 Gap=-1 T -4

Filing Up The Matrix

- F A S T -1 -2 -3 -4 -2 +2 -3 -2 +1 -4 -3 +1 -2 -3 +4 -1 +3 -3 -4 +3 -2 +2 -3 -2 +1 -4 -3 +1 -2 -3 +4 -1 +3 -3 -4 +3 -1 +2 +3 -1 -4 -5 +2 -1 -2 +2 +5 +1

Delivering the alignment: Trace-back F S - A T Score of 1…3 Vs 1…4  Optimal Aln Score

Trace-back: possible implementation

Local Alignments Without Affine Gap penalties Smith and Waterman

Getting rid of the pieces of Junk between the interesting bits Smith and Waterman

The Smith and Waterman Algorithm F(i-1,j) + Gep F(i-1,j-1) + Mat[i,j] F(i,j-1) + Gep X - 1…i 1…j-1 1…i-1 1…j + F(i,j)= best

The Smith and Waterman Algorithm F(i-1,j) + Gep F(i-1,j-1) + Mat[i,j] F(i,j-1) + Gep F(i,j)= best

The Smith and Waterman Algorithm  Ignore The rest of the Matrix Terminate a local Aln

Filing Up a SW Matrix

Filling up a SW matrix: borders * - A N I C E C A T - 0 0 0 0 0 0 0 0 0 C 0 A 0 T 0 A 0 N 0 D 0 O 0 G 0 Easy: Local alignments NEVER start/end with a gap…

Beginning of the trace-back Filling up a SW matrix * - A N I C E C A T - 0 0 0 0 0 0 0 0 0 C 0 0 0 0 2 0 2 0 0 A 0 2 0 0 0 0 0 4 0 T 0 0 0 0 0 0 0 2 6 A 0 2 0 0 0 0 0 0 4 N 0 0 4 2 0 0 0 0 2 D 0 0 2 2 0 0 0 0 0 O 0 0 0 0 0 0 0 0 0 G 0 0 0 0 0 0 0 0 0 Best Local score  Beginning of the trace-back

Turning NW into SW Prepare Trace back

A few things to remember SW only works if the substitution matrix has been normalized to give a Negative score to a random alignment. Chance should not pay when it comes to local alignments !

More than One match… -SW delivers only the best scoring Match If you need more than one match: SIM (Huang and Millers) Or Waterman and Eggert (Durbin, p91)

Waterman and Eggert Iterative algorithm: 1-identify the best match 2-redo SW with used pairs forbidden 3-finish when the last interesting local extracted Delivers a collection of non-overlapping local alignments Avoid trivial variations of the optimal.

Adding Affine Gap Penalties The Gotoh Algorithm

Forcing a bit of Biology into your alignment The Gotoh Formulation

Why Affine gap Penalties are Biologically better Cost L Afine Gap Penalty GOP GEP GOP GOP Cost=gop+L*gep Or Cost=gop+(L-1)*gep Parsimony: Evolution takes the simplest path (So We Think…)

But Harder To compute… + More Than 3 Ways to extend an Alignment ? Opening Extension X - Deletion X-XX XXXX X Alignment - X Insertion

More Questions Need to be asked For instance, what is the cost of an insertion ? 1…I-1 ??X 1…J-1 ??X 1…I ??- 1…J-1 ??X GEP GOP 1…I ??- 1…J ??X

Solution:Maintain 3 Tables Ix: Table that contains the score of every optimal alignment 1…i vs 1…j that finishes with an Insertion in sequence X. Iy: Table that contains the score of every optimal alignment 1…I vs 1…J that finishes with an Insertion in sequence Y. M: Table that contains the score of every optimal alignment 1…I vs 1…J that finishes with an alignment between sequence X and Y

+ The Algorithm M(i,j)= best M(i-1,j-1) + Mat(i,j) X 1…i-1 1…j-1 Ix(i-1,j-1) + Mat(i,j) Iy(i-1,j-1) + Mat(i,j) X - 1…i-1 X 1…j X + Ix(i,j)= best M(i-1,j) + gop Ix(i-1,j) + gep 1…j - - X 1…i X 1…j-1 X + Iy(i,j)= best M(i,j-1) + gop Iy(i,j-1) + gep 1…i -

Trace-back? Ix M Iy M(i,j) Start From BEST Ix(i,j) Iy(i,j)

Trace-back? Ix M Iy Navigate from one table to the next, knowing that a gap always finishes with an aligned column…

Going Further ? With the affine gap penalties, we have increased the number of possibilities when building our alignment. CS talk of states and represent this as a Finite State Automaton (FSA are HMM cousins)

Going Further ?

Going Further ? In Theory, there is no Limit on the number of states one may consider when doing such a computation.

Going Further ? Imagine a pairwise alignment algorithm where the gap penalty depends on the length of the gap. Can you simplify it realistically so that it can be efficiently implemented?

Lx Ly

A divide and Conquer Strategy The Myers and Miller Strategy

Remember Not To Run Out of Memory The Myers and Miller Strategy

A Score in Linear Space You never Need More Than The Previous Row To Compute the optimal score

A Score in Linear Space For I For J R2[i][j]=best R1 R2[j-1], +gep R2 For J, R1[j]=R2[j] R1 R2[j-1], +gep R1[j-1]+mat R1[j]+gep R2

A Score in Linear Space

A Score in Linear Space Or do you ???? You never Need More Than The Previous Row To Compute the optimal score You only need the matrix for the Trace-Back, Or do you ????

An Alignment in Linear Space Forward Algorithm F(i,j)=Optimal score of 0…i Vs 0…j Backward algorithm B(i,j)=Optimal score of M…i Vs N…j B(i,j)+F(i,j)=Optimal score of the alignment that passes through pair i,j

An Alignment in Linear Space Forward Algorithm Forward Algorithm Backward algorithm Backward algorithm Optimal B(i,j)+F(i,j)

An Alignment in Linear Space Forward Algorithm Backward algorithm Recursive divide and conquer strategy: Myers and Miller (Durbin p35)

An Alignment in Linear Space

A Forward-only Strategy(Durbin, p35) Forward Algorithm M -Keep Row M in memory -Keep track of which Cell in Row M lead to the optimal score -Divide on this cell

M M

An interesting application: finding sub-optimal alignments Forward Algorithm Forward Algorithm Backward algorithm Backward algorithm Sum over the Forw/Bward and identify the score of the best aln going through cell i,j

Application: Non-local models Double Dynamic Programming

Outline The main limitation of DP: Context independent measure

Double Dynamic Programming High Level Smith and Waterman Dynamic Programming Score=Max S(i-1, j-1)+RMSd score S(i, j-1)+gp { RMSd Score Rigid Body Superposition where i and j are forced together 1 14 1 13 13 12 5 8 9

Double Dynamic Programming

Application: Repeats The Durbin Algorithm

In The End: Wraping it Up

Dynamic Programming Needleman and Wunsch: Delivers the best scoring global alignment Smith and Waterman: NW with an extra state 0 Affine Gap Penalties: Making DP more realistic

Dynamic Programming Linear space: Using Divide and Conquer Strategies Not to run out of memory Double Dynamic Programming, repeat extraction: DP can easily be adapted to a special need