|
| | TTNeutralGenesSH (TProtoNeutralGenes *TP) |
| |
| virtual | ~TTNeutralGenesSH () |
| |
| virtual void | init () |
| |
| virtual bool | setStatRecorders (std::string &token) |
| |
| void | setFreqRecorders (age_t AGE) |
| |
| void | setFreqRecordersPerPatch (age_t AGE) |
| |
| void | setFstatRecorders (age_t AGE) |
| |
| void | setFstat2Recorders (age_t AGE) |
| |
| void | setFstatWCRecorders (age_t AGE) |
| |
| void | setCoaMatrixRecorders (age_t AGE, unsigned char dim) |
| |
| void | setFstMatrixRecorders (age_t AGE, unsigned char dim) |
| |
| void | setNeiGeneticDistanceRecorders (age_t AGE, bool pairwise) |
| |
| void | setDxyRecorders (age_t AGE, bool patchwise) |
| |
|
| void | setAdultAlleleFreq () |
| |
| void | setOffspringAlleleFreq () |
| |
| void | setHeterozygosity (age_t AGE) |
| |
| void | setAdultHeterozygosity () |
| |
| void | setOffspringHeterozygosity () |
| |
| double | getGlobalAlleleFreq (unsigned int loc, unsigned int all) |
| |
| double | getHeterozygosity (unsigned int loc) |
| |
|
| void | setAlleleTables (age_t AGE) |
| |
| void | setHeteroTable (age_t AGE) |
| |
| void | allocateTables (unsigned int loci, unsigned int all) |
| |
| DataTable< double > * | getAlleleFreqTable () |
| | Accessor to the table of allele frequencies, per patch. More...
|
| |
| DataTable< unsigned int > * | getAlleleCountTable () |
| |
| DataTable< double > * | getHeteroTable () |
| |
| TMatrix * | getGlobalFreqs () |
| | Accessor to the table of allele frequencies in the whole population. More...
|
| |
| void | setFstMatrix (age_t AGE, unsigned char dim) |
| | Computes the weighted within and between patch Fst's as well as the overall Fst (Theta). More...
|
| |
| void | setAdultsFstMatrix () |
| |
| void | setAdultsFstWithin () |
| |
| void | setAdultsFstBetween () |
| |
| void | setOffsprgFstMatrix () |
| |
| void | setOffsprgFstWithin () |
| |
| void | setOffsprgFstBetween () |
| |
| double | getWeightedFst () |
| | Returns the weighted Fst using Weir & Hill (2002) method. More...
|
| |
| double | getFst_ij (unsigned int i) |
| | Accessor to the Fst matrix as set by setFstMatrix(). More...
|
| |
| void | setFst_li (unsigned int N, unsigned int L, double **array) |
| | Computes the per-locus per-patch Fst values using Weir&Hill 2002 approach. More...
|
| |
| void | setFstat (age_t AGE) |
| | Computes the F-statistics following Nei & Chesser (1983). More...
|
| |
| void | setOffsprgFstat () |
| |
| void | setAdultsFstat () |
| |
| double | setHo (age_idx age_pos) |
| |
| double | setHs (age_idx age_pos) |
| |
| double | setHt (age_idx age_pos) |
| |
| double | getHsnei () |
| |
| double | getHtnei () |
| |
| double | getHo () |
| |
| double | getHs () |
| |
| double | getHt () |
| |
| double | getFst () |
| |
| double | getFis () |
| |
| double | getFit () |
| |
| void | setFstat2 (age_t AGE) |
| | New version of Nei & Chesser. More...
|
| |
| void | setOffsprgFstat2 () |
| |
| void | setAdultsFstat2 () |
| |
| deque< double > | setHo2 (age_idx age_pos) |
| |
| deque< double > | setHs2 (age_idx age_pos) |
| |
| deque< double > | setHt2 (age_idx age_pos) |
| |
| void | setFstatWeirCockerham (age_t AGE) |
| | Computes the Weir & Cockerham (1984) Fstat values (Theta, F, and f). More...
|
| |
| void | setFstatWeirCockerham_MS (age_t AGE) |
| |
| void | setOffspringFstatWeirCockerham () |
| |
| void | setAdultsFstatWeirCockerham () |
| |
| double | getFstWC () |
| |
| double | getFisWC () |
| |
| double | getFitWC () |
| |
| void | setLociDivCounter (age_t AGE) |
| | Sets the allelic diversity counters. More...
|
| |
| double | getNbAllLocal () |
| |
| double | getNbAllGlobal () |
| |
| double | getFixLocLocal () |
| |
| double | getFixLocGlobal () |
| |
|
| double | Coancestry (const TTrait *ind1, const TTrait *ind2, unsigned int nb_locus) |
| | Gives the coancestry (probability of identity by state) of two gene sequences. More...
|
| |
| void | setCoaMatrix (age_idx age_pos, unsigned char dim) |
| | Computes the within and between patches coancestry coefficients. More...
|
| |
| void | setAdultsCoaMatrix () |
| |
| void | setOffsprgCoaMatrix () |
| |
| void | setAdultsCoaWithin () |
| |
| void | setOffsprgCoaWithin () |
| |
| void | setAdultsCoaBetween () |
| |
| void | setOffsprgCoaBetween () |
| |
| void | setAdults_Theta () |
| |
| double | getCoa (unsigned int i) |
| | Gets the given coancestry coefficient from the coancestry matrix. More...
|
| |
| double | getMeanTheta () |
| |
| double | getMeanAlpha () |
| |
| double | getTheta_FF () |
| | Gives the mean within females coancestry coefficient. More...
|
| |
| double | getTheta_MM () |
| | Gives the mean within males coancestry coefficient. More...
|
| |
| double | getTheta_FM () |
| | Gives the mean between males and females coancestry coefficient. More...
|
| |
| void | setSibStats () |
| |
| void | setSibCoa (Individual *I1, Individual *I2) |
| |
| double | getSibProportions (unsigned int i) |
| |
| double | getSibCoaMeans (unsigned int i) |
| |
|
| void | setAdltNeiGeneticDistance () |
| |
| void | setOffsprgNeiGeneticDistance () |
| |
| void | setNeiGeneticDistance (age_t AGE) |
| |
| double | getNeiGeneticDistance (unsigned int i) |
| |
| double | getMeanNeiGeneticDistance () |
| |
|
| double | getDxyOffspringPerPatch (unsigned int patch1, unsigned patch2) |
| |
| double | getDxyAdultPerPatch (unsigned int patch1, unsigned patch2) |
| |
| double | getDxyPerPatch (age_idx age, unsigned int patch1, unsigned patch2) |
| |
| double | getDxy (unsigned int age_class) |
| |
Public Member Functions inherited from TraitStatHandler< TProtoNeutralGenes, TTNeutralGenesSH > |
| | TraitStatHandler (TProtoNeutralGenes *trait_proto) |
| |
| virtual | ~TraitStatHandler () |
| |
Public Member Functions inherited from StatHandler< SH > |
| | StatHandler () |
| |
| virtual | ~StatHandler () |
| |
| virtual void | clear () |
| | Empties the _recorders list, they are destroyed in StatHandlerBase::reset(). More...
|
| |
| virtual StatRecorder< SH > * | add (std::string Title, std::string Name, age_t AGE, unsigned int ARG1, unsigned int ARG2, double(SH::*getStatNoArg)(void), double(SH::*getStatOneArg)(unsigned int), double(SH::*getStatTwoArg)(unsigned int, unsigned int), void(SH::*setStat)(void)) |
| | Adds a StatRecorder to the list, it is also added to the StatHandlerBase::_stats list. More...
|
| |
Public Member Functions inherited from StatHandlerBase |
| | StatHandlerBase () |
| |
| virtual | ~StatHandlerBase () |
| |
| virtual void | reset () |
| | Empties the _stats list and calls clear() (defined in the derived class). More...
|
| |
| Metapop * | get_pop_ptr () |
| |
| void | set_service (StatServices *srv) |
| |
| StatServices * | get_service () |
| |
| unsigned int | getOccurrence () |
| |
| unsigned int | getNumOccurrences () |
| |
| unsigned int | getCurrentOccurrence () |
| |
| unsigned int | getNbRecorders () |
| |
| std::list< StatRecBase * > & | getStats () |
| |
| virtual void | add (StatRecBase *rec) |
| |
| virtual void | update () |
| | This function is left empty as the StatServices calls StatRecorder::setVal directly. More...
|
| |
Public Member Functions inherited from Handler |
| virtual | ~Handler () |
| |
The stat handler for neutral markers.
| void TTNeutralGenesSH::setAlleleTables |
( |
age_t |
AGE | ) |
|
98 unsigned int* count1 =
new unsigned int[nb_locus]();
100 for(
unsigned int k = 0; k < patchNbr; ++k) {
103 memset(count1, 0, nb_locus *
sizeof(
unsigned int));
105 for (
int sx = 0; sx < 2; ++sx) {
107 for(
unsigned int i = 0, size = crnt_patch->
size(
sex_t(sx), age_pos); i < size; ++i) {
112 for (
int chr = 0; chr < 2; ++chr) {
115 for (
size_t w = 0; w < nwords; ++w) {
126 for (
unsigned int j = 0; j < nb_locus; ++j) {
129 crnt_patch->
size(age_pos) * 2 - count1[j]);
138 for(
unsigned int k = 0; k < patchNbr; ++k) {
142 for (
int sx = 0; sx < 2; ++sx) {
144 for(
unsigned int i = 0, size = crnt_patch->
size(
sex_t(sx), age_pos); i < size; ++i) {
148 for (
unsigned int j = 0; j < nb_locus; ++j)
151 for (
unsigned int j = 0; j < nb_locus; ++j)
160 for (
unsigned int i = 0; i < patchNbr; ++i) {
166 for (
unsigned int l = 0; l < nb_locus; ++l)
167 for (
unsigned int u = 0; u < nb_allele; ++u)
171 for (
unsigned int l = 0; l < nb_locus; ++l)
172 for (
unsigned int u = 0; u < nb_allele; ++u)
178 unsigned int tot_size =
_pop->
size(AGE) * 2;
182 for(
unsigned int i = 0; i < patchNbr; i++)
183 for (
unsigned int l = 0; l < nb_locus; ++l)
184 for (
unsigned int u = 0; u < nb_allele; ++u)
187 for (
unsigned int l = 0; l < nb_locus; ++l)
188 for (
unsigned int u = 0; u < nb_allele; ++u)
#define BITS_PER_WORD
Definition: bitstring.h:41
void set(unsigned int group, unsigned int Class, unsigned int elmnt, T val)
Sets the element 'elmnt' of the class 'Class' in the group 'group' to the value 'val'.
Definition: datatable.h:232
void init(T val)
Sets all elements of the table to value 'val'.
Definition: datatable.h:256
void increment(unsigned int group, unsigned int Class, unsigned int elmnt)
Increments 'elmnt' of the class 'Class' in the group 'group' by one.
Definition: datatable.h:236
void assign(double val)
Assigns a value to all element of the matrix.
Definition: tmatrix.h:155
void divide(unsigned int i, unsigned int j, double value)
Divide an element of the matrix by a value.
Definition: tmatrix.h:289
void plus(unsigned int i, unsigned int j, double value)
Adds a value to an element of the matrix.
Definition: tmatrix.h:256
TTNeutralGenes_bitstring : diallelic neutral loci encoded as bitstrings.
Definition: ttneutralgenes_bitstring.h:40
const bitstring & get_bit_sequence(bool chromosome) const
Definition: ttneutralgenes_bitstring.h:52
Non-template and faster implementation of std::bitset.
Definition: bitstring.h:57
unsigned long _ul
Definition: bitstring.h:61
_ul * getword_atIdx(size_t index) const
Definition: bitstring.h:159
size_t nb_words() const
Definition: bitstring.h:164
sex_t
Sex types, males are always 0 and females 1!!
Definition: types.h:36
References _alleleCountTable, _alleleFreqTable, _globalAlleleFreq, _is_diallelic_bitstring, StatHandlerBase::_pop, TraitStatHandler< TProtoNeutralGenes, TTNeutralGenesSH >::_SHLinkedTrait, TraitStatHandler< TProtoNeutralGenes, TTNeutralGenesSH >::_SHLinkedTraitIndex, _table_set_age, _table_set_gen, _table_set_repl, ADLTx, ADULTS, allocateTables(), TMatrix::assign(), BITS_PER_WORD, TMatrix::divide(), Patch::get(), DataTable< T >::get(), TTrait::get_allele(), TProtoNeutralGenes::get_allele_num(), TTNeutralGenes_bitstring::get_bit_sequence(), TProtoNeutralGenes::get_locus_num(), Metapop::getCurrentGeneration(), Metapop::getCurrentReplicate(), DataTable< T >::getNumGroups(), Metapop::getPatch(), Metapop::getPatchNbr(), Individual::getTrait(), bitstring::getword_atIdx(), DataTable< T >::increment(), DataTable< T >::init(), bitstring::nb_words(), OFFSx, TMatrix::plus(), DataTable< T >::set(), Metapop::size(), and Patch::size().
Referenced by setAdultAlleleFreq(), setFst_li(), setFstat(), setFstat2(), setFstatWeirCockerham(), setFstatWeirCockerham_MS(), setFstMatrix(), setNeiGeneticDistance(), setOffspringAlleleFreq(), and TTNeutralGenesFH::write_varcompWC().
| void TTNeutralGenesSH::setFstat |
( |
age_t |
AGE | ) |
|
Computes the F-statistics following Nei & Chesser (1983).
284 double harmonic = 0, nbpatch = 0, nbind;
297 for (
unsigned int i = 0; i < patchNbr; ++i){
302 harmonic += 1.0/nbind;
306 harmonic = nbpatch / harmonic;
312 _hsnei = (nbpatch != 0 ? harmonic/(harmonic-1.0)*(
_hs-(
_ho/(2.0*harmonic))) : nanf(
"NULL") );
314 -(
_ho/(2.0*harmonic*nbpatch)) : nanf(
"NULL") );
double setHo(age_idx age_pos)
Definition: stats_fstat.cc:391
double setHt(age_idx age_pos)
Definition: stats_fstat.cc:496
void setLociDivCounter(age_t AGE)
Sets the allelic diversity counters.
Definition: stats_fstat.cc:323
double setHs(age_idx age_pos)
Definition: stats_fstat.cc:451
References _alleleCountTable, _fis, _fit, _fst, _ho, _hs, _hsnei, _ht, _htnei, StatHandlerBase::_pop, TraitStatHandler< TProtoNeutralGenes, TTNeutralGenesSH >::_SHLinkedTrait, ADLTx, ADULTS, allocateTables(), TProtoNeutralGenes::get_allele_num(), TProtoNeutralGenes::get_locus_num(), DataTable< T >::getNumGroups(), Metapop::getPatchNbr(), OFFSx, setAlleleTables(), setHo(), setHs(), setHt(), setLociDivCounter(), and Metapop::size().
Referenced by setAdultsFstat(), and setOffsprgFstat().
| void TTNeutralGenesSH::setFstat2 |
( |
age_t |
AGE | ) |
|
New version of Nei & Chesser.
525 double harmonic = 0, nbpatch = 0, nbind;
539 for (
unsigned int i = 0; i < patchNbr; ++i){
544 harmonic += 1.0/nbind;
548 harmonic = nbpatch / harmonic;
550 deque<double> ho =
setHo2(age_pos);
551 deque<double> hs =
setHs2(age_pos);
552 deque<double> ht =
setHt2(age_pos);
558 for (
unsigned int l = 0; l < nloc; ++l) {
561 hsnei = (nbpatch != 0 ? harmonic/(harmonic-1.0)*(hs[l]-(ho[l]/(2.0*harmonic))) : nanf(
"NULL") );
562 htnei = (nbpatch != 0 ? ht[l] + (hsnei/(harmonic*nbpatch))
563 -(ho[l]/(2.0*harmonic*nbpatch)) : 0 );
571 if(ht[l] == 0) nloc--;
572 _fst += ( ht[l] != 0 ? 1.0-(hsnei/htnei) : 0);
deque< double > setHo2(age_idx age_pos)
Definition: stats_fstat.cc:586
deque< double > setHt2(age_idx age_pos)
Definition: stats_fstat.cc:698
deque< double > setHs2(age_idx age_pos)
Definition: stats_fstat.cc:648
References _alleleCountTable, _fis, _fit, _fst, _ho, _hsnei, _htnei, StatHandlerBase::_pop, TraitStatHandler< TProtoNeutralGenes, TTNeutralGenesSH >::_SHLinkedTrait, ADLTx, ADULTS, allocateTables(), TProtoNeutralGenes::get_allele_num(), TProtoNeutralGenes::get_locus_num(), DataTable< T >::getNumGroups(), Metapop::getPatchNbr(), OFFSx, setAlleleTables(), setHo2(), setHs2(), setHt2(), setLociDivCounter(), and Metapop::size().
Referenced by setAdultsFstat2(), and setOffsprgFstat2().
| void TTNeutralGenesSH::setFstatWeirCockerham |
( |
age_t |
AGE | ) |
|
Computes the Weir & Cockerham (1984) Fstat values (Theta, F, and f).
841 double *pop_sizes =
new double [patchNbr];
842 double tot_size, inv_ntot;
843 double sum_weights = 0;
844 double nbar, nc, inv_nbar;
845 unsigned int extantPs = 0;
849 for(
unsigned int i = 0; i < patchNbr; i++) {
853 sum_weights += (pop_sizes[i] * pop_sizes[i] / tot_size);
856 nbar = tot_size/extantPs;
857 nc = (tot_size - sum_weights)/(extantPs-1);
858 inv_nbar = 1/(nbar - 1);
859 inv_ntot = 1/tot_size;
862 double s2, pbar, hbar;
863 double s2_denom = 1.0/((extantPs-1)*nbar),
864 r = (double)(extantPs-1)/extantPs,
865 hbar_factor=(2*nbar-1)/(4*nbar);
866 double a = 0, b = 0, c = 0, x;
868 for (
unsigned int l = 0; l < nb_locus; ++l) {
870 for (
unsigned int u = 0; u < nb_allele; ++u) {
872 s2 = pbar = hbar = 0;
874 for (
unsigned int i = 0; i < patchNbr; ++i) {
880 s2 += var * pop_sizes[i];
890 x = pbar * (1 - pbar) - r * s2;
891 a += s2 - inv_nbar*( x - 0.25 * hbar);
892 b += x - hbar_factor * hbar;
901 b *= nbar/(nbar - 1);
905 _fit_WC = (a + b) / (a + b + c);
void setHeteroTable(age_t AGE)
Definition: stats_fstat.cc:200
References _alleleFreqTable, _fis_WC, _fit_WC, _fst_WC, _globalAlleleFreq, _heteroTable, StatHandlerBase::_pop, TraitStatHandler< TProtoNeutralGenes, TTNeutralGenesSH >::_SHLinkedTrait, DataTable< T >::get(), TMatrix::get(), TProtoNeutralGenes::get_allele_num(), TProtoNeutralGenes::get_locus_num(), Metapop::getPatchNbr(), setAlleleTables(), setHeteroTable(), and Metapop::size().
Referenced by setAdultsFstatWeirCockerham(), and setOffspringFstatWeirCockerham().
| void TTNeutralGenesSH::setFstatWeirCockerham_MS |
( |
age_t |
AGE | ) |
|
Computes W&C F-stats using the Mean Squares approach, similar to the implementation in Hierfstat. This code gives the exact same results as the other version.
926 double *pop_sizes =
new double [patchNbr];
928 double sum_weights = 0;
930 unsigned int extantPs = 0;
934 for(
unsigned int i = 0; i < patchNbr; i++) {
938 sum_weights += (pop_sizes[i] * pop_sizes[i] / tot_size);
942 nc = (tot_size - sum_weights)/(extantPs-1);
945 unsigned int npl = extantPs;
950 unsigned int *alploc =
new unsigned int [nb_locus];
952 unsigned int **alploc_table =
new unsigned int* [nb_locus];
954 for(
unsigned int i = 0; i < nb_locus; ++i)
955 alploc_table[i] =
new unsigned int[nb_allele];
957 unsigned int tot_num_allele = 0;
959 for(
unsigned int l = 0; l < nb_locus; ++l){
963 for(
unsigned int cnt, a = 0; a < nb_allele; ++a) {
967 for(
unsigned int i = 0; i < patchNbr; i++) {
972 alploc_table[l][a] = (cnt != 0);
973 alploc[l] += (cnt != 0);
976 tot_num_allele += alploc[l];
984 double *SSG =
new double[tot_num_allele];
985 double *SSP =
new double[tot_num_allele];
986 double *SSi =
new double[tot_num_allele];
988 unsigned int all_cntr = 0;
990 double het, freq, var;
992 for(
unsigned int l = 0; l < nb_locus; ++l) {
994 for(
unsigned int a = 0; a < nb_allele & all_cntr < tot_num_allele; ++a) {
996 if(alploc_table[l][a] == 0)
continue;
1002 for(
unsigned int p = 0; p < patchNbr; ++p){
1014 SSG[all_cntr] += het;
1016 SSi[all_cntr] += 2*pop_sizes[p]*freq*(1-freq) - het/2;
1018 SSP[all_cntr] += 2*pop_sizes[p]*var;
1027 assert(all_cntr == tot_num_allele);
1029 double *MSG =
new double[tot_num_allele];
1030 double *MSP =
new double[tot_num_allele];
1031 double *MSI =
new double[tot_num_allele];
1032 double *sigw =
new double[tot_num_allele];
1033 double *siga =
new double[tot_num_allele];
1034 double *sigb =
new double[tot_num_allele];
1039 double SIGA = 0, SIGB = 0, SIGW = 0;
1041 for(
unsigned int i = 0; i < tot_num_allele; ++i){
1043 MSG[i] = SSG[i] / (2 * tot_size);
1046 MSP[i] = SSP[i] / (npl-1);
1048 MSI[i] = SSi[i]/ (tot_size - npl);
1050 sigb[i] = 0.5*(MSI[i] - MSG[i]);
1052 siga[i] = (MSP[i] - MSI[i])/(2*nc);
1067 double lsiga, lsigb, lsigw;
1071 for(
unsigned int allcntr = 0, i = 0; i < nb_locus; ++i) {
1073 lsiga = lsigb = lsigw = 0;
1075 for(
unsigned int l = 0; l < alploc[i]; ++l) {
1077 lsiga += siga[allcntr];
1078 lsigb += sigb[allcntr];
1079 lsigw += sigw[allcntr];
1087 _fit_WC_loc[i] = (lsiga +lsigb) /(lsiga + lsigb + lsigw);
1093 _fst_WC = SIGA / (SIGA + SIGB + SIGW);
1094 _fit_WC = (SIGA + SIGB) / (SIGA + SIGB + SIGW);
1095 _fis_WC = SIGB / (SIGB + SIGW);
1099 for(
unsigned int i = 0; i < nb_locus; ++i)
1100 delete[]alploc_table[i];
1101 delete[]alploc_table;
References _alleleCountTable, _alleleFreqTable, _fis_WC, _fis_WC_loc, _fit_WC, _fit_WC_loc, _fst_WC, _fst_WC_loc, _globalAlleleFreq, _heteroTable, StatHandlerBase::_pop, TraitStatHandler< TProtoNeutralGenes, TTNeutralGenesSH >::_SHLinkedTrait, DataTable< T >::get(), TMatrix::get(), TProtoNeutralGenes::get_allele_num(), TProtoNeutralGenes::get_locus_num(), Metapop::getPatchNbr(), setAlleleTables(), setHeteroTable(), and Metapop::size().
| void TTNeutralGenesSH::setFstMatrix |
( |
age_t |
AGE, |
|
|
unsigned char |
dim |
|
) |
| |
Computes the weighted within and between patch Fst's as well as the overall Fst (Theta).
The method used here is that of Weir & Hill 2002, Ann. Rev. Genet. 36:721-750. The weighting is done for samples (patches) of unequal sizes.
- Parameters
-
| AGE | the age class |
| dim | the dimension of the matrix to fill:
- 1 = the diagonal (i.e. the wihtin patch Fst or theta_ii)
- 2 = the upper half (i.e. the between patch Fst or theta_ii')
- 3 = both
|
743 double *pop_weights =
new double[patchNbr];
744 double *pop_sizes =
new double[patchNbr];
745 double **numerator =
new double*[patchNbr];
746 for(
unsigned int i = 0; i < patchNbr; i++) numerator[i] =
new double [patchNbr];
748 double numerator_W = 0;
749 double denominator = 0;
750 double sum_weights = 0;
754 for(
unsigned int i = 0; i < patchNbr; ++i) {
755 pop_sizes[i] =
_pop->
size(AGE, i) * 2;
756 pop_weights[i] = pop_sizes[i] - (pop_sizes[i] * pop_sizes[i] / tot_size);
757 sum_weights += pop_weights[i];
758 for(
unsigned int j = 0; j < patchNbr; j++)
762 double p, pq, var, num;
764 for (
unsigned int i = 0; i < patchNbr; ++i) {
766 if( !pop_sizes[i] )
continue;
768 for (
unsigned int l = 0; l < nb_locus; ++l) {
770 for (
unsigned int u = 0; u < nb_allele; ++u) {
780 num = pq * pop_sizes[i] / (pop_sizes[i] -1);
782 numerator[i][i] += num;
784 numerator_W += num * pop_sizes[i];
786 denominator += pop_sizes[i] * var + pop_weights[i] * pq;
792 for (
unsigned int i = 0; i < patchNbr; ++i) {
793 if( !pop_sizes[i] )
continue;
794 _fst_matrix->
set(i, i, 1 - (numerator[i][i] * sum_weights / denominator) );
796 _fst_WH = 1 - ((numerator_W * sum_weights) / (denominator * tot_size));
801 for (
unsigned int l = 0; l < nb_locus; ++l)
802 for (
unsigned int u = 0; u < nb_allele; ++u)
803 for (
unsigned int i = 0; i < patchNbr - 1; ++i) {
804 if( !pop_sizes[i] )
continue;
805 for (
unsigned int j = i + 1; j < patchNbr; ++j) {
806 if( !pop_sizes[j] )
continue;
809 numerator[i][j] += pi * (1 - pj) + pj * (1 - pi);
812 for (
unsigned int i = 0; i < patchNbr - 1; ++i){
813 if( !pop_sizes[i] )
continue;
814 for (
unsigned int j = i + 1; j < patchNbr; ++j){
815 if( !pop_sizes[j] )
continue;
816 _fst_matrix->
set(i, j, 1 - ( (numerator[i][j] * sum_weights) / (2 * denominator)) );
822 delete [] pop_weights;
824 for(
unsigned int i = 0; i < patchNbr; i++)
delete [] numerator[i];
void set(unsigned int i, unsigned int j, double val)
Sets element at row i and column j to value val.
Definition: tmatrix.h:103
References _alleleFreqTable, _fst_matrix, _fst_WH, _globalAlleleFreq, StatHandlerBase::_pop, TraitStatHandler< TProtoNeutralGenes, TTNeutralGenesSH >::_SHLinkedTrait, TMatrix::assign(), DataTable< T >::get(), TMatrix::get(), TProtoNeutralGenes::get_allele_num(), TProtoNeutralGenes::get_locus_num(), Metapop::getPatchNbr(), TMatrix::length(), TMatrix::reset(), TMatrix::set(), setAlleleTables(), and Metapop::size().
Referenced by setAdultsFstBetween(), setAdultsFstMatrix(), setAdultsFstWithin(), setOffsprgFstBetween(), setOffsprgFstMatrix(), and setOffsprgFstWithin().
| void TTNeutralGenesSH::setHeteroTable |
( |
age_t |
AGE | ) |
|
206 unsigned int isHetero, a0, a1;
210 unsigned int **sizes;
212 sizes =
new unsigned int * [patchNbr];
214 for(
unsigned int i = 0; i < patchNbr; ++i) {
215 sizes[i] =
new unsigned int [nb_locus];
216 for(
unsigned int j = 0; j < nb_locus; ++j)
217 sizes[i][j] = nb_allele;
224 for (
unsigned int i = 0; i < patchNbr; ++i) {
228 if(!patch->
size(age_pos))
continue;
230 for (
int sx = 0; sx < 2; ++sx) {
232 for(
unsigned int j = 0, size = patch->
size(
sex_t(sx), age_pos); j < size; ++j) {
236 for (
unsigned int l = 0; l < nb_locus; ++l) {
239 isHetero = (a0 != a1);
246 for(
unsigned int i = 0; i < patchNbr; ++i)
delete [] sizes[i];
void plus(unsigned int group, unsigned int Class, unsigned int elmnt, T val)
Adds 'val' to 'elmnt' in the class 'Class' in the group 'group'.
Definition: datatable.h:240
void update(unsigned int nbgroups, unsigned int nbclasses, unsigned int **classSizes)
Updates the group and classe sizes and re-allocates the table according to its new length.
Definition: datatable.h:154
References _heteroTable, StatHandlerBase::_pop, TraitStatHandler< TProtoNeutralGenes, TTNeutralGenesSH >::_SHLinkedTrait, TraitStatHandler< TProtoNeutralGenes, TTNeutralGenesSH >::_SHLinkedTraitIndex, ADLTx, ADULTS, Patch::get(), TTrait::get_allele(), TProtoNeutralGenes::get_allele_num(), TProtoNeutralGenes::get_locus_num(), Metapop::getPatch(), Metapop::getPatchNbr(), DataTable< T >::init(), OFFSx, DataTable< T >::plus(), Patch::size(), and DataTable< T >::update().
Referenced by setFstatWeirCockerham(), setFstatWeirCockerham_MS(), setHeterozygosity(), and TTNeutralGenesFH::write_varcompWC().
| bool TTNeutralGenesSH::setStatRecorders |
( |
std::string & |
token | ) |
|
|
virtual |
Implements StatHandlerBase.
2081 message(
"-TTNeutralGenesSH::setStatRecorders ");
2083 if(token ==
"coa") {
2085 add(
"Wtn Patch Coancestry (offsprg)",
"off.theta",
OFFSPRG,0,0,
2089 add(
"Wtn Patch Coancestry (adult)",
"adlt.theta",
ADULTS,0,0,
2093 }
else if(token ==
"adlt.coa") {
2095 add(
"Wtn Patch Coancestry (adult)",
"adlt.theta",
ADULTS,0,0,
2099 }
else if(token ==
"off.coa") {
2101 add(
"Wtn Patch Coancestry (offsprg)",
"off.theta",
OFFSPRG,0,0,
2105 }
else if(token ==
"adlt.coa.persex") {
2107 add(
"Female Theta (adult)",
"adlt.theta",
ADULTS,0,0,
2113 }
else if(token ==
"adlt.coa.within") {
2115 add(
"Wtn Patch Coancestry (adult)",
"adlt.theta",
ADULTS,0,0,
2118 }
else if(token ==
"off.coa.within") {
2120 add(
"Wtn Patch Coancestry (offsprg)",
"off.theta",
OFFSPRG,0,0,
2123 }
else if(token ==
"adlt.coa.between") {
2125 add(
"Btn Patch Coancestry (adult)",
"adlt.alpha",
ADULTS,0,0,
2128 }
else if(token ==
"off.coa.between") {
2130 add(
"Btn Patch Coancestry (offsprg)",
"off.alpha",
OFFSPRG,0,0,
2133 }
else if(token ==
"coa.matrix") {
2138 }
else if(token ==
"off.coa.matrix") {
2142 }
else if(token ==
"adlt.coa.matrix") {
2146 }
else if(token ==
"coa.matrix.within") {
2151 }
else if(token ==
"off.coa.matrix.within") {
2155 }
else if(token ==
"adlt.coa.matrix.within") {
2159 }
else if(token ==
"sibcoa") {
2161 add(
"Proportion of full-sib offspring",
"prop.fsib",
OFFSPRG,0,0,
2171 }
else if (token ==
"ntrl.freq") {
2176 }
else if (token ==
"off.ntrl.freq") {
2180 }
else if (token ==
"adlt.ntrl.freq") {
2196 }
else if(token ==
"offsprgfstat" || token ==
"off.fstat") {
2200 }
else if(token ==
"adultfstat" || token ==
"adlt.fstat") {
2204 }
else if(token ==
"fstat") {
2208 }
else if(token ==
"off.fstat2") {
2212 }
else if(token ==
"adlt.fstat2") {
2216 }
else if(token ==
"fstat2") {
2220 }
else if(token ==
"fstWC" || token ==
"fstatWC") {
2224 }
else if(token ==
"off.fstWC" || token ==
"off.fstatWC") {
2228 }
else if(token ==
"adlt.fstWC" || token ==
"adlt.fstatWC") {
2232 }
else if(token ==
"weighted.fst") {
2237 }
else if(token ==
"off.weighted.fst") {
2241 }
else if(token ==
"adlt.weighted.fst") {
2245 }
else if(token ==
"weighted.fst.matrix") {
2250 }
else if(token ==
"off.weighted.fst.matrix") {
2254 }
else if(token ==
"adlt.weighted.fst.matrix") {
2258 }
else if(token ==
"weighted.fst.within") {
2263 }
else if(token ==
"off.weighted.fst.within") {
2267 }
else if(token ==
"adlt.weighted.fst.within") {
2271 }
else if(token ==
"adlt.NeiDistance") {
2275 }
else if(token ==
"off.NeiDistance") {
2279 }
else if(token ==
"NeiDistance") {
2284 }
else if(token ==
"mean.NeiDistance") {
2289 }
else if(token ==
"adlt.mean.NeiDistance") {
2293 }
else if(token ==
"off.mean.NeiDistance") {
2297 }
else if(token ==
"Dxy") {
2302 }
else if(token ==
"off.Dxy") {
2306 }
else if(token ==
"adlt.Dxy") {
2310 }
else if(token ==
"Dxy.patch") {
2315 }
else if(token ==
"off.Dxy.patch") {
2319 }
else if(token ==
"adlt.Dxy.patch") {
double getSibCoaMeans(unsigned int i)
Definition: ttneutralgenes.h:538
double getSibProportions(unsigned int i)
Definition: ttneutralgenes.h:537
void setSibStats()
Definition: stats_coa.cc:278
void setDxyRecorders(age_t AGE, bool patchwise)
Definition: ttneutralgenes.cc:2573
void setCoaMatrixRecorders(age_t AGE, unsigned char dim)
Definition: ttneutralgenes.cc:2331
void setFstatRecorders(age_t AGE)
Definition: ttneutralgenes.cc:2419
void setFreqRecorders(age_t AGE)
Definition: ttneutralgenes.cc:2387
double getTheta_FF()
Gives the mean within females coancestry coefficient.
Definition: ttneutralgenes.h:530
double getTheta_MM()
Gives the mean within males coancestry coefficient.
Definition: ttneutralgenes.h:532
double getTheta_FM()
Gives the mean between males and females coancestry coefficient.
Definition: ttneutralgenes.h:534
void setFstatWCRecorders(age_t AGE)
Definition: ttneutralgenes.cc:2475
void setFstMatrixRecorders(age_t AGE, unsigned char dim)
Definition: ttneutralgenes.cc:2495
void setNeiGeneticDistanceRecorders(age_t AGE, bool pairwise)
Definition: ttneutralgenes.cc:2543
void setAdults_Theta()
Definition: stats_coa.cc:202
void setFstat2Recorders(age_t AGE)
Definition: ttneutralgenes.cc:2453
void message(const char *message,...)
Definition: output.cc:40
#define ALL
All ages age class flag.
Definition: types.h:56
References StatHandler< SH >::add(), ADULTS, ALL, getMeanAlpha(), getMeanTheta(), getSibCoaMeans(), getSibProportions(), getTheta_FF(), getTheta_FM(), getTheta_MM(), message(), OFFSPRG, setAdults_Theta(), setAdultsCoaBetween(), setAdultsCoaMatrix(), setAdultsCoaWithin(), setCoaMatrixRecorders(), setDxyRecorders(), setFreqRecorders(), setFstat2Recorders(), setFstatRecorders(), setFstatWCRecorders(), setFstMatrixRecorders(), setNeiGeneticDistanceRecorders(), setOffsprgCoaBetween(), setOffsprgCoaMatrix(), setOffsprgCoaWithin(), and setSibStats().