An Introduction to Bioinformatics 2. Comparing biological sequences: sequence alignment.

Slides:



Advertisements
Similar presentations
DYNAMIC PROGRAMMING ALGORITHMS VINAY ABHISHEK MANCHIRAJU.
Advertisements

Introduction to Bioinformatics Algorithms Divide & Conquer Algorithms.
Introduction to Bioinformatics Algorithms Divide & Conquer Algorithms.
Introduction to Bioinformatics Algorithms Divide & Conquer Algorithms.
Dynamic Programming: Sequence alignment
Chapter 7 Dynamic Programming.
Outline The power of DNA Sequence Comparison The Change Problem
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.
Dynamic Programming: Edit Distance
Introduction to Bioinformatics Algorithms Dynamic Programming: Edit Distance.
Dynamic Programming Reading Material: Chapter 7..
Longest Common Subsequence (LCS) Dr. Nancy Warter-Perez.
UNIVERSITY OF SOUTH CAROLINA College of Engineering & Information Technology Bioinformatics Algorithms and Data Structures Chapter 11 sections4-7 Lecturer:
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
Sequence Alignment.
Introduction to Bioinformatics Algorithms Sequence Alignment.
Introduction to Bioinformatics Algorithms Block Alignment and the Four-Russians Speedup Presenter: Yung-Hsing Peng Date:
Longest Common Subsequence (LCS) Dr. Nancy Warter-Perez June 22, 2005.
Sequence Alignment Bioinformatics. Sequence Comparison Problem: Given two sequences S & T, are S and T similar? Need to establish some notion of similarity.
Developing Pairwise Sequence Alignment Algorithms Dr. Nancy Warter-Perez June 23, 2004.
7 -1 Chapter 7 Dynamic Programming Fibonacci Sequence Fibonacci sequence: 0, 1, 1, 2, 3, 5, 8, 13, 21, … F i = i if i  1 F i = F i-1 + F i-2 if.
Developing Pairwise Sequence Alignment Algorithms Dr. Nancy Warter-Perez May 20, 2003.
UNIVERSITY OF SOUTH CAROLINA College of Engineering & Information Technology Bioinformatics Algorithms and Data Structures Chapter 11: Core String Edits.
Implementation of Planted Motif Search Algorithms PMS1 and PMS2 Clifford Locke BioGrid REU, Summer 2008 Department of Computer Science and Engineering.
Introduction to Bioinformatics Algorithms Sequence Alignment.
Bioinformatics Unit 1: Data Bases and Alignments Lecture 3: “Homology” Searches and Sequence Alignments (cont.) The Mechanics of Alignments.
Developing Pairwise Sequence Alignment Algorithms Dr. Nancy Warter-Perez May 10, 2005.
Phylogenetic Tree Construction and Related Problems Bioinformatics.
Class 2: Basic Sequence Alignment
1 Theory I Algorithm Design and Analysis (11 - Edit distance and approximate string matching) Prof. Dr. Th. Ottmann.
Dynamic Programming I Definition of Dynamic Programming
Developing Pairwise Sequence Alignment Algorithms
Sequence Alignment.
BIOMETRICS Module Code: CA641 Week 11- Pairwise Sequence Alignment.
Brandon Andrews.  Longest Common Subsequences  Global Sequence Alignment  Scoring Alignments  Local Sequence Alignment  Alignment with Gap Penalties.
Pairwise alignments Introduction Introduction Why do alignments? Why do alignments? Definitions Definitions Scoring alignments Scoring alignments Alignment.
Pairwise & Multiple sequence alignments
Space-Efficient Sequence Alignment Space-Efficient Sequence Alignment Bioinformatics 202 University of California, San Diego Lecture Notes No. 7 Dr. Pavel.
Introduction to Bioinformatics Algorithms Dynamic Programming: Edit Distance.
Pairwise Alignment, Part I Constructing the Values and Directions Tables from 2 related DNA (or Protein) Sequences.
Pairwise Sequence Alignment (I) (Lecture for CS498-CXZ Algorithms in Bioinformatics) Sept. 22, 2005 ChengXiang Zhai Department of Computer Science University.
Introduction to Bioinformatics Algorithms Sequence Alignment.
Pairwise Sequence Alignment (II) (Lecture for CS498-CXZ Algorithms in Bioinformatics) Sept. 27, 2005 ChengXiang Zhai Department of Computer Science University.
Dynamic Programming: Sequence alignment CS 466 Saurabh Sinha.
Pairwise alignment of DNA/protein sequences I519 Introduction to Bioinformatics, Fall 2012.
Sequence Analysis CSC 487/687 Introduction to computing for Bioinformatics.
Minimum Edit Distance Definition of Minimum Edit Distance.
Dynamic Programming: Manhattan Tourist Problem Lecture 17.
Sequence Comparison Algorithms Ellen Walker Bioinformatics Hiram College.
Intro to Alignment Algorithms: Global and Local Intro to Alignment Algorithms: Global and Local Algorithmic Functions of Computational Biology Professor.
Sequence Alignments with Indels Evolution produces insertions and deletions (indels) – In addition to substitutions Good example: MHHNALQRRTVWVNAY MHHALQRRTVWVNAY-
Dynamic Programming: Edit Distance
Introduction to Bioinformatics Algorithms Divide & Conquer Algorithms.
The Manhattan Tourist Problem Shane Wood 4/29/08 CS 329E.
Chapter 7 Dynamic Programming 7.1 Introduction 7.2 The Longest Common Subsequence Problem 7.3 Matrix Chain Multiplication 7.4 The dynamic Programming Paradigm.
Sequence Comparison I519 Introduction to Bioinformatics, Fall 2012.
Introduction to Bioinformatics Algorithms Dynamic Programming: Edit Distance.
Core String Edits, Alignments, and Dynamic Programming.
Dr Nazir A. Zafar Advanced Algorithms Analysis and Design Advanced Algorithms Analysis and Design By Dr. Nazir Ahmad Zafar.
Sequence Alignment.
CSE 5290: Algorithms for Bioinformatics Fall 2011
Sequence Alignment Using Dynamic Programming
Pairwise sequence Alignment.
Intro to Alignment Algorithms: Global and Local
Sequence Alignment.
Dynamic Programming-- Longest Common Subsequence
Bioinformatics Algorithms and Data Structures
Presentation transcript:

