Outline The power of DNA Sequence Comparison The Change Problem

Slides:



Advertisements
Similar presentations
Single Source Shortest Paths
Advertisements

CHAPTER 7 Greedy Algorithms.
DYNAMIC PROGRAMMING ALGORITHMS VINAY ABHISHEK MANCHIRAJU.
Introduction to Bioinformatics Algorithms Divide & Conquer Algorithms.
Introduction to Bioinformatics Algorithms Divide & Conquer Algorithms.
Dynamic Programming: Sequence alignment
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.
Rapid Global Alignments How to align genomic sequences in (more or less) linear time.
Dynamic Programming: Edit Distance
Introduction to Bioinformatics Algorithms Dynamic Programming: Edit Distance.
Introduction to Bioinformatics Algorithms Dynamic Programming: Edit Distance.
Sequencing and Sequence Alignment
Introduction to Bioinformatics Algorithms Block Alignment and the Four-Russians Speedup Presenter: Yung-Hsing Peng Date:
Sequence Alignment Bioinformatics. Sequence Comparison Problem: Given two sequences S & T, are S and T similar? Need to establish some notion of similarity.
Dynamic Programming1. 2 Outline and Reading Matrix Chain-Product (§5.3.1) The General Technique (§5.3.2) 0-1 Knapsack Problem (§5.3.3)
Pertemuan 23 : Penerapan Dinamik Programming (DP) Mata kuliah : K0164-Pemrograman vers 01.
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.
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.
Assignment 4. (Due on Dec 2. 2:30 p.m.) This time, Prof. Yao and I can explain the questions, but we will NOT tell you how to solve the problems. Question.
Important Problem Types and Fundamental Data Structures
Dynamic Programming Introduction to Algorithms Dynamic Programming CSE 680 Prof. Roger Crawfis.
Introduction to Bioinformatics Algorithms Clustering and Microarray Analysis.
Pairwise Sequence Alignments
Sequence Alignment.
BIONFORMATIC ALGORITHMS Ryan Tinsley Brandon Lile May 9th, 2014.
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.
Chapter 9 – Graphs A graph G=(V,E) – vertices and edges
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.
1 Generalized Tree Alignment: The Deferred Path Heuristic Stinus Lindgreen
Dynamic Programming Dynamic Programming Dynamic Programming is a general algorithm design technique for solving problems defined by or formulated.
Dr. Naveed Ahmad Assistant Professor Department of Computer Science University of Peshawar.
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.
Sequence Comparison Algorithms Ellen Walker Bioinformatics Hiram College.
Lecture 11 Algorithm Analysis Arne Kutzner Hanyang University / Seoul Korea.
1 Sequence Alignment Input: two sequences over the same alphabet Output: an alignment of the two sequences Example: u GCGCATGGATTGAGCGA u TGCGCCATTGATGACCA.
Intro to Alignment Algorithms: Global and Local Intro to Alignment Algorithms: Global and Local Algorithmic Functions of Computational Biology Professor.
Gene expression & Clustering. Determining gene function Sequence comparison tells us if a gene is similar to another gene, e.g., in a new species –Dynamic.
Dynamic Programming: Edit Distance
SPANNING TREES Lecture 20 CS2110 – Fall Spanning Trees  Definitions  Minimum spanning trees  3 greedy algorithms (incl. Kruskal’s & Prim’s)
The Manhattan Tourist Problem Shane Wood 4/29/08 CS 329E.
DIRECTED ACYCLIC GRAPHS AND TOPOLOGICAL SORT CS16: Introduction to Data Structures & Algorithms Tuesday, March 10,
Sequence Comparison I519 Introduction to Bioinformatics, Fall 2012.
1 Microarray Clustering. 2 Outline Microarrays Hierarchical Clustering K-Means Clustering Corrupted Cliques Problem CAST Clustering Algorithm.
Introduction to Bioinformatics Algorithms Dynamic Programming: Edit Distance.
Clustering [Idea only, Chapter 10.1, 10.2, 10.4].
Special Graphs: Modeling and Algorithms
CSE 5290: Algorithms for Bioinformatics Fall 2011
The Taxi Scheduling Problem
Single-Source All-Destinations Shortest Paths With Negative Costs
SPIRE Normalized Similarity of RNA Sequences
Sequence Alignment Using Dynamic Programming
Intro to Alignment Algorithms: Global and Local
Clustering.
SPIRE Normalized Similarity of RNA Sequences
Sequence Alignment.
Dynamic Programming-- Longest Common Subsequence
Bioinformatics Algorithms and Data Structures
Spanning Trees Lecture 20 CS2110 – Spring 2015.
Special Graphs: Modeling and Algorithms
Clustering.
Presentation transcript:

Chapter 6: Dynamic Programming Algorithms July/18/2012 Name: Xuanyu Hu Professor: Elise de Doncker

