CSE 5290: Algorithms for Bioinformatics Fall 2009

Slides:



Advertisements
Similar presentations
Algorithm Analysis Input size Time I1 T1 I2 T2 …
Advertisements

Gene Regulation and Microarrays. Finding Regulatory Motifs Given a collection of genes with common expression, Find the TF-binding motif in common......
. Markov Chains. 2 Dependencies along the genome In previous classes we assumed every letter in a sequence is sampled randomly from some distribution.
296.3: Algorithms in the Real World
Combinatorial Pattern Matching CS 466 Saurabh Sinha.
Bioinformatics Dr. Aladdin HamwiehKhalid Al-shamaa Abdulqader Jighly Lecture 3 Finding Motifs Aleppo University Faculty of technical engineering.
Motif Finding. Regulation of Genes Gene Regulatory Element RNA polymerase (Protein) Transcription Factor (Protein) DNA.
Branch and Bound Similar to backtracking in generating a search tree and looking for one or more solutions Different in that the “objective” is constrained.
Pattern Discovery in RNA Secondary Structure Using Affix Trees (when computer scientists meet real molecules) Giulio Pavesi& Giancarlo Mauri Dept. of Computer.
Multiple Sequence Alignment Algorithms in Computational Biology Spring 2006 Most of the slides were created by Dan Geiger and Ydo Wexler and edited by.
L16: Micro-array analysis Dimension reduction Unsupervised clustering.
Sequence Alignment Variations Computing alignments using only O(m) space rather than O(mn) space. Computing alignments with bounded difference Exclusion.
6/29/20151 Efficient Algorithms for Motif Search Sudha Balla Sanguthevar Rajasekaran University of Connecticut.
Introduction to Bioinformatics Algorithms Finding Regulatory Motifs in DNA Sequences.
(Regulatory-) Motif Finding. Clustering of Genes Find binding sites responsible for common expression patterns.
Finding Regulatory Motifs in DNA Sequences
Backtracking.
Phylogenetic Tree Construction and Related Problems Bioinformatics.
Finding Regulatory Motifs in DNA Sequences. Motifs and Transcriptional Start Sites gene ATCCCG gene TTCCGG gene ATCCCG gene ATGCCG gene ATGCCC.
Motif finding: Lecture 1 CS 498 CXZ. From DNA to Protein: In words 1.DNA = nucleotide sequence Alphabet size = 4 (A,C,G,T) 2.DNA  mRNA (single stranded)
Multiple Sequence Alignment CSC391/691 Bioinformatics Spring 2004 Fetrow/Burg/Miller (Slides by J. Burg)
Motif Finding Kun-Pin Wu ( 巫坤品 ) Institute of Biomedical Informatics National Yang Ming University 2007/11/20.
Finding Regulatory Motifs in DNA Sequences An Introduction to Bioinformatics Algorithms (Jones and Pevzner)
Introduction to Bioinformatics Algorithms Finding Regulatory Motifs in DNA Sequences.
Introduction n – length of text, m – length of search pattern string Generally suffix tree construction takes O(n) time, O(n) space and searching takes.
Analysis of Algorithms
Motif finding with Gibbs sampling CS 466 Saurabh Sinha.
Parsimony-Based Approaches to Inferring Phylogenetic Trees BMI/CS 576 Colin Dewey Fall 2010.
Outline More exhaustive search algorithms Today: Motif finding
Markov Chain Monte Carlo and Gibbs Sampling Vasileios Hatzivassiloglou University of Texas at Dallas.
Greedy Algorithms CS 498 SS Saurabh Sinha. A greedy approach to the motif finding problem Given t sequences of length n each, to find a profile matrix.
BLAST: Basic Local Alignment Search Tool Altschul et al. J. Mol Bio CS 466 Saurabh Sinha.
Introduction to Bioinformatics Algorithms Finding Regulatory Motifs in DNA Sequences.
MS Sequence Clustering
Gene Prediction: Similarity-Based Methods (Lecture for CS498-CXZ Algorithms in Bioinformatics) Sept. 15, 2005 ChengXiang Zhai Department of Computer Science.
Exhaustive search (cont’d) CS 466 Saurabh Sinha. Finding motifs ab initio Enumerate all possible strings of some fixed (small) length For each such string.
Finding Regulatory Motifs in DNA Sequences
Motif Finding [1]: Ch , , 5.5,
. Finding Motifs in Promoter Regions Libi Hertzberg Or Zuk.
Introduction to Bioinformatics Algorithms Finding Regulatory Motifs in DNA Sequences.
Intro to Probabilistic Models PSSMs Computational Genomics, Lecture 6b Partially based on slides by Metsada Pasmanik-Chor.
HW4: sites that look like transcription start sites Nucleotide histogram Background frequency Count matrix for translation start sites (-10 to 10) Frequency.
Finding Motifs Vasileios Hatzivassiloglou University of Texas at Dallas.
Advanced Data Structures Lecture 8 Mingmin Xie. Agenda Overview Trie Suffix Tree Suffix Array, LCP Construction Applications.
CSCI2950-C Genomes, Networks, and Cancer
BackTracking CS255.
Gibbs sampling.
Heuristic Search A heuristic is a rule for choosing a branch in a state space search that will most likely lead to a problem solution Heuristics are used.
13 Text Processing Hongfei Yan June 1, 2016.
Learning Sequence Motif Models Using Expectation Maximization (EM)
JinJu Lee & Beatrice Seifert CSE 5311 Fall 2005 Week 10 (Nov 1 & 3)
CSE 5290: Algorithms for Bioinformatics Fall 2011
Probabilities and Probabilistic Models
Hierarchical clustering approaches for high-throughput data
Recitation 7 2/4/09 PSSMs+Gene finding
Finding Regulatory Motifs in DNA Sequences
Data Structures Review Session
Graph Algorithms in Bioinformatics
CSE 589 Applied Algorithms Spring 1999
(Regulatory-) Motif Finding
3. Brute Force Selection sort Brute-Force string matching
3. Brute Force Selection sort Brute-Force string matching
Backtracking and Branch-and-Bound
Dynamic Programming II DP over Intervals
CSE 5290: Algorithms for Bioinformatics Fall 2009
The Selection Problem.
CSE 5290: Algorithms for Bioinformatics Fall 2009
Clustering.
Algorithm Course Algorithms Lecture 3 Sorting Algorithm-1
3. Brute Force Selection sort Brute-Force string matching
Presentation transcript:

