bpp-popgen  2.1.0
bpp::SequenceStatistics Class Reference

Static class providing methods to compute statistics on sequences data. More...

#include <Bpp/PopGen/SequenceStatistics.h>

List of all members.

Public Member Functions

double FstHudson92 (const PolymorphismSequenceContainer &psc, size_t id1, size_t id2)

Static Public Member Functions

static size_t polymorphicSiteNumber (const PolymorphismSequenceContainer &psc, bool gapflag=true, bool ignoreUnknown=true)
 Compute the number of polymorphic site in an alignment.
static size_t parsimonyInformativeSiteNumber (const PolymorphismSequenceContainer &psc, bool gapflag=true)
 Compute the number of parsimony informative sites in an alignment.
static size_t countSingleton (const PolymorphismSequenceContainer &psc, bool gapflag=true)
 Count the number of singleton nucleotides in an alignment.
static size_t totNumberMutations (const PolymorphismSequenceContainer &psc, bool gapflag=true)
 Count the total number of mutations in an alignment.
static size_t totMutationsExternalBranchs (const PolymorphismSequenceContainer &ing, const PolymorphismSequenceContainer &outg) throw (Exception)
 Count the total number of mutations in external branchs.
static size_t tripletNumber (const PolymorphismSequenceContainer &psc, bool gapflag=true)
 Compute the number of triplet in an alignment.
static double heterozygosity (const PolymorphismSequenceContainer &psc, bool gapflag=true)
 Compute the sum of per site heterozygosity in an alignment.
static double squaredHeterozygosity (const PolymorphismSequenceContainer &psc, bool gapflag=true)
 Compute the sum of per site squared heterozygosity in an alignment.
static double gcContent (const PolymorphismSequenceContainer &psc)
 Compute the mean GC content in an alignment.
static std::vector< size_t > gcPolymorphism (const PolymorphismSequenceContainer &psc, bool gapflag=true)
 Return the number of GC alleles and the total number of alleles at polymorphic sites only.
static double watterson75 (const PolymorphismSequenceContainer &psc, bool gapflag=true, bool ignoreUnknown=true)
 Compute diversity estimator Theta of Watterson (1975, Theor Popul Biol, 7 pp256-276)
static double tajima83 (const PolymorphismSequenceContainer &psc, bool gapflag=true)
 Compute diversity estimator Theta of Tajima (1983, Genetics, 105 pp437-460)
static double FayWu2000 (const PolymorphismSequenceContainer &psc, const Sequence &ancestralSites)
 Compute diversity estimator Theta H (eq. 3) of Fay and Wu (2000, Genetics, 155: 1405-1413)
static size_t DVK (const PolymorphismSequenceContainer &psc, bool gapflag=true)
 Return the number of haplotype in the sample. Depaulis and Veuille (1998, Mol Biol Evol, 12 pp1788-1790)
static double DVH (const PolymorphismSequenceContainer &psc, bool gapflag=true)
 Return the haplotype diversity of a sample. Depaulis and Veuille (1998, Mol Biol Evol, 12 pp1788-1790)
static size_t getNumberOfTransitions (const PolymorphismSequenceContainer &psc)
 Return the number of transitions.
static size_t getNumberOfTransversions (const PolymorphismSequenceContainer &psc)
 Return the number of transversions.
static double getTransitionsTransversionsRatio (const PolymorphismSequenceContainer &psc) throw (Exception)
 Return the ratio of transitions/transversions.
static size_t stopCodonSiteNumber (const PolymorphismSequenceContainer &psc, const GeneticCode &gCode, bool gapflag=true)
 Compute the number of codon sites with stop codon.
static size_t monoSitePolymorphicCodonNumber (const PolymorphismSequenceContainer &psc, bool stopflag=true, bool gapflag=true)
 Compute the number of polymorphic codon with only one mutated site.
static size_t synonymousPolymorphicCodonNumber (const PolymorphismSequenceContainer &psc, const GeneticCode &gc)
 Compute the number of synonymous polymorphic codon sites.
static double watterson75Synonymous (const PolymorphismSequenceContainer &psc, const GeneticCode &gc)
 Compute the Watterson(1975,Theor Popul Biol, 7 pp256-276) estimator for synonymous positions.
static double watterson75NonSynonymous (const PolymorphismSequenceContainer &psc, const GeneticCode &gc)
 Compute the Watterson(1975, Theor Popul Biol, 7 pp256-276) estimator for non synonymous positions.
static double piSynonymous (const PolymorphismSequenceContainer &psc, const GeneticCode &gc, bool minchange=false)
 Compute the synonymous nucleotide diversity, pi.
static double piNonSynonymous (const PolymorphismSequenceContainer &psc, const GeneticCode &gc, bool minchange=false)
 Compute the non-synonymous nucleotide diversity, pi.
static double meanSynonymousSitesNumber (const PolymorphismSequenceContainer &psc, const GeneticCode &gc, double ratio=1.)
 compute the mean number of synonymous site in an alignment
static double meanNonSynonymousSitesNumber (const PolymorphismSequenceContainer &psc, const GeneticCode &gc, double ratio=1.)
 compute the mean number of non-synonymous site in an alignment
static size_t synonymousSubstitutionsNumber (const PolymorphismSequenceContainer &psc, const GeneticCode &gc, double freqmin=0.)
 compute the number of synonymous subsitutions in an alignment
static size_t nonSynonymousSubstitutionsNumber (const PolymorphismSequenceContainer &psc, const GeneticCode &gc, double freqmin=0.)
 compute the number of non synonymous subsitutions in an alignment
static std::vector< size_t > fixedDifferences (const PolymorphismSequenceContainer &pscin, const PolymorphismSequenceContainer &pscout, PolymorphismSequenceContainer &psccons, const GeneticCode &gc)
 compute the number of fixed differences between two alignements
static std::vector< size_t > MKtable (const PolymorphismSequenceContainer &ingroup, const PolymorphismSequenceContainer &outgroup, const GeneticCode &gc, double freqmin=0.)
 return a vector containing Pa, Ps, Da, Ds
static double neutralityIndex (const PolymorphismSequenceContainer &ingroup, const PolymorphismSequenceContainer &outgroup, const GeneticCode &gc, double freqmin=0.)
 return the neutrality index NI = (Pa/Ps)/(Da/Ds) (Rand & Kann 1996, Mol. Biol. Evol. 13 pp735-748)
static double tajimaDSS (const PolymorphismSequenceContainer &psc, bool gapflag=true) throw (ZeroDivisionException)
 Return the Tajima's D test (Tajima 1989, Genetics 123 pp 585-595).
static double tajimaDTNM (const PolymorphismSequenceContainer &psc, bool gapflag=true) throw (ZeroDivisionException)
 Return the Tajima's D test (Tajima 1989, Genetics 123 pp 585-595).
static double fuliD (const PolymorphismSequenceContainer &ingroup, const PolymorphismSequenceContainer &outgroup, bool original=true) throw (ZeroDivisionException)
 Return the Fu and Li D test (Fu & Li 1993, Genetics, 133 pp693-709).
static double fuliDstar (const PolymorphismSequenceContainer &group) throw (ZeroDivisionException)
 Return the Fu and Li D* test (Fu & Li 1993, Genetics, 133 pp693-709).
