. Sequence Alignment I Lecture #2 This class has been edited from Nir Friedman’s lecture which is available at www.cs.huji.ac.il/~nir. Changes made by.

Slides:



Advertisements
Similar presentations
Sequence Alignment I Lecture #2
Advertisements

. Computational Genomics Lecture #2 This class has been edited from Nir Friedman’s lecture which is available at Changes made by.
. Sequence Alignment III Lecture #4 This class has been edited from Nir Friedman’s lecture which is available at Changes made by.
Sequence Alignment Tutorial #2
Inexact Matching of Strings General Problem –Input Strings S and T –Questions How distant is S from T? How similar is S to T? Solution Technique –Dynamic.
. EM algorithm and applications Lecture #9 Background Readings: Chapters 11.2, 11.6 in the text book, Biological Sequence Analysis, Durbin et al., 2001.
Lecture 6, Thursday April 17, 2003
Sequence Alignment Tutorial #2
UNIVERSITY OF SOUTH CAROLINA College of Engineering & Information Technology Bioinformatics Algorithms and Data Structures Chapter 12: Refining Core String.
Sequence Alignment Storing, retrieving and comparing DNA sequences in Databases. Comparing two or more sequences for similarities. Searching databases.
Heuristic alignment algorithms and cost matrices
Space Efficient Alignment Algorithms and Affine Gap Penalties
. Hidden Markov Model Lecture #6 Background Readings: Chapters 3.1, 3.2 in the text book, Biological Sequence Analysis, Durbin et al., 2001.
Sequence Alignment Algorithms in Computational Biology Spring 2006 Edited by Itai Sharon Most slides have been created and edited by Nir Friedman, Dan.
. Sequence Alignment via HMM Background Readings: chapters 3.4, 3.5, 4, in the Durbin et al.
. Hidden Markov Model Lecture #6 Background Readings: Chapters 3.1, 3.2 in the text book, Biological Sequence Analysis, Durbin et al., 2001.
Computational Genomics Lecture #3a Much of this class has been edited from Nir Friedman’s lecture which is available at Changes.
Reminder -Structure of a genome Human 3x10 9 bp Genome: ~30,000 genes ~200,000 exons ~23 Mb coding ~15 Mb noncoding pre-mRNA transcription splicing translation.
Sequence Alignment Variations Computing alignments using only O(m) space rather than O(mn) space. Computing alignments with bounded difference Exclusion.
. Computational Genomics Lecture #2 This class has been edited from Nir Friedman’s lecture which is available at Changes made by.
Defining Scoring Functions, Multiple Sequence Alignment Lecture #4
Introduction To Bioinformatics Tutorial 2. Local Alignment Tutorial 2.
Dynamic Programming and Biological Sequence Comparison Part I.
Alignment methods June 26, 2007 Learning objectives- Understand how Global alignment program works. Understand how Local alignment program works.
. Computational Genomics Lecture #3a (revised 24/3/09) This class has been edited from Nir Friedman’s lecture which is available at
Class 3: Estimating Scoring Rules for Sequence Alignment.
. Sequence Alignment Tutorial #3 © Ydo Wexler & Dan Geiger.
. Sequence Alignment II Lecture #3 This class has been edited from Nir Friedman’s lecture. Changes made by Dan Geiger, then by Shlomo Moran. Background.
Sequence similarity. Motivation Same gene, or similar gene Suffix of A similar to prefix of B? Suffix of A similar to prefix of B..Z? Longest similar.
. Computational Genomics Lecture #2 This class has been edited from Nir Friedman’s lecture which is available at Changes made by.
Class 2: Basic Sequence Alignment
. Sequence Alignment I Lecture #2 This class has been edited from Nir Friedman’s lecture. Changes made by Dan Geiger, then Shlomo Moran. Background Readings:
. Pairwise and Multiple Alignment Lecture #4 This class has been edited from Nir Friedman’s lecture which is available at Changes.
. Sequence Alignment II Lecture #3 This class has been edited from Nir Friedman’s lecture which is available at Changes made by.
. Sequence Alignment II Lecture #3 This class has been edited from Nir Friedman’s lecture which is available at Changes made by.
. Sequence Alignment II Lecture #3 This class has been edited from Nir Friedman’s lecture. Changes made by Dan Geiger, then by Shlomo Moran. Background.
Alignment Statistics and Substitution Matrices BMI/CS 576 Colin Dewey Fall 2010.
Pairwise alignments Introduction Introduction Why do alignments? Why do alignments? Definitions Definitions Scoring alignments Scoring alignments Alignment.
. EM with Many Random Variables Another Example of EM Sequence Alignment via HMM Lecture # 10 This class has been edited from Nir Friedman’s lecture. Changes.
Pairwise Sequence Alignment. The most important class of bioinformatics tools – pairwise alignment of DNA and protein seqs. alignment 1alignment 2 Seq.
Pairwise Sequence Alignment (II) (Lecture for CS498-CXZ Algorithms in Bioinformatics) Sept. 27, 2005 ChengXiang Zhai Department of Computer Science University.
. Sequence Alignment. Sequences Much of bioinformatics involves sequences u DNA sequences u RNA sequences u Protein sequences We can think of these sequences.
Pairwise Sequence Alignment BMI/CS 776 Mark Craven January 2002.
Sequence Analysis CSC 487/687 Introduction to computing for Bioinformatics.
Alignment, Part I Vasileios Hatzivassiloglou University of Texas at Dallas.
Chapter 3 Computational Molecular Biology Michael Smith
1 CPSC 320: Intermediate Algorithm Design and Analysis July 28, 2014.
. Correctness proof of EM Variants of HMM Sequence Alignment via HMM Lecture # 10 This class has been edited from Nir Friedman’s lecture. Changes made.
BLAST: Basic Local Alignment Search Tool Altschul et al. J. Mol Bio CS 466 Saurabh Sinha.
1 Sequence Alignment Input: two sequences over the same alphabet Output: an alignment of the two sequences Example: u GCGCATGGATTGAGCGA u TGCGCCATTGATGACCA.
. Fasta, Blast, Probabilities. 2 Reminder u Last classes we discussed dynamic programming algorithms for l global alignment l local alignment l Multiple.
Intro to Alignment Algorithms: Global and Local Intro to Alignment Algorithms: Global and Local Algorithmic Functions of Computational Biology Professor.
. Sequence Alignment. Sequences Much of bioinformatics involves sequences u DNA sequences u RNA sequences u Protein sequences We can think of these sequences.
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.
Sequence Alignment.
The statistics of pairwise alignment BMI/CS 576 Colin Dewey Fall 2015.
Multiple Sequence Alignment Vasileios Hatzivassiloglou University of Texas at Dallas.
. Sequence Alignment Author:- Aya Osama Supervision:- Dr.Noha khalifa.
Introduction to Sequence Alignment. Why Align Sequences? Find homology within the same species Find clues to gene function Practical issues in experiments.
Core String Edits, Alignments, and Dynamic Programming.
4.2 - Algorithms Sébastien Lemieux Elitra Canada Ltd.
1 Sequence Alignment -AGGCTATCACCTGACCTCCAGGCCGA--TGCCC--- TAG-CTATCAC--GACCGC--GGTCGATTTGCCCGAC Definition Given two strings x = x 1 x 2...x M, y = y.
Sequence Alignment ..
Intro to Alignment Algorithms: Global and Local
Bioinformatics Algorithms and Data Structures
Computational Genomics Lecture #3a
Hidden Markov Model Lecture #6
Sequence Alignment Tutorial #2
Presentation transcript:

