1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43
|
#ifndef SIMPLE_POS_BIAS_HPP
#define SIMPLE_POS_BIAS_HPP
#include "spline.h"
#include <array>
#include <vector>
class SimplePosBias {
public:
SimplePosBias(int32_t numBins = 20, bool logSpace = true);
// Add a mass of @mass to bin @bin
void addMass(int32_t bin, double mass);
// Compute the bin for @pos on a transcript of length @length,
// and add @mass to the appropriate bin
void addMass(int32_t pos, int32_t length, double mass);
// Project, via linear interpolation, the weights contained in "bins"
// into the vector @out.
void projectWeights(std::vector<double>& out);
// Combine the distribution @other
// with this distribution
void combine(const SimplePosBias& other);
// We're finished updating this distribution, so
// compute the cdf etc.
void finalize();
private:
int32_t numBins_;
std::vector<double> masses_;
bool isLogged_{true};
tk::spline s_;
// position bins taken from Cufflinks:
// https://github.com/cole-trapnell-lab/cufflinks/blob/master/src/biascorrection.cpp
const std::vector<double> positionBins_{{.02, .04, .06, .08, .10, .15, .2,
.3, .4, .5, .6, .7, .8, .85,
.9, .92, .94, .96, .98, 1.0}};
};
#endif // SIMPLE_POS_BIAS_HPP
|