static double fuliF (const PolymorphismSequenceContainer &ingroup, const PolymorphismSequenceContainer &outgroup, bool original=true) throw (ZeroDivisionException)
 Return the Fu and Li F test (Fu & Li 1993, Genetics, 133 pp693-709).
static double fuliFstar (const PolymorphismSequenceContainer &group) throw (ZeroDivisionException)
 Return the Fu and Li F* test (Fu & Li 1993, Genetics, 133 pp693-709).
static
PolymorphismSequenceContainer
generateLDContainer (const PolymorphismSequenceContainer &psc, bool keepsingleton=true, double freqmin=0.)
 generate a special PolymorphismSequenceContainer for linkage disequilbrium analysis
static Vdouble pairwiseDistances1 (const PolymorphismSequenceContainer &psc, bool keepsingleton=true, double freqmin=0.) throw (DimensionException)
 give the vector of the pairwise distances between site positions corresponding to a LD SequencePolymorphismContainer
static Vdouble pairwiseDistances2 (const PolymorphismSequenceContainer &psc, bool keepsingleton=true, double freqmin=0.) throw (DimensionException)
 give the vector of all mean pairwise distance between two sites to a LD SequencePolymorphismContainer
static Vdouble pairwiseD (const PolymorphismSequenceContainer &psc, bool keepsingleton=true, double freqmin=0.) throw (DimensionException)
 give the vector of all mean pairwise D value between two sites (Lewontin & Kojima 1964, Evolution 14 pp458-472)
static Vdouble pairwiseDprime (const PolymorphismSequenceContainer &psc, bool keepsingleton=true, double freqmin=0.) throw (DimensionException)
 give the vector of all mean pairwise D' value between two sites (Lewontin 1964, Genetics 49 pp49-67))
static Vdouble pairwiseR2 (const PolymorphismSequenceContainer &psc, bool keepsingleton=true, double freqmin=0.) throw (DimensionException)
 give the vector of all mean pairwise R² value between two sites (Hill & Robertson 1968, Theor. Appl. Genet., 38 pp226-231)
static double meanD (const PolymorphismSequenceContainer &psc, bool keepsingleton=true, double freqmin=0.) throw (DimensionException)
 give mean D over all pairwise comparisons
static double meanDprime (const PolymorphismSequenceContainer &psc, bool keepsingleton=true, double freqmin=0.) throw (DimensionException)
 give mean D' over all pairwise comparisons
static double meanR2 (const PolymorphismSequenceContainer &psc, bool keepsingleton=true, double freqmin=0.) throw (DimensionException)
 give mean R² over all pairwise comparisons
static double meanDistance1 (const PolymorphismSequenceContainer &psc, bool keepsingleton=true, double freqmin=0.) throw (DimensionException)
 give mean pairwise distances between sites / method 1: differences between sequences are not taken into account
static double meanDistance2 (const PolymorphismSequenceContainer &psc, bool keepsingleton=true, double freqmin=0.) throw (DimensionException)
 give mean pairwise distances between sites / method 2: differences between sequences are taken into account
static double originRegressionD (const PolymorphismSequenceContainer &psc, bool distance1=false, bool keepsingleton=true, double freqmin=0.) throw (DimensionException)
 give the slope of the regression |D| = 1+a*distance
static double originRegressionDprime (const PolymorphismSequenceContainer &psc, bool distance1=false, bool keepsingleton=true, double freqmin=0.) throw (DimensionException)
 give the slope of the regression |D'| = 1+a*distance
static double originRegressionR2 (const PolymorphismSequenceContainer &psc, bool distance1=false, bool keepsingleton=true, double freqmin=0.) throw (DimensionException)
 give the slope of the regression R² = 1+a*distance
static Vdouble linearRegressionD (const PolymorphismSequenceContainer &psc, bool distance1=false, bool keepsingleton=true, double freqmin=0.) throw (DimensionException)
 give the slope and the origin of the regression |D| = a*distance+b
static Vdouble linearRegressionDprime (const PolymorphismSequenceContainer &psc, bool distance1=false, bool keepsingleton=true, double freqmin=0.) throw (DimensionException)
 give the slope and the origin of the regression |D'| = a*distance+b
static Vdouble linearRegressionR2 (const PolymorphismSequenceContainer &psc, bool distance1=false, bool keepsingleton=true, double freqmin=0.) throw (DimensionException)
 give the slope and the origin of the regression R² = a*distance+b
static double inverseRegressionR2 (const PolymorphismSequenceContainer &psc, bool distance1=false, bool keepsingleton=true, double freqmin=0.) throw (DimensionException)
 give the slope of the regression R² = 1/(1+a*distance)
static double hudson87 (const PolymorphismSequenceContainer &psc, double precision=0.000001, double cinf=0.001, double csup=10000.)
 give estimate of C=4Nr using Hudson method (Hudson 1987, Genet. Res., 50 pp245-250)
static void testUsefullValues (std::ostream &s, size_t n)
 Test usefull values.

Static Private Member Functions

static size_t getMutationNumber_ (const Site &site)
 Count the number of mutation for a site.
static size_t getSingletonNumber_ (const Site &site)
 Count the number of singleton for a site.
static size_t getDerivedSingletonNumber_ (const Site &site_in, const Site &site_out)
 Count the number of singleton for a site.
static std::map< std::string,
double > 
getUsefullValues_ (size_t n)
 Get usefull values for theta estimators.
static double getVD_ (size_t n, double a1, double a2, double cn)
 Get the vD value of equation (32) in Fu & Li 1993, Genetics, 133 pp693-709)
static double getUD_ (double a1, double vD)
 Get the uD value of equation (32) in Fu & Li 1993, Genetics, 133 pp693-709)
static double getVDstar_ (size_t n, double a1, double a2, double dn)
 Get the vD* value of D* equation in Fu & Li 1993, Genetics, 133 pp693-709)
static double getUDstar_ (size_t n, double a1, double vDs)
 Get the uD* value of D* equation in Fu & Li 1993, Genetics, 133 pp693-709)
static double leftHandHudson_ (const PolymorphismSequenceContainer &psc)
 give the left hand term of equation (4) in Hudson (Hudson 1987, Genet. Res., 50 pp245-250) This term is used in hudson87
static double rightHandHudson_ (double c, size_t n)
 give the right hand term of equation (4) in Hudson (Hudson 1987, Genet. Res., 50 pp245-250) This term is used in hudson87

Detailed Description

Static class providing methods to compute statistics on sequences data.

Author:
Sylvain Gaillard

Definition at line 69 of file SequenceStatistics.h.


Member Function Documentation

size_t SequenceStatistics::countSingleton ( const PolymorphismSequenceContainer psc,
bool  gapflag = true 
) [static]

Count the number of singleton nucleotides in an alignment.

Parameters:
psca PolymorphismSequenceContainer
gapflaga boolean set by default to true if you don't want to take gap into account
Author:
Sylvain Gaillard

Definition at line 114 of file SequenceStatistics.cpp.

References bpp::ConstSiteIterator::hasMoreSites(), and bpp::ConstSiteIterator::nextSite().

double SequenceStatistics::DVH ( const PolymorphismSequenceContainer psc,
bool  gapflag = true 
) [static]

Return the haplotype diversity of a sample. Depaulis and Veuille (1998, Mol Biol Evol, 12 pp1788-1790)

Parameters:
psca PolymorphismSequenceContainer
gapflagflag set by default to true if you don't want to take gaps into account
Author:
Éric Bazin
Todo:

Definition at line 426 of file SequenceStatistics.cpp.

References bpp::VectorSiteContainer::getNumberOfSequences(), bpp::PolymorphismSequenceContainer::getSequenceCount(), and bpp::VectorSiteContainer::toString().

size_t SequenceStatistics::DVK ( const PolymorphismSequenceContainer psc,
bool  gapflag = true 
) [static]

Return the number of haplotype in the sample. Depaulis and Veuille (1998, Mol Biol Evol, 12 pp1788-1790)

Parameters:
psca PolymorphismSequenceContainer
gapflagflag set by default to true if you don't want to take gap into account
Author:
Éric Bazin
Todo:

Definition at line 387 of file SequenceStatistics.cpp.

References bpp::VectorSiteContainer::getNumberOfSequences(), and bpp::VectorSiteContainer::toString().

double SequenceStatistics::FayWu2000 ( const PolymorphismSequenceContainer psc,
const Sequence ancestralSites 
) [static]

Compute diversity estimator Theta H (eq. 3) of Fay and Wu (2000, Genetics, 155: 1405-1413)

Parameters:
psca PolymorphismSequenceContainer
ancestralSitesa Sequence containing the ancestral states (reconstructed independently) to fold the mutation in the psc SequenceContainer.
Author:
Benoit Nabholz

Definition at line 340 of file SequenceStatistics.cpp.

References bpp::VectorSiteContainer::getAlphabet(), bpp::Sequence::getChar(), bpp::VectorSiteContainer::getNumberOfSites(), bpp::VectorSiteContainer::getSequence(), bpp::VectorSiteContainer::getSite(), bpp::Sequence::getValue(), and bpp::Sequence::size().

vector< size_t > SequenceStatistics::fixedDifferences ( const PolymorphismSequenceContainer pscin,
const PolymorphismSequenceContainer pscout,
PolymorphismSequenceContainer psccons,
const GeneticCode gc 
) [static]

compute the number of fixed differences between two alignements

Gaps and unresolved sites are automatically excluded

In case of complex codon, the path that gives the minimum number of non-synonymous changes is chosen. The argument minchange=true is sent to numberOfSynonymousDifferences used in this method. Otherwise, a non-integer number could be return.

Parameters:
pscina PolymorphismSequenceContainer
pscouta PolymorphismSequenceContainer
pscconsa PolymorphismSequenceContainer
gca GeneticCode
Author:
Sylvain Glémin

Definition at line 751 of file SequenceStatistics.cpp.

References bpp::Site::getValue(), bpp::ConstSiteIterator::hasMoreSites(), and bpp::ConstSiteIterator::nextSite().

double SequenceStatistics::FstHudson92 ( const PolymorphismSequenceContainer psc,
size_t  id1,
size_t  id2 
)

Fst of Hudson, Slatkin and Maddison

Taken from eq. 3 of Hudson, Slatkin and Maddison 1992 Genetics 132:153

\[ F_{st} = 1 - \frac{H_w}{H_b} \]

where $H_w$ is mean number of differences between different sequences sampled from the same subpopulation, and $H_b$ is the mean number of differences between sequences sampled from the two different subpopulations sampled.

Parameters:
psca PolymorphismSequenceContainer will at least two populations
id1is the id of the population 1
id2is the id of the population 2
Author:
Benoit Nabholz

Definition at line 944 of file SequenceStatistics.cpp.

References bpp::VectorSiteContainer::getNumberOfSequences(), bpp::VectorSiteContainer::getNumberOfSites(), and bpp::VectorSiteContainer::getSequence().

double SequenceStatistics::fuliD ( const PolymorphismSequenceContainer ingroup,
const PolymorphismSequenceContainer outgroup,
bool  original = true 
) throw (ZeroDivisionException) [static]

Return the Fu and Li D test (Fu & Li 1993, Genetics, 133 pp693-709).

Parameters:
ingroupa PolymorphismSequenceContainer
outgroupa PolymorphismSequenceContainer
originaltrue: use the Fu & Li methode, false: use mutations in external branch.
Exceptions:
ZeroDivisionExceptionif eta == 0
Author:
Sylvain Gaillard
Khalid Belkhir

If one set original=false then the number of mutations will be used. If the outgroup contains more than one sequence the sites with more than one variant will not be considered for external branch mutations!

Definition at line 864 of file SequenceStatistics.cpp.

Return the Fu and Li D* test (Fu & Li 1993, Genetics, 133 pp693-709).

Parameters:
groupa PolymorphismSequenceContainer
Author:
Sylvain Gaillard

Definition at line 881 of file SequenceStatistics.cpp.

double SequenceStatistics::fuliF ( const PolymorphismSequenceContainer ingroup,
const PolymorphismSequenceContainer outgroup,
bool  original = true 
) throw (ZeroDivisionException) [static]

Return the Fu and Li F test (Fu & Li 1993, Genetics, 133 pp693-709).

Parameters:
ingroupa PolymorphismSequenceContainer
outgroupa PolymorphismSequenceContainer
originaltrue: use the Fu & Li methode, false: use mutations in external branch.
Author:
Sylvain Gaillard
Khalid Belkhir

If one set original=false then the number of mutations will be used. If the outgroup contains more than one sequence the sites with more than one variant will not be considered for external branch mutations!

Definition at line 903 of file SequenceStatistics.cpp.

Return the Fu and Li F* test (Fu & Li 1993, Genetics, 133 pp693-709).

Parameters:
groupa PolymorphismSequenceContainer
Author:
Sylvain Gaillard

Definition at line 922 of file SequenceStatistics.cpp.

Compute the mean GC content in an alignment.

Parameters:
psca PolymorphismSequenceContainer

Definition at line 239 of file SequenceStatistics.cpp.

References bpp::Alphabet::charToInt(), and bpp::VectorSiteContainer::getAlphabet().

std::vector< size_t > SequenceStatistics::gcPolymorphism ( const PolymorphismSequenceContainer psc,
bool  gapflag = true 
) [static]

Return the number of GC alleles and the total number of alleles at polymorphic sites only.

G vs C and A vs T polymorphism are not taken into account

Warning:
SG 15/03/2010: The code of this method is not clear. See implementation for more details.
Parameters:
psca PolymorphismSequenceContainer
gapflaga boolean set by default to true if you don't want to take gap into account
Returns:
A std::vector of size 2 containing the number of GC alleles and the total number of alleles.

Definition at line 247 of file SequenceStatistics.cpp.

References bpp::VectorSiteContainer::getNumberOfSequences(), bpp::ConstSiteIterator::hasMoreSites(), and bpp::ConstSiteIterator::nextSite().

PolymorphismSequenceContainer * SequenceStatistics::generateLDContainer ( const PolymorphismSequenceContainer psc,
bool  keepsingleton = true,
double  freqmin = 0. 
) [static]

generate a special PolymorphismSequenceContainer for linkage disequilbrium analysis

Create a PolymorphismSequenceContainer with only polymorphic site : The value 1 is assigned to the most frequent allele, and 0 to the least frequent. This psc is needed to compute Linkage Disequilibrium Statistics. Should be used before excluding gaps, but sites with gaps are not counted as polymorphic sites. Singleton can be excluded. Polymorphic site with the lowest frequency < threshold can be excluded. Only polymorphic sites with 2 alleles are kept.