CSE 5290: Algorithms for Bioinformatics Fall 2009 Suprakash Datta datta@cs.yorku.ca Office: CSEB 3043 Phone: 416-736-2100 ext 77875 Course page: http://www.cs.yorku.ca/course/5290 4/6/2019 CSE 5290, Fall 2009

Last time DNA Mapping and Brute Force Algorithms Next: Finding Regulatory Motifs in DNA sequences 4/6/2019 CSE 5290, Fall 2009

Combinatorial Gene Regulation A microarray experiment showed that when gene X is knocked out, 20 other genes are not expressed How can one gene have such drastic effects? 4/6/2019 CSE 5290, Fall 2009

Regulatory Proteins Gene X encodes regulatory protein, a.k.a. a transcription factor (TF) The 20 unexpressed genes rely on gene X’s TF to induce transcription A single TF may regulate multiple genes 4/6/2019 CSE 5290, Fall 2009

Regulatory Regions Every gene contains a regulatory region (RR) typically stretching 100-1000 bp upstream of the transcriptional start site Located within the RR are the Transcription Factor Binding Sites (TFBS), also known as motifs, specific for a given transcription factor TFs influence gene expression by binding to a specific location in the respective gene’s regulatory region - TFBS 4/6/2019 CSE 5290, Fall 2009

Transcription Factor Binding Sites A TFBS can be located anywhere within the Regulatory Region. TFBS may vary slightly across different regulatory regions since non-essential bases could mutate 4/6/2019 CSE 5290, Fall 2009

Motifs and Transcriptional Start Sites ATCCCG gene TTCCGG gene ATCCCG gene ATGCCG gene ATGCCC gene 4/6/2019 CSE 5290, Fall 2009

