1 #include <unordered_map> 11 const std::unordered_map<std::int32_t, std::int32_t>& counts,
12 const std::size_t nsam)
14 if (counts.empty() || !nsam)
16 return std::numeric_limits<double>::quiet_NaN();
19 for (
auto&& c : counts)
21 hom +=
static_cast<double>(c.second * (c.second - 1));
23 hom /=
static_cast<double>(nsam * (nsam - 1));
double diversity_from_counts(const std::unordered_map< std::int32_t, std::int32_t > &counts, const std::size_t nsam)
Calculate heterozygosity/diversity from count data.
The namespace in which this library resides.