. Sequence Alignment I Lecture #2 This class has been edited from Nir Friedman’s lecture which is available at Changes made by Dan Geiger, then Shlomo Moran. Background Readings: The second chapter (pages 12-45) in the text book, Biological Sequence Analysis, Durbin et al., 2001.

2 Sequence Comparison Much of bioinformatics involves sequences u DNA sequences u RNA sequences u Protein sequences We can think of these sequences as strings of letters u DNA & RNA: alphabet ∑ of 4 letters u Protein: alphabet ∑ of 20 letters

3 Sequence Comparison (cont) u Finding similarity between sequences is important for many biological questions For example: u Find similar proteins  Allows to predict function & structure u Locate similar subsequences in DNA  Allows to identify (e.g) regulatory elements u Locate DNA sequences that might overlap  Helps in sequence assembly g1g1 g2g2

4 Sequence Alignment Input: two sequences over the same alphabet Output: an alignment of the two sequences Example: u GCGCATGGATTGAGCGA u TGCGCCATTGATGACCA A possible alignment: -GCGC-ATGGATTGAGCGA TGCGCCATTGAT-GACC-A

5 Alignments -GCGC-ATGGATTGAGCGA TGCGCCATTGAT-GACC-A Three elements: u Perfect matches u Mismatches u Insertions & deletions (indel)

