libsequence  1.9.5
thetapi.cc
1 #include <stdexcept>
2 #include <Sequence/AlleleCountMatrix.hpp>
3 
4 namespace Sequence
5 {
6  double
8  {
9  double pi = 0.0;
10  for (std::size_t i = 0; i < ac.counts.size(); i += ac.ncol)
11  {
12  std::int32_t nsam = 0;
13  double homozygosity = 0.0;
14  for (std::size_t j = i; j < i + ac.ncol; ++j)
15  {
16  nsam += ac.counts[j];
17  homozygosity += static_cast<double>(
18  ac.counts[j] * (ac.counts[j] - 1));
19  }
20  pi += 1.0
21  - homozygosity / static_cast<double>(nsam * (nsam - 1));
22  }
23  return pi;
24  }
25 
26 } // namespace Sequence
The namespace in which this library resides.
double thetapi(const AlleleCountMatrix &ac)
Mean pairwise differences.
Definition: thetapi.cc:7
Matrix representation of allele counts in a VariantMatrix To be constructed.