|
A library for working with phylogenetic and population genetic data.
v0.32.0
|
|
Go to the documentation of this file. 1 #ifndef GENESIS_POPULATION_FUNCTION_DIVERSITY_POOL_FUNCTIONS_H_
2 #define GENESIS_POPULATION_FUNCTION_DIVERSITY_POOL_FUNCTIONS_H_
45 #include <type_traits>
49 namespace population {
177 template<
class ForwardIterator>
179 ForwardIterator begin,
181 bool with_bessel =
true,
182 bool only_passing_samples =
true
185 for(
auto& it = begin; it != end; ++it ) {
186 if( only_passing_samples && !it->status.passing() ) {
202 template<
class ForwardIterator>
205 ForwardIterator begin,
207 bool only_passing_samples =
true
209 auto const psb =
static_cast<double>( poolsize ) / (
static_cast<double>( poolsize ) - 1.0 );
211 for(
auto& it = begin; it != end; ++it ) {
212 if( only_passing_samples && !it->status.passing() ) {
233 DiversityPoolSettings
const& settings,
235 size_t nucleotide_count
249 template<
class ForwardIterator>
253 ForwardIterator begin,
255 bool only_passing_samples =
true
262 for(
auto& it = begin; it != end; ++it ) {
263 if( only_passing_samples && !it->status.passing() ) {
271 if( std::isfinite( pi_snp ) && std::isfinite( denom )) {
272 pi_sum += ( pi_snp / denom );
311 DiversityPoolSettings
const& settings,
313 size_t nucleotide_count
322 template<
class ForwardIterator>
326 ForwardIterator begin,
328 bool only_passing_samples =
true
335 for(
auto& it = begin; it != end; ++it ) {
336 if( only_passing_samples && !it->status.passing() ) {
343 if( std::isfinite( denom )) {
391 double a_n(
double n );
416 double b_n(
double n );
510 double n_base(
size_t read_depth,
size_t poolsize );
539 DiversityPoolSettings
const& settings,
542 double window_avg_denom,
543 size_t empirical_min_read_depth
556 double theta_watterson,
558 double window_avg_denom,
559 size_t empirical_min_read_depth
570 settings, theta_watterson, poolsize, window_avg_denom, empirical_min_read_depth
572 return (
theta_pi - theta_watterson ) / denom;
584 template<
class ForwardIterator>
588 double theta_watterson,
590 ForwardIterator begin,
592 bool only_passing_samples =
true
596 size_t empirical_min_read_depth = std::numeric_limits<size_t>::max();
597 auto entry_count = std::distance( begin, end );
599 only_passing_samples ||
603 for(
auto& it = begin; it != end; ++it ) {
604 if( only_passing_samples && !it->status.passing() ) {
609 if( cov < empirical_min_read_depth ) {
610 empirical_min_read_depth = cov;
617 settings,
theta_pi, theta_watterson, poolsize, entry_count, empirical_min_read_depth
631 template<
class ForwardIterator>
635 ForwardIterator begin,
637 bool only_passing_samples =
true
640 auto const pi =
theta_pi_pool( settings, poolsize, begin, end, only_passing_samples );
642 return tajima_d_pool( settings, pi, tw, poolsize, begin, end, only_passing_samples );
648 #endif // include guard
TajimaDenominatorPolicy tajima_denominator_policy
double sum(const Histogram &h)
One set of nucleotide sample counts, for example for a given sample that represents a pool of sequenc...
double theta_watterson_pool_denominator(DiversityPoolSettings const &settings, size_t poolsize, size_t nucleotide_count)
Compute the denominator for the pool-sequencing correction of theta watterson according to Kofler et ...
double f_star(double a_n, double n)
Compute f* according to Achaz 2008 and Kofler et al. 2011.
double theta_pi_pool_denominator(DiversityPoolSettings const &settings, size_t poolsize, size_t nucleotide_count)
Compute the denominator for the pool-sequencing correction of theta pi according to Kofler et al.
constexpr size_t nucleotide_sum(SampleCounts const &sample)
Count of the pure nucleotide bases at this position, that is, the sum of all A, C,...
@ kPoolsize
Instead of using n_base() to obtain the number of individuals sequenced (empirical pool size),...
@ kUncorrected
Do not correct Tajima's D at all.
double n_base(size_t read_depth, size_t poolsize)
Compute the n_base term used for Tajima's D in Kofler et al. 2011, using a faster closed form express...
@ kEmpiricalMinReadDepth
Use the empirical minimum read depth found in each window to compute the expected number of individua...
Container namespace for all symbols of genesis in order to keep them separate when used as a library.
double b_n(double n)
Compute b_n, the sum of squared reciprocals.
double n_base_matrix(size_t read_depth, size_t poolsize)
Compute the n_base term used for Tajima's D in Kofler et al. 2011, following their approach.
double theta_pi_pool(DiversityPoolSettings const &settings, size_t poolsize, ForwardIterator begin, ForwardIterator end, bool only_passing_samples=true)
Compute theta pi with pool-sequencing correction according to Kofler et al, that is,...
TajimaDenominatorPolicy
Select how to compute the denominator for the pool sequencing correction of Tajima's D.
double beta_star(double n)
Compute beta* according to Achaz 2008 and Kofler et al. 2011.
double theta_watterson_pool(DiversityPoolSettings const &settings, size_t poolsize, ForwardIterator begin, ForwardIterator end, bool only_passing_samples=true)
Compute theta watterson with pool-sequencing correction according to Kofler et al.
double a_n(double n)
Compute a_n, the sum of reciprocals.
double theta_pi(ForwardIterator begin, ForwardIterator end, bool with_bessel=true, bool only_passing_samples=true)
Compute classic theta pi, that is, the sum of heterozygosities.
@ kWithPopoolationBugs
Replicate the original behaviour of PoPoolation <= 1.2.2.
double alpha_star(double n)
Compute alpha* according to Achaz 2008 and Kofler et al. 2011.
@ kProvidedMinReadDepth
Fix the bugs of the original PoPoolation, but still use their way of computing the empirical pool siz...
double tajima_d_pool_denominator(DiversityPoolSettings const &settings, double theta, size_t poolsize, double window_avg_denom, size_t empirical_min_read_depth)
Compute the denominator for the pool-sequencing correction of Tajima's D according to Kofler et al.
Settings used by different pool-sequencing corrected diversity statistics.
double theta_pi_within_pool(size_t poolsize, ForwardIterator begin, ForwardIterator end, bool only_passing_samples=true)
Compute classic theta pi (within a population), that is, the sum of heterozygosities including Bessel...
double tajima_d_pool(DiversityPoolSettings const &settings, double theta_pi, double theta_watterson, size_t poolsize, double window_avg_denom, size_t empirical_min_read_depth)
Compute the pool-sequencing corrected version of Tajima's D according to Kofler et al.
double heterozygosity(SampleCounts const &sample, bool with_bessel)
Compute classic heterozygosity.