Outline The power of DNA Sequence Comparison The Change Problem The Manhattan Tourist Problem Edit Distance

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

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 The Change Problem is a good problem to introduce the idea of dynamic programming

The Change Problem Goal: Convert some amount of money M into given denominations, using the fewest possible number of coins Input: An amount of money M, and an array of d denominations c = (c1, c2, …, cd), in a decreasing order of value (c1 > c2 > … > cd) Output: A list of d integers i1, i2, …, id such that c1i1 + c2i2 + … + cdid = M and i1 + i2 + … + id is minimal

Change Problem: Example Given the denominations 1, 3, and 5, what is the minimum number of coins needed to make change for a given value? 1 2 3 4 5 6 7 8 9 10 Value Min # of coins Only one coin is needed to make change for the values 1, 3, and 5

Given the denominations 1, 3, and 5, what is the minimum number of coins needed to make change for a given value? Value 1 2 3 4 5 6 7 8 9 10 Min # of coins 1 2 1 2 1 2 2 2 However, two coins are needed to make change for the values 2, 4, 6, 8, and 10.

Lastly, three coins are needed to make change for the values 7 and 9 Given the denominations 1, 3, and 5, what is the minimum number of coins needed to make change for a given value? Value 1 2 3 4 5 6 7 8 9 10 Min # of coins 1 2 1 2 1 2 3 2 3 2 Lastly, three coins are needed to make change for the values 7 and 9

Change Problem: Recurrence This example is expressed by the following recurrence relation: minNumCoins(M) = minNumCoins(M-1) + 1 minNumCoins(M-3) + 1 minNumCoins(M-5) + 1 min of

Given the denominations c: c1, c2, …, cd, the recurrence relation is: minNumCoins(M) = minNumCoins(M-c1) + 1 minNumCoins(M-c2) + 1 … minNumCoins(M-cd) + 1 min of

RecursiveChange(M,c,d) if M = 0 return 0 bestNumCoins  infinity for i  1 to d if M ≥ ci numCoins  RecursiveChange(M – ci , c, d) if numCoins + 1 < bestNumCoins bestNumCoins  numCoins + 1 return bestNumCoins

RecursiveChange Is Not Efficient It recalculates the optimal coin combination for a given amount of money repeatedly i.e., M = 77, c = (1,3,7): Optimal coin combo for 70 cents is computed 9 times!

The RecursiveChange Tree 77 76 74 70 75 73 69 73 71 67 69 67 63 74 72 68 68 66 62 70 68 64 68 66 62 62 60 56 72 70 66 72 70 66 66 64 60 66 64 60 . . . . . . 70 70 70 70 70

We Can Do Better We’re re-computing values in our algorithm more than once Save results of each computation for 0 to M This way, we can do a reference call to find an already computed value, instead of re-computing each time Running time M*d, where M is the value of money and d is the number of denominations

DPChange(M,c,d) bestNumCoins0  0 for m  1 to M bestNumCoinsm  infinity for i  1 to d if m ≥ ci if bestNumCoinsm – ci+ 1 < bestNumCoinsm bestNumCoinsm  bestNumCoinsm – ci+ 1 return bestNumCoinsM

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 Source * * * * * * * * * * * * Sink

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 Source * * * * * * * * * * * * Sink

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”

MTP: Dynamic Programming j 1 2 3 source 1 2 5 i 5 3 10 -5 -5 1 -5 1 3 5 -3 2 -5 3 3 2 -5 1 3 sink

MTP: Dynamic Programming j 1 2 3 source 1 2 5 1 3 8 Done! i 5 3 10 -5 -5 1 -5 1 5 4 13 8 (showing all back-traces) 3 5 -3 2 -5 3 3 2 8 9 12 15 -5 1 3 8 9 9 16 S3,3 = 16

MTP: Recurrence Computing the score for a point (i,j) by the recurrence relation: si, j = max si-1, j + weight of the edge between (i-1, j) and (i, j) si, 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)

Manhattan Is Not A Perfect Grid B A3 A1 A2 What about diagonals? The score at point B is given by: sB = max of sA1 + weight of the edge (A1, B) sA2 + weight of the edge (A2, B) sA3 + weight of the edge (A3, B)

DAG: Directed Acyclic Graph Since Manhattan is not a perfect regular grid, we represent it as a DAG DAG for Dressing in the morning problem

Topological Ordering A numbering of vertices of the graph is called topological ordering of the DAG if every edge of the DAG connects a vertex with a smaller label to a vertex with a larger label In other words, if vertices are positioned on a line in an increasing order of labels then all edges go from left to right.

Topological ordering 2 different topological orderings of the DAG

Longest Path in DAG Problem Goal: Find a longest path between two vertices in a weighted DAG Input: A weighted DAG G with source and sink vertices Output: A longest path in G from source to sink