An Introduction to Bioinformatics 2. Comparing biological sequences: sequence alignment

An Introduction to Bioinformatics DNA Sequence Comparison: First Success Story Finding sequence similarities with genes of known function is a common approach to infer a newly sequenced gene’s function In 1984 Russell Doolittle and colleagues found similarities between cancer-causing gene (v-sys in Simian Sarcoma Virus) and normal growth factor (PDGF) gene

An Introduction to Bioinformatics 3 So what? Identifying the similarity between PDGF and the viral oncogene helped lead to a modern hypothesis of cancer. Identifying the similarity between ATP binding ion channels and the Cystic Fibrosis gene led to a modern hypothesis of CF. Comparing sequences can yield biological insight. 3

An Introduction to Bioinformatics Similarity Similar genes may have similar functions Similar genes may have similar evolutionary origins Similarity between sequences is not a vague idea--- it can be quantified But...how do we compute it?

An Introduction to Bioinformatics 5 Complete DNA Sequences nearly 200 complete genomes have been sequenced

An Introduction to Bioinformatics 6 Evolution

An Introduction to Bioinformatics 7 Evolution at the DNA level …ACGGTGCAGTTACCA… …AC----CAGTCCACCA… Mutation SEQUENCE EDITS REARRANGEMENTS Deletion Inversion Translocation Duplication

An Introduction to Bioinformatics 8 Evolutionary Rates OK X X Still OK? next generation

An Introduction to Bioinformatics 9 Sequence conservation implies function Alignment is the key to Finding important regions Determining function Uncovering the evolutionary forces

An Introduction to Bioinformatics 10 Sequence Alignment -AGGCTATCACCTGACCTCCAGGCCGA--TGCCC--- TAG-CTATCAC--GACCGC--GGTCGATTTGCCCGAC Definition Given two strings x = x 1 x 2...x M, y = y 1 y 2 …y N, an alignment is an assignment of gaps to positions 0,…, N in x, and 0,…, N in y, so as to line up each letter in one sequence with either a letter, or a gap in the other sequence AGGCTATCACCTGACCTCCAGGCCGATGCCC TAGCTATCACGACCGCGGTCGATTTGCCCGAC

