NAME
Bio::PopGen::Statistics - Population Genetics statistical tests
SYNOPSIS
use Bio::PopGen::Statistics;use Bio::AlignIO;use Bio::PopGen::IO;use Bio::PopGen::Simulation::Coalescent;my $sim = Bio::PopGen::Simulation::Coalescent->new( -sample_size => 12);my $tree = $sim->next_tree;$sim->add_Mutations($tree,20);my $stats = Bio::PopGen::Statistics->new();my $individuals = [ $tree->get_leaf_nodes];my $pi = $stats->pi($individuals);my $D = $stats->tajima_D($individuals);# Alternatively to do this on input data from# See the tests in t/PopGen.t for more examplesmy $parser = Bio::PopGen::IO->new(-format => 'prettybase',-file => 't/data/popstats.prettybase');my $pop = $parser->next_population;# Note that you can also call the stats as a class method if you like# the only reason to instantiate it (as above) is if you want# to set the verbosity for debugging$pi = Bio::PopGen::Statistics->pi($pop);$theta = Bio::PopGen::Statistics->theta($pop);# Pi and Theta also take additional arguments,# see the documentation for more informationuse Bio::PopGen::Utilities;use Bio::AlignIO;my $in = Bio::AlignIO->new(-file => 't/data/t7.aln',-format => 'clustalw');my $aln = $in->next_aln;# get a population, each sequence is an individual and# for the default case, every site which is not monomorphic# is a 'marker'. Each individual will have a 'genotype' for the# site which will be the specific base in the alignment at that# sitemy $pop = Bio::PopGen::Utilities->aln_to_population(-alignment => $aln);
DESCRIPTION
This object is intended to provide implementations some standard population genetics statistics about alleles in populations.
This module was previously named Bio::Tree::Statistics.
This object is a place to accumulate routines for calculating various statistics from the coalescent simulation, marker/allele, or from aligned sequence data given that you can calculate alleles, number of segregating sites.
Currently implemented:
Fu and Li's D (fu_and_li_D)
Fu and Li's D* (fu_and_li_D_star)
Fu and Li's F (fu_and_li_F)
Fu and Li's F* (fu_and_li_F_star)
Tajima's D (tajima_D)
Watterson's theta (theta)
pi (pi) - number of pairwise differences
composite_LD (composite_LD)
McDonald-Kreitman (mcdonald_kreitman or MK)
Count based methods also exist in case you have already calculated the key statistics (seg sites, num individuals, etc) and just want to compute the statistic.
In all cases where a the method expects an arrayref of Bio::PopGen::IndividualI objects and Bio::PopGen::PopulationI object will also work.
REFERENCES
Fu Y.X and Li W.H. (1993) "Statistical Tests of Neutrality of Mutations." Genetics 133:693-709.
Fu Y.X. (1996) "New Statistical Tests of Neutrality for DNA samples from a Population." Genetics 143:557-570.
McDonald J, Kreitman M.
Tajima F. (1989) "Statistical method for testing the neutral mutation hypothesis by DNA polymorphism." Genetics 123:585-595.
CITING THIS WORK
Please see this reference for use of this implementation.
Stajich JE and Hahn MW "Disentangling the Effects of Demography and Selection in Human History." (2005) Mol Biol Evol 22(1):63-73.
If you use these Bio::PopGen modules please cite the Bioperl publication (see FAQ) and the above reference.
FEEDBACK
Mailing Lists
User feedback is an integral part of the evolution of this and other Bioperl modules. Send your comments and suggestions preferably to the Bioperl mailing list. Your participation is much appreciated.
[email protected] - General discussionhttp://bioperl.org/wiki/Mailing_lists - About the mailing lists
Support
Please direct usage questions or support issues to the mailing list:
rather than to the module maintainer directly. Many experienced and reponsive experts will be able look at the problem and quickly address it. Please include a thorough description of the problem with code and data examples if at all possible.
Reporting Bugs
Report bugs to the Bioperl bug tracking system to help us keep track of the bugs and their resolution. Bug reports can be submitted via the web:
https://github.com/bioperl/bioperl-live/issues
AUTHOR - Jason Stajich, Matthew Hahn
Email jason-at-bioperl-dot-org Email matthew-dot-hahn-at-duke-dot-edu
McDonald-Kreitman implementation based on work by Alisha Holloway at UC Davis.
APPENDIX
The rest of the documentation details each of the object methods. Internal methods are usually preceded with a _
new
Title : newUsage : my $obj = Bio::PopGen::Statistics->new();Function: Builds a new Bio::PopGen::Statistics objectReturns : an instance of Bio::PopGen::StatisticsArgs : none
fu_and_li_D
Title : fu_and_li_DUsage : my $D = $statistics->fu_and_li_D(\@ingroup,\@outgroup);ORmy $D = $statistics->fu_and_li_D(\@ingroup,$extmutations);Function: Fu and Li D statistic for a list of individualsgiven an outgroup and the number of external mutations(either provided or calculated from list of outgroup individuals)Returns : decimalArgs : $individuals - array reference which contains ingroup individuals(L<Bio::PopGen::Individual> or derived classes)$extmutations - number of external mutations ORarrayref of outgroup individuals
fu_and_li_D_counts
Title : fu_li_D_countsUsage : my $D = $statistics->fu_and_li_D_counts($samps,$sites,$external);Function: Fu and Li D statistic for the raw counts of the numberof samples, sites, external and internal mutationsReturns : decimal numberArgs : number of samples (N)number of segregating sites (n)number of external mutations (n_e)
fu_and_li_D_star
Title : fu_and_li_D_starUsage : my $D = $statistics->fu_an_li_D_star(\@individuals);Function: Fu and Li's D* statistic for a set of samplesWithout an outgroupReturns : decimal numberArgs : array ref of L<Bio::PopGen::IndividualI> objectsORL<Bio::PopGen::PopulationI> object
fu_and_li_D_star_counts
Title : fu_li_D_star_countsUsage : my $D = $statistics->fu_and_li_D_star_counts($samps,$sites,$singletons);Function: Fu and Li D statistic for the raw counts of the numberof samples, sites, external and internal mutationsReturns : decimal numberArgs : number of samples (N)number of segregating sites (n)singletons (n_s)
fu_and_li_F
Title : fu_and_li_FUsage : my $F = Bio::PopGen::Statistics->fu_and_li_F(\@ingroup,$ext_muts);Function: Calculate Fu and Li's F on an ingroup with either the set ofoutgroup individuals, or the number of external mutationsReturns : decimal numberArgs : array ref of L<Bio::PopGen::IndividualI> objects for the ingroupOR a L<Bio::PopGen::PopulationI> objectnumber of external mutations OR list of individuals for the outgroup
fu_and_li_F_counts
Title : fu_li_F_countsUsage : my $F = $statistics->fu_and_li_F_counts($samps,$pi,$sites,$external);Function: Fu and Li F statistic for the raw counts of the numberof samples, sites, external and internal mutationsReturns : decimal numberArgs : number of samples (N)average pairwise differences (pi)number of segregating sites (n)external mutations (n_e)
fu_and_li_F_star
Title : fu_and_li_F_starUsage : my $F = Bio::PopGen::Statistics->fu_and_li_F_star(\@ingroup);Function: Calculate Fu and Li's F* on an ingroup without an outgroupIt uses count of singleton alleles insteadReturns : decimal numberArgs : array ref of L<Bio::PopGen::IndividualI> objects for the ingroupORL<Bio::PopGen::PopulationI> object
fu_and_li_F_star_counts
Title : fu_li_F_star_countsUsage : my $F = $statistics->fu_and_li_F_star_counts($samps,$pi,$sites,$singletons);Function: Fu and Li F statistic for the raw counts of the numberof samples, sites, external and internal mutationsReturns : decimal numberArgs : number of samples (N)average pairwise differences (pi)number of segregating sites (n)singleton mutations (n_s)
tajima_D
Title : tajima_DUsage : my $D = Bio::PopGen::Statistics->tajima_D(\@samples);Function: Calculate Tajima's D on a set of samplesReturns : decimal numberArgs : array ref of L<Bio::PopGen::IndividualI> objectsORL<Bio::PopGen::PopulationI> object
tajima_D_counts
Title : tajima_D_countsUsage : my $D = $statistics->tajima_D_counts($samps,$sites,$pi);Function: Tajima's D statistic for the raw counts of the numberof samples, sites, and avg pairwise distances (pi)Returns : decimal numberArgs : number of samples (N)number of segregating sites (n)average pairwise differences (pi)
pi
Title : piUsage : my $pi = Bio::PopGen::Statistics->pi(\@inds)Function: Calculate pi (average number of pairwise differences) givena list of individuals which have the same number of markers(also called sites) as available from the get_Genotypes()call in L<Bio::PopGen::IndividualI>Returns : decimal numberArgs : Arg1= array ref of L<Bio::PopGen::IndividualI> objectswhich have markers/mutations. We expect all individuals tohave a marker - we will deal with missing data as a special case.ORArg1= L<Bio::PopGen::PopulationI> object. In the event thatonly allele frequency data is available, storing it inPopulation object will make this available.num sites [optional], an optional second argument (integer)which is the number of sites, then pi returned is pi/site.
theta
Title : thetaUsage : my $theta = Bio::PopGen::Statistics->theta($sampsize,$segsites);Function: Calculates Watterson's theta from the sample sizeand the number of segregating sites.Providing the third parameter, total number of sites willreturn theta per site.This is also known as K-hat = K / a_nReturns : decimal numberArgs : sample size (integer),num segregating sites (integer)total sites (integer) [optional] (to calculate theta per site)ORprovide an arrayref of the L<Bio::PopGen::IndividualI> objectstotal sites (integer) [optional] (to calculate theta per site)ORprovide an L<Bio::PopGen::PopulationI> objecttotal sites (integer)[optional]
singleton_count
Title : singleton_countUsage : my ($singletons) = Bio::PopGen::Statistics->singleton_count(\@inds)Function: Calculate the number of mutations/alleles which only occur once ina list of individuals for all sites/markersReturns : (integer) number of alleles which only occur once (integer)Args : arrayref of L<Bio::PopGen::IndividualI> objectsORL<Bio::PopGen::PopulationI> object
segregating_sites_count
Title : segregating_sites_countUsage : my $segsites = Bio::PopGen::Statistics->segregating_sites_countFunction: Gets the number of segregating sites (number of polymorphic sites)Returns : (integer) number of segregating sitesArgs : arrayref of L<Bio::PopGen::IndividualI> objectsORL<Bio::PopGen::PopulationI> object
heterozygosity
Title : heterozygosityUsage : my $het = Bio::PopGen::Statistics->heterozygosity($sampsize,$freq1);Function: Calculate the heterozgosity for a sample set for a set of allelesReturns : decimal numberArgs : sample size (integer)frequency of one allele (fraction - must be less than 1)[optional] frequency of another allele - this is only neededin a non-binary allele system
Note : p^2 + 2pq + q^2
derived_mutations
Title : derived_mutationsUsage : my $ext = Bio::PopGen::Statistics->derived_mutations($ingroup,$outgroup);Function: Calculate the number of alleles or (mutations) which are ancestraland the number which are derived (occurred only on the tips)Returns : array of 2 items - number of external and internal derivedmutationArgs : ingroup - L<Bio::PopGen::IndividualI>s arrayref ORL<Bio::PopGen::PopulationI>outgroup- L<Bio::PopGen::IndividualI>s arrayref ORL<Bio::PopGen::PopulationI> ORa single L<Bio::PopGen::IndividualI>
composite_LD
Title : composite_LDUsage : %matrix = Bio::PopGen::Statistics->composite_LD($population);Function: Calculate the Linkage DisequilibriumThis is for calculating LD for unphased data.Other methods will be appropriate for phased haplotype data.Returns : Hash of Hashes - first key is site 1,second key is site 2and value is LD for those two sites.my $LDarrayref = $matrix{$site1}->{$site2};my ($ldval, $chisquared) = @$LDarrayref;Args : L<Bio::PopGen::PopulationI> or arrayref ofL<Bio::PopGen::IndividualI>sReference: Weir B.S. (1996) "Genetic Data Analysis II",Sinauer, Sunderlanm MA.
mcdonald_kreitman
Title : mcdonald_kreitmanUsage : $Fstat = mcdonald_kreitman($ingroup, $outgroup);Function: Calculates McDonald-Kreitman statistic based on a set of ingroupindividuals and an outgroup by computing the number ofdifferences at synonymous and non-synonymous sitesfor intraspecific comparisons and with the outgroupReturns : 2x2 table, followed by a hash reference indicating anywarning messages about the status of the alleles or codonsArgs : -ingroup => L<Bio::PopGen::Population> object orarrayref of L<Bio::PopGen::Individual>s-outgroup => L<Bio::PopGen::Population> object orarrayef of L<Bio::PopGen::Individual>s-polarized => Boolean, to indicate if this should bea polarized test. Must provide two individualsas outgroups.
mcdonald_kreitman_counts
Title : mcdonald_kreitman_countsUsage : my $MK = $statistics->mcdonald_kreitman_counts(N_poly -> integer of count of non-syn polymorphismN_fix -> integer of count of non-syn fixed substitutionsS_poly -> integer of count of syn polymorphismS_fix -> integer of count of syn fixed substitutions);Function:Returns : decimal numberArgs :