6 Choosing Alignments There are many possible alignments For example, compare: -GCGC-ATGGATTGAGCGA TGCGCCATTGAT-GACC-A to GCGCATGGATTGAGCGA TGCGCC----ATTGATGACCA-- Which one is better?

7 Scoring Alignments Intuition: u Similar sequences evolved from a common ancestor u Evolution changed the sequences from this ancestral sequence by mutations:  Replacements: one letter replaced by another  Deletion: deletion of a letter  Insertion: insertion of a letter u Scoring of sequence similarity should examine how many and which operations took place

8 Simple Scoring Rule Score each position independently: u Match: +1 u Mismatch: -1 u Indel -2 Score of an alignment is sum of position scores

9 Example Example: -GCGC-ATGGATTGAGCGA TGCGCCATTGAT-GACC-A Score: (+1x13) + (-1x2) + (-2x4) = GCGCATGGATTGAGCGA TGCGCC----ATTGATGACCA-- Score: (+1x5) + (-1x6) + (-2x11) = -23

10 More General Scores u The choice of +1,-1, and -2 scores is quite arbitrary u Depending on the context, some changes are more plausible than others  Exchange of an amino-acid by one with similar properties (size, charge, etc.) vs.  Exchange of an amino-acid by one with opposite properties u Probabilistic interpretation: (e.g.) How likely is one alignment versus another ?

11 Additive Scoring Rules u We define a scoring function by specifying a function  (x,y) is the score of replacing x by y  (x,-) is the score of deleting x  (-,x) is the score of inserting x u The score of an alignment is the sum of position scores

12 The Optimal Score  The optimal (maximal) score between two sequences is the maximal score of all alignments of these sequences, namely, u Computing the maximal score or actually finding an alignment that yields the maximal score are closely related tasks with similar algorithms. u We now address these problems.

13 Computing Optimal Score u How can we compute the optimal score ?  If | s | = n and | t | = m, the number A( m,n ) of possible “legal” alignments is large! Exercise: Show that u The additive form of the score allows us to perform dynamic programming to compute optimal score efficiently.

14 Recursive Argument  Suppose we have two sequences: s[1..n+1] and t[1..m+1] The best alignment must be one of three cases: 1. Last match is ( s[n+1],t[m +1] ) 2. Last match is ( s[n +1], - ) 3. Last match is ( -, t[m +1] )

15 Recursive Argument  Suppose we have two sequences: s[1..n+1] and t[1..m+1] The best alignment must be one of three cases: 1. Last match is ( s[n+1],t[m +1] ) 2. Last match is ( s[n +1], - ) 3. Last match is ( -, t[m +1] )