An Introduction to Bioinformatics 11 Apologia for a diversion... Computing similarity is detail-oriented, and we need to do some preliminary work first: The Manhattan Tourist Problem introduces grids, graphs and edit graphs 11

An Introduction to Bioinformatics 12 Manhattan Tourist Problem Where to? See the most stuff in the least time.

An Introduction to Bioinformatics Manhattan Tourist Problem (MTP) Imagine seeking a path (from source to sink) to travel (only eastward and southward) with the most number of attractions (*) in the Manhattan grid Sink * * * * * * * ** * * Source

An Introduction to Bioinformatics Manhattan Tourist Problem: Formulation Goal: Find the longest path in a weighted grid. Input: A weighted grid G with two distinct vertices, one labeled “source” and the other labeled “sink” Output: A longest path in G from “source” to “sink”

An Introduction to Bioinformatics MTP: An Example j coordinates i coordinates 13 source sink

An Introduction to Bioinformatics MTP: An Example j coordinates i coordinates 13 source sink

An Introduction to Bioinformatics MTP: Simple Recursive Program MT(n,m) x  MT(n-1,m)+ length of the edge from (n- 1,m) to (n,m) y  MT(n,m-1)+ length of the edge from (n,m-1) to (n,m) return max{x,y}

An Introduction to Bioinformatics MTP: Simple Recursive Program MT(n,m) x  MT(n-1,m)+ length of the edge from (n- 1,m) to (n,m) y  MT(n,m-1)+ length of the edge from (n,m-1) to (n,m) return max{x,y} Slow, for the same reason that RecursiveChange was slow

An Introduction to Bioinformatics i source 1 5 S 1,0 = 5 S 0,1 = 1 Instead of recursion, store the result in an array S MTP: Dynamic Programming j

An Introduction to Bioinformatics MTP: Dynamic Programming source S 2,0 = 8 i S 1,1 = 4 S 0,2 = j

An Introduction to Bioinformatics MTP: Dynamic Programming i source S 3,0 = 8 S 2,1 = 9 S 1,2 = 13 S 3,0 = 8 j

An Introduction to Bioinformatics MTP: Dynamic Programming i source S 3,1 = 9 S 2,2 = 12 S 1,3 = 8 j

An Introduction to Bioinformatics MTP: Dynamic Programming (cont’d) i source j S 3,2 = 9 S 2,3 = 15

An Introduction to Bioinformatics MTP: Dynamic Programming (cont’d) i source j S 3,3 = 16 (showing all back-traces) Done!

An Introduction to Bioinformatics MTP: Recurrence Computing the score for a point (i,j) by the recurrence relation: s i, j = max s i-1, j + weight of the edge between (i-1, j) and (i, j) s i, j-1 + weight of the edge between (i, j-1) and (i, j) the running time is n x m for a n by m grid (n = # of rows, m = # of columns)

An Introduction to Bioinformatics 26 Manhattan is not a perfect grid

An Introduction to Bioinformatics Manhattan Is Not A Perfect Grid What about diagonals? The score at point B is given by: s B = max of s A1 + weight of the edge (A 1, B) s A2 + weight of the edge (A 2, B) s A3 + weight of the edge (A 3, B) B A3A3 A1A1 A2A2

An Introduction to Bioinformatics Manhattan Is Not A Perfect Grid (cont’d) Computing the score for point x is given by the recurrence relation: s x = max of s y + weight of vertex (y, x) where y є Predecessors(x) Predecessors (x) – set of vertices that have edges leading to x The running time for a graph G(V, E) (V is the set of all vertices and E is the set of all edges) is O(E) since each edge is evaluated once

An Introduction to Bioinformatics Traversing the Manhattan Grid 3 different strategies: a) Column by column b) Row by row c) Along diagonals a)b) c)

An Introduction to Bioinformatics Aligning DNA Sequences V = ATCTGATG W = TGCATAC n = 8 m = 7 ATCTGATG TGCATAC V W match deletion insertion mismatch indels matches mismatches insertions deletions

An Introduction to Bioinformatics Longest Common Subsequence (LCS) Problem Given two sequences v = v 1 v 2 …v m and w = w 1 w 2 …w n The LCS of v and w is a sequence of positions in v: 1 < i 1 < i 2 < … < i t < m and a sequence of positions in w: 1 < j 1 < j 2 < … < j t < n such that i t -th letter of v equals to j t -letter of w and t is maximal

