Www.bioalgorithms.infoAn Introduction to Bioinformatics Algorithms Dynamic Programming: Edit Distance.

Slides:



Advertisements
Similar presentations
Longest Common Subsequence
Advertisements

DYNAMIC PROGRAMMING ALGORITHMS VINAY ABHISHEK MANCHIRAJU.
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.
Gene Prediction: Similarity-Based Approaches (selected from Jones/Pevzner lecture notes)
Dynamic Programming: Edit Distance
Introduction to Bioinformatics Algorithms Dynamic Programming: Edit Distance.
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:
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.
Introduction to Bioinformatics Algorithms Multiple Alignment.
Class 2: Basic Sequence Alignment
Alignment methods II April 24, 2007 Learning objectives- 1) Understand how Global alignment program works using the longest common subsequence method.
Berkeley Fial Michaela McNiff.  Someone gets Cystic Fibrosis when they inherit two mutated genes – one from each parent.  The CF gene is on chromosome.
Introduction to Bioinformatics Algorithms Clustering and Microarray Analysis.
A Study of Cystic Fibrosis Using Web-Based Tools Anuradha Datta Murphy Graduate Student, Dept. of Molecular and Integrative Physiology, University of Illinois.
Dynamic Programming I Definition of Dynamic Programming
Multiple Sequence Alignment BMI/CS 576 Colin Dewey Fall 2010.
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.
Space-Efficient Sequence Alignment Space-Efficient Sequence Alignment Bioinformatics 202 University of California, San Diego Lecture Notes No. 7 Dr. Pavel.
Pairwise Alignment, Part I Constructing the Values and Directions Tables from 2 related DNA (or Protein) Sequences.
The dynamic nature of the proteome
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.
An Introduction to Bioinformatics 2. Comparing biological sequences: sequence alignment.
Pairwise alignment of DNA/protein sequences I519 Introduction to Bioinformatics, Fall 2012.
Sequence Analysis CSC 487/687 Introduction to computing for Bioinformatics.
Dynamic Programming: Manhattan Tourist Problem Lecture 17.
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-
Cystic Fibrosis and Gastric Acid Transport March 11, 2008 CH353 Group Project Sidani et al. 2007, DeltaF508 mutation results in impaired gastric acid secretion,
CYSTIC FIBROSIS AND CELL COMMUNICATION. CFTR Cystic Fibrosis Transmembrane Conductance Regulator ( Or CFTR)  Is a transport protein for Chloride across.
Dynamic Programming: Edit Distance
Introduction to Bioinformatics Algorithms Divide & Conquer Algorithms.
The Manhattan Tourist Problem Shane Wood 4/29/08 CS 329E.
Space Efficient Alignment Algorithms and Affine Gap Penalties Dr. Nancy Warter-Perez.
Sequence Comparison I519 Introduction to Bioinformatics, Fall 2012.
CCystic Fibrosis is an inherited chronic disease IIt affects the lungs and digestive system SSymptoms IIt clogs the lungs with phlegm and causes.
Introduction to Bioinformatics Algorithms Dynamic Programming: Edit Distance.
Sequence Alignment.
CSE 5290: Algorithms for Bioinformatics Fall 2011
Sequence Alignment Using Dynamic Programming
Intro to Alignment Algorithms: Global and Local
Sequence Alignment.
Dynamic Programming-- Longest Common Subsequence
Bioinformatics Algorithms and Data Structures
Presentation transcript:

Introduction to Bioinformatics Algorithms Dynamic Programming: Edit Distance

An Introduction to Bioinformatics Algorithmswww.bioalgorithms.info Outline DNA Sequence Comparison: First Success Stories Sequence Alignment Edit Distance Manhattan Tourist Problem Longest Common Subsequence Problem

An Introduction to Bioinformatics Algorithmswww.bioalgorithms.info 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 and normal growth factor (PDGF) gene

