A library for working with phylogenetic and population genetic data.
v0.27.0
diversity.cpp
Go to the documentation of this file.
1 /*
2  Genesis - A toolkit for working with phylogenetic data.
3  Copyright (C) 2014-2022 Lucas Czech
4 
5  This program is free software: you can redistribute it and/or modify
6  it under the terms of the GNU General Public License as published by
7  the Free Software Foundation, either version 3 of the License, or
8  (at your option) any later version.
9 
10  This program is distributed in the hope that it will be useful,
11  but WITHOUT ANY WARRANTY; without even the implied warranty of
12  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  GNU General Public License for more details.
14 
15  You should have received a copy of the GNU General Public License
16  along with this program. If not, see <http://www.gnu.org/licenses/>.
17 
18  Contact:
19  Lucas Czech <lczech@carnegiescience.edu>
20  Department of Plant Biology, Carnegie Institution For Science
21  260 Panama Street, Stanford, CA 94305, USA
22 */
23 
32 
36 
37 #include <cassert>
38 #include <cmath>
39 #include <mutex>
40 #include <stdexcept>
41 #include <unordered_map>
42 
43 #ifdef GENESIS_OPENMP
44 # include <omp.h>
45 #endif
46 
47 namespace genesis {
48 namespace population {
49 
50 // =================================================================================================
51 // Local Helper Functions
52 // =================================================================================================
53 
63 double amnm_( // get_aMnm_buffer
64  size_t poolsize, // n
65  size_t nucleotide_count, // M (coverage)
66  size_t allele_frequency // m, m_it (running variable for b .. M-b)
67 ) {
68  // The terminology in PoPoolation is confusing and differs completely from the paper,
69  // their code is not well documented, and their binomial_term function combines other aspects
70  // of the computation than just computing the binomial distribution,
71  // hence adding to the confusion. Let's try to disentangle:
72  //
73  // It seems, we want a binomial distribution with n being the coverage/nucleotide_count/M,
74  // and k being the allele_frequency/m, and we want p being r (1..poolsize-1) divided by poolsize,
75  // using the r from the below loop (which confusingly is also called k in PoPoolation).
76  // What a mess.
77 
79  size_t poolsize, size_t nucleotide_count, size_t allele_frequency
80  ) {
81  double result = 0.0;
82 
83  // #pragma omp parallel for
84  for( size_t r = 1; r <= poolsize - 1; ++r ) {
85  double const p = static_cast<double>( r ) / static_cast<double>( poolsize );
86 
87  // We use the "lenient" flag of the binomial distribution, so that values of
88  // nucleotide_count = n > 1024 do not throw an exception, but return infinity instead.
89  // That is okay, because this will lead to the theta denominator being infinity as well,
90  // which is then inverted, so it becomes 0, and then added to the total theta of the
91  // window. So, it just vanishes in that case, which is okay.
92  double const binom = utils::binomial_distribution(
93  allele_frequency, nucleotide_count, p, true
94  );
95  double const partial = binom / static_cast<double>( r );
96 
97  // #pragma omp atomic
98  result += partial;
99  }
100  return result;
101  }};
102 
103  return amnm_cache_( poolsize, nucleotide_count, allele_frequency );
104 }
105 
106 // =================================================================================================
107 // Diversity Estimates
108 // =================================================================================================
109 
110 double heterozygosity( BaseCounts const& sample, bool with_bessel )
111 {
112  using namespace genesis::utils;
113 
114  double h = 1.0;
115  double const nt_cnt = static_cast<double>( nucleotide_sum( sample ));
116  h -= squared( static_cast<double>( sample.a_count ) / nt_cnt );
117  h -= squared( static_cast<double>( sample.c_count ) / nt_cnt );
118  h -= squared( static_cast<double>( sample.g_count ) / nt_cnt );
119  h -= squared( static_cast<double>( sample.t_count ) / nt_cnt );
120 
121  // Slighly slower version with powers.
122  // h -= std::pow( static_cast<double>( sample.a_count ) / nt_cnt, 2 );
123  // h -= std::pow( static_cast<double>( sample.c_count ) / nt_cnt, 2 );
124  // h -= std::pow( static_cast<double>( sample.g_count ) / nt_cnt, 2 );
125  // h -= std::pow( static_cast<double>( sample.t_count ) / nt_cnt, 2 );
126  if( with_bessel ) {
127  h *= nt_cnt / ( nt_cnt - 1.0 );
128  }
129  return h;
130 }
131 
132 // =================================================================================================
133 // Theta Pi
134 // =================================================================================================
135 
137  PoolDiversitySettings const& settings,
138  size_t nucleotide_count // M
139 ) {
140  // PoPoolation variable names:
141  // poolsize: n
142  // min_allele_count: b
143  // nucleotide_count: M
144 
145  // Local cache for speed.
147  size_t poolsize, size_t min_allele_count, size_t nucleotide_count
148  ){
149  // Boundary: if not held, we'd return zero, and that would not be a useful denominator.
150  if( 2 * min_allele_count > nucleotide_count ) {
151  throw std::invalid_argument(
152  "Cannot compute theta_pi_pool_denominator with min_allele_count = " +
153  std::to_string( min_allele_count ) + " and nucleotide_count = " +
154  std::to_string( nucleotide_count )
155  );
156  }
157 
158  // Iterate all allele frequencies in between the min and max-min boundaries.
159  double div = 0.0;
160 
161  #pragma omp parallel for
162  for( size_t m_it = min_allele_count; m_it <= ( nucleotide_count - min_allele_count ); ++m_it ) {
163  // We iterate from b to M-b (in PoPoolation terminology), inclusively.
164  // Use double values however for the computations.
165  double const m = static_cast<double>( m_it );
166  double const M = static_cast<double>( nucleotide_count );
167 
168  // Compute the term. We here use the cache, which also computes results if not yet cached.
169  double const term = ( 2.0 * m * ( M - m )) / ( M * ( M - 1.0 ));
170  double const partial = term * amnm_( poolsize, nucleotide_count, m_it );
171 
172  #pragma omp atomic
173  div += partial;
174  }
175  return div;
176  }};
177 
178  // Simply return the cached value (which computes them first if not yet cached).
179  return denom_cache_( settings.poolsize, settings.min_allele_count, nucleotide_count );
180 }
181 
182 // =================================================================================================
183 // Theta Watterson
184 // =================================================================================================
185 
187  PoolDiversitySettings const& settings,
188  size_t nucleotide_count // M
189 ) {
190  // PoPoolation variable names:
191  // poolsize: n
192  // min_allele_count: b
193  // nucleotide_count: M
194 
195  // Local cache for speed.
197  size_t poolsize, size_t min_allele_count, size_t nucleotide_count
198  ){
199  // Boundary: if not held, we'd return zero, and that would not be a useful denominator.
200  if( 2 * min_allele_count > nucleotide_count ) {
201  throw std::invalid_argument(
202  "Cannot compute theta_watterson_pool_denominator with min_allele_count = " +
203  std::to_string( min_allele_count ) + " and nucleotide_count = " +
204  std::to_string( nucleotide_count )
205  );
206  }
207 
208  // Iterate all allele frequencies in between the min and max-min boundaries.
209  double div = 0.0;
210 
211  #pragma omp parallel for
212  for( size_t m_it = min_allele_count; m_it <= ( nucleotide_count - min_allele_count ); ++m_it ) {
213 
214  // Compute the term. We here use the cache, which also computes results if not yet cached.
215  auto const anmn = amnm_( poolsize, nucleotide_count, m_it );
216 
217  #pragma omp atomic
218  div += anmn;
219  }
220  return div;
221  }};
222 
223  // Simply return the cached value (which computes them first if not yet cached).
224  return denom_cache_( settings.poolsize, settings.min_allele_count, nucleotide_count );
225 }
226 
227 // =================================================================================================
228 // Tajima's D Local Helpers
229 // =================================================================================================
230 
231 double a_n( size_t n ) // get_an_buffer
232 {
233  // Local cache for speed.
234  static genesis::utils::FunctionCache<double, size_t> a_n_cache_{ []( size_t n ){
235  double sum = 0.0;
236  for( size_t i = 1; i < n; ++i ) {
237  sum += 1.0 / static_cast<double>( i );
238  }
239  return sum;
240  }};
241  return a_n_cache_( n );
242 }
243 
244 double b_n( size_t n ) // get_bn_buffer
245 {
246  // Local cache for speed.
247  static genesis::utils::FunctionCache<double, size_t> b_n_cache_{ []( size_t n ){
248  double sum = 0.0;
249  for( size_t i = 1; i < n; ++i ) {
250  sum += 1.0 / ( static_cast<double>( i ) * static_cast<double>( i ));
251  }
252  return sum;
253  }};
254  return b_n_cache_( n );
255 }
256 
257 double f_star( double a_n, double n ) // calculate_fstar
258 {
259  double const nd = static_cast<double>( n );
260  return ( nd - 3.0 ) / ( a_n * ( nd - 1.0 ) - nd );
261 }
262 
263 double alpha_star( double n ) // get_alphastar_calculator
264 {
265  if( n <= 1 ) {
266  throw std::invalid_argument( "Cannot compute alpha star with effective coverage n <= 1" );
267  }
268 
269  // Local cache for speed.
270  static genesis::utils::FunctionCache<double, double> alpha_star_cache_{ []( double n ){
271  using namespace genesis::utils;
272 
273  // Prepare some constants: n as double, a_n, and f_star.
274  double const nd = static_cast<double>( n );
275  double const an = a_n( n );
276  double const fs = f_star( an, n );
277 
278  // Calculate individual terms (t) and subterms (ts).
279  auto const t1 = squared( fs ) * ( an - ( nd / ( nd - 1.0 )));
280  auto const t2s1 = an * (( 4.0 * ( nd + 1.0 )) / squared( nd - 1.0 ));
281  auto const t2s2 = 2.0 * (( nd + 3.0 ) / ( nd - 1.0 ));
282  auto const t2 = fs * ( t2s1 - t2s2 );
283  auto const t3 = an * (( 8.0 * ( nd + 1.0 )) / ( nd * squared( nd - 1.0 )));
284  auto const t4 = ( squared( nd ) + nd + 60.0 ) / ( 3.0 * nd * ( nd - 1.0 ));
285  return t1 + t2 - t3 + t4;
286  }};
287 
288  return alpha_star_cache_( n );
289 }
290 
291 double beta_star( double n ) // get_betastar_calculator
292 {
293  if( n <= 1 ) {
294  throw std::invalid_argument( "Cannot compute beta star with effective coverage n <= 1" );
295  }
296 
297  // Local cache for speed.
298  static genesis::utils::FunctionCache<double, double> beta_star_cache_{ []( double n ){
299  using namespace genesis::utils;
300 
301  // Prepare some constants: n as double, a_n, b_n, and f_star.
302  double const nd = static_cast<double>( n );
303  double const an = a_n( n );
304  double const bn = b_n( n );
305  double const fs = f_star( an, n );
306 
307  // Calculate individual terms (t) and subterms (ts).
308  auto const t1 = squared( fs ) * ( bn - (( 2.0 * ( nd - 1.0 )) / squared( nd - 1.0 )));
309  auto const t2s1 = bn * ( 8.0 / ( nd - 1.0 ));
310  auto const t2s2 = an * ( 4.0 / ( nd * ( nd - 1.0 )));
311  auto const t2s3n = cubed( nd ) + 12.0 * squared( nd ) - 35.0 * nd + 18.0;
312  auto const t2s3d = nd * squared( nd - 1.0 );
313  auto const t2s3 = t2s3n / t2s3d;
314  auto const t2 = fs * ( t2s1 - t2s2 - t2s3 );
315  auto const t3 = bn * ( 16.0 / ( nd * ( nd - 1.0 )));
316  auto const t4 = an * ( 8.0 / ( squared( nd ) * ( nd - 1.0 )));
317  auto const t5s1 = 2.0 * ( std::pow( nd, 4 ) + 110.0 * squared( nd ) - 255.0 * nd + 126.0 );
318  auto const t5s2 = 9.0 * ( squared( nd ) * squared( nd - 1.0 ));
319  auto const t5 = t5s1 / t5s2;
320  return t1 + t2 - t3 + t4 + t5;
321  }};
322 
323  return beta_star_cache_( n );
324 }
325 
327  size_t max_coverage, size_t poolsize
328 ) {
329  // Prepare a matrix with the needed dimensions. PoPoolation only computes this matrix
330  // for min( max_coverage, poolsize ) many columns, but we go all the way and compute
331  // all that is needed. Just seems cleaner. Also it avoids a bug that PoPoolation might have there.
332  // auto const max_width = max_coverage < poolsize ? max_coverage : poolsize;
333  auto const max_width = poolsize;
334  auto result = genesis::utils::Matrix<double>( max_coverage + 1, max_width + 1 );
335 
336  // Prepare double conversion constants.
337  double const poold = static_cast<double>( poolsize );
338 
339  // Init first row and column, and top left element.
340  result( 0, 0 ) = 1.0;
341  for( size_t i = 1; i < max_coverage + 1; ++i ) {
342  result( i, 0 ) = 0.0;
343  }
344  for( size_t j = 1; j < max_width + 1; ++j ) {
345  result( 0, j ) = 0.0;
346  }
347 
348  // Compute the remaining entries.
349  for( size_t i = 1; i < max_coverage + 1; ++i ) {
350  for( size_t j = 1; j < max_width + 1; ++j ) {
351  auto const t1s1 = (( 1.0 + poold - static_cast<double>( j )) / poold );
352  auto const t1s2 = result( i - 1, j - 1 );
353  auto const t2 = ( static_cast<double>( j ) / poold ) * result( i-1, j );
354  result( i, j ) = t1s1 * t1s2 + t2;
355  }
356  }
357  return result;
358 }
359 
360 genesis::utils::Matrix<double> const& pij_matrix_resolver_( // get_nbase_matrix_resolver
361  size_t max_coverage, size_t poolsize
362 ) {
363  // Here, we need to cache only by poolsize, but additionally make sure that for a given
364  // poolsize, the matrix is large enough for max_coverage.
365  // If it already is, we can just return it. If not, we compute a large enough matrix first.
366  // We could re-use data from the smaller matrix for the computation here, but that would
367  // be more complex. In terms of runtime, this amortizes pretty quickly, so probably no
368  // need to do this optimization as of now.
369  // We could modify FunctionCache to allow overwriting cached values from the outside,
370  // but that somehow seems unclean for all other standard use cases of that class.
371  // Hence, simple map here, so that we can do our own caching with overwriting.
372 
373  // Map from poolsizes to the matrix for that poolsize.
374  using PijMatrix = genesis::utils::Matrix<double>;
375  static std::unordered_map<size_t, PijMatrix> pij_matrix_cache_;
376 
377  // Make sure this function is called thread savely, for concurrent access to the cache.
378  static std::mutex guard_;
379  std::lock_guard<std::mutex> lock( guard_ );
380 
381  // Check if we already have the correct size, and re-compute if not.
382  if(
383  pij_matrix_cache_.count( poolsize ) == 0 ||
384  max_coverage >= pij_matrix_cache_.at( poolsize ).rows() ||
385  poolsize + 1 != pij_matrix_cache_.at( poolsize ).cols()
386  ) {
387  // Get a bit of leeway to reduce recomputation. Or maybe this is about the approximation
388  // that PoPollation does. Not sure. We just copied their approach here...
389  pij_matrix_cache_[ poolsize ] = pij_matrix_( 3 * max_coverage, poolsize );
390  }
391 
392  assert( pij_matrix_cache_.count( poolsize ) > 0 );
393  assert( max_coverage <= pij_matrix_cache_.at( poolsize ).rows() );
394  assert( poolsize <= pij_matrix_cache_.at( poolsize ).cols() );
395  return pij_matrix_cache_[ poolsize ];
396 }
397 
398 double n_base_matrix( size_t coverage, size_t poolsize ) // get_nbase_buffer
399 {
400  // Shortcut? Boundary check? PoPoolation is not clear on this...
401  // Also, might not be needed at all. Who knows. Not me.
402  // News: apparently, not needed, as we cover that case below by flipping roles of the variables.
403  // Not sure why. But let's do as PoPoolation does!
404  // if( poolsize <= coverage ) {
405  // throw std::invalid_argument(
406  // "Cannot compute nbase with poolsize == " + std::to_string( poolsize ) +
407  // " <= coverage == " + std::to_string( coverage )
408  // );
409  // }
410 
411  // Local cache for speed.
413  size_t coverage, size_t poolsize
414  ) {
415 
416  // Get the matrix, cached and by reference, to optimize the access.
417  auto const& pij_matrix = pij_matrix_resolver_( coverage, poolsize );
418 
419  double nbase = 0.0;
420  auto const minj = ( coverage < poolsize ) ? coverage : poolsize;
421  for( size_t k = 1; k <= minj; ++k ) {
422  assert( coverage < pij_matrix.rows() );
423  assert( k < pij_matrix.cols() );
424  nbase += static_cast<double>( k ) * pij_matrix( coverage, k );
425  }
426  return nbase;
427  }};
428 
429  return nbase_cache_( coverage, poolsize );
430 }
431 
432 double n_base( size_t coverage, size_t poolsize ) // get_nbase_buffer, but better
433 {
434  // The following simple closed form is equivalent to the way more complicated equation given
435  // in that hidden PoPoolation auxiliary equations document. See
436  // https://math.stackexchange.com/questions/72223/finding-expected-number-of-distinct-values-selected-from-a-set-of-integers
437  // for the proof. At the time of writing this, we are however still lacking the proof that
438  // the PoPoolation equation and the PoPoolation implementation are equivalent - they never
439  // show that, and instead just use their recursive dynamic programming approach (which we
440  // re-implemented above) without ever showing (to the best of our knowledge) that this is
441  // the same as the given equation.
442  double const p = static_cast<double>( coverage );
443  double const n = static_cast<double>( poolsize );
444  return n * ( 1.0 - std::pow(( n - 1.0 ) / n, p ));
445 }
446 
447 // =================================================================================================
448 // Tajima's D
449 // =================================================================================================
450 
451 double tajima_d_pool_denominator( // get_ddivisor
452  PoolDiversitySettings const& settings,
453  size_t snp_count,
454  double theta
455 ) {
456  // PoPoolation variable names:
457  // poolsize: n
458  // min_allele_count: b
459  // nucleotide_count: M
460 
461  using namespace genesis::utils;
462 
463  // Edge cases.
464  if( settings.min_allele_count != 2 ) {
465  throw std::invalid_argument(
466  "Minimum allele count needs to be set to 2 for calculating pool-corrected Tajima's D "
467  "with tajima_d_pool() according to Kofler et al. In case 2 is insufficient, "
468  "we recommend to subsample the reads to a smaller coverage."
469  );
470  }
471  if( 3 * settings.min_coverage >= settings.poolsize ) {
472  throw std::invalid_argument(
473  "Invalid mincoverage >> poolsize (as internal aproximation we use: "
474  "3 * minimumcoverage < poolsize) in tajima_d_pool()"
475  );
476  }
477 
478  // TODO The average of n seems to be calcualted as the expected value of picking distinct
479  // individuals from a pool. This value is however not an integer. But the alpha star and
480  // beta star computations assume integers. Not sure what to make of this...
481 
482  // We here re-implement two bugs from PoPoolation that massively change the results.
483  // We do this in order to be able to ensure that these are the only differences between
484  // our code and PoPoolation. It is weird and freaky though to conciously implement bugs...
485  double avg_n;
486  double alphastar;
487  double betastar;
488  if( settings.with_popoolation_bugs ) {
489  avg_n = n_base( settings.poolsize, settings.poolsize );
490  alphastar = static_cast<double>( beta_star( avg_n ));
491  betastar = alphastar;
492  } else {
493  avg_n = n_base( settings.min_coverage, settings.poolsize );
494  alphastar = static_cast<double>( alpha_star( avg_n ));
495  betastar = static_cast<double>( beta_star( avg_n ));;
496  }
497 
498  return std::sqrt(
499  ( alphastar / static_cast<double>( snp_count )) * theta + betastar * squared( theta )
500  );
501 }
502 
503 } // namespace population
504 } // namespace genesis
genesis::population::pij_matrix_
genesis::utils::Matrix< double > pij_matrix_(size_t max_coverage, size_t poolsize)
Definition: diversity.cpp:326
genesis::utils::sum
double sum(const Histogram &h)
Definition: utils/math/histogram/stats.cpp:140
genesis::population::a_n
double a_n(size_t n)
Compute a_n, the sum of reciprocals.
Definition: diversity.cpp:231
genesis::population::heterozygosity
double heterozygosity(BaseCounts const &sample, bool with_bessel)
Compute classic heterozygosity.
Definition: diversity.cpp:110
genesis::population::BaseCounts::t_count
size_t t_count
Count of all T nucleotides that are present in the sample.
Definition: base_counts.hpp:74
genesis::population::PoolDiversitySettings::min_coverage
size_t min_coverage
Definition: diversity.hpp:79
genesis::population::amnm_
double amnm_(size_t poolsize, size_t nucleotide_count, size_t allele_frequency)
Local helper function to compute values for the denominator.
Definition: diversity.cpp:63
genesis::population::f_star
double f_star(double a_n, double n)
Compute f* according to Achaz 2008 and Kofler et al. 2011.
Definition: diversity.cpp:257
common.hpp
genesis::population::PoolDiversitySettings::min_allele_count
size_t min_allele_count
Definition: diversity.hpp:78
genesis::population::BaseCounts::g_count
size_t g_count
Count of all G nucleotides that are present in the sample.
Definition: base_counts.hpp:69
genesis::utils::cubed
constexpr double cubed(double x)
Cube of a number.
Definition: common.hpp:259
genesis::utils::FunctionCache
Simple cache, for example for function return values.
Definition: function_cache.hpp:81
genesis::population::BaseCounts::a_count
size_t a_count
Count of all A nucleotides that are present in the sample.
Definition: base_counts.hpp:59
genesis::population::tajima_d_pool_denominator
double tajima_d_pool_denominator(PoolDiversitySettings const &settings, size_t snp_count, double theta)
Compute the denominator for the pool-sequencing correction of Tajima's D according to Kofler et al.
Definition: diversity.cpp:451
diversity.hpp
genesis::utils
Definition: placement/formats/edge_color.hpp:42
genesis::utils::Matrix< double >
genesis::population::to_string
std::string to_string(GenomeLocus const &locus)
Definition: functions/genome_locus.hpp:48
genesis::population::PoolDiversitySettings::poolsize
size_t poolsize
Definition: diversity.hpp:76
function_cache.hpp
genesis::population::n_base_matrix
double n_base_matrix(size_t coverage, size_t poolsize)
Compute the n_base term used for Tajima's D in Kofler et al. 2011, following their approach.
Definition: diversity.cpp:398
genesis::utils::binomial_distribution
double binomial_distribution(size_t k, size_t n, double p, bool lenient=false)
Compute the probability mass function for a binomial distribution.
Definition: common.hpp:113
genesis::population::pij_matrix_resolver_
genesis::utils::Matrix< double > const & pij_matrix_resolver_(size_t max_coverage, size_t poolsize)
Definition: diversity.cpp:360
genesis::population::theta_watterson_pool_denominator
double theta_watterson_pool_denominator(PoolDiversitySettings const &settings, size_t nucleotide_count)
Compute the denominator for the pool-sequencing correction of theta watterson according to Kofler et ...
Definition: diversity.cpp:186
genesis::population::nucleotide_sum
size_t nucleotide_sum(BaseCounts const &sample)
Count of the pure nucleotide bases at this position, that is, the sum of all A, C,...
Definition: population/functions/functions.hpp:222
matrix.hpp
genesis::population::b_n
double b_n(size_t n)
Compute b_n, the sum of squared reciprocals.
Definition: diversity.cpp:244
genesis::population::n_base
double n_base(size_t coverage, size_t poolsize)
Compute the n_base term used for Tajima's D in Kofler et al. 2011, using a faster closed form express...
Definition: diversity.cpp:432
genesis::population::BaseCounts::c_count
size_t c_count
Count of all C nucleotides that are present in the sample.
Definition: base_counts.hpp:64
genesis
Container namespace for all symbols of genesis in order to keep them separate when used as a library.
Definition: placement/formats/edge_color.cpp:42
genesis::population::BaseCounts
One set of nucleotide base counts, for example for a given sample that represents a pool of sequenced...
Definition: base_counts.hpp:54
genesis::population::beta_star
double beta_star(double n)
Compute beta* according to Achaz 2008 and Kofler et al. 2011.
Definition: diversity.cpp:291
genesis::population::theta_pi_pool_denominator
double theta_pi_pool_denominator(PoolDiversitySettings const &settings, size_t nucleotide_count)
Compute the denominator for the pool-sequencing correction of theta pi according to Kofler et al.
Definition: diversity.cpp:136
genesis::population::PoolDiversitySettings::with_popoolation_bugs
bool with_popoolation_bugs
Definition: diversity.hpp:82
genesis::population::alpha_star
double alpha_star(double n)
Compute alpha* according to Achaz 2008 and Kofler et al. 2011.
Definition: diversity.cpp:263
genesis::utils::squared
constexpr double squared(double x)
Square of a number.
Definition: common.hpp:247
genesis::population::PoolDiversitySettings
Settings used by different pool-sequencing corrected diversity statistics.
Definition: diversity.hpp:74