Parameters:
psca PolymorphismSequenceContainer
keepsingletona boolean (true by default, false to exclude singleton)
freqmina float (to exlude site with the lowest allele frequency less than the threshold given by freqmin, 0 by default)
Author:
Sylvain Glémin
Todo:

Definition at line 987 of file SequenceStatistics.cpp.

References bpp::VectorSiteContainer::addSite(), bpp::SiteContainer::getNumberOfSequences(), bpp::SiteContainer::getNumberOfSites(), bpp::VectorSiteContainer::getNumberOfSites(), bpp::SiteContainer::getSite(), bpp::VectorSiteContainer::getSite(), bpp::Site::getValue(), and bpp::Site::setElement().

size_t SequenceStatistics::getDerivedSingletonNumber_ ( const Site site_in,
const Site site_out 
) [static, private]

Count the number of singleton for a site.

will count singletons that are not in site_out (a site in outgroup) site_in is a site from an ingroup

Author:
Khalid Belkhir

Definition at line 1608 of file SequenceStatistics.cpp.

size_t SequenceStatistics::getMutationNumber_ ( const Site site) [static, private]

Count the number of mutation for a site.

Definition at line 1579 of file SequenceStatistics.cpp.

Return the number of transitions.

Parameters:
psca PolymorphismSequenceContainer
Author:
Éric Bazin

Definition at line 474 of file SequenceStatistics.cpp.

References bpp::Site::getContent(), bpp::ConstSiteIterator::hasMoreSites(), and bpp::ConstSiteIterator::nextSite().

Return the number of transversions.

Parameters:
psca PolymorphismSequenceContainer
Author:
Éric Bazin

Definition at line 506 of file SequenceStatistics.cpp.

References bpp::Site::getContent(), bpp::ConstSiteIterator::hasMoreSites(), and bpp::ConstSiteIterator::nextSite().

size_t SequenceStatistics::getSingletonNumber_ ( const Site site) [static, private]

Count the number of singleton for a site.

Definition at line 1595 of file SequenceStatistics.cpp.

Return the ratio of transitions/transversions.

Parameters:
psca PolymorphismSequenceContainer
Author:
Éric Bazin

Definition at line 538 of file SequenceStatistics.cpp.

References bpp::ConstSiteIterator::hasMoreSites(), and bpp::ConstSiteIterator::nextSite().

double SequenceStatistics::getUD_ ( double  a1,
double  vD 
) [static, private]

Get the uD value of equation (32) in Fu & Li 1993, Genetics, 133 pp693-709)

Parameters:
a1as describe in getUsefullValues
vDas provided by getVD_
Returns:
the uD value as double
Author:
Sylvain Gaillard

Definition at line 1686 of file SequenceStatistics.cpp.

double SequenceStatistics::getUDstar_ ( size_t  n,
double  a1,
double  vDs 
) [static, private]

Get the uD* value of D* equation in Fu & Li 1993, Genetics, 133 pp693-709)

Parameters:
nthe number of observed sequences
a1as describe in getUsefullValues
vDsas provided by getVDstar_
Returns:
the uD* value as double
Author:
Sylvain Gaillard

Definition at line 1719 of file SequenceStatistics.cpp.

std::map< std::string, double > SequenceStatistics::getUsefullValues_ ( size_t  n) [static, private]

Get usefull values for theta estimators.

Parameters:
nthe number of observed sequences
Returns:
A map with 11 values. Keys are a1, a2, a1n, b1, b2, c1, c2, cn, dn, e1 and e2. The values are :

\[ a_1=\sum_{i=1}^{n-1}\frac{1}{i} \qquad a_2=\sum_{i=1}^{n-1}\frac{1}{i^2} \]

\[ a_{1n}=\sum_{i=1}^{n}\frac{1}{i} \]

\[ b_1=\frac{n+1}{3(n-1)} \qquad b_2=\frac{2(n^2+n+3)}{9n(n-1)} \]

\[ c_1=b_1-\frac{1}{a_1} \qquad c_2=b_2-\frac{n+2}{a_1n}+\frac{a_2}{a_1^2} \]

\[ c_n=2\frac{na_1-2(n-1)}{(n-1)(n-2)} \]

\[ d_n=c_n+\frac{n-2}{(n-1)^2}+\frac{2}{n-1}\left(\frac{3}{2}-\frac{2a_{1n}-3}{n-2}-\frac{1}{n}\right) \]

\[ e_1=\frac{c_1}{a_1} \qquad e_2=\frac{c_2}{a_1^2+a_2} \]

where $n$ is the number of observed sequences.
Author:
Sylvain Gaillard

Definition at line 1630 of file SequenceStatistics.cpp.

double SequenceStatistics::getVD_ ( size_t  n,
double  a1,
double  a2,
double  cn 
) [static, private]

Get the vD value of equation (32) in Fu & Li 1993, Genetics, 133 pp693-709)

Parameters:
nthe number of observed sequences
a1as describe in getUsefullValues
a2as describe in getUsefullValues
cnas describe in getUsefullValues
Returns:
the vD value as double
Author:
Sylvain Gaillard

Definition at line 1677 of file SequenceStatistics.cpp.

double SequenceStatistics::getVDstar_ ( size_t  n,
double  a1,
double  a2,
double  dn 
) [static, private]

Get the vD* value of D* equation in Fu & Li 1993, Genetics, 133 pp693-709)

Parameters:
nthe number of observed sequences
a1as describe in getUsefullValues
a2as describe in getUsefullValues
dnas describe in getUsefullValues
Returns:
the vD* value as double
Author:
Sylvain Gaillard

Definition at line 1691 of file SequenceStatistics.cpp.

double SequenceStatistics::heterozygosity ( const PolymorphismSequenceContainer psc,
bool  gapflag = true 
) [static]

Compute the sum of per site heterozygosity in an alignment.

Parameters:
psca PolymorphismSequenceContainer
gapflaga boolean set by default to true if you don't want to take gap into account

Definition at line 198 of file SequenceStatistics.cpp.

References bpp::ConstSiteIterator::hasMoreSites(), and bpp::ConstSiteIterator::nextSite().

double SequenceStatistics::hudson87 ( const PolymorphismSequenceContainer psc,
double  precision = 0.000001,
double  cinf = 0.001,
double  csup = 10000. 
) [static]

give estimate of C=4Nr using Hudson method (Hudson 1987, Genet. Res., 50 pp245-250)

Parameters:
psca PolymorphismSequenceContainer
precisiondefault value = 0.000001
cinfinitial value, by default cinf=0.001
csupinitial value, by default csup = 10000
Author:
Sylvain Glémin

Definition at line 1521 of file SequenceStatistics.cpp.

References bpp::VectorSiteContainer::getNumberOfSequences().

double SequenceStatistics::inverseRegressionR2 ( const PolymorphismSequenceContainer psc,
bool  distance1 = false,
bool  keepsingleton = true,
double  freqmin = 0. 
) throw (DimensionException) [static]

give the slope of the regression R² = 1/(1+a*distance)

To fit the theoretical prediction R² = 1/(1+4Nr) The slope is given in R² per kb

Parameters:
psca PolymorphismSequenceContainer
distance1a boolean (true to use distance1, false to use distance2, false by default)
keepsingletona boolean (true by default, false to exclude singleton)
freqmina float (to exlude site with the lowest allele frequency less than the threshold given by freqmin, 0 by default)
Exceptions:
DimensionExceptionif the number of sites or the number of sequences is lower than 2
Author:
Sylvain Glémin