An Introduction to Bioinformatics Algorithmswww.bioalgorithms.info Cystic Fibrosis Cystic fibrosis (CF) is a chronic and frequently fatal genetic disease of the body's mucus glands (abnormally high level of mucus in glands). CF primarily affects the respiratory systems in children. Mucus is a slimy material that coats many epithelial surfaces and is secreted into fluids such as saliva

An Introduction to Bioinformatics Algorithmswww.bioalgorithms.info Cystic Fibrosis: Inheritance In early 1980s biologists hypothesized that CF is an autosomal recessive disorder caused by mutations in a gene that remained unknown till 1989 Heterozygous carriers are asymptomatic Must be homozygously recessive in this gene in order to be diagnosed with CF

An Introduction to Bioinformatics Algorithmswww.bioalgorithms.info Cystic Fibrosis: Finding the Gene

An Introduction to Bioinformatics Algorithmswww.bioalgorithms.info Finding Similarities between the Cystic Fibrosis Gene and ATP binding proteins ATP binding proteins are present on cell membrane and act as transport channel In 1989 biologists found similarity between the cystic fibrosis gene and ATP binding proteins A plausible function for cystic fibrosis gene, given the fact that CF involves sweet secretion with abnormally high sodium level

An Introduction to Bioinformatics Algorithmswww.bioalgorithms.info Cystic Fibrosis: Mutation Analysis If a high % of cystic fibrosis (CF) patients have a certain mutation in the gene and the normal patients don’t, then that could be an indicator of a mutation that is related to CF A certain mutation was found in 70% of CF patients, convincing evidence that it is a predominant genetic diagnostics marker for CF

An Introduction to Bioinformatics Algorithmswww.bioalgorithms.info Cystic Fibrosis and CFTR Gene :

An Introduction to Bioinformatics Algorithmswww.bioalgorithms.info Cystic Fibrosis and the CFTR Protein CFTR (Cystic Fibrosis Transmembrane conductance Regulator) protein is acting in the cell membrane of epithelial cells that secrete mucus These cells line the airways of the nose, lungs, the stomach wall, etc.

An Introduction to Bioinformatics Algorithmswww.bioalgorithms.info Mechanism of Cystic Fibrosis The CFTR protein (1480 amino acids) regulates a chloride ion channel Adjusts the “wateriness” of fluids secreted by the cell Those with cystic fibrosis are missing one single amino acid in their CFTR Mucus ends up being too thick, affecting many organs

An Introduction to Bioinformatics Algorithmswww.bioalgorithms.info Bring in the Bioinformaticians Gene similarities between two genes with known and unknown function alert biologists to some possibilities Computing a similarity score between two genes tells how likely it is that they have similar functions Dynamic programming is a technique for revealing similarities between genes

An Introduction to Bioinformatics Algorithmswww.bioalgorithms.info 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 :w :

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

An Introduction to Bioinformatics Algorithmswww.bioalgorithms.info Aligning Sequences with Insertions and Deletions v :ATATATAT ATATATATw :w :-- By shifting one sequence over one position: The edit distance: d H (v, w) = 2. Hamming distance neglects insertions and deletions in DNA

An Introduction to Bioinformatics Algorithmswww.bioalgorithms.info Edit Distance: Example TGCATAT  ATCCGAT in 5 steps 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 Algorithmswww.bioalgorithms.info Edit Distance: Example TGCATAT  ATCCGAT in 5 steps 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) What is the edit distance? 5?

An Introduction to Bioinformatics Algorithmswww.bioalgorithms.info Edit Distance: Example (cont’d) TGCATAT  ATCCGAT in 4 steps 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 Algorithmswww.bioalgorithms.info Edit Distance: Example (cont’d) TGCATAT  ATCCGAT in 4 steps 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) Can it be done in 3 steps???

An Introduction to Bioinformatics Algorithmswww.bioalgorithms.info Edit Distance vs Hamming Distance V = ATATATAT W = TATATATA Hamming distance: Edit distance: d(v, w)=8 d(v, w)=2 (one insertion and one deletion) How to find what j goes with what i ??? W = TATATATA V = - ATATATAT Hamming distance always compares i -th letter of v with i -th letter of w Edit distance may compare i -th letter of v with j -th letter of w

