WBO 7 – Hidden Markov Models

Today, we will be talking about Hidden Markov Models. The slides are here: wyk7-hmm. Polish version of the notes can be found below. The lecture will be online again, check the chat.mimuw.edu.pl for the link. 

Today’s practicals are here:

0. Take a look at the  hmmlearn package. We will be using it to train hidden Markov Models

1.CpG islands are found frequently in diverse genomes, and human genome in particular. Try to define a 2-state HMM (CpG and background) and train it on the  cpg.fa input file. You can try and do it with four possible emissions (ACGT), and for 16 di-nucleotide emissions (AA,AC,AG,AT,  etc.) Can you interpret the emission matrix and assign the learned states to the CpG and background sequences? Perform the learning process  (Baum-Welch) several times and see if the results are similar. Can you interpret the transition matrix probabilities? What does it tell us about the average length of CpG islands?

It might be worth to take a look at the  MultinomialHMM usage example

2. We can also use HMMs for quantitative signal segmentation. Let us take a sample file – histone methylation data from A. thaliana plant (H3K9me2-crh6-3-chr1.sgr) giving us methylation quantification for different positions in the genome (this is a text file with a position and a value in each line).Use GaussianHMM class to identify 2-state and 3-state models from this data. What are the mean emission values for these data? You can find an example of GaussianHMM here.

Homework (2 pts):

Use the trained CpG model on the following 30 sequences from a file cpg_test.fa. As a result, send me the code (in .py) and the results (in a text file). This time you have 2 weeks for this task.

Polish version below:

Dziś na wykładzie omówimy ukryte modele Markowa i algorytmy rekonstrukcji parametrów z danych. Slajdy są tu: wyk7-hmm

Zadania na dziś:

0. Zapoznaj się z modułem hmmlearn. Będziemy go wykorzystywać do uczenia modeli z emisjami

1. Wyspy CpG znajdują się często w genomach, w szczególności genomie ludzkim. Spróbuj zdefiniować ukryty model Markowa, który ma 2 stany i spróbuj nauczyć go na sekwncji zawartej w pliku cpg.fa. Zrób to zarówno dla sekwencji liter (ACGT), jak i dla sekwencji dwunukleotydów (AA,AC,AG,AT, itp…) Czy możesz zinterpretować macierze emisji i przypisać jeden ze stanów do wysp CpG? Wykonaj kilkakrotnie proces uczenia (Baum-Welch) i zobacz czy wyniki są podobne. Jak interpretujesz prawdopodobieństwa w macierzy przejść. Czy coś możesz powiedzieć o średniej długości wysp CpG?

Warto przyjrzeć się przykładowi użycia klasy MultinomialHMM

2. czasami potrzebujemy użyć łańcuchów Markowa do segmentacji sygnału. Weżmy przykładowy plik – dane o methylacji histonów w rzodkiewniku (H3K9me2-crh6-3-chr1.sgr) zawierający poziom metylacji w różnych pozycjach (plik jest tekstowy, każda linia zawiera informacje o pozycji i wartośći). Wykorzystaj HMM z emisjami Gaussowskimi do segmentacji genomu na 2 lub 3 stany. Jakie są wysetymowane wartości średnie dla różnych stanów? Przykład wykorzystania HMMów z emisjami Gaussowskimi można znaleźć tu 

praca domowa (2 pkt):

Wykorzystaj model nauczony na danych o CpG i przetestuj które z 30 sekwencji w pliku cpg_test.fa są naprawdę wyspami CpG. Jako wynik proszę przysłać program w pythonie i wynik w pliku tekstowym.

Leave a Reply

Your email address will not be published. Required fields are marked *