ΗΜΜ

advertisement
HMM
Περιγραφή ενός HMM
N – πλήθος καταστάσεων
– Q = {q1, q2, …,qT} - set καταστάσεων
M – πλήθος συμβόλων (παρατηρήσεις)
– O = {o1, o2, …,oT} - set συμβόλων
Περιγραφή ενός HMM
A – Πίνακας πιθανοτήτων μετάβασης
– aij = P(qt+1 = j|qt = i)
B- κατανομή πιθανοτήτων παρατήρησης
– bj(k) = P(ot = k|qt = j)
i≤k≤M
π – κατανομή αρχικών καταστάσεων
Περιγραφή ενός HMM
Άρα ένα HMM περιγράφεται πλήρως
από την τριάδα:
– λ = (A,B,π)
Markov Chains
Rain
Sunny
Cloudy
State transition matrix : The probability of
States : Three states - sunny,
cloudy, rainy.
the weather given the previous day's
weather.
Initial Distribution : Defining the probability of the
system being in each of the states at time 0.
5
Hidden Markov Models
Hidden states : the (TRUE) states of a system that
may be described by a Markov process (e.g., the
weather).
Observable states : the states of the process that are
`visible' (e.g., seaweed dampness).
6
Components of HMM
Output matrix : containing the probability of observing a
particular observable state given that the hidden model is in
a particular hidden state.
Initial Distribution : contains the probability of the (hidden)
model being in a particular hidden state at time t = 1.
State transition matrix : holding the probability of a hidden
state given the previous hidden state.
7
Προβλήματα μοντελοποίησης με
HMM
Πρόβλημα 1
Αξιολόγηση:
– Πιθανότητα εμφάνισης της συγκεκριμένης
ακολουθίας παρατήρησης, O = {o1,…,ok},
δεδομένου του μοντέλου
– P(O|λ)
– Πολύπλοκο– κρυφές καταστάσεις
– Χρήσιμο στο classification ακολουθιών
Problems With HMM
Scoring problem:
Given an existing HMM and observed sequence , what is the probability
that the HMM can generate the sequence
9
Προβλήματα μοντελοποίησης με
HMM
Πρόβλημα 2
Αποκωδικοποίηση:
– Βέλτιστη ακολουθία καταστάσεων για την
παραγωγή δεδομένων παρατηρήσεων, O =
{o1,…,ok}, δεδομένου του μοντέλου
– Κριτήριο βελτιστοποίησης
– Χρήσιμο σε προβλήματα αναγνώρισης
Problems With HMM
Alignment Problem
Given a sequence, what is the optimal state sequence that the HMM
would use to generate it
11
Προβλήματα μοντελοποίησης με
HMM
Πρόβλημα 3
Μάθηση:
– Καθορίστε το βέλτιστo μοντέλο,
λαμβάνοντας υπόψη τις παρατηρήσεις του
συνόλου εκπαίδευσης
– Βρες λ, τέτοιο ώστε η P(O|λ) να
μεγιστοποιείται
Πρόβλημα 1: απλοϊκή λύση
 Ακολουθία καταστάσεων Q = (q1,…qT)
 Υποθέτουμε ανεξάρτητες παρατηρήσεις:
T
P(O | q,     P(ot | qt ,  )  bq1 (o1 )bq 2 (o2 )...bqT (oT )
i 1
Οι παρατηρήσεις είναι ανεξάρτητες μεταξύ τους,
δεδομένων των κρυμμένων καταστάσεων. (Η κοινή
κατανομή των ανεξάρτητων μεταβλητών
παραγοντοποιείται στις κατανομές των ανεξάρτητων
μεταβλητών.)
Πρόβλημα 1: απλοϊκή λύση
 Παρατηρήστε ότι:
P(q | )   q1aq1q 2aq 2q3...aqT 1qT
 και:
P(O |  )   P(O | q,  ) P(q |  )
q
Πρόβλημα 1: απλοϊκή λύση
 Τελικά:
P(O |  )   P(O | q,  ) P(q |  )
q
-Το πιο πάνω άθροισμα αφορά όλα τις διαδρομές
καταστάσεων
-Υπάρχουν NT διαδρομές καταστάσεων, όπου η
καθεμία ‘κοστίζει’ O(T) υπολογισμούς, που δίνει
πολυπλοκότητα O(TNT)
Πρόβλημα 1: Αποτελεσματική
λύση
Forward αλγόριθμος:
 Ορίζουμε βοηθητική forward μεταβλητή α:
t (i)  P(o1,...,ot | qt  i,  )
αt(i) είναι η πιθανότητα παρατήρησης της μερικής
ακολουθίας των παρατηρήσεων o1,…ot ώστε τη στιγμή t,
η κατάσταση qt=i
Πρόβλημα 1: Αποτελεσματική
λύση
 Αναδρομικός αλγόριθμος:
– Αρχικοποίηση:
1 (i)   ibi (o1 )
– Υπολογισμός:
N
 t 1 ( j )  [  t (i)aij ]b j (ot 1 )
i 1
N
P(O |  )    T (i)
i 1
Πολυπλοκότητα O(N2T)
Πρόβλημα 1: Εναλλακτική
λύση
Backward αλγόριθμος:
 Ορίζουμε βοηθητική
μεταβλητή β:
t (i)  P(ot 1, ot 2 ,...,oT | qt  i,  )
t(i) είναι η πιθανότητα παρατήρησης της
ακολουθίας των παρατηρήσεων ot+1,…,oT δεδομένου τη
στιγμή t, η κατάσταση qt=i
Πρόβλημα 1: Εναλλακτική
λύση
 Αναδρομικός αλγόριθμος:
– Αρχικοποίηση:
T ( j)  1
– Υπολογισμός:
N
t (i)   t 1 ( j )aij b j (ot 1 )
j 1
N
p(O |  )   1 (i)
i 1
Πολυπλοκότητα O(N2T)
t  T  1,...,1
Πρόβλημα 2:
Αποκωδικοποίηση
 Επιλέγουμε ακολουθία καταστάσεων για τη
μεγιστοποίηση της πιθανότητας της ακολουθίας
παρατήρησης
 Ο Viterbi είναι επαγωγικός αλγόριθμος που κρατά
την καλύτερο ακολουθία καταστάσεων σε κάθε
περίπτωση
Πρόβλημα 2:
Αποκωδικοποίηση
Viterbi αλγόριθμος:
 Ακολουθία καταστάσεων που μεγιστοποιεί το
P(O,Q|):
P(q1 , q2 ,...qT | O,  )
 Ορίζουμε βοηθητική μεταβλητή δ:
 t (i)  max P(q1 , q2 ,...,qt  i, o1 , o2 ,...ot |  )
q
δt(i) το πιο πιθανό μονοπάτι που λήγει στην
κατάσταση qt=i
Πρόβλημα 2:
Αποκωδικοποίηση
Για να πάρουμε την ακολουθία κατάστασεων,
πρέπει να παρακολουθούμε τα ορίσματα που
τη μεγιστοποιούν, για κάθε
t και j. Γίνεται μέσω του πίνακα ψt(j).
 Αναδρομή:
 t 1 ( j )  max ( t (i )aij )b j (ot 1 )
i
 Αλγόριθμος:
– 1. Αρχικοποίηση:
1 (i)   ibi (o1 )
 1 (i)  0
1 i  N
Πρόβλημα 2:
Αποκωδικοποίηση
– 2. Αναδρομή:
 t ( j )  max ( t 1 (i )aij )b j (ot )
1i  N
 t ( j )  arg max ( t 1 (i )aij )
1i  N
– 3. Τερματισμός:
P   max  T (i )
2  t  T ,1  j  N
P*: δίνει τη βέλτιστη πιθανότητα ως
προς την κατάσταση
1i  N
qT  arg max  T (i )
1i  N
Q* βέλτιστη ακολουθία
(Q* = {q1*,q2*,…,qT*})
Πρόβλημα 2:
Αποκωδικοποίηση
– 4. Backtrack ακολουθία:
qt   t 1 (qt1 )
O(N2T) πολυπλοκότητα
t  T  1, T  2,...,1
Πρόβλημα 3: Μάθηση
 Εκπαίδευση του HMM ώστε να κωδικοποιήσει
ακολουθίες παρατηρήσεων ώστε να εντοπίσει
μια παρόμοια ακολουθία στο μέλλον
 Εύρεση λ=(A,B,π), που μεγιστοποιεί το P(O|λ)
 Αλγόριθμος:
– Αρχικοποίηση: λ0
– Υπολογίζουμε νέο μοντέλο λ, χρησιμοποιώντας τα
λ0 και O
– λ0λ
– Επαναλαμβάνουμε τη διαδικασία εώς:
log P(O |  )  log P(O | 0 )  d
Πρόβλημα 3: Μάθηση
Baum-Welch αλγόριθμος Βήμα 1:
 Έστω ξ(i,j) η πιθανότητα να είμαστε στην
κατάσταση i τη στιγμή t και τη j όταν t+1,
δεδομένου των λ και O
 t (i)aijb j (ot 1 ) t 1 ( j )
 (i, j ) 
P(O |  )

 t (i)aijb j (ot 1 )  t 1 ( j )
N
N
 (i)a b (o
i 1 j 1
t
ij
j
t 1
)  t 1 ( j )
Πρόβλημα 3: Μάθηση
Δραστηριότητες που απαιτούνται για τον υπολογισμό
της κοινής περίπτωση που το σύστημα βρίσκεται στην
κατάσταση Si για t και Sj για t+1
Πρόβλημα 3: Μάθηση
 Έστω γt(i) η πιθανότητα να είμαστε στην
κατάσταση i τη στιγμή t, δεδομένου του O
N
 t (i)   t (i, j )
j 1
T 1
  (i)
t 1
t
T 1
 (i)
t 1
t
- αναμενόμενο πλήθος μεταβάσεων από i
- αναμενόμενο πλήθος μεταβάσεων i  j
Πρόβλημα 3: Μάθηση
Baum-Welch αλγόριθμος Βήμα 2:
ˆ   1 (i) αναμενόμενη συχνότητα κατάστασης i για t=1
aˆij
 (i, j )


  (i)
t
t
 Αναλογία αναμενομένων μεταβάσεων από την
κατάσταση i στην j προς αναμενόμενες μεταβάσεις από i
 ( j)

bˆ (k ) 
  ( j)
t ,ot  k
t
j
t
 Αναλογία αναμενόμενο πλήθος φορών που στην
κατάσταση j παρατηρείται το k προς πλήθος φορών στη j
Πρόβλημα 3: Μάθηση
 Baum-Welch αλγόριθμος χρησιμοποιεί τους forward
και backward αλγορίθμους για τον υπολογισμό των
βοηθητικών μεταβλητών α, β
 Ο BW είναι μια ειδική περίπτωση του αλγορίθμου EM:
– E-βήμα: υπολογισμός των ξ και γ
– M-βήμα: επαναληπτικός υπολογισμός των ˆ
 Πρακτικά ζητήματα:
– Μπορεί να κολλήσει σε τοπικά μέγιστα
aˆij bˆ j (k )
HMMs in Biology
Gene finding and prediction
Protein-Profile Analysis
Secondary Structure prediction
Advantages
Limitations
31
Relationship Between DNA,
RNA And Proteins
DNA
CCTGAGCCAACTATTGATGAA
transcription
mRNA
CCUGAGCCAACUAUUGAUGAA
translation
Protein
PEPTIDE
32
Protein Structure
Primary Structure of Proteins
The primary structure of peptides and proteins refers to the linear
number and order of the amino acids present.
33
Protein Structure
Secondary Structure
Protein secondary structure refers to regular, repeated patters of folding of
the protein backbone. How a protein folds is largely dictated by the primary
sequence of amino acids
34
What is a (protein-coding) gene?
DNA
CCTGAGCCAACTATTGATGAA
transcription
mRNA
CCUGAGCCAACUAUUGAUGAA
translation
Protein
PEPTIDE
35
In more detail
(color ~state)
(Left)
(Removed)
36
Gene Finding HMMs
Our Objective:
– To find the coding and non-coding regions of
an unlabeled string of DNA nucleotides
Our Motivation:
– Assist in the annotation of genomic data
produced by genome sequencing methods
– Gain insight into the mechanisms involved in
transcription, splicing and other processes
37
Why HMMs
• Classification: Classifying observations within a sequence
• Order: A DNA sequence is a set of ordered observations
• Grammar : Our grammatical structure (and the beginnings of our
architecture) is right here:
• Success measure: # of complete exons correctly labeled
• Training data: Available from various genome annotation projects
38
HMMs for gene finding
 Training - Expectation Maximization (EM)
 Parsing – Viterbi algorithm
An HMM for unspliced genes.
x : non-coding DNA
c : coding state
Protein Profile HMMs
 Motivation
– Given a single amino acid target sequence of
unknown structure, we want to infer the structure
of the resulting protein. Use Profile Similarity
 What is a Profile?
–
–
–
–
Proteins families of related sequences and structures
Same function
Clear evolutionary relationship
Patterns of conservation, some positions are more conserved
than the others
40
An Overview
Aligned Sequences
Build a Profile HMM (Training)
Database
search
Query against Profile Multiple
HMM database
alignments
(Forward)
(Viterbi)
41
Building – from an existing alignment
ACA - - - ATG
TCA ACT ATC
ACA C - - AGC
AGA - - - ATC
ACC G - - ATC insertion
Transition probabilities
Output Probabilities
A HMM model for a DNA motif alignments, The transitions
are shown with arrows whose thickness indicate their
probability. In each state, the histogram shows the probabilities
of the four bases.
Database Searching
• Given HMM, M, for a sequence family,
find all members of the family in data
base.
• LL – score LL(x) = log P(x|M)
(LL score is length dependent – must
normalize or use Z-score)
43
Query a new sequence
Suppose I have a query protein sequence, and I am interested
in which family it belongs to? There can be many paths
leading to the generation of this sequence. Need to find all
these paths and sum the probabilities.
Consensus sequence: ACAC - - ATC
P (ACACATC) = 0.8x1 x 0.8x1 x 0.8x0.6 x 0.4x0.6 x 1x1 x
0.8x1 x 0.8 = 4.7 x 10 -2
Multiple Alignments
Try every possible path through the
model that would produce the target
sequences
– Keep the best one and its probability.
– Output : Sequence of match, insert and
delete states
Viterbi alg. Dynamic Programming
45
Building – unaligned sequences
 Baum-Welch Expectation-maximization
method
– Start with a model whose length matches the
average length of the sequences and with random
output and transition probabilities.
– Align all the sequences to the model.
– Use the alignment to alter the output and
transition probabilities
– Repeat. Continue until the model stops changing
 By-product: It produced a multiple alignment
46
PHMM Example
An alignment of 30 short amino acid sequences chopped out
of a alignment of the SH3 domain. The shaded area are the
most conserved and were represented by the main states in
the HMM. The unshaded area was represented by an insert
state.
47
Prediction of Protein Secondary
structures
 Prediction of secondary structures is needed
for the prediction of protein function.
 Analyze the amino-acid sequences of
proteins
 Learn secondary structures
– helix, sheet and turn
 Predict the secondary structures of sequences
48
Advantages
 Characterize an entire family of sequences.
 Position-dependent character distributions and
position-dependent insertion and deletion gap
penalties.
 Built on a formal probabilistic basis
 Can make libraries of hundreds of profile HMMs and
apply them on a large scale (whole genome)
49
Demos
 Speech synthesis
http://www.cstr.ed.ac.uk/projects/festival/onlinedemo.html
Download