eXpress “1.5”
|
The MarkovModel class is used to store transition probabilities of a Markov chain based on a nucleotide Sequence, which itself can be probabilistic. More...
#include <markovmodel.h>
Public Member Functions | |
MarkovModel (size_t order, size_t window_size, size_t num_pos, double alpha) | |
MarkovModel Constructor. | |
double | transition_prob (size_t p, size_t cond, size_t curr) const |
Accessor for the probability of transitioning from cond to curr at node p. | |
double | seq_prob (const Sequence &seq, int left) const |
Computes the probability of the sequence beginning at left of size _window_size using the parameters of the Markov model. | |
void | update (const Sequence &seq, int left, double mass) |
Increments the parameters associated with the sequence beginning at left of size _window_size by the (logged) mass. | |
void | update (size_t p, size_t i, size_t j, double mass) |
Increments the specified transition by the given mass. | |
size_t | get_indices (const Sequence &seq, int left, std::vector< char > &indices) |
A member function that computes and returns the parameter table indices used to compute and update the likelihood for the given sequence at the window started at the given position. | |
std::vector< char > | get_indices (const Sequence &seq) |
A member function that computes and returns the parameter table indices used to fast_learn (see below) the likelihood for the given sequence. | |
double | marginal_prob (size_t w, size_t nuc) const |
Computes the marginal probability of transitioning to the given nucleotide at position w in the model. | |
void | fast_learn (const Sequence &seq, double mass, const std::vector< double > &fl_cmf) |
Slides a window along the given sequence, incrementing the highest order transition paramaters by the given mass multiplied by the probability of observing a fragment at that distance from the end. | |
void | calc_marginals () |
After learning the highest order transitions with fast_learn, this method fills in the lower-order transitions. |
The MarkovModel class is used to store transition probabilities of a Markov chain based on a nucleotide Sequence, which itself can be probabilistic.
The The probabilities can be updated based on a sequence window and can be initialized by sliding a window over a sequence. Nucleotides are represented by size_t values according to the NUCS array in main.h.
Definition at line 28 of file markovmodel.h.
MarkovModel::MarkovModel | ( | size_t | order, |
size_t | window_size, | ||
size_t | num_pos, | ||
double | alpha | ||
) |
MarkovModel Constructor.
order | the order of the model. |
window_size | the size of the sequence window to calculate probabilities for. |
num_pos | the number of nodes in the model. |
alpha | the initial pseudo-counts (non-logged). |
Definition at line 16 of file markovmodel.cpp.
void MarkovModel::fast_learn | ( | const Sequence & | seq, |
double | mass, | ||
const std::vector< double > & | fl_cmf | ||
) |
Slides a window along the given sequence, incrementing the highest order transition paramaters by the given mass multiplied by the probability of observing a fragment at that distance from the end.
seq | the sequence to slide the window along. |
mass | the amount to increment the parameters by. |
fl_cmf | the fragment length CMF to determine the probability of observing fragment starts at different positions in the sequence. |
Definition at line 113 of file markovmodel.cpp.
size_t MarkovModel::get_indices | ( | const Sequence & | seq, |
int | left, | ||
std::vector< char > & | indices | ||
) |
A member function that computes and returns the parameter table indices used to compute and update the likelihood for the given sequence at the window started at the given position.
Negative values indicate that the position is not used in the likelihood computation.
seq | the sequence to find the indices for. |
left | the position where the window should begin in the sequence. |
indices | a vector to fill with indices into the parameter tables that would be used in a likelihood calculation. |
vector< char > MarkovModel::get_indices | ( | const Sequence & | seq | ) |
A member function that computes and returns the parameter table indices used to fast_learn (see below) the likelihood for the given sequence.
Negative values indicate that the position is not used in the fast_learn computation.
seq | the sequence to find the indices for. |
Definition at line 92 of file markovmodel.cpp.
double MarkovModel::marginal_prob | ( | size_t | w, |
size_t | nuc | ||
) | const |
Computes the marginal probability of transitioning to the given nucleotide at position w in the model.
w | the position (node) in the model. |
nuc | the nucleotide to calculate the marginal transition probability to. |
Definition at line 204 of file markovmodel.cpp.
double MarkovModel::seq_prob | ( | const Sequence & | seq, |
int | left | ||
) | const |
Computes the probability of the sequence beginning at left of size _window_size using the parameters of the Markov model.
seq | the sequence from which to extract the window. |
left | the leftmost point in the sequence window. |
Definition at line 163 of file markovmodel.cpp.
double MarkovModel::transition_prob | ( | size_t | p, |
size_t | cond, | ||
size_t | curr | ||
) | const |
Accessor for the probability of transitioning from cond to curr at node p.
p | the node to get the transition probability from. |
cond | the index of the previous state. |
curr | the index of the state being transitioned to. |
Definition at line 158 of file markovmodel.cpp.
void MarkovModel::update | ( | const Sequence & | seq, |
int | left, | ||
double | mass | ||
) |
Increments the parameters associated with the sequence beginning at left of size _window_size by the (logged) mass.
seq | the sequence from which to extract the window. |
left | the leftmost point in the sequence window. |
mass | the amount to increment the parameters by (logged). |
Definition at line 57 of file markovmodel.cpp.
void MarkovModel::update | ( | size_t | p, |
size_t | i, | ||
size_t | j, | ||
double | mass | ||
) |
Increments the specified transition by the given mass.
p | the position in the chain to increment. |
i | the index of the previous state. |
j | the index of the transitioned state. |
mass | the amount to increment by (logged). |
Definition at line 88 of file markovmodel.cpp.