libsequence  1.9.5
rmin.cc
1 #include <cstdint>
2 #include <Sequence/summstats/ld.hpp>
4 #include <Sequence/VariantMatrix.hpp>
5 #include <Sequence/AlleleCountMatrix.hpp>
6 #include <Sequence/VariantMatrixViews.hpp>
7 
8 namespace Sequence
9 {
10  std::int32_t
11  rmin(const VariantMatrix& m)
12  {
13  if (m.nsites < 2)
14  {
15  return -1;
16  }
18  auto ac = allele_counts(acm);
19  std::vector<std::size_t> biallelic_site_indexes;
20  for (std::size_t i = 0; i < ac.size(); ++i)
21  {
22  if (ac[i].nstates == 2)
23  {
24  biallelic_site_indexes.push_back(i);
25  }
26  }
27  if (biallelic_site_indexes.size() < 2)
28  {
29  return 0;
30  }
31  bool flag = false;
32  std::size_t x = 0;
33  std::int32_t rv = 0;
34  for (std::size_t a = x + 1; a < biallelic_site_indexes.size(); ++a)
35  {
36  for (std::size_t b = (!flag) ? x : a - 1; b < a; ++b)
37  {
38  flag = false;
39  // We do not allow missing data to result in
40  // additional haplotypes
41  auto tl = two_locus_haplotype_counts(m, a, b, true);
42  if (tl.size() == 4)
43  {
44  ++rv;
45  flag = true;
46  break;
47  }
48  }
49  if (flag == true)
50  {
51  x = a;
52  }
53  }
54  return rv;
55  }
56 } // namespace Sequence
std::vector< AlleleCounts > allele_counts(const AlleleCountMatrix &m)
Count number of alleles at each site.
The namespace in which this library resides.
std::size_t nsites
Number of sites in data set.
Count alleles at variable sites.
std::int32_t rmin(const VariantMatrix &m)
Definition: rmin.cc:11
Matrix representation of variation data.
Matrix representation of allele counts in a VariantMatrix To be constructed.