Definition at line 1497 of file SequenceStatistics.cpp.

double SequenceStatistics::leftHandHudson_ ( const PolymorphismSequenceContainer psc) [static, private]

give the left hand term of equation (4) in Hudson (Hudson 1987, Genet. Res., 50 pp245-250) This term is used in hudson87

Parameters:
psca PolymorphismSequenceContainer

Definition at line 1734 of file SequenceStatistics.cpp.

References bpp::VectorSiteContainer::getNumberOfSequences().

Vdouble SequenceStatistics::linearRegressionD ( const PolymorphismSequenceContainer psc,
bool  distance1 = false,
bool  keepsingleton = true,
double  freqmin = 0. 
) throw (DimensionException) [static]

give the slope and the origin of the regression |D| = a*distance+b

The slope is given in |D| per kb

Parameters:
psca PolymorphismSequenceContainer
distance1a boolean (true to use distance1, false to use distance2, false by default)
keepsingletona boolean (true by default, false to exclude singleton)
freqmina float (to exlude site with the lowest allele frequency less than the threshold given by freqmin, 0 by default)
Exceptions:
DimensionExceptionif the number of sites or the number of sequences is lower than 2
Author:
Sylvain Glémin

Definition at line 1434 of file SequenceStatistics.cpp.

Vdouble SequenceStatistics::linearRegressionDprime ( const PolymorphismSequenceContainer psc,
bool  distance1 = false,
bool  keepsingleton = true,
double  freqmin = 0. 
) throw (DimensionException) [static]

give the slope and the origin of the regression |D'| = a*distance+b

The slope is given in |D'| per kb

Parameters:
psca PolymorphismSequenceContainer
distance1a boolean (true to use distance1, false to use distance2, false by default)
keepsingletona boolean (true by default, false to exclude singleton)
freqmina float (to exlude site with the lowest allele frequency less than the threshold given by freqmin, 0 by default)
Exceptions:
DimensionExceptionif the number of sites or the number of sequences is lower than 2
Author:
Sylvain Glémin

Definition at line 1455 of file SequenceStatistics.cpp.

Vdouble SequenceStatistics::linearRegressionR2 ( const PolymorphismSequenceContainer psc,
bool  distance1 = false,
bool  keepsingleton = true,
double  freqmin = 0. 
) throw (DimensionException) [static]

give the slope and the origin of the regression R² = a*distance+b

The slope is given in R² per kb

Parameters:
psca PolymorphismSequenceContainer
distance1a boolean (true to use distance1, false to use distance2, false by default)
keepsingletona boolean (true by default, false to exclude singleton)
freqmina float (to exlude site with the lowest allele frequency less than the threshold given by freqmin, 0 by default)
Exceptions:
DimensionExceptionif the number of sites or the number of sequences is lower than 2
Author:
Sylvain Glémin

Definition at line 1476 of file SequenceStatistics.cpp.

double SequenceStatistics::meanD ( const PolymorphismSequenceContainer psc,
bool  keepsingleton = true,
double  freqmin = 0. 
) throw (DimensionException) [static]

give mean D over all pairwise comparisons

Parameters:
psca PolymorphismSequenceContainer
keepsingletona boolean (true by default, false to exclude singleton)
freqmina float (to exlude site with the lowest allele frequency less than the threshold given by freqmin, 0 by default)
Exceptions:
DimensionExceptionif the number of sites or the number of sequences is lower than 2
Author:
Sylvain Glémin

Definition at line 1318 of file SequenceStatistics.cpp.

double SequenceStatistics::meanDistance1 ( const PolymorphismSequenceContainer psc,
bool  keepsingleton = true,
double  freqmin = 0. 
) throw (DimensionException) [static]

give mean pairwise distances between sites / method 1: differences between sequences are not taken into account

Parameters:
psca PolymorphismSequenceContainer
keepsingletona boolean (true by default, false to exclude singleton)
freqmina float (to exlude site with the lowest allele frequency less than the threshold given by freqmin, 0 by default)
Exceptions:
DimensionExceptionif the number of sites is lower than 2
Author:
Sylvain Glémin

Definition at line 1350 of file SequenceStatistics.cpp.

double SequenceStatistics::meanDistance2 ( const PolymorphismSequenceContainer psc,
bool  keepsingleton = true,
double  freqmin = 0. 
) throw (DimensionException) [static]

give mean pairwise distances between sites / method 2: differences between sequences are taken into account

Parameters:
psca PolymorphismSequenceContainer
keepsingletona boolean (true by default, false to exclude singleton)
freqmina float (to exlude site with the lowest allele frequency less than the threshold given by freqmin, 0 by default)
Exceptions:
DimensionExceptionif the number of sites is lower than 2
Author:
Sylvain Glémin

Definition at line 1363 of file SequenceStatistics.cpp.

double SequenceStatistics::meanDprime ( const PolymorphismSequenceContainer psc,
bool  keepsingleton = true,
double  freqmin = 0. 
) throw (DimensionException) [static]

give mean D' over all pairwise comparisons

Parameters:
psca PolymorphismSequenceContainer
keepsingletona boolean (true by default, false to exclude singleton)
freqmina float (to exlude site with the lowest allele frequency less than the threshold given by freqmin, 0 by default)
Exceptions:
DimensionExceptionif the number of sites or the number of sequences is lower than 2
Author:
Sylvain Glémin

Definition at line 1324 of file SequenceStatistics.cpp.

double SequenceStatistics::meanNonSynonymousSitesNumber ( const PolymorphismSequenceContainer psc,
const GeneticCode gc,
double  ratio = 1. 
) [static]

compute the mean number of non-synonymous site in an alignment

A site is x% synonymous if x% of possible mutations are synonymous The transition/transversion can be taken into account (use the variable ratio). Gaps are automatically excluded

Parameters:
psca PolymorphismSequenceContainer
gca GeneticCode
ratioa double
Author:
Éric Bazin

Definition at line 706 of file SequenceStatistics.cpp.

References bpp::ConstSiteIterator::hasMoreSites(), and bpp::ConstSiteIterator::nextSite().

double SequenceStatistics::meanR2 ( const PolymorphismSequenceContainer psc,
bool  keepsingleton = true,
double  freqmin = 0. 
) throw (DimensionException) [static]

give mean R² over all pairwise comparisons

Parameters:
psca PolymorphismSequenceContainer
keepsingletona boolean (true by default, false to exclude singleton)
freqmina float (to exlude site with the lowest allele frequency less than the threshold given by freqmin, 0 by default)
Exceptions:
DimensionExceptionif the number of sites or the number of sequences is lower than 2
Author:
Sylvain Glémin

Definition at line 1337 of file SequenceStatistics.cpp.

double SequenceStatistics::meanSynonymousSitesNumber ( const PolymorphismSequenceContainer psc,
const GeneticCode gc,
double  ratio = 1. 
) [static]

compute the mean number of synonymous site in an alignment

A site is x% synonymous if x% of possible mutations are synonymous. The transition/transversion can be taken into account (use the variable ratio). Gaps and unresolved sites are automatically excluded.

Parameters:
psca PolymorphismSequenceContainer
gca GeneticCode
ratioa double
Author:
Sylvain Glémin
Éric Bazin

