Class 2: Basic Sequence Alignment

Slides:



Advertisements
Similar presentations
Sequence Alignment I Lecture #2
Advertisements

Longest Common Subsequence
DYNAMIC PROGRAMMING ALGORITHMS VINAY ABHISHEK MANCHIRAJU.
Solusi DP Menggunakan Software Pertemuan 24 : (Off Class) Mata kuliah:K0164-Pemrograman Matematika Tahun:2008.
. Computational Genomics Lecture #2 This class has been edited from Nir Friedman’s lecture which is available at Changes made by.
Introduction to Bioinformatics Algorithms Divide & Conquer Algorithms.
. Sequence Alignment I Lecture #2 This class has been edited from Nir Friedman’s lecture which is available at Changes made by.
Sequence Alignment Arthur W. Chou Tunghai University Fall 2005.
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.
Refining Edits and Alignments Υλικό βασισμένο στο κεφάλαιο 12 του βιβλίου: Dan Gusfield, Algorithms on Strings, Trees and Sequences, Cambridge University.
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.
Space Efficient Alignment Algorithms and Affine Gap Penalties
Sequence Alignment Algorithms in Computational Biology Spring 2006 Edited by Itai Sharon Most slides have been created and edited by Nir Friedman, Dan.
Introduction to Bioinformatics Algorithms Dynamic Programming: Edit Distance.
Sequencing and Sequence Alignment
CSE 421 Algorithms Richard Anderson Lecture 19 Longest Common Subsequence.
Inexact Matching General Problem –Input Strings S and T –Questions How distant is S from T? How similar is S to T? Solution Technique –Dynamic programming.
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.
Introduction To Bioinformatics Tutorial 2. Local Alignment Tutorial 2.
Dynamic Programming and Biological Sequence Comparison Part I.
Sequence Alignment II CIS 667 Spring Optimal Alignments So we know how to compute the similarity between two sequences  How do we construct an.
UNIVERSITY OF SOUTH CAROLINA College of Engineering & Information Technology Bioinformatics Algorithms and Data Structures Chapter 11: Core String Edits.
Introduction to Bioinformatics Algorithms 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.
Incorporating Bioinformatics in an Algorithms Course Lawrence D’Antonio Ramapo College of New Jersey.
FA05CSE182 CSE 182-L2:Blast & variants I Dynamic Programming
Space Efficient Alignment Algorithms Dr. Nancy Warter-Perez.
1 Theory I Algorithm Design and Analysis (11 - Edit distance and approximate string matching) Prof. Dr. Th. Ottmann.
. 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:
CS 5263 Bioinformatics Lecture 4: Global Sequence Alignment Algorithms.
Pairwise alignments Introduction Introduction Why do alignments? Why do alignments? Definitions Definitions Scoring alignments Scoring alignments Alignment.
Space-Efficient Sequence Alignment Space-Efficient Sequence Alignment Bioinformatics 202 University of California, San Diego Lecture Notes No. 7 Dr. Pavel.
Comp. Genomics Recitation 2 12/3/09 Slides by Igor Ulitsky.
Pairwise Sequence Alignment (I) (Lecture for CS498-CXZ Algorithms in Bioinformatics) Sept. 22, 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.
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 Comparison I519 Introduction to Bioinformatics, Fall 2012.
Local Alignment Vasileios Hatzivassiloglou University of Texas at Dallas.
. Sequence Alignment Author:- Aya Osama Supervision:- Dr.Noha khalifa.
9/27/10 A. Smith; based on slides by E. Demaine, C. Leiserson, S. Raskhodnikova, K. Wayne Adam Smith Algorithm Design and Analysis L ECTURE 16 Dynamic.
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.
Bioinformatics: The pair-wise alignment problem
Sequence Alignment ..
Using Dynamic Programming To Align Sequences
Intro to Alignment Algorithms: Global and Local
CSE 589 Applied Algorithms Spring 1999
Bioinformatics Algorithms and Data Structures
DYNAMIC PROGRAMMING.
Sequence Alignment Tutorial #2
Presentation transcript:

Class 2: Basic Sequence Alignment .

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

Sequence Comparison (cont) Finding similarity between sequences is important for many biological questions For example: Find genes/proteins with common origin Allows to predict function & structure Locate common subsequences in genes/proteins Identify common “motifs” Locate sequences that might overlap Help in sequence assembly

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

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

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

