1 #ifndef SEQUENCE_DETAIL_HPRIME_FAYWUH_AGGREGATOR_HPP 2 #define SEQUENCE_DETAIL_HPRIME_FAYWUH_AGGREGATOR_HPP 4 #include <Sequence/AlleleCountMatrix.hpp> 20 class hprime_faywuh_row_processor
24 update_stat(
const double d,
const stat_is_faywuh)
26 return std::pow(d, 2.0);
30 update_stat(
const double d,
const stat_is_hprime)
36 denominator(
const std::size_t nsam,
const stat_is_faywuh)
38 return 2./
static_cast<double>(nsam * (nsam - 1));
42 denominator(
const std::size_t nsam,
const stat_is_hprime)
44 return 1./
static_cast<double>(nsam - 1);
50 const std::size_t i,
const std::size_t refindex,
56 double homozygosity = 0.0;
57 for (std::size_t j = i; j < i + ac.ncol; ++j)
59 auto ci = ac.counts[j];
63 +=
static_cast<double>(ci * (ci - 1));
65 if (j - i != refindex)
67 temp += update_stat(ci, t);
77 throw std::runtime_error(
78 "site has more than one derived state");
88 =
static_cast<double>(ac.nsam * (ac.nsam - 1));
89 pi += 1.0 - homozygosity / nnm1;
90 double x = denominator(ac.nsam, t);
98 hprime_faywuh_row_processor()
99 : S{ 0 }, pi{ 0.0 }, theta{ 0.0 }
105 const std::size_t i,
const std::size_t refindex,
106 const stat_is_faywuh dispatch)
108 stat_details(ac, i, refindex, dispatch);
113 const std::size_t i,
const std::size_t refindex,
114 const stat_is_hprime dispatch)
116 stat_details(ac, i, refindex, dispatch);
bool operator()(const std::pair< key, value > &l, const std::pair< key, value > &r) const
The namespace in which this library resides.
Matrix representation of allele counts in a VariantMatrix To be constructed.