Definition at line 692 of file SequenceStatistics.cpp.

References bpp::ConstSiteIterator::hasMoreSites(), and bpp::ConstSiteIterator::nextSite().

vector< size_t > SequenceStatistics::MKtable ( const PolymorphismSequenceContainer ingroup,
const PolymorphismSequenceContainer outgroup,
const GeneticCode gc,
double  freqmin = 0. 
) [static]

return a vector containing Pa, Ps, Da, Ds

Gaps and unresolved sites are automatically excluded

Parameters:
ingroupa PolymorphismSequenceContainer
outgroupa PolymorphismSequenceContainer
gca GeneticCode
freqmina double, to exclude snp in frequency strictly lower than freqmin
Author:
Sylvain Glémin

Definition at line 779 of file SequenceStatistics.cpp.

References bpp::PolymorphismSequenceContainer::addSequence(), bpp::VectorSiteContainer::getAlphabet(), bpp::VectorSiteContainer::getNumberOfSequences(), bpp::VectorSiteContainer::getSequence(), and bpp::PolymorphismSequenceContainer::setAsOutgroupMember().

size_t SequenceStatistics::monoSitePolymorphicCodonNumber ( const PolymorphismSequenceContainer psc,
bool  stopflag = true,
bool  gapflag = true 
) [static]

Compute the number of polymorphic codon with only one mutated site.

Parameters:
psca PolymorphismSequenceContainer
stopflaga boolean set by default to true if you don't want to take stop codon neither undefined sites into account
gapflaga boolean set by default to true if you don't want to take gaps into account
Author:
Sylvain Glémin

Definition at line 605 of file SequenceStatistics.cpp.

References bpp::ConstSiteIterator::hasMoreSites(), and bpp::ConstSiteIterator::nextSite().

double SequenceStatistics::neutralityIndex ( const PolymorphismSequenceContainer ingroup,
const PolymorphismSequenceContainer outgroup,
const GeneticCode gc,
double  freqmin = 0. 
) [static]

return the neutrality index NI = (Pa/Ps)/(Da/Ds) (Rand & Kann 1996, Mol. Biol. Evol. 13 pp735-748)

Return -1 if Ps or Da are zero Gaps and unresolved sites are automatically excluded

Parameters:
ingroupa PolymorphismSequenceContainer
outgroupa PolymorphismSequenceContainer
gca GeneticCode
freqmina double, to exclude snp in frequency strictly lower than freqmin
Author:
Sylvain Glémin

Definition at line 825 of file SequenceStatistics.cpp.

size_t SequenceStatistics::nonSynonymousSubstitutionsNumber ( const PolymorphismSequenceContainer psc,
const GeneticCode gc,
double  freqmin = 0. 
) [static]

compute the number of non synonymous subsitutions in an alignment

Gaps and unresolved sites are automatically excluded

In case of complex codon, the path that gives the minimum number of non-synonymous changes is chosen. The argument minchange=true is sent to numberOfSynonymousDifferences used in this method. Otherwise, a non-integer number could be return.

Parameters:
psca PolymorphismSequenceContainer
gca GeneticCode
freqmina double, to exclude snp in frequency strictly lower than freqmin

Definition at line 737 of file SequenceStatistics.cpp.

References bpp::ConstSiteIterator::hasMoreSites(), and bpp::ConstSiteIterator::nextSite().

double SequenceStatistics::originRegressionD ( const PolymorphismSequenceContainer psc,
bool  distance1 = false,
bool  keepsingleton = true,
double  freqmin = 0. 
) throw (DimensionException) [static]

give the slope of the regression |D| = 1+a*distance

The slope is given in |D| per kb

Parameters:
psca PolymorphismSequenceContainer
distance1a boolean (true to use distance1, false to use distance2, false by default)
keepsingletona boolean (true by default, false to exclude singleton)
freqmina float (to exlude site with the lowest allele frequency less than the threshold given by freqmin, 0 by default)
Exceptions:
DimensionExceptionif the number of sites or the number of sequences is lower than 2
Author:
Sylvain Glémin

Definition at line 1380 of file SequenceStatistics.cpp.

double SequenceStatistics::originRegressionDprime ( const PolymorphismSequenceContainer psc,
bool  distance1 = false,
bool  keepsingleton = true,
double  freqmin = 0. 
) throw (DimensionException) [static]

give the slope of the regression |D'| = 1+a*distance

The slope is given in |D'| per kb

Parameters:
psca PolymorphismSequenceContainer
distance1a boolean (true to use distance1, false to use distance2, false by default)
keepsingletona boolean (true by default, false to exclude singleton)
freqmina float (to exlude site with the lowest allele frequency less than the threshold given by freqmin, 0 by default)
Exceptions:
DimensionExceptionif the number of sites or the number of sequences is lower than 2
Author:
Sylvain Glémin

Definition at line 1398 of file SequenceStatistics.cpp.

double SequenceStatistics::originRegressionR2 ( const PolymorphismSequenceContainer psc,
bool  distance1 = false,
bool  keepsingleton = true,
double  freqmin = 0. 
) throw (DimensionException) [static]

give the slope of the regression R² = 1+a*distance

The slope is given in R² per kb

Parameters:
psca PolymorphismSequenceContainer
distance1a boolean (true to use distance1, false to use distance2, false by default)
keepsingletona boolean (true by default, false to exclude singleton)
freqmina float (to exlude site with the lowest allele frequency less than the threshold given by freqmin, 0 by default)
Exceptions:
DimensionExceptionif the number of sites or the number of sequences is lower than 2
Author:
Sylvain Glémin

Definition at line 1416 of file SequenceStatistics.cpp.

Vdouble SequenceStatistics::pairwiseD ( const PolymorphismSequenceContainer psc,
bool  keepsingleton = true,
double  freqmin = 0. 
) throw (DimensionException) [static]

give the vector of all mean pairwise D value between two sites (Lewontin & Kojima 1964, Evolution 14 pp458-472)

Parameters:
psca PolymorphismSequenceContainer
keepsingletona boolean (true by default, false to exclude singleton)
freqmina float (to exlude site with the lowest allele frequency less than the threshold given by freqmin, 0 by default)
Exceptions:
DimensionExceptionif the number of sites or the number of sequences is lower than 2
Author:
Sylvain Glémin

Definition at line 1191 of file SequenceStatistics.cpp.

References bpp::VectorSiteContainer::getNumberOfSequences(), bpp::VectorSiteContainer::getNumberOfSites(), bpp::VectorSiteContainer::getSite(), and bpp::Site::getValue().

Vdouble SequenceStatistics::pairwiseDistances1 ( const PolymorphismSequenceContainer psc,
bool  keepsingleton = true,
double  freqmin = 0. 
) throw (DimensionException) [static]

give the vector of the pairwise distances between site positions corresponding to a LD SequencePolymorphismContainer

Assume that all sequences have the same length

Parameters:
psca PolymorphismSequenceContainer
keepsingletona boolean (true by default, false to exclude singleton)
freqmina float (to exlude site with the lowest allele frequency less than the threshold given by freqmin, 0 by default)
Exceptions:
DimensionExceptionif the number of sites is lower than 2
Author:
Sylvain Glémin

Definition at line 1057 of file SequenceStatistics.cpp.

References bpp::Site::getAlphabet(), and bpp::Alphabet::getSize().

