Nemo  2.4.2
Simulate forward-in-time genetic evolution in a spatially explicit, individual-based stochastic simulator
TTQuanti_diallelic_full_pleio_epistasis Class Reference

TTQuanti_diallelic_full_pleio : pleiotropic di-allelic loci, max PD = 2. More...

#include <ttquanti_epistasis.h>

+ Inheritance diagram for TTQuanti_diallelic_full_pleio_epistasis:
+ Collaboration diagram for TTQuanti_diallelic_full_pleio_epistasis:

Public Member Functions

 TTQuanti_diallelic_full_pleio_epistasis ()
 
 TTQuanti_diallelic_full_pleio_epistasis (const TTQuanti_diallelic_full_pleio_epistasis &TT)
 
virtual ~TTQuanti_diallelic_full_pleio_epistasis ()
 
virtual void init_sequence ()
 
virtual TTQuanti_diallelic_full_pleio_epistasisclone ()
 
virtual void show_up ()
 
virtual double get_additive_genotype (const unsigned int trait) const
 
virtual double get_dominant_genotype (const unsigned int trait) const
 
virtual void copy_sequence_block (sex_t SEX, unsigned int chromosome, unsigned int from_locus, unsigned int to_locus, const TTQuanti *parent)
 
virtual void copy_sequence_1locus (sex_t SEX, unsigned int chromosome, unsigned int at, const TTQuanti *parent)
 
double get_epistatic_genotype (const vector< double > &genotypes) const
 
- Public Member Functions inherited from TTQuanti_diallelic
 TTQuanti_diallelic ()
 
 TTQuanti_diallelic (const TTQuanti &T)
 
virtual ~TTQuanti_diallelic ()
 
virtual bool get_allele_bit (unsigned int position, unsigned int allele) const
 
virtual void set_allele_bit (unsigned int position, unsigned int allele, bool value)
 
void inherit_free (const TTrait *mother, const TTrait *father)
 
virtual void reset ()
 
virtual void init ()
 
virtual void set_sequence (void **seq)
 
virtual void ** get_sequence () const
 
virtual unsigned int get_allele (int loc, int all) const
 
virtual double get_allele_value (int locus, int allele) const
 
virtual void set_allele_value (unsigned int locus, unsigned int allele, double value)
 
virtual TTQuanti_diallelicoperator= (const TTrait &T)
 
virtual bool operator== (const TTrait &T)
 
virtual bool operator!= (const TTrait &T)
 
virtual void store_data (BinaryStorageBuffer *saver)
 
virtual bool retrieve_data (BinaryStorageBuffer *reader)
 
virtual double get_full_genotype (unsigned int trait)
 
virtual void set_allele (int locus, int allele, double value)
 
virtual void mutate_add (unsigned int position, unsigned int allele, double value)
 
virtual void mutate_inplace (unsigned int position, unsigned int allele, double value)
 
- Public Member Functions inherited from TTQuanti
 TTQuanti ()
 
 TTQuanti (const TTQuanti &T)
 
virtual ~TTQuanti ()
 
virtual trait_t get_type () const
 
virtual void mutate ()
 
virtual void inherit (const TTrait *mother, const TTrait *father)
 
virtual void * set_trait (void *value)
 
virtual void set_value ()
 
virtual void * getValue () const
 
void set_proto (TProtoQuanti *proto)
 
TProtoQuantiget_proto ()
 
double get_phenotype (unsigned int trai)
 
void set_phenotype (unsigned int trait, double value)
 
void reset_phenotype_to_genotypic_value ()
 
- Public Member Functions inherited from TTrait
virtual ~TTrait ()
 
- Public Member Functions inherited from StorableComponent
virtual ~StorableComponent ()
 

Additional Inherited Members

- Protected Attributes inherited from TTQuanti_diallelic
unsigned char ** _sequence
 
- Protected Attributes inherited from TTQuanti
double * _phenotypes
 
double * _genotypic_values
 
TProtoQuanti_myProto
 

Detailed Description

TTQuanti_diallelic_full_pleio : pleiotropic di-allelic loci, max PD = 2.

Constructor & Destructor Documentation

◆ TTQuanti_diallelic_full_pleio_epistasis() [1/2]