Transcription Factors and Motifs 4/6/2019 CSE 5290, Fall 2009

Motif Logo TGGGGGA TGAGAGA TGAGGGA Motifs can mutate on non important bases The five motifs in five different genes have mutations in position 3 and 5 Representations called motif logos illustrate the conserved and variable regions of a motif TGGGGGA TGAGAGA TGAGGGA 4/6/2019 CSE 5290, Fall 2009

Identifying Motifs Genes are turned on or off by regulatory proteins These proteins bind to upstream regulatory regions of genes to either attract or block an RNA polymerase Regulatory protein (TF) binds to a short DNA sequence called a motif (TFBS) So finding the same motif in multiple genes’ regulatory regions suggests a regulatory relationship amongst those genes 4/6/2019 CSE 5290, Fall 2009

Identifying Motifs: Complications We do not know the motif sequence We do not know where it is located relative to the genes start Motifs can differ slightly from one gene to the next How to discern it from “random” motifs? 4/6/2019 CSE 5290, Fall 2009

Motifs: summary Short strings Transcription factors bind to motifs Regulate downstream genes Challenge: must find patterns without knowing them 4/6/2019 CSE 5290, Fall 2009

How can we do this? Statistics? Brute force search 4/6/2019 CSE 5290, Fall 2009

Statistical approaches Deciphering encoded English text. 4/6/2019 CSE 5290, Fall 2009

Motif Finding and The Gold Bug Problem: Similarities Nucleotides in motifs encode for a message in the “genetic” language. Symbols in “The Gold Bug” encode for a message in English In order to solve the problem, we analyze the frequencies of patterns in DNA/Gold Bug message. Knowledge of established regulatory motifs makes the Motif Finding problem simpler. Knowledge of the words in the English dictionary helps to solve the Gold Bug problem. 4/6/2019 CSE 5290, Fall 2009

Similarities (cont’d) Motif Finding: In order to solve the problem, we analyze the frequencies of patterns in the nucleotide sequences Gold Bug Problem: In order to solve the problem, we analyze the frequencies of patterns in the text written in English 4/6/2019 CSE 5290, Fall 2009

Similarities (cont’d) Motif Finding: Knowledge of established motifs reduces the complexity of the problem Gold Bug Problem: Knowledge of the words in the dictionary is highly desirable 4/6/2019 CSE 5290, Fall 2009

Motif Finding and The Gold Bug Problem: Differences Motif Finding is harder than Gold Bug problem: We don’t have the complete dictionary of motifs The “genetic” language does not have a standard “grammar” Only a small fraction of nucleotide sequences encode for motifs; the size of data is enormous 4/6/2019 CSE 5290, Fall 2009

Challenge Problem Find a motif in a sample of - 20 “random” sequences (e.g. 600 nt long) - each sequence containing an implanted pattern of length 15, - each pattern appearing with 4 mismatches as (15,4)-motif. 4/6/2019 CSE 5290, Fall 2009

Exhaustive searches 4/6/2019 CSE 5290, Fall 2009

The Motif Finding Problem Given a random sample of DNA sequences: cctgatagacgctatctggctatccacgtacgtaggtcctctgtgcgaatctatgcgtttccaaccat agtactggtgtacatttgatacgtacgtacaccggcaacctgaaacaaacgctcagaaccagaagtgc aaacgtacgtgcaccctctttcttcgtggctctggccaacgagggctgatgtataagacgaaaatttt agcctccgatgtaagtcatagctgtaactattacctgccacccctattacatcttacgtacgtataca ctgttatacaacgcgtcatggcggggtatgcgttttggtcgtcgtacgctcgatcgttaacgtacgtc Find the pattern that is implanted in each of the individual sequences, namely, the motif 4/6/2019 CSE 5290, Fall 2009

The Motif Finding Problem (cont’d) Additional information: The hidden sequence is of length 8 The pattern is not exactly the same in each array because random point mutations may occur in the sequences 4/6/2019 CSE 5290, Fall 2009

