Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions src/radmeth/radmeth_model.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ template <typename T> struct Regression {
static double tolerance; // 1e-3;
static double stepsize; // 0.001;
static std::uint32_t max_iter; // 250;
static constexpr double pseudocount = 1.0 / 256.0;

Design design;
std::string rowname;
Expand Down Expand Up @@ -155,6 +156,15 @@ Regression<T>::parse(const std::string &line) {
mc.push_back(mc1);
}

const auto add_pseudocount = [&](auto x) {
x.n_meth = x.n_reads > 0.0 ? pseudocount / 2.0 +
x.n_meth * (1.0 - pseudocount / x.n_reads)
: 0.0;
return x;
};

std::transform(std::begin(mc), std::end(mc), std::begin(mc), add_pseudocount);

if (failed)
throw std::runtime_error("failed to parse counts from:\n" + line);
}
Expand Down