Docsity

Viterbi algorithm algoritmo di viterbi, Appunti di Elementi di Informatica

Toggle sidebar
bg1
HMM : Viterbi algorithm - a toy example
Sources: For the theory, see Durbin et al (1998);
For the example, see Borodovsky & Ekisheva (2006), pp 80-81
H
Start
A 0.2
C 0.3
G 0.3
T 0.2
L
A 0.3
C 0.2
G 0.2
T 0.3
0.5 0.5
0.5
0.4
0.5 0.6
Let's consider the following simple HMM. This model is composed
of 2 states, H (high GC content) and L (low GC content). We can
for example consider that state H characterizes coding DNA while
L characterizes a non-coding DNA.
The model can then be used to predict the region of coding DNA
from a given sequence.
pf3
pf4
pf5
pf8
pf9
pfa

Anteprima parziale del testo

Scarica Viterbi algorithm algoritmo di viterbi e più Appunti in PDF di Elementi di Informatica solo su Docsity!

Sources : For the theory, see Durbin et al (1998); For the example, see Borodovsky & Ekisheva (2006), pp 80-

H

Start

A 0.

C 0.

G 0.

T 0.

L

A 0.

C 0.

G 0.

T 0.

Let's consider the following simple HMM. This model is composed of 2 states, H (high GC content) and L (low GC content). We can for example consider that state H characterizes coding DNA while L characterizes a non-coding DNA.

The model can then be used to predict the region of coding DNA from a given sequence.

H

Start

A 0.

C 0.

G 0.

T 0.

L

A 0.

C 0.

G 0.

T 0.

GGCACTGAA

There are several paths through the hidden states (H and L) that lead to

the given sequence.

Example: P = LLHHHHLLL

The probability of the HMM to produce sequence S through the path P is:

p = pL(0) * pL(G) * pLL * pL(G) * pLH * pH(C) * ... = 0.5 * 0.2 * 0.6 * 0.2 * 0.4 * 0.3 * ... = ...

Consider the sequence S=

H

Start

A 0.

C 0.

G 0.

T 0.

L

A 0.

C 0.

G 0.

T 0.

G G C A C T G A A

Viterbi algorithm: principle

!

pl ( i , x ) = el ( i )max k

(^ pk (^ j ,^ x^ "^1 ). pkl )

The probability of the most probable path ending in state k with observation "i" is

probability to observe element i in state l

probability of the most probable path ending at position x-1 in state k with element j

probability of the transition from state l to state k

H

Start

A 0.

C 0.

G 0.

T 0.

L

A 0.

C 0.

G 0.

T 0.

G G C A C T G A A

Viterbi algorithm: principle

pH ( A , 4 ) = eH ( A )max (^) ( pL ( C , 3 ) pLH , pH ( C , 3 ) pHH )

The probability of the most probable path ending in state k with observation "i" is

In our example, the probability of the most probable path ending in state H with observation "A" at the 4th position is:

We can thus compute recursively (from the first to the last element of our sequence) the probability of the most probable path.

!

pl ( i , x ) = el ( i )max k

(^ pk (^ j ,^ x^ "^1 ). pkl )

H

Start

A -2.

C -1.

G - 1.

T -2.

L

A -1.

C -2.

G -2.

T -1.

GGCACTGAA

pH(G,1) = -1 -1.737 = -2.

pL(G,1) = -1 -2.322 = -3.

Probability (in log 2 ) that G at the first position was emitted by state H

Probability (in log 2 ) that G at the first position was emitted by state L

H

Start

A -2.

C -1.

G - 1.

T -2.

L

A -1.

C -2.

G -2.

T -1.

GGCACTGAA

pH(G,2) = -1.737 + max (pH(G,1)+pHH, pL(G,1)+pLH) = -1.737 + max (-2.737 -1 , -3.322 -1.322) = -5.474 (obtained from pH(G,1))

pL(G,2) = -2.322 + max (pH(G,1)+pHL, pL(G,1)+pLL) = -2.322 + max (-2.737 -1 , -3.322 -0.737) = -6.059 (obtained from pH(G,1))

Probability (in log 2 ) that G at the 2nd position was emitted by state H

Probability (in log 2 ) that G at the 2nd position was emitted by state L

H

Start

A -2.

C -1.

G - 1.

T -2.

L

A -1.

C -2.

G -2.

T -1.

GGCACTGAA

L -3.32 -6.06 -8.79 -10.94 -14.01 ... -24.

H -2.73 -5.47 -8.21 -11.53 -14.01 ... -25.

G G C A C T G A A

back-tracking (= finding the path which corresponds to the highest probability, -24.49)

The most probable path is: (^) HHHLLLLLL Its probability is 2

-24.49 = 4.25E-

(remember that we used log 2 (p))

The Viterbi algorithm is used to compute the most probable path (as well as

its probability). It requires knowledge of the parameters of the HMM model and

a particular output sequence and it finds the state sequence that is most likely

to have generated that output sequence. It works by finding a maximum over

all possible state sequences.

In sequence analysis, this method can be used for example to predict coding

vs non-coding sequences.

In fact there are often many state sequences that can produce the same

particular output sequence, but with different probabilities. It is possible to

calculate the probability for the HMM model to generate that output sequence

by doing the summation over all possible state sequences. This also can be

done efficiently using the Forward algorithm , which is also a dynamical

programming algorithm.

In sequence analysis, this method can be used for example to predict the

probability that a particular DNA region match the HMM motif (i.e. was emitted

by the HMM model).

Remarks