The Motif Finding Problem (cont’d) The patterns revealed with no mutations: cctgatagacgctatctggctatccacgtacgtaggtcctctgtgcgaatctatgcgtttccaaccat agtactggtgtacatttgatacgtacgtacaccggcaacctgaaacaaacgctcagaaccagaagtgc aaacgtacgtgcaccctctttcttcgtggctctggccaacgagggctgatgtataagacgaaaatttt agcctccgatgtaagtcatagctgtaactattacctgccacccctattacatcttacgtacgtataca ctgttatacaacgcgtcatggcggggtatgcgttttggtcgtcgtacgctcgatcgttaacgtacgtc acgtacgt Consensus String 4/6/2019 CSE 5290, Fall 2009

The Motif Finding Problem (cont’d) The patterns with 2 point mutations: cctgatagacgctatctggctatccaGgtacTtaggtcctctgtgcgaatctatgcgtttccaaccat agtactggtgtacatttgatCcAtacgtacaccggcaacctgaaacaaacgctcagaaccagaagtgc aaacgtTAgtgcaccctctttcttcgtggctctggccaacgagggctgatgtataagacgaaaatttt agcctccgatgtaagtcatagctgtaactattacctgccacccctattacatcttacgtCcAtataca ctgttatacaacgcgtcatggcggggtatgcgttttggtcgtcgtacgctcgatcgttaCcgtacgGc 4/6/2019 CSE 5290, Fall 2009

The Motif Finding Problem (cont’d) The patterns with 2 point mutations: cctgatagacgctatctggctatccaGgtacTtaggtcctctgtgcgaatctatgcgtttccaaccat agtactggtgtacatttgatCcAtacgtacaccggcaacctgaaacaaacgctcagaaccagaagtgc aaacgtTAgtgcaccctctttcttcgtggctctggccaacgagggctgatgtataagacgaaaatttt agcctccgatgtaagtcatagctgtaactattacctgccacccctattacatcttacgtCcAtataca ctgttatacaacgcgtcatggcggggtatgcgttttggtcgtcgtacgctcgatcgttaCcgtacgGc Can we still find the motif, now that we have 2 mutations? 4/6/2019 CSE 5290, Fall 2009

Defining Motifs To define a motif, lets say we know where the motif starts in the sequence The motif start positions in their sequences can be represented as s = (s1,s2,s3,…,st) 4/6/2019 CSE 5290, Fall 2009

Motifs: Profiles and Consensus Line up the patterns by their start indexes s = (s1, s2, …, st) Construct matrix profile with frequencies of each nucleotide in columns Consensus nucleotide in each position has the highest score in column a G g t a c T t C c A t a c g t Alignment a c g t T A g t a c g t C c A t C c g t a c g G _________________ A 3 0 1 0 3 1 1 0 Profile C 2 4 0 0 1 4 0 0 G 0 1 4 0 0 0 3 1 T 0 0 0 5 1 0 1 4 Consensus A C G T A C G T 4/6/2019 CSE 5290, Fall 2009

Consensus Think of consensus as an “ancestor” motif, from which mutated motifs emerged The distance between a real motif and the consensus sequence is generally less than that for two real motifs 4/6/2019 CSE 5290, Fall 2009

Consensus (cont’d) 4/6/2019 CSE 5290, Fall 2009

Evaluating Motifs We have a guess about the consensus sequence, but how “good” is this consensus? Need to introduce a scoring function to compare different guesses and choose the “best” one. 4/6/2019 CSE 5290, Fall 2009

Defining Some Terms t - number of sample DNA sequences n - length of each DNA sequence DNA - sample of DNA sequences (t x n array) l - length of the motif (l-mer) si - starting position of an l-mer in sequence i s=(s1, s2,… st) - array of motif’s starting positions 4/6/2019 CSE 5290, Fall 2009