16 Recursive Argument  Suppose we have two sequences: s[1..n+1] and t[1..m+1] The best alignment must be one of three cases: 1. Last match is ( s[n+1],t[m +1] ) 2. Last match is ( s[n +1], - ) 3. Last match is ( -, t[m +1] )

17 Recursive Argument Define the notation:  Using our recursive argument, we get the following recurrence for V : V[i,j]V[i+1,j] V[i,j+1]V[i+1,j+1]

18 Recursive Argument u Of course, we also need to handle the base cases in the recursion: AA - We fill the matrix using the recurrence rule: S T versus

19 Dynamic Programming Algorithm We continue to fill the matrix using the recurrence rule S T

20 Dynamic Programming Algorithm V[0,0]V[0,1] V[1,0]V[1,1] A A- -2 (A- versus -A) versus S T

21 Dynamic Programming Algorithm S T

22 Dynamic Programming Algorithm Conclusion: d( AAAC, AGC ) = -1 S T

23 Reconstructing the Best Alignment u To reconstruct the best alignment, we record which case(s) in the recursive rule maximized the score S T

24 Reconstructing the Best Alignment u We now trace back a path that corresponds to the best alignment AAAC AG-C S T

25 Reconstructing the Best Alignment u Sometimes, more than one alignment has the best score S T AAAC A-GC AAAC -AGC AAAC AG-C

26 Time Complexity Space: O(mn) Time: O(mn)  Filling the matrix O(mn)  Backtrace O(m+n) S T

27 Space Complexity  In real-life applications, n and m can be very large u The space requirements of O(mn) can be too demanding  If m = n = 1000, we need 1MB space  If m = n = 10000, we need 100MB space u We can afford to perform extra computation to save space  Looping over million operations takes less than seconds on modern workstations u Can we trade space with time?

28 Why Do We Need So Much Space?  Compute V(i,j), column by column, storing only two columns in memory (or line by line if lines are shorter) A 1 G 2 C 3 0 A 1 A 2 A 3 C 4 Note however that u This “trick” fails when we need to reconstruct the optimizing sequence.  Trace back information requires O(mn) memory bytes. To compute V[n,m]=d(s[1..n],t[1..m]), we need only O(min(n,m)) space:

29 Space Efficient Version: Outline u If n=1 align s[1,1] and t[1,m]  Else, find position (n/2, j) at which some best alignment crosses a midpoint s t u Construct alignments  A=s[1,n/2] vs t[1,j]  B=s[n/2+1,n] vs t[j+1,m]  Return AB Input: Sequences s[1,n] and t[1,m] to be aligned. Idea: perform divide and conquer

30 Finding the Midpoint The score of the best alignment that goes through j equals: d(s[1,n/2],t[1,j]) + d(s[n/2+1,n],t[j+1,m])  Thus, we need to compute these two quantities for all values of j s t

31 Finding the Midpoint (Algorithm) Define u F[i,j] = d(s[1,i],t[1,j]) u B[i,j] = d(s[i+1,n],t[j+1,m])  F[i,j] + B[i,j] = score of best alignment through (i,j)  We compute F[i,j] as we did before  We compute B[i,j] in exactly the same manner, going “backward” from B[n,m] u Requires linear space complexity

32 Time Complexity Analysis  Time to find a mid-point: cnm ( c - a constant) u Size of recursive sub-problems is (n/2,j) and (n/2,m-j-1), hence T(n,m) = cnm + T(n/2,j) + T(n/2,m-j-1) Lemma: T(n,m)  2cnm Proof (by induction): T(n,m)  cnm + 2c(n/2)j + 2c(n/2)(m-j-1)  2cnm. Thus, time complexity is linear in size of the problem At worst, twice the cost of the regular solution.

33 Local Alignment Consider now a different question:  Can we find similar substrings of s and t  Formally, given s[1..n] and t[1..m] find i,j,k, and l such that d(s[i..j],t[k..l]) is maximal

