eXpress “1.5”
|
The MismatchTable class is used to store and update mismatch and indel (error) parameters using a first-order Markov model based on nucleotide and position in a read. More...
#include <mismatchmodel.h>
Public Member Functions | |
MismatchTable (double alpha) | |
MismatchTable constructor initializes the model parameters using the specified (non-logged) pseudo-counts. | |
MismatchTable (std::string param_file_name) | |
A second constructor that loads the distribution from a parameter file. | |
void | activate (bool active=true) |
Mutator to set the _active member variable to allow for log_likelihood calculations. | |
void | get_indices (const FragHit &f, std::vector< char > &left_indices, std::vector< char > &left_seq, std::vector< char > &left_ref, std::vector< char > &right_indices, std::vector< char > &right_seq, std::vector< char > &right_ref) const |
A member function that computes and returns the parameter table indices used to compute and update the likelihood based on the given FragHit. | |
double | log_likelihood (const FragHit &f) const |
A member function that returns the log likelihood of mismatches and indels in the mapping given the current error model parematers. | |
void | update (const FragHit &, double p, double mass) |
A member function that updates the error model parameters based on a mapping and its (logged) mass. | |
void | fix () |
Freezes the parameters to allow for faster computation after burn out. | |
void | append_output (std::ofstream &outfile) const |
A member function that appends the final model parameters in tab-separated format to the given file. |
The MismatchTable class is used to store and update mismatch and indel (error) parameters using a first-order Markov model based on nucleotide and position in a read.
Also computes likelihoods of mismatches and indels in given fragment mappings. When the target sequences are proabilistic, this class is responsible for updating those parameters. All values are stored and returned in log space.
Definition at line 29 of file mismatchmodel.h.
MismatchTable::MismatchTable | ( | double | alpha | ) |
MismatchTable constructor initializes the model parameters using the specified (non-logged) pseudo-counts.
alpha | a double containing the non-logged pseudo-counts for parameter initialization. |
Definition at line 19 of file mismatchmodel.cpp.
MismatchTable::MismatchTable | ( | std::string | param_file_name | ) |
A second constructor that loads the distribution from a parameter file.
Note that the values should not be modified after using this constructor.
param_file_name | a string specifying the path to the parameter file. |
void MismatchTable::activate | ( | bool | active = true | ) | [inline] |
Mutator to set the _active member variable to allow for log_likelihood calculations.
Used to skip calculations before burn-in completes.
active | a boolean specifying whether to activate (true) or deactivate (false) |
Definition at line 79 of file mismatchmodel.h.
void MismatchTable::append_output | ( | std::ofstream & | outfile | ) | const |
A member function that appends the final model parameters in tab-separated format to the given file.
The output has 1 row for each read position and the parameters are in columns indexed as (ref, prev, obs) in base 4 with A,C,G,T encoded as 0,1,2,3.
file | stream to append to. |
Definition at line 119 of file biascorrection.cpp.
void MismatchTable::fix | ( | ) |
Freezes the parameters to allow for faster computation after burn out.
Cannot be undone.
Definition at line 567 of file mismatchmodel.cpp.
void MismatchTable::get_indices | ( | const FragHit & | f, |
std::vector< char > & | left_indices, | ||
std::vector< char > & | left_seq, | ||
std::vector< char > & | left_ref, | ||
std::vector< char > & | right_indices, | ||
std::vector< char > & | right_seq, | ||
std::vector< char > & | right_ref | ||
) | const |
A member function that computes and returns the parameter table indices used to compute and update the likelihood based on the given FragHit.
Sequence values are compressed to 2 bits per nucleotide.
f | the FragHit to find the table indices for. |
left_indices | vector to store the left read's mismatched positions. |
left_seq | vector to store the left read's mismatched nucleotides (compressed). |
left_ref | vector to store the left read's reference nucleotides (compressed) at mismatch positions. |
right_indices | vector to store the right read's mismatched positions. |
right_seq | vector to store the rightt read's mismatched nucleotides (compressed). |
right_ref | vector to store the right read's reference nucleotides (compressed) at mismatch positions. |
Definition at line 159 of file mismatchmodel.cpp.
double MismatchTable::log_likelihood | ( | const FragHit & | f | ) | const |
A member function that returns the log likelihood of mismatches and indels in the mapping given the current error model parematers.
Returns 0 if _active is false.
f | the fragment mapping to calculate the log likelihood for. |
Definition at line 264 of file mismatchmodel.cpp.
void MismatchTable::update | ( | const FragHit & | f, |
double | p, | ||
double | mass | ||
) |
A member function that updates the error model parameters based on a mapping and its (logged) mass.
Also updates the sequence parameters if they are probabilistic and active_ is true.
f | the fragment mapping. |
p | the logged posterior probablity of the alignment. |
mass | the logged mass of the fragment. |
Definition at line 393 of file mismatchmodel.cpp.