markov chain models bmi/cs 576 [email protected] fall 2010

36
Markov Chain Models BMI/CS 576 www.biostat.wisc.edu/bmi576/ [email protected] Fall 2010

Upload: franklin-bailey

Post on 28-Dec-2015

221 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Markov Chain Models BMI/CS 576  cdewey@biostat.wisc.edu Fall 2010

Markov Chain Models

BMI/CS 576

www.biostat.wisc.edu/bmi576/

[email protected]

Fall 2010

Page 2: Markov Chain Models BMI/CS 576  cdewey@biostat.wisc.edu Fall 2010

Motivation for Markov Models in Computational Biology

• there are many cases in which we would like to represent the statistical regularities of some class of sequences

– genes

– various regulatory sites in DNA (e.g., where RNA polymerase and transcription factors bind)

– proteins in a given family

• Markov models are well suited to this type of task

Page 3: Markov Chain Models BMI/CS 576  cdewey@biostat.wisc.edu Fall 2010

Markov Chain Models

• a Markov chain model is defined by

– a set of states• we’ll think of a traversal through the states as

generating a sequence

• each state adds to the sequence (except for begin and end)

– a set of transitions with associated probabilities

• the transitions emanating from a given state define a distribution over the possible next states

Page 4: Markov Chain Models BMI/CS 576  cdewey@biostat.wisc.edu Fall 2010

.34.16

.38

.12

transition probabilities

Pr(X i = a | X i−1 = g) = 0.16

Pr(X i = c | X i−1 = g) = 0.34

Pr(X i = g | X i−1 = g) = 0.38

Pr(X i = t | X i−1 = g) = 0.12

A Markov Chain Model for DNA

A

TC

G

begin

state

transition

Page 5: Markov Chain Models BMI/CS 576  cdewey@biostat.wisc.edu Fall 2010

Markov Chain Models

begin end

A

TC

G

• can also have an end state; allows the model to represent

– a distribution over sequences of different lengths

– preferences for ending sequences with certain symbols

Page 6: Markov Chain Models BMI/CS 576  cdewey@biostat.wisc.edu Fall 2010

Markov Chain Models• Let X be a sequence of L random variables X1… XL representing a

biological sequence generated through some process• We can ask how probable the sequence is given our model• for any probabilistic model of sequences, we can write this probability as

(recall the “Chain Rule of Probability”)

Pr(X) = Pr(XL ,XL−1,...,X1)

= Pr (XL|XL−1,...,X1)Pr(XL−1 | XL−2,...,X1)...Pr(X1)• key property of a (1st order) Markov chain: the probability

of each depends only on the value of

Pr(X) = Pr (XL|XL−1)Pr(XL−1 | XL−2)...Pr(X2 | X1)Pr(X1)

= Pr(X1) Pr(X i

i= 2

L

∏ | X i−1)€

X i

X i−1

Page 7: Markov Chain Models BMI/CS 576  cdewey@biostat.wisc.edu Fall 2010

The Probability of a Sequence for a Given Markov Chain Model

end

A

TC

G

begin

Pr(cggt) = Pr(c | begin)Pr(g | c)Pr(g | g)Pr (t | g)Pr(end | t)

Page 8: Markov Chain Models BMI/CS 576  cdewey@biostat.wisc.edu Fall 2010

Markov Chain Notation• the transition parameters can be denoted by where

• similarly we can denote the probability of a sequence x as

where represents the transition from the begin state

• This gives a probability distribution over sequences of length L

aBx1axi−1xi

i=2

L

∏ = Pr(x1) Pr(x ii=2

L

∏ | x i−1)€

axi−1xi= Pr(X i = x i | X i−1 = x i−1)

ii xxa1−

1xaB

Page 9: Markov Chain Models BMI/CS 576  cdewey@biostat.wisc.edu Fall 2010

Estimating the Model Parameters

• given some data (e.g. a set of sequences from CpG islands), how can we determine the probability parameters of our model?

• one approach: maximum likelihood estimation– given a set of data D– set the parameters to maximize

