CSE 182 L 5 Scoring matrices Dictionary Matching

  • Slides: 26
Download presentation
CSE 182 -L 5: Scoring matrices Dictionary Matching

CSE 182 -L 5: Scoring matrices Dictionary Matching

Silly Quiz • • Your friend has a hobby of generating random bit strings,

Silly Quiz • • Your friend has a hobby of generating random bit strings, and finding patterns in them. One day she come to you, excited and says: I found the strangest thing in my randomly generated string; a row of of length 30 which was as follows – • 0101010101010101 If her original string was of length 2 B, should she be surprised?

Summary • We considered the basics of sequence alignment – – – • •

Summary • We considered the basics of sequence alignment – – – • • Opt score computation Reconstructing alignments Local alignments Affine gap costs Space saving measures Scoring matrices for DNA and protein sequences The local alignment algorithm (for biological strings) was given by Temple Smith, and Mike Waterman, and is called the Smith-Waterman algorithm (SW) Can we recreate Blast?

What’s next? • The output of BLAST is a collection of alignments sorted in

What’s next? • The output of BLAST is a collection of alignments sorted in decreasing order of scores. • Where do we stop?

A thought experiment • Consider – – – • Use SW/BLAST to search the

A thought experiment • Consider – – – • Use SW/BLAST to search the database against the query, and choose all alignments that score above a threshold ‘s’ – • • a large random DNA database (size n) a random query DNA string (size m) A score function: match/mismatch, etc. All hits are bogus. Q: how many hits do we get above score s? Q: what is the probability that we even get one hit above s?

P-value computation • • BLAST: The matching regions are expanded into alignments, which are

P-value computation • • BLAST: The matching regions are expanded into alignments, which are scored using SW, and an appropriate scoring matrix. The results are presented in order of decreasing scores The score is just a number. 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 match generate a score S, or better P-value= Probability if seeing a random hit score S, or better. How can we compute E-value, P-value?

Blast Output 1 S Id Schematic Q beg 26 422 query db S beg

Blast Output 1 S Id Schematic Q beg 26 422 query db S beg 19 Q end S end 405

Blast Output 2 (drosophila) S Id Q beg S beg Q end S end

Blast Output 2 (drosophila) S Id Q beg S beg Q end S end

Expectation? • Some quantities can be reasonably guessed by taking a statistical sample, others

Expectation? • Some quantities can be reasonably guessed by taking a statistical sample, others not – – – • • • Average weight of a group of 100 people Average height of a group of 100 people Average grade on a test Give an example of a quantity that cannot. When the distribution, and the expectation is known, it is easy to see when you see something significant. If the distribution is not well understood, or the wrong distribution is chosen, a wrong conclusion can be drawn

P-value and E-value • • P-value(11): probability that a specific value (11) or something

P-value and E-value • • P-value(11): probability that a specific value (11) or something more extreme is achieved by chance. E-value(11): The number of times we expect to see a specific value or something more extreme just by chance.

P-value • • • P-value(11): probability that a specific value (11) or something more

P-value • • • P-value(11): probability that a specific value (11) or something more extreme is achieved by chance. E-value(11): The number of times we expect to see a specific value or something more extreme just by chance. E. g. , look at alignment scores obtained by chance – 1, 2, 8, 3, 5, 3, 6, 12, 4, 4, 1, 5, 3, 6, 7, 15 • Compute a Distribution • 1 -2 XXX – 3 -4 XXXX – 5 -6 XXXX – 7 -8 XX – 9 -10 – 11 -12 X – 12 -13 – 14 -15 X P-value (11) = 2/15 –

Distribution • • Given a collection of numbers (scores) – 1, 2, 8, 3,

Distribution • • 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

P-value computation • • Goal: Compute P-value(x) A simple empirical method: • • •

P-value computation • • Goal: Compute P-value(x) 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. x P-val(x)

Z-scores for alignment • • Initial assumption was that the scores followed a normal

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

Blast E-value • • • Initial (and natural) assumption was that scores followed a

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

Altschul Karlin statistics • For simplicity, assume that the database is a binary string,

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?

Exact matches Database (n) Query (m) Database size n=100 M, Querysize m=1000.

Exact matches Database (n) Query (m) Database size n=100 M, Querysize m=1000.

Observations • • • For a typical query, there are only a few ‘real

Observations • • • For a typical query, there are only a few ‘real hits’ in the database. Much of the database is random from the query’s perspective Consider a random DNA string of length n. – • • Pr[A]=Pr[C] = Pr[G]=Pr[T]=0. 25 Assume for the moment that the query is all A’s (length m). What is the probability that an exact match to the query can be found?

Basic probability • • • Probability that there is a match starting at a

Basic probability • • • Probability that there is a match starting at a fixed position i = 0. 25 m What is the probability that some position i has a match. Dependencies confound probability estimates.

Basic Probability: Expectation • • Q: Toss a coin many times: If it is

Basic Probability: Expectation • • Q: Toss a coin many times: If it is HEADS, and the previous time was HEADS too, you get a dollar. What is the money you expect to get after n tosses? – Let Xi be the amount earned in the i-th toss

Expected number of matches • Expected number of matches can still be computed. i

Expected number of matches • Expected number of matches can still be computed. i § Let Xi=1 if there is a match starting at position i, § Xi=0 otherwise § Expected number of matches =

Expected number of exact Matches is small! • • Expected number of matches =

Expected number of exact Matches is small! • • Expected number of matches = n*0. 25 m – If n=107, m=10, • Then, expected number of matches = 9. 537 – If n=107, m=11 • expected number of hits = 2. 38 – n=107, m=12, • Expected number of hits = 0. 5 < 1 Bottom Line: An exact match to a substring of the query is unlikely just by chance.

Exponential distribution • • • Random Database, Pr(1) = p What is the expected

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 1 s

 • • As you increase k, the number decreases exponentially. The number of

• • 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 behavior does not change (Karlin & Altschul). As the score increases, the number of alignments that achieve the score decreases exponentially

Blast E-value • • Choose a score such that the expected score between a

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 Bit score • For small values, E-value and P-value are the same

End of Lecture 5

End of Lecture 5