Vdouble SequenceStatistics::pairwiseDistances2 ( const PolymorphismSequenceContainer psc,
bool  keepsingleton = true,
double  freqmin = 0. 
) throw (DimensionException) [static]

give the vector of all mean pairwise distance between two sites to a LD SequencePolymorphismContainer

pairwise distances are computed for each sequence separately, excluding gaps. Then the mean is taken over all the sequences.

Parameters:
psca PolymorphismSequenceContainer
keepsingletona boolean (true by default, false to exclude singleton)
freqmina float (to exlude site with the lowest allele frequency less than the threshold given by freqmin, 0 by default)
Exceptions:
DimensionExceptionif the number of sites is lower than 2
Author:
Sylvain Glémin

Definition at line 1113 of file SequenceStatistics.cpp.

References bpp::Site::getAlphabet(), bpp::Alphabet::getSize(), and bpp::Sequence::getValue().

Vdouble SequenceStatistics::pairwiseDprime ( const PolymorphismSequenceContainer psc,
bool  keepsingleton = true,
double  freqmin = 0. 
) throw (DimensionException) [static]

give the vector of all mean pairwise D' value between two sites (Lewontin 1964, Genetics 49 pp49-67))

Parameters:
psca PolymorphismSequenceContainer
keepsingletona boolean (true by default, false to exclude singleton)
freqmina float (to exlude site with the lowest allele frequency less than the threshold given by freqmin, 0 by default)
Exceptions:
DimensionExceptionif the number of sites or the number of sequences is lower than 2
Author:
Sylvain Glémin

Definition at line 1224 of file SequenceStatistics.cpp.

References bpp::VectorSiteContainer::getNumberOfSequences(), bpp::VectorSiteContainer::getNumberOfSites(), bpp::VectorSiteContainer::getSite(), and bpp::Site::getValue().

Vdouble SequenceStatistics::pairwiseR2 ( const PolymorphismSequenceContainer psc,
bool  keepsingleton = true,
double  freqmin = 0. 
) throw (DimensionException) [static]

give the vector of all mean pairwise R² value between two sites (Hill & Robertson 1968, Theor. Appl. Genet., 38 pp226-231)

Parameters:
psca PolymorphismSequenceContainer
keepsingletona boolean (true by default, false to exclude singleton)
freqmina float (to exlude site with the lowest allele frequency less than the threshold given by freqmin, 0 by default)
Exceptions:
DimensionExceptionif the number of sites or the number of sequences is lower than 2
Author:
Sylvain Glémin

Definition at line 1280 of file SequenceStatistics.cpp.

References bpp::VectorSiteContainer::getNumberOfSequences(), bpp::VectorSiteContainer::getNumberOfSites(), bpp::VectorSiteContainer::getSite(), and bpp::Site::getValue().

size_t SequenceStatistics::parsimonyInformativeSiteNumber ( const PolymorphismSequenceContainer psc,
bool  gapflag = true 
) [static]

Compute the number of parsimony informative sites in an alignment.

Parameters:
psca PolymorphicSequenceContainer
gapflaga boolean set by default to true if you don't want to take gap into account

Definition at line 93 of file SequenceStatistics.cpp.

References bpp::ConstSiteIterator::hasMoreSites(), and bpp::ConstSiteIterator::nextSite().

double SequenceStatistics::piNonSynonymous ( const PolymorphismSequenceContainer psc,
const GeneticCode gc,
bool  minchange = false 
) [static]

Compute the non-synonymous nucleotide diversity, pi.

Gaps and unresolved sites are automatically excluded If minchange = false (default option) the different paths are equally weighted. If minchange = true the path with the minimum number of non-synonymous change is chosen.

Parameters:
psca PolymorphismSequenceContainer
gca GeneticCode
minchangea boolean set by default to false
Author:
Sylvain Glémin
Éric Bazin

Definition at line 678 of file SequenceStatistics.cpp.

References bpp::ConstSiteIterator::hasMoreSites(), and bpp::ConstSiteIterator::nextSite().

double SequenceStatistics::piSynonymous ( const PolymorphismSequenceContainer psc,
const GeneticCode gc,
bool  minchange = false 
) [static]

Compute the synonymous nucleotide diversity, pi.

Gaps and unresolved sites are automatically excluded If minchange = false (default option) the different paths are equally weighted. If minchange = true the path with the minimum number of non-synonymous change is chosen.

Parameters:
psca PolymorphismSequenceContainer
gca GeneticCode
minchangea boolean set to false
Author:
Sylvain Glémin
Éric Bazin

Definition at line 664 of file SequenceStatistics.cpp.

References bpp::ConstSiteIterator::hasMoreSites(), and bpp::ConstSiteIterator::nextSite().

size_t SequenceStatistics::polymorphicSiteNumber ( const PolymorphismSequenceContainer psc,
bool  gapflag = true,
bool  ignoreUnknown = true 
) [static]

Compute the number of polymorphic site in an alignment.

The number of polymorphic site is also known as the number of segregating site $S$.

Gaps are consider as mutations so if you want number of polymorphic site without gap, set the gapflag parameter to true.

Parameters:
psca PolymorphismSequenceContainer
gapflaga boolean set by default to true if you don't want to take gap into account
ignoreUnknowna boolean set by default to true to ignore unknown states

Definition at line 72 of file SequenceStatistics.cpp.

References bpp::ConstSiteIterator::hasMoreSites(), and bpp::ConstSiteIterator::nextSite().

double SequenceStatistics::rightHandHudson_ ( double  c,
size_t  n 
) [static, private]

give the right hand term of equation (4) in Hudson (Hudson 1987, Genet. Res., 50 pp245-250) This term is used in hudson87

Definition at line 1760 of file SequenceStatistics.cpp.

double SequenceStatistics::squaredHeterozygosity ( const PolymorphismSequenceContainer psc,
bool  gapflag = true 
) [static]

Compute the sum of per site squared heterozygosity in an alignment.

Parameters:
psca PolymorphismSequenceContainer
gapflaga boolean set by default to true if you don't want to take gap into account

Definition at line 216 of file SequenceStatistics.cpp.

References bpp::ConstSiteIterator::hasMoreSites(), and bpp::ConstSiteIterator::nextSite().

size_t SequenceStatistics::stopCodonSiteNumber ( const PolymorphismSequenceContainer psc,
const GeneticCode gCode,
bool  gapflag = true 
) [static]

Compute the number of codon sites with stop codon.

Parameters:
psca PolymorphismSequenceContainer
gCodethe genetic code to use
gapflaga boolean set by default to true if you don't want to take gaps into account
Author:
Sylvain Glémin

Definition at line 579 of file SequenceStatistics.cpp.

References bpp::VectorSiteContainer::getAlphabet().

Compute the number of synonymous polymorphic codon sites.

Gaps and unresolved sites are automatically excluded

Parameters:
psca PolymorphismSequenceContainer
gca GeneticCode
Author:
Sylvain Glémin
Éric Bazin

Definition at line 629 of file SequenceStatistics.cpp.

References bpp::ConstSiteIterator::hasMoreSites(), and bpp::ConstSiteIterator::nextSite().

size_t SequenceStatistics::synonymousSubstitutionsNumber ( const PolymorphismSequenceContainer psc,
const GeneticCode gc,
double  freqmin = 0. 
) [static]

compute the number of synonymous subsitutions in an alignment

Gaps and unresolved sites are automatically excluded

