Presentation is loading. Please wait.

Presentation is loading. Please wait.

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

Similar presentations


Presentation on theme: "An Introduction to Bioinformatics 2. Comparing biological sequences: sequence alignment."— Presentation transcript:

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

2 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

3 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

4 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?

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

6 An Introduction to Bioinformatics 6 Evolution

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

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

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

10 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

11 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

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

13 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

14 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”

15 An Introduction to Bioinformatics MTP: An Example 324 073 33 0 132 4 4 5 6 4 6 5 5 8 2 2 5 0123 0 1 2 3 j coordinates i coordinates 13 source sink 4 3240 10 2 43 3 1 1 2 2 2 4 199515230203 4

16 An Introduction to Bioinformatics MTP: An Example 324 073 33 0 132 4 4 5 6 4 6 5 5 8 2 2 5 0123 0 1 2 3 j coordinates i coordinates 13 source sink 4 3240 10 2 43 3 1 1 2 2 2 4 199515340203 4 141017223032

17 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}

18 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

19 An Introduction to Bioinformatics 1 5 01 0 1 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

20 An Introduction to Bioinformatics MTP: Dynamic Programming 12 5 3 012 0 1 2 source 13 5 8 4 S 2,0 = 8 i S 1,1 = 4 S 0,2 = 3 3 -5 j

21 An Introduction to Bioinformatics MTP: Dynamic Programming 12 5 3 0123 0 1 2 3 i source 13 5 8 8 4 0 5 8 103 5 -5 9 13 1-5 S 3,0 = 8 S 2,1 = 9 S 1,2 = 13 S 3,0 = 8 j

22 An Introduction to Bioinformatics MTP: Dynamic Programming 125 -51 3 0 5 3 0 3 5 0 10 -3 -5 0123 0 1 2 3 i source 138 5 8 8 4 9 138 9 12 S 3,1 = 9 S 2,2 = 12 S 1,3 = 8 j

23 An Introduction to Bioinformatics MTP: Dynamic Programming (cont’d) 125 -51 33 00 5 3 0 3 5 0 10 -3 -5 2 0123 0 1 2 3 i source 138 5 8 8 4 9 138 12 9 15 9 j S 3,2 = 9 S 2,3 = 15

24 An Introduction to Bioinformatics MTP: Dynamic Programming (cont’d) 125 -51 33 00 5 3 0 3 5 0 10 -3 -5 2 0123 0 1 2 3 i source 138 5 8 8 4 9 138 12 9 15 9 j 0 1 16 S 3,3 = 16 (showing all back-traces) Done!

25 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)

26 An Introduction to Bioinformatics 26 Manhattan is not a perfect grid

27 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

28 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

29 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)

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

31 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

32 An Introduction to Bioinformatics LCS: Example AT -- CTGATG TGCT A C elements of v elements of w -- A 1 2 0 1 2 2 3 3 4 3 5 4 5 5 6 6 6 7 7 8 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)

33 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

34 An Introduction to Bioinformatics LCS Problem as Manhattan Tourist Problem T G C A T A C 1 2 3 4 5 6 7 0i ATCTGATC 012345678 j

35 An Introduction to Bioinformatics Edit Graph for LCS Problem T G C A T A C 1 2 3 4 5 6 7 0i ATCTGATC 012345678 j

36 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-1 + 1 if v i = w j

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

38 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 23 13 4 5 6 6 i j i 1, i 2, i 3, i 4 2346 j 1, j 2, j 3, j 4 1356 < < < 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

39 An Introduction to Bioinformatics Alignment Grid Example 01234 0 1 2 3 4 W ATCG A T G T V 0 1 2 2 3 4 V = A T - G T | | | W= A T C G – 0 1 2 3 4 4

40 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 :

41 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

42 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

43 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

44 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)

45 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)

46 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:

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

48 An Introduction to Bioinformatics 48 Alignment as a Path in the Edit Graph 0 1 2 2 3 4 5 6 7 7 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 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 -

49 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.

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

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

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

53 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

54 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.

55 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)

56 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

57 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

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

59 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

60 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.

61 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-1 10. 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-1 + 1 return (s n,m, b)

62 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

63 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)

64 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.


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

Similar presentations


Ads by Google