Longest Path in DAG: Dynamic Programming Suppose vertex v has indegree 3 and predecessors {u1, u2, u3} Longest path to v from source is: In General: sv = maxu (su + weight of edge from u to v) su1 + weight of edge from u1 to v su2 + weight of edge from u2 to v su3 + weight of edge from u3 to v sv = max of

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

Aligning DNA Sequences Given 2 DNA sequences v and w: V = ATCTGATG n = 8 4 matches mismatches insertions deletions m = 7 1 W = TGCATAC 2 match mismatch 2 V A T C G W insertions indels deletions

Every Path in the Grid Corresponds to an Alignment W A T C G 0 1 2 2 3 4 V = A T - G T | | | W= A T C G – 0 1 2 3 4 4 V 1 2 3 4 A T G T

Aligning Sequences without Insertions and Deletions: Hamming Distance Given two DNA sequences v and w : v : A T w : A T The Hamming distance: dH(v, w) = 8 is large but the sequences are very similar

Aligning Sequences with Insertions and Deletions By shifting one sequence over one position: v : A T -- w : -- A T The edit distance: dH(v, w) = 2. Hamming distance neglects insertions and deletions in DNA

Edit Distance vs Hamming Distance always compares i-th letter of v with i-th letter of w V = ATATATAT W = TATATATA Hamming distance: d(v, w)=8 Computing Hamming distance is a trivial task.

Hamming distance: Edit distance: d(v, w)=8 d(v, w)=2 may compare i-th letter of v with j-th letter of w Hamming distance always compares i-th letter of v with i-th letter of w V = - ATATATAT V = ATATATAT Just one shift Make it all line up W = TATATATA W = TATATATA Hamming distance: Edit distance: d(v, w)=8 d(v, w)=2 Computing Hamming distance Computing edit distance is a trivial task is a non-trivial task

Hamming distance: Edit distance: d(v, w)=8 d(v, w)=2 may compare i-th letter of v with j-th letter of w Hamming distance always compares i-th letter of v with i-th letter of w V = - ATATATAT V = ATATATAT W = TATATATA W = TATATATA Hamming distance: Edit distance: d(v, w)=8 d(v, w)=2 (one insertion and one deletion)

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 3rd G) ATCCAT  (insert G before last A) ATCCGAT (Done)

TGCATAT  ATCCGAT in 5 steps TGCATAT  (delete last T) TGCATA  (delete last A) TGCAT  (insert A at front) ATGCAT  (substitute C for 3rd G) ATCCAT  (insert G before last A) ATCCGAT (Done) What is the edit distance? 5?

TGCATAT  ATCCGAT in 4 steps TGCATAT  (insert A at front) ATGCATAT  (delete 6th T) ATGCATA  (substitute G for 5th A) ATGCGTA  (substitute C for 3rd G) ATCCGAT (Done) Actually, the edit distance between them is 4

The Alignment Grid Every alignment path is from source to sink

Alignment as a Path in the Edit Graph 1 2 3 4 5 6 7 G A T C w v 0 1 2 2 3 4 5 6 7 7 A T _ G T T A T _ A T C G T _ A _ C 0 1 2 3 4 5 5 6 6 7 (0,0) , (1,1) , (2,2), (2,3), (3,4), (4,5), (5,5), (6,6), (7,6), (7,7) - Corresponding path -

w v and represent indels in v and w with score 0. represent matches with score 1. The score of the alignment path is 5. 1 2 3 4 5 6 7 G A T C w v

Alignment as a Path in the Edit Graph 1 2 3 4 5 6 7 G A T C w v Every path in the edit graph corresponds to an alignment:

w v Old Alignment 0122345677 v= AT_GTTAT_ w= ATCGT_A_C 0123455667 2 3 4 5 6 7 G A T C w v Old Alignment 0122345677 v= AT_GTTAT_ w= ATCGT_A_C 0123455667 New Alignment 0122345677 v= AT_GTTAT_ w= ATCG_TA_C 0123445667

w v 0122345677 v= AT_GTTAT_ w= ATCGT_A_C 0123455667 2 3 4 5 6 7 G A T C w v 0122345677 v= AT_GTTAT_ w= ATCGT_A_C 0123455667 (0,0) , (1,1) , (2,2), (2,3), (3,4), (4,5), (5,5), (6,6), (7,6), (7,7)

Conclusion and Question? The power of DNA Sequence Comparison The Change Problem The Manhattan Tourist Problem Edit Distance

References 1.http://bix.ucsd.edu/bioalgorithms/presentations/Ch06_EditDist.pdf 2.http://en.wikipedia.org/wiki/Change-making_problem 3.http://chinmaylokesh.wordpress.com/2011/02/19/manhattan-tourist-problem-good-problem-to-understand-dynamic-programming/ 4.http://www.itu.dk/courses/AVA/E2005/StringEditDistance.pdf 5.http://en.wikipedia.org/wiki/DNA_sequencing 6.http://www.algorithmist.com/index.php/Coin_Change