Presentation is loading. Please wait.

Presentation is loading. Please wait.

Fa05CSE 182 CSE182-L5: Scoring matrices Dictionary Matching.

Similar presentations


Presentation on theme: "Fa05CSE 182 CSE182-L5: Scoring matrices Dictionary Matching."— Presentation transcript:

1 Fa05CSE 182 CSE182-L5: Scoring matrices Dictionary Matching

2 Fa05CSE 182 Silly Quiz

3 Fa05CSE 182 PAM 1 distance Two sequences are 1 PAM apart if they differ in 1 % of the residues. PAM 1 (a,b) = Pr[residue a substitutes residue b, when the sequences are 1 PAM apart] 1% mismatch

4 Fa05CSE 182 PAM 1

5 Fa05CSE 182 Generating Higher PAMs PAM 2 (a,b) = ∑ c PAM 1 (a,c). PAM 1 (c,b) PAM 2 = PAM 1 * PAM 1 (Matrix multiplication) PAM 250 –= PAM 1 *PAM 249 –= PAM 1 250 = a a b c b c PAM 2 PAM 1

6 Fa05CSE 182 Scoring residues A reasonable score function C(a,b) is given as follows: –Look at ‘high quality’ alignments –C(a,b) should be high when a,b are seen together more often than is expected by chance –C(a,b) should be low, otherwise. How often would you expect to see a,b together just by chance? –P a P b Let P ab be the probability that a and b are aligned in a high- quality alignment A good scoring function is the log-odds score –C(a,b)= log 10 (P ab /P a P b )

7 Fa05CSE 182 Scoring alignments To compute P ab, we need ‘high-quality’ alignments How can you get quality alignments? –Use SW (But that needs the scoring function) –Build alignments manually –Use Dayhoff’s theory to extrapolate from high identity alignments

8 Fa05CSE 182 Scoring using PAM matrices Suppose we know that two sequences are 250 PAMs apart. S(a,b) = log 10 (P ab /P a P b )= log 10 (P a|b /P a ) = log 10 (PAM 250 (a,b)/P a ) How does it help? –S 250 (A,V) >> S 1 (A,V) –Scoring of hum vs. Dros should be using a higher PAM matrix than scoring hum vs. mus. –An alignment with a smaller % identity could still have a higher score and be more significant hum mus dros

9 Fa05CSE 182 S 250 (a,b) = log 10 (P ab /P a P b ) = log 10 (PAM250(a,b)/P a ) PAM250 based scoring matrix

10 Fa05CSE 182 BLOSUM series of Matrices Henikoff & Henikoff: Sequence substitutions in evolutionarily distant proteins do not seem to follow the PAM distributions A more direct method based on hand-curated multiple alignments of distantly related proteins from the BLOCKS database. BLOSUM60 Merge all proteins that have greater than 60%. Then, compute the substitution probability. –In practice BLOSUM62 seems to work very well.

11 Fa05CSE 182 PAM vs. BLOSUM What is the correspondence? PAM1 Blosum1 PAM2 Blosum2 Blosum62 PAM250 Blosum100

12 Fa05CSE 182 P-value computation We use text filtering to filter the database quickly. The matching regions are expanded into alignments, which are scored using SW, and an appropriate scoring matrix. The results are presented in order. How significant is the top scoring hits if it has a score S? Expect/E-value (score S)= Number of times we would expect to see a random query generate a score S, or better How can we compute E-value?

13 Fa05CSE 182 What is a distribution function Given a collection of numbers (scores) –1, 2, 8, 3, 5, 3,6, 4, 4,1,5,3,6,7,…. Plot its distribution as follows: –X-axis =each number –Y-axis (count/frequency/probability) of seeing that number –More generally, the x-axis can be a range to accommodate real numbers

14 Fa05CSE 182 P-value computation How significant is a score? What happens to significance when you change the score function A simple empirical method: Compute a distribution of scores against a random database. Use an estimate of the area under the curve to get the probability. OR, fit the distribution to one of the standard distributions.

15 Fa05CSE 182 Z-scores for alignment Initial assumption was that the scores followed a normal distribution. Z-score computation: –For any alignment, score S, shuffle one of the sequences many times, and recompute alignment. Get mean and standard deviation –Look up a table to get a P-value