– i.e. make the data D look as likely as possible under the model

)|Pr( θDθ

Page 10: Markov Chain Models BMI/CS 576  cdewey@biostat.wisc.edu Fall 2010

Maximum Likelihood Estimation• Let’s use a very simple sequence model

– every position is independent of the others

– every position generated from the same multinomial distribution

• we want to estimate the parameters Pr(a), Pr(c), Pr(g), Pr(t)

• and we’re given the sequences

accgcgctta

gcttagtgac

tagccgttac

• then the maximum likelihood estimates are the observed frequencies of the bases

267.030

8)Pr(

233.030

7)Pr(

==

==

t

g

3.030

9)Pr(

2.030

6)Pr(

==

==

c

a€

Pr(a) =na

nii

Page 11: Markov Chain Models BMI/CS 576  cdewey@biostat.wisc.edu Fall 2010

Maximum Likelihood Estimation• suppose instead we saw the following sequences

gccgcgcttg

gcttggtggc

tggccgttgc

• then the maximum likelihood estimates are

267.030

8)Pr(

433.030

13)Pr(

==

==

t

g

3.030

9)Pr(

030

0)Pr(

==

==

c

a

do we really want to set this to 0?

Page 12: Markov Chain Models BMI/CS 576  cdewey@biostat.wisc.edu Fall 2010

A Bayesian Approach• instead of estimating parameters strictly from the data, we could start with some prior

belief for each• for example, we could use Laplace estimates

• where represents the number of occurrences of character i

∑ ++

=

ii

a

n

na

)1(

1)Pr(

• using Laplace estimates with the sequences

gccgcgcttg

gcttggtggc

tggccgttgc34

19)Pr(

34

10)Pr(

+=

+=

c

a

pseudocount

in

Page 13: Markov Chain Models BMI/CS 576  cdewey@biostat.wisc.edu Fall 2010

A Bayesian Approach

• a more general form: m-estimates

mn

mpna

ii

aa

+⎟⎠

⎞⎜⎝

⎛+

=

∑)(Pr

• with m=8 and uniform priors

gccgcgcttg

gcttggtggc

tggccgttgc

number of “virtual” instances

prior probability of a

38

11

830

825.09)Pr( =

+×+

=c

Page 14: Markov Chain Models BMI/CS 576  cdewey@biostat.wisc.edu Fall 2010

Estimation for 1st Order Probabilities• to estimate a 1st order parameter, such as Pr(c|g), we count

the number of times that c follows the history g in our given sequences

• using Laplace estimates with the sequences

gccgcgcttg

gcttggtggc

tggccgttgc

412

12)|Pr(

412

13)|Pr(

412

17)|Pr(

412

10)|Pr(

++

=

++

=

++

=

++

=

gt

gg

gc

ga

M47

10)|Pr(

++

=ca

Page 15: Markov Chain Models BMI/CS 576  cdewey@biostat.wisc.edu Fall 2010

Example Application

• CpG islands– CG dinucleotides are rarer in eukaryotic genomes than

expected given the marginal probabilities of C and G– but the regions upstream of genes are richer in CG

dinucleotides than elsewhere – CpG islands– useful evidence for finding genes

• could predict CpG islands with Markov chains– one to represent CpG islands– one to represent the rest of the genome

Page 16: Markov Chain Models BMI/CS 576  cdewey@biostat.wisc.edu Fall 2010

Markov Chains for Discrimination• suppose we want to distinguish CpG islands from other

sequence regions

• given sequences from CpG islands, and sequences from other regions, we can construct

– a model to represent CpG islands

– a null model to represent the other regions

• can then score a test sequence by:

)model null|Pr(

)modelCpG |Pr(log)(

x

xxscore =

Page 17: Markov Chain Models BMI/CS 576  cdewey@biostat.wisc.edu Fall 2010

Markov Chains for Discrimination

+ a c g t

a .18 .27 .43 .12

c .17 .37 .27 .19

g .16 .34 .38 .12

t .08 .36 .38 .18

- a c g t

a .30 .21 .28 .21

c .32 .30 .08 .30

g .25 .24 .30 .21

t .18 .24 .29 .29

• parameters estimated for CpG and null models

– human sequences containing 48 CpG islands

– 60,000 nucleotides

Pr( | )c a

CpG null

Page 18: Markov Chain Models BMI/CS 576  cdewey@biostat.wisc.edu Fall 2010

Markov Chains for Discrimination• light bars represent

negative sequences

• dark bars represent positive sequences

• the actual figure here is not from a CpG island discrimination task, however

Figure from A. Krogh, “An Introduction to Hidden Markov Models for Biological Sequences” in Computational Methods in Molecular Biology, Salzberg et al. editors, 1998.

Page 19: Markov Chain Models BMI/CS 576  cdewey@biostat.wisc.edu Fall 2010

Markov Chains for Discrimination

)|Pr(

)|Pr(log)(

nullx

CpGxxscore =

)Pr(

)Pr()|Pr()|Pr(

x

CpGCpGxxCpG =

)Pr(

)Pr()|Pr()|Pr(

x

nullnullxxnull =

• why use

• Bayes’ rule tells us

• if we’re not taking into account prior probabilities of two classes ( and ) then we just need to compare and

)Pr(CpG)|Pr( nullx)|Pr( CpGx

)Pr(null

Page 20: Markov Chain Models BMI/CS 576  cdewey@biostat.wisc.edu Fall 2010

Pr(X i | X i−1, X i−2,...,X1) = Pr(X i | X i−1,...,X i−n )

Higher Order Markov Chains

• the Markov property specifies that the probability of a state depends only on the probability of the previous state

• but we can build more “memory” into our states by using a higher order Markov model

• in an nth order Markov model

Page 21: Markov Chain Models BMI/CS 576  cdewey@biostat.wisc.edu Fall 2010

Selecting the Order of a Markov Chain Model

• higher order models remember more “history”

• additional history can have predictive value

• example:

– predict the next word in this sentence fragment “…finish __” (up, it, first, last, …?)

– now predict it given more history “Nice guys finish __”

Page 22: Markov Chain Models BMI/CS 576  cdewey@biostat.wisc.edu Fall 2010

Selecting the Order of a Markov Chain Model

• but the number of parameters we need to estimate grows exponentially with the order– for modeling DNA we need parameters for an nth

order model

• the higher the order, the less reliable we can expect our parameter estimates to be– estimating the parameters of a 2nd order Markov chain from the

complete genome of E. Coli, we’d see each (n+1)-mer > 72,000 times on average

– estimating the parameters of an 9th order chain, we’d see each (n+1)-mer ~ 4 times on average

)4( 1+nO

Page 23: Markov Chain Models BMI/CS 576  cdewey@biostat.wisc.edu Fall 2010

Higher Order Markov Chains

• an nth order Markov chain over some alphabet is equivalent to a first order Markov chain over the alphabet of n-tuples

• example: a 2nd order Markov model for DNA can be treated as a 1st order Markov model over alphabet

AA, AC, AG, AT, CA, CC, CG, CT, GA, GC, GG, GT, TA, TC, TG, TT

• caveat: we process a sequence one character at a time

A C G G T

A

nA

AC GGCG GT

Page 24: Markov Chain Models BMI/CS 576  cdewey@biostat.wisc.edu Fall 2010

A Fifth Order Markov Chain

GCTAC

AAAAA

TTTTT

CTACG

CTACA

CTACC

CTACT

Pr(A | GCTAC)begin

Pr(GCTAC)

Pr(C | GCTAC)

Page 25: Markov Chain Models BMI/CS 576  cdewey@biostat.wisc.edu Fall 2010

A Fifth Order Markov Chain

GCTAC

AAAAA

CTACG

CTACA

CTACC

CTACT

Pr(A | GCTAC)begin

Pr(GCTAC)

)|Pr()Pr )Pr( gctaca(gctacgctaca =

Page 26: Markov Chain Models BMI/CS 576  cdewey@biostat.wisc.edu Fall 2010

Inhomogenous Markov Chains

• in the Markov chain models we have considered so far, the probabilities do not depend on where we are in a given sequence

• in an inhomogeneous Markov model, we can have different distributions at different positions in the sequence

• Equivalent to expanding the state space so that states keep track of which position they correspond to

• consider modeling codons in protein coding regions

Page 27: Markov Chain Models BMI/CS 576  cdewey@biostat.wisc.edu Fall 2010

An Inhomogeneous Markov Chain

A

T

C

G

A

T

C

G

A

T

C

G

begin

pos 1 pos 2 pos 3

Page 28: Markov Chain Models BMI/CS 576  cdewey@biostat.wisc.edu Fall 2010

An Application of Markov Chain Models: Finding Genes

• build Markov models of coding & noncoding regions

• apply models to ORFs or fixed-sized windows of sequence

• e.g. GeneMark [Borodovsky et al.]

– popular system for identifying genes in bacterial genomes

– uses 5th order inhomogeneous Markov chain models

Page 29: Markov Chain Models BMI/CS 576  cdewey@biostat.wisc.edu Fall 2010

Open Reading Frames (ORFs)• an open reading frame is a sequence that could potentially

encode a protein

– it begins with a potential start codon

– it ends with a potential stop codon

– It has no internal in frame stop codons

– it satisfies some minimum length requirement

ATG CCG AAA TCG CAT GCA TTT GTG … TAGstart stop

start

Page 30: Markov Chain Models BMI/CS 576  cdewey@biostat.wisc.edu Fall 2010

Approaches to Finding Genes

• search by sequence similarity: find genes by looking for matches to sequences that are known to be related to genes

• search by signal: find genes by identifying the sequence signals involved in gene expression

• search by content: find genes by statistical properties that distinguish protein-coding DNA from non-coding DNA

• combined: state-of-the-art systems for gene finding combine these strategies

Page 31: Markov Chain Models BMI/CS 576  cdewey@biostat.wisc.edu Fall 2010

Gene Finding: Search by Content

• encoding a protein affects the statistical properties of a DNA sequence

– some amino acids are used more frequently than others (Leu more popular than Trp)

– different numbers of codons for different amino acids (Leu has 6, Trp has 1)

– for a given amino acid, usually one codon is used more frequently than others

• this is termed codon preference

• these preferences vary by species

Page 32: Markov Chain Models BMI/CS 576  cdewey@biostat.wisc.edu Fall 2010

Codon Preference in E. ColiAA codon freq per 1000-------------------------Gly GGG 1.89Gly GGA 0.44Gly GGU 52.99Gly GGC 34.55

Glu GAG 15.68Glu GAA 57.20

Asp GAU 21.63Asp GAC 43.26

Page 33: Markov Chain Models BMI/CS 576  cdewey@biostat.wisc.edu Fall 2010

Base Composition for Various Organisms

Page 34: Markov Chain Models BMI/CS 576  cdewey@biostat.wisc.edu Fall 2010

Reading Frames

• a given sequence may encode a protein in any of the six reading frames

G C T A C G G A G C T T C G G A G CC G A T G C C T C G A A G C C T C G

Page 35: Markov Chain Models BMI/CS 576  cdewey@biostat.wisc.edu Fall 2010

Markov Models & Reading Frames• consider modeling a given coding sequence

• for each “word” we evaluate, we’ll want to consider its position with respect to the reading frame we’re assuming

G C T A C G G A G C T T C G G A G C

G C T A C G

reading frame

G is in 3rd codon position

C T A C G G G is in 1st position

T A C G G A A is in 2nd position

Page 36: Markov Chain Models BMI/CS 576  cdewey@biostat.wisc.edu Fall 2010

A Fifth Order Inhomogenous Markov Chain

GCTAC

AAAAA

TTTTT

CTACG

CTACA

CTACC

CTACT

start

AAAAA

TTTTT

TACAG

TACAA

TACAC

TACATGCTAC

AAAAA

TTTTT

CTACG

CTACA

CTACC

CTACT

position 1 position 2 position 3