Parameters l = 8 DNA t=5 s s1 = 26 s2 = 21 s3= 3 s4 = 56 s5 = 60 cctgatagacgctatctggctatccaGgtacTtaggtcctctgtgcgaatctatgcgtttccaaccat agtactggtgtacatttgatCcAtacgtacaccggcaacctgaaacaaacgctcagaaccagaagtgc aaacgtTAgtgcaccctctttcttcgtggctctggccaacgagggctgatgtataagacgaaaatttt agcctccgatgtaagtcatagctgtaactattacctgccacccctattacatcttacgtCcAtataca ctgttatacaacgcgtcatggcggggtatgcgttttggtcgtcgtacgctcgatcgttaCcgtacgGc l = 8 DNA t=5 n = 69 s s1 = 26 s2 = 21 s3= 3 s4 = 56 s5 = 60 4/6/2019 CSE 5290, Fall 2009

Scoring Motifs Given s = (s1, … st) and DNA: Score(s,DNA) = l t a G g t a c T t C c A t a c g t a c g t T A g t a c g t C c A t C c g t a c g G _________________ A 3 0 1 0 3 1 1 0 C 2 4 0 0 1 4 0 0 G 0 1 4 0 0 0 3 1 T 0 0 0 5 1 0 1 4 Consensus a c g t a c g t Score 3+4+4+5+3+4+3+4=30 t 4/6/2019 CSE 5290, Fall 2009

The Motif Finding Problem If starting positions s=(s1, s2,… st) are given, finding consensus is easy even with mutations in the sequences because we can simply construct the profile to find the motif (consensus) But… the starting positions s are usually not given. How can we find the “best” profile matrix? 4/6/2019 CSE 5290, Fall 2009

The Motif Finding Problem: Formulation Goal: Given a set of DNA sequences, find a set of l-mers, one from each sequence, that maximizes the consensus score Input: A t x n matrix of DNA, and l, the length of the pattern to find Output: An array of t starting positions s = (s1, s2, … st) maximizing Score(s,DNA) 4/6/2019 CSE 5290, Fall 2009

The Motif Finding Problem: Brute Force Solution Compute the scores for each possible combination of starting positions s The best score will determine the best profile and the consensus pattern in DNA The goal is to maximize Score(s,DNA) by varying the starting positions si, where: si = [1, …, n-l+1] i = [1, …, t] 4/6/2019 CSE 5290, Fall 2009

BruteForceMotifSearch BruteForceMotifSearch(DNA, t, n, l) bestScore  0 for each s=(s1,s2 , . . ., st) from (1,1 . . . 1) to (n-l+1, . . ., n-l+1) if (Score(s,DNA) > bestScore) bestScore  score(s, DNA) bestMotif  (s1,s2 , . . . , st) return bestMotif 4/6/2019 CSE 5290, Fall 2009

Running Time of BruteForceMotifSearch Varying (n - l + 1) positions in each of t sequences, we’re looking at (n - l + 1)t sets of starting positions For each set of starting positions, the scoring function makes l operations, so complexity is l (n – l + 1)t = O(l nt) That means that for t = 8, n = 1000, l = 10 we must perform approximately 1020 computations – it will take billions of years 4/6/2019 CSE 5290, Fall 2009

The Median String Problem Given a set of t DNA sequences find a pattern that appears in all t sequences with the minimum number of mutations This pattern will be the motif 4/6/2019 CSE 5290, Fall 2009

Hamming Distance Hamming distance: dH(v,w) is the number of nucleotide pairs that do not match when v and w are aligned. For example: dH(AAAAAA,ACAAAC) = 2 4/6/2019 CSE 5290, Fall 2009

Total Distance: Definition (Intuition: let v be a (candidate) motif) For each DNA sequence i, compute all dH(v, x), where x is an l-mer with starting position si (1 < si < n – l + 1) Find minimum of dH(v, x) among all l-mers in sequence i TotalDistance(v,DNA,s) is the sum of the minimum Hamming distances for each DNA sequence i TotalDistance(v,DNA) = mins dH(v, s), where s is the set of starting positions s1, s2,… st 4/6/2019 CSE 5290, Fall 2009

The Median String Problem: Formulation Goal: Given a set of DNA sequences, find a median string Input: A t x n matrix DNA, and l, the length of the pattern to find Output: A string v of l nucleotides that minimizes TotalDistance(v,DNA) over all strings of that length 4/6/2019 CSE 5290, Fall 2009