An Introduction to Bioinformatics LCS: Example AT -- CTGATG TGCT A C elements of v elements of w -- A j coords: i coords: Matches shown in red positions in v: positions in w: 2 < 3 < 4 < 6 1 < 3 < 5 < 6 The LCS Problem can be expressed using the grid similar to Manhattan Tourist Problem grid… 0 0 (0,0)  (1,0)  (2,1)  (2,2)  (3,3)  (3,4)  (4,5)  (5,5)  (6,6)  (7,6)  (8,7)

An Introduction to Bioinformatics LCS: Dynamic Programming Find the LCS of two strings Input: A weighted graph G with two distinct vertices, one labeled “source” one labeled “sink” Output: A longest path in G from “source” to “sink” Solve using an LCS edit graph with diagonals replaced with +1 edges

An Introduction to Bioinformatics LCS Problem as Manhattan Tourist Problem T G C A T A C i ATCTGATC j

An Introduction to Bioinformatics Edit Graph for LCS Problem T G C A T A C i ATCTGATC j

An Introduction to Bioinformatics Computing LCS Let v i = prefix of v of length i: v 1 … v i and w j = prefix of w of length j: w 1 … w j The length of LCS(v i,w j ) is computed by: s i, j = max s i-1, j s i, j-1 s i-1, j if v i = w j

An Introduction to Bioinformatics Computing LCS (cont’d) s i,j = MAX s i-1,j + 0 s i,j s i-1,j , if v i = w j i,j i -1,j i,j -1 i -1,j

An Introduction to Bioinformatics LCS Problem Revisited V = ATCTGATG = V 1, V 2, …, V n where n = 8 W = TGCATAC = W 1, W 2, …, W m where m = 7 ATCTGATG TGCATAC V W i j i 1, i 2, i 3, i j 1, j 2, j 3, j < < < Manhattan Tourist Problem is also the example of maximizing problem i 1, j 1 i 2, j 2 i 3, j 3 i 1, j 1 i 2, j 2... i t, j t

An Introduction to Bioinformatics Alignment Grid Example W ATCG A T G T V V = A T - G T | | | W= A T C G –

An Introduction to Bioinformatics Aligning Sequences without Insertions and Deletions: Hamming Distance Given two DNA sequences V and W : V : The Hamming distance: d H (V, W) = 8 is large but the sequences are very similar ATATATAT ATATATATW :

An Introduction to Bioinformatics Aligning Sequences with Insertions and Deletions V :ATATATAT ATATATATW :-- However, by shifting one sequence over one position: The edit distance: d H (v, w) = 2. Using Hamming distance neglects insertions and deletions in DNA

An Introduction to Bioinformatics Edit Distance Levenshtein (1966) introduced edit distance of two strings as the minimum number of elementary operations (insertions, deletions, and substitutions) to transform one string into the other d(v,w) = MIN no. of elementary operations to transform v  w

An Introduction to Bioinformatics Edit Distance (cont’d) V = ATATATAT W = TATATATA Edit distance: d(v, w) = 2 (one insertion and one deletion) i th letter of v compare with i th letter of w W = TATATATA Just one shift Make it all line up V = - ATATATAT

An Introduction to Bioinformatics Edit Distance: Example 5 edit operations: TGCATAT  ATCCGAT TGCATAT  (delete last T) TGCATA  (delete last A) TGCAT  (insert A at front) ATGCAT  (substitute C for 3 rd G) ATCCAT  (insert G before last A) ATCCGAT (Done)

An Introduction to Bioinformatics Edit Distance: Example (cont’d) 4 edit operations: TGCATAT  ATCCGAT TGCATAT  (insert A at front) ATGCATAT  (delete 6 th T) ATGCATA  (substitute G for 5 th A) ATGCGTA  (substitute C for 3 rd G) ATCCGAT (Done)

An Introduction to Bioinformatics Alignment: 2 row representation Alignment : 2 * k matrix ( k > m, n ) AT--GTAT ATCG A C letters of v letters of w T T ATCTGAT TGCATA v : w : m = 7 n = 6 4 matches2 insertions2 deletions Given 2 DNA sequences v and w:

An Introduction to Bioinformatics The Alignment Grid 2 sequences used for grid V = ATGTTAT W = ATCGTAC Every alignment path is from source to sink

