eXpress “1.5”

MarkovModel Class Reference

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>

List of all members.

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.

Detailed Description

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.

Author:
Adam Roberts
Date:
2012 Artistic License 2.0

Definition at line 28 of file markovmodel.h.


Constructor & Destructor Documentation

MarkovModel::MarkovModel ( size_t  order,
size_t  window_size,
size_t  num_pos,
double  alpha 
)

MarkovModel Constructor.

Parameters:
orderthe order of the model.
window_sizethe size of the sequence window to calculate probabilities for.
num_posthe number of nodes in the model.
alphathe initial pseudo-counts (non-logged).

Definition at line 16 of file markovmodel.cpp.


Member Function Documentation

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.

Parameters:
seqthe sequence to slide the window along.
massthe amount to increment the parameters by.
fl_cmfthe 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.

Parameters:
seqthe sequence to find the indices for.
leftthe position where the window should begin in the sequence.
indicesa vector to fill with indices into the parameter tables that would be used in a likelihood calculation.
Returns:
The starting position in the sequence to align with the first index.
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.

Parameters:
seqthe sequence to find the indices for.
Returns:
A vector of indices into the parameter tables that would be used in a fast_learn.

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.

Parameters:
wthe position (node) in the model.
nucthe nucleotide to calculate the marginal transition probability to.
Returns:
The marginal probability of transitioning to nuc at position w.

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.

Parameters:
seqthe sequence from which to extract the window.
leftthe leftmost point in the sequence window.
Returns:
The probability of the sequence based on the model parameters.

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.

Parameters:
pthe node to get the transition probability from.
condthe index of the previous state.
currthe index of the state being transitioned to.
Returns:
The probability of transitioning from cond to curr at node p.

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.

Parameters:
seqthe sequence from which to extract the window.
leftthe leftmost point in the sequence window.
massthe 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.

Parameters:
pthe position in the chain to increment.
ithe index of the previous state.
jthe index of the transitioned state.
massthe amount to increment by (logged).

Definition at line 88 of file markovmodel.cpp.


The documentation for this class was generated from the following files:
 All Classes Functions Variables