Page MenuHomec4science

ReadLayer.hpp
No OneTemporary

File Metadata

Created
Fri, May 10, 23:49

ReadLayer.hpp

#ifndef READLAYER_HPP
#define READLAYER_HPP
#include <DataLayer.hpp>
#include <matrices.hpp>
class ReadLayer : public DataLayer
{
public:
/*!
* \brief Constructs an object with the
* given data and an empty (0 values)
* model.
* \param data the data.
* \param n_class the number of classes
* of the model.
* \param n_shift the number of shift
* states of the model.
* \param flip whether flipping is allowed.
*/
ReadLayer(const matrix2d_i& data,
size_t n_class,
size_t n_shift,
bool flip) ;
/*!
* \brief Construct an object with the
* given data and model.
* \param data the data.
* \param the model.
* \param flip whether flipping is allowed.
*/
ReadLayer(const matrix2d_i& data,
const matrix3d_d& model,
bool flip) ;
/*!
* Destructor
*/
virtual ~ReadLayer() override ;
/*!
* \brief Initialises the references randomly.
* Generates the initial references by randomly
* assigning the data to the classes using a beta
* distribution.
*/
virtual void seed_model_randomly() override ;
/*!
* \brief Sets the model values by
* sampling rows in the data and
* assigning them as initial model
* values.
*/
virtual void seed_model_sampling() override ;
/*!
* \brief Sets the model values by
* using the first n_class rows in data.
*/
virtual void seed_model_toy() override ;
/*!
* \brief Computes the log likelihood of the data
* given the current model parameters.
* During this process, a normalized version of the
* models, having a sum of signal of 1 count in average,
* is used (a copy of the models is normalized, meaning
* that the original models can still be retrieved the
* dedicated getter).
* \param logliklihood a matrix to store the
* results. It should have the following dimensions :
* 1st : same as the data number of row
* 2nd : same as the model number of classes
* 3rd : same as the number of shifts
* 4th : same as the number of flip states
* \param loglikelihood_max a vector containing the
* max value for each row of loglikelihood.
* Its length should be equal to the data row number.
* \throw std::invalid_argument if the dimensions are
* incorrect.
*/
virtual void compute_loglikelihoods(matrix4d_d& loglikelihood,
vector_d& loglikelihood_max) const override ;
/*!
* \brief Updates the model given the posterior
* probabilities (the probabilities of each row
* in the data to be assigned to each class,
* for each shift and flip state).
* \param posterior_prob the data assignment probabilities to
* the different classes.
*/
virtual void update_model(const matrix4d_d& posterior_prob) override ;
/*!
* \brief Updates the model given the posterior
* probabilities (the probabilities of each row
* in the data to be assigned to each class,
* for each shift and flip state).
* This method does the same as the virtual method it
* overloads. The only difference is that, for run time
* gain, it is given the sum over the columns of the
* posterior_prob matrix which is computed by the virtual
* method.
* \param posterior_prob the data assignment probabilities to
* the different classes.
* \param posterior_prob_colsum the sum over the columns
* (classes) of the posterior_prob matrix.
*/
void update_model(const matrix4d_d& posterior_prob,
const vector_d& posterior_prob_colsum) ;
protected:
/*!
* \brief Computes the mean number of reads present in
* each slice (of length l_model), in each row
* of the data and store them in this->window_means.
*/
void compute_window_means() ;
/*!
* \brief Checks that the argument has compatible
* dimensions with the data and models. If this is
* not the case, throw a std::invalid_argument with
* a relevant message.
* \param posterior_class_prob a vector containing the
* class probabilities.
* It should have a length equal to the number of
* classes.
* \throw std::invalid_argument if the dimensions are
* incorrect.
*/
void check_posterior_prob_colsum_dim(const vector_d& posterior_prob_colsum) const ;
/*!
* \brief contains the data means, for
* each window of size l_model.
*/
matrix2d_d window_means ;
} ;
#endif // READLAYER_HPP

Event Timeline