Egglib 2.1.11
C++ library reference manual
FStatistics.hpp
1 /*
2  Copyright 2009 Stéphane De Mita, Mathieu Siol
3 
4  This file is part of the EggLib library.
5 
6  EggLib is free software: you can redistribute it and/or modify
7  it under the terms of the GNU General Public License as published by
8  the Free Software Foundation, either version 3 of the License, or
9  (at your option) any later version.
10 
11  EggLib is distributed in the hope that it will be useful,
12  but WITHOUT ANY WARRANTY; without even the implied warranty of
13  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  GNU General Public License for more details.
15 
16  You should have received a copy of the GNU General Public License
17  along with EggLib. If not, see <http://www.gnu.org/licenses/>.
18 */
19 
20 #ifndef EGGLIB_FSTATISTICS_HPP
21 #define EGGLIB_FSTATISTICS_HPP
22 
23 
24 
25 namespace egglib {
26 
27 
50  class FStatistics {
51 
52  public:
53 
57  FStatistics();
58 
59 
63  virtual ~FStatistics();
64 
65 
75  void reserve(unsigned int numberOfIndividuals);
76 
77 
95  void loadIndividual(unsigned int genotype1,
96  unsigned int genotype2, unsigned int populationLabel);
97 
98 
106  unsigned int populationLabel(unsigned int populationIndex);
107 
108 
116  unsigned int alleleValue(unsigned int alleleIndex);
117 
118 
120  unsigned int firstAllele(unsigned int individualIndex) const;
121 
123  unsigned int secondAllele(unsigned int individualIndex) const;
124 
126  unsigned int individualLabel(unsigned int individualIndex) const;
127 
128 
132  unsigned int numberOfAlleles();
133 
134 
138  unsigned int numberOfPopulations();
139 
140 
144  unsigned int numberOfGenotypes() const;
145 
146 
150  unsigned int alleleFrequencyTotal(unsigned int alleleIndex);
151 
152 
156  unsigned int alleleFrequencyPerPopulation(unsigned int populationIndex, unsigned int alleleIndex);
157 
158 
166  unsigned int genotypeFrequencyTotal(unsigned int alleleIndex1, unsigned int alleleIndex2);
167 
168 
176  unsigned int genotypeFrequencyPerPopulation(unsigned int populationIndex, unsigned int alleleIndex1, unsigned int alleleIndex2);
177 
178 
182  unsigned int populationFrequency(unsigned int populationIndex);
183 
184 
190  double F();
191 
192 
198  double theta();
199 
200 
206  double f();
207 
208 
212  double Vpopulation();
213 
214 
218  double Vindividual();
219 
220 
224  double Vallele();
225 
226 
227  protected:
228 
229  bool d_flag;
230  void d_init();
231  void d_clear();
232  unsigned int d_reserved;
233  unsigned int d_numberOfGenotypes;
234  unsigned int *d_genotypes;
235  unsigned int *d_populationLabels;
236 
237  bool s_flag;
238  void s_init();
239  void s_clear();
240  void s_compute();
241  void processPopulations();
242  void processAlleles();
243  unsigned int getPopulationIndex(unsigned int) const;
244  unsigned int getAlleleIndex(unsigned int) const;
245  unsigned int s_numberOfAlleles;
246  unsigned int *s_alleleValueMapping;
247  unsigned int s_numberOfPopulations;
248  unsigned int *s_populationLabelMapping;
249  unsigned int *s_populationFrequencies;
250  unsigned int *s_alleleFrequenciesTotal;
251  unsigned int **s_alleleFrequenciesPerPopulation;
252  unsigned int **s_genotypeFrequenciesTotal;
253  unsigned int ***s_genotypeFrequenciesPerPopulation;
254 
255  bool w_flag;
256  void w_init();
257  void w_clear();
258  void w_compute();
259  double w_F;
260  double w_T;
261  double w_f;
262  double *w_a;
263  double *w_b;
264  double *w_c;
265  double w_nbar;
266  double w_nc;
267  double *w_pbar;
268  double *w_ssquare;
269  double *w_hbar;
270  double w_sum_a;
271  double w_sum_b;
272  double w_sum_c;
273  double w_sum_abc;
274  double w_sum_bc;
275 
276 
277  private:
278 
279  FStatistics(const FStatistics& source) { }
280 
281  FStatistics& operator=(const FStatistics& source) {
282  return *this;
283  }
284 
285  };
286 }
287 
288 #endif
double F()
Weir-Cockerham F-statistic.
Definition: FStatistics.cpp:629
double Vpopulation()
Between-population component of variance.
Definition: FStatistics.cpp:644
void reserve(unsigned int numberOfIndividuals)
Reserve sufficient memory for a given number of individuals.
Definition: FStatistics.cpp:141
unsigned int numberOfPopulations()
Number of populations.
Definition: FStatistics.cpp:574
unsigned int secondAllele(unsigned int individualIndex) const
Second allele of a given individual (no checking)
Definition: FStatistics.cpp:559
double theta()
Weir-Cockerham theta-statistic.
Definition: FStatistics.cpp:634
unsigned int firstAllele(unsigned int individualIndex) const
First allele of a given individual (no checking)
Definition: FStatistics.cpp:555
double f()
Weir-Cockerham f-statistic.
Definition: FStatistics.cpp:639
unsigned int alleleFrequencyTotal(unsigned int alleleIndex)
Absolute total allele frequency.
Definition: FStatistics.cpp:598
unsigned int individualLabel(unsigned int individualIndex) const
Population label of a given individual (no checking)
Definition: FStatistics.cpp:563
unsigned int populationLabel(unsigned int populationIndex)
Label of a population.
Definition: FStatistics.cpp:586
virtual ~FStatistics()
Destructor.
Definition: FStatistics.cpp:132
double Vindividual()
Within-population, between-individual component of variance.
Definition: FStatistics.cpp:649
unsigned int genotypeFrequencyTotal(unsigned int alleleIndex1, unsigned int alleleIndex2)
Absolute genotype frequency.
Definition: FStatistics.cpp:610
unsigned int populationFrequency(unsigned int populationIndex)
Sample size of a population.
Definition: FStatistics.cpp:621
FStatistics()
Constructor.
Definition: FStatistics.cpp:125
unsigned int alleleFrequencyPerPopulation(unsigned int populationIndex, unsigned int alleleIndex)
Absolute allele frequency in a population.
Definition: FStatistics.cpp:604
unsigned int numberOfGenotypes() const
Number of loaded genotypes.
Definition: FStatistics.cpp:570
Definition: ABC.cpp:37
unsigned int alleleValue(unsigned int alleleIndex)
Value of an allele.
Definition: FStatistics.cpp:592
void loadIndividual(unsigned int genotype1, unsigned int genotype2, unsigned int populationLabel)
Loads the data for one individual.
Definition: FStatistics.cpp:160
Computes Fis, Fst and Fit from diploid data.
Definition: FStatistics.hpp:50
unsigned int genotypeFrequencyPerPopulation(unsigned int populationIndex, unsigned int alleleIndex1, unsigned int alleleIndex2)
Absolute genotype frequency in a population.
Definition: FStatistics.cpp:616
double Vallele()
Within-individual component of variance.
Definition: FStatistics.cpp:654
unsigned int numberOfAlleles()
Number of alleles.
Definition: FStatistics.cpp:580

Hosted by 
Get EggLib at SourceForge.net. Fast, secure and Free Open Source software downloads