Median String Search Algorithm MedianStringSearch (DNA, t, n, l) bestWord  AAA…A bestDistance  ∞ for each l-mer s from AAA…A to TTT…T if TotalDistance(s,DNA) < bestDistance bestDistanceTotalDistance(s,DNA) bestWord  s return bestWord 4/6/2019 CSE 5290, Fall 2009

Motif Finding Problem == Median String Problem The Motif Finding is a maximization problem while Median String is a minimization problem However, the Motif Finding problem and Median String problem are computationally equivalent Need to show that minimizing TotalDistance is equivalent to maximizing Score 4/6/2019 CSE 5290, Fall 2009

We are looking for the same thing At any column i Scorei + TotalDistancei = t Because there are l columns Score + TotalDistance = l * t Rearranging: Score = l * t - TotalDistance l * t is constant the minimization of the right side is equivalent to the maximization of the left side a G g t a c T t C c A t a c g t Alignment a c g t T A g t a c g t C c A t C c g t a c g G _________________ A 3 0 1 0 3 1 1 0 Profile C 2 4 0 0 1 4 0 0 G 0 1 4 0 0 0 3 1 T 0 0 0 5 1 0 1 4 Consensus a c g t a c g t Score 3+4+4+5+3+4+3+4 TotalDistance 2+1+1+0+2+1+2+1 Sum 5 5 5 5 5 5 5 5 t 4/6/2019 CSE 5290, Fall 2009

Motif Finding Problem vs. Median String Problem Why bother reformulating the Motif Finding problem into the Median String problem? The Motif Finding Problem needs to examine all the combinations for s. That is (n - l + 1)t combinations!!! The Median String Problem needs to examine all 4l combinations for v. This number is relatively smaller 4/6/2019 CSE 5290, Fall 2009

Motif Finding: Improving the Running Time Recall the BruteForceMotifSearch: BruteForceMotifSearch(DNA, t, n, l) bestScore  0 for each s=(s1,s2 , . . ., st) from (1,1 . . . 1) to (n-l+1, . . ., n-l+1) if (Score(s,DNA) > bestScore) bestScore  Score(s, DNA) bestMotif  (s1,s2 , . . . , st) return bestMotif 4/6/2019 CSE 5290, Fall 2009

Structuring the Search How can we perform the line for each s=(s1,s2 , . . ., st) from (1,1 . . . 1) to (n-l+1, . . ., n-l+1) ? We need a method for efficiently structuring and navigating the many possible motifs This is not very different than exploring all t-digit numbers 4/6/2019 CSE 5290, Fall 2009

Median String: Improving the Running Time MedianStringSearch (DNA, t, n, l) bestWord  AAA…A bestDistance  ∞ for each l-mer s from AAA…A to TTT…T if TotalDistance(s,DNA) < bestDistance bestDistanceTotalDistance(s,DNA) bestWord  s return bestWord 4/6/2019 CSE 5290, Fall 2009

Structuring the Search For the Median String Problem we need to consider all 4l possible l-mers: aa… aa aa… ac aa… ag aa… at . tt… tt How to organize this search? l 4/6/2019 CSE 5290, Fall 2009

Alternative Representation of the Search Space Let A = 1, C = 2, G = 3, T = 4 Then the sequences from AA…A to TT…T become: 11…11 11…12 11…13 11…14 . 44…44 Notice that the sequences above simply list all numbers as if we were counting on base 4 without using 0 as a digit l 4/6/2019 CSE 5290, Fall 2009

aa ac ag at ca cc cg ct ga gc gg gt ta tc tg tt Linked List Suppose l = 2 aa ac ag at ca cc cg ct ga gc gg gt ta tc tg tt Need to visit all the predecessors of a sequence before visiting the sequence itself Start 4/6/2019 CSE 5290, Fall 2009

aa ac ag at ca cc cg ct ga gc gg gt ta tc tg tt Linked List (cont’d) Linked list is not the most efficient data structure for motif finding Let’s try grouping the sequences by their prefixes aa ac ag at ca cc cg ct ga gc gg gt ta tc tg tt 4/6/2019 CSE 5290, Fall 2009

