|
| | 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 (void **ind1, void **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 | ) |
|
82 unsigned char** genes;
95 for(
unsigned int k = 0; k < patchNbr; ++k) {
99 for(
unsigned int i = 0, size = crnt_patch->
size(
FEM, age_pos); i < size; ++i) {
103 for (
unsigned int j = 0; j < nb_locus; ++j)
106 for (
unsigned int j = 0; j < nb_locus; ++j)
111 for(
unsigned int i = 0, size = crnt_patch->
size(
MAL, age_pos); i < size; ++i) {
115 for (
unsigned int j = 0; j < nb_locus; ++j)
118 for (
unsigned int j = 0; j < nb_locus; ++j)
125 for (
unsigned int i = 0; i < patchNbr; ++i) {
131 for (
unsigned int l = 0; l < nb_locus; ++l)
132 for (
unsigned int u = 0; u < nb_allele; ++u)
136 for (
unsigned int l = 0; l < nb_locus; ++l)
137 for (
unsigned int u = 0; u < nb_allele; ++u)
144 unsigned int tot_size =
_pop->
size(AGE) * 2;
148 for(
unsigned int i = 0; i < patchNbr; i++)
149 for (
unsigned int l = 0; l < nb_locus; ++l)
150 for (
unsigned int u = 0; u < nb_allele; ++u)
153 for (
unsigned int l = 0; l < nb_locus; ++l)
154 for (
unsigned int u = 0; u < nb_allele; ++u)
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
References _alleleCountTable, _alleleFreqTable, _globalAlleleFreq, StatHandlerBase::_pop, TraitStatHandler< TProtoNeutralGenes, TTNeutralGenesSH >::_SHLinkedTrait, TraitStatHandler< TProtoNeutralGenes, TTNeutralGenesSH >::_SHLinkedTraitIndex, _table_set_age, _table_set_gen, _table_set_repl, ADLTx, ADULTS, allocateTables(), TMatrix::assign(), TMatrix::divide(), FEM, Patch::get(), DataTable< T >::get(), TProtoNeutralGenes::get_allele_num(), TProtoNeutralGenes::get_locus_num(), TTrait::get_sequence(), Metapop::getCurrentGeneration(), Metapop::getCurrentReplicate(), DataTable< T >::getNumGroups(), Metapop::getPatch(), Metapop::getPatchNbr(), Individual::getTrait(), DataTable< T >::increment(), DataTable< T >::init(), MAL, 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).
256 double harmonic = 0, nbpatch = 0, nbind;
269 for (
unsigned int i = 0; i < patchNbr; ++i){
274 harmonic += 1.0/nbind;
278 harmonic = nbpatch / harmonic;
284 _hsnei = (nbpatch != 0 ? harmonic/(harmonic-1.0)*(
_hs-(
_ho/(2.0*harmonic))) : nanf(
"NULL") );
286 -(
_ho/(2.0*harmonic*nbpatch)) : nanf(
"NULL") );
double setHo(age_idx age_pos)
Definition: stats_fstat.cc:363
double setHt(age_idx age_pos)
Definition: stats_fstat.cc:455
void setLociDivCounter(age_t AGE)
Sets the allelic diversity counters.
Definition: stats_fstat.cc:295
double setHs(age_idx age_pos)
Definition: stats_fstat.cc:410
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.
484 double harmonic = 0, nbpatch = 0, nbind;
498 for (
unsigned int i = 0; i < patchNbr; ++i){
503 harmonic += 1.0/nbind;
507 harmonic = nbpatch / harmonic;
509 deque<double> ho =
setHo2(age_pos);
510 deque<double> hs =
setHs2(age_pos);
511 deque<double> ht =
setHt2(age_pos);
517 for (
unsigned int l = 0; l < nloc; ++l) {
520 hsnei = (nbpatch != 0 ? harmonic/(harmonic-1.0)*(hs[l]-(ho[l]/(2.0*harmonic))) : nanf(
"NULL") );
521 htnei = (nbpatch != 0 ? ht[l] + (hsnei/(harmonic*nbpatch))
522 -(ho[l]/(2.0*harmonic*nbpatch)) : 0 );
530 if(ht[l] == 0) nloc--;
531 _fst += ( ht[l] != 0 ? 1.0-(hsnei/htnei) : 0);
deque< double > setHo2(age_idx age_pos)
Definition: stats_fstat.cc:545
deque< double > setHt2(age_idx age_pos)
Definition: stats_fstat.cc:639
deque< double > setHs2(age_idx age_pos)
Definition: stats_fstat.cc:589
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).
782 double *pop_sizes =
new double [patchNbr];
783 double tot_size, inv_ntot;
784 double sum_weights = 0;
785 double nbar, nc, inv_nbar;
786 unsigned int extantPs = 0;
790 for(
unsigned int i = 0; i < patchNbr; i++) {
794 sum_weights += (pop_sizes[i] * pop_sizes[i] / tot_size);
797 nbar = tot_size/extantPs;
798 nc = (tot_size - sum_weights)/(extantPs-1);
799 inv_nbar = 1/(nbar - 1);
800 inv_ntot = 1/tot_size;
803 double s2, pbar, hbar;
804 double s2_denom = 1.0/((extantPs-1)*nbar),
805 r = (double)(extantPs-1)/extantPs,
806 hbar_factor=(2*nbar-1)/(4*nbar);
807 double a = 0, b = 0, c = 0, x;
809 for (
unsigned int l = 0; l < nb_locus; ++l) {
811 for (
unsigned int u = 0; u < nb_allele; ++u) {
813 s2 = pbar = hbar = 0;
815 for (
unsigned int i = 0; i < patchNbr; ++i) {
821 s2 += var * pop_sizes[i];
831 x = pbar * (1 - pbar) - r * s2;
832 a += s2 - inv_nbar*( x - 0.25 * hbar);
833 b += x - hbar_factor * hbar;
842 b *= nbar/(nbar - 1);
846 _fit_WC = (a + b) / (a + b + c);
void setHeteroTable(age_t AGE)
Definition: stats_fstat.cc:166
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.
867 double *pop_sizes =
new double [patchNbr];
869 double sum_weights = 0;
871 unsigned int extantPs = 0;
875 for(
unsigned int i = 0; i < patchNbr; i++) {
879 sum_weights += (pop_sizes[i] * pop_sizes[i] / tot_size);
883 nc = (tot_size - sum_weights)/(extantPs-1);
886 unsigned int npl = extantPs;
891 unsigned int *alploc =
new unsigned int [nb_locus];
893 unsigned int **alploc_table =
new unsigned int* [nb_locus];
895 for(
unsigned int i = 0; i < nb_locus; ++i)
896 alploc_table[i] =
new unsigned int[nb_allele];
898 unsigned int tot_num_allele = 0;
900 for(
unsigned int l = 0; l < nb_locus; ++l){
904 for(
unsigned int cnt, a = 0; a < nb_allele; ++a) {
908 for(
unsigned int i = 0; i < patchNbr; i++) {
913 alploc_table[l][a] = (cnt != 0);
914 alploc[l] += (cnt != 0);
917 tot_num_allele += alploc[l];
925 double *SSG =
new double[tot_num_allele];
926 double *SSP =
new double[tot_num_allele];
927 double *SSi =
new double[tot_num_allele];
929 unsigned int all_cntr = 0;
931 double het, freq, var;
933 for(
unsigned int l = 0; l < nb_locus; ++l) {
935 for(
unsigned int a = 0; a < nb_allele & all_cntr < tot_num_allele; ++a) {
937 if(alploc_table[l][a] == 0)
continue;
943 for(
unsigned int p = 0; p < patchNbr; ++p){
955 SSG[all_cntr] += het;
957 SSi[all_cntr] += 2*pop_sizes[p]*freq*(1-freq) - het/2;
959 SSP[all_cntr] += 2*pop_sizes[p]*var;
968 assert(all_cntr == tot_num_allele);
970 double *MSG =
new double[tot_num_allele];
971 double *MSP =
new double[tot_num_allele];
972 double *MSI =
new double[tot_num_allele];
973 double *sigw =
new double[tot_num_allele];
974 double *siga =
new double[tot_num_allele];
975 double *sigb =
new double[tot_num_allele];
980 double SIGA = 0, SIGB = 0, SIGW = 0;
982 for(
unsigned int i = 0; i < tot_num_allele; ++i){
984 MSG[i] = SSG[i] / (2 * tot_size);
987 MSP[i] = SSP[i] / (npl-1);
989 MSI[i] = SSi[i]/ (tot_size - npl);
991 sigb[i] = 0.5*(MSI[i] - MSG[i]);
993 siga[i] = (MSP[i] - MSI[i])/(2*nc);
1008 double lsiga, lsigb, lsigw;
1012 for(
unsigned int allcntr = 0, i = 0; i < nb_locus; ++i) {
1014 lsiga = lsigb = lsigw = 0;
1016 for(
unsigned int l = 0; l < alploc[i]; ++l) {
1018 lsiga += siga[allcntr];
1019 lsigb += sigb[allcntr];
1020 lsigw += sigw[allcntr];
1028 _fit_WC_loc[i] = (lsiga +lsigb) /(lsiga + lsigb + lsigw);
1034 _fst_WC = SIGA / (SIGA + SIGB + SIGW);
1035 _fit_WC = (SIGA + SIGB) / (SIGA + SIGB + SIGW);
1036 _fis_WC = SIGB / (SIGB + SIGW);
1040 for(
unsigned int i = 0; i < nb_locus; ++i)
1041 delete[]alploc_table[i];
1042 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
|
684 double *pop_weights =
new double[patchNbr];
685 double *pop_sizes =
new double[patchNbr];
686 double **numerator =
new double*[patchNbr];
687 for(
unsigned int i = 0; i < patchNbr; i++) numerator[i] =
new double [patchNbr];
689 double numerator_W = 0;
690 double denominator = 0;
691 double sum_weights = 0;
695 for(
unsigned int i = 0; i < patchNbr; ++i) {
696 pop_sizes[i] =
_pop->
size(AGE, i) * 2;
697 pop_weights[i] = pop_sizes[i] - (pop_sizes[i] * pop_sizes[i] / tot_size);
698 sum_weights += pop_weights[i];
699 for(
unsigned int j = 0; j < patchNbr; j++)
703 double p, pq, var, num;
705 for (
unsigned int i = 0; i < patchNbr; ++i) {
707 if( !pop_sizes[i] )
continue;
709 for (
unsigned int l = 0; l < nb_locus; ++l) {
711 for (
unsigned int u = 0; u < nb_allele; ++u) {
721 num = pq * pop_sizes[i] / (pop_sizes[i] -1);
723 numerator[i][i] += num;
725 numerator_W += num * pop_sizes[i];
727 denominator += pop_sizes[i] * var + pop_weights[i] * pq;
733 for (
unsigned int i = 0; i < patchNbr; ++i) {
734 if( !pop_sizes[i] )
continue;
735 _fst_matrix->
set(i, i, 1 - (numerator[i][i] * sum_weights / denominator) );
737 _fst_WH = 1 - ((numerator_W * sum_weights) / (denominator * tot_size));
742 for (
unsigned int l = 0; l < nb_locus; ++l)
743 for (
unsigned int u = 0; u < nb_allele; ++u)
744 for (
unsigned int i = 0; i < patchNbr - 1; ++i) {
745 if( !pop_sizes[i] )
continue;
746 for (
unsigned int j = i + 1; j < patchNbr; ++j) {
747 if( !pop_sizes[j] )
continue;
750 numerator[i][j] += pi * (1 - pj) + pj * (1 - pi);
753 for (
unsigned int i = 0; i < patchNbr - 1; ++i){
754 if( !pop_sizes[i] )
continue;
755 for (
unsigned int j = i + 1; j < patchNbr; ++j){
756 if( !pop_sizes[j] )
continue;
757 _fst_matrix->
set(i, j, 1 - ( (numerator[i][j] * sum_weights) / (2 * denominator)) );
763 delete [] pop_weights;
765 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 | ) |
|
172 unsigned int isHetero;
173 unsigned char** genes;
176 unsigned int **sizes;
178 sizes =
new unsigned int * [patchNbr];
180 for(
unsigned int i = 0; i < patchNbr; ++i) {
181 sizes[i] =
new unsigned int [nb_locus];
182 for(
unsigned int j = 0; j < nb_locus; ++j)
183 sizes[i][j] = nb_allele;
190 for (
unsigned int i = 0; i < patchNbr; ++i) {
194 if(!patch->
size(age_pos))
continue;
196 for(
unsigned int j = 0, size = patch->
size(
FEM, age_pos); j < size; ++j) {
200 for (
unsigned int l = 0; l < nb_locus; ++l) {
201 isHetero = (genes[0][l] != genes[1][l]);
207 for(
unsigned int j = 0, size = patch->
size(
MAL, age_pos); j < size; ++j) {
211 for (
unsigned int l = 0; l < nb_locus; ++l) {
212 isHetero = (genes[0][l] != genes[1][l]);
218 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, FEM, Patch::get(), TProtoNeutralGenes::get_allele_num(), TProtoNeutralGenes::get_locus_num(), TTrait::get_sequence(), Metapop::getPatch(), Metapop::getPatchNbr(), Individual::getTrait(), DataTable< T >::init(), MAL, 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.
2106 message(
"-TTNeutralGenesSH::setStatRecorders ");
2108 if(token ==
"coa") {
2110 add(
"Wtn Patch Coancestry (offsprg)",
"off.theta",
OFFSPRG,0,0,
2114 add(
"Wtn Patch Coancestry (adult)",
"adlt.theta",
ADULTS,0,0,
2118 }
else if(token ==
"adlt.coa") {
2120 add(
"Wtn Patch Coancestry (adult)",
"adlt.theta",
ADULTS,0,0,
2124 }
else if(token ==
"off.coa") {
2126 add(
"Wtn Patch Coancestry (offsprg)",
"off.theta",
OFFSPRG,0,0,
2130 }
else if(token ==
"adlt.coa.persex") {
2132 add(
"Female Theta (adult)",
"adlt.theta",
ADULTS,0,0,
2138 }
else if(token ==
"adlt.coa.within") {
2140 add(
"Wtn Patch Coancestry (adult)",
"adlt.theta",
ADULTS,0,0,
2143 }
else if(token ==
"off.coa.within") {
2145 add(
"Wtn Patch Coancestry (offsprg)",
"off.theta",
OFFSPRG,0,0,
2148 }
else if(token ==
"adlt.coa.between") {
2150 add(
"Btn Patch Coancestry (adult)",
"adlt.alpha",
ADULTS,0,0,
2153 }
else if(token ==
"off.coa.between") {
2155 add(
"Btn Patch Coancestry (offsprg)",
"off.alpha",
OFFSPRG,0,0,
2158 }
else if(token ==
"coa.matrix") {
2163 }
else if(token ==
"off.coa.matrix") {
2167 }
else if(token ==
"adlt.coa.matrix") {
2171 }
else if(token ==
"coa.matrix.within") {
2176 }
else if(token ==
"off.coa.matrix.within") {
2180 }
else if(token ==
"adlt.coa.matrix.within") {
2184 }
else if(token ==
"sibcoa") {
2186 add(
"Proportion of full-sib offspring",
"prop.fsib",
OFFSPRG,0,0,
2196 }
else if (token ==
"ntrl.freq") {
2201 }
else if (token ==
"off.ntrl.freq") {
2205 }
else if (token ==
"adlt.ntrl.freq") {
2221 }
else if(token ==
"offsprgfstat" || token ==
"off.fstat") {
2225 }
else if(token ==
"adultfstat" || token ==
"adlt.fstat") {
2229 }
else if(token ==
"fstat") {
2233 }
else if(token ==
"off.fstat2") {
2237 }
else if(token ==
"adlt.fstat2") {
2241 }
else if(token ==
"fstat2") {
2245 }
else if(token ==
"fstWC" || token ==
"fstatWC") {
2249 }
else if(token ==
"off.fstWC" || token ==
"off.fstatWC") {
2253 }
else if(token ==
"adlt.fstWC" || token ==
"adlt.fstatWC") {
2257 }
else if(token ==
"weighted.fst") {
2262 }
else if(token ==
"off.weighted.fst") {
2266 }
else if(token ==
"adlt.weighted.fst") {
2270 }
else if(token ==
"weighted.fst.matrix") {
2275 }
else if(token ==
"off.weighted.fst.matrix") {
2279 }
else if(token ==
"adlt.weighted.fst.matrix") {
2283 }
else if(token ==
"weighted.fst.within") {
2288 }
else if(token ==
"off.weighted.fst.within") {
2292 }
else if(token ==
"adlt.weighted.fst.within") {
2296 }
else if(token ==
"adlt.NeiDistance") {
2300 }
else if(token ==
"off.NeiDistance") {
2304 }
else if(token ==
"NeiDistance") {
2309 }
else if(token ==
"mean.NeiDistance") {
2314 }
else if(token ==
"adlt.mean.NeiDistance") {
2318 }
else if(token ==
"off.mean.NeiDistance") {
2322 }
else if(token ==
"Dxy") {
2327 }
else if(token ==
"off.Dxy") {
2331 }
else if(token ==
"adlt.Dxy") {
2335 }
else if(token ==
"Dxy.patch") {
2340 }
else if(token ==
"off.Dxy.patch") {
2344 }
else if(token ==
"adlt.Dxy.patch") {
double getSibCoaMeans(unsigned int i)
Definition: ttneutralgenes.h:483
double getSibProportions(unsigned int i)
Definition: ttneutralgenes.h:482
void setSibStats()
Definition: stats_coa.cc:279
void setDxyRecorders(age_t AGE, bool patchwise)
Definition: ttneutralgenes.cc:2598
void setCoaMatrixRecorders(age_t AGE, unsigned char dim)
Definition: ttneutralgenes.cc:2356
void setFstatRecorders(age_t AGE)
Definition: ttneutralgenes.cc:2444
void setFreqRecorders(age_t AGE)
Definition: ttneutralgenes.cc:2412
double getTheta_FF()
Gives the mean within females coancestry coefficient.
Definition: ttneutralgenes.h:475
double getTheta_MM()
Gives the mean within males coancestry coefficient.
Definition: ttneutralgenes.h:477
double getTheta_FM()
Gives the mean between males and females coancestry coefficient.
Definition: ttneutralgenes.h:479
void setFstatWCRecorders(age_t AGE)
Definition: ttneutralgenes.cc:2500
void setFstMatrixRecorders(age_t AGE, unsigned char dim)
Definition: ttneutralgenes.cc:2520
void setNeiGeneticDistanceRecorders(age_t AGE, bool pairwise)
Definition: ttneutralgenes.cc:2568
void setAdults_Theta()
Definition: stats_coa.cc:203
void setFstat2Recorders(age_t AGE)
Definition: ttneutralgenes.cc:2478
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().