| 1 |
|
| 2 |
/*************************************************************************** |
| 3 |
distgnt.cpp - Librairie d'objets permettant de manipuler |
| 4 |
des distances entre populations |
| 5 |
------------------- |
| 6 |
begin : ven sep 01 10:25:55 CEST 2000 |
| 7 |
copyright : (C) 2000 by Olivier Langella CNRS UPR9034 |
| 8 |
email : [email protected] |
| 9 |
***************************************************************************/ |
| 10 |
|
| 11 |
/*************************************************************************** |
| 12 |
* * |
| 13 |
* This program is free software; you can redistribute it and/or modify * |
| 14 |
* it under the terms of the GNU General Public License as published by * |
| 15 |
* the Free Software Foundation; either version 2 of the License, or * |
| 16 |
* (at your option) any later version. * |
| 17 |
* * |
| 18 |
***************************************************************************/ |
| 19 |
#include "distgnt.h" |
| 20 |
#include "arbreplus.h" |
| 21 |
|
| 22 |
|
| 23 |
vector<string> DistancesGnt::_tab_noms_methodes; |
| 24 |
|
| 25 |
DistancesGnt::DistancesGnt(int methode, bool square_distance, Jeupop * Pjeupop, unsigned int niveau) { |
| 26 |
//cerr << "DistancesGnt::DistancesGnt debut" << endl; |
| 27 |
unsigned long j; |
| 28 |
|
| 29 |
_methode = methode; |
| 30 |
_Pjeupop = Pjeupop; |
| 31 |
|
| 32 |
if ((niveau == 100) & (Pjeupop->_VcalcStrucPop.size() >0)) { |
| 33 |
//stuct pop level is already defined |
| 34 |
} |
| 35 |
else {Pjeupop->f_rempliVcalcStrucPop(niveau); |
| 36 |
} |
| 37 |
|
| 38 |
_tabPstrucpop = Pjeupop->_VcalcStrucPop; |
| 39 |
|
| 40 |
_tabPloc = Pjeupop->_tabPloc; |
| 41 |
_nbpop = Pjeupop->get_nbstrucpopVcalc(); |
| 42 |
_PtabFreq = 0; |
| 43 |
_PtabMu = 0; |
| 44 |
_tabEviteLocus = 0; |
| 45 |
_squareDistance = square_distance; |
| 46 |
_pi = ((long double) acos((double)-1)); |
| 47 |
// _tabNbAll = 0; |
| 48 |
|
| 49 |
_nbloc = Pjeupop->get_nbloc(); |
| 50 |
_tabNbAll = new unsigned long [_nbloc]; |
| 51 |
|
| 52 |
_bootind = false; |
| 53 |
|
| 54 |
for (j=0; j < _nbloc; j++) { |
| 55 |
_tabNbAll[j] = _tabPloc[j]->get_nball(); |
| 56 |
} |
| 57 |
//cerr << "DistancesGnt::DistancesGnt fin" << endl; |
| 58 |
} |
| 59 |
|
| 60 |
DistancesGnt::~DistancesGnt() { |
| 61 |
if (_tabNbAll != 0) delete[] _tabNbAll; |
| 62 |
if (_PtabFreq != 0) { |
| 63 |
delete[] _PtabFreq[0]; |
| 64 |
delete[] _PtabFreq; |
| 65 |
} |
| 66 |
if (_PtabMu != 0) { |
| 67 |
delete[] _PtabMu; |
| 68 |
} |
| 69 |
if (_tabEviteLocus != 0) delete[] _tabEviteLocus; |
| 70 |
|
| 71 |
// _nbloc = Pjeupop->get_nbloc(); |
| 72 |
} |
| 73 |
|
| 74 |
long double DistancesGnt::r_allsimilnul(Individu * pind1, Individu * pind2) const{ |
| 75 |
//Calcul de la similarit� entre deux individus |
| 76 |
//valable pour nploides |
| 77 |
Vecteur<Allele*> tabPall1;//, tabPallNuls; |
| 78 |
long pos;//, nballnuls(0); |
| 79 |
unsigned long allele, taille, nb_all_communs(0); |
| 80 |
unsigned long j, i; |
| 81 |
unsigned long nploidie(_Pjeupop->get_nploidie()); |
| 82 |
unsigned long nb_all_comparables(0); |
| 83 |
unsigned long nblocus(_VcalcLocus.size()); |
| 84 |
|
| 85 |
taille = nblocus * nploidie; |
| 86 |
|
| 87 |
for (j = 0 ; j < nblocus; j++) { |
| 88 |
i = pind1->get_nballnuls(_VcalcLocus[j]); |
| 89 |
if (pind2->get_nballnuls(_VcalcLocus[j]) > i) i = pind2->get_nballnuls(_VcalcLocus[j]); |
| 90 |
nb_all_comparables += nploidie - i; |
| 91 |
} |
| 92 |
if (nb_all_comparables == 0) { |
| 93 |
throw Jeupop::Anomalie(6); |
| 94 |
return (0); |
| 95 |
} |
| 96 |
|
| 97 |
//cerr << nb_all_comparables << " "; |
| 98 |
|
| 99 |
for (j = 0 ; j < nblocus; j++) { |
| 100 |
for (i = 0; i < nploidie; i++) { |
| 101 |
allele = (_VcalcLocus[j] * nploidie) + i; |
| 102 |
if (pind1->_tabPall[allele]->_miss) {} |
| 103 |
else tabPall1.push_back(pind1->_tabPall[allele]); |
| 104 |
} |
| 105 |
} |
| 106 |
|
| 107 |
//cerr << pind1->get_nom() << " " << pind2->get_nom() << endl; |
| 108 |
for (j = 0 ; j < nblocus; j++) { |
| 109 |
for (i = 0; i < nploidie; i++) { |
| 110 |
allele = (_VcalcLocus[j] * nploidie) + i; |
| 111 |
if (pind2->_tabPall[allele]->_miss) {} |
| 112 |
else { |
| 113 |
pos = tabPall1.Position(pind2->_tabPall[allele]); |
| 114 |
if (pos != -1) { |
| 115 |
// cerr << pind2->_tabPall[allele]->get_Nom() << " " << tabPall1[pos]->get_Nom() << endl; |
| 116 |
|
| 117 |
nb_all_communs++; |
| 118 |
tabPall1.Suppr(pos); |
| 119 |
} |
| 120 |
} |
| 121 |
} |
| 122 |
} |
| 123 |
//cerr << nb_all_communs << " " << nb_all_comparables << endl; |
| 124 |
return ((long double) nb_all_communs / (long double) nb_all_comparables); |
| 125 |
} |
| 126 |
|
| 127 |
long double DistancesGnt::r_dist2ind(unsigned long nbind1, unsigned long nbind2) const { |
| 128 |
//renvoi de la distance |
| 129 |
long double resultat(0); |
| 130 |
// int Smoy(get_nbloc()), nball; |
| 131 |
// int nbloc(get_nbloc()); |
| 132 |
// long i; |
| 133 |
|
| 134 |
switch (_methode) { |
| 135 |
case 5: |
| 136 |
//methode simple correct: moyenne de ressemblance |
| 137 |
//sur population nploide |
| 138 |
// 0 allele en commun => 1 |
| 139 |
// 1 allele en commun => 0.5 |
| 140 |
// 2 alleles en commun => 0 |
| 141 |
// ne fait pas de calcul sur les all�les 00 && 00 |
| 142 |
// applique 0.5 pour 0001 avec 0101 ou 0103 |
| 143 |
// et 0 pour 0001 avec 0302 |
| 144 |
// ATTENTION pour les donn�es manquantes: la similitude est maximisee |
| 145 |
resultat = (double) 1 - (double) r_allsimilnul(_tabPind[nbind1], _tabPind[nbind2]); |
| 146 |
//cerr << r_allsimilnul(pind1, pind2) << endl; |
| 147 |
break; |
| 148 |
default: |
| 149 |
resultat = r_dist2pop(nbind1, nbind2); |
| 150 |
break; |
| 151 |
} |
| 152 |
|
| 153 |
return resultat; |
| 154 |
} |
| 155 |
|
| 156 |
long double DistancesGnt::r_distDasPsAi(unsigned long nbind1, unsigned long nbind2) const { |
| 157 |
return (r_distDasPsAi(_tabPind[nbind1], _tabPind[nbind2])); |
| 158 |
} |
| 159 |
|
| 160 |
long double DistancesGnt::r_distDasPsAi(const Individu * Pind1, const Individu * Pind2) const { |
| 161 |
//Calcul de la similarit� entre deux individus (Das) |
| 162 |
//valable pour nploides |
| 163 |
Vecteur<Allele*> tabPall1;//, tabPallNuls; |
| 164 |
long pos;//, nballnuls(0); |
| 165 |
unsigned long allele, taille, nb_all_communs(0); |
| 166 |
unsigned long j, i; |
| 167 |
unsigned long nploidie(_Pjeupop->get_nploidie()); |
| 168 |
unsigned long nb_all_comparables(0); |
| 169 |
unsigned long nblocus(_VcalcLocus.size()); |
| 170 |
|
| 171 |
taille = nblocus * nploidie; |
| 172 |
|
| 173 |
for (j = 0 ; j < nblocus; j++) { |
| 174 |
i = Pind1->get_nballnuls(_VcalcLocus[j]); |
| 175 |
if (Pind2->get_nballnuls(_VcalcLocus[j]) > i) i = Pind2->get_nballnuls(_VcalcLocus[j]); |
| 176 |
nb_all_comparables += nploidie - i; |
| 177 |
} |
| 178 |
if (nb_all_comparables == 0) { |
| 179 |
throw Jeupop::Anomalie(6); |
| 180 |
return (0); |
| 181 |
} |
| 182 |
|
| 183 |
//cerr << nb_all_comparables << " "; |
| 184 |
|
| 185 |
for (j = 0 ; j < nblocus; j++) { |
| 186 |
for (i = 0; i < nploidie; i++) { |
| 187 |
allele = (_VcalcLocus[j] * nploidie) + i; |
| 188 |
if (Pind1->_tabPall[allele]->_miss) {} |
| 189 |
else tabPall1.push_back(Pind1->_tabPall[allele]); |
| 190 |
} |
| 191 |
} |
| 192 |
|
| 193 |
//cerr << pind1->get_nom() << " " << pind2->get_nom() << endl; |
| 194 |
for (j = 0 ; j < nblocus; j++) { |
| 195 |
for (i = 0; i < nploidie; i++) { |
| 196 |
allele = (_VcalcLocus[j] * nploidie) + i; |
| 197 |
if (Pind2->_tabPall[allele]->_miss) {} |
| 198 |
else { |
| 199 |
pos = tabPall1.Position(Pind2->_tabPall[allele]); |
| 200 |
if (pos != -1) { |
| 201 |
// cerr << pind2->_tabPall[allele]->get_Nom() << " " << tabPall1[pos]->get_Nom() << endl; |
| 202 |
|
| 203 |
nb_all_communs++; |
| 204 |
tabPall1.Suppr(pos); |
| 205 |
} |
| 206 |
} |
| 207 |
} |
| 208 |
} |
| 209 |
//cerr << nb_all_communs << " " << nb_all_comparables << endl; |
| 210 |
return ((long double) nb_all_communs / (long double) nb_all_comparables); |
| 211 |
} |
| 212 |
|
| 213 |
|
| 214 |
long double DistancesGnt::r_dist2ind(Individu* Pind1, Individu* Pind2) const { |
| 215 |
//renvoi de la distance |
| 216 |
long double resultat(0); |
| 217 |
|
| 218 |
switch (_methode) { |
| 219 |
case 5: |
| 220 |
//methode simple correct: moyenne de ressemblance |
| 221 |
//sur population nploide |
| 222 |
// 0 allele en commun => 1 |
| 223 |
// 1 allele en commun => 0.5 |
| 224 |
// 2 alleles en commun => 0 |
| 225 |
// ne fait pas de calcul sur les all�les 00 && 00 |
| 226 |
// applique 0.5 pour 0001 avec 0101 ou 0103 |
| 227 |
// et 0 pour 0001 avec 0302 |
| 228 |
// ATTENTION pour les donn�es manquantes: la similitude est maximisee |
| 229 |
resultat = (double) 1 - (double) r_allsimilnul(Pind1,Pind2); |
| 230 |
//cerr << r_allsimilnul(pind1, pind2) << endl; |
| 231 |
break; |
| 232 |
} |
| 233 |
|
| 234 |
return resultat; |
| 235 |
} |
| 236 |
|
| 237 |
void DistancesGnt::newTabFreq() { |
| 238 |
//calcul et stockage des frequences alleliques |
| 239 |
// tabPfreq contient les adresses de tableaux de frequences |
| 240 |
// tabNbAll contient le nombre d'alleles a chaque locus |
| 241 |
// _tabEviteLocus contient les locus � �viter (qui ne contiennent que des all�les nuls) |
| 242 |
|
| 243 |
unsigned long i, j; |
| 244 |
unsigned long indice(0); |
| 245 |
|
| 246 |
//cerr << "coucou newTabFreq" <<endl ; |
| 247 |
if (_PtabFreq != 0) { |
| 248 |
delete[] _PtabFreq[0]; |
| 249 |
delete[] _PtabFreq; |
| 250 |
_PtabFreq = 0; |
| 251 |
} |
| 252 |
if (_tabEviteLocus != 0) { |
| 253 |
delete[] _tabEviteLocus; |
| 254 |
_tabEviteLocus = 0; |
| 255 |
} |
| 256 |
|
| 257 |
_PtabFreq = new long double * [_nbloc * _nbpop]; |
| 258 |
_tabEviteLocus = new bool [_nbloc * _nbpop]; |
| 259 |
|
| 260 |
for (j=0; j < _nbloc; j++) { |
| 261 |
indice += _tabNbAll[j]; |
| 262 |
} |
| 263 |
|
| 264 |
long double* adresse; |
| 265 |
adresse = new long double[_nbloc * _nbpop * indice]; |
| 266 |
|
| 267 |
indice = 0; |
| 268 |
for (i=0; i < _nbpop; i++) { |
| 269 |
for (j=0; j < _nbloc; j++) { |
| 270 |
_tabEviteLocus[indice] = false; |
| 271 |
|
| 272 |
_PtabFreq[indice] = adresse; |
| 273 |
adresse += _tabNbAll[j]; |
| 274 |
indice++; |
| 275 |
} |
| 276 |
} |
| 277 |
} |
| 278 |
|
| 279 |
void DistancesGnt::newTabFreqTot() { |
| 280 |
//fr�quence des all�les � chaque locus sur toutes les pops |
| 281 |
//�a ne sert pas pour l'instant (26/02/2002) |
| 282 |
unsigned long i; |
| 283 |
unsigned long nballtot(0); |
| 284 |
|
| 285 |
newTabFreq(); |
| 286 |
|
| 287 |
for (i=0; i < _nbloc; i++) { |
| 288 |
nballtot += _tabNbAll[i]; |
| 289 |
} |
| 290 |
|
| 291 |
if (_PtabFreqTot != 0) { |
| 292 |
delete[] _PtabFreqTot; |
| 293 |
_PtabFreqTot = 0; |
| 294 |
} |
| 295 |
/* |
| 296 |
if (_tabEviteLocus != 0) { |
| 297 |
delete[] _tabEviteLocus; |
| 298 |
_tabEviteLocus = 0; |
| 299 |
} |
| 300 |
*/ |
| 301 |
_PtabFreqTot = new long double [nballtot]; |
| 302 |
//_tabEviteLocus = new (bool [_nbloc * _nbpop]); |
| 303 |
//for (i=0; i < (_nbloc * _nbpop); i++) _tabEviteLocus[i] = false; |
| 304 |
} |
| 305 |
|
| 306 |
void DistancesGnt::newTabMu() { |
| 307 |
unsigned long i; |
| 308 |
|
| 309 |
if (_PtabMu != 0) { |
| 310 |
delete[] _PtabMu; |
| 311 |
_PtabMu = 0; |
| 312 |
} |
| 313 |
if (_tabEviteLocus != 0) { |
| 314 |
delete[] _tabEviteLocus; |
| 315 |
_tabEviteLocus = 0; |
| 316 |
} |
| 317 |
|
| 318 |
_PtabMu = new long double [_nbloc * _nbpop]; |
| 319 |
_tabEviteLocus = new bool [_nbloc * _nbpop]; |
| 320 |
for (i=0; i < (_nbloc * _nbpop); i++) _tabEviteLocus[i] = false; |
| 321 |
} |
| 322 |
|
| 323 |
void DistancesGnt::newTabMuInd() { |
| 324 |
unsigned long i; |
| 325 |
|
| 326 |
if (_PtabMu != 0) { |
| 327 |
delete[] _PtabMu; |
| 328 |
_PtabMu = 0; |
| 329 |
} |
| 330 |
if (_tabEviteLocus != 0) { |
| 331 |
delete[] _tabEviteLocus; |
| 332 |
_tabEviteLocus = 0; |
| 333 |
} |
| 334 |
|
| 335 |
_PtabMu = new long double [_nbloc * _tabPind.size()]; |
| 336 |
_tabEviteLocus = new bool [_nbloc * _tabPind.size()]; |
| 337 |
for (i=0; i < (_nbloc * _tabPind.size()); i++) _tabEviteLocus[i] = false; |
| 338 |
} |
| 339 |
|
| 340 |
void DistancesGnt::newTabFreqInd() { |
| 341 |
//calcul et stockage des frequences alleliques |
| 342 |
//pour chaque individus |
| 343 |
// tabPfreq contient les adresses de tableaux de frequences |
| 344 |
// tabNbAll contient le nombre d'alleles a chaque locus |
| 345 |
// _tabEviteLocus contient les locus � �viter (qui ne contiennent que des all�les nuls) |
| 346 |
|
| 347 |
unsigned long nbind(_tabPind.size()); |
| 348 |
unsigned long i, j, indice(0); |
| 349 |
|
| 350 |
if (_PtabFreq != 0) { |
| 351 |
delete[] _PtabFreq[0]; |
| 352 |
delete[] _PtabFreq; |
| 353 |
_PtabFreq = 0; |
| 354 |
} |
| 355 |
if (_tabEviteLocus != 0) { |
| 356 |
delete[] _tabEviteLocus; |
| 357 |
_tabEviteLocus = 0; |
| 358 |
} |
| 359 |
|
| 360 |
//cerr << "coucou newTabFreq" <<endl ; |
| 361 |
_PtabFreq = new long double * [_nbloc * nbind]; |
| 362 |
_tabEviteLocus = new bool [_nbloc * nbind]; |
| 363 |
|
| 364 |
for (j=0; j < _nbloc; j++) { |
| 365 |
indice += _tabNbAll[j]; |
| 366 |
} |
| 367 |
|
| 368 |
long double * adresse; |
| 369 |
adresse = new long double[_nbloc * nbind * indice]; |
| 370 |
|
| 371 |
indice = 0; |
| 372 |
for (i=0; i < nbind; i++) { |
| 373 |
for (j=0; j < _nbloc; j++) { |
| 374 |
_tabEviteLocus[indice] = false; |
| 375 |
|
| 376 |
_PtabFreq[indice] = adresse; |
| 377 |
adresse += _tabNbAll[j]; |
| 378 |
indice++; |
| 379 |
} |
| 380 |
} |
| 381 |
} |
| 382 |
|
| 383 |
void DistancesGnt::f_bootstrapLocus(Arbre &arbreRef, int methodeArbre, unsigned int nbrepet, Vecteur<unsigned int> * PVcalcLocusRef, bool sur_ind) { |
| 384 |
// Boostrap sur les locus |
| 385 |
// ********creer des exceptions pour v�rifier l'arbreRef ********* |
| 386 |
unsigned long i, j; |
| 387 |
unsigned int tirage; |
| 388 |
MatriceLD distancesRef; |
| 389 |
unsigned long nbLocus(PVcalcLocusRef->size()); |
| 390 |
Arbre bootArbre; |
| 391 |
MatriceLD distancesBoot; |
| 392 |
unsigned long taillemat; |
| 393 |
|
| 394 |
// calcul de l'arbre de r�f�rence arbreRef |
| 395 |
// arbreRef => arbre vide !!! |
| 396 |
//ofstream sortie_test; |
| 397 |
//sortie_test.open("test_boot", ios::out); |
| 398 |
|
| 399 |
|
| 400 |
cerr << "distances ref:"; |
| 401 |
if (sur_ind) f_distgntInd(distancesRef, PVcalcLocusRef); |
| 402 |
else f_distgntpop(distancesRef, PVcalcLocusRef); |
| 403 |
cerr << "+"<< endl; |
| 404 |
|
| 405 |
cerr << "arbre ref:"; |
| 406 |
arbreRef.f_forceiDistances(distancesRef,methodeArbre); |
| 407 |
// arbreRef.iDistances(distancesRef,methodeArbre); |
| 408 |
cerr << "+"<< endl; |
| 409 |
//_tabPOtu de arbre est cree avec les titres des lignes |
| 410 |
// de la matrice, dans le meme ordre |
| 411 |
//cerr << "sortie du fichier" << endl; |
| 412 |
//sortie_test << arbreRef << endl; |
| 413 |
|
| 414 |
|
| 415 |
srand ((unsigned) time( NULL ) ); |
| 416 |
|
| 417 |
taillemat = distancesRef.GetNC(); |
| 418 |
distancesBoot.resize(taillemat, taillemat); |
| 419 |
distancesBoot.SetType(2); |
| 420 |
distancesBoot.SetFlag(1); |
| 421 |
for (j = 0; j < taillemat; j++) { |
| 422 |
distancesBoot._tcol[j] = distancesBoot._tlig[j] = distancesRef._tcol[j]; |
| 423 |
} |
| 424 |
//cerr << distancesBoot._tcol[1] << endl; |
| 425 |
//cerr << distancesRef._tcol[1] << endl; |
| 426 |
|
| 427 |
// arbreRef.fRempliTabNumOtusNoeuds(); |
| 428 |
// arbreRef.f_load_vectind(); |
| 429 |
arbreRef.f_load_vect_id_ind(); |
| 430 |
|
| 431 |
for (i = 0; i < nbrepet; i ++ ) { //boucle du bootstrap |
| 432 |
|
| 433 |
cerr <<endl; // tirage des locus |
| 434 |
for (j = 0; j < nbLocus; j ++ ) { |
| 435 |
tirage = (unsigned int) (nbLocus * ((long double)rand() / ((long double) RAND_MAX))); |
| 436 |
_VcalcLocus[j] = PVcalcLocusRef->operator[](tirage); |
| 437 |
} |
| 438 |
|
| 439 |
cerr <<endl; |
| 440 |
cerr << "tirage: " << i+1 << " sur: " << nbrepet << endl; |
| 441 |
cerr << "distances:"; |
| 442 |
// calcul de distances |
| 443 |
if (sur_ind) f_distgntIndVcalc(distancesBoot._tab); |
| 444 |
else f_distgntpopVcalc(distancesBoot._tab); |
| 445 |
|
| 446 |
cerr << "+"<< endl; |
| 447 |
cerr << "arbre:"; |
| 448 |
|
| 449 |
// construction de l'arbre � examiner |
| 450 |
bootArbre.f_forceiDistances(distancesBoot,100 + methodeArbre); |
| 451 |
// bootArbre.iDistances(distancesBoot,100 + methodeArbre); |
| 452 |
cerr << "+"<< endl; |
| 453 |
cerr << "ajboot:"; |
| 454 |
|
| 455 |
//cout << endl << bootArbre << endl; |
| 456 |
//cerr << "sortie du fichier" << endl; |
| 457 |
//sortie_test << bootArbre << endl; |
| 458 |
|
| 459 |
|
| 460 |
// comparaison avec l'arbre de r�f�rence |
| 461 |
arbreRef.AjBootstrap(bootArbre); |
| 462 |
cerr << "+"<< endl; |
| 463 |
//cerr << "sortie du fichier" << endl; |
| 464 |
//sortie_test << arbreRef << endl; |
| 465 |
|
| 466 |
}// fin de boucle du bootstrap |
| 467 |
//sortie_test.close(); |
| 468 |
|
| 469 |
arbreRef.fCalcValBootstrap(); |
| 470 |
} |
| 471 |
|
| 472 |
void DistancesGnt::f_bootstrapIndividus(Arbre &arbreRef, int methodeArbre, unsigned int nbrepet, Vecteur<unsigned int> * PVcalcLocusRef) { |
| 473 |
// Boostrap sur les individus |
| 474 |
// ********creer des exceptions pour v�rifier l'arbreRef ********* |
| 475 |
unsigned long i, j; |
| 476 |
MatriceLD distancesRef; |
| 477 |
Arbre bootArbre; |
| 478 |
MatriceLD distancesBoot; |
| 479 |
|
| 480 |
// calcul de l'arbre de r�f�rence arbreRef |
| 481 |
// arbreRef => arbre vide !!! |
| 482 |
_bootind = false; |
| 483 |
|
| 484 |
cerr << "distances ref:"; |
| 485 |
f_distgntpop(distancesRef, PVcalcLocusRef); |
| 486 |
cerr << "+"<< endl; |
| 487 |
|
| 488 |
cerr << "arbre ref:"; |
| 489 |
arbreRef.f_forceiDistances(distancesRef,methodeArbre); |
| 490 |
// bootArbre.iDistances(distancesRef,methodeArbre); |
| 491 |
cerr << "+"<< endl; |
| 492 |
//_tabPOtu de arbre est cree avec les titres des lignes |
| 493 |
// de la matrice, dans le meme ordre |
| 494 |
|
| 495 |
|
| 496 |
srand ((unsigned) time( NULL ) ); |
| 497 |
_bootind = true; |
| 498 |
|
| 499 |
distancesBoot.resize(_nbpop, _nbpop); |
| 500 |
distancesBoot.SetType(2); |
| 501 |
distancesBoot.SetFlag(1); |
| 502 |
for (j = 0; j < _nbpop; j++) { |
| 503 |
distancesBoot._tcol[j] = distancesBoot._tlig[j] = _tabPstrucpop[j]->get_nom(); |
| 504 |
} |
| 505 |
//cerr << distancesBoot._tcol[1] << endl; |
| 506 |
//cerr << distancesRef._tcol[1] << endl; |
| 507 |
|
| 508 |
// arbreRef.fRempliTabNumOtusNoeuds(); |
| 509 |
//cerr << "DistancesGnt::f_bootstrapIndividus top1" <<endl; |
| 510 |
// arbreRef.f_load_vectind(); |
| 511 |
arbreRef.f_load_vect_id_ind(); |
| 512 |
//cerr << "DistancesGnt::f_bootstrapIndividus top2" <<endl; |
| 513 |
|
| 514 |
for (i = 0; i < nbrepet; i ++ ) { //boucle du bootstrap |
| 515 |
|
| 516 |
cerr <<endl; |
| 517 |
|
| 518 |
cerr <<endl; |
| 519 |
cerr << "tirage: " << i+1 << " sur: " << nbrepet << endl; |
| 520 |
cerr << "distances:"; |
| 521 |
// calcul de distances |
| 522 |
f_distgntpopVcalc(distancesBoot._tab); |
| 523 |
|
| 524 |
cerr << "+"<< endl; |
| 525 |
cerr << "arbre:"; |
| 526 |
|
| 527 |
// construction de l'arbre � examiner |
| 528 |
bootArbre.f_forceiDistances(distancesBoot,100 + methodeArbre); |
| 529 |
// bootArbre.iDistances(distancesBoot,100 + methodeArbre); |
| 530 |
cerr << "+"<< endl; |
| 531 |
cerr << "ajboot: "; |
| 532 |
|
| 533 |
//cout << endl << bootArbre << endl; |
| 534 |
|
| 535 |
// comparaison avec l'arbre de r�f�rence |
| 536 |
arbreRef.AjBootstrap(bootArbre); |
| 537 |
cerr << "+"<< endl; |
| 538 |
|
| 539 |
}// fin de boucle du bootstrap |
| 540 |
|
| 541 |
arbreRef.fCalcValBootstrap(); |
| 542 |
} |
| 543 |
|
| 544 |
void DistancesGnt::f_distgntpop (MatriceLD &resultat, Vecteur<unsigned int> *PVcalcLocus) { |
| 545 |
//distances G�n�tiques entre Populations |
| 546 |
unsigned long i; |
| 547 |
// pr�paration de _VcalcLoc: |
| 548 |
_VcalcLocus = *PVcalcLocus; |
| 549 |
|
| 550 |
biolib::vecteurs::ChaineCar mot; |
| 551 |
|
| 552 |
resultat.resize(_nbpop, _nbpop); |
| 553 |
resultat._titre.push_back(_("Genetic distances on ")); |
| 554 |
mot.AjEntier(_nbpop); |
| 555 |
|
| 556 |
resultat._titre[resultat._titre.size() - 1] += mot; |
| 557 |
resultat._titre[resultat._titre.size() - 1] += " populations"; |
| 558 |
|
| 559 |
resultat._titre.push_back(get_nom_methode(_methode)); |
| 560 |
if (_squareDistance) resultat._titre[resultat._titre.size() - 1] += _(" (squared distances)"); |
| 561 |
|
| 562 |
switch (_methode) { |
| 563 |
case 5: |
| 564 |
break; |
| 565 |
case 101: |
| 566 |
// stockage des fr�quences |
| 567 |
newTabFreq(); |
| 568 |
f_calcTabFreq(); |
| 569 |
break; |
| 570 |
case 102: |
| 571 |
// stockage des fr�quences |
| 572 |
newTabFreq(); |
| 573 |
f_calcTabFreq(); |
| 574 |
break; |
| 575 |
case 103: |
| 576 |
// stockage des fr�quences |
| 577 |
newTabFreq(); |
| 578 |
f_calcTabFreq(); |
| 579 |
break; |
| 580 |
case 104: |
| 581 |
// stockage des fr�quences |
| 582 |
newTabFreq(); |
| 583 |
f_calcTabFreq(); |
| 584 |
break; |
| 585 |
case 106: |
| 586 |
// stockage des Mu |
| 587 |
newTabMu(); |
| 588 |
f_calcTabMu(); |
| 589 |
break; |
| 590 |
case 107: |
| 591 |
// stockage des fr�quences |
| 592 |
newTabFreq(); |
| 593 |
f_calcTabFreq(); |
| 594 |
break; |
| 595 |
case 108: |
| 596 |
// stockage des fr�quences |
| 597 |
newTabFreq(); |
| 598 |
f_calcTabFreq(); |
| 599 |
break; |
| 600 |
case 109: |
| 601 |
// stockage des fr�quences |
| 602 |
newTabFreq(); |
| 603 |
f_calcTabFreq(); |
| 604 |
break; |
| 605 |
case 110: |
| 606 |
// stockage des fr�quences |
| 607 |
newTabFreq(); |
| 608 |
f_calcTabFreq(); |
| 609 |
break; |
| 610 |
case 111: |
| 611 |
// stockage des fr�quences |
| 612 |
newTabFreq(); |
| 613 |
f_calcTabFreq(); |
| 614 |
break; |
| 615 |
case 112: |
| 616 |
// stockage des Mu |
| 617 |
newTabMu(); |
| 618 |
f_calcTabMu(); |
| 619 |
break; |
| 620 |
case 113: |
| 621 |
// stockage des fr�quences |
| 622 |
newTabFreq(); |
| 623 |
f_calcTabFreq(); |
| 624 |
break; |
| 625 |
case 114: |
| 626 |
// stockage des fr�quences |
| 627 |
newTabFreq(); |
| 628 |
f_calcTabFreq(); |
| 629 |
break; |
| 630 |
case 115: |
| 631 |
// stockage des fr�quences |
| 632 |
newTabFreq(); |
| 633 |
f_calcTabFreq(); |
| 634 |
break; |
| 635 |
default: |
| 636 |
break; |
| 637 |
} |
| 638 |
resultat.SetType(2); |
| 639 |
resultat.SetFlag(1); //titres sur les lignes |
| 640 |
|
| 641 |
for (i = 0; i < _nbpop; i++) { |
| 642 |
resultat._tcol[i] = resultat._tlig[i] = _tabPstrucpop[i]->get_nom(); |
| 643 |
} |
| 644 |
|
| 645 |
f_distgntpopVcalc (resultat._tab); |
| 646 |
// try { |
| 647 |
// f_distgntpopVcalc (resultat._tab); |
| 648 |
// } |
| 649 |
// catch (Anomalie lepb) { |
| 650 |
// cerr << endl << lepb.fmessage(lepb.le_pb) << endl; |
| 651 |
// } |
| 652 |
} |
| 653 |
|
| 654 |
void DistancesGnt::f_distgntInd (MatriceLD &resultat, Vecteur<unsigned int> *PVcalcLocus) { |
| 655 |
// _VcalcLocus.resize(PVcalcLocus->size()); |
| 656 |
_VcalcLocus = *PVcalcLocus; |
| 657 |
|
| 658 |
//cerr << "f_distgntIndVcalc deb" << endl; |
| 659 |
|
| 660 |
unsigned long i, k, nbind; //(_Pjeupop->get_nbind()); |
| 661 |
unsigned long j; |
| 662 |
biolib::vecteurs::ChaineCar mot; |
| 663 |
//vector<Individu*> tabPind; |
| 664 |
nbind = get_nbind(); |
| 665 |
|
| 666 |
_tabPind.resize(nbind); |
| 667 |
|
| 668 |
resultat.resize(nbind, nbind); |
| 669 |
resultat._titre.push_back(_("Genetic distances on ")); |
| 670 |
resultat._titre[resultat._titre.size() - 1].AjEntier(nbind); // += mot; |
| 671 |
resultat._titre[resultat._titre.size() - 1] += _(" individuals"); |
| 672 |
|
| 673 |
resultat._titre.push_back(get_nom_methode(_methode)); |
| 674 |
if (_squareDistance) resultat._titre[resultat._titre.size() - 1] += _(" (squared distances)"); |
| 675 |
|
| 676 |
resultat.SetType(2); |
| 677 |
resultat.SetFlag(1); //titres sur les lignes |
| 678 |
|
| 679 |
k=0; |
| 680 |
for (i = 0; i < _nbpop; i++) { |
| 681 |
for (j = 0; j < _tabPstrucpop[i]->get_nbind(); j++) { |
| 682 |
mot.assign(_tabPstrucpop[i]->_tabPind[j]->_nom); |
| 683 |
// mot.AjEntier(i+1); |
| 684 |
// mot += '_'; |
| 685 |
// mot += _tabPstrucpop[i]->_tabPind[j]->_nom; |
| 686 |
resultat._tlig[k] = mot; |
| 687 |
resultat._tcol[k] = mot; |
| 688 |
_tabPind[k] = _tabPstrucpop[i]->_tabPind[j]; |
| 689 |
k++; |
| 690 |
} |
| 691 |
} |
| 692 |
|
| 693 |
resultat._titre.push_back(get_nom_methode(_methode)); |
| 694 |
switch (_methode) { |
| 695 |
case 5: |
| 696 |
break; |
| 697 |
case 101: |
| 698 |
// stockage des fr�quences |
| 699 |
newTabFreqInd(); |
| 700 |
f_calcTabFreqInd(); |
| 701 |
break; |
| 702 |
case 102: |
| 703 |
// stockage des fr�quences |
| 704 |
newTabFreqInd(); |
| 705 |
f_calcTabFreqInd(); |
| 706 |
break; |
| 707 |
case 103: |
| 708 |
// stockage des fr�quences |
| 709 |
newTabFreqInd(); |
| 710 |
f_calcTabFreqInd(); |
| 711 |
break; |
| 712 |
case 104: |
| 713 |
// stockage des fr�quences |
| 714 |
newTabFreqInd(); |
| 715 |
f_calcTabFreqInd(); |
| 716 |
break; |
| 717 |
case 106: |
| 718 |
// stockage des Mu |
| 719 |
newTabMuInd(); |
| 720 |
f_calcTabMuInd(); |
| 721 |
break; |
| 722 |
case 107: |
| 723 |
// stockage des fr�quences |
| 724 |
newTabFreqInd(); |
| 725 |
f_calcTabFreqInd(); |
| 726 |
break; |
| 727 |
case 108: |
| 728 |
// stockage des fr�quences |
| 729 |
newTabFreqInd(); |
| 730 |
f_calcTabFreqInd(); |
| 731 |
break; |
| 732 |
case 109: |
| 733 |
// stockage des fr�quences |
| 734 |
newTabFreqInd(); |
| 735 |
f_calcTabFreqInd(); |
| 736 |
break; |
| 737 |
case 110: |
| 738 |
// stockage des fr�quences |
| 739 |
newTabFreqInd(); |
| 740 |
f_calcTabFreqInd(); |
| 741 |
break; |
| 742 |
case 111: |
| 743 |
// stockage des fr�quences |
| 744 |
newTabFreqInd(); |
| 745 |
f_calcTabFreqInd(); |
| 746 |
break; |
| 747 |
case 112: |
| 748 |
// stockage des Mu |
| 749 |
newTabMuInd(); |
| 750 |
f_calcTabMuInd(); |
| 751 |
break; |
| 752 |
case 113: |
| 753 |
throw Anomalie(4, get_nom_methode(13)); |
| 754 |
break; |
| 755 |
case 114: |
| 756 |
throw Anomalie(4, get_nom_methode(14)); |
| 757 |
break; |
| 758 |
case 115: |
| 759 |
throw Anomalie(4, get_nom_methode(15)); |
| 760 |
break; |
| 761 |
default: |
| 762 |
break; |
| 763 |
} |
| 764 |
resultat.SetType(2); |
| 765 |
resultat.SetFlag(1); //titres sur les lignes |
| 766 |
|
| 767 |
f_distgntIndVcalc (resultat._tab); |
| 768 |
} |
| 769 |
|
| 770 |
void DistancesGnt::f_distgntpopDas(long double * Ptab) const { |
| 771 |
// calcul de distance g�n�tique avec la Das entre Populations |
| 772 |
// combinaison des individus entre les 2 pops (moyPsAB), |
| 773 |
// combinaison des individus dans la pop1 (moyPsA1), |
| 774 |
// combinaison des individus dans la pop2 (moyPsA2) |
| 775 |
|
| 776 |
long double moyPsAB(0); |
| 777 |
long double moyPsA1(0); |
| 778 |
long double moyPsA2(0); |
| 779 |
unsigned long i,j; |
| 780 |
|
| 781 |
if (_bootind) { |
| 782 |
for (j = 0; j < _nbpop; j++) { |
| 783 |
_tabPstrucpop[j]->f_bootstrap(); |
| 784 |
} |
| 785 |
} |
| 786 |
|
| 787 |
for (j = 0; j < _nbpop; j++) { |
| 788 |
for (i = 0; i < j; i++) { |
| 789 |
moyPsAB = r_distDasMoyPsAB(_tabPstrucpop[i], _tabPstrucpop[j]); |
| 790 |
moyPsA1 = r_distDasMoyPsA(_tabPstrucpop[i]); |
| 791 |
moyPsA2 = r_distDasMoyPsA(_tabPstrucpop[j]); |
| 792 |
|
| 793 |
Ptab[(i * _nbpop) + j] = Ptab[(j * _nbpop) + i] = (long double)1 - (((long double) 2 * moyPsAB)/(moyPsA1 + moyPsA2)); |
| 794 |
} |
| 795 |
} |
| 796 |
} |
| 797 |
|
| 798 |
long double DistancesGnt::r_distDasMoyPsA(const StrucPop * Ppop) const { |
| 799 |
//n�cessaire au calcul de distance � l'int�rieur d'une population pour la Das |
| 800 |
|
| 801 |
long double somme(0); |
| 802 |
unsigned long calcsomme(0); |
| 803 |
unsigned long k,l, nbind; |
| 804 |
|
| 805 |
|
| 806 |
if (_bootind) { |
| 807 |
nbind = (Ppop->_VcalcInd.size()); |
| 808 |
|
| 809 |
if (nbind < 2) throw Anomalie(2, Ppop->get_nom() ); |
| 810 |
|
| 811 |
for (k=0; k < nbind; k++) { //scan des individus de la pop |
| 812 |
for (l=(k+1); l < nbind; l++) { //scan des individus de la pop |
| 813 |
calcsomme++; |
| 814 |
try { |
| 815 |
somme += r_distDasPsAi(Ppop->_VcalcInd[k], Ppop->_VcalcInd[l]); |
| 816 |
} |
| 817 |
catch (Jeupop::Anomalie erreur) { |
| 818 |
if (erreur.le_pb == 6) calcsomme--; |
| 819 |
} |
| 820 |
} |
| 821 |
} |
| 822 |
} |
| 823 |
else { |
| 824 |
nbind = (Ppop->get_nbind()); |
| 825 |
|
| 826 |
if (nbind < 2) throw Anomalie(2, Ppop->get_nom()); |
| 827 |
|
| 828 |
for (k=0; k < nbind; k++) { //scan des individus de la pop |
| 829 |
for (l=(k+1); l < nbind; l++) { //scan des individus de la pop |
| 830 |
calcsomme++; |
| 831 |
try { |
| 832 |
somme += r_distDasPsAi(Ppop->get_Pind(k), Ppop->get_Pind(l)); |
| 833 |
} |
| 834 |
catch (Jeupop::Anomalie erreur) { |
| 835 |
if (erreur.le_pb == 6) calcsomme--; |
| 836 |
} |
| 837 |
} |
| 838 |
} |
| 839 |
} |
| 840 |
|
| 841 |
return (somme / ((long double) calcsomme)); |
| 842 |
} |
| 843 |
|
| 844 |
long double DistancesGnt::r_distDasMoyPsAB(const StrucPop * Ppop1, const StrucPop * Ppop2) const { |
| 845 |
//n�cessaire au calcul de distance entre 2 pops pour la Das |
| 846 |
|
| 847 |
long double somme(0); |
| 848 |
unsigned long calcsomme; |
| 849 |
unsigned long k,l, nbind1(0), nbind2(0); |
| 850 |
|
| 851 |
|
| 852 |
if (_bootind) { |
| 853 |
nbind1 = (Ppop1->_VcalcInd.size()); |
| 854 |
nbind2 = (Ppop2->_VcalcInd.size()); |
| 855 |
calcsomme = nbind1 * nbind2; |
| 856 |
|
| 857 |
for (k=0; k < nbind1; k++) { //scan des individus de la pop1 |
| 858 |
for (l=0; l < nbind2; l++) { //scan des individus de la pop2 |
| 859 |
try { |
| 860 |
somme += r_distDasPsAi(Ppop1->_VcalcInd[k], Ppop2->_VcalcInd[l]); |
| 861 |
} |
| 862 |
catch (Jeupop::Anomalie erreur) { |
| 863 |
if (erreur.le_pb == 6) calcsomme--; |
| 864 |
} |
| 865 |
} |
| 866 |
} |
| 867 |
} |
| 868 |
else { |
| 869 |
nbind1 = (Ppop1->get_nbind()); |
| 870 |
nbind2 = (Ppop2->get_nbind()); |
| 871 |
calcsomme = nbind1 * nbind2; |
| 872 |
|
| 873 |
for (k=0; k < nbind1; k++) { //scan des individus de la pop1 |
| 874 |
for (l=0; l < nbind2; l++) { //scan des individus de la pop2 |
| 875 |
try { |
| 876 |
somme += r_distDasPsAi(Ppop1->get_Pind(k), Ppop2->get_Pind(l)); |
| 877 |
} |
| 878 |
catch (Jeupop::Anomalie erreur) { |
| 879 |
if (erreur.le_pb == 6) calcsomme--; |
| 880 |
} |
| 881 |
} |
| 882 |
} |
| 883 |
} |
| 884 |
|
| 885 |
return (somme / ((long double) calcsomme)); |
| 886 |
} |
| 887 |
|
| 888 |
void DistancesGnt::f_distgntpopVcalc(long double * Ptab) const { |
| 889 |
unsigned long i,j; |
| 890 |
|
| 891 |
|
| 892 |
if (_methode == 5) f_distgntpopDas(Ptab); |
| 893 |
else { |
| 894 |
if (_bootind) f_calcTabBootInd(); |
| 895 |
|
| 896 |
for (j = 0; j < _nbpop; j++) { |
| 897 |
for (i = 0; i < j; i++) { |
| 898 |
Ptab[(i * _nbpop) + j] = Ptab[(j * _nbpop) + i] = r_dist2pop(i, j); |
| 899 |
} |
| 900 |
} |
| 901 |
} |
| 902 |
} |
| 903 |
|
| 904 |
long double DistancesGnt::r_dist2pop(unsigned long pop1, unsigned long pop2) const{ |
| 905 |
long double result(0); |
| 906 |
//renvoi de la distance entre 2 Populations |
| 907 |
switch (_methode) { |
| 908 |
case 101: |
| 909 |
// Nei's minimum genetic distance (1972) |
| 910 |
result = r_dpopNei(pop1, pop2, false); |
| 911 |
// return(r_dpopNei(pop1, pop2, false)); |
| 912 |
break; |
| 913 |
case 102: |
| 914 |
// Nei's standard genetic distance (1972) |
| 915 |
result = r_dpopNei(pop1, pop2, true); |
| 916 |
// return(r_dpopNei(pop1, pop2, true)); |
| 917 |
break; |
| 918 |
case 103: |
| 919 |
// Cavalli-Sforza and Edwards' (1967) |
| 920 |
result = r_dpopCavalli(pop1, pop2); |
| 921 |
break; |
| 922 |
case 104: |
| 923 |
// Nei et al's, Da (1983) |
| 924 |
result = r_dpopNeiDa(pop1, pop2); |
| 925 |
// return(r_dpopNeiDa(pop1,pop2)); |
| 926 |
break; |
| 927 |
case 106: |
| 928 |
// Goldstein et al. (1995a) |
| 929 |
result = r_dpopGoldsteinMu(pop1, pop2); |
| 930 |
// return(r_dpopGoldsteinMu(pop1,pop2)); |
| 931 |
break; |
| 932 |
case 107: |
| 933 |
// Latter's Fst (1972) |
| 934 |
result = r_dpopFst(pop1, pop2); |
| 935 |
// return(r_dpopFst(pop1, pop2)); |
| 936 |
break; |
| 937 |
case 108: |
| 938 |
// Prevosti et al.'s, Cp (1975) |
| 939 |
result = r_dpopPrevosti(pop1, pop2); |
| 940 |
// return(r_dpopPrevosti(pop1, pop2)); |
| 941 |
break; |
| 942 |
case 109: |
| 943 |
// Rogers', Dr (1972) |
| 944 |
result = r_dpopRoger(pop1, pop2); |
| 945 |
// return(r_dpopRoger(pop1, pop2)); |
| 946 |
break; |
| 947 |
case 110: |
| 948 |
// Goldstein et al. (1995b) Slatkin 1995 |
| 949 |
result = r_dpopGoldsteinASD(pop1, pop2); |
| 950 |
// return(r_dpopGoldsteinASD(pop1, pop2)); |
| 951 |
break; |
| 952 |
case 111: |
| 953 |
// Shriver et al's, Dsw (1995) |
| 954 |
result = r_dpopShriver(pop1, pop2); |
| 955 |
// return(r_dpopShriver(pop1, pop2)); |
| 956 |
break; |
| 957 |
case 112: |
| 958 |
// Zhivotovsky , DR (1999) |
| 959 |
result = r_dpopZhivotovsky(pop1, pop2); |
| 960 |
// return(r_dpopZhivotovsky(pop1, pop2)); |
| 961 |
break; |
| 962 |
case 113: |
| 963 |
// Reynolds unweighted (1983) |
| 964 |
result = r_dpopReynoldsUnweighted(pop1, pop2); |
| 965 |
// return(r_dpopReynoldsUnweighted(pop1, pop2)); |
| 966 |
break; |
| 967 |
case 114: |
| 968 |
// Reynolds weighted (1983) |
| 969 |
result = r_dpopReynoldsWeighted(pop1, pop2); |
| 970 |
// return(r_dpopReynoldsWeighted(pop1, pop2)); |
| 971 |
break; |
| 972 |
case 115: |
| 973 |
// Reynolds least squares (1983) |
| 974 |
result = r_dpopReynoldsLeast(pop1, pop2); |
| 975 |
// return(r_dpopReynoldsLeast(pop1, pop2)); |
| 976 |
break; |
| 977 |
|
| 978 |
} |
| 979 |
if (_squareDistance) return (result * result); |
| 980 |
else return (result); |
| 981 |
|
| 982 |
throw Anomalie(1); |
| 983 |
return(0); |
| 984 |
} |
| 985 |
|
| 986 |
|
| 987 |
long double DistancesGnt::r_dpopCavalli(unsigned long pop1,unsigned long pop2) const { |
| 988 |
|
| 989 |
//distances de Cavalli-Sforza and Edwards' (1967) entre 2 populations |
| 990 |
// tir� de Naoko Takezaki and Masatoshi Nei |
| 991 |
// "Genetic Distances and Reconstruction of Phylogenetic |
| 992 |
// Trees From Microsatellite DNA" |
| 993 |
// Genetics society of America 144: 389-399.1996. |
| 994 |
|
| 995 |
long double Sracinelocus(0); |
| 996 |
long double Sracinealleles; |
| 997 |
unsigned long i, l, locus; |
| 998 |
unsigned long nblocus(_VcalcLocus.size()); // soit r |
| 999 |
unsigned long nblocusdivise; |
| 1000 |
long double ** tabfreq1; |
| 1001 |
long double ** tabfreq2; |
| 1002 |
tabfreq1 = ( _PtabFreq + (pop1 * _nbloc)); |
| 1003 |
tabfreq2 = ( _PtabFreq + (pop2 * _nbloc)); |
| 1004 |
|
| 1005 |
nblocusdivise = nblocus; |
| 1006 |
|
| 1007 |
|
| 1008 |
for (l = 0; l < nblocus; l++) { |
| 1009 |
// l numero du locus |
| 1010 |
//cerr << "DistancesGnt::r_dpopCavalli entre " << l << endl; |
| 1011 |
locus = _VcalcLocus[l]; |
| 1012 |
if ((_tabEviteLocus[(pop1 * _nbloc) + locus]) || (_tabEviteLocus[(pop2 * _nbloc) + locus])) { |
| 1013 |
nblocusdivise--; |
| 1014 |
continue; |
| 1015 |
} |
| 1016 |
//cerr << "DistancesGnt::r_dpopCavalli sort " << l << endl; |
| 1017 |
|
| 1018 |
Sracinealleles = 0; |
| 1019 |
for (i = 0; i < _tabNbAll[locus]; i++) { |
| 1020 |
//i numero de l'allele |
| 1021 |
//Pall = _tabPloc[locus]->getPall(i); |
| 1022 |
//if (_Pjeupop->_tabPloc[locus]->getPall(i)->_nul) continue; |
| 1023 |
|
| 1024 |
Sracinealleles += (long double) sqrt(*(tabfreq1[locus] + i) * *(tabfreq2[locus] + i)); |
| 1025 |
} |
| 1026 |
|
| 1027 |
//necessaire: racine carree de zero ne fonctionne pas. |
| 1028 |
if (Sracinealleles < 1) Sracinelocus += (long double)sqrt ((long double)2 * ((long double)1 - Sracinealleles)); |
| 1029 |
} |
| 1030 |
|
| 1031 |
if (nblocusdivise < 1) throw Anomalie(3); |
| 1032 |
return (((long double)2 * Sracinelocus) / (_pi * (long double)nblocusdivise)); |
| 1033 |
} |
| 1034 |
|
| 1035 |
long double DistancesGnt::r_dpopFst(unsigned long pop1,unsigned long pop2) const { |
| 1036 |
|
| 1037 |
//Latter's Fst (1972) entre 2 populations |
| 1038 |
// tir� de Naoko Takezaki and Masatoshi Nei |
| 1039 |
// "Genetic Distances and Reconstruction of Phylogenetic |
| 1040 |
// Trees From Microsatellite DNA" |
| 1041 |
// Genetics society of America 144: 389-399.1996. |
| 1042 |
|
| 1043 |
long double resultat(0), inter; |
| 1044 |
long double Jx(0), Jy(0), Jxy(0); |
| 1045 |
unsigned long i, l, locus; |
| 1046 |
unsigned long nblocus(_VcalcLocus.size()); |
| 1047 |
unsigned long nblocusdivise; |
| 1048 |
long double ** tabfreq1; |
| 1049 |
long double ** tabfreq2; |
| 1050 |
tabfreq1 = (_PtabFreq + (pop1 * _nbloc)); |
| 1051 |
tabfreq2 = (_PtabFreq + (pop2 * _nbloc)); |
| 1052 |
|
| 1053 |
nblocusdivise = nblocus; |
| 1054 |
|
| 1055 |
for (l = 0; l < nblocus; l++) { |
| 1056 |
locus = _VcalcLocus[l]; |
| 1057 |
if ((_tabEviteLocus[(pop1 * _nbloc) + locus]) || (_tabEviteLocus[(pop2 * _nbloc) + locus])) { |
| 1058 |
nblocusdivise--; |
| 1059 |
continue; |
| 1060 |
} |
| 1061 |
|
| 1062 |
for (i = 0; i < _tabNbAll[locus]; i++) { |
| 1063 |
//Pall = _tabPloc[locus]->getPall(i); |
| 1064 |
if (_Pjeupop->_tabPloc[locus]->getPall(i)->_miss) continue; |
| 1065 |
|
| 1066 |
//frequence de l'allele i dans la population 1 |
| 1067 |
inter = *(tabfreq1[locus] + i); |
| 1068 |
//inter = ((long double) ppop1->r_nbcopall(Pall) / (long double) nballpop1); |
| 1069 |
resultat = inter * inter; |
| 1070 |
// resultat /= nblocus; |
| 1071 |
Jx += resultat; |
| 1072 |
|
| 1073 |
//frequence de l'allele i dans la population 2 |
| 1074 |
resultat = *(tabfreq2[locus] + i); |
| 1075 |
//resultat = ((long double) ppop2->r_nbcopall(Pall) / (long double) nballpop2); |
| 1076 |
inter = inter * resultat; |
| 1077 |
resultat = resultat * resultat; |
| 1078 |
// resultat /= nblocus; |
| 1079 |
Jy += resultat; |
| 1080 |
|
| 1081 |
// inter /= nblocus; |
| 1082 |
Jxy += inter; |
| 1083 |
} |
| 1084 |
} |
| 1085 |
|
| 1086 |
if (nblocusdivise < 1) throw Anomalie(3); |
| 1087 |
Jx /= (long double)nblocusdivise; |
| 1088 |
Jy /= (long double)nblocusdivise; |
| 1089 |
Jxy /= (long double)nblocusdivise; |
| 1090 |
|
| 1091 |
//distance de Nei classique: |
| 1092 |
resultat = ((Jx + Jy) / (long double)2 ) - Jxy; |
| 1093 |
|
| 1094 |
// Fst : |
| 1095 |
resultat /= ((long double)1 - Jxy); |
| 1096 |
|
| 1097 |
|
| 1098 |
return (resultat); |
| 1099 |
} |
| 1100 |
|
| 1101 |
/* |
| 1102 |
long double DistancesGnt::r_dpopFstClassique(long double ** tabfreq1,long double ** tabfreq2) const { |
| 1103 |
|
| 1104 |
//Fst entre 2 populations |
| 1105 |
|
| 1106 |
long double somme; |
| 1107 |
long double HT, moyHS; |
| 1108 |
unsigned long i, l, locus; |
| 1109 |
long double nblocus((long double) _VcalcLocus.size()); |
| 1110 |
|
| 1111 |
|
| 1112 |
for (l = 0; l < nblocus; l++) { |
| 1113 |
locus = _VcalcLocus[l]; |
| 1114 |
|
| 1115 |
for (i = 0; i < _tabNbAll[locus]; i++) { |
| 1116 |
if (_Pjeupop->_tabPloc[locus]->getPall(i)->_nul) continue; |
| 1117 |
|
| 1118 |
//pour chaque locus, chaque allele |
| 1119 |
//calcul de HT |
| 1120 |
somme = (*(tabfreq1[locus] + i) * nbind1) |
| 1121 |
} |
| 1122 |
} |
| 1123 |
|
| 1124 |
// Fst : |
| 1125 |
resultat /= ((long double)1 - Jxy); |
| 1126 |
|
| 1127 |
|
| 1128 |
return (resultat); |
| 1129 |
} |
| 1130 |
*/ |
| 1131 |
|
| 1132 |
long double DistancesGnt::r_dpopGoldsteinASD(unsigned long pop1,unsigned long pop2) const { |
| 1133 |
|
| 1134 |
//distances de Goldstein et al., ASD (1995b; Slatkin 1995) entre 2 populations |
| 1135 |
// Average Square Distance |
| 1136 |
// tir� de Naoko Takezaki and Masatoshi Nei |
| 1137 |
// "Genetic Distances and Reconstruction of Phylogenetic |
| 1138 |
// Trees From Microsatellite DNA" |
| 1139 |
// Genetics society of America 144: 389-399.1996. |
| 1140 |
|
| 1141 |
long double freqxil; |
| 1142 |
long double freqyjl; |
| 1143 |
long double Slocus(0); |
| 1144 |
long double DblSommeij(0); |
| 1145 |
unsigned long i,j, l, locus; |
| 1146 |
unsigned long nblocus(_VcalcLocus.size()); // soit r |
| 1147 |
unsigned long nballdiff; |
| 1148 |
unsigned long nblocusdivise; |
| 1149 |
long double ** tabfreq1; |
| 1150 |
long double ** tabfreq2; |
| 1151 |
tabfreq1 = (_PtabFreq + (pop1 * _nbloc)); |
| 1152 |
tabfreq2 = (_PtabFreq + (pop2 * _nbloc)); |
| 1153 |
|
| 1154 |
nblocusdivise = nblocus; |
| 1155 |
|
| 1156 |
for (l = 0; l < nblocus; l++) { |
| 1157 |
// l numero du locus |
| 1158 |
locus = _VcalcLocus[l]; |
| 1159 |
if ((_tabEviteLocus[(pop1 * _nbloc) + locus]) || (_tabEviteLocus[(pop2 * _nbloc) + locus])) { |
| 1160 |
nblocusdivise--; |
| 1161 |
//cerr << "DistancesGnt::r_dpopGoldsteinASD" << nblocusdivise << endl; |
| 1162 |
continue; |
| 1163 |
} |
| 1164 |
|
| 1165 |
nballdiff = _tabNbAll[locus]; |
| 1166 |
DblSommeij = 0; |
| 1167 |
for (i = 0; i < nballdiff; i++) { |
| 1168 |
//Palli = _tabPloc[locus]->getPall(i); |
| 1169 |
if (_Pjeupop->_tabPloc[locus]->getPall(i)->_miss) continue; |
| 1170 |
|
| 1171 |
//frequence de l'allele i dans la population 1 |
| 1172 |
freqxil = *(tabfreq1[locus] + i); |
| 1173 |
//freqxil = ((long double) ppop1->r_nbcopall(Palli) / (long double) nballpop1); |
| 1174 |
//cerr << "DistancesGnt::r_dpopGoldsteinASD freqxil" << freqxil << endl; |
| 1175 |
if (freqxil == 0) continue; |
| 1176 |
|
| 1177 |
for (j = 0; j < nballdiff; j++) { |
| 1178 |
//double somme |
| 1179 |
if (i == j) continue; |
| 1180 |
//Pallj = _tabPloc[locus]->getPall(j); |
| 1181 |
if (_Pjeupop->_tabPloc[locus]->getPall(j)->_miss) continue; |
| 1182 |
|
| 1183 |
|
| 1184 |
//cerr << "DistancesGnt::r_dpopGoldsteinASD nbrepet1" << _tabPloc[locus]->getPall(i)->_nbrepet << endl; |
| 1185 |
//cerr << "DistancesGnt::r_dpopGoldsteinASD nbrepet2" << _tabPloc[locus]->getPall(j)->_nbrepet << endl; |
| 1186 |
freqyjl = ((long double)_tabPloc[locus]->getPall(i)->_nbrepet - (long double)_tabPloc[locus]->getPall(j)->_nbrepet); |
| 1187 |
//cerr << "DistancesGnt::r_dpopGoldsteinASD freqyjl" << freqyjl << endl; |
| 1188 |
freqyjl = freqyjl * freqyjl; |
| 1189 |
//cerr << "DistancesGnt::r_dpopGoldsteinASD freqyjl" << freqyjl << endl; |
| 1190 |
//frequence de l'allele j dans la population 2 |
| 1191 |
freqyjl = freqyjl * (*(tabfreq2[locus] + j)); |
| 1192 |
//cerr << "DistancesGnt::r_dpopGoldsteinASD freqyjl" << freqyjl << endl; |
| 1193 |
//freqyjl *= ((long double) ppop2->r_nbcopall(Pallj) / (long double) nballpop2); |
| 1194 |
|
| 1195 |
DblSommeij += (freqxil * freqyjl); |
| 1196 |
//cerr << "DistancesGnt::r_dpopGoldsteinASD DblSommeij" << DblSommeij << endl; |
| 1197 |
} |
| 1198 |
} |
| 1199 |
|
| 1200 |
//Slocus += (DblSommeij / nblocus); |
| 1201 |
Slocus += DblSommeij; |
| 1202 |
//cerr << "DistancesGnt::r_dpopGoldsteinASD Slocus" << Slocus << endl; |
| 1203 |
} |
| 1204 |
|
| 1205 |
// resultat = (long double)1 - (Sracinelocus * ((long double)1 / nblocus)); |
| 1206 |
if (nblocusdivise == 0) throw Anomalie(3); |
| 1207 |
Slocus /= (long double) nblocusdivise; |
| 1208 |
|
| 1209 |
return (Slocus); |
| 1210 |
} |
| 1211 |
|
| 1212 |
|
| 1213 |
long double DistancesGnt::r_dpopGoldsteinMu(unsigned long pop1,unsigned long pop2) const { |
| 1214 |
|
| 1215 |
//distances de Goldstein et al. (1995a) entre 2 populations |
| 1216 |
// deltaMu carre |
| 1217 |
// tir� de Naoko Takezaki and Masatoshi Nei |
| 1218 |
// "Genetic Distances and Reconstruction of Phylogenetic |
| 1219 |
// Trees From Microsatellite DNA" |
| 1220 |
// Genetics society of America 144: 389-399.1996. |
| 1221 |
|
| 1222 |
long double Slocus(0); |
| 1223 |
long double Mu2; |
| 1224 |
unsigned long l, locus; |
| 1225 |
unsigned long nblocus(_VcalcLocus.size()); // soit r |
| 1226 |
unsigned long nblocusdivise; |
| 1227 |
long double * tabmu1(_PtabMu + (pop1 * _nbloc)); |
| 1228 |
long double * tabmu2(_PtabMu + (pop2 * _nbloc)); |
| 1229 |
|
| 1230 |
nblocusdivise = nblocus; |
| 1231 |
|
| 1232 |
for (l = 0; l < nblocus; l++) { |
| 1233 |
// l numero du locus |
| 1234 |
locus = _VcalcLocus[l]; |
| 1235 |
if ((_tabEviteLocus[(pop1 * _nbloc) + locus]) || (_tabEviteLocus[(pop2 * _nbloc) + locus])) { |
| 1236 |
nblocusdivise--; |
| 1237 |
continue; |
| 1238 |
} |
| 1239 |
|
| 1240 |
//Muxj = Muxj - Muyj; |
| 1241 |
Mu2 = tabmu1[locus] - tabmu2[locus]; |
| 1242 |
Mu2 *= Mu2; |
| 1243 |
|
| 1244 |
//Slocus += (Muxj / nblocus); |
| 1245 |
Slocus += Mu2; |
| 1246 |
} |
| 1247 |
|
| 1248 |
if (nblocusdivise < 1) throw Anomalie(3); |
| 1249 |
Slocus /= (long double) nblocusdivise; |
| 1250 |
|
| 1251 |
// resultat = (long double)1 - (Sracinelocus * ((long double)1 / nblocus)); |
| 1252 |
|
| 1253 |
return (Slocus); |
| 1254 |
} |
| 1255 |
|
| 1256 |
|
| 1257 |
long double DistancesGnt::r_dpopZhivotovsky(unsigned long pop1,unsigned long pop2) const { |
| 1258 |
|
| 1259 |
//distances de Lev A. Zhivotovsky (1999) entre 2 populations |
| 1260 |
// tir� de Lev A. Zhivotovsky |
| 1261 |
// "A new Genetic Distance with Application to constrained |
| 1262 |
// Variation at Microsatellite Loci" |
| 1263 |
// Mol. Biol. Evol. 16(4) 144: 389-399.1996. |
| 1264 |
|
| 1265 |
long double Cab(0); |
| 1266 |
long double MoyRa(0), MoyRb(0); |
| 1267 |
long double SRa2(0), SRb2(0); |
| 1268 |
unsigned long l, locus; |
| 1269 |
unsigned long nblocus(_VcalcLocus.size()); |
| 1270 |
unsigned long nblocusdivise; |
| 1271 |
long double * tabmu1(_PtabMu + (pop1 * _nbloc)); |
| 1272 |
long double * tabmu2(_PtabMu + (pop2 * _nbloc)); |
| 1273 |
|
| 1274 |
nblocusdivise = nblocus; |
| 1275 |
|
| 1276 |
//cerr << "zhivotovski deb" << endl; |
| 1277 |
//ce calcul peut �tre externalis� |
| 1278 |
for (l = 0; l < nblocus; l++) { |
| 1279 |
locus = _VcalcLocus[l]; |
| 1280 |
if ((_tabEviteLocus[(pop1 * _nbloc) + locus]) || (_tabEviteLocus[(pop2 * _nbloc) + locus])) { |
| 1281 |
nblocusdivise--; |
| 1282 |
continue; |
| 1283 |
} |
| 1284 |
|
| 1285 |
MoyRa += tabmu1[locus]; |
| 1286 |
MoyRb += tabmu2[locus]; |
| 1287 |
SRa2 += (tabmu1[locus] * tabmu1[locus]); |
| 1288 |
SRb2 += (tabmu2[locus] * tabmu2[locus]); |
| 1289 |
Cab += (tabmu1[locus] * tabmu2[locus]); |
| 1290 |
} |
| 1291 |
|
| 1292 |
if (nblocusdivise < 1) throw Anomalie(3); |
| 1293 |
|
| 1294 |
MoyRa /= (long double) nblocusdivise; |
| 1295 |
MoyRb /= (long double) nblocusdivise; |
| 1296 |
//-------------- |
| 1297 |
|
| 1298 |
//cerr << Cab << " - " << (((long double) nblocus) * MoyRa * MoyRb) << endl; |
| 1299 |
Cab -= (((long double) nblocusdivise) * MoyRa * MoyRb); |
| 1300 |
Cab /= (long double)(nblocusdivise - 1); |
| 1301 |
// c'est bon pour Cab |
| 1302 |
// pour Va et Vb, utilisons respectivement SRa2 et SRb2 |
| 1303 |
SRa2 -= (((long double) nblocusdivise) * MoyRa * MoyRa); |
| 1304 |
SRb2 -= (((long double) nblocusdivise) * MoyRb * MoyRb); |
| 1305 |
SRa2 /= (long double)(nblocusdivise - 1); |
| 1306 |
SRb2 /= (long double)(nblocusdivise - 1); |
| 1307 |
|
| 1308 |
SRa2 += SRb2; |
| 1309 |
SRa2 /= (long double) 2; |
| 1310 |
|
| 1311 |
//cerr << Cab << " " << SRa2 << endl; |
| 1312 |
//Attention a l'approximation: |
| 1313 |
if (Cab < 1) Cab = 1; //sans ca, ca risque de planter... |
| 1314 |
Cab = ((long double) log(Cab / SRa2) * (long double)-1); |
| 1315 |
|
| 1316 |
//cerr << "zhivotovski fin " << Cab << endl; |
| 1317 |
return (Cab); |
| 1318 |
|
| 1319 |
} |
| 1320 |
|
| 1321 |
long double DistancesGnt::r_dpopNei(unsigned long pop1,unsigned long pop2, bool standard) const { |
| 1322 |
//distances de Nei (1972) entre 2 populations (standard et minimum) |
| 1323 |
// Ds et Dm |
| 1324 |
// tir� de Jin et Chakraborty |
| 1325 |
// mol.Biol. Evol. 11(1): 120-127.1994. |
| 1326 |
long double ** tabfreq1; |
| 1327 |
long double ** tabfreq2; |
| 1328 |
tabfreq1 = (_PtabFreq + (pop1 * _nbloc)); |
| 1329 |
tabfreq2 = (_PtabFreq + (pop2 * _nbloc)); |
| 1330 |
|
| 1331 |
// long double * tabfreq1( _PtabFreq[(pop1 * _nbloc)]); |
| 1332 |
// long double * tabfreq2( _PtabFreq[(pop2 * _nbloc)]); |
| 1333 |
// tabfreq1 = *tabfreq1 + (pop1 * _nbloc); |
| 1334 |
|
| 1335 |
long double resultat(0), inter; |
| 1336 |
long double Jx(0), Jy(0), Jxy(0); |
| 1337 |
unsigned long i, l, locus; |
| 1338 |
unsigned long nblocus(_VcalcLocus.size()); |
| 1339 |
unsigned long nblocusdivise; |
| 1340 |
|
| 1341 |
nblocusdivise = nblocus; |
| 1342 |
// long nballdiff, nballpop1, nballpop2; |
| 1343 |
// Allele * Pall; |
| 1344 |
|
| 1345 |
for (l = 0; l < nblocus; l++) { |
| 1346 |
locus = _VcalcLocus[l]; |
| 1347 |
if ((_tabEviteLocus[(pop1 * _nbloc) + locus]) || (_tabEviteLocus[(pop2 * _nbloc) + locus])) { |
| 1348 |
nblocusdivise--; |
| 1349 |
continue; |
| 1350 |
} |
| 1351 |
// nballdiff = tabNbAll[locus]; |
| 1352 |
for (i = 0; i < _tabNbAll[locus]; i++) { |
| 1353 |
if (_Pjeupop->_tabPloc[locus]->getPall(i)->_miss) continue; |
| 1354 |
|
| 1355 |
//frequence de l'allele i dans la population 1 |
| 1356 |
inter = *(tabfreq1[locus] + i); |
| 1357 |
resultat = inter * inter; |
| 1358 |
Jx += resultat; |
| 1359 |
|
| 1360 |
//frequence de l'allele i dans la population 2 |
| 1361 |
resultat = *(tabfreq2[locus] + i); |
| 1362 |
inter = inter * resultat; |
| 1363 |
resultat = resultat * resultat; |
| 1364 |
Jy += resultat; |
| 1365 |
|
| 1366 |
Jxy += inter; |
| 1367 |
} |
| 1368 |
} |
| 1369 |
if (nblocusdivise == 0) throw Anomalie(3); |
| 1370 |
|
| 1371 |
Jx /= (long double)nblocusdivise; |
| 1372 |
Jy /= (long double)nblocusdivise; |
| 1373 |
Jxy /= (long double)nblocusdivise; |
| 1374 |
|
| 1375 |
if (standard) { |
| 1376 |
//resultat = ((log(Jx) + log(Jy)) / 2 ) - log(Jxy); |
| 1377 |
//cerr << "Ds Nei " << endl; |
| 1378 |
resultat = ( - log (Jxy/(sqrt(Jx * Jy)))); |
| 1379 |
} |
| 1380 |
else { |
| 1381 |
resultat = ((Jx + Jy) / 2 ) - Jxy; |
| 1382 |
} |
| 1383 |
|
| 1384 |
return (resultat); |
| 1385 |
} |
| 1386 |
|
| 1387 |
|
| 1388 |
long double DistancesGnt::r_dpopNeiDa(unsigned long pop1,unsigned long pop2) const { |
| 1389 |
|
| 1390 |
//distances de Nei et al's, Da (1983) entre 2 populations |
| 1391 |
// tir� de Naoko Takezaki and Masatoshi Nei |
| 1392 |
// "Genetic Distances and Reconstruction of Phylogenetic |
| 1393 |
// Trees From Microsatellite DNA" |
| 1394 |
// Genetics society of America 144: 389-399.1996. |
| 1395 |
|
| 1396 |
long double resultat(0); |
| 1397 |
long double freqil; |
| 1398 |
long double Sracinelocus(0); |
| 1399 |
long double Sracinealleles(0); |
| 1400 |
// long double pi(acos(-1)); |
| 1401 |
unsigned long i, l, locus; |
| 1402 |
unsigned long nblocus(_VcalcLocus.size()); // soit r |
| 1403 |
unsigned long nblocusdivise; |
| 1404 |
long double ** tabfreq1; |
| 1405 |
long double ** tabfreq2; |
| 1406 |
tabfreq1 = (_PtabFreq + (pop1 * _nbloc)); |
| 1407 |
tabfreq2 = (_PtabFreq + (pop2 * _nbloc)); |
| 1408 |
|
| 1409 |
|
| 1410 |
nblocusdivise = nblocus; |
| 1411 |
|
| 1412 |
for (l = 0; l < nblocus; l++) { |
| 1413 |
// l numero du locus |
| 1414 |
locus = _VcalcLocus[l]; |
| 1415 |
if ((_tabEviteLocus[(pop1 * _nbloc) + locus]) || (_tabEviteLocus[(pop2 * _nbloc) + locus])) { |
| 1416 |
nblocusdivise--; |
| 1417 |
continue; |
| 1418 |
} |
| 1419 |
|
| 1420 |
Sracinealleles = 0; |
| 1421 |
for (i = 0; i < _tabNbAll[locus]; i++) { |
| 1422 |
//i numero de l'allele |
| 1423 |
//Pall = _tabPloc[locus]->getPall(i); |
| 1424 |
if (_Pjeupop->_tabPloc[locus]->getPall(i)->_miss) continue; |
| 1425 |
|
| 1426 |
//frequence de l'allele i dans la population 1 |
| 1427 |
freqil = *(tabfreq1[locus] + i); |
| 1428 |
//freqil = ((long double) ppop1->r_nbcopall(Pall) / (long double) nballpop1); |
| 1429 |
|
| 1430 |
//frequence de l'allele i dans la population 2 |
| 1431 |
freqil *= *(tabfreq2[locus] + i); |
| 1432 |
//freqil *= ((long double) ppop2->r_nbcopall(Pall) / (long double) nballpop2); |
| 1433 |
|
| 1434 |
Sracinealleles += (long double) sqrt(freqil); |
| 1435 |
} |
| 1436 |
|
| 1437 |
Sracinelocus += Sracinealleles; |
| 1438 |
} |
| 1439 |
|
| 1440 |
if (nblocusdivise < 1) throw Anomalie(3); |
| 1441 |
resultat = (long double)1 - (Sracinelocus / (long double)nblocusdivise); |
| 1442 |
|
| 1443 |
return (resultat); |
| 1444 |
} |
| 1445 |
|
| 1446 |
long double DistancesGnt::r_dpopPrevosti(unsigned long pop1,unsigned long pop2) const { |
| 1447 |
|
| 1448 |
//distances de Prevosti et al.'s, Cp (1975) entre 2 populations |
| 1449 |
// tir� de Naoko Takezaki and Masatoshi Nei |
| 1450 |
// "Genetic Distances and Reconstruction of Phylogenetic |
| 1451 |
// Trees From Microsatellite DNA" |
| 1452 |
// Genetics society of America 144: 389-399.1996. |
| 1453 |
|
| 1454 |
long double freqil; |
| 1455 |
long double Sracinelocus(0); |
| 1456 |
long double Salleles(0); |
| 1457 |
unsigned long i, l, locus; |
| 1458 |
unsigned long nblocus(_VcalcLocus.size()); // soit r |
| 1459 |
unsigned long nblocusdivise; |
| 1460 |
long double ** tabfreq1; |
| 1461 |
long double ** tabfreq2; |
| 1462 |
tabfreq1 = (_PtabFreq + (pop1 * _nbloc)); |
| 1463 |
tabfreq2 = (_PtabFreq + (pop2 * _nbloc)); |
| 1464 |
|
| 1465 |
nblocusdivise = nblocus; |
| 1466 |
|
| 1467 |
for (l = 0; l < nblocus; l++) { |
| 1468 |
// l numero du locus |
| 1469 |
locus = _VcalcLocus[l]; |
| 1470 |
if ((_tabEviteLocus[(pop1 * _nbloc) + locus]) || (_tabEviteLocus[(pop2 * _nbloc) + locus])) { |
| 1471 |
nblocusdivise--; |
| 1472 |
continue; |
| 1473 |
} |
| 1474 |
|
| 1475 |
Salleles = 0; |
| 1476 |
for (i = 0; i < _tabNbAll[locus]; i++) { |
| 1477 |
//i numero de l'allele |
| 1478 |
if (_Pjeupop->_tabPloc[locus]->getPall(i)->_miss) continue; |
| 1479 |
//frequence de l'allele i dans la population 1 |
| 1480 |
freqil = *(tabfreq1[locus] + i); |
| 1481 |
|
| 1482 |
//frequence de l'allele i dans la population 2 |
| 1483 |
freqil -= *(tabfreq2[locus] + i); |
| 1484 |
|
| 1485 |
Salleles += (freqil < 0)?((long double)-1 * freqil):(freqil); |
| 1486 |
} |
| 1487 |
|
| 1488 |
//Sracinelocus += (Salleles / ((long double)2 * nblocus)); |
| 1489 |
Sracinelocus += Salleles; |
| 1490 |
} |
| 1491 |
|
| 1492 |
if (nblocusdivise < 1) throw Anomalie(3); |
| 1493 |
Sracinelocus /= (((long double)2 * (long double)nblocusdivise)); |
| 1494 |
|
| 1495 |
return (Sracinelocus); |
| 1496 |
} |
| 1497 |
|
| 1498 |
|
| 1499 |
long double DistancesGnt::r_dpopRoger(unsigned long pop1,unsigned long pop2) const { |
| 1500 |
|
| 1501 |
//distances de Rogers', Dr (1972) entre 2 populations |
| 1502 |
// tir� de Naoko Takezaki and Masatoshi Nei |
| 1503 |
// "Genetic Distances and Reconstruction of Phylogenetic |
| 1504 |
// Trees From Microsatellite DNA" |
| 1505 |
// Genetics society of America 144: 389-399.1996. |
| 1506 |
|
| 1507 |
long double freqil; |
| 1508 |
long double Sracinelocus(0); |
| 1509 |
long double Salleles(0); |
| 1510 |
unsigned long i, l, locus; |
| 1511 |
unsigned long nblocus(_VcalcLocus.size()); // soit r |
| 1512 |
unsigned long nblocusdivise; |
| 1513 |
long double ** tabfreq1; |
| 1514 |
long double ** tabfreq2; |
| 1515 |
tabfreq1 = (_PtabFreq + (pop1 * _nbloc)); |
| 1516 |
tabfreq2 = (_PtabFreq + (pop2 * _nbloc)); |
| 1517 |
|
| 1518 |
|
| 1519 |
nblocusdivise = nblocus; |
| 1520 |
|
| 1521 |
|
| 1522 |
for (l = 0; l < nblocus; l++) { |
| 1523 |
// l numero du locus |
| 1524 |
locus = _VcalcLocus[l]; |
| 1525 |
if ((_tabEviteLocus[(pop1 * _nbloc) + locus]) || (_tabEviteLocus[(pop2 * _nbloc) + locus])) { |
| 1526 |
nblocusdivise--; |
| 1527 |
continue; |
| 1528 |
} |
| 1529 |
|
| 1530 |
Salleles = 0; |
| 1531 |
for (i = 0; i < _tabNbAll[locus]; i++) { |
| 1532 |
//i numero de l'allele |
| 1533 |
//Pall = _tabPloc[locus]->getPall(i); |
| 1534 |
if (_Pjeupop->_tabPloc[locus]->getPall(i)->_miss) continue; |
| 1535 |
//frequence de l'allele i dans la population 1 |
| 1536 |
freqil = *(tabfreq1[locus] + i); |
| 1537 |
//freqil = ((long double) ppop1->r_nbcopall(Pall) / (long double) nballpop1); |
| 1538 |
|
| 1539 |
//frequence de l'allele i dans la population 2 |
| 1540 |
freqil -= *(tabfreq2[locus] + i); |
| 1541 |
//freqil -= ((long double) ppop2->r_nbcopall(Pall) / (long double) nballpop2); |
| 1542 |
|
| 1543 |
Salleles += freqil * freqil; |
| 1544 |
} |
| 1545 |
|
| 1546 |
Sracinelocus += (long double)sqrt (Salleles / (long double)2); |
| 1547 |
} |
| 1548 |
|
| 1549 |
// resultat = Sracinelocus * ((long double)2 / (pi * nblocus)); |
| 1550 |
|
| 1551 |
if (nblocusdivise < 1) throw Anomalie(3); |
| 1552 |
return (Sracinelocus / (long double) nblocusdivise); |
| 1553 |
} |
| 1554 |
|
| 1555 |
long double DistancesGnt::r_dpopShriver(unsigned long pop1,unsigned long pop2) const { |
| 1556 |
|
| 1557 |
// Dsw Shriver et al's(1995) |
| 1558 |
//distances de Shriver (1995) entre 2 populations |
| 1559 |
// "A novel Measure of Genetic Distance for Highly Polymorphic Tandem Repeat Loci" |
| 1560 |
// Mark D. Shriver, Li Jin, Eric Boerwinkle, Ranjan Deka, Robert E. Ferrell and Ranajit Chakraborty |
| 1561 |
// Mol. Bio. Evol. 12(5):914-920. 1995. |
| 1562 |
|
| 1563 |
long double freqxil; |
| 1564 |
long double freqxjl; |
| 1565 |
long double freqyil; |
| 1566 |
long double freqyjl; |
| 1567 |
long double Resultat(0); |
| 1568 |
int Absdiffij(0); |
| 1569 |
// long double Wxy(0); |
| 1570 |
// long double Wx(0); |
| 1571 |
// long double Wy(0); |
| 1572 |
long double SWxy(0); |
| 1573 |
long double SWx(0); |
| 1574 |
long double SWy(0); |
| 1575 |
// long double pi(acos(-1)); |
| 1576 |
unsigned long i,j, l, locus; |
| 1577 |
unsigned long nblocus(_VcalcLocus.size()); // soit r |
| 1578 |
// long nploidie(get_nploidie()); |
| 1579 |
// long nballdiff, nballpop1, nballpop2; |
| 1580 |
unsigned long nballdiff; |
| 1581 |
unsigned long nbrepet; |
| 1582 |
unsigned long nblocusdivise; |
| 1583 |
long double ** tabfreq1; |
| 1584 |
long double ** tabfreq2; |
| 1585 |
tabfreq1 = (_PtabFreq + (pop1 * _nbloc)); |
| 1586 |
tabfreq2 = (_PtabFreq + (pop2 * _nbloc)); |
| 1587 |
|
| 1588 |
nblocusdivise = nblocus; |
| 1589 |
|
| 1590 |
for (l = 0; l < nblocus; l++) { |
| 1591 |
// l numero du locus |
| 1592 |
locus = _VcalcLocus[l]; |
| 1593 |
if ((_tabEviteLocus[(pop1 * _nbloc) + locus]) || (_tabEviteLocus[(pop2 * _nbloc) + locus])) { |
| 1594 |
nblocusdivise--; |
| 1595 |
continue; |
| 1596 |
} |
| 1597 |
|
| 1598 |
nballdiff = _tabNbAll[locus]; |
| 1599 |
//SWxy = 0; |
| 1600 |
//SWy = 0; |
| 1601 |
//SWx = 0; |
| 1602 |
for (i = 0; i < nballdiff; i++) { |
| 1603 |
//Palli = _tabPloc[locus]->getPall(i); |
| 1604 |
if (_Pjeupop->_tabPloc[locus]->getPall(i)->_miss) continue; |
| 1605 |
|
| 1606 |
//frequence de l'allele i dans la population 1 |
| 1607 |
freqxil = *(tabfreq1[locus] + i); |
| 1608 |
//freqxil = ((long double) ppop1->r_nbcopall(Palli) / (long double) nballpop1); |
| 1609 |
//frequence de l'allele i dans la population 2 |
| 1610 |
freqyil = *(tabfreq2[locus] + i); |
| 1611 |
//freqyil = ((long double) ppop2->r_nbcopall(Palli) / (long double) nballpop2); |
| 1612 |
|
| 1613 |
nbrepet = _tabPloc[locus]->getPall(i)->_nbrepet; |
| 1614 |
for (j = 0; j < nballdiff; j++) { |
| 1615 |
//double somme |
| 1616 |
if (i == j) continue; |
| 1617 |
//Pallj = _tabPloc[locus]->getPall(j); |
| 1618 |
if (_tabPloc[locus]->getPall(j)->_miss) continue; |
| 1619 |
|
| 1620 |
//cerr << Palli->_nom << " " << Pallj->_nom << endl; |
| 1621 |
Absdiffij = (int)nbrepet - (int)_tabPloc[locus]->getPall(j)->_nbrepet; |
| 1622 |
Absdiffij = (Absdiffij < 0)?(-1 * Absdiffij):(Absdiffij); |
| 1623 |
|
| 1624 |
//frequence de l'allele j dans la population 2 |
| 1625 |
freqyjl = *(tabfreq2[locus] + j); |
| 1626 |
//freqyjl = ((long double) ppop2->r_nbcopall(Pallj) / (long double) nballpop2); |
| 1627 |
//frequence de l'allele j dans la population 1 |
| 1628 |
freqxjl = *(tabfreq1[locus] + j); |
| 1629 |
//freqxjl = ((long double) ppop1->r_nbcopall(Pallj) / (long double) nballpop1); |
| 1630 |
|
| 1631 |
|
| 1632 |
SWxy += freqxil * freqyjl * (long double)Absdiffij; |
| 1633 |
SWx += freqxil * freqxjl * (long double)Absdiffij; |
| 1634 |
SWy += freqyil * freqyjl * (long double)Absdiffij; |
| 1635 |
//cerr << SWxy << " " << SWx << " " << SWy << endl; |
| 1636 |
} |
| 1637 |
} |
| 1638 |
|
| 1639 |
//Wxy += (SWxy / nblocus); |
| 1640 |
//Wx += (SWx / nblocus); |
| 1641 |
//Wy += (SWy / nblocus); |
| 1642 |
} |
| 1643 |
//cin >> Resultat; |
| 1644 |
|
| 1645 |
if (nblocusdivise < 1) throw Anomalie(3); |
| 1646 |
SWxy /= (long double) nblocusdivise; |
| 1647 |
SWx /= (long double) nblocusdivise; |
| 1648 |
SWy /= (long double) nblocusdivise; |
| 1649 |
|
| 1650 |
Resultat = SWxy - ((SWx + SWy)/(long double)2); |
| 1651 |
|
| 1652 |
// cerr << SWxy << " " << SWx << " " << SWy << " " << Resultat << endl; |
| 1653 |
//cin >> SWxy; |
| 1654 |
|
| 1655 |
return (Resultat); |
| 1656 |
} |
| 1657 |
|
| 1658 |
|
| 1659 |
inline void DistancesGnt::f_calcTabFreq() const{ |
| 1660 |
//calcul des frequences alleliques |
| 1661 |
// tabPfreq contient les adresses de tableaux de frequences |
| 1662 |
// tabNbAll contient le nombre d'alleles a chaque locus |
| 1663 |
|
| 1664 |
unsigned long nball, nballnonnuls; |
| 1665 |
unsigned long i, j, k; |
| 1666 |
|
| 1667 |
long double* adresse(_PtabFreq[0]); |
| 1668 |
|
| 1669 |
for (i=0; i < _nbpop; i++) { |
| 1670 |
for (j=0; j < _nbloc; j++) { |
| 1671 |
nball = _tabNbAll[j]; |
| 1672 |
nballnonnuls = _tabPstrucpop[i]->r_nballnonnuls(j); |
| 1673 |
if (nballnonnuls == 0) { |
| 1674 |
_tabEviteLocus[(i*_nbloc)+j] = true; // calculs de fr�quences impossible sur ce locus |
| 1675 |
|
| 1676 |
for (k=0; k < nball; k++, adresse++) *adresse = 0; |
| 1677 |
continue; |
| 1678 |
// throw Anomalie(3, _tabPstrucpop[i]->get_nom()); |
| 1679 |
} |
| 1680 |
|
| 1681 |
for (k=0; k < nball; k++) { |
| 1682 |
if (_tabPloc[j]->getPall(k)->_miss) *adresse = 0; |
| 1683 |
else *adresse = (long double) _tabPstrucpop[i]->r_nbcopall(_tabPloc[j]->getPall(k)) / (long double) nballnonnuls; |
| 1684 |
adresse++; |
| 1685 |
} |
| 1686 |
} |
| 1687 |
} |
| 1688 |
} |
| 1689 |
|
| 1690 |
void DistancesGnt::f_calcTabFreqTot() const{ |
| 1691 |
//calcul des frequences alleliques moyennes � chaque locus pour toutes les pops |
| 1692 |
//�a ne sert pas pour l'instant (26/02/2002) |
| 1693 |
unsigned long j,k,nball, nballnonnuls; |
| 1694 |
MetaPop * Pracinepop(_Pjeupop->get_Pracinepop()); |
| 1695 |
long double* adresse(_PtabFreqTot); |
| 1696 |
|
| 1697 |
f_calcTabFreq(); |
| 1698 |
|
| 1699 |
for (j=0; j < _nbloc; j++) { |
| 1700 |
nball = _tabNbAll[j]; |
| 1701 |
nballnonnuls = Pracinepop->r_nballnonnuls(j); |
| 1702 |
if (nballnonnuls == 0) { |
| 1703 |
// calculs impossibles non trait� |
| 1704 |
|
| 1705 |
//_tabEviteLocus[(i*_nbloc)+j] = true; // calculs de fr�quences impossible sur ce locus |
| 1706 |
|
| 1707 |
//for (k=0; k < nball; k++, adresse++) *adresse = 0; |
| 1708 |
//continue; |
| 1709 |
// throw Anomalie(3, _tabPstrucpop[i]->get_nom()); |
| 1710 |
} |
| 1711 |
|
| 1712 |
for (k=0; k < nball; k++) { |
| 1713 |
if (_tabPloc[j]->getPall(k)->_miss) *adresse = 0; |
| 1714 |
else *adresse = (long double) Pracinepop->r_nbcopall(_tabPloc[j]->getPall(k)) / (long double) nballnonnuls; |
| 1715 |
adresse++; |
| 1716 |
} |
| 1717 |
} |
| 1718 |
|
| 1719 |
|
| 1720 |
} |
| 1721 |
|
| 1722 |
void DistancesGnt::f_calcTabFreqInd() const{ |
| 1723 |
//calcul des frequences alleliques |
| 1724 |
// pour chaque individu |
| 1725 |
// tabPfreq contient les adresses de tableaux de frequences |
| 1726 |
// tabNbAll contient le nombre d'alleles a chaque locus |
| 1727 |
// _tabEviteLocus contient les locus � �viter (qui ne contiennent que des all�les nuls) |
| 1728 |
|
| 1729 |
unsigned long nball, nballnonnuls; |
| 1730 |
unsigned long nbind(_tabPind.size()); |
| 1731 |
unsigned int nploidie(_Pjeupop->get_nploidie()); |
| 1732 |
unsigned long i, j, k; |
| 1733 |
|
| 1734 |
long double* adresse(_PtabFreq[0]); |
| 1735 |
|
| 1736 |
for (i=0; i < nbind; i++) { |
| 1737 |
for (j=0; j < _nbloc; j++) { |
| 1738 |
nball = _tabNbAll[j]; |
| 1739 |
nballnonnuls = _tabPind[i]->r_nballnonnuls(j, nploidie); |
| 1740 |
|
| 1741 |
if (nballnonnuls == 0) { |
| 1742 |
_tabEviteLocus[(i*_nbloc)+j] = true; // calculs de fr�quences impossible sur ce locus |
| 1743 |
|
| 1744 |
for (k=0; k < nball; k++, adresse++) *adresse = 0; |
| 1745 |
continue; |
| 1746 |
} |
| 1747 |
|
| 1748 |
for (k=0; k < nball; k++) { |
| 1749 |
if (_tabPloc[j]->getPall(k)->_miss) *adresse = 0; |
| 1750 |
else *adresse = (long double) _tabPind[i]->r_nbcopall(_tabPloc[j]->getPall(k)) / (long double) nballnonnuls; |
| 1751 |
adresse++; |
| 1752 |
} |
| 1753 |
} |
| 1754 |
} |
| 1755 |
} |
| 1756 |
|
| 1757 |
void DistancesGnt::f_calcTabFreqBootInd() const{ |
| 1758 |
//calcul des frequences alleliques |
| 1759 |
// tabPfreq contient les adresses de tableaux de frequences |
| 1760 |
// tabNbAll contient le nombre d'alleles a chaque locus |
| 1761 |
// sp�cifique aux calculs avec des bootstrap sur les individus |
| 1762 |
|
| 1763 |
unsigned long nball, nballnonnuls; |
| 1764 |
unsigned long i, j, k; |
| 1765 |
|
| 1766 |
long double* adresse(_PtabFreq[0]); |
| 1767 |
|
| 1768 |
//cerr << "f_calcTabFreqBootInd deb" << endl; |
| 1769 |
for (i=0; i < _nbpop; i++) { |
| 1770 |
_tabPstrucpop[i]->f_bootstrap(); |
| 1771 |
for (j=0; j < _nbloc; j++) { |
| 1772 |
nball = _tabNbAll[j]; |
| 1773 |
nballnonnuls = _tabPstrucpop[i]->r_nballnonnulsBootInd(j); |
| 1774 |
|
| 1775 |
if (nballnonnuls == 0) { |
| 1776 |
_tabEviteLocus[(i*_nbloc)+j] = true; // calculs de fr�quences impossible sur ce locus |
| 1777 |
for (k=0; k < nball; k++, adresse++) *adresse = 0; |
| 1778 |
//cerr << "f_calcTabFreqBootInd" << endl; |
| 1779 |
continue; |
| 1780 |
} |
| 1781 |
|
| 1782 |
for (k=0; k < nball; k++) { |
| 1783 |
if (_tabPloc[j]->getPall(k)->_miss) *adresse = 0; |
| 1784 |
else *adresse = (long double) _tabPstrucpop[i]->r_nbcopallBootInd(_tabPloc[j]->getPall(k)) / (long double) nballnonnuls; |
| 1785 |
adresse++; |
| 1786 |
} |
| 1787 |
} |
| 1788 |
} |
| 1789 |
//cerr << "f_calcTabFreqBootInd fin" << endl; |
| 1790 |
|
| 1791 |
} |
| 1792 |
|
| 1793 |
inline void DistancesGnt::f_calcTabBootInd() const{ |
| 1794 |
//recalcul des tableaux |
| 1795 |
switch (_methode) { |
| 1796 |
case 106: |
| 1797 |
// calculs des Mu |
| 1798 |
f_calcTabMuBootInd(); |
| 1799 |
break; |
| 1800 |
case 112: |
| 1801 |
// calculs des Mu |
| 1802 |
f_calcTabMuBootInd(); |
| 1803 |
break; |
| 1804 |
|
| 1805 |
default: |
| 1806 |
// calculs des fr�quences |
| 1807 |
f_calcTabFreqBootInd(); |
| 1808 |
break; |
| 1809 |
} |
| 1810 |
} |
| 1811 |
|
| 1812 |
void DistancesGnt::f_calcTabMu() const{ |
| 1813 |
//calcul des Mu (moyenne du nombre de repetitions (au sens |
| 1814 |
// microsat) pond�r�e par la frequence allelique pour chaque locus) |
| 1815 |
// tabNbAll contient le nombre d'alleles a chaque locus |
| 1816 |
|
| 1817 |
unsigned long nball; |
| 1818 |
long double nballnonnuls; |
| 1819 |
unsigned long i, j, k; |
| 1820 |
|
| 1821 |
long double* adresse(_PtabMu); |
| 1822 |
|
| 1823 |
for (i=0; i < _nbpop; i++) { |
| 1824 |
for (j=0; j < _nbloc; j++) { |
| 1825 |
nball = _tabNbAll[j]; |
| 1826 |
nballnonnuls = (long double) _tabPstrucpop[i]->r_nballnonnuls(j); |
| 1827 |
if (nballnonnuls == 0) { |
| 1828 |
_tabEviteLocus[(i*_nbloc)+j] = true; // calculs de fr�quences impossible sur ce locus |
| 1829 |
|
| 1830 |
for (k=0; k < nball; k++, adresse++) *adresse = 0; |
| 1831 |
continue; |
| 1832 |
// throw Anomalie(3, _tabPstrucpop[i]->get_nom()); |
| 1833 |
} |
| 1834 |
*adresse = 0; |
| 1835 |
|
| 1836 |
for (k=0; k < nball; k++) { |
| 1837 |
if (_tabPloc[j]->getPall(k)->_miss) continue; |
| 1838 |
*adresse += (long double) _tabPloc[j]->getPall(k)->_nbrepet * ((long double) _tabPstrucpop[i]->r_nbcopall(_tabPloc[j]->getPall(k)) / nballnonnuls); |
| 1839 |
} |
| 1840 |
adresse++; |
| 1841 |
} |
| 1842 |
} |
| 1843 |
} |
| 1844 |
|
| 1845 |
void DistancesGnt::f_calcTabMuInd() const{ |
| 1846 |
//calcul des Mu (moyenne du nombre de repetitions (au sens |
| 1847 |
// microsat) pond�r�e par la frequence allelique pour chaque locus) |
| 1848 |
// tabNbAll contient le nombre d'alleles a chaque locus |
| 1849 |
|
| 1850 |
//pour chaque individu |
| 1851 |
|
| 1852 |
unsigned long nball; |
| 1853 |
long double nballnonnuls; |
| 1854 |
unsigned long nbind(_tabPind.size()); |
| 1855 |
unsigned int nploidie(_Pjeupop->get_nploidie()); |
| 1856 |
unsigned long i, j, k; |
| 1857 |
|
| 1858 |
long double* adresse(_PtabMu); |
| 1859 |
|
| 1860 |
for (i=0; i < nbind; i++) { |
| 1861 |
for (j=0; j < _nbloc; j++) { |
| 1862 |
nball = _tabNbAll[j]; |
| 1863 |
nballnonnuls = (long double) _tabPind[i]->r_nballnonnuls(j, nploidie); |
| 1864 |
if (nballnonnuls == 0) { |
| 1865 |
_tabEviteLocus[(i*_nbloc)+j] = true; // calculs de fr�quences impossible sur ce locus |
| 1866 |
for (k=0; k < nball; k++, adresse++) *adresse = 0; |
| 1867 |
continue; |
| 1868 |
} |
| 1869 |
|
| 1870 |
*adresse = 0; |
| 1871 |
|
| 1872 |
for (k=0; k < nball; k++) { |
| 1873 |
if (_tabPloc[j]->getPall(k)->_miss) continue; |
| 1874 |
*adresse += (long double) _tabPloc[j]->getPall(k)->_nbrepet * ((long double) _tabPind[i]->r_nbcopall(_tabPloc[j]->getPall(k)) / nballnonnuls); |
| 1875 |
} |
| 1876 |
adresse++; |
| 1877 |
} |
| 1878 |
} |
| 1879 |
} |
| 1880 |
|
| 1881 |
void DistancesGnt::f_calcTabMuBootInd() const{ |
| 1882 |
//calcul des Mu (moyenne du nombre de repetitions (au sens |
| 1883 |
// microsat) pond�r�e par la frequence allelique pour chaque locus) |
| 1884 |
// tabNbAll contient le nombre d'alleles a chaque locus |
| 1885 |
// sp�cifique aux calculs avec des bootstrap sur les individus |
| 1886 |
|
| 1887 |
|
| 1888 |
unsigned long nball; |
| 1889 |
long double nballnonnuls; |
| 1890 |
unsigned long i, j, k; |
| 1891 |
|
| 1892 |
long double* adresse(_PtabMu); |
| 1893 |
|
| 1894 |
for (i=0; i < _nbpop; i++) { |
| 1895 |
_tabPstrucpop[i]->f_bootstrap(); |
| 1896 |
for (j=0; j < _nbloc; j++) { |
| 1897 |
nball = _tabNbAll[j]; |
| 1898 |
nballnonnuls = (long double) _tabPstrucpop[i]->r_nballnonnulsBootInd(j); |
| 1899 |
if (nballnonnuls == 0) { |
| 1900 |
_tabEviteLocus[(i*_nbloc)+j] = true; // calculs de fr�quences impossible sur ce locus |
| 1901 |
for (k=0; k < nball; k++, adresse++) *adresse = 0; |
| 1902 |
continue; |
| 1903 |
} |
| 1904 |
|
| 1905 |
*adresse = 0; |
| 1906 |
|
| 1907 |
for (k=0; k < nball; k++) { |
| 1908 |
if (_tabPloc[j]->getPall(k)->_miss) continue; |
| 1909 |
*adresse += (long double) _tabPloc[j]->getPall(k)->_nbrepet * ((long double) _tabPstrucpop[i]->r_nbcopallBootInd(_tabPloc[j]->getPall(k)) / nballnonnuls); |
| 1910 |
} |
| 1911 |
adresse++; |
| 1912 |
} |
| 1913 |
} |
| 1914 |
} |
| 1915 |
|
| 1916 |
void DistancesGnt::f_distgntIndVcalc (long double * Ptab) const{ |
| 1917 |
//distances G�n�tiques entre individus |
| 1918 |
long nbind (_tabPind.size()); |
| 1919 |
long j,i; |
| 1920 |
|
| 1921 |
for (j = 0; j < nbind; j++) { |
| 1922 |
for (i = 0; i < j; i++) { |
| 1923 |
try { |
| 1924 |
Ptab[(j * nbind) + i] = r_dist2ind(i, j); |
| 1925 |
Ptab[(i * nbind) + j] = Ptab[(j * nbind) + i]; |
| 1926 |
} |
| 1927 |
catch (Jeupop::Anomalie erreur) { |
| 1928 |
if (erreur.le_pb == 6) { |
| 1929 |
Ptab[(j * nbind) + i] = -1; |
| 1930 |
Ptab[(i * nbind) + j] = Ptab[(j * nbind) + i]; |
| 1931 |
} |
| 1932 |
} |
| 1933 |
} |
| 1934 |
} |
| 1935 |
//cerr << "f_distgntIndVcalc fin" << endl; |
| 1936 |
|
| 1937 |
} |
| 1938 |
|
| 1939 |
unsigned long DistancesGnt::get_nbind() const { |
| 1940 |
unsigned long i, res(0); |
| 1941 |
|
| 1942 |
for (i = 0; i < _nbpop; i++) { |
| 1943 |
res += _tabPstrucpop[i]->get_nbind(); |
| 1944 |
} |
| 1945 |
return (res); |
| 1946 |
} |
| 1947 |
|
| 1948 |
|
| 1949 |
unsigned int DistancesGnt::get_nb_methodes() { |
| 1950 |
if (_tab_noms_methodes.size() == 0) f_rempli_tab_noms_methodes(); |
| 1951 |
return(_tab_noms_methodes.size()); |
| 1952 |
} |
| 1953 |
|
| 1954 |
const string & DistancesGnt::get_nom_methode(unsigned int methode) { |
| 1955 |
if (_tab_noms_methodes.size() == 0) f_rempli_tab_noms_methodes(); |
| 1956 |
if (methode > 100) methode -= 100; |
| 1957 |
if (methode < _tab_noms_methodes.size()) return (_tab_noms_methodes[methode]); |
| 1958 |
else throw Anomalie(6); |
| 1959 |
} |
| 1960 |
|
| 1961 |
void DistancesGnt::f_rempli_tab_noms_methodes() { |
| 1962 |
// _map_noms_methodes.resize(0); |
| 1963 |
|
| 1964 |
/* _map_noms_methodes[1] = string("Nei's minimum genetic distance, Dm (1972)"); |
| 1965 |
_map_noms_methodes[2] = string("Nei's standard genetic distance, Ds (1972)"); |
| 1966 |
_map_noms_methodes[3] = string("Cavalli-Sforza and Edwards, Dc (1967)"); //3 |
| 1967 |
//_map_noms_methodes[16] = string("Cavalli-Sforza and Edwards, Dc (1967)"); //3 |
| 1968 |
_map_noms_methodes[4] = string("Nei et al's, Da (1983)"); //4 |
| 1969 |
_map_noms_methodes[5] = string("DAS"); //5 |
| 1970 |
_map_noms_methodes[6] = string("Goldstein et al. , dmu2 (1995a)"); //6 |
| 1971 |
_map_noms_methodes[7] = string("Latter, Fst (1972)"); //7 |
| 1972 |
_map_noms_methodes[8] = string("Prevosti et al.'s, Cp (1975)"); //8 |
| 1973 |
_map_noms_methodes[9] = string("Rogers', Dr (1972)"); //9 |
| 1974 |
_map_noms_methodes[10] = string("Goldstein et al. (1995b) Slatkin, ASD (1995)"); //10 |
| 1975 |
_map_noms_methodes[11] = string("Shriver et al's, Dsw (1995)"); //11 |
| 1976 |
_map_noms_methodes[12] = string("Lev A. Zhivotovsky, DR (1999)"); //12 |
| 1977 |
_map_noms_methodes[13] = string("Reynolds J., unweighted (1983)"); //13 |
| 1978 |
_map_noms_methodes[14] = string("Reynolds J., weighted (1983)"); //14 |
| 1979 |
_map_noms_methodes[15] = string("Reynolds J., least squares (1983)"); //15 |
| 1980 |
|
| 1981 |
*/ _tab_noms_methodes.resize(0); |
| 1982 |
// _tab_numeros_methodes.resize(0); |
| 1983 |
_tab_noms_methodes.push_back(""); //0 |
| 1984 |
_tab_noms_methodes.push_back("Nei's minimum genetic distance, Dm (1972)"); //1 |
| 1985 |
_tab_noms_methodes.push_back("Nei's standard genetic distance, Ds (1972)"); //2 |
| 1986 |
_tab_noms_methodes.push_back("Cavalli-Sforza and Edwards, Dc (1967)"); //3 |
| 1987 |
_tab_noms_methodes.push_back("Nei et al's, Da (1983)"); //4 |
| 1988 |
_tab_noms_methodes.push_back("DAS"); //5 |
| 1989 |
_tab_noms_methodes.push_back("Goldstein et al. , dmu2 (1995a)"); //6 |
| 1990 |
_tab_noms_methodes.push_back("Latter, Fst (1972)"); //7 |
| 1991 |
_tab_noms_methodes.push_back("Prevosti et al.'s, Cp (1975)"); //8 |
| 1992 |
_tab_noms_methodes.push_back("Rogers', Dr (1972)"); //9 |
| 1993 |
_tab_noms_methodes.push_back("Goldstein et al. (1995b) Slatkin, ASD (1995)"); //10 |
| 1994 |
_tab_noms_methodes.push_back("Shriver et al's, Dsw (1995)"); //11 |
| 1995 |
_tab_noms_methodes.push_back("Lev A. Zhivotovsky, DR (1999)"); //12 |
| 1996 |
_tab_noms_methodes.push_back("Reynolds J., unweighted (1983)"); //13 |
| 1997 |
_tab_noms_methodes.push_back("Reynolds J., weighted (1983)"); //14 |
| 1998 |
_tab_noms_methodes.push_back("Reynolds J., least squares (1983)"); //15 |
| 1999 |
|
| 2000 |
} |
| 2001 |
|
| 2002 |
long double DistancesGnt::r_dpopReynoldsUnweighted(unsigned long pop1,unsigned long pop2) const { |
| 2003 |
|
| 2004 |
//distance de Reynolds (1983) entre 2 populations |
| 2005 |
// tir� de {Reynolds, J.} and {Weir, B.S.} and {Cockerham, C.} |
| 2006 |
// "Estimation of the coancestry coefficient: basis for a short-term genetic distance" |
| 2007 |
// Genetics society of America |
| 2008 |
// 105: 767-779.1983. |
| 2009 |
|
| 2010 |
long double al, alpbl; |
| 2011 |
long double sommeu(0); |
| 2012 |
long double sommetheta(0); |
| 2013 |
long double alpha1(0), alpha2(0); |
| 2014 |
long double intermediaire; |
| 2015 |
long double effpop1(_tabPstrucpop[pop1]->get_nbind()), effpop2(_tabPstrucpop[pop2]->get_nbind()); |
| 2016 |
// _nbpop => nombre de populations |
| 2017 |
|
| 2018 |
unsigned long i, l, locus; |
| 2019 |
unsigned long nblocus(_VcalcLocus.size()); |
| 2020 |
unsigned long nblocusdivise; |
| 2021 |
long double ** tabfreq1; |
| 2022 |
long double ** tabfreq2; |
| 2023 |
tabfreq1 = (_PtabFreq + (pop1 * _nbloc)); |
| 2024 |
tabfreq2 = (_PtabFreq + (pop2 * _nbloc)); |
| 2025 |
|
| 2026 |
nblocusdivise = nblocus; |
| 2027 |
|
| 2028 |
for (l = 0; l < nblocus; l++) { |
| 2029 |
// l numero du locus |
| 2030 |
locus = _VcalcLocus[l]; |
| 2031 |
if ((_tabEviteLocus[(pop1 * _nbloc) + locus]) || (_tabEviteLocus[(pop2 * _nbloc) + locus])) { |
| 2032 |
nblocusdivise--; |
| 2033 |
continue; |
| 2034 |
} |
| 2035 |
|
| 2036 |
sommeu = 0; |
| 2037 |
alpha1 = 0; |
| 2038 |
alpha2 = 0; |
| 2039 |
|
| 2040 |
for (i = 0; i < _tabNbAll[locus]; i++) { |
| 2041 |
//i numero de l'allele |
| 2042 |
if (_Pjeupop->_tabPloc[locus]->getPall(i)->_miss) continue; |
| 2043 |
//frequence de l'allele i dans la population 1 |
| 2044 |
alpha1 += ( (*(tabfreq1[locus] + i)) * (*(tabfreq1[locus] + i)) ); |
| 2045 |
|
| 2046 |
//frequence de l'allele i dans la population 2 |
| 2047 |
alpha2 += ( (*(tabfreq2[locus] + i)) * (*(tabfreq2[locus] + i)) ); |
| 2048 |
|
| 2049 |
intermediaire = ((*(tabfreq1[locus] + i)) - (*(tabfreq2[locus] + i))); |
| 2050 |
intermediaire *= intermediaire; |
| 2051 |
sommeu += intermediaire; |
| 2052 |
} |
| 2053 |
sommeu /= ((long double) 2); |
| 2054 |
|
| 2055 |
alpha1 = (long double)1 - alpha1; |
| 2056 |
alpha2 = (long double)1 - alpha2; |
| 2057 |
|
| 2058 |
al = (effpop1 * alpha1); |
| 2059 |
al += (effpop2 * alpha2); |
| 2060 |
al /= (((long double)4 * effpop1 * effpop2) * (effpop1 + effpop2 - (long double)1)); |
| 2061 |
|
| 2062 |
alpbl = (((long double)4 * effpop1 * effpop2) - effpop1 - effpop2); |
| 2063 |
alpbl *= al; |
| 2064 |
|
| 2065 |
al *= (effpop1 + effpop2); |
| 2066 |
al *= (- (long double)1); |
| 2067 |
|
| 2068 |
al += sommeu; |
| 2069 |
alpbl += sommeu; |
| 2070 |
|
| 2071 |
|
| 2072 |
//Sracinelocus += (Salleles / ((long double)2 * nblocus)); |
| 2073 |
sommetheta += (al / alpbl); |
| 2074 |
} |
| 2075 |
|
| 2076 |
if (nblocusdivise < 1) throw Anomalie(3); |
| 2077 |
sommetheta /= ((long double)nblocusdivise); |
| 2078 |
|
| 2079 |
return ( - log ((long double)1 - sommetheta)); |
| 2080 |
} |
| 2081 |
|
| 2082 |
long double DistancesGnt::r_dpopReynoldsWeighted(unsigned long pop1,unsigned long pop2) const { |
| 2083 |
|
| 2084 |
//distance de Reynolds (1983) entre 2 populations |
| 2085 |
// tir� de {Reynolds, J.} and {Weir, B.S.} and {Cockerham, C.} |
| 2086 |
// "Estimation of the coancestry coefficient: basis for a short-term genetic distance" |
| 2087 |
// Genetics society of America |
| 2088 |
// 105: 767-779.1983. |
| 2089 |
|
| 2090 |
long double al, alpbl; |
| 2091 |
long double sommeal(0); |
| 2092 |
long double sommealpbl(0); |
| 2093 |
long double sommeu(0); |
| 2094 |
long double thetaw(0); |
| 2095 |
long double alpha1(0), alpha2(0); |
| 2096 |
long double intermediaire; |
| 2097 |
long double effpop1(_tabPstrucpop[pop1]->get_nbind()), effpop2(_tabPstrucpop[pop2]->get_nbind()); |
| 2098 |
// _nbpop => nombre de populations |
| 2099 |
|
| 2100 |
unsigned long i, l, locus; |
| 2101 |
unsigned long nblocus(_VcalcLocus.size()); |
| 2102 |
unsigned long nblocusdivise; |
| 2103 |
long double ** tabfreq1; |
| 2104 |
long double ** tabfreq2; |
| 2105 |
tabfreq1 = (_PtabFreq + (pop1 * _nbloc)); |
| 2106 |
tabfreq2 = (_PtabFreq + (pop2 * _nbloc)); |
| 2107 |
|
| 2108 |
nblocusdivise = nblocus; |
| 2109 |
|
| 2110 |
for (l = 0; l < nblocus; l++) { |
| 2111 |
// l numero du locus |
| 2112 |
locus = _VcalcLocus[l]; |
| 2113 |
if ((_tabEviteLocus[(pop1 * _nbloc) + locus]) || (_tabEviteLocus[(pop2 * _nbloc) + locus])) { |
| 2114 |
nblocusdivise--; |
| 2115 |
continue; |
| 2116 |
} |
| 2117 |
|
| 2118 |
//sommeal = 0; |
| 2119 |
//sommealpbl = 0; |
| 2120 |
sommeu = 0; |
| 2121 |
alpha1 = 0; |
| 2122 |
alpha2 = 0; |
| 2123 |
|
| 2124 |
for (i = 0; i < _tabNbAll[locus]; i++) { |
| 2125 |
//i numero de l'allele |
| 2126 |
if (_Pjeupop->_tabPloc[locus]->getPall(i)->_miss) continue; |
| 2127 |
//frequence de l'allele i dans la population 1 |
| 2128 |
alpha1 += ( (*(tabfreq1[locus] + i)) * (*(tabfreq1[locus] + i)) ); |
| 2129 |
|
| 2130 |
//frequence de l'allele i dans la population 2 |
| 2131 |
alpha2 += ( (*(tabfreq2[locus] + i)) * (*(tabfreq2[locus] + i)) ); |
| 2132 |
|
| 2133 |
intermediaire = ((*(tabfreq1[locus] + i)) - (*(tabfreq2[locus] + i))); |
| 2134 |
intermediaire *= intermediaire; |
| 2135 |
sommeu += intermediaire; |
| 2136 |
} |
| 2137 |
sommeu /= ((long double) 2); |
| 2138 |
|
| 2139 |
alpha1 = (long double)1 - alpha1; |
| 2140 |
alpha2 = (long double)1 - alpha2; |
| 2141 |
|
| 2142 |
al = (effpop1 * alpha1); |
| 2143 |
al += (effpop2 * alpha2); |
| 2144 |
al /= (((long double)4 * effpop1 * effpop2) * (effpop1 + effpop2 - (long double)1)); |
| 2145 |
|
| 2146 |
alpbl = (((long double)4 * effpop1 * effpop2) - effpop1 - effpop2); |
| 2147 |
alpbl *= al; |
| 2148 |
|
| 2149 |
al *= (effpop1 + effpop2); |
| 2150 |
al *= (- (long double)1); |
| 2151 |
|
| 2152 |
al += sommeu; // al |
| 2153 |
alpbl += sommeu; // al + bl |
| 2154 |
|
| 2155 |
|
| 2156 |
//Sracinelocus += (Salleles / ((long double)2 * nblocus)); |
| 2157 |
sommeal += al; |
| 2158 |
sommealpbl += alpbl; |
| 2159 |
} |
| 2160 |
|
| 2161 |
if (nblocusdivise < 1) throw Anomalie(3); |
| 2162 |
thetaw = sommeal / sommealpbl; |
| 2163 |
|
| 2164 |
return ( - log ((long double)1 - thetaw)); |
| 2165 |
} |
| 2166 |
|
| 2167 |
|
| 2168 |
long double DistancesGnt::r_dpopReynoldsLeast(unsigned long pop1,unsigned long pop2) const { |
| 2169 |
|
| 2170 |
//distance de Reynolds (1983) entre 2 populations |
| 2171 |
// tir� de {Reynolds, J.} and {Weir, B.S.} and {Cockerham, C.} |
| 2172 |
// "Estimation of the coancestry coefficient: basis for a short-term genetic distance" |
| 2173 |
// Genetics society of America |
| 2174 |
// 105: 767-779.1983. |
| 2175 |
|
| 2176 |
long double al, alpbl, bl; |
| 2177 |
long double sommealcarre(0); |
| 2178 |
long double sommeblcarre(0); |
| 2179 |
long double sommealbl(0); |
| 2180 |
long double sommeu(0); |
| 2181 |
long double thetal1(0); |
| 2182 |
long double thetal2(0); |
| 2183 |
long double alpha1(0), alpha2(0); |
| 2184 |
long double intermediaire; |
| 2185 |
long double effpop1(_tabPstrucpop[pop1]->get_nbind()), effpop2(_tabPstrucpop[pop2]->get_nbind()); |
| 2186 |
// _nbpop => nombre de populations |
| 2187 |
|
| 2188 |
unsigned long i, l, locus; |
| 2189 |
unsigned long nblocus(_VcalcLocus.size()); |
| 2190 |
unsigned long nblocusdivise; |
| 2191 |
long double ** tabfreq1; |
| 2192 |
long double ** tabfreq2; |
| 2193 |
tabfreq1 = (_PtabFreq + (pop1 * _nbloc)); |
| 2194 |
tabfreq2 = (_PtabFreq + (pop2 * _nbloc)); |
| 2195 |
|
| 2196 |
nblocusdivise = nblocus; |
| 2197 |
|
| 2198 |
for (l = 0; l < nblocus; l++) { |
| 2199 |
// l numero du locus |
| 2200 |
locus = _VcalcLocus[l]; |
| 2201 |
if ((_tabEviteLocus[(pop1 * _nbloc) + locus]) || (_tabEviteLocus[(pop2 * _nbloc) + locus])) { |
| 2202 |
nblocusdivise--; |
| 2203 |
continue; |
| 2204 |
} |
| 2205 |
|
| 2206 |
//sommealcarre = 0; |
| 2207 |
//sommeblcarre = 0; |
| 2208 |
//sommealpbl = 0; |
| 2209 |
sommeu = 0; |
| 2210 |
alpha1 = 0; |
| 2211 |
alpha2 = 0; |
| 2212 |
|
| 2213 |
for (i = 0; i < _tabNbAll[locus]; i++) { |
| 2214 |
//i numero de l'allele |
| 2215 |
if (_Pjeupop->_tabPloc[locus]->getPall(i)->_miss) continue; |
| 2216 |
//frequence de l'allele i dans la population 1 |
| 2217 |
alpha1 += ( (*(tabfreq1[locus] + i)) * (*(tabfreq1[locus] + i)) ); |
| 2218 |
|
| 2219 |
//frequence de l'allele i dans la population 2 |
| 2220 |
alpha2 += ( (*(tabfreq2[locus] + i)) * (*(tabfreq2[locus] + i)) ); |
| 2221 |
|
| 2222 |
intermediaire = ((*(tabfreq1[locus] + i)) - (*(tabfreq2[locus] + i))); |
| 2223 |
intermediaire *= intermediaire; |
| 2224 |
sommeu += intermediaire; |
| 2225 |
} |
| 2226 |
sommeu /= ((long double) 2); |
| 2227 |
|
| 2228 |
alpha1 = (long double)1 - alpha1; |
| 2229 |
alpha2 = (long double)1 - alpha2; |
| 2230 |
|
| 2231 |
al = (effpop1 * alpha1); |
| 2232 |
al += (effpop2 * alpha2); |
| 2233 |
al /= (((long double)4 * effpop1 * effpop2) * (effpop1 + effpop2 - (long double)1)); |
| 2234 |
|
| 2235 |
alpbl = (((long double)4 * effpop1 * effpop2) - effpop1 - effpop2); |
| 2236 |
alpbl *= al; |
| 2237 |
|
| 2238 |
al *= (effpop1 + effpop2); |
| 2239 |
al *= (- (long double)1); |
| 2240 |
|
| 2241 |
al += sommeu; // al |
| 2242 |
alpbl += sommeu; // al + bl |
| 2243 |
bl = alpbl - al; // bl |
| 2244 |
|
| 2245 |
|
| 2246 |
//Sracinelocus += (Salleles / ((long double)2 * nblocus)); |
| 2247 |
sommealcarre += (al * al); |
| 2248 |
sommealbl += (al * bl); |
| 2249 |
sommeblcarre += (bl * bl); |
| 2250 |
} |
| 2251 |
|
| 2252 |
if (nblocusdivise < 1) throw Anomalie(3); |
| 2253 |
|
| 2254 |
//cerr << "DistancesGnt::r_dpopReynoldsLeast" << endl; |
| 2255 |
//caclcul des 2 solutions possibles |
| 2256 |
intermediaire = (long double)2 * (sommeblcarre - sommealcarre); |
| 2257 |
al = (((long double)2 * sommealbl) + sommeblcarre + sommealcarre); |
| 2258 |
bl = sqrt(((sommealcarre - sommeblcarre)*(sommealcarre - sommeblcarre)) + ( (long double)4 * sommealbl * sommealbl) ); |
| 2259 |
thetal1 = (al + bl) / intermediaire; |
| 2260 |
thetal2 = (al - bl) / intermediaire; |
| 2261 |
|
| 2262 |
//cerr << "numerateur de theta: " << intermediaire << endl; |
| 2263 |
|
| 2264 |
// calcul des "Residual sum of squares" pour pouvoir choisir thetal1 ou thetal2 |
| 2265 |
alpbl = ((long double)2 * sommealbl) + sommealcarre + sommeblcarre; |
| 2266 |
|
| 2267 |
//al devient la Residual sum of squares 1 |
| 2268 |
intermediaire = ((long double)1 - ((long double)2 * thetal1) + ((long double)2 * thetal1 * thetal1)); |
| 2269 |
|
| 2270 |
//cerr << "numerateur de R1: " << intermediaire << endl; |
| 2271 |
al = ((alpbl * thetal1 * thetal1) - ((long double)2 * (sommealbl + sommealcarre) * thetal1) + sommealcarre) / intermediaire; |
| 2272 |
|
| 2273 |
//bl devient la Residual sum of squares 2 |
| 2274 |
intermediaire = ((long double)1 - ((long double)2 * thetal2) + ((long double)2 * thetal2 * thetal2)); |
| 2275 |
//cerr << "numerateur de R2: " << intermediaire << endl; |
| 2276 |
bl = ((alpbl * thetal2 * thetal2) - ((long double)2 * (sommealbl + sommealcarre) * thetal2) + sommealcarre) / intermediaire; |
| 2277 |
|
| 2278 |
//calculs des distances: |
| 2279 |
//cerr << "thetal1: " << thetal1 << " thetal2: " << thetal2 << endl; |
| 2280 |
|
| 2281 |
//cerr << "D1: " << thetal1 << " D2: " << thetal2 << endl; |
| 2282 |
//cerr << "R1: " << al << " R2: " << bl << endl; |
| 2283 |
if ((al < bl) && (thetal1 < 1)) return (- log ((long double)1 - thetal1)); |
| 2284 |
else if (thetal2 < 1) return (- log ((long double)1 - thetal2)); |
| 2285 |
else throw Anomalie(5); |
| 2286 |
} |