1 / 99

Combinatorial Pattern Matching

Combinatorial Pattern Matching. An Introduction to Bioinformatics Algorithms (Jones and Pevzner) www.bioalgorithms.info. Genomic Repeats. Example of repeats: A T GGTC TA GGTC CTAGT GGTC Motivation to find them: Genomic rearrangements are often associated with repeats

ferris
Télécharger la présentation

Combinatorial Pattern Matching

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Combinatorial Pattern Matching An Introduction to Bioinformatics Algorithms (Jones and Pevzner) www.bioalgorithms.info

  2. Genomic Repeats • Example of repeats: • ATGGTCTAGGTCCTAGTGGTC • Motivation to find them: • Genomic rearrangements are often associated with repeats • Trace evolutionary secrets • Many tumors are characterized by an explosion of repeats • ~50% of human genome composed of repeats An Introduction to Bioinformatics Algorithms (Jones and Pevzner) www.bioalgorithms.info

  3. Genomic Repeats • The problem is often more difficult: • ATGGTCTAGGACCTAGTGTTC • Motivation to find them: • Genomic rearrangements are often associated with repeats • Trace evolutionary secrets • Many tumors are characterized by an explosion of repeats • ~50% of human genome composed of repeats An Introduction to Bioinformatics Algorithms (Jones and Pevzner) www.bioalgorithms.info

  4. l-mer Repeats • Long repeats are difficult to find • Short repeats are easy to find (e.g., hashing) • Simple approach to finding long repeats: • Find exact repeats of short l-mers. lis usually 10 to 13; for an n-element sequence, table would need 4l bins with ~ n/4l elements/bin (i.e., because there are n-l + 1 l -mers per sequence) • Use l-mer repeats to potentially extend into longer, maximal repeats An Introduction to Bioinformatics Algorithms (Jones and Pevzner) www.bioalgorithms.info

  5. l-mer Repeats (cont’d) • There are typically many locations where an l-mer is repeated: GCTTACAGATTCAGTCTTACAGATGGT • The 4-mer TTAC starts at locations 3 and 17 An Introduction to Bioinformatics Algorithms (Jones and Pevzner) www.bioalgorithms.info

  6. Extending l-mer Repeats GCTTACAGATTCAGTCTTACAGATGGT • Extend these 4-mer matches: GCTTACAGATTCAGTCTTACAGATGGT • Maximal repeat: TTACAGAT An Introduction to Bioinformatics Algorithms (Jones and Pevzner) www.bioalgorithms.info

  7. Maximal Repeats • To find maximal repeats in this way, we need ALL start locations of all l-mers in the genome • Hashing lets us find repeats quickly in this manner An Introduction to Bioinformatics Algorithms (Jones and Pevzner) www.bioalgorithms.info

  8. Hashing: What is it? • What does hashing do? • For different data, generate a unique integer • Store data in an array at the unique integer index generated from the data • Hashing is a very efficient way to store and retrieve data An Introduction to Bioinformatics Algorithms (Jones and Pevzner) www.bioalgorithms.info

  9. Hashing: Definitions • Hash table: array used in hashing • Records: data stored in a hash table • Keys: identifies sets of records • Hash function: uses a key to generate an index to insert at in hash table • Collision: when more than one record is mapped to the same index in the hash table An Introduction to Bioinformatics Algorithms (Jones and Pevzner) www.bioalgorithms.info

  10. Hashing DNA sequences • Each l-mer can be translated into a binary string (A, C, G, Tcan be represented as 00, 01, 10, 11) • After assigning a unique integer per l-mer it is easy to get all start locations of each l-mer in a genome An Introduction to Bioinformatics Algorithms (Jones and Pevzner) www.bioalgorithms.info

  11. Hashing: Maximal Repeats • To find repeats in a genome: • For all l-mers in the genome, note the start position and the sequence • Generate a hash table index for each unique l-mer sequence • In each index of the hash table, store all genome start locations of the l-mer which generated that index • Extend l-mer repeats to maximal repeats An Introduction to Bioinformatics Algorithms (Jones and Pevzner) www.bioalgorithms.info

  12. Hashing: Collisions • Dealing with collisions: • “Chain” all start locations of l-mers (linked list) An Introduction to Bioinformatics Algorithms (Jones and Pevzner) www.bioalgorithms.info

  13. Pattern Matching • What if, instead of finding repeats in a genome, we want to find all sequences in a database that contain a given pattern? • This leads us to a different problem, the Pattern MatchingProblem An Introduction to Bioinformatics Algorithms (Jones and Pevzner) www.bioalgorithms.info

  14. Pattern Matching Problem • Goal: Find all occurrences of a pattern in a text • Input: Pattern p = p1…pn and text t = t1…tm • Output: All positions 1<i< (m – n + 1) such that the n-letter substring of t starting at i matches p • Motivation: Searching database for a known pattern An Introduction to Bioinformatics Algorithms (Jones and Pevzner) www.bioalgorithms.info

  15. Exact Pattern Matching: A Brute-Force Algorithm PatternMatching(p,t) • n length of pattern p • m length of text t • for i 1 to (m – n + 1) • if ti…ti+n-1 = p • outputi An Introduction to Bioinformatics Algorithms (Jones and Pevzner) www.bioalgorithms.info

  16. Exact Pattern Matching: An Example GCAT • PatternMatching algorithm for: • Pattern GCAT • Text CGCATC CGCATC GCAT CGCATC GCAT CGCATC GCAT CGCATC GCAT CGCATC An Introduction to Bioinformatics Algorithms (Jones and Pevzner) www.bioalgorithms.info

  17. Exact Pattern Matching: Running Time • PatternMatching runtime: O(nm) • Probability-wise, it’s more like O(m) • Rarely will there be close to n comparisons in line 4 (e.g., consider looking for AAAAT in a string consisting of 106 A’s…). Note: probability for x character types that the first character matches is 1/x; probability that it doesn’t is (x-1)/x. Probability that first matches and second doesn’t is (x-1)/x2. The probability that the first j characters match is 1/xj. • Better solution: suffix trees • Can solve problem in O(m) time • Conceptually related to keyword trees An Introduction to Bioinformatics Algorithms (Jones and Pevzner) www.bioalgorithms.info

  18. Keyword Trees: Example • Keyword tree: • Apple An Introduction to Bioinformatics Algorithms (Jones and Pevzner) www.bioalgorithms.info

  19. Keyword Trees: Example (cont’d) • Keyword tree: • Apple • Apropos An Introduction to Bioinformatics Algorithms (Jones and Pevzner) www.bioalgorithms.info

  20. Keyword Trees: Example (cont’d) • Keyword tree: • Apple • Apropos • Banana An Introduction to Bioinformatics Algorithms (Jones and Pevzner) www.bioalgorithms.info

  21. Keyword Trees: Example (cont’d) • Keyword tree: • Apple • Apropos • Banana • Bandana An Introduction to Bioinformatics Algorithms (Jones and Pevzner) www.bioalgorithms.info

  22. Keyword Trees: Example (cont’d) • Keyword tree: • Apple • Apropos • Banana • Bandana • Orange An Introduction to Bioinformatics Algorithms (Jones and Pevzner) www.bioalgorithms.info

  23. Keyword Trees: Properties • Stores a set of keywords in a rooted labeled tree • Each edge labeled with a letter from an alphabet • Any two edges coming out of the same vertex have distinct labels • Every keyword stored can be spelled on a path from root to some leaf An Introduction to Bioinformatics Algorithms (Jones and Pevzner) www.bioalgorithms.info

  24. Keyword Trees: Threading (cont’d) • Search for “appeal” • appeal An Introduction to Bioinformatics Algorithms (Jones and Pevzner) www.bioalgorithms.info

  25. Keyword Trees: Threading (cont’d) • Search for “appeal” • appeal An Introduction to Bioinformatics Algorithms (Jones and Pevzner) www.bioalgorithms.info

  26. Keyword Trees: Threading (cont’d) • Search for “appeal” • appeal An Introduction to Bioinformatics Algorithms (Jones and Pevzner) www.bioalgorithms.info

  27. Keyword Trees: Threading (cont’d) • Search for “appeal” • appeal An Introduction to Bioinformatics Algorithms (Jones and Pevzner) www.bioalgorithms.info

  28. Keyword Trees: Threading (cont’d) • Search for “apple” • apple An Introduction to Bioinformatics Algorithms (Jones and Pevzner) www.bioalgorithms.info

  29. Keyword Trees: Threading (cont’d) • Search for “apple” • apple An Introduction to Bioinformatics Algorithms (Jones and Pevzner) www.bioalgorithms.info

  30. Keyword Trees: Threading (cont’d) • Search for “apple” • apple An Introduction to Bioinformatics Algorithms (Jones and Pevzner) www.bioalgorithms.info

  31. Keyword Trees: Threading (cont’d) • Search for “apple” • apple An Introduction to Bioinformatics Algorithms (Jones and Pevzner) www.bioalgorithms.info

  32. Keyword Trees: Threading (cont’d) • Search for “apple” • apple An Introduction to Bioinformatics Algorithms (Jones and Pevzner) www.bioalgorithms.info

  33. Multiple Pattern Matching Problem • Goal: Given a set of patterns and a text, find all occurrences of any of the patterns in the text • Input: k patterns p1,…,pk, and text t = t1…tm • Output: Positions 1 <i<m where substring of t starting at imatches pj for 1 <j<k • Motivation: Searching database for known multiple patterns An Introduction to Bioinformatics Algorithms (Jones and Pevzner) www.bioalgorithms.info

  34. Multiple Pattern Matching: Straightforward Approach • Can solve as k “Pattern Matching Problems” • Runtime: O(kmn) using the PatternMatching algorithm k times • m - length of the text • n - average length of the pattern An Introduction to Bioinformatics Algorithms (Jones and Pevzner) www.bioalgorithms.info

  35. Multiple Pattern Matching: Keyword Tree Approach • Or, we could use keyword trees: • Build keyword tree in O(N) time; N is total length of all patterns (i.e., k*n) • With naive threading: O(N + nm) • Aho-Corasick algorithm: O(N + m) Example: Suppose m = 106, k=100, and n = 1000 O(kmn)  102*106*103 = 1011 O(N + nm)  102*103 + 103*106 = 105 + 109 ≈ 109 O(N + m)  102*103 + 106 = 105 + 106 ≈ 106 An Introduction to Bioinformatics Algorithms (Jones and Pevzner) www.bioalgorithms.info

  36. Keyword Trees: Threading • To match patterns in a text using a keyword tree: • Build keyword tree of patterns • “Thread” the text through the keyword tree An Introduction to Bioinformatics Algorithms (Jones and Pevzner) www.bioalgorithms.info

  37. Keyword Trees: Threading (cont’d) • Threading is “complete” when we reach a leaf in the keyword tree • When threading is “complete,” we’ve found a pattern in the text An Introduction to Bioinformatics Algorithms (Jones and Pevzner) www.bioalgorithms.info

  38. Suffix Trees=Collapsed Keyword Trees • Similar to keyword trees, except edges that form paths are collapsed • Each edge is labeled with a substring of a text • All internal vertices have at least two outgoing edges • Leaves labeled by the index of the pattern. An Introduction to Bioinformatics Algorithms (Jones and Pevzner) www.bioalgorithms.info

  39. Suffix Tree of a Text • Suffix trees of a text is constructed for all its suffixes ATCATG TCATG CATG ATG TG G Keyword Tree Suffix Tree An Introduction to Bioinformatics Algorithms (Jones and Pevzner) www.bioalgorithms.info

  40. Suffix Tree of a Text • Suffix trees of a text is constructed for all its suffixes ATCATG TCATG CATG ATG TG G Keyword Tree Suffix Tree How much time does it take? An Introduction to Bioinformatics Algorithms (Jones and Pevzner) www.bioalgorithms.info

  41. Suffix Tree of a Text • Suffix trees of a text is constructed for all its suffixes ATCATG TCATG CATG ATG TG G Keyword Tree Suffix Tree quadratic Time is linear in the total size of all suffixes, i.e., it is quadratic in the length of the text An Introduction to Bioinformatics Algorithms (Jones and Pevzner) www.bioalgorithms.info

  42. Suffix Trees: Advantages • Suffix trees of a text is constructed for all its suffixes • Suffix trees build faster than keyword trees ATCATG TCATG CATG ATG TG G Keyword Tree Suffix Tree quadratic linear (Weiner suffix tree algorithm) An Introduction to Bioinformatics Algorithms (Jones and Pevzner) www.bioalgorithms.info

  43. Use of Suffix Trees • Suffix trees hold all suffixes of a text • i.e., ATCGC: ATCGC, TCGC, CGC, GC, C • Builds in O(m) time for text of length m • To find any pattern of length n in a text: • Build suffix tree for text • Thread the pattern through the suffix tree • Can find pattern in text in O(n) time! • O(n + m) time for “Pattern Matching Problem” • Build suffix tree and lookup pattern An Introduction to Bioinformatics Algorithms (Jones and Pevzner) www.bioalgorithms.info

  44. Pattern Matching with Suffix Trees SuffixTreePatternMatching(p,t) • Build suffix tree for text t • Thread pattern p through suffix tree • if threading is complete • output positions of all p-matching leaves in the tree • else • output “Pattern does not appear in text” An Introduction to Bioinformatics Algorithms (Jones and Pevzner) www.bioalgorithms.info

  45. Suffix Trees: Example G G An Introduction to Bioinformatics Algorithms (Jones and Pevzner) www.bioalgorithms.info

  46. Multiple Pattern Matching: Summary • Keyword and suffix trees are used to find patterns in a text • Keyword trees: • Build keyword tree of patterns, and thread text through it • Suffix trees: • Build suffix tree of text, and thread patterns through it An Introduction to Bioinformatics Algorithms (Jones and Pevzner) www.bioalgorithms.info

  47. Approximate vs. Exact Pattern Matching • So far all we’ve seen exact pattern matching algorithms • Usually, because of mutations, it makes much more biological sense to find approximate pattern matches • Biologists often use fast heuristic approaches (rather than local alignment) to find approximate matches An Introduction to Bioinformatics Algorithms (Jones and Pevzner) www.bioalgorithms.info

  48. Heuristic Similarity Searches • Genomes are huge: Smith-Waterman quadratic alignment algorithms are too slow • Alignment of two sequences usually has short identical or highly similar fragments • Many heuristic methods (i.e., FASTA) are based on the same idea of filtration • Find short exact matches, and use them as seeds for potential match extension • “Filter” out positions with no extendable matches An Introduction to Bioinformatics Algorithms (Jones and Pevzner) www.bioalgorithms.info

  49. Dot Matrices • Dot matrices show similarities between two sequences • FASTA makes an implicit dot matrix from short exact matches, and tries to find long diagonals (allowing for some mismatches) An Introduction to Bioinformatics Algorithms (Jones and Pevzner) www.bioalgorithms.info

More Related