An Introduction to Bioinformatics 48 Alignment as a Path in the Edit Graph A T _ G T T A T _ A T _ G T T A T _ A T C G T _ A _ C A T C G T _ A _ C (0,0), (1,1), (2,2), (2,3), (3,4), (4,5), (5,5), (6,6), (7,6), (7,7) - Corresponding path -

An Introduction to Bioinformatics 49 Alignments in Edit Graph (cont’d) and represent indels in v and w with score 0. represent matches with score 1. The score of the alignment path is 5.

An Introduction to Bioinformatics 50 Alignment as a Path in the Edit Graph Every path in the edit graph corresponds to an alignment:

An Introduction to Bioinformatics 51 Alignment as a Path in the Edit Graph Old Alignment v= AT_GTTAT_ w= ATCGT_A_C New Alignment v= AT_GTTAT_ w= ATCG_TA_C

An Introduction to Bioinformatics 52 Alignment as a Path in the Edit Graph v= AT_GTTAT_ w= ATCGT_A_C (0,0), (1,1), (2,2), (2,3), (3,4), (4,5), (5,5), (6,6), (7,6), (7,7)

An Introduction to Bioinformatics 53 Alignment: Dynamic Programming s i,j = s i-1, j-1 +1 if v i = w j max s i-1, j s i, j-1

An Introduction to Bioinformatics 54 Dynamic Programming Example Initialize 1 st row and 1 st column to be all zeroes. Or, to be more precise, initialize 0 th row and 0 th column to be all zeroes.

An Introduction to Bioinformatics 55 Dynamic Programming Example S i,j = S i-1, j-1 max S i-1, j S i, j-1  value from NW +1, if v i = w j  value from North (top)  value from West (left)

An Introduction to Bioinformatics 56 Alignment: Backtracking Arrows show where the score originated from. if from the top if from the left if v i = w j

An Introduction to Bioinformatics 57 Backtracking Example Find a match in row and column 2. i=2, j=2,5 is a match (T). j=2, i=4,5,7 is a match (T). Since v i = w j, s i,j = s i-1,j-1 +1 s 2,2 = [s 1,1 = 1] + 1 s 2,5 = [s 1,4 = 1] + 1 s 4,2 = [s 3,1 = 1] + 1 s 5,2 = [s 4,1 = 1] + 1 s 7,2 = [s 6,1 = 1] + 1

An Introduction to Bioinformatics 58 Backtracking Example Continuing with the dynamic programming algorithm gives this result.

An Introduction to Bioinformatics 59 Alignment: Dynamic Programming s i,j = s i-1, j-1 +1 if v i = w j max s i-1, j s i, j-1

An Introduction to Bioinformatics 60 Alignment: Dynamic Programming s i,j = s i-1, j-1 +1 if v i = w j max s i-1, j +0 s i, j-1 +0 This recurrence corresponds to the Manhattan Tourist problem (three incoming edges into a vertex) with all horizontal and vertical edges weighted by zero.

An Introduction to Bioinformatics 61 LCS Algorithm 1.LCS(v,w) 2. for i  1 to n 3. s i,0  0 4. for j  1 to m 5. s 0,j  0 6. for i  1 to n 7. for j  1 to m 8. s i-1,j 9. s i,j  max s i,j s i-1,j-1 + 1, if v i = w j 11. “ “ if s i,j = s i-1,j b i,j  “ “ if s i,j = s i,j-1 “ “ if s i,j = s i-1,j return (s n,m, b)

An Introduction to Bioinformatics 62 Now What? LCS(v,w) created the alignment grid Now we need a way to read the best alignment of v and w Follow the arrows backwards from sink

An Introduction to Bioinformatics 63 Printing LCS: Backtracking 1.PrintLCS(b,v,i,j) 2. if i = 0 or j = 0 3. return 4. if b i,j = “ “ 5. PrintLCS(b,v,i-1,j-1) 6. print v i 7. else 8. if b i,j = “ “ 9. PrintLCS(b,v,i-1,j) 10. else 11. PrintLCS(b,v,i,j-1)

An Introduction to Bioinformatics 64 LCS Runtime It takes O(nm) time to fill in the nxm dynamic programming matrix. Why O(nm)? The pseudocode consists of a nested “for” loop inside of another “for” loop to set up a nxm matrix.