eXpress “1.5”

LengthDistribution Class Reference

lengthdistribution.h express More...

#include <lengthdistribution.h>

List of all members.

Public Member Functions

 LengthDistribution (double alpha, size_t max_val, size_t prior_mu, size_t prior_sigma, size_t kernel_n, double kernel_p, size_t bin_size=1)
 LengthDistribution Constructor.
 LengthDistribution (std::string param_file_name, std::string length_type)
 A second constructor that loads the distribution from a parameter file.
size_t max_val () const
 An accessor for the maximum allowed length.
size_t min_val () const
 An accessor for the minimum observed length (1 initially).
double mean () const
 An accessor for the mean length in the distribution.
void add_val (size_t len, double mass)
 A member function that updates the distribution based on a new length observation.
double pmf (size_t len) const
 An accessor for the (logged) probability of a given length.
double cmf (size_t len) const
 A member function that returns a (logged) cumulative mass for a given length.
std::vector< double > cmf () const
 A member function that returns a vector containing the (logged) cumulative mass function *for the bins*.
double tot_mass () const
 An accessor for the (logged) observation mass (including pseudo-counts).
std::string to_string () const
 A member function that returns a string containing the current distribution.
void append_output (std::ofstream &outfile, std::string length_type) const
 A member function that appends the LengthDistribution parameters to the end of the given file.

Detailed Description

lengthdistribution.h express

Created by Adam Roberts on 1/30/13. Copyright 2013 Adam Roberts. All rights reserved. The LengthDistribution class keeps track of the observed length distribution. It is initialized with a Gaussian prior with parameters specified by the arguments to the constructor. An argument-specified binomial kernel is then added for each observation. All mass values and probabilities are stored and returned in log space (except in to_string).

Definition at line 22 of file lengthdistribution.h.


Constructor & Destructor Documentation

LengthDistribution::LengthDistribution ( double  alpha,
size_t  max_val,
size_t  prior_mu,
size_t  prior_sigma,
size_t  kernel_n,
double  kernel_p,
size_t  bin_size = 1 
)

LengthDistribution Constructor.

Parameters:
alphadouble that sets the average pseudo-counts (logged).
max_valan integer that sets the maximum allowable length.
prior_mua size_t for the mean of the prior gaussian distribution. If 0, a uniform distribution is used instead.
prior_sigmaa size_t for the standard deviation of the prior gaussian distribution.
kernel_na size_t specifying the number of trials in the kernel binomial distribution. Must be odd.
kernel_pa double specifying the success probability for the kernel binomial distribution.
bin_sizea size_t specifying the size of bins to use internally to reduce the number of parameters in the distribution.

Definition at line 20 of file lengthdistribution.cpp.

LengthDistribution::LengthDistribution ( std::string  param_file_name,
std::string  length_type 
)

A second constructor that loads the distribution from a parameter file.

Note that the values should not be modified (add_val should not be called) after using this constructor. The bin size is set to 1.

Parameters:
param_file_namea string specifying the path to the parameter file.
length_typea string specifying the type of length distribution to be matched in the parameter file.

Member Function Documentation

void LengthDistribution::add_val ( size_t  len,
double  mass 
)

A member function that updates the distribution based on a new length observation.

Parameters:
lenan integer for the observed length.
massa double for the mass (logged) to add.

Definition at line 114 of file lengthdistribution.cpp.

void LengthDistribution::append_output ( std::ofstream &  outfile,
std::string  length_type 
) const

A member function that appends the LengthDistribution parameters to the end of the given file.

Parameters:
outfilethe file to append to.
length_typea string specifying the type of length the distribution is of (ie. "Fragment" or "Target") to be included in the header.
double LengthDistribution::cmf ( size_t  len) const

A member function that returns a (logged) cumulative mass for a given length.

Parameters:
lenan integer for the length to return the cmf value of.
Returns:
(Logged) cmf value of length.

Definition at line 148 of file lengthdistribution.cpp.

vector< double > LengthDistribution::cmf ( ) const

A member function that returns a vector containing the (logged) cumulative mass function *for the bins*.

Returns:
(Logged) cmf of bins.

Definition at line 158 of file lengthdistribution.cpp.

size_t LengthDistribution::max_val ( ) const

An accessor for the maximum allowed length.

Returns:
Max allowed length.

Definition at line 103 of file lengthdistribution.cpp.

double LengthDistribution::mean ( ) const

An accessor for the mean length in the distribution.

Returns:
Mean observed length.

Definition at line 174 of file lengthdistribution.cpp.

size_t LengthDistribution::min_val ( ) const

An accessor for the minimum observed length (1 initially).

Returns:
Minimum observed length.

Definition at line 107 of file lengthdistribution.cpp.

double LengthDistribution::pmf ( size_t  len) const

An accessor for the (logged) probability of a given length.

Parameters:
lenan integer for the length to return the probability of.
Returns:
(logged) probability of observing the given length.

Definition at line 140 of file lengthdistribution.cpp.

string LengthDistribution::to_string ( ) const

A member function that returns a string containing the current distribution.

Returns:
Space-separated string of probabilities ordered from length 0 to max_val (non-logged).

Definition at line 178 of file lengthdistribution.cpp.

double LengthDistribution::tot_mass ( ) const

An accessor for the (logged) observation mass (including pseudo-counts).

Returns:
Total observation mass.

Definition at line 170 of file lengthdistribution.cpp.


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