In case of complex codon, the path that gives the minimum number of non-synonymous changes is chosen. The argument minchange=true is sent to numberOfSynonymousDifferences used in this method. Otherwise, a non-integer number could be return.

Parameters:
psca PolymorphismSequenceContainer
gca GeneticCode
freqmina double, to exclude snp in frequency strictly lower than freqmin

Definition at line 722 of file SequenceStatistics.cpp.

References bpp::ConstSiteIterator::hasMoreSites(), and bpp::ConstSiteIterator::nextSite().

double SequenceStatistics::tajima83 ( const PolymorphismSequenceContainer psc,
bool  gapflag = true 
) [static]

Compute diversity estimator Theta of Tajima (1983, Genetics, 105 pp437-460)

\[ \hat{\theta}_\pi=1-\sum_{i=1}^{S}\sum_{j=1}^{4}\frac{k_{j,i}\times\left(k_{j,i}-1\right)} {n_i\times\left(n_i-1\right)} \qquad \textrm{with }k_{j,i}>0 \]

where $k_{j,i}$ is the count of the jth state at the ith site, $n_i$ the number of nucleotides and $S$ the number of polymorphic sites.

Parameters:
psca PolymorphismSequenceContainer
gapflagflag set by default to true if you don't want to take gap into account
Author:
Sylvain Gaillard

Definition at line 299 of file SequenceStatistics.cpp.

References bpp::VectorSiteContainer::getAlphabet(), bpp::ConstSiteIterator::hasMoreSites(), and bpp::ConstSiteIterator::nextSite().

double SequenceStatistics::tajimaDSS ( const PolymorphismSequenceContainer psc,
bool  gapflag = true 
) throw (ZeroDivisionException) [static]

Return the Tajima's D test (Tajima 1989, Genetics 123 pp 585-595).

Calculation using the number of polymorphic (segregating) sites.

\[ D=\frac{\hat{\theta}_\pi-\hat{\theta}_S}{\sqrt{\textrm{V}\left(\hat{\theta}_\pi-\hat{\theta}_S\right)}} =\frac{\hat{\theta}_\pi-\hat{\theta}_S}{\sqrt{e_1S+e_2S(S-1)}} \]

Parameters:
psca PolymorphismSequenceContainer
gapflagflag set by default to true if you don't want to take gap into account
Exceptions:
ZeroDivisionExceptionif S == 0
Author:
Sylvain Gaillard

Definition at line 838 of file SequenceStatistics.cpp.

double SequenceStatistics::tajimaDTNM ( const PolymorphismSequenceContainer psc,
bool  gapflag = true 
) throw (ZeroDivisionException) [static]

Return the Tajima's D test (Tajima 1989, Genetics 123 pp 585-595).

Calculation using the total number of mutation.

\[ D=\frac{\hat{\theta}_\pi-\frac{\eta}{a_1}}{\sqrt{e_1\eta+e_2\eta(\eta-1)}} \]

Parameters:
psca PolymorphismSequenceContainer
gapflagflag set by default to true if you don't want to take gap into account
Exceptions:
ZeroDivisionExceptionif eta == 0
Author:
Sylvain Gaillard

Definition at line 852 of file SequenceStatistics.cpp.

void SequenceStatistics::testUsefullValues ( std::ostream &  s,
size_t  n 
) [static]

Test usefull values.

Parameters:
sa ostream where write the values
nthen number of observed sequences
Author:
Sylvain Gaillard

Definition at line 1549 of file SequenceStatistics.cpp.

Count the total number of mutations in external branchs.

This is counted as the number of distinct singleton nucleotide in the ingroup that are not shared with the outgroup. A site is ignored if it contains more than one variant in the outgroup. A site is ignored if it contains unresolved variants or gaps.

Parameters:
inga PolymorphismSequenceContainer the ingroup alignement
outga PolymorphismSequenceContainer the outgroup alignement
Exceptions:
Exceptionif ing and outg are not of the same size (site number)
Author:
Khalid Belkhir

Definition at line 172 of file SequenceStatistics.cpp.

References bpp::ConstSiteIterator::hasMoreSites(), and bpp::ConstSiteIterator::nextSite().

size_t SequenceStatistics::totNumberMutations ( const PolymorphismSequenceContainer psc,
bool  gapflag = true 
) [static]

Count the total number of mutations in an alignment.

This count is assumed to be under an infinite site model.

Parameters:
psca PolymorphismSequenceContainer
gapflaga boolean set by default to true if you don't want to take gap into account
Author:
Sylvain Gaillard

Definition at line 154 of file SequenceStatistics.cpp.

References bpp::ConstSiteIterator::hasMoreSites(), and bpp::ConstSiteIterator::nextSite().

size_t SequenceStatistics::tripletNumber ( const PolymorphismSequenceContainer psc,
bool  gapflag = true 
) [static]

Compute the number of triplet in an alignment.

Parameters:
psca PolymorphismSequenceContainer
gapflaga boolean set by default to true if you don't want to take gap into account
Author:
Sylvain Glémin

Definition at line 132 of file SequenceStatistics.cpp.

References bpp::ConstSiteIterator::hasMoreSites(), and bpp::ConstSiteIterator::nextSite().

double SequenceStatistics::watterson75 ( const PolymorphismSequenceContainer psc,
bool  gapflag = true,
bool  ignoreUnknown = true 
) [static]

Compute diversity estimator Theta of Watterson (1975, Theor Popul Biol, 7 pp256-276)

\[ \hat{\theta}_S=\frac{S}{a_1} \]

where $S$ is the number of polymorphic sites and $a_1$ is describe in SequenceStatistics::_getUsefullValues().

Parameters:
psca PolymorphismSequenceContainer
gapflagflag set by default to true if you don't want to take gap into account
ignoreUnknowna boolean set by default to true to ignore unknown states
Author:
Sylvain Gaillard

Definition at line 289 of file SequenceStatistics.cpp.

References bpp::VectorSiteContainer::getNumberOfSequences().

Compute the Watterson(1975, Theor Popul Biol, 7 pp256-276) estimator for non synonymous positions.

Gaps and unresolved sites are automatically excluded

In case of complex codon, the path that gives the minimum number of non-synonymous changes is chosen. The argument minchange=true is sent to numberOfSynonymousDifferences used in this method. Otherwise, a non-integer number could be return.

Parameters:
psca PolymorphismSequenceContainer
gca GeneticCode
Author:
Sylvain Glémin

Definition at line 654 of file SequenceStatistics.cpp.

References bpp::VectorSiteContainer::getNumberOfSequences().

double SequenceStatistics::watterson75Synonymous ( const PolymorphismSequenceContainer psc,
const GeneticCode gc 
) [static]

Compute the Watterson(1975,Theor Popul Biol, 7 pp256-276) estimator for synonymous positions.

Gaps and unresolved sites are automatically excluded

In case of complex codon, the path that gives the minimum number of non-synonymous changes* is chosen. The argument minchange=true is sent to numberOfSynonymousDifferences used in this method. Otherwise, a non-integer number could be return.

Parameters:
psca PolymorphismSequenceContainer
gca GeneticCode
Author:
Sylvain Glémin

Definition at line 644 of file SequenceStatistics.cpp.

References bpp::VectorSiteContainer::getNumberOfSequences().


The documentation for this class was generated from the following files:
 All Classes Namespaces Files Functions Variables Typedefs Friends