TTQuanti_diallelic_full_pleio_epistasis::TTQuanti_diallelic_full_pleio_epistasis ( )
inline
72 : TTQuanti_diallelic() {}
TTQuanti_diallelic()
Definition: ttquanti.h:283

Referenced by clone().

+ Here is the caller graph for this function:

◆ TTQuanti_diallelic_full_pleio_epistasis() [2/2]

TTQuanti_diallelic_full_pleio_epistasis::TTQuanti_diallelic_full_pleio_epistasis ( const TTQuanti_diallelic_full_pleio_epistasis TT)
inline
74  :
75  TTQuanti_diallelic(TT) {}

◆ ~TTQuanti_diallelic_full_pleio_epistasis()

virtual TTQuanti_diallelic_full_pleio_epistasis::~TTQuanti_diallelic_full_pleio_epistasis ( )
inlinevirtual
77 {}

Member Function Documentation

◆ clone()

virtual TTQuanti_diallelic_full_pleio_epistasis* TTQuanti_diallelic_full_pleio_epistasis::clone ( )
inlinevirtual

Implements TTrait.

81 {return new TTQuanti_diallelic_full_pleio_epistasis(*this);}
TTQuanti_diallelic_full_pleio_epistasis()
Definition: ttquanti_epistasis.h:72

References TTQuanti_diallelic_full_pleio_epistasis().

◆ copy_sequence_1locus()

void TTQuanti_diallelic_full_pleio_epistasis::copy_sequence_1locus ( sex_t  SEX,
unsigned int  chromosome,
unsigned int  at,
const TTQuanti parent 
)
inlinevirtual

Implements TTQuanti.

340 {
341  const unsigned char *orig = (const unsigned char*)parent->get_sequence()[chromosome];
342  unsigned char *seq = _sequence[SEX];
343  unsigned int from_pos = at * _myProto->get_num_traits();
344 
345  memcpy(&seq[from_pos], &orig[from_pos], _myProto->get_locus_byte_size());
346 }
size_t get_locus_byte_size()
Definition: ttquanti.h:427
unsigned int get_num_traits()
Definition: ttquanti.h:421
unsigned char ** _sequence
Definition: ttquanti.h:320
TProtoQuanti * _myProto
Definition: ttquanti.h:105
virtual void ** get_sequence() const =0
sequence accessor.

References TTQuanti::_myProto, TTQuanti_diallelic::_sequence, TProtoQuanti::get_locus_byte_size(), TProtoQuanti::get_num_traits(), and TTrait::get_sequence().

◆ copy_sequence_block()

void TTQuanti_diallelic_full_pleio_epistasis::copy_sequence_block ( sex_t  SEX,
unsigned int  chromosome,
unsigned int  from_locus,
unsigned int  to_locus,
const TTQuanti parent 
)
inlinevirtual

Implements TTQuanti.

324 {
325  assert(to_locus >= from_locus);
326 
327  const unsigned char* orig = (const unsigned char*)parent->get_sequence()[chromosome];
328  unsigned char* seq = _sequence[SEX];
329  unsigned int from_pos = from_locus * _myProto->get_num_traits();
330 
331  size_t block_size = (to_locus - from_locus) * _myProto->get_locus_byte_size();
332 
333  memcpy(&seq[from_pos], &orig[from_pos], block_size);
334 }

References TTQuanti::_myProto, TTQuanti_diallelic::_sequence, TProtoQuanti::get_locus_byte_size(), TProtoQuanti::get_num_traits(), and TTrait::get_sequence().

◆ get_additive_genotype()

double TTQuanti_diallelic_full_pleio_epistasis::get_additive_genotype ( const unsigned int  trait) const
inlinevirtual

Implements TTQuanti.

253 {
254  double genotype = 0;
255  unsigned int L = _myProto->get_num_locus(); //number of loci
256  unsigned int pos = _myProto->get_locus_seq_pos(0, trait); //starting position, all loci contiguous on the map
257  vector<double> genotypes(L,0);
258 
259  for(unsigned int j = 0; j < L; ++j) {
260  genotypes[j] = _myProto->get_seq_diallele_value( pos, _sequence[0][pos] ) + _myProto->get_seq_diallele_value( pos, _sequence[1][pos] );
261  pos += _myProto->get_num_traits(); // stride size on the genome (all loci affect each trait)
262  genotype += genotypes[j];
263  }
264 
265  return genotype + get_epistatic_genotype(genotypes);
266 }
double get_seq_diallele_value(unsigned int position, unsigned int allele)
Definition: ttquanti.h:436
unsigned int get_locus_seq_pos(unsigned int loc, unsigned int trait)
Definition: ttquanti.h:451
unsigned int get_num_locus()
Definition: ttquanti.h:422
double get_epistatic_genotype(const vector< double > &genotypes) const
Definition: ttquanti_epistasis.cc:294