An Introduction to Bioinformatics Algorithmswww.bioalgorithms.info 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 Algorithmswww.bioalgorithms.info 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 Algorithmswww.bioalgorithms.info 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 Algorithmswww.bioalgorithms.info MTP: Greedy Algorithm Is Not Optimal promising start, but leads to bad choices! source sink 18 22

An Introduction to Bioinformatics Algorithmswww.bioalgorithms.info MTP: An Example j coordinate i coordinate 13 source sink

An Introduction to Bioinformatics Algorithmswww.bioalgorithms.info MTP: Simple Recursive Program MT(n,m) if n=0 or m=0 return 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 Algorithmswww.bioalgorithms.info 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 Algorithmswww.bioalgorithms.info 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 Algorithmswww.bioalgorithms.info Edit Distance vs Hamming Distance V = ATATATAT W = TATATATA Hamming distance: Edit distance: d(v, w)=8 d(v, w)=2 (one insertion and one deletion) How to find what j goes with what i ??? W = TATATATA V = - ATATATAT Hamming distance always compares i -th letter of v with i -th letter of w Edit distance may compare i -th letter of v with j -th letter of w

An Introduction to Bioinformatics Algorithmswww.bioalgorithms.info Aligning DNA Sequences V = ATCTGATG W = TGCATAC n = 8 m = 7 ATCTGATG TGCATAC V W match deletion insertion mismatch indels matches mismatches insertions deletions Alignment : 2 * k matrix ( k > m, n )

An Introduction to Bioinformatics Algorithmswww.bioalgorithms.info Longest Common Subsequence (LCS) – Alignment without Mismatches 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 Algorithmswww.bioalgorithms.info LCS: Example AT -- CTGATC 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 < 8 1 < 3 < 5 < 6 < 7 Every common subsequence is a path in 2-D 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 Algorithmswww.bioalgorithms.info LCS Problem as Manhattan Tourist Problem T G C A T A C i ATCTGATC j

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

An Introduction to Bioinformatics Algorithmswww.bioalgorithms.info Edit Graph for LCS Problem T G C A T A C i ATCTGATC j Every path is a common subsequence. Every diagonal edge adds an extra element to common subsequence LCS Problem: Find a path with maximum number of diagonal edges

An Introduction to Bioinformatics Algorithmswww.bioalgorithms.info 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 Algorithmswww.bioalgorithms.info Every Path in the Grid Corresponds to an Alignment W ATCG A T G T V V = A T - G T | | | W= A T C G –

An Introduction to Bioinformatics Algorithmswww.bioalgorithms.info The Alignment Grid Every alignment path is from source to sink

An Introduction to Bioinformatics Algorithmswww.bioalgorithms.info 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 Algorithmswww.bioalgorithms.info 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 Algorithmswww.bioalgorithms.info Alignment as a Path in the Edit Graph Every path in the edit graph corresponds to an alignment:

An Introduction to Bioinformatics Algorithmswww.bioalgorithms.info 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 Algorithmswww.bioalgorithms.info 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 Algorithmswww.bioalgorithms.info 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 Algorithmswww.bioalgorithms.info 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 Algorithmswww.bioalgorithms.info 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 Algorithmswww.bioalgorithms.info 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 Algorithmswww.bioalgorithms.info 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 Algorithmswww.bioalgorithms.info Backtracking Example Continuing with the dynamic programming algorithm gives this result.

An Introduction to Bioinformatics Algorithmswww.bioalgorithms.info 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 Algorithmswww.bioalgorithms.info 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 Algorithmswww.bioalgorithms.info 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 Algorithmswww.bioalgorithms.info 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 Algorithmswww.bioalgorithms.info 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 Algorithmswww.bioalgorithms.info 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.