34 Local Alignment u As before, we use dynamic programming  We now want to set V[i,j] to record the best alignment of a suffix of s[1..i] and a suffix of t[1..j] u How should we change the recurrence rule?  Same as before but with an option to start afresh u The result is called the Smith-Waterman algorithm

35 Local Alignment New option: u We can start a new match instead of extending a previous alignment Alignment of empty suffixes

36 Local Alignment Example s = TAATA t = TACTAA S T

37 Local Alignment Example s = TAATA t = TACTAA S T

38 Local Alignment Example s = TAATA t = TACTAA S T

39 Local Alignment Example s = TAATA t = TACTAA S T

40 Local Alignment Example s = TAATA t = TACTAA S T

41 Variants of Sequence Alignment We have seen two variants of sequence alignment: u Global alignment u Local alignment Other variants in the book and in tutorial time: 1. Finding best overlap 2. Using an affine cost d(g) = -d –(g-1)e for gaps of length g. The –d is for introducing a gap and –e for continuing the gap. We used d=e=2. We could use smaller e. These variants are based on the same basic idea of dynamic programming.

42 Remark: Edit Distance Instead of speaking about the score of an alignment, one often talks about an edit distance between two sequences, defined to be the “cost” of the “cheapest” set of edit operations needed to transform one sequence into the other.  Cheapest operation is “no change”  Next cheapest operation is “replace”  The most expensive operation is “add space”. Our goal is now to minimize the cost of operations, which is exactly what we actually did.

43 Where do scoring rules come from ? We have defined an additive scoring function by specifying a function  ( ,  ) such that  (x,y) is the score of replacing x by y  (x,-) is the score of deleting x  (-,x) is the score of inserting x But how do we come up with the “correct” score ? Answer: By encoding experience of what are similar sequences for the task at hand.

44 Why use probability to define and/or interpret a scoring function ? Similarity is probabilistic in nature because biological changes like mutation, recombination, and selection, are not deterministic. We could answer questions such as: How probable two sequences are similar? Is the similarity found significant or random? How to change a similarity score when, say, mutation rate of a specific area on the chromosome becomes known ?

45 A Probabilistic Model u For now, we will focus on alignment without indels. u For now, we assume each position (nucleotide /amino-acid) is independent of other positions. u We consider two options: M: the sequences are Matched (related) R: the sequences are Random (unrelated)

46 Unrelated Sequences u Our random model of unrelated sequences is simple  Each position is sampled independently from a distribution over the alphabet   We assume there is a distribution q(  ) that describes the probability of letters in such positions. u Then:

47 Related Sequences  We assume that each pair of aligned positions (s[i],t[i]) evolved from a common ancestor  Let p(a,b) be a distribution over pairs of letters.  p(a,b) is the probability that some ancestral letter evolved into this particular pair of letters.

48 Odd-Ratio Test for Alignment If Q > 1, then the two strings s and t are more likely to be related (M) than unrelated (R). If Q < 1, then the two strings s and t are more likely to be unrelated (R) than related (M).

49 Score(s[i],t[i]) Log Odd-Ratio Test for Alignment Taking logarithm of Q yields If log Q > 0, then s and t are more likely to be related. If log Q < 0, then they are more likely to be unrelated. How can we relate this quantity to a score function ?

50 Probabilistic Interpretation of Scores u We define the scoring function via u Then, the score of an alignment is the log-ratio between the two models:  Score > 0  Model is more likely  Score < 0  Random is more likely

51 Modeling Assumptions u It is important to note that this interpretation depends on our modeling assumption!! u For example, if we assume that the letter in each position depends on the letter in the preceding position, then the likelihood ratio will have a different form.

52 Constructing Scoring Rules The formula suggests how to construct a scoring rule:  Estimate p(·,·) and q(·) from the data  Compute  (a,b) based on the estimated p(·,·) and q(·) u How to estimate these parameters is the subject matter of parameter estimation in Statistics.