References TTQuanti::_myProto, TTQuanti_diallelic::_sequence, get_epistatic_genotype(), TProtoQuanti::get_locus_seq_pos(), TProtoQuanti::get_num_locus(), TProtoQuanti::get_num_traits(), and TProtoQuanti::get_seq_diallele_value().

◆ get_dominant_genotype()

double TTQuanti_diallelic_full_pleio_epistasis::get_dominant_genotype ( const unsigned int  trait) const
inlinevirtual

Implements TTQuanti.

272 {
273  double genotype = 0;
274  unsigned int L = _myProto->get_num_locus(); //number of loci
275  unsigned int pos = _myProto->get_locus_seq_pos(0, trait); //starting position
276  vector<double> genotypes(L,0);
277 
278 
279  for(unsigned int j = 0; j < L; ++j) {
280  genotypes[j] = _myProto->get_genotype_with_dominance(
281  _myProto->get_seq_diallele_value( pos, _sequence[0][pos] ),
282  _myProto->get_seq_diallele_value( pos, _sequence[1][pos] ),
283  j,
284  trait);
285  pos += _myProto->get_num_traits(); // stride size on the genome (all loci affect each trait)
286  genotype += genotypes[j];
287  }
288 
289  return genotype + get_epistatic_genotype(genotypes);
290 }
double get_genotype_with_dominance(const double a1, const double a2, const unsigned int locus, const unsigned int trait)
Definition: ttquanti.cc:2537

References TTQuanti::_myProto, TTQuanti_diallelic::_sequence, get_epistatic_genotype(), TProtoQuanti::get_genotype_with_dominance(), TProtoQuanti::get_locus_seq_pos(), TProtoQuanti::get_num_locus(), TProtoQuanti::get_num_traits(), and TProtoQuanti::get_seq_diallele_value().

◆ get_epistatic_genotype()

double TTQuanti_diallelic_full_pleio_epistasis::get_epistatic_genotype ( const vector< double > &  genotypes) const
inline
295 {
296  double genotype = 0;
297 
298  const TMatrix& epi_loc_idx = _myProto->get_epi_coef_index();
299  const TMatrix& epi_coef = _myProto->get_epi_coefs();
300  unsigned int pos0, pos1;
301 
302  // now add the epistatic effects
303  for(unsigned int i = 0; i < epi_coef.length() ; ++i) {
304 
305  // Note _epistatic_coefs_indices has dimensions [_nb_epi_coefs; 2]
306  pos0 = epi_loc_idx.get(i,0);
307  pos1 = epi_loc_idx.get(i,1);
308 
309 // genotype += epi_coef.get(0,i)
310 // * (_sequence[0][pos0] + _sequence[1][pos0])
311 // * (_sequence[0][pos1] + _sequence[1][pos1]);
312 
313  genotype += epi_coef.get(0,i) * double(genotypes[pos0]) * double(genotypes[pos1]);
314 
315  }
316 
317  return genotype;
318 }
A class to handle matrix in params, coerces matrix into a vector of same total size.
Definition: tmatrix.h:48
double get(unsigned int i, unsigned int j) const
Accessor to element at row i and column j.
Definition: tmatrix.h:191
unsigned int length() const
Returns the number of elements in the matrix.
Definition: tmatrix.h:216
const TMatrix & get_epi_coefs() const
Definition: ttquanti.h:566
const TMatrix & get_epi_coef_index() const
Definition: ttquanti.h:567

References TTQuanti::_myProto, TMatrix::get(), TProtoQuanti::get_epi_coef_index(), TProtoQuanti::get_epi_coefs(), and TMatrix::length().

Referenced by get_additive_genotype(), and get_dominant_genotype().

+ Here is the caller graph for this function:

◆ init_sequence()

void TTQuanti_diallelic_full_pleio_epistasis::init_sequence ( )
inlinevirtual

Implements TTrait.