16 Fa05CSE 182 Blast E-value Initial (and natural) assumption was that scores followed a Normal distribution 1990, Karlin and Altschul showed that ungapped local alignment scores follow an exponential distribution Practical consequence: –Longer tail. –Previously significant hits now not so significant

17 Fa05CSE 182 Altschul Karlin statistics For simplicity, assume that the database is a binary string, and so is the query. –Let match-score=1, –mismatch score=- , –indel=-  (No gaps allowed) What does it mean to get a score k?

18 Fa05CSE 182 Exponential distribution Random Database, Pr(1) = p What is the expected number of hits to a sequence of k 1’s Instead, consider a random binary Matrix. Expected # of diagonals of k 1s

19 Fa05CSE 182 As you increase k, the number decreases exponentially. The number of diagonals of k runs can be approximated by a Poisson process In ungapped alignments, we replace the coin tosses by column scores, but the behaviour does not change (Karlin & Altschul). As the score increases, the number of alignments that achieve the score decreases exponentially

20 Fa05CSE 182 Blast E-value Choose a score such that the expected score between a pair of residues < 0 Expected number of alignments with a score S For small values, E-value and P-value are the same

21 Fa05CSE 182 The last step in Blast We have discussed –Alignments –Db filtering using keywords –Scoring matrices –E-values and P-values The last step: Database filtering requires us to scan a large sequence fast for matching keywords

22 Fa05CSE 182 Dictionary Matching, R.E. matching, and position specific scoring

23 Fa05CSE 182 Keyword search Recall: In BLAST, we get a collection of keywords from the query sequence, and identify all db locations with an exact match to the keyword. Question: Given a collection of strings (keywords), find all occurrences in a database string where they keyword might match.

24 Fa05CSE 182 Dictionary Matching Q: Given k words (s i has length l i ), and a database of size n, find all matches to these words in the database string. How fast can this be done? 1:POTATO 2:POTASSIUM 3:TASTE P O T A S T P O T A T O dictionary database

25 Fa05CSE 182 Dict. Matching & string matching How fast can you do it, if you only had one word of length m? –Trivial algorithm O(nm) time –Pre-processing O(m), Search O(n) time. Dictionary matching –Trivial algorithm (l 1 +l 2 +l 3 …)n –Using a keyword tree, l p n (l p is the length of the longest pattern) –Aho-Corasick: O(n) after preprocessing O(l 1 +l 2..) We will consider the most general case

26 Fa05CSE 182 Direct Algorithm P O P O P O T A S T P O T A T O P O T A T O Observations: When we mismatch, we (should) know something about where the next match will be. When there is a mismatch, we (should) know something about other patterns in the dictionary as well.

27 Fa05CSE 182 PO T A TO T UISM SET A The Trie Automaton Construct an automaton A from the dictionary –A[v,x] describes the transition from node v to a node w upon reading x. –A[u,’T’] = v, and A[u,’S’] = w –Special root node r –Some nodes are terminal, and labeled with the index of the dictionary word. 1:POTATO 2:POTASSIUM 3:TASTE 1 2 3 w vu S r

28 Fa05CSE 182 An O(l p n) algorithm for keyword matching Start with the first position in the db, and the root node. If successful transition –Increment current pointer –Move to a new node –If terminal node “success” Else –Retract ‘current’ pointer –Increment ‘start’ pointer –Move to root & repeat

29 Fa05CSE 182 Illustration: PO T A TO T UISM SET A P O T A S T P O T A T O l c v S 1 2 3

30 Fa05CSE 182 Idea for improving the time P O T A S T P O T A T O Suppose we have partially matched pattern i (indicated by l, and c), but fail subsequently. If some other pattern j is to match –Then prefix(pattern j) = suffix [ first c-l characters of pattern(i)) l c 1:POTATO 2:POTASSIUM 3:TASTE P O T A S S I U M T A S T E Pattern i Pattern j

31 Fa05CSE 182 Improving speed of dictionary matching Every node v corresponds to a string s v that is a prefix of some pattern. Define F[v] to be the node u such that s u is the longest suffix of s v If we fail to match at v, we should jump to F[v], and commence matching from there Let lp[v] = |s u | PO T A TO T UISM SET A 1 2345 6 7 8 910 11 S

32 Fa05CSE 182 End of L5


Download ppt "Fa05CSE 182 CSE182-L5: Scoring matrices Dictionary Matching."

Similar presentations


Ads by Google