aa ac ag at ca cc cg ct ga gc gg gt ta tc tg tt Search Tree a- c- g- t- aa ac ag at ca cc cg ct ga gc gg gt ta tc tg tt root -- 4/6/2019 CSE 5290, Fall 2009

Analyzing Search Trees Characteristics of the search trees: The sequences are contained in its leaves The parent of a node is the prefix of its children How can we move through the tree? 4/6/2019 CSE 5290, Fall 2009

Visit the Next Leaf NextLeaf( a,L, k ) // a : the array of digits Given a current leaf a , we need to compute the “next” leaf: NextLeaf( a,L, k ) // a : the array of digits for i  L to 1 // L: length of the array if ai < k // k : max digit value ai  ai + 1 return a ai  1 4/6/2019 CSE 5290, Fall 2009

NextLeaf (cont’d) The algorithm is common addition in radix k: Increment the least significant digit “Carry the one” to the next digit position when the digit is at maximal value 4/6/2019 CSE 5290, Fall 2009

NextLeaf: Example Moving to the next leaf: Current Location 1- 2- 3- 4- 11 12 13 14 21 22 23 24 31 32 33 34 41 42 43 44 -- Current Location 4/6/2019 CSE 5290, Fall 2009

NextLeaf: Example (cont’d) Moving to the next leaf: 1- 2- 3- 4- 11 12 13 14 21 22 23 24 31 32 33 34 41 42 43 44 -- Next Location 4/6/2019 CSE 5290, Fall 2009

Visit All Leaves Printing all permutations in ascending order: AllLeaves(L,k) // L: length of the sequence a  (1,...,1) // k : max digit value while forever // a : array of digits output a a  NextLeaf(a,L,k) if a = (1,...,1) return 4/6/2019 CSE 5290, Fall 2009

Tree Search So we can search leaves How about searching all vertices of the tree? We can do this with a depth first search 4/6/2019 CSE 5290, Fall 2009

Visit the Next Vertex NextVertex(a,i,L,k) // a : the array of digits if i < L // i : prefix length a i+1  1 // L: max length return ( a,i+1) // k : max digit value else for j  l to 1 if aj < k aj  aj +1 return( a,j ) return(a,0) 4/6/2019 CSE 5290, Fall 2009

Example Moving to the next vertex: Current Location 1- 2- 3- 4- 1- 2- 3- 4- 11 12 13 14 21 22 23 24 31 32 33 34 41 42 43 44 Current Location -- 4/6/2019 CSE 5290, Fall 2009

Example Moving to the next vertices: 1- 2- 3- 4- 11 12 13 14 21 22 23 24 31 32 33 34 41 42 43 44 Location after 5 next vertex moves -- 4/6/2019 CSE 5290, Fall 2009

Bypass Move Given a prefix (internal vertex), find next vertex after skipping all its children Bypass(a,i,L,k) // a: array of digits for j  i to 1 // i : prefix length if aj < k // L: maximum length aj  aj +1 // k : max digit value return(a,j) return(a,0) 4/6/2019 CSE 5290, Fall 2009

Bypass Move: Example Bypassing the descendants of “2-”: 1- 2- 3- 4- 11 12 13 14 21 22 23 24 31 32 33 34 41 42 43 44 Current Location -- 4/6/2019 CSE 5290, Fall 2009

Example Bypassing the descendants of “2-”: Next Location 1- 2- 3- 4- 1- 2- 3- 4- 11 12 13 14 21 22 23 24 31 32 33 34 41 42 43 44 Next Location -- 4/6/2019 CSE 5290, Fall 2009

Revisiting Brute Force Search Now that we have method for navigating the tree, lets look again at BruteForceMotifSearch 4/6/2019 CSE 5290, Fall 2009

Brute Force Search Again BruteForceMotifSearchAgain(DNA, t, n, l) s  (1,1,…, 1) bestScore  Score(s,DNA) while forever s  NextLeaf (s, t, n- l +1) if (Score(s,DNA) > bestScore) bestScore  Score(s, DNA) bestMotif  (s1,s2 , . . . , st) return bestMotif 4/6/2019 CSE 5290, Fall 2009