351 {
352  //options:
353  //0: no variation, init value = one of each allele, mean value is average genotype
354  //1: max variation, randomly set alleles at each locus
355  //2: no variation and initialize with opposite effect alleles at alternating loci.
356 
357 
358  if (_myProto->get_doInitMutation() == 0){
359 
360  memset(_sequence[0], 0, _myProto->get_seq_length());
361  memset(_sequence[1], 0, _myProto->get_seq_length());
362 
363  } else if (_myProto->get_doInitMutation() == 1) {
364 
365  for(unsigned int i = 0; i < _myProto->get_seq_length(); ++i) {
366 
367  // randomly set the allelic values
368  _sequence[0][ i ] = RAND::RandBool();
369  _sequence[1][ i ] = RAND::RandBool();
370 
371  }
372 
373  } else {
374  //option 2; polarized di-allelic values; even locus set to +a, odd locus set to -a
375 
376  for(unsigned int t = 0; t < _myProto->get_num_traits(); ++t) {
377  for(unsigned int i = 0; i < _myProto->get_num_locus(t); i++) { // process trait-wise
378  // even locus
379  if (i % 2 == 0){
380  _sequence[0][ _myProto->get_locus_seq_pos(i, t) ] = 0; //_myProto->get_allele_value(i, 0); //set with the positive allele value
381  _sequence[1][ _myProto->get_locus_seq_pos(i, t) ] = 0; //_myProto->get_allele_value(i, 0);
382  }
383  else { // odd locus
384  _sequence[1][ _myProto->get_locus_seq_pos(i, t) ] = 1; // = _myProto->get_allele_value(i, 1); //set with the alternate/negative allele value
385  _sequence[0][ _myProto->get_locus_seq_pos(i, t) ] = 1; // = _myProto->get_allele_value(i, 1);
386  }
387  }
388 
389  }
390  }
391 }
static bool RandBool()
Returns a random boolean.
Definition: Uniform.h:170
unsigned int get_seq_length()
Definition: ttquanti.h:425
unsigned int get_doInitMutation()
Definition: ttquanti.h:447

References TTQuanti::_myProto, TTQuanti_diallelic::_sequence, TProtoQuanti::get_doInitMutation(), TProtoQuanti::get_locus_seq_pos(), TProtoQuanti::get_num_locus(), TProtoQuanti::get_num_traits(), TProtoQuanti::get_seq_length(), and RAND::RandBool().

◆ show_up()

void TTQuanti_diallelic_full_pleio_epistasis::show_up ( )
virtual

Implements TTrait.

396 {
397  message("\
398  Trait's type: QUANTI (diallelic, full pleiotropy with epistasis)\n\
399  traits: %i\n\
400  loci: %i\n\
401  seq length: %i\n",_myProto->get_num_traits(),_myProto->get_num_locus()
403 
404  for(unsigned int i = 0; i < _myProto->get_num_traits(); i++)
405  message("phenotype %i: %f\n",i+1,_phenotypes[i]);
406 
407  message("_sequence:");
408 
409  for(unsigned int i = 0; i < _myProto->get_num_traits(); ++i) {
410 
411  message("\nt%i (%i loci):\n[0]: ",i+1, _myProto->get_num_locus(i));
412 
413  for(unsigned int j = 0; j < _myProto->get_num_locus(i); ++j) {
414  message("%.3f,",(double)_sequence[0][ _myProto->get_locus_seq_pos(j, i) ]);
415  }
416 
417  message("\n[1]: ");
418 
419  for(unsigned int j = 0; j < _myProto->get_num_locus(i); ++j) {
420  message("%.3f,",(double)_sequence[1][ _myProto->get_locus_seq_pos(j, i) ]);
421  }
422  }
423 
424  message("\n");
425 
426 }
double * _phenotypes
Definition: ttquanti.h:103
void message(const char *message,...)
Definition: output.cc:38

References TTQuanti::_myProto, TTQuanti::_phenotypes, TTQuanti_diallelic::_sequence, TProtoQuanti::get_locus_seq_pos(), TProtoQuanti::get_num_locus(), TProtoQuanti::get_num_traits(), TProtoQuanti::get_seq_length(), and message().


The documentation for this class was generated from the following files:

Generated for Nemo v2.4.2 by  doxygen 1.9.1

Catalogued on GSR