Scoring Alignments Rough intuition: Similar sequences evolved from a common ancestor 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 Scoring of sequence similarity should examine how many operations took place

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

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

More General Scores The choice of +1,-1, and -2 scores was quite arbitrary 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

Additive Scoring Rules 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 The score of an alignment is the sum of position scores

Edit Distance The edit distance between two sequences is the “cost” of the “cheapest” set of edit operations needed to transform one sequence into the other Computing edit distance between two sequences almost equivalent to finding the alignment that minimizes the distance

Computing Edit Distance How can we compute the edit distance?? If |s| = n and |t| = m, there are more than alignments The additive form of the score allows to perform dynamic programming to compute edit distance efficiently

Recursive Argument Suppose we have two sequences: s[1..i+1] and t[1..j+1] The best alignment must be in one of three cases: 1. Last position is (s[i+1],t[j+1] ) 2. Last position is (s[i+1],-) 3. Last position is (-, t[j +1] )

Recursive Argument Suppose we have two sequences: s[1..i+1] and t[1..j+1] The best alignment must be in one of three cases: 1. Last position is (s[i+1],t[j +1] ) 2. Last position is (s[i +1],-) 3. Last position is (-, t[j +1] )

Recursive Argument Suppose we have two sequences: s[1..i+1] and t[1..j+1] The best alignment must be in one of three cases: 1. Last position is (s[i+1],t[j +1] ) 2. Last position is (s[i +1],-) 3. Last position is (-, t[j +1] )

Recursive Argument Define the notation: Using the recursive argument, we get the following recurrence for V:

Recursive Argument Of course, we also need to handle the base cases in the recursion:

Dynamic Programming Algorithm We fill the matrix using the recurrence rule

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

Reconstructing the Best Alignment To reconstruct the best alignment, we record which case in the recursive rule maximized the score

Reconstructing the Best Alignment We now trace back the path the corresponds to the best alignment AAAC AG-C

Reconstructing the Best Alignment Sometimes, more than one alignment has the best score AAAC A-GC

Complexity Space: O(mn) Time: O(mn) Filling the matrix O(mn) Backtrace O(m+n)

Space Complexity In real-life applications, n and m can be very large 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 We can afford to perform extra computation to save space Looping over million operations takes less than seconds on modern workstations Can we trade off space with time?

Why Do We Need So Much Space? To find d(s,t), need O(n) space Need to compute V[i,m] Can fill in V, column by column, storing only two columns in memory A 1 G 2 C 3 4 -2 -4 -6 -8 -2 1 -1 -3 -5 -4 -1 -2 -6 -3 -2 -1 Note however This “trick” fails when we need to reconstruct the sequence Trace back information “eats up” all the memory

Space Efficient Version: Outline Idea: perform divide and conquer Find position (n/2, j) at which the best alignment crosses s midpoint s Construct alignments s[1,n/2] vs t[1,j] s[n/2+1,n] vs t[j+1,m] t

d(s[1,n/2],t[1,j]) + d(s[n/2+1,n],t[j+1,m]) Finding the Midpoint Suppose s[1,n] and t[1,m] are given We can write the score of the best alignment that goes through j as: 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

Finding the Midpoint (cont) Define F[i,j] = d(s[1,i],t[1,j]) 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]

Time Complexity Analysis Finding mid-point: cmn (c - a constant) Recursive sub-problems of sizes (n/2,j) and (n/2,m-j-1) T(m,n) = cmn + T(j,n/2) + T(m-j-1, n/2) Lemma: T(m,n)  2cmn Time complexity is linear in size of the problem At worse, twice the time of regular solution.

Local Alignment Consider now a different question: Can we find similar substring 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

Local Alignment As before, we use dynamic programming We now want to setV[i,j] to record the best alignment of a suffix of s[1..i] and a suffix of t[1..j] How should we change the recurrence rule?

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

Local Alignment Example s = TAATA t = TACTAA

Local Alignment Example s = TAATA t = TACTAA

Local Alignment Example s = TAATA t = TACTAA

Local Alignment Example s = TAATA t = TACTAA

Sequence Alignment We saw two variants of sequence alignment: Global alignment Local alignment Other variants: Finding best overlap (exercise) All are based on the same basic idea of dynamic programming