Can We Do Better? Sets of s=(s1, s2, …,st) may have a weak profile for the first i positions (s1, s2, …,si) Every row of alignment may add at most l to Score Optimism: if all subsequent (t-i) positions (si+1, …st) add (t – i ) * l to Score(s,i,DNA) If Score(s,i,DNA) + (t – i ) * l < BestScore, it makes no sense to search in vertices of the current subtree Use ByPass() 4/6/2019 CSE 5290, Fall 2009

Branch and Bound Algorithm for Motif Search Since each level of the tree goes deeper into search, discarding a prefix discards all following branches This saves us from looking at (n – l + 1)t-i leaves Use NextVertex() and ByPass() to navigate the tree 4/6/2019 CSE 5290, Fall 2009

Pseudocode for Branch and Bound Motif Search BranchAndBoundMotifSearch(DNA,t,n,l) s  (1,…,1) bestScore  0 i  1 while i > 0 if i < t optimisticScore  Score(s, i, DNA) +(t – i ) * l if optimisticScore < bestScore (s, i)  Bypass(s,i, n-l +1) else (s, i)  NextVertex(s, i, n-l +1) if Score(s,DNA) > bestScore bestScore  Score(s) bestMotif  (s1, s2, s3, …, st) (s,i)  NextVertex(s,i,t,n-l + 1) return bestMotif 4/6/2019 CSE 5290, Fall 2009

Median String Search Improvements Recall the computational differences between motif search and median string search The Motif Finding Problem needs to examine all (n-l +1)t combinations for s. The Median String Problem needs to examine 4l combinations of v. This number is relatively small We want to use median string algorithm with the Branch and Bound trick! 4/6/2019 CSE 5290, Fall 2009

Branch and Bound Applied to Median String Search Note that if the total distance for a prefix is greater than that for the best word so far: TotalDistance (prefix, DNA) > BestDistance there is no use exploring the remaining part of the word We can eliminate that branch and BYPASS exploring that branch further 4/6/2019 CSE 5290, Fall 2009

Bounded Median String Search BranchAndBoundMedianStringSearch(DNA,t,n,l ) s  (1,…,1) bestDistance  ∞ i  1 while i > 0 if i < l prefix  string corresponding to the first i nucleotides of s optimisticDistance  TotalDistance(prefix,DNA) if optimisticDistance > bestDistance (s, i )  Bypass(s,i, l, 4) else (s, i )  NextVertex(s, i, l, 4) word  nucleotide string corresponding to s if TotalDistance(s,DNA) < bestDistance bestDistance  TotalDistance(word, DNA) bestWord  word (s,i )  NextVertex(s,i,l, 4) return bestWord 4/6/2019 CSE 5290, Fall 2009

Improving the Bounds Given an l-mer w, divided into two parts at point i u : prefix w1, …, wi, v : suffix wi+1, ..., wl Find minimum distance for u in a sequence No instances of u in the sequence have distance less than the minimum distance Note this doesn’t tell us anything about whether u is part of any motif. We only get a minimum distance for prefix u 4/6/2019 CSE 5290, Fall 2009

Improving the Bounds (cont’d) Repeating the process for the suffix v gives us a minimum distance for v Since u and v are two substrings of w, and included in motif w, we can assume that the minimum distance of u plus minimum distance of v can only be less than the minimum distance for w 4/6/2019 CSE 5290, Fall 2009

Better Bounds 4/6/2019 CSE 5290, Fall 2009

Better Bounds (cont’d) If d(prefix) + d(suffix) > bestDistance: Motif w (prefix.suffix) cannot give a better (lower) score than d(prefix) + d(suffix) In this case, we can ByPass() 4/6/2019 CSE 5290, Fall 2009

More on the Motif Problem Exhaustive Search and Median String are both exact algorithms They always find the optimal solution, though they may be too slow to perform practical tasks Many algorithms sacrifice optimal solution for speed Examples: Local search, Stochastic sampling… 4/6/2019 CSE 5290, Fall 2009