HMM
description
Transcript of HMM
HMM
Περιγραφή ενός HMMN – πλήθος καταστάσεων
– Q = {q1, q2, …,qT} - set καταστάσεωνM – πλήθος συμβόλων
(παρατηρήσεις)– O = {o1, o2, …,oT} - set συμβόλων
Περιγραφή ενός HMMA – Πίνακας πιθανοτήτων
μετάβασης– aij = P(qt+1 = j|qt = i)
B- κατανομή πιθανοτήτων παρατήρησης – bj(k) = P(ot = k|qt = j) i ≤ k ≤ M
π – κατανομή αρχικών καταστάσεων
Περιγραφή ενός HMMΆρα ένα HMM περιγράφεται πλήρως
από την τριάδα:– λ = (A,B,π)
5
Markov Chains
Sunny
Rain
Cloudy
State transition matrix : The probability of 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.
States : Three states - sunny, cloudy, rainy.
6
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).
7
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.
Προβλήματα μοντελοποίησης με HMM
Πρόβλημα 1 Αξιολόγηση:– Πιθανότητα εμφάνισης της
συγκεκριμένης ακολουθίας παρατήρησης, O = {o1,…,ok}, δεδομένου του μοντέλου
– P(O|λ)– Πολύπλοκο– κρυφές καταστάσεις– Χρήσιμο στο classification ακολουθιών
9
Problems With HMM
Scoring problem:Given an existing HMM and observed sequence , what is the probability that the HMM can generate the sequence
Προβλήματα μοντελοποίησης με HMM
Πρόβλημα 2Αποκωδικοποίηση:– Βέλτιστη ακολουθία καταστάσεων για
την παραγωγή δεδομένων παρατηρήσεων, O = {o1,…,ok}, δεδομένου του μοντέλου
– Κριτήριο βελτιστοποίησης– Χρήσιμο σε προβλήματα αναγνώρισης
11
Problems With HMM
Alignment ProblemGiven a sequence, what is the optimal state sequence that the HMM would use to generate it
Προβλήματα μοντελοποίησης με HMM
Πρόβλημα 3Μάθηση:– Καθορίστε το βέλτιστo μοντέλο,
λαμβάνοντας υπόψη τις παρατηρήσεις του συνόλου εκπαίδευσης
– Βρες λ, τέτοιο ώστε η P(O|λ) να μεγιστοποιείται
Πρόβλημα 1: απλοϊκή λύσηΑκολουθία καταστάσεων Q = (q1,…qT)Υποθέτουμε ανεξάρτητες παρατηρήσεις:
)()...()(),|(,|( 22111
TqTqqt
T
it obobobqoPqOP
Οι παρατηρήσεις είναι ανεξάρτητες μεταξύ τους, δεδομένων των κρυμμένων καταστάσεων. (Η κοινή κατανομή των ανεξάρτητων μεταβλητών παραγοντοποιείται στις κατανομές των ανεξάρτητων μεταβλητών.)
Πρόβλημα 1: απλοϊκή λύσηΠαρατηρήστε ότι:
και:
qTqTqqqqq aaaqP 132211 ...)|(
q
qPqOPOP )|(),|()|(
Πρόβλημα 1: απλοϊκή λύσηΤελικά:
q
qPqOPOP )|(),|()|(
-Το πιο πάνω άθροισμα αφορά όλα τις διαδρομέςκαταστάσεων-Υπάρχουν NT διαδρομές καταστάσεων, όπου ηκαθεμία ‘κοστίζει’ O(T) υπολογισμούς, που δίνει πολυπλοκότητα O(TNT)
Πρόβλημα 1: Αποτελεσματική λύση
Ορίζουμε βοηθητική forward μεταβλητή α:
),|,...,()( 1 iqooPi ttt
αt(i) είναι η πιθανότητα παρατήρησης της μερικής ακολουθίας των παρατηρήσεων o1,…ot ώστε τη στιγμή t, η κατάσταση qt=i
Forward αλγόριθμος:
Πρόβλημα 1: Αποτελεσματική λύση
Αναδρομικός αλγόριθμος:– Αρχικοποίηση:
– Υπολογισμός:
)()( 11 obi ii
)(])([)( 11
1
tj
N
iijtt obaij
N
iT iOP
1
)()|(
Πολυπλοκότητα O(N2T)
Πρόβλημα 1: Εναλλακτική λύση
Ορίζουμε βοηθητική μεταβλητή β:
Backward αλγόριθμος:
),|,...,,()( 21 iqoooPi tTttt
t(i) είναι η πιθανότητα παρατήρησης τηςακολουθίας των παρατηρήσεων ot+1,…,oT δεδομένου τη στιγμή t, η κατάσταση qt=i
Αναδρομικός αλγόριθμος:– Αρχικοποίηση:
– Υπολογισμός:
1)( jT
Πολυπλοκότητα O(N2T)
1 11
( ) ( ) ( )N
t t ij j tj
i j a b o
N
i
iOp1
1 )()|( 1,...,1Tt
Πρόβλημα 1: Εναλλακτική λύση
Πρόβλημα 2: Αποκωδικοποίηση
Επιλέγουμε ακολουθία καταστάσεων για τη μεγιστοποίηση της πιθανότητας της ακολουθίας παρατήρησης
Ο Viterbi είναι επαγωγικός αλγόριθμος που κρατά την καλύτερο ακολουθία καταστάσεων σε κάθε περίπτωση
Πρόβλημα 2: Αποκωδικοποίηση
Ακολουθία καταστάσεων που μεγιστοποιεί το P(O,Q|):
Ορίζουμε βοηθητική μεταβλητή δ:
),|,...,( 21 OqqqP T
Viterbi αλγόριθμος:
)|,...,,,...,,(max)( 2121 ttqt oooiqqqPi
δt(i) το πιο πιθανό μονοπάτι που λήγει στηνκατάσταση qt=i
Πρόβλημα 2: Αποκωδικοποίηση
Αναδρομή:
Αλγόριθμος:– 1. Αρχικοποίηση:
)())((max)( 11 tjijtit obaij
)()( 11 obi ii Ni 1
0)(1 i
Για να πάρουμε την ακολουθία κατάστασεων, πρέπει να παρακολουθούμε τα ορίσματα που τη μεγιστοποιούν, για κάθεt και j. Γίνεται μέσω του πίνακα ψt(j).
Πρόβλημα 2: Αποκωδικοποίηση
– 2. Αναδρομή:
– 3. Τερματισμός:
)())((max)( 11 tjijtNit obaij
))((maxarg)( 11 ijtNit aij NjTt 1,2
)(max1
iP TNi
)(maxarg1
iq TNiT
P*: δίνει τη βέλτιστη πιθανότητα ως προς την κατάσταση
Q* βέλτιστη ακολουθία(Q* = {q1*,q2*,…,qT*})
Πρόβλημα 2: Αποκωδικοποίηση
– 4. Backtrack ακολουθία:
)( 11
ttt qq 1,...,2,1 TTt
O(N2T) πολυπλοκότητα
Πρόβλημα 3: ΜάθησηΕκπαίδευση του HMM ώστε να
κωδικοποιήσει ακολουθίες παρατηρήσεων ώστε να εντοπίσει μια παρόμοια ακολουθία στο μέλλον
Εύρεση λ=(A,B,π), που μεγιστοποιεί το P(O|λ)
Αλγόριθμος:– Αρχικοποίηση: λ0– Υπολογίζουμε νέο μοντέλο λ,
χρησιμοποιώντας τα λ0 και O– λ0λ– Επαναλαμβάνουμε τη διαδικασία εώς:
dOPOP )|(log)|(log 0
Πρόβλημα 3: Μάθηση
Έστω ξ(i,j) η πιθανότητα να είμαστε στην κατάσταση i τη στιγμή t και τη j όταν t+1, δεδομένου των λ και O
)|()()()(
),( 11
OP
jobaiji ttjijt
N
i
N
jttjijt
ttjijt
jobai
jobai
1 111
11
)()()(
)()()(
Baum-Welch αλγόριθμος Βήμα 1:
Πρόβλημα 3: Μάθηση
Δραστηριότητες που απαιτούνται για τον υπολογισμότης κοινής περίπτωση που το σύστημα βρίσκεται στηνκατάσταση Si για t και Sj για t+1
Πρόβλημα 3: Μάθηση
Έστω γt(i) η πιθανότητα να είμαστε στην κατάσταση i τη στιγμή t, δεδομένου του O
- αναμενόμενο πλήθος μεταβάσεων από i
- αναμενόμενο πλήθος μεταβάσεων
N
jtt jii
1
),()(
1
1
( )T
tt
i
1
1
( )T
tt
i
ji
Πρόβλημα 3: Μάθηση
αναμενόμενη συχνότητα κατάστασης i για t=1
Αναλογία αναμενομένων μεταβάσεων από την κατάσταση i στην j προς αναμενόμενες μεταβάσεις από i
Αναλογία αναμενόμενο πλήθος φορών που στην κατάσταση j παρατηρείται το k προς πλήθος φορών στη j
)(),(
ˆiji
at
tij
Baum-Welch αλγόριθμος Βήμα 2:
)(
)()(ˆ ,
j
jkb
t
kot t
jt
)(ˆ 1 i
Πρόβλημα 3: Μάθηση Baum-Welch αλγόριθμος χρησιμοποιεί τους
forward και backward αλγορίθμους για τον υπολογισμό των βοηθητικών μεταβλητών α, β
Ο BW είναι μια ειδική περίπτωση του αλγορίθμου EM:– E-βήμα: υπολογισμός των ξ και γ– M-βήμα: επαναληπτικός υπολογισμός των
Πρακτικά ζητήματα:– Μπορεί να κολλήσει σε τοπικά μέγιστα
ija )(ˆ kb j
31
HMMs in BiologyGene finding and predictionProtein-Profile AnalysisSecondary Structure predictionAdvantagesLimitations
32
Protein
mRNA
DNA
transcription
translation
CCTGAGCCAACTATTGATGAA
PEPTIDE
CCUGAGCCAACUAUUGAUGAA
Relationship Between DNA, RNA And Proteins
33
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.
34
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
35
What is a (protein-coding) gene?
Protein
mRNA
DNA
transcription
translation
CCTGAGCCAACTATTGATGAA
PEPTIDE
CCUGAGCCAACUAUUGAUGAA
36
In more detail(color ~state)
(Removed)
(Left)
37
Gene Finding HMMsOur 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
38
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
HMMs for gene finding
An HMM for unspliced genes.x : non-coding DNAc : coding state
Training - Expectation Maximization (EM) Parsing – Viterbi algorithm
40
Protein Profile HMMsMotivation
– 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
41
Aligned Sequences
Build a Profile HMM (Training)
Database search
Multiple alignments
(Viterbi)
Query against Profile HMM
database(Forward)
An Overview
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.
ACA - - - ATG TCA ACT ATCACA C - - AGCAGA - - - ATCACC G - - ATC
Building – from an existing alignment
Transition probabilitiesOutput Probabilities
insertion
43
• 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)
Database Searching
Consensus sequence: 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
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.
ACAC - - ATC
Query a new sequence
45
Multiple AlignmentsTry 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 statesViterbi alg. Dynamic Programming
46
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
changingBy-product: It produced a multiple
alignment
47
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.
48
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
49
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)
Demos Speech synthesis
http://www.cstr.ed.ac.uk/projects/festival/onlinedemo.html