Egglib 2.1.11
C++ library reference manual
HFStatistics.hpp
1 /*
2  Copyright 2010 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_HFSTATISTICS_HPP
21 #define EGGLIB_HFSTATISTICS_HPP
22 
23 
24 
25 namespace egglib {
26 
27 
45  class HFStatistics {
46 
47  public:
48 
52  HFStatistics();
53 
54 
58  virtual ~HFStatistics();
59 
60 
70  void reserve(unsigned int numberOfIndividuals);
71 
72 
89  void loadIndividual(unsigned int genotype, unsigned int populationLabel);
90 
91 
99  unsigned int populationLabel(unsigned int populationIndex);
100 
101 
109  unsigned int alleleValue(unsigned int alleleIndex);
110 
111 
113  unsigned int allele(unsigned int individualIndex) const;
114 
116  unsigned int individualLabel(unsigned int individualIndex) const;
117 
118 
122  unsigned int numberOfAlleles();
123 
124 
128  unsigned int numberOfPopulations();
129 
130 
134  unsigned int numberOfGenotypes() const;
135 
136 
140  unsigned int alleleFrequencyTotal(unsigned int alleleIndex);
141 
142 
146  unsigned int alleleFrequencyPerPopulation(unsigned int populationIndex, unsigned int alleleIndex);
147 
148 
152  unsigned int populationFrequency(unsigned int populationIndex);
153 
154 
160  double theta();
161 
162 
166  double T1();
167 
168 
172  double T2();
173 
174 
175  protected:
176 
177  bool d_flag;
178  void d_init();
179  void d_clear();
180  unsigned int d_reserved;
181  unsigned int d_numberOfGenotypes;
182  unsigned int *d_genotypes;
183  unsigned int *d_populationLabels;
184 
185  bool s_flag;
186  void s_init();
187  void s_clear();
188  void s_compute();
189  void processPopulations();
190  void processAlleles();
191  unsigned int getPopulationIndex(unsigned int) const;
192  unsigned int getAlleleIndex(unsigned int) const;
193  unsigned int s_numberOfAlleles;
194  unsigned int *s_alleleValueMapping;
195  unsigned int s_numberOfPopulations;
196  unsigned int *s_populationLabelMapping;
197  unsigned int *s_populationFrequencies;
198  unsigned int *s_alleleFrequenciesTotal;
199  unsigned int **s_alleleFrequenciesPerPopulation;
200 
201  bool w_flag;
202  void w_init();
203  void w_clear();
204  void w_compute();
205  double w_T;
206  double *w_T1;
207  double *w_T2;
208  double w_nbar;
209  double w_nc;
210  double *w_pbar;
211  double *w_ssquare;
212  double w_sum_T1;
213  double w_sum_T2;
214 
215 
216  private:
217 
218  HFStatistics(const HFStatistics& source) { }
219 
220  HFStatistics& operator=(const HFStatistics& source) {
221  return *this;
222  }
223 
224  };
225 }
226 
227 #endif
HFStatistics()
Constructor.
Definition: HFStatistics.cpp:97
unsigned int alleleFrequencyTotal(unsigned int alleleIndex)
Absolute total allele frequency.
Definition: HFStatistics.cpp:436
unsigned int populationLabel(unsigned int populationIndex)
Label of a population.
Definition: HFStatistics.cpp:424
unsigned int alleleFrequencyPerPopulation(unsigned int populationIndex, unsigned int alleleIndex)
Absolute allele frequency in a population.
Definition: HFStatistics.cpp:442
virtual ~HFStatistics()
Destructor.
Definition: HFStatistics.cpp:104
unsigned int alleleValue(unsigned int alleleIndex)
Value of an allele.
Definition: HFStatistics.cpp:430
double T1()
Between-population component of variance.
Definition: HFStatistics.cpp:461
unsigned int numberOfGenotypes() const
Number of loaded genotypes.
Definition: HFStatistics.cpp:408
unsigned int populationFrequency(unsigned int populationIndex)
Sample size of a population.
Definition: HFStatistics.cpp:448
unsigned int numberOfPopulations()
Number of populations.
Definition: HFStatistics.cpp:412
double theta()
Weir-Cockerham theta-statistic.
Definition: HFStatistics.cpp:456
void reserve(unsigned int numberOfIndividuals)
Reserve sufficient memory for a given number of individuals.
Definition: HFStatistics.cpp:113
unsigned int individualLabel(unsigned int individualIndex) const
Population label of a given individual (no checking)
Definition: HFStatistics.cpp:401
Definition: ABC.cpp:37
unsigned int allele(unsigned int individualIndex) const
Allele of a given individual (no checking)
Definition: HFStatistics.cpp:397
Computes Fst and Fit from haploid data.
Definition: HFStatistics.hpp:45
void loadIndividual(unsigned int genotype, unsigned int populationLabel)
Loads the data for one individual.
Definition: HFStatistics.cpp:132
double T2()
Total variance.
Definition: HFStatistics.cpp:466
unsigned int numberOfAlleles()
Number of alleles.
Definition: HFStatistics.cpp:418

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