Nemo  2.4.0b
Simulate forward-in-time genetic evolution in a spatially explicit, individual-based stochastic simulator
TProtoQuanti Class Reference

TProtoQuanti. More...

#include <ttquanti.h>

+ Inheritance diagram for TProtoQuanti:
+ Collaboration diagram for TProtoQuanti:

Public Member Functions

 TProtoQuanti ()
 
 TProtoQuanti (const TProtoQuanti &T)
 
virtual ~TProtoQuanti ()
 
unsigned int get_num_traits ()
 
unsigned int get_num_locus ()
 
unsigned int get_num_locus (unsigned int trait)
 
unsigned int get_pleiotropy_type ()
 
unsigned int get_seq_length ()
 
size_t get_size_locus_type ()
 
size_t get_locus_byte_size ()
 
vector< double > get_env_var ()
 
vector< double > get_heritability ()
 
unsigned int get_h2_setTime ()
 
bool get_h2_isBroad ()
 
unsigned int get_allele_model ()
 
const TMatrixget_diallele_values ()
 
double get_diallele_value (unsigned int locus, unsigned int allele)
 
double get_seq_diallele_value (unsigned int position, unsigned int allele)
 
bool has_equal_domCoeff ()
 
bool has_equal_effects ()
 
double get_equal_val_0 ()
 
double get_equal_val_1 ()
 
double get_equal_val_diff ()
 
const bitstringget_trait_mask (unsigned int trait) const
 
double get_init_value (unsigned int i)
 
double get_init_variance (unsigned int i)
 
unsigned int get_doInitMutation ()
 
TTQuantiSHget_stater ()
 
const TMatrixget_pleio_matrix ()
 
unsigned int get_locus_seq_pos (unsigned int loc, unsigned int trait)
 
unsigned int get_locus_ID (unsigned int locus, unsigned int trait)
 
unsigned int get_locus_PD (unsigned int locus)
 
unsigned int get_locus_start_pos (unsigned int locus)
 
unsigned int get_sequence_block_size (unsigned int from, unsigned int to)
 
void set_eVarianceSD (unsigned int trait, double SD)
 
void set_init_values (const double *values, unsigned int nval)
 
void set_trait_value_func_ptr (bool withVe)
 
double set_trait_value_VE (const TTQuanti *ind, const unsigned int trait)
 
double set_trait_value_noVE (const TTQuanti *ind, const unsigned int trait)
 
double set_genotype_value_additive (const TTQuanti *ind, const unsigned int trait)
 
double set_genotype_value_dominance (const TTQuanti *ind, const unsigned int trait)
 
int get_allele_position (const unsigned int locus, const unsigned int trait)
 
double get_allele_value (const TTQuanti *ind, const unsigned int allele, const unsigned int locus, const unsigned int trait)
 
double get_genotype_with_dominance (const double a1, const double a2, const unsigned int locus, const unsigned int trait)
 
double get_genotype_dominance_h (double a1, double a2, double h)
 
double get_genotype_dominance_k (double a1, double a2, double k)
 
unsigned int get_dominance_model ()
 
double get_dominance (unsigned int locus, unsigned int trait)
 
const TMatrixget_dominance_effects ()
 
double get_trait_mutation_variance (unsigned int trait)
 
double get_genotypic_value (const TTQuanti *ind, const unsigned int trait)
 
double get_phenotypic_value (const TTQuanti *ind, const unsigned int trait)
 
bool setHeritabilityParams ()
 
bool setInitialValuesParams ()
 
bool setGeneticMapParams ()
 
unsigned int setAlleleModel ()
 
bool setMutationModel_no_pleio ()
 
bool setMutationModel_full_pleio ()
 
bool setMutationModel_var_pleio ()
 
void setTraitAndLocusTables_full_pleio ()
 
void setTraitAndLocusTables_no_pleio (TMatrix &mat)
 
bool setMutationCorrelation ()
 
bool setDominanceParameters ()
 
bool setDiallelicMutationModel ()
 
bool setMutationSigmaFromQuantiMutationVariance ()
 
bool setMutationSigmaFromQuantiMutationVariance_no_pleio ()
 
bool readMatrixFromQuantiMutationMatrix (vector< vector< double >> &varmat)
 
bool setContinuousMutationModel_no_pleio ()
 
bool setContinuousMutationModel_full_pleio ()
 
bool setContinuousMutationModel_var_pleio ()
 
void allocate_gsl_mutation_matrix_space (unsigned int num_locus)
 
void deallocate_gsl_mutation_matrix_space ()
 
gsl_matrix * set_gsl_mutation_matrix_from_sigma (unsigned int loc, unsigned int pleio_deg)
 
gsl_matrix * set_gsl_mutation_matrix (unsigned int pleio_deg, const vector< double > &varcov)
 
void set_mutation_matrix_decomposition (unsigned int loc, unsigned int pleio_deg)
 
double * getMutationEffectMultivariateGaussian (unsigned int loc)
 
double * getMutationEffectBivariateGaussian (unsigned int loc)
 
double * getMutationEffectUnivariateGaussian (unsigned int loc)
 
double * getMutationEffectMultivariateGaussianLocSpec (unsigned int loc)
 
double * getMutationEffectBivariateGaussianLocSpec (unsigned int loc)
 
double * getMutationEffectUnivariateGaussianLocSpec (unsigned int loc)
 
double * getMutationEffectBivariateDiallelic (unsigned int loc)
 
double * getMutationEffects (unsigned int loc)
 
double * getMutationEffectsVarPleio (unsigned int loc)
 
void inherit (sex_t SEX, TTQuanti *ind, const TTQuanti *parent)
 
void inherit_free (sex_t SEX, TTQuanti *ind, const TTQuanti *parent)
 
void inherit_low (sex_t SEX, TTQuanti *ind, const TTQuanti *parent)
 
unsigned int get_num_mutations ()
 
void mutate (TTQuanti *ind)
 
void mutate_nill (TTQuanti *ind)
 
void mutate_full_pleio (TTQuanti *ind)
 
void mutate_var_pleio (TTQuanti *ind)
 
void mutate_no_pleio (TTQuanti *ind)
 
void mutate_inplace_full_pleio (TTQuanti *ind)
 
void mutate_inplace_var_pleio (TTQuanti *ind)
 
void mutate_inplace_no_pleio (TTQuanti *ind)
 
void mutate_diallelic_pleio (TTQuanti *ind)
 
void mutate_diallelic_var_pleio (TTQuanti *ind)
 
void mutate_diallelic_no_pleio (TTQuanti *ind)
 
bool setEpistasisParameters ()
 
unsigned int get_num_epi_coefs ()
 
bool do_epistasis ()
 
const TMatrixget_epi_coefs () const
 
const TMatrixget_epi_coef_index () const
 
TraitPrototype implementations
virtual void reset ()
 
virtual TTQuantihatch ()
 
virtual TProtoQuanticlone ()
 
virtual trait_t get_type () const
 
virtual int get_phenotype_dimension ()
 Returns the dimension of the phenotype of the trait (size of the array accessed with TTrait::getValue() More...
 
virtual int get_allele_number ()
 Returns the number of allele per locus. More...
 
virtual int get_locus_number ()
 Returns the number of locus. More...
 
StorableComponent implementation
virtual void store_data (BinaryStorageBuffer *saver)
 
virtual bool retrieve_data (BinaryStorageBuffer *reader)
 
SimComponent implementation
virtual bool setParameters ()
 
virtual void loadFileServices (FileServices *loader)
 
virtual void loadStatServices (StatServices *loader)
 
virtual bool resetParameterFromSource (std::string param, SimComponent *cmpt)
 
- Public Member Functions inherited from TTProtoWithMap
 TTProtoWithMap ()
 
 TTProtoWithMap (const TTProtoWithMap &TP)
 
virtual ~TTProtoWithMap ()
 
void setMapIndex (unsigned int idx)
 
unsigned int getMapIndex ()
 
double getRecombRate () const
 
bool setGeneticMapParameters (string prefix, unsigned int numLoci=0)
 
void addGeneticMapParameters (string prefix)
 
bool setRecombinationMapRandom ()
 
bool setRecombinationMapNonRandom (vector< vector< double > > &lociPositions)
 
bool setRecombinationMapFixed ()
 
bool setNumLociPerChromosome (string param_name)
 
void reset_recombination_pointers ()
 
void registerGeneticMap ()
 
void unregisterFromGeneticMap ()
 
bool areGeneticMapParamSet (string prefix)
 
bool isRecombinationFree (string prefix)
 
void recordRandomMap ()
 
virtual bool is_mappable ()
 Checks if the trait is mappable, i.e., if the loci can be placed on a genetic map. More...
 
virtual bool is_mapped ()
 Checks if the trait's loci are placed on a genetic map. More...
 
virtual vector< unsigned int > get_locus_map_positions ()
 Returns the map positions of the loci in vector. More...
 
- Public Member Functions inherited from TraitPrototype
virtual void set_index (int idx)
 Sets the traits index. More...
 
virtual int get_index ()
 Index getter. More...
 
- Public Member Functions inherited from StorableComponent
virtual ~StorableComponent ()
 
- Public Member Functions inherited from SimComponent
 SimComponent ()
 
virtual ~SimComponent ()
 
virtual void loadUpdaters (UpdaterServices *loader)
 Loads the parameters and component updater onto the updater manager. More...
 
virtual void set_paramset (ParamSet *paramset)
 Sets the ParamSet member. More...
 
virtual void set_paramset (std::string name, bool required, SimComponent *owner)
 Sets a new ParamSet and name it. More...
 
virtual void set_paramsetFromCopy (const ParamSet &PSet)
 Reset the set of parameters from a another set. More...
 
virtual ParamSetget_paramset ()
 ParamSet accessor. More...
 
virtual void add_parameter (Param *param)
 Interface to add a parameter to the set. More...
 
virtual void add_parameter (std::string Name, param_t Type, bool isRequired, bool isBounded, double low_bnd, double up_bnd)
 Interface to add a parameter to the set. More...
 
virtual void add_parameter (std::string Name, param_t Type, bool isRequired, bool isBounded, double low_bnd, double up_bnd, ParamUpdaterBase *updater)
 Interface to add a parameter and its updater to the set. More...
 
virtual Paramget_parameter (std::string name)
 Param getter. More...
 
virtual double get_parameter_value (std::string name)
 Param value getter. More...
 
virtual string get_name ()
 Returnd the name of the ParamSet, i.e. More...
 
virtual bool has_parameter (std::string name)
 Param getter. More...
 

Protected Attributes

unsigned int _num_locus
 Total number of loci, for all traits. More...
 
unsigned int _2L
 Diploid locus size, to save on useless operations during mutation. More...
 
unsigned int _num_traits
 Number of traits. More...
 
unsigned int _seq_length
 Total number of allelic values stored in individual sequences, no trait x no locus. More...
 
unsigned int _allele_model
 
string _diallele_datatype
 
double _mutation_rate
 
double _genomic_mutation_rate
 
unsigned int _pleio_type
 
- Protected Attributes inherited from TTProtoWithMap
unsigned int _mapIndex
 
double _totRecombEventsMean
 
double _recombRate
 
double _mapResolution
 
unsigned int _numChromosome
 
unsigned int _numLoci
 
double * _recombRatePerChrmsm
 
unsigned int * _numLociPerChrmsm
 
unsigned int * _chrsmLength
 
unsigned int * _lociMapPositions
 
- Protected Attributes inherited from TraitPrototype
int _index
 The trait index in the Individual traits table. More...
 
- Protected Attributes inherited from SimComponent
ParamSet_paramSet
 The parameters container. More...
 

Private Attributes

TMatrix _allele_value
 
double * _sequence_diallele_values [2]
 
bool _equal_effects
 
double _equal_val_0
 
double _equal_val_1
 
double _equal_val_diff
 
vector< bitstring_trait_masks
 
TMatrix _init_value
 
TMatrix _init_variance
 
TMatrix _mutation_correlation
 
TMatrix _mutation_sigma
 
gsl_matrix ** _gsl_mutation_matrix
 
gsl_matrix ** _evect
 
gsl_vector ** _eval
 
gsl_vector ** _effects_multivar
 
gsl_vector ** _ws
 
double _effects_bivar [2]
 
unsigned int _doInitMutation
 
bool _mutationVarianceIsLocusSpecific
 
bool _mutationEffectIsFixedDiAllele
 
unsigned int _dominance_model
 
TMatrix _dominance_effects
 
bool _equal_dom_coeff
 
bool * _all_chooser
 
size_t _locusByteSize
 
size_t _sizeofLocusType
 
vector< double > _eVariance
 
vector< double > _h2
 
unsigned int _h2_setTime
 
bool _h2_isBroad
 
TMatrix _pleio_matx
 Pleiotropy matrix provided in input (num locu X num trait). More...
 
vector< vector< unsigned int > > _trait_table
 Trait table, (num trait X (variable length/trait)), holds, for each trait, the array position of causative alleles in the sequence. More...
 
vector< vector< unsigned int > > _trait_locus_table
 Table storing the locus id of each locus affecting each trait (num trait X (variable length/trait)). More...
 
vector< vector< unsigned int > > _locus_table
 Locus table, num_locus x 2, first column holds the start position of the alleles of each locus in the sequence, second column counts the number of alleles = pleiotropic degree. More...
 
bool _epistasis
 
unsigned int _num_epi_coefs
 
TMatrix _epistatic_coefs_matrix
 
TMatrix _epistatic_coefs_indices
 
void(TProtoQuanti::* _inherit_fun_ptr )(sex_t, TTQuanti *, const TTQuanti *)
 Pointer to inheritance functions: either inherit_free() (r=0.5), or inherit_low() (r<0.5). More...
 
void(TProtoQuanti::* _mutation_func_ptr )(TTQuanti *)
 Pointer to mutation function, which depends on allele on model (HC, noHC, diallelic) More...
 
double *(TProtoQuanti::* _getMutationValues )(unsigned int)
 Pointer to mutation allele value function, which depends on allele model and number of traits affected. More...
 
vector< double *(TProtoQuanti::*)(unsigned int) > _getMutationValuesVarPleio
 Collection of pointers to mutation functions, which generate allele values in dependence of pleiotropic degree. More...
 
double(TProtoQuanti::* _getGenotypeWithDominance )(double, double, double)
 Pointer to either dominance_h() or dominance_k() function computing the genotypic value with dominance. More...
 
double(TProtoQuanti::* _set_trait_value_func_ptr )(const TTQuanti *, const unsigned int)
 Pointer to either set_trait_value_VE() or set_trait_value_noVE() to compute phenotypic values. More...
 
double(TProtoQuanti::* _set_genotype_func_ptr )(const TTQuanti *, const unsigned int)
 Pointer to functions get_genotype_value_additive() or get_genotype_value_dominance() computing the genotypic value of a trait as function of allele effect. More...
 
TTQuantiSH_stats
 
TTQuantiFH_writer
 
TTQuantiFH_reader
 
TTQFreqExtractor_freqExtractor
 
TTQOhtaStats_ohtaStats
 

Friends

class TTQuanti
 
class TTQuanti_continuous
 
class TTQuanti_continuous_full_pleio
 
class TTQuanti_continuous_var_pleio
 
class TTQuanti_continuous_no_pleio
 
class TTQuanti_continuous_single
 

Additional Inherited Members

- Static Public Member Functions inherited from TTProtoWithMap
static GeneticMapgetGeneticMapRef ()
 
static void recombine (unsigned long indID)
 
- Static Public Attributes inherited from TTProtoWithMap
static GeneticMap _map
 

Detailed Description

Constructor & Destructor Documentation

◆ TProtoQuanti() [1/2]

TProtoQuanti::TProtoQuanti ( )
64  :
65  _num_locus(0),
66  _2L(0),
67  _num_traits(0),
68  _seq_length(0),
69  _allele_model(0),
71  _evect(0),
72  _eval(0),
74  _ws(0),
75  _mutation_rate(0),
77  _doInitMutation(0),
80  _h2_setTime(0),
81  _h2_isBroad(0),
82  _pleio_type(0),
84  _all_chooser(0),
85  _locusByteSize(0),
87  _eVariance(0),
88  _epistasis(false),
89  _num_epi_coefs(0),
96  _stats(0),
97  _writer(0),
98  _reader(0),
99  _freqExtractor(0),
100  _ohtaStats(0)
101 {
102  set_paramset("quantitative_trait", false, this);
103 
104  add_parameter("quanti_traits",INT,true,false,0,0); // MANDATORY
105  add_parameter("quanti_loci",INT,true,false,0,0); // MANDATORY
106  add_parameter("quanti_loci_per_trait", MAT, false, false,0,0);
107  add_parameter("quanti_allele_model",STR,true,false,0,0); // MANDATORY
108  add_parameter("quanti_allele_value",DBL,false,false,0,0);
109  add_parameter("quanti_diallele_datatype", STR, false, false, 0, 0);
110  add_parameter("quanti_init_value",MAT,false,false,0,0);
111  add_parameter("quanti_init_variance",DBL,false,false,0,0,0);
112  add_parameter("quanti_init_model",INT,false,true,0,3);
113 
114  // heritability
115  add_parameter("quanti_environmental_variance",DBL,false,false,0,0);
116  add_parameter("quanti_heritability", DBL, false, false, 0, 0);
117  add_parameter("quanti_heritability_setTime",INT, false, false, 0,0);
118  add_parameter("quanti_heritability_isBroad",BOOL, false, false, 0,0);
119 
120  // mutations
121  add_parameter("quanti_mutation_rate",DBL,true,true,0,1, 0); // MANDATORY
122  add_parameter("quanti_mutation_variance",DBL,false,false,0,0, 0); // accept locus-specific values
123 
124  // pleiotropy
125  add_parameter("quanti_pleiotropy", STR, false, false, 0,0, 0); // optional
126  add_parameter("quanti_mutation_correlation",DBL,false,false,0,0, 0); // accept locus-specific values
127  add_parameter("quanti_mutation_matrix",MAT,false,false,0,0, 0);
128  add_parameter("quanti_pleio_matrix",INT,false,true,0,1); // allows user to set pleiotropic degree of loci
129 
130  //dominance
131 // add_parameter("quanti_dominance_model", INT, false, true, 0, 1, 0);
132  add_parameter("quanti_dominance_mean", DBL, false, false, 0, 0, 0);
133  add_parameter("quanti_dominance_sd", DBL, false, false, 0, 0, 0);
134  add_parameter("quanti_dominance_effects", DBL, false, false, 0, 0, 0);
135 
136  //epsistasis
137  add_parameter("quanti_epistatic_effects", MAT, false, false, 0, 0, 0);
138  add_parameter("quanti_epistatic_network", MAT, false, false, 0, 0, 0);
139 
140  //genetic map parameters:
142 
143  // output
144  add_parameter("quanti_output",STR,false,false,0,0);
145  add_parameter("quanti_logtime",INT,false,false,0,0);
146  add_parameter("quanti_dir",STR,false,false,0,0);
147 
148  add_parameter("quanti_freq_output",BOOL,false,false,0,0);
149  add_parameter("quanti_freq_logtime",INT,false,false,0,0);
150 
151  add_parameter("quanti_ohta_output",BOOL,false,false,0,0);
152  add_parameter("quanti_ohta_logtime",INT,false,false,0,0);
153 
154 
155 // some pointer initialization:
156  _sequence_diallele_values[0] = NULL;
157  _sequence_diallele_values[1] = NULL;
158  _equal_effects = false;
159  _equal_val_0 = 0.0;
160  _equal_val_1 = 0.0;
161  _equal_val_diff = 0.0;
162 
163 }
virtual void set_paramset(ParamSet *paramset)
Sets the ParamSet member.
Definition: simcomponent.h:86
virtual void add_parameter(Param *param)
Interface to add a parameter to the set.
Definition: simcomponent.h:112
bool _equal_effects
Definition: ttquanti.h:624
vector< double > _eVariance
Definition: ttquanti.h:657
unsigned int _allele_model
Definition: ttquanti.h:610
bool _epistasis
Definition: ttquanti.h:680
size_t _sizeofLocusType
Definition: ttquanti.h:654
unsigned int _doInitMutation
Definition: ttquanti.h:642
unsigned int _dominance_model
Definition: ttquanti.h:647
void(TProtoQuanti::* _inherit_fun_ptr)(sex_t, TTQuanti *, const TTQuanti *)
Pointer to inheritance functions: either inherit_free() (r=0.5), or inherit_low() (r<0....
Definition: ttquanti.h:689
bool _h2_isBroad
Definition: ttquanti.h:660
TTQuantiFH * _reader
Definition: ttquanti.h:724
unsigned int _h2_setTime
Definition: ttquanti.h:659
unsigned int _seq_length
Total number of allelic values stored in individual sequences, no trait x no locus.
Definition: ttquanti.h:609
double _mutation_rate
Definition: ttquanti.h:614
gsl_matrix ** _evect
Definition: ttquanti.h:637
gsl_vector ** _ws
Definition: ttquanti.h:640
bool _mutationVarianceIsLocusSpecific
Definition: ttquanti.h:643
unsigned int _num_epi_coefs
Definition: ttquanti.h:681
unsigned int _num_traits
Number of traits.
Definition: ttquanti.h:607
double * _sequence_diallele_values[2]
Definition: ttquanti.h:623
TTQuantiSH * _stats
Definition: ttquanti.h:722
void(TProtoQuanti::* _mutation_func_ptr)(TTQuanti *)
Pointer to mutation function, which depends on allele on model (HC, noHC, diallelic)
Definition: ttquanti.h:692
gsl_vector ** _effects_multivar
Definition: ttquanti.h:639
double(TProtoQuanti::* _set_genotype_func_ptr)(const TTQuanti *, const unsigned int)
Pointer to functions get_genotype_value_additive() or get_genotype_value_dominance() computing the ge...
Definition: ttquanti.h:713
double _genomic_mutation_rate
Definition: ttquanti.h:615
gsl_matrix ** _gsl_mutation_matrix
Definition: ttquanti.h:636
bool * _all_chooser
Definition: ttquanti.h:652
double(TProtoQuanti::* _getGenotypeWithDominance)(double, double, double)
Pointer to either dominance_h() or dominance_k() function computing the genotypic value with dominanc...
Definition: ttquanti.h:701
double _equal_val_diff
Definition: ttquanti.h:627
double _equal_val_0
Definition: ttquanti.h:625
size_t _locusByteSize
Definition: ttquanti.h:653
double(TProtoQuanti::* _set_trait_value_func_ptr)(const TTQuanti *, const unsigned int)
Pointer to either set_trait_value_VE() or set_trait_value_noVE() to compute phenotypic values.
Definition: ttquanti.h:707
double *(TProtoQuanti::* _getMutationValues)(unsigned int)
Pointer to mutation allele value function, which depends on allele model and number of traits affecte...
Definition: ttquanti.h:695
gsl_vector ** _eval
Definition: ttquanti.h:638
TTQuantiFH * _writer
Definition: ttquanti.h:723
bool _mutationEffectIsFixedDiAllele
Definition: ttquanti.h:644
TTQOhtaStats * _ohtaStats
Definition: ttquanti.h:726
unsigned int _2L
Diploid locus size, to save on useless operations during mutation.
Definition: ttquanti.h:605
unsigned int _num_locus
Total number of loci, for all traits.
Definition: ttquanti.h:603
double _equal_val_1
Definition: ttquanti.h:626
unsigned int _pleio_type
Definition: ttquanti.h:618
TTQFreqExtractor * _freqExtractor
Definition: ttquanti.h:725
void addGeneticMapParameters(string prefix)
Definition: ttrait_with_map.cc:78
@ DBL
Definition: types.h:78
@ MAT
Definition: types.h:78
@ BOOL
Definition: types.h:78
@ STR
Definition: types.h:78
@ INT
Definition: types.h:78

References _equal_effects, _equal_val_0, _equal_val_1, _equal_val_diff, _sequence_diallele_values, SimComponent::add_parameter(), TTProtoWithMap::addGeneticMapParameters(), BOOL, DBL, INT, MAT, SimComponent::set_paramset(), and STR.

Referenced by clone().

◆ TProtoQuanti() [2/2]

TProtoQuanti::TProtoQuanti ( const TProtoQuanti T)
167  :
169  _2L(_2L),
174  _evect(0),
175  _eval(0),
177  _ws(0),
180  _h2_setTime(0),
181  _h2_isBroad(0),
182  _pleio_type(0),
183  _doInitMutation(0),
186  _dominance_model(0),
187  _all_chooser(0),
188  _locusByteSize(0),
190  _eVariance(0),
193  _inherit_fun_ptr(0),
199  _stats(0),
200  _writer(0),
201  _reader(0),
202  _freqExtractor(0),
203  _ohtaStats(0)
204 {
205  _locusByteSize = T._num_traits * sizeof(double);
206  _paramSet = new ParamSet( *(T._paramSet) ) ;
207 
209 
210  _sequence_diallele_values[0] = NULL;
211  _sequence_diallele_values[1] = NULL;
216 
219 
220 }
Parameters container, implemented in each SimComponent.
Definition: param.h:206
ParamSet * _paramSet
The parameters container.
Definition: simcomponent.h:48
void copy(const TMatrix &mat)
Copy a matrix.
Definition: tmatrix.h:78
TMatrix _pleio_matx
Pleiotropy matrix provided in input (num locu X num trait).
Definition: ttquanti.h:665
TMatrix _epistatic_coefs_matrix
Definition: ttquanti.h:682
TMatrix _epistatic_coefs_indices
Definition: ttquanti.h:683

References _epistatic_coefs_indices, _epistatic_coefs_matrix, _equal_effects, _equal_val_0, _equal_val_1, _equal_val_diff, _locusByteSize, _num_traits, SimComponent::_paramSet, _pleio_matx, _sequence_diallele_values, and TMatrix::copy().

◆ ~TProtoQuanti()

TProtoQuanti::~TProtoQuanti ( )
virtual
225 {
227 
228  if(_stats){delete _stats; _stats = NULL;}
229  if(_writer){delete _writer; _writer = NULL;}
230  if(_reader) delete _reader;
231  if(_freqExtractor){delete _freqExtractor; _freqExtractor = NULL;}
232  if(_ohtaStats) {delete _ohtaStats; _ohtaStats = NULL;}
233  if(_all_chooser) {delete [] _all_chooser; _all_chooser = NULL;}
234 
236  delete [] _sequence_diallele_values[0];
237  _sequence_diallele_values[0] = NULL;
238  }
239 
241  delete [] _sequence_diallele_values[1];
242  _sequence_diallele_values[1] = NULL;
243  }
244 
245 }
void deallocate_gsl_mutation_matrix_space()
Definition: ttquanti.cc:2137

References _all_chooser, _freqExtractor, _ohtaStats, _reader, _sequence_diallele_values, _stats, _writer, and deallocate_gsl_mutation_matrix_space().

Member Function Documentation

◆ allocate_gsl_mutation_matrix_space()

void TProtoQuanti::allocate_gsl_mutation_matrix_space ( unsigned int  num_locus)
2118 {
2119  _eval = new gsl_vector* [num_loc];
2120  _evect = new gsl_matrix* [num_loc];
2121  _effects_multivar = new gsl_vector* [num_loc];;
2122  _ws = new gsl_vector* [num_loc];
2123  _gsl_mutation_matrix = new gsl_matrix* [num_loc];
2124 
2125  // initializing pointers
2126  for(unsigned int i = 0; i < num_loc; ++i) {
2127  _eval[i] = NULL;
2128  _evect[i] = NULL;
2129  _effects_multivar[i] = NULL;
2130  _ws[i] = NULL;
2131  _gsl_mutation_matrix[i] = NULL;
2132  }
2133 }

References _effects_multivar, _eval, _evect, _gsl_mutation_matrix, and _ws.

Referenced by setContinuousMutationModel_full_pleio(), and setContinuousMutationModel_var_pleio().

◆ clone()

virtual TProtoQuanti* TProtoQuanti::clone ( )
inlinevirtual

Implements TraitPrototype.

575 {return new TProtoQuanti(*this);}
TProtoQuanti()
Definition: ttquanti.cc:64

References TProtoQuanti().

◆ deallocate_gsl_mutation_matrix_space()

void TProtoQuanti::deallocate_gsl_mutation_matrix_space ( )
2138 {
2139 
2140  unsigned int SIZE = 1;
2141 
2142  if(_mutationVarianceIsLocusSpecific) // this should represent the state of the simulation which did the allocation
2143  SIZE = _num_locus;
2144 
2146 
2147  for(unsigned int i = 0; i < SIZE; ++i)
2148  if(_gsl_mutation_matrix[i]) gsl_matrix_free(_gsl_mutation_matrix[i]);
2149 
2150  delete [] _gsl_mutation_matrix;
2151  _gsl_mutation_matrix = NULL;
2152  }
2153 
2154  if(_evect) {
2155  for(unsigned int i = 0; i < SIZE; ++i)
2156  if(_evect[i]) gsl_matrix_free(_evect[i]);
2157  delete [] _evect;
2158  _evect = NULL;
2159  }
2160 
2161  if(_eval){
2162  for(unsigned int i = 0; i < SIZE; ++i)
2163  if(_eval[i]) gsl_vector_free(_eval[i]);
2164  delete [] _eval;
2165  _eval = NULL;
2166  }
2167 
2168  if(_effects_multivar) {
2169  for(unsigned int i = 0; i < SIZE; ++i)
2170  if(_effects_multivar[i]) gsl_vector_free(_effects_multivar[i]);
2171  delete [] _effects_multivar;
2172  _effects_multivar = NULL;
2173  }
2174 
2175  if(_ws) {
2176  for(unsigned int i = 0; i < SIZE; ++i)
2177  if(_ws[i]) gsl_vector_free(_ws[i]);
2178  delete [] _ws;
2179  _ws = NULL;
2180  }
2181 
2182 }

References _effects_multivar, _eval, _evect, _gsl_mutation_matrix, _mutationVarianceIsLocusSpecific, _num_locus, and _ws.

Referenced by setParameters(), and ~TProtoQuanti().

◆ do_epistasis()

bool TProtoQuanti::do_epistasis ( )
inline
567 {return _epistasis;}

References _epistasis.

Referenced by TTQuantiSH::addQuanti(), and TTQuantiSH::addVarPerPatch().

◆ get_allele_model()

◆ get_allele_number()

virtual int TProtoQuanti::get_allele_number ( )
inlinevirtual

Returns the number of allele per locus.

Implements TraitPrototype.

580 {return (_allele_model > 2 ? 3: 2);} //3 just means more than di-allelic

References _allele_model.

◆ get_allele_position()

int TProtoQuanti::get_allele_position ( const unsigned int  locus,
const unsigned int  trait 
)
2469 {
2470  // not assured that the locus is affecting that trait, first check
2471  if(std::any_of(_trait_locus_table[trait].cbegin(), _trait_locus_table[trait].cend(),
2472  [locus](unsigned int i){return (i == locus);})) {
2473 
2474  // we have to find where the locus sits in the table
2475  vector<unsigned int>::const_iterator I = find(_trait_locus_table[trait].cbegin(), _trait_locus_table[trait].cend(),
2476  locus);
2477  // find index of pointer
2478  unsigned int pos = I - _trait_locus_table[trait].cbegin();
2479 
2480  return _trait_table[trait][pos];
2481  }
2482  return -1;
2483 }
vector< vector< unsigned int > > _trait_locus_table
Table storing the locus id of each locus affecting each trait (num trait X (variable length/trait)).
Definition: ttquanti.h:671
vector< vector< unsigned int > > _trait_table
Trait table, (num trait X (variable length/trait)), holds, for each trait, the array position of caus...
Definition: ttquanti.h:668

References _trait_locus_table, and _trait_table.

Referenced by get_allele_value().

◆ get_allele_value()

double TProtoQuanti::get_allele_value ( const TTQuanti ind,
const unsigned int  allele,
const unsigned int  locus,
const unsigned int  trait 
)
2488 {
2489  assert(allele < 2); // can be 0 or 1 only
2490 
2491  int pos = get_allele_position(locus, trait);
2492 
2493  if(pos > -1)
2494  return ind->get_allele_value(pos, allele);
2495  else
2496  return error("TProtoQuanti::get_allele_value::wrong allele position at locus %i for trait %i\n", locus, trait);
2497 }
int get_allele_position(const unsigned int locus, const unsigned int trait)
Definition: ttquanti.cc:2468
virtual double get_allele_value(int loc, int all) const =0
Called to read the value of the allele at a particular locus.
int error(const char *str,...)
Definition: output.cc:79

References error(), get_allele_position(), and TTrait::get_allele_value().

◆ get_diallele_value()

double TProtoQuanti::get_diallele_value ( unsigned int  locus,
unsigned int  allele 
)
inline
437  {return _allele_value.get(locus, allele);}
double get(unsigned int i, unsigned int j) const
Accessor to element at row i and column j.
Definition: tmatrix.h:193
TMatrix _allele_value
Definition: ttquanti.h:622

References _allele_value, and TMatrix::get().

◆ get_diallele_values()

const TMatrix& TProtoQuanti::get_diallele_values ( )
inline

◆ get_doInitMutation()

◆ get_dominance()

double TProtoQuanti::get_dominance ( unsigned int  locus,
unsigned int  trait 
)
inline

◆ get_dominance_effects()

const TMatrix& TProtoQuanti::get_dominance_effects ( )
inline

◆ get_dominance_model()

◆ get_env_var()

vector<double> TProtoQuanti::get_env_var ( )
inline

◆ get_epi_coef_index()

◆ get_epi_coefs()

◆ get_equal_val_0()

◆ get_equal_val_1()

◆ get_equal_val_diff()

◆ get_genotype_dominance_h()

double TProtoQuanti::get_genotype_dominance_h ( double  a1,
double  a2,
double  h 
)
inline
2558 {
2559  if(a1<a2) return 2*((1-h)*a1 + h*a2);
2560  return 2*((1-h)*a2 + h*a1);
2561 }

◆ get_genotype_dominance_k()

double TProtoQuanti::get_genotype_dominance_k ( double  a1,
double  a2,
double  k 
)
inline
2574 {
2575  return a1 + a2 + k*fabs(a2-a1);
2576 }

Referenced by get_genotype_with_dominance(), and setParameters().

◆ get_genotype_with_dominance()

double TProtoQuanti::get_genotype_with_dominance ( const double  a1,
const double  a2,
const unsigned int  locus,
const unsigned int  trait 
)
2541 {
2542  // let's use the "k" model by default, it's the fastest:
2543  return get_genotype_dominance_k( a1 , a2, get_dominance(locus, trait));
2544 // return (this->*_getGenotypeWithDominance)( a1 , a2, get_dominance(locus, trait));
2545 }
double get_dominance(unsigned int locus, unsigned int trait)
Definition: ttquanti.h:479
double get_genotype_dominance_k(double a1, double a2, double k)
Definition: ttquanti.cc:2573

References get_dominance(), and get_genotype_dominance_k().

Referenced by TTQuanti_continuous_full_pleio::get_dominant_genotype(), TTQuanti_continuous_var_pleio::get_dominant_genotype(), TTQuanti_continuous_single::get_dominant_genotype(), TTQuanti_diallelic_no_pleio::get_dominant_genotype(), TTQuanti_diallelic_full_pleio::get_dominant_genotype(), TTQuanti_diallelic_var_pleio::get_dominant_genotype(), TTQuanti_diallelic_bitstring_no_pleio::get_dominant_genotype(), TTQuanti_diallelic_bitstring_full_pleio::get_dominant_genotype(), TTQuanti_diallelic_bitstring_var_pleio::get_dominant_genotype(), TTQuanti_continuous_full_pleio_epistasis::get_dominant_genotype(), TTQuanti_diallelic_full_pleio_epistasis::get_dominant_genotype(), TTQuanti_continuous_no_pleio_epistasis::get_dominant_genotype(), TTQuanti_diallelic_no_pleio_epistasis::get_dominant_genotype(), TTQuanti_diallelic_bitstring_no_pleio_epistasis::get_dominant_genotype(), TTQuanti_diallelic_bitstring_full_pleio_epistasis::get_dominant_genotype(), and TTQuantiSH::getVaWithDominance().

◆ get_genotypic_value()

double TProtoQuanti::get_genotypic_value ( const TTQuanti ind,
const unsigned int  trait 
)
inline

◆ get_h2_isBroad()

bool TProtoQuanti::get_h2_isBroad ( )
inline
433 {return _h2_isBroad;}

References _h2_isBroad.

Referenced by TTQuantiSH::getVaWithDominance().

◆ get_h2_setTime()

unsigned int TProtoQuanti::get_h2_setTime ( )
inline
432 {return _h2_setTime;}

References _h2_setTime.

Referenced by LCE_Breed_Quanti::setVefromVa().

◆ get_heritability()

vector<double> TProtoQuanti::get_heritability ( )
inline

◆ get_init_value()

◆ get_init_variance()

◆ get_locus_byte_size()

◆ get_locus_ID()

◆ get_locus_number()

virtual int TProtoQuanti::get_locus_number ( )
inlinevirtual

Returns the number of locus.

Implements TraitPrototype.

582 {return _num_locus;}

References _num_locus.

◆ get_locus_PD()

unsigned int TProtoQuanti::get_locus_PD ( unsigned int  locus)
inline
457 {return _locus_table[locus][1];}
vector< vector< unsigned int > > _locus_table
Locus table, num_locus x 2, first column holds the start position of the alleles of each locus in the...
Definition: ttquanti.h:676

References _locus_table.

Referenced by TTQuanti_diallelic_bitstring_var_pleio::copy_sequence_1locus(), TTQuanti_continuous_var_pleio::copy_sequence_1locus(), TTQuanti_diallelic_var_pleio::copy_sequence_1locus(), getMutationEffectMultivariateGaussian(), getMutationEffectMultivariateGaussianLocSpec(), and TTQuanti_continuous_var_pleio::init_sequence().

◆ get_locus_seq_pos()

unsigned int TProtoQuanti::get_locus_seq_pos ( unsigned int  loc,
unsigned int  trait 
)
inline
454  {return _trait_table[trait][loc];}

References _trait_table.

Referenced by TTQuantiFH::FHread(), TTQFreqExtractor::FHwrite(), TTQuanti_continuous_var_pleio::get_additive_genotype(), TTQuanti_continuous_no_pleio::get_additive_genotype(), TTQuanti_diallelic_no_pleio::get_additive_genotype(), TTQuanti_diallelic_full_pleio::get_additive_genotype(), TTQuanti_diallelic_var_pleio::get_additive_genotype(), TTQuanti_diallelic_bitstring_no_pleio::get_additive_genotype(), TTQuanti_diallelic_bitstring_full_pleio::get_additive_genotype(), TTQuanti_diallelic_bitstring_var_pleio::get_additive_genotype(), TTQuanti_diallelic_full_pleio_epistasis::get_additive_genotype(), TTQuanti_continuous_no_pleio_epistasis::get_additive_genotype(), TTQuanti_diallelic_no_pleio_epistasis::get_additive_genotype(), TTQuanti_diallelic_bitstring_no_pleio_epistasis::get_additive_genotype(), TTQuanti_diallelic_bitstring_full_pleio_epistasis::get_additive_genotype(), TTQuanti_diallelic_bitstring_no_pleio::get_additive_genotype_equal_effects(), TTQuanti_continuous_var_pleio::get_dominant_genotype(), TTQuanti_continuous_no_pleio::get_dominant_genotype(), TTQuanti_diallelic_no_pleio::get_dominant_genotype(), TTQuanti_diallelic_full_pleio::get_dominant_genotype(), TTQuanti_diallelic_var_pleio::get_dominant_genotype(), TTQuanti_diallelic_bitstring_no_pleio::get_dominant_genotype(), TTQuanti_diallelic_bitstring_full_pleio::get_dominant_genotype(), TTQuanti_diallelic_bitstring_var_pleio::get_dominant_genotype(), TTQuanti_diallelic_full_pleio_epistasis::get_dominant_genotype(), TTQuanti_continuous_no_pleio_epistasis::get_dominant_genotype(), TTQuanti_diallelic_no_pleio_epistasis::get_dominant_genotype(), TTQuanti_diallelic_bitstring_no_pleio_epistasis::get_dominant_genotype(), TTQuanti_diallelic_bitstring_full_pleio_epistasis::get_dominant_genotype(), TTQuantiSH::getVaWithDominance(), TTQuanti_continuous_var_pleio::init_sequence(), TTQuanti_continuous_no_pleio::init_sequence(), TTQuanti_diallelic_full_pleio::init_sequence(), TTQuanti_diallelic_var_pleio::init_sequence(), TTQuanti_diallelic_bitstring_full_pleio::init_sequence(), TTQuanti_diallelic_bitstring_var_pleio::init_sequence(), TTQuanti_diallelic_full_pleio_epistasis::init_sequence(), TTQuanti_continuous_no_pleio_epistasis::init_sequence(), TTQuanti_diallelic_bitstring_full_pleio_epistasis::init_sequence(), TTQuantiFH::print(), TTQuantiFH::print_PLINK_PED(), setDiallelicMutationModel(), TTQuanti_continuous_var_pleio::show_up(), TTQuanti_continuous_no_pleio::show_up(), TTQuanti_diallelic_no_pleio::show_up(), TTQuanti_diallelic_full_pleio::show_up(), TTQuanti_diallelic_var_pleio::show_up(), TTQuanti_diallelic_bitstring_no_pleio::show_up(), TTQuanti_diallelic_bitstring_full_pleio::show_up(), TTQuanti_diallelic_bitstring_var_pleio::show_up(), TTQuanti_diallelic_full_pleio_epistasis::show_up(), TTQuanti_continuous_no_pleio_epistasis::show_up(), TTQuanti_diallelic_no_pleio_epistasis::show_up(), TTQuanti_diallelic_bitstring_no_pleio_epistasis::show_up(), and TTQuanti_diallelic_bitstring_full_pleio_epistasis::show_up().

◆ get_locus_start_pos()

◆ get_num_epi_coefs()

unsigned int TProtoQuanti::get_num_epi_coefs ( )
inline
566 {return _num_epi_coefs;}

References _num_epi_coefs.

◆ get_num_locus() [1/2]

unsigned int TProtoQuanti::get_num_locus ( )
inline
424 {return _num_locus;}

References _num_locus.

Referenced by TTQuantiFH::FHread(), TTQFreqExtractor::FHwrite(), TTQOhtaStats::FHwrite(), TTQuanti_continuous_full_pleio::get_additive_genotype(), TTQuanti_continuous_var_pleio::get_additive_genotype(), TTQuanti_continuous_no_pleio::get_additive_genotype(), TTQuanti_continuous_single::get_additive_genotype(), TTQuanti_diallelic_no_pleio::get_additive_genotype(), TTQuanti_diallelic_full_pleio::get_additive_genotype(), TTQuanti_diallelic_var_pleio::get_additive_genotype(), TTQuanti_diallelic_bitstring_no_pleio::get_additive_genotype(), TTQuanti_diallelic_bitstring_full_pleio::get_additive_genotype(), TTQuanti_diallelic_bitstring_var_pleio::get_additive_genotype(), TTQuanti_continuous_full_pleio_epistasis::get_additive_genotype(), TTQuanti_diallelic_full_pleio_epistasis::get_additive_genotype(), TTQuanti_continuous_no_pleio_epistasis::get_additive_genotype(), TTQuanti_diallelic_no_pleio_epistasis::get_additive_genotype(), TTQuanti_diallelic_bitstring_no_pleio_epistasis::get_additive_genotype(), TTQuanti_diallelic_bitstring_full_pleio_epistasis::get_additive_genotype(), TTQuanti_diallelic_bitstring_no_pleio::get_additive_genotype_equal_effects(), TTQuanti_continuous_full_pleio::get_dominant_genotype(), TTQuanti_continuous_var_pleio::get_dominant_genotype(), TTQuanti_continuous_no_pleio::get_dominant_genotype(), TTQuanti_continuous_single::get_dominant_genotype(), TTQuanti_diallelic_no_pleio::get_dominant_genotype(), TTQuanti_diallelic_full_pleio::get_dominant_genotype(), TTQuanti_diallelic_var_pleio::get_dominant_genotype(), TTQuanti_diallelic_bitstring_no_pleio::get_dominant_genotype(), TTQuanti_diallelic_bitstring_full_pleio::get_dominant_genotype(), TTQuanti_diallelic_bitstring_var_pleio::get_dominant_genotype(), TTQuanti_continuous_full_pleio_epistasis::get_dominant_genotype(), TTQuanti_diallelic_full_pleio_epistasis::get_dominant_genotype(), TTQuanti_continuous_no_pleio_epistasis::get_dominant_genotype(), TTQuanti_diallelic_no_pleio_epistasis::get_dominant_genotype(), TTQuanti_diallelic_bitstring_no_pleio_epistasis::get_dominant_genotype(), TTQuanti_diallelic_bitstring_full_pleio_epistasis::get_dominant_genotype(), TTQuantiSH::getVaWithDominance(), TTQuantiSH::init(), TTQuanti_continuous_full_pleio::init_sequence(), TTQuanti_continuous_var_pleio::init_sequence(), TTQuanti_continuous_no_pleio::init_sequence(), TTQuanti_diallelic_no_pleio::init_sequence(), TTQuanti_diallelic_full_pleio::init_sequence(), TTQuanti_diallelic_var_pleio::init_sequence(), TTQuanti_diallelic_bitstring_no_pleio::init_sequence(), TTQuanti_diallelic_bitstring_full_pleio::init_sequence(), TTQuanti_diallelic_bitstring_var_pleio::init_sequence(), TTQuanti_continuous_full_pleio_epistasis::init_sequence(), TTQuanti_diallelic_full_pleio_epistasis::init_sequence(), TTQuanti_continuous_no_pleio_epistasis::init_sequence(), TTQuanti_diallelic_no_pleio_epistasis::init_sequence(), TTQuanti_diallelic_bitstring_no_pleio_epistasis::init_sequence(), TTQuanti_diallelic_bitstring_full_pleio_epistasis::init_sequence(), TTQuanti_continuous::operator==(), TTQuanti_diallelic::operator==(), TTQuanti_diallelic_bitstring::operator==(), TTQuantiFH::print(), TTQuantiFH::print_PLINK_PED(), setDiallelicMutationModel(), LCE_QuantiInit::setParameters(), TTQuanti_continuous_full_pleio::show_up(), TTQuanti_continuous_var_pleio::show_up(), TTQuanti_continuous_no_pleio::show_up(), TTQuanti_diallelic_no_pleio::show_up(), TTQuanti_diallelic_full_pleio::show_up(), TTQuanti_diallelic_var_pleio::show_up(), TTQuanti_diallelic_bitstring_no_pleio::show_up(), TTQuanti_diallelic_bitstring_full_pleio::show_up(), TTQuanti_diallelic_bitstring_var_pleio::show_up(), TTQuanti_continuous_full_pleio_epistasis::show_up(), TTQuanti_diallelic_full_pleio_epistasis::show_up(), TTQuanti_continuous_no_pleio_epistasis::show_up(), TTQuanti_diallelic_no_pleio_epistasis::show_up(), TTQuanti_diallelic_bitstring_no_pleio_epistasis::show_up(), TTQuanti_diallelic_bitstring_full_pleio_epistasis::show_up(), TTQuantiFH::write_PLINK(), and TTQuantiFH::write_TABLE().

◆ get_num_locus() [2/2]

unsigned int TProtoQuanti::get_num_locus ( unsigned int  trait)
inline
425 {return _trait_table[trait].size();}

References _trait_table.

◆ get_num_mutations()

unsigned int TProtoQuanti::get_num_mutations ( )
inline

◆ get_num_traits()

unsigned int TProtoQuanti::get_num_traits ( )
inline
423 {return _num_traits;}

References _num_traits.

Referenced by LCE_PhenotypeExpression::check_g_index_matrix(), TTQuanti_diallelic_bitstring_full_pleio::copy_sequence_1locus(), TTQuanti_continuous_full_pleio_epistasis::copy_sequence_1locus(), TTQuanti_diallelic_full_pleio_epistasis::copy_sequence_1locus(), TTQuanti_diallelic_bitstring_full_pleio_epistasis::copy_sequence_1locus(), TTQuanti_continuous_full_pleio::copy_sequence_1locus(), TTQuanti_diallelic_full_pleio::copy_sequence_1locus(), TTQuanti_diallelic_bitstring_full_pleio::copy_sequence_block(), TTQuanti_continuous_full_pleio_epistasis::copy_sequence_block(), TTQuanti_diallelic_full_pleio_epistasis::copy_sequence_block(), TTQuanti_diallelic_bitstring_full_pleio_epistasis::copy_sequence_block(), TTQuanti_continuous_full_pleio::copy_sequence_block(), TTQuanti_diallelic_full_pleio::copy_sequence_block(), TTQuantiFH::FHread(), TTQFreqExtractor::FHwrite(), TTQOhtaStats::FHwrite(), TTQuanti_continuous_full_pleio::get_additive_genotype(), TTQuanti_diallelic_full_pleio::get_additive_genotype(), TTQuanti_diallelic_bitstring_full_pleio::get_additive_genotype(), TTQuanti_continuous_full_pleio_epistasis::get_additive_genotype(), TTQuanti_diallelic_full_pleio_epistasis::get_additive_genotype(), TTQuanti_diallelic_bitstring_full_pleio_epistasis::get_additive_genotype(), TTQuanti_continuous_full_pleio::get_dominant_genotype(), TTQuanti_diallelic_full_pleio::get_dominant_genotype(), TTQuanti_diallelic_bitstring_full_pleio::get_dominant_genotype(), TTQuanti_continuous_full_pleio_epistasis::get_dominant_genotype(), TTQuanti_diallelic_full_pleio_epistasis::get_dominant_genotype(), TTQuanti_diallelic_bitstring_full_pleio_epistasis::get_dominant_genotype(), TTQuanti_continuous::init(), TTQuanti_diallelic::init(), TTQuantiSH::init(), TTQuanti_diallelic_bitstring::init(), TTQuanti_continuous_full_pleio::init_sequence(), TTQuanti_continuous_var_pleio::init_sequence(), TTQuanti_continuous_no_pleio::init_sequence(), TTQuanti_diallelic_full_pleio::init_sequence(), TTQuanti_diallelic_var_pleio::init_sequence(), TTQuanti_diallelic_bitstring_full_pleio::init_sequence(), TTQuanti_diallelic_bitstring_var_pleio::init_sequence(), TTQuanti_continuous_full_pleio_epistasis::init_sequence(), TTQuanti_diallelic_full_pleio_epistasis::init_sequence(), TTQuanti_continuous_no_pleio_epistasis::init_sequence(), TTQuanti_diallelic_bitstring_full_pleio_epistasis::init_sequence(), TTQuanti_continuous::operator==(), TTQuanti_diallelic::operator==(), TTQuanti_diallelic_bitstring::operator==(), TTQuantiFH::print(), TTQuantiFH::print_PLINK_FAM(), TTQuantiFH::print_PLINK_PED(), TTQuanti::reset_phenotype_to_genotypic_value(), LCE_PhenotypeExpression::set_g_value_matrix(), TTQuanti::set_value(), LCE_PhenotypeExpression::setParameters(), LCE_QuantiModifier::setVefromVa(), LCE_Breed_Quanti::setVefromVa(), TTQuanti_continuous_full_pleio::show_up(), TTQuanti_continuous_var_pleio::show_up(), TTQuanti_continuous_no_pleio::show_up(), TTQuanti_diallelic_no_pleio::show_up(), TTQuanti_diallelic_full_pleio::show_up(), TTQuanti_diallelic_var_pleio::show_up(), TTQuanti_diallelic_bitstring_no_pleio::show_up(), TTQuanti_diallelic_bitstring_full_pleio::show_up(), TTQuanti_diallelic_bitstring_var_pleio::show_up(), TTQuanti_continuous_full_pleio_epistasis::show_up(), TTQuanti_diallelic_full_pleio_epistasis::show_up(), TTQuanti_continuous_no_pleio_epistasis::show_up(), TTQuanti_diallelic_no_pleio_epistasis::show_up(), TTQuanti_diallelic_bitstring_no_pleio_epistasis::show_up(), TTQuanti_diallelic_bitstring_full_pleio_epistasis::show_up(), TTQuantiFH::write_PLINK(), and TTQuantiFH::write_TABLE().

◆ get_phenotype_dimension()

virtual int TProtoQuanti::get_phenotype_dimension ( )
inlinevirtual

Returns the dimension of the phenotype of the trait (size of the array accessed with TTrait::getValue()

Implements TraitPrototype.

578 {return _num_traits;}

References _num_traits.

◆ get_phenotypic_value()

double TProtoQuanti::get_phenotypic_value ( const TTQuanti ind,
const unsigned int  trait 
)
inline
489  {
490  return (this->*_set_trait_value_func_ptr)(ind, trait);
491  }

References _set_trait_value_func_ptr.

Referenced by TTQuanti::set_value().

◆ get_pleio_matrix()

const TMatrix& TProtoQuanti::get_pleio_matrix ( )
inline
452 {return _pleio_matx;}

References _pleio_matx.

◆ get_pleiotropy_type()

unsigned int TProtoQuanti::get_pleiotropy_type ( )
inline

◆ get_seq_diallele_value()

double TProtoQuanti::get_seq_diallele_value ( unsigned int  position,
unsigned int  allele 
)
inline
439  {return _sequence_diallele_values[allele][position];}

References _sequence_diallele_values.

Referenced by TTQuantiFH::FHread(), TTQuanti_diallelic_no_pleio::get_additive_genotype(), TTQuanti_diallelic_full_pleio::get_additive_genotype(), TTQuanti_diallelic_var_pleio::get_additive_genotype(), TTQuanti_diallelic_bitstring_no_pleio::get_additive_genotype(), TTQuanti_diallelic_bitstring_full_pleio::get_additive_genotype(), TTQuanti_diallelic_bitstring_var_pleio::get_additive_genotype(), TTQuanti_diallelic_full_pleio_epistasis::get_additive_genotype(), TTQuanti_diallelic_no_pleio_epistasis::get_additive_genotype(), TTQuanti_diallelic_bitstring_no_pleio_epistasis::get_additive_genotype(), TTQuanti_diallelic_bitstring_full_pleio_epistasis::get_additive_genotype(), TTQuanti_diallelic::get_allele_value(), TTQuanti_diallelic_bitstring::get_allele_value(), TTQuanti_diallelic_no_pleio::get_dominant_genotype(), TTQuanti_diallelic_full_pleio::get_dominant_genotype(), TTQuanti_diallelic_var_pleio::get_dominant_genotype(), TTQuanti_diallelic_bitstring_no_pleio::get_dominant_genotype(), TTQuanti_diallelic_bitstring_full_pleio::get_dominant_genotype(), TTQuanti_diallelic_bitstring_var_pleio::get_dominant_genotype(), TTQuanti_diallelic_full_pleio_epistasis::get_dominant_genotype(), TTQuanti_diallelic_no_pleio_epistasis::get_dominant_genotype(), TTQuanti_diallelic_bitstring_no_pleio_epistasis::get_dominant_genotype(), TTQuanti_diallelic_bitstring_full_pleio_epistasis::get_dominant_genotype(), TTQuanti_diallelic::set_allele_value(), and TTQuanti_diallelic_bitstring::set_allele_value().

◆ get_seq_length()

unsigned int TProtoQuanti::get_seq_length ( )
inline
427 {return _seq_length;}

References _seq_length.

Referenced by TTQuantiFH::FHread(), TTQFreqExtractor::FHwrite(), TTQuanti_diallelic::get_allele(), TTQuanti_diallelic_bitstring::get_allele(), TTQuanti_continuous::get_allele_value(), TTQuanti_diallelic::get_allele_value(), TTQuanti_diallelic_bitstring::get_allele_value(), TTQuantiSH::getSNPalleleFreqInPatch(), TTQuanti_continuous::init(), TTQuanti_diallelic::init(), TTQuanti_diallelic_bitstring::init(), TTQuanti_diallelic_no_pleio::init_sequence(), TTQuanti_diallelic_full_pleio::init_sequence(), TTQuanti_diallelic_var_pleio::init_sequence(), TTQuanti_diallelic_bitstring_full_pleio::init_sequence(), TTQuanti_diallelic_bitstring_var_pleio::init_sequence(), TTQuanti_diallelic_full_pleio_epistasis::init_sequence(), TTQuanti_diallelic_no_pleio_epistasis::init_sequence(), TTQuanti_diallelic_bitstring_full_pleio_epistasis::init_sequence(), TTQuanti_continuous::operator=(), TTQuanti_diallelic::operator=(), TTQuanti_continuous::operator==(), TTQuanti_diallelic::operator==(), TTQuanti_diallelic_bitstring::operator==(), TTQuanti_continuous::retrieve_data(), TTQuanti_diallelic::retrieve_data(), TTQuanti_diallelic_bitstring::set_allele_bit(), TTQuanti_continuous::set_sequence(), TTQuanti_diallelic::set_sequence(), TTQuanti_continuous_full_pleio::show_up(), TTQuanti_continuous_var_pleio::show_up(), TTQuanti_continuous_no_pleio::show_up(), TTQuanti_diallelic_no_pleio::show_up(), TTQuanti_diallelic_full_pleio::show_up(), TTQuanti_diallelic_var_pleio::show_up(), TTQuanti_diallelic_bitstring_no_pleio::show_up(), TTQuanti_diallelic_bitstring_full_pleio::show_up(), TTQuanti_diallelic_bitstring_var_pleio::show_up(), TTQuanti_continuous_full_pleio_epistasis::show_up(), TTQuanti_diallelic_full_pleio_epistasis::show_up(), TTQuanti_continuous_no_pleio_epistasis::show_up(), TTQuanti_diallelic_no_pleio_epistasis::show_up(), TTQuanti_diallelic_bitstring_no_pleio_epistasis::show_up(), TTQuanti_diallelic_bitstring_full_pleio_epistasis::show_up(), TTQuanti_continuous::store_data(), and TTQuanti_diallelic::store_data().

◆ get_sequence_block_size()

◆ get_size_locus_type()

◆ get_stater()

TTQuantiSH* TProtoQuanti::get_stater ( )
inline
450 {return _stats;}

References _stats.

Referenced by LCE_QuantiModifier::setVefromVa(), and LCE_Breed_Quanti::setVefromVa().

◆ get_trait_mask()

◆ get_trait_mutation_variance()

double TProtoQuanti::get_trait_mutation_variance ( unsigned int  trait)
2581 {
2582  double Vm;
2583 
2584  if(_mutation_sigma.nrows() == 1) // same value for all loci
2585  Vm = 2 * _genomic_mutation_rate * _mutation_sigma.get(0, trait);
2586  else
2587  Vm = _mutation_sigma.colSum(trait) * _mutation_rate * 2;
2588 
2589  return Vm;
2590 }
double colSum(unsigned int col)
Sum all elements in a column.
Definition: tmatrix.h:308
unsigned int nrows() const
Definition: tmatrix.h:213
TMatrix _mutation_sigma
Definition: ttquanti.h:635

References _genomic_mutation_rate, _mutation_rate, _mutation_sigma, TMatrix::colSum(), TMatrix::get(), and TMatrix::nrows().

◆ get_type()

virtual trait_t TProtoQuanti::get_type ( ) const
inlinevirtual

Implements TraitPrototype.

576 {return QUANT;}
#define QUANT
Definition: types.h:72

References QUANT.

Referenced by TTQuantiSH::init(), TTQuantiFH::setOutputOption(), and TTQuantiFH::write_PLINK().

◆ getMutationEffectBivariateDiallelic()

double * TProtoQuanti::getMutationEffectBivariateDiallelic ( unsigned int  loc)
2458 {
2459  bool pos = RAND::RandBool();
2460  _effects_bivar[0] = _allele_value.get(loc, pos);
2462  pos : RAND::RandBool()) );
2463  return &_effects_bivar[0];
2464 }
static double Uniform()
Generates a random number from [0.0, 1.0[ uniformly distributed.
Definition: Uniform.h:127
static bool RandBool()
Returns a random boolean.
Definition: Uniform.h:165
TMatrix _mutation_correlation
Definition: ttquanti.h:634
double _effects_bivar[2]
Definition: ttquanti.h:641

References _allele_value, _effects_bivar, _mutation_correlation, TMatrix::get(), RAND::RandBool(), and RAND::Uniform().

Referenced by setMutationModel_full_pleio().

◆ getMutationEffectBivariateGaussian()

double * TProtoQuanti::getMutationEffectBivariateGaussian ( unsigned int  loc)
2415 {
2416  //no need to assert() as we are using a different set of containers and read from mutation_sigma directly
2418  &_effects_bivar[0], &_effects_bivar[1]);
2419  return &_effects_bivar[0];
2420 }
static void BivariateGaussian(double sigma1, double sigma2, double rho, double *out1, double *out2)
Definition: Uniform.h:333

References _effects_bivar, _mutation_correlation, _mutation_sigma, RAND::BivariateGaussian(), and TMatrix::get().

Referenced by setMutationModel_full_pleio(), and setMutationModel_var_pleio().

◆ getMutationEffectBivariateGaussianLocSpec()

double * TProtoQuanti::getMutationEffectBivariateGaussianLocSpec ( unsigned int  loc)

◆ getMutationEffectMultivariateGaussian()

double * TProtoQuanti::getMutationEffectMultivariateGaussian ( unsigned int  loc)
2391 {
2392  // assert we are using the correct mutation environment
2393  assert(get_locus_PD(loc) == _effects_multivar[0]->size);
2394 
2395  RAND::MultivariateGaussian(_eval[0], _evect[0], _ws[0], _effects_multivar[0]);
2396 
2397  return _effects_multivar[0]->data;
2398 }
unsigned int get_locus_PD(unsigned int locus)
Definition: ttquanti.h:457

References _effects_multivar, _eval, _evect, _ws, and get_locus_PD().

Referenced by setMutationModel_full_pleio().

◆ getMutationEffectMultivariateGaussianLocSpec()

double * TProtoQuanti::getMutationEffectMultivariateGaussianLocSpec ( unsigned int  loc)
2403 {
2404  // assert we are using the correct mutation environment
2405  assert(get_locus_PD(loc) == _effects_multivar[loc]->size);
2406 
2407  RAND::MultivariateGaussian(_eval[loc], _evect[loc], _ws[loc], _effects_multivar[loc]);
2408 
2409  return _effects_multivar[loc]->data;
2410 }

References _effects_multivar, _eval, _evect, _ws, and get_locus_PD().

Referenced by setMutationModel_full_pleio(), and setMutationModel_var_pleio().

◆ getMutationEffects()

double* TProtoQuanti::getMutationEffects ( unsigned int  loc)
inline

◆ getMutationEffectsVarPleio()

double* TProtoQuanti::getMutationEffectsVarPleio ( unsigned int  loc)
inline
536  {
537  return (this->* _getMutationValuesVarPleio[loc]) (loc);
538  }
vector< double *(TProtoQuanti::*)(unsigned int) > _getMutationValuesVarPleio
Collection of pointers to mutation functions, which generate allele values in dependence of pleiotrop...
Definition: ttquanti.h:698

References _getMutationValuesVarPleio.

Referenced by TTQuanti_continuous_var_pleio::init_sequence().

◆ getMutationEffectUnivariateGaussian()

double * TProtoQuanti::getMutationEffectUnivariateGaussian ( unsigned int  loc)
2434 {
2436  return &_effects_bivar[0];
2437 }
static double Gaussian(double sigma)
Definition: Uniform.h:264

References _effects_bivar, _mutation_sigma, RAND::Gaussian(), and TMatrix::get().

Referenced by setMutationModel_no_pleio(), and setMutationModel_var_pleio().

◆ getMutationEffectUnivariateGaussianLocSpec()

double * TProtoQuanti::getMutationEffectUnivariateGaussianLocSpec ( unsigned int  loc)

◆ has_equal_domCoeff()

◆ has_equal_effects()

◆ hatch()

TTQuanti * TProtoQuanti::hatch ( )
virtual

Implements TraitPrototype.

2899 {
2900  TTQuanti* kid;
2901 
2902  if(_epistasis && _pleio_type == 2)
2903  fatal("quantitative trait loci with variable pleiotropy are not implemented for the epistatic case.\n");
2904 
2905  if(_pleio_type == 0) { //non-pleiotropic cases
2906 
2907  if(_allele_model <= 2) { // diallelic
2908 
2909  if(_epistasis) {
2910  if(_diallele_datatype == "byte")
2912  else
2914  }
2915  else if(_diallele_datatype == "byte") {
2916  kid = new TTQuanti_diallelic_no_pleio();
2917  } else {
2919  }
2920 
2921  } else { // continuous
2922 
2923  if(_epistasis)
2925  else
2926  kid = new TTQuanti_continuous_no_pleio();
2927  }
2928 
2929  } else if (_pleio_type == 1) { //full-pleiotropic cases
2930 
2931  if(_allele_model <= 2) {
2932 
2933  if(_epistasis) {
2934  if(_diallele_datatype == "byte")
2936  else
2938  }
2939  else if(_diallele_datatype == "byte") {
2940  kid = new TTQuanti_diallelic_full_pleio();
2941  } else {
2943  }
2944 
2945  } else {
2946 
2947  if(_epistasis)
2949  else
2950  kid = new TTQuanti_continuous_full_pleio();
2951  }
2952 
2953  } else { // variable pleiotropy cases
2954 
2955  if(_allele_model <= 2) {
2956 
2957  if(_diallele_datatype == "byte")
2958  kid = new TTQuanti_diallelic_var_pleio();
2959  else
2961 
2962  } else {
2963  kid = new TTQuanti_continuous_var_pleio();
2964  }
2965  }
2966 
2967  kid->set_proto(this);
2968 
2969  // set specific optimisations:
2970 
2971 
2972  return kid;
2973 }
friend class TTQuanti_continuous_var_pleio
Definition: ttquanti.h:718
string _diallele_datatype
Definition: ttquanti.h:611
friend class TTQuanti_continuous_no_pleio
Definition: ttquanti.h:719
friend class TTQuanti_continuous_full_pleio
Definition: ttquanti.h:717
TTQuanti_continuous_full_pleio : universal pleiotropy.
Definition: ttquanti_epistasis.h:40
TTQuanti_continuous_no_pleio : multiple non-pleiotropic traits with epistasis.
Definition: ttquanti_epistasis.h:100
TTQuanti_diallelic_bitstring_full_pleio_epistasis : pleiotropic di-allelic bitstring with epistasis.
Definition: ttquanti_epistasis.h:188
TTQuanti_diallelic_bitstring_full_pleio : pleiotropic di-allelic loci, max PD = 2.
Definition: ttquanti_bitstring.h:130
TTQuanti_diallelic_bitstring_no_pleio_epistasis : non-pleiotropic di-allelic bitstring with epistasis...
Definition: ttquanti_epistasis.h:159
TTQuanti_diallelic_bitstring_no_pleio : single or multiple non-pleiotropic traits,...
Definition: ttquanti_bitstring.h:97
TTQuanti_diallelic_bitstring_var_pleio : variable pleiotropic di-allelic loci, max PD = 2.
Definition: ttquanti_bitstring.h:157
TTQuanti_diallelic_full_pleio : pleiotropic di-allelic loci, max PD = 2.
Definition: ttquanti_epistasis.h:70
TTQuanti_diallelic_full_pleio : pleiotropic di-allelic loci, max PD = 2.
Definition: ttquanti.h:356
TTQuanti_diallelic_no_pleio_epistasis : single or multiple non-pleiotropic traits,...
Definition: ttquanti_epistasis.h:129
TTQuanti_diallelic_no_pleio : single or multiple non-pleiotropic traits, di-allelic.
Definition: ttquanti.h:329
TTQuanti_diallelic_var_pleio : variable pleiotropic di-allelic loci, max PD = 2.
Definition: ttquanti.h:383
TTQuanti.
Definition: ttquanti.h:61
void set_proto(TProtoQuanti *proto)
Definition: ttquanti.h:97
void fatal(const char *str,...)
Definition: output.cc:100

References _allele_model, _diallele_datatype, _epistasis, _pleio_type, fatal(), TTQuanti::set_proto(), TTQuanti_continuous_full_pleio, TTQuanti_continuous_no_pleio, and TTQuanti_continuous_var_pleio.

Referenced by setParameters().

◆ inherit()

void TProtoQuanti::inherit ( sex_t  SEX,
TTQuanti ind,
const TTQuanti parent 
)
inline
2595 {
2596  (this->*_inherit_fun_ptr)(SEX, ind, parent);
2597 }

References _inherit_fun_ptr.

Referenced by TTQuanti::inherit().

◆ inherit_free()

void TProtoQuanti::inherit_free ( sex_t  SEX,
TTQuanti ind,
const TTQuanti parent 
)
inline
2640 {
2641 // assert(_all_chooser);
2642 
2643 // for(unsigned int i = 0; i < _num_locus; ++i)
2644 // _all_chooser[i] = RAND::RandBool();
2645 
2646  // copy the information for one locus at a time
2647  for(unsigned int i = 0; i < _num_locus; ++i)
2648 // ind->copy_sequence_block(SEX, _all_chooser[i], i, i+1, parent);
2649  ind->copy_sequence_1locus(SEX, RAND::RandBool(), i, parent);
2650 
2651  // note that more than one value may be copied at a time because of pleiotropy
2652 }
virtual void copy_sequence_1locus(sex_t SEX, unsigned int strand, unsigned int at, const TTQuanti *parent)=0

References _num_locus, TTQuanti::copy_sequence_1locus(), and RAND::RandBool().

Referenced by setGeneticMapParams().

◆ inherit_low()

void TProtoQuanti::inherit_low ( sex_t  SEX,
TTQuanti ind,
const TTQuanti parent 
)
inline
2602 {
2603  unsigned int prevLoc = 0;
2604 
2605  //the table containing the loci at which x-overs happen
2606  vector< pair<unsigned int, unsigned int> > recTable = _map.reduceJunctions(SEX, _mapIndex);
2607 
2608 
2609 #ifdef _REC_DEBUG_
2610  //number of x-overs
2611  unsigned int nbRec = recTable.size();
2612  cout << "TProtoQuanti::inherit_low; nb Rec = "<<nbRec - 1<<endl;
2613  cout << " --sex = "<<SEX<<"\n";
2614 #endif
2615 
2616 // unsigned int num_copied = 0;
2617 
2618  vector< pair<unsigned int, unsigned int> >::const_iterator xover = recTable.begin();
2619 
2620  while(xover != recTable.end()) {
2621 
2622 #ifdef _REC_DEBUG_
2623  cout<< " copy seq from "<<prevLoc<<" to "<<xover->first
2624  <<" ("<<(xover->first - prevLoc)<<" loc) ("
2625  <<(xover->first - prevLoc)*_sizeofLocusType
2626  <<"B) on side "<<xover->second<<std::endl;
2627 #endif
2628 
2629  ind->copy_sequence_block(SEX, xover->second, prevLoc, xover->first, parent);
2630 
2631  prevLoc = xover->first;
2632 
2633  xover++;
2634  }
2635 }
vector< pair< unsigned int, unsigned int > > reduceJunctions(sex_t SEX, unsigned int trait_idx)
Remove multiple x-over at the same locus when traits differ in number of loci.
Definition: ttrait_with_map.cc:1205
static GeneticMap _map
Definition: ttrait_with_map.h:209
unsigned int _mapIndex
Definition: ttrait_with_map.h:193
virtual void copy_sequence_block(sex_t SEX, unsigned int strand, unsigned int from_pos, unsigned int to_pos, const TTQuanti *parent)=0

References TTProtoWithMap::_map, TTProtoWithMap::_mapIndex, _sizeofLocusType, TTQuanti::copy_sequence_block(), and GeneticMap::reduceJunctions().

Referenced by setGeneticMapParams().

◆ loadFileServices()

void TProtoQuanti::loadFileServices ( FileServices loader)
virtual

Implements SimComponent.

2978 {
2979  int logtime = 0;
2980 
2981  //writer
2982  // purge previous settings:
2983  if(_writer) delete _writer;
2984  _writer = NULL;
2985 
2986  if(get_parameter("quanti_output")->isSet()) {
2987 
2988  _writer = new TTQuantiFH(this);
2989 
2990  if(get_parameter("quanti_output")->getArg().find("snp_") != string::npos && get_allele_model() > 2) {
2991  fatal("parameter \"quanti_output\" option \"%s\" can only be selected for di-allelic quantitative loci\n",
2992  get_parameter("quanti_output")->getArg().c_str());
2993  }
2994 
2995  _writer->setOutputOption(get_parameter("quanti_output")->getArg());
2996 
2997  if(!get_parameter("quanti_logtime")->isSet())
2998  fatal("quant trait::parameter \"quanti_logtime\" is missing!\n");
2999 
3000  Param* param = get_parameter("quanti_logtime");
3001 
3002  logtime = (param->isSet() ? (int)param->getValue() : 0);
3003 
3004  if(param->isMatrix()) {
3005 
3006  TMatrix temp;
3007  param->getMatrix(&temp);
3008  _writer->set_multi(true, true, 1, &temp, get_parameter("quanti_dir")->getArg(), this);
3009 
3010  } else // rpl_per, gen_per, rpl_occ, gen_occ, rank (0), path, self-ref
3011  _writer->set(true, true, 1, logtime, 0, get_parameter("quanti_dir")->getArg(),this);
3012 
3013  loader->attach(_writer);
3014 
3015  }
3016 
3017  //freq extractor
3018  if(_freqExtractor) delete _freqExtractor;
3019  _freqExtractor = NULL;
3020 
3021  if(get_parameter("quanti_freq_output")->isSet()) {
3022 
3023  if(get_allele_model() > 2) {
3024 
3025  error("option \"quanti_freq_output\" only works with di-allelic quantitative loci. This option will be ignored.\n");
3026 
3027  }else {
3028 
3029  _freqExtractor = new TTQFreqExtractor(this);
3030 
3032 
3033  Param* param = get_parameter("quanti_freq_logtime");
3034 
3035  if(!param->isSet())
3036  fatal("quant trait::parameter \"quanti_freq_logtime\" is missing!\n");
3037 
3038  if(param->isMatrix())
3039  fatal("parameter \"quanti_freq_logtime\" only accepts a single log-time value and not an array of values.\n\
3040  A single '.qfreq' output file contains the allele frequencies computed every log-time generation.\n");
3041 
3042  logtime = (int)param->getValue();
3043 
3044  //save multiple generations in a single file:
3045  _freqExtractor->set(true, true, 1, logtime, 0, get_parameter("quanti_dir")->getArg(),this);
3046 
3047  loader->attach(_freqExtractor);
3048  }
3049 
3050  }
3051 
3052  // Ohta's (1982) D statistics
3053  if(_ohtaStats) delete _ohtaStats;
3054  _ohtaStats = NULL;
3055 
3056  if(get_parameter("quanti_ohta_output")->isSet()) {
3057 
3058  if ((_allele_model > 2) || (_num_traits > 1) || (SIMenv::MainSim->get_pop()->getPatchNbr() < 2)) {
3059  fatal("output option \"quanti_ohta_output\" is only valid for diallelic QTL affecting one trait in multiple patches!\n");
3060  }
3061 
3062  _ohtaStats = new TTQOhtaStats(this);
3063 
3064  Param* param = get_parameter("quanti_ohta_logtime");
3065 
3066  if(!param->isSet())
3067  fatal("quant trait::parameter \"quanti_ohta_logtime\" is missing!\n");
3068 
3069  if(param->isMatrix()) {
3070 
3071  TMatrix temp;
3072  param->getMatrix(&temp);
3073  _ohtaStats->set_multi(true, true, 1, &temp, get_parameter("quanti_dir")->getArg(), this);
3074 
3075  } else // rpl_per, gen_per, rpl_occ, gen_occ, rank (0), path, self-ref
3076  _ohtaStats->set(true, true, 1, (param->isSet() ? (int)param->getValue() : 0),
3077  0, get_parameter("quanti_dir")->getArg(),this);
3078 
3079  loader->attach(_ohtaStats);
3080  }
3081 
3082  //load the reader:
3083  if(_reader) delete _reader;
3084  _reader = new TTQuantiFH(this);
3085  _reader->set_isInputHandler(true);
3086  loader->attach_reader(_reader);
3087 }
void set_isInputHandler(bool val)
Definition: filehandler.h:155
virtual void attach_reader(FileHandler *FH)
Attaches the FileHandler to the current list (_readers) of the FileServices.
Definition: fileservices.cc:74
virtual void attach(Handler *FH)
Attaches the FileHandler to the current list (_writers) of the FileServices.
Definition: fileservices.cc:61
This structure stores one parameter, its definition and its string argument.
Definition: param.h:54
double getValue()
Returns the argument value according to its type.
Definition: param.cc:368
bool isMatrix()
Checks if the argument is of matrix type.
Definition: param.h:172
string getArg()
Definition: param.h:138
void getMatrix(TMatrix *mat)
Sets the matrix from the argument string if the parameter is set and of matrix type.
Definition: param.cc:378
bool isSet()
Definition: param.h:140
static SimRunner * MainSim
Definition: simenv.h:42
virtual Param * get_parameter(std::string name)
Param getter.
Definition: simcomponent.h:139
A class to handle matrix in params, coerces matrix into a vector of same total size.
Definition: tmatrix.h:50
unsigned int get_allele_model()
Definition: ttquanti.h:434
TTQFreqExtractor.
Definition: ttquanti.h:836
void resetTable()
Definition: ttquanti.cc:6320
TTQOhtaStats.
Definition: ttquanti.h:855
TTQuantiFH.
Definition: ttquanti.h:810
void setOutputOption(string opt)
Definition: ttquanti.cc:5677
virtual void set_multi(bool rpl_per, bool gen_per, int rpl_occ, TMatrix *Occ, string path, TP *trait_proto)
Definition: filehandler.h:248
virtual void set(bool rpl_per, bool gen_per, int rpl_occ, int gen_occ, int rank, string path, TP *trait_proto)
Definition: filehandler.h:241

References _allele_model, _freqExtractor, _num_traits, _ohtaStats, _reader, _writer, FileServices::attach(), FileServices::attach_reader(), error(), fatal(), get_allele_model(), SimComponent::get_parameter(), Param::getArg(), Param::getMatrix(), Param::getValue(), Param::isMatrix(), Param::isSet(), SIMenv::MainSim, TTQFreqExtractor::resetTable(), TraitFileHandler< TP >::set(), FileHandler::set_isInputHandler(), TraitFileHandler< TP >::set_multi(), and TTQuantiFH::setOutputOption().

◆ loadStatServices()

void TProtoQuanti::loadStatServices ( StatServices loader)
virtual

Implements SimComponent.

3092 {
3093  //allocate the stat handler
3094  if(_stats)
3095  delete _stats; // this will reset internal state for the new simulation, safest solution
3096 
3097  _stats = new TTQuantiSH(this);
3098 
3099  loader->attach(_stats);
3100 }
virtual void attach(Handler *H)
attach the StatHandler to the current list (_statHandlers) of the StatServices
Definition: statservices.cc:177
TTQuantiSH.
Definition: ttquanti.h:734

References _stats, and StatServices::attach().

◆ mutate()

void TProtoQuanti::mutate ( TTQuanti ind)
inline
2657 {
2658  (this->*_mutation_func_ptr)(ind);
2659 }

References _mutation_func_ptr.

Referenced by TTQuanti::mutate().

◆ mutate_diallelic_no_pleio()

void TProtoQuanti::mutate_diallelic_no_pleio ( TTQuanti ind)
inline
2879 {
2880  unsigned int NbMut = get_num_mutations(); //RAND::Poisson(_genomic_mutation_rate);
2881  unsigned int mut_locus, mut_all;
2882 
2883  while(NbMut != 0) {
2884 
2885  mut_locus = RAND::Uniform(_num_locus);
2886  mut_all = RAND::RandBool();
2887 
2888  // here just flips the bit at the mutating allele, value argument is ignored
2889  ind->mutate_inplace( mut_locus, mut_all, 1);
2890 
2891  NbMut--;
2892  }
2893 
2894 }
unsigned int get_num_mutations()
Definition: ttquanti.h:543
virtual void mutate_inplace(unsigned int position, unsigned int allele, double value)=0

References _num_locus, get_num_mutations(), TTQuanti::mutate_inplace(), RAND::RandBool(), and RAND::Uniform().

Referenced by setMutationModel_no_pleio().

◆ mutate_diallelic_pleio()

void TProtoQuanti::mutate_diallelic_pleio ( TTQuanti ind)
inline
2813 {
2814  unsigned int NbMut = get_num_mutations(); //RAND::Poisson(_genomic_mutation_rate);
2815  unsigned int mut_locus, mut_all, pos;
2816  bool allele;
2817 
2818  while(NbMut != 0) {
2819 
2820  mut_locus = RAND::Uniform(_num_locus);
2821  mut_all = RAND::RandBool(); // which of the two copies is mutated
2822 
2823  pos = mut_locus*_num_traits; //where it stands in the sequence (full pleio)
2824 
2825  allele = !(ind->get_allele_bit(pos, mut_all));
2826 
2827  // flip the bit, mutate to the alt. allele
2828  ind->mutate_inplace( pos, mut_all, allele);
2829 
2830  // There cannot be more than two traits in this case, as set during startup
2831  // set second value:
2832  pos++;
2833  // The allele affecting the second trait may receive the same mutation depending on the
2834  // mutational correlation
2836  ind->set_allele_bit(pos, mut_all, allele); // calling ind->mutate_add(pos,...) would be equivalent
2837  else
2838  ind->set_allele_bit(pos, mut_all, RAND::RandBool()); // may or may not flip the bit, avoids spurious correlation
2839 
2840  NbMut--;
2841  }
2842 
2843 }
virtual void set_allele_bit(unsigned int position, unsigned int allele, bool value)=0
virtual bool get_allele_bit(unsigned int position, unsigned int allele) const =0

References _mutation_correlation, _num_locus, _num_traits, TMatrix::get(), TTQuanti::get_allele_bit(), get_num_mutations(), TTQuanti::mutate_inplace(), RAND::RandBool(), TTQuanti::set_allele_bit(), and RAND::Uniform().

Referenced by setMutationModel_full_pleio().

◆ mutate_diallelic_var_pleio()

void TProtoQuanti::mutate_diallelic_var_pleio ( TTQuanti ind)
inline
2848 {
2849  unsigned int NbMut = get_num_mutations(); //RAND::Poisson(_genomic_mutation_rate);
2850  unsigned int mut_locus, mut_all, pos;
2851 
2852  while(NbMut != 0) {
2853 
2854  mut_locus = RAND::Uniform(_num_locus);
2855  mut_all = RAND::RandBool();
2856 
2857  pos = _locus_table[mut_locus][0];
2858 
2859  ind->mutate_inplace(pos, mut_all, 1); // value argument is ignored, flips the bit
2860 
2861  if(_locus_table[mut_locus][1] == 2) { // only degree of pleiotropy allowed
2862 
2863  pos++;
2864 
2866  ind->set_allele_bit(pos, mut_all, ind->get_allele_bit(pos-1, mut_all));
2867  else
2868  ind->set_allele_bit(pos, mut_all, RAND::RandBool()); //avoids spurious correlations
2869  }
2870 
2871  NbMut--;
2872  }
2873 
2874 }

References _locus_table, _mutation_correlation, _num_locus, TMatrix::get(), TTQuanti::get_allele_bit(), get_num_mutations(), TTQuanti::mutate_inplace(), RAND::RandBool(), TTQuanti::set_allele_bit(), and RAND::Uniform().

Referenced by setMutationModel_var_pleio().

◆ mutate_full_pleio()

void TProtoQuanti::mutate_full_pleio ( TTQuanti ind)
inline
2692 {
2693  unsigned int NbMut = get_num_mutations(); //RAND::Poisson(_genomic_mutation_rate);
2694  unsigned int mut_locus, mut_all, pos;
2695  double *effects;
2696 
2697  while(NbMut != 0) {
2698  mut_locus = RAND::Uniform(_num_locus);
2699  mut_all = RAND::RandBool();
2700 
2701  effects = (this->*_getMutationValues)(mut_locus);
2702 
2703  pos = mut_locus*_num_traits;
2704 
2705  //cycle through all alleles at the mutated locus, depending on the PD of the locus
2706  for(unsigned int i = 0; i < _num_traits; ++i, ++pos) {
2707  ind->mutate_add( pos, mut_all, effects[i]);
2708  }
2709 
2710  NbMut--;
2711  }
2712 
2713 }
virtual void mutate_add(unsigned int position, unsigned int allele, double value)=0

References _getMutationValues, _num_locus, _num_traits, get_num_mutations(), TTQuanti::mutate_add(), RAND::RandBool(), and RAND::Uniform().

Referenced by setMutationModel_full_pleio().

◆ mutate_inplace_full_pleio()

void TProtoQuanti::mutate_inplace_full_pleio ( TTQuanti ind)
inline
2764 {
2765  unsigned int NbMut = get_num_mutations(); //RAND::Poisson(_genomic_mutation_rate);
2766  unsigned int mut_locus, mut_all, pos;
2767  double *effects;
2768 
2769  while(NbMut != 0) {
2770  mut_locus = RAND::Uniform(_num_locus);
2771  mut_all = RAND::RandBool();
2772 
2773  effects = (this->*_getMutationValues)(mut_locus);
2774 
2775  pos = mut_locus*_num_traits; //start location of the locus in the sequence
2776 
2777  //cycle through all alleles at the mutated locus, depending on the PD of the locus
2778  for(unsigned int i = 0; i < _num_traits; ++i, ++pos) {
2779  ind->mutate_inplace( pos, mut_all, effects[i]);
2780  }
2781 
2782  NbMut--;
2783  }
2784 }

References _getMutationValues, _num_locus, _num_traits, get_num_mutations(), TTQuanti::mutate_inplace(), RAND::RandBool(), and RAND::Uniform().

Referenced by setMutationModel_full_pleio().

◆ mutate_inplace_no_pleio()

void TProtoQuanti::mutate_inplace_no_pleio ( TTQuanti ind)
inline
2744 {
2745  unsigned int NbMut = get_num_mutations(); //RAND::Poisson(_genomic_mutation_rate);
2746  unsigned int mut_locus, mut_all;
2747  double *effects;
2748 
2749  while(NbMut != 0) {
2750  mut_locus = RAND::Uniform(_num_locus);
2751  mut_all = RAND::RandBool();
2752 
2753  effects = (this->*_getMutationValues)(mut_locus);
2754 
2755  ind->mutate_inplace( mut_locus, mut_all, effects[0]);
2756 
2757  NbMut--;
2758  }
2759 }

References _getMutationValues, _num_locus, get_num_mutations(), TTQuanti::mutate_inplace(), RAND::RandBool(), and RAND::Uniform().

Referenced by setMutationModel_no_pleio().

◆ mutate_inplace_var_pleio()

void TProtoQuanti::mutate_inplace_var_pleio ( TTQuanti ind)
inline
2789 {
2790  unsigned int NbMut = get_num_mutations(); //RAND::Poisson(_genomic_mutation_rate);
2791  unsigned int mut_locus, mut_all, pos;
2792  double *effects;
2793 
2794  while(NbMut != 0) {
2795  mut_locus = RAND::Uniform(_num_locus);
2796  mut_all = RAND::RandBool();
2797 
2798  effects = (this->*_getMutationValuesVarPleio[mut_locus])(mut_locus);
2799 
2800  pos = _locus_table[mut_locus][0];
2801 
2802  for(unsigned int i = 0; i < _locus_table[mut_locus][1]; ++i, ++pos){
2803  ind->mutate_inplace( pos, mut_all, effects[i]);
2804  }
2805 
2806  NbMut--;
2807  }
2808 }

References _getMutationValuesVarPleio, _locus_table, _num_locus, get_num_mutations(), TTQuanti::mutate_inplace(), RAND::RandBool(), and RAND::Uniform().

Referenced by setMutationModel_var_pleio().

◆ mutate_nill()

void TProtoQuanti::mutate_nill ( TTQuanti ind)
inline

◆ mutate_no_pleio()

void TProtoQuanti::mutate_no_pleio ( TTQuanti ind)
inline
2671 {
2672  unsigned int NbMut = get_num_mutations(); //(unsigned int)RAND::Poisson(_genomic_mutation_rate);
2673  unsigned int mut_locus, mut_all;
2674  double *effects;
2675 
2676  while(NbMut != 0) {
2677  mut_locus = RAND::Uniform(_num_locus);
2678  mut_all = RAND::RandBool();
2679 
2680  effects = (this->*_getMutationValues)(mut_locus);
2681 
2682  ind->mutate_add( mut_locus, mut_all, effects[0]);
2683 
2684  NbMut--;
2685  }
2686 
2687 }

References _getMutationValues, _num_locus, get_num_mutations(), TTQuanti::mutate_add(), RAND::RandBool(), and RAND::Uniform().

Referenced by setMutationModel_no_pleio().

◆ mutate_var_pleio()

void TProtoQuanti::mutate_var_pleio ( TTQuanti ind)
inline
2718 {
2719  unsigned int NbMut = get_num_mutations(); //RAND::Poisson(_genomic_mutation_rate);
2720  unsigned int mut_locus, mut_all, pos;
2721  double *effects;
2722 
2723  while(NbMut != 0) {
2724 
2725  mut_locus = RAND::Uniform(_num_locus);
2726  mut_all = RAND::RandBool();
2727 
2728  effects = (this->* _getMutationValuesVarPleio[mut_locus])(mut_locus);
2729 
2730  pos = _locus_table[mut_locus][0];
2731 
2732  //cycle through all alleles at the mutated locus, depending on the PD of the locus
2733  for(unsigned int i = 0; i < _locus_table[mut_locus][1]; ++i, ++pos) {
2734  ind->mutate_add( pos, mut_all, effects[i]);
2735  }
2736 
2737  NbMut--;
2738  }
2739 }

References _getMutationValuesVarPleio, _locus_table, _num_locus, get_num_mutations(), TTQuanti::mutate_add(), RAND::RandBool(), and RAND::Uniform().

Referenced by setMutationModel_var_pleio().

◆ readMatrixFromQuantiMutationMatrix()

bool TProtoQuanti::readMatrixFromQuantiMutationMatrix ( vector< vector< double >> &  varmat)
2059 {
2060 // message("quant::found \"quanti_mutation_matrix\" in input, analyzing the matrix for pleiotropic loci\n");
2061 
2062  get_parameter("quanti_mutation_matrix")->getVariableMatrix(&varmat);
2063 
2064  // check dimensionality of the matrix: ------------------------------------------------
2065  size_t numRows = varmat.size();
2066  size_t numEl;
2067  size_t maxNumEl = varmat[0].size(); //number of elements in the first row, as a start
2068  bool rowsAreDifferent = false;
2069 
2070  int numCovariance = (_num_traits - 1)*_num_traits/2; // number of off-diagonal elements
2071 
2072  for(size_t i = 0; i < numRows; ++i) {
2073 
2074  numEl = varmat[i].size();
2075 
2076  if(_pleio_type == 1) { //full pleio
2077  if( numEl != _num_traits && numEl != numCovariance + _num_traits) {
2078  return error("number of values in \"quanti_mutation_matrix\" at row %i \
2079 does not match with the pleiotropic degree of %i. Rows must contain either %i or %i variance-covariance values.\n",
2080 i+1, _num_traits, _num_traits, _num_traits + numCovariance);
2081  }
2082  }
2083 
2084  if(maxNumEl != numEl) rowsAreDifferent = true;
2085 
2086  maxNumEl = max(numEl, maxNumEl);
2087 
2088  }
2089 
2090  // assess if locus-specific matrices have been provided:
2091  if(numRows == _num_traits && maxNumEl == _num_traits && !rowsAreDifferent) {
2092 
2093 // if(_pleio_type == 1)
2094 // message("quant::\"quanti_mutation_matrix\" is a single square, num. traits x num. traits matrix. It will be used for all loci equally.\n");
2095 
2096  if(_pleio_type == 2)
2097  warning("\"quanti_mutation_matrix\" is a single square, num. traits x num. traits matrix but loci have variable pleiotropy. \
2098 The matrix will be interpreted as a set of locus-specific mutation matrices.");
2099 
2101 
2102  } else {
2103 
2104 // message("quant::\"quanti_mutation_matrix\" is not a square, num. traits x num. traits matrix. Rows will be treated as locus-specific mutation matrices.");
2105 
2106  if( numRows > _num_locus )
2107  return error("\"quanti_mutation_matrix\" has too many rows, it must be a matrix with max num. rows = \"quanti_loci\" or \"quanti_traits\" \n");
2108 
2110  }
2111 
2112  return true;
2113 }
void getVariableMatrix(vector< vector< double > > *mat)
Definition: param.cc:462
void warning(const char *str,...)
Definition: output.cc:58

References _mutationVarianceIsLocusSpecific, _num_locus, _num_traits, _pleio_type, error(), SimComponent::get_parameter(), Param::getVariableMatrix(), and warning().

Referenced by setContinuousMutationModel_full_pleio(), and setContinuousMutationModel_var_pleio().

◆ reset()

virtual void TProtoQuanti::reset ( )
inlinevirtual

Reimplemented from TTProtoWithMap.

virtual void reset()
Definition: ttrait_with_map.cc:638

References TTProtoWithMap::reset().

◆ resetParameterFromSource()

virtual bool TProtoQuanti::resetParameterFromSource ( std::string  param,
SimComponent cmpt 
)
inlinevirtual

Implements SimComponent.

597 {return false;}

◆ retrieve_data()

virtual bool TProtoQuanti::retrieve_data ( BinaryStorageBuffer reader)
inlinevirtual

Implements StorableComponent.

590  {reader->read(&_seq_length,sizeof(int));return true;}
void read(void *out, unsigned int nb_bytes)
Definition: binarystoragebuffer.h:162

References _seq_length, and BinaryStorageBuffer::read().

◆ set_eVarianceSD()

void TProtoQuanti::set_eVarianceSD ( unsigned int  trait,
double  SD 
)
2381 {
2382  if(_eVariance.size() < trait + 1) //trait is expected to be the element's index
2383  _eVariance.push_back(SD);
2384  else
2385  _eVariance[trait] = SD;
2386 }

References _eVariance.

Referenced by LCE_QuantiModifier::setVefromVa(), and LCE_Breed_Quanti::setVefromVa().

◆ set_genotype_value_additive()

double TProtoQuanti::set_genotype_value_additive ( const TTQuanti ind,
const unsigned int  trait 
)
2526 {
2527  return ind->get_additive_genotype(trait);
2528 }
virtual double get_additive_genotype(const unsigned int trait) const =0

References TTQuanti::get_additive_genotype().

Referenced by setParameters().

◆ set_genotype_value_dominance()

double TProtoQuanti::set_genotype_value_dominance ( const TTQuanti ind,
const unsigned int  trait 
)
2533 {
2534  return ind->get_dominant_genotype(trait);
2535 }
virtual double get_dominant_genotype(const unsigned int trait) const =0

References TTQuanti::get_dominant_genotype().

Referenced by setParameters().

◆ set_gsl_mutation_matrix()

gsl_matrix * TProtoQuanti::set_gsl_mutation_matrix ( unsigned int  pleio_deg,
const vector< double > &  varcov 
)
2187 {
2188  // varcov must be a one-line matrix
2189  unsigned int numCovariance = (pleio_deg - 1)*pleio_deg/2; // number of off-diagonal elements
2190  unsigned int cov_pos = pleio_deg; //first covariance term in the array
2191  size_t numEl = varcov.size(); //dimension check has been done already
2192 
2193  gsl_matrix* mat = gsl_matrix_alloc(pleio_deg, pleio_deg);
2194 
2195  for(unsigned int i = 0; i < pleio_deg; ++i){
2196 
2197  //set the diagonal = variances, we know they are the first pleio_deg elements in the matrix
2198  gsl_matrix_set(mat,i,i,varcov[i]);
2199 
2200  if (numEl == numCovariance + pleio_deg ) { // covariance values also provided, set the off-diagonal
2201 
2202  //setting covariance given in input as: e.g. {{v1,v2,v3,cov12,cov13,cov23}} with pleio_deg = 3
2203  for(unsigned long int j = i+1; j < pleio_deg && cov_pos < numEl; ++j){
2204  gsl_matrix_set(mat,i,j,varcov[cov_pos]);
2205  gsl_matrix_set(mat,j,i,varcov[cov_pos++]); // the matrix is symmetrical
2206  }
2207 
2208  } else {
2209  // no covariance provided in input, set off-diagonal to zero
2210  for(unsigned long int j = i+1; j < pleio_deg ; ++j){
2211  gsl_matrix_set(mat,i,j,0);
2212  gsl_matrix_set(mat,j,i,0); // the matrix is symmetrical
2213  }
2214 
2215  }
2216  }
2217 
2218  return mat;
2219 }

Referenced by set_gsl_mutation_matrix_from_sigma(), setContinuousMutationModel_full_pleio(), and setContinuousMutationModel_var_pleio().

◆ set_gsl_mutation_matrix_from_sigma()

gsl_matrix * TProtoQuanti::set_gsl_mutation_matrix_from_sigma ( unsigned int  loc,
unsigned int  pleio_deg 
)
2224 {
2225  // variance are identical across traits (in a row of _mutation_sigma) at this stage (mutation_matrix not set in input)
2226 
2227  unsigned int numCov = (pleio_deg-1)*pleio_deg / 2;
2228 
2229  vector<double> varcov(pleio_deg + numCov);
2230 
2231  // fill in the varcov array as a one-line matrix {{var1, var2, ..., covar12, covar13, ...}}
2232 
2233  // must be carefull as the mutation_sigma matrix may have only one row if variances are not locus specific
2234  // check for locus specificity:
2235  unsigned int pos = (_mutationVarianceIsLocusSpecific ? loc : 0);
2236 
2237  unsigned int cov_pos = pleio_deg; //starting place where covariance are recorded, after the variances
2238 
2239  for(unsigned int i = 0; i < pleio_deg; ++i) {
2240  varcov[i] = _mutation_sigma.get(pos, i)*_mutation_sigma.get(pos, i);
2241 
2242  for(unsigned int j = i; j < pleio_deg - 1 && cov_pos < (pleio_deg + numCov); ++j)
2243  varcov[cov_pos++] = _mutation_correlation.get(0, loc) * _mutation_sigma.get(pos, i)*_mutation_sigma.get(pos, j+1);
2244  }
2245 
2246 #ifdef _DEBUG_
2247  message("quanti:: Locus %i\n--setting mutation matrix from mutation variance and correlation\n", loc+1);
2248  message("-- one-line reduced matrix:\n");
2249  for(unsigned int i = 0; i < varcov.size(); ++i)
2250  message("%.3f ",varcov[i]);
2251  message("\n");
2252 #endif
2253 
2254  return set_gsl_mutation_matrix(pleio_deg, varcov);
2255 }
gsl_matrix * set_gsl_mutation_matrix(unsigned int pleio_deg, const vector< double > &varcov)
Definition: ttquanti.cc:2186
void message(const char *message,...)
Definition: output.cc:40

References _mutation_correlation, _mutation_sigma, _mutationVarianceIsLocusSpecific, TMatrix::get(), message(), and set_gsl_mutation_matrix().

Referenced by setContinuousMutationModel_full_pleio(), and setContinuousMutationModel_var_pleio().

◆ set_init_values()

void TProtoQuanti::set_init_values ( const double *  values,
unsigned int  nval 
)
2502 {
2503  assert(nval == _num_traits);
2504 
2505  _init_value.reset(1, _num_traits, values);
2506 
2507 }
void reset(unsigned int rows, unsigned int cols)
Re-allocate the existing matrix with assigned rows and cols dimensions and all elements to 0.
Definition: tmatrix.h:161

References _init_value, _num_traits, and TMatrix::reset().

Referenced by LCE_QuantiInit::execute().

◆ set_mutation_matrix_decomposition()

void TProtoQuanti::set_mutation_matrix_decomposition ( unsigned int  loc,
unsigned int  pleio_deg 
)
2260 {
2261  _evect[loc] = gsl_matrix_alloc(pleio_deg, pleio_deg);
2262  _eval[loc] = gsl_vector_alloc(pleio_deg);
2263  _effects_multivar[loc] = gsl_vector_alloc(pleio_deg);
2264  _ws[loc] = gsl_vector_alloc(pleio_deg);
2265 
2266  gsl_matrix *E = gsl_matrix_alloc(pleio_deg, pleio_deg);
2267  gsl_matrix_memcpy(E,_gsl_mutation_matrix[loc]);
2268  gsl_eigen_symmv_workspace * w = gsl_eigen_symmv_alloc (pleio_deg);
2269  gsl_eigen_symmv (E, _eval[loc], _evect[loc], w);
2270  gsl_eigen_symmv_free (w);
2271  gsl_matrix_free(E);
2272 
2273  #ifdef _DEBUG_
2274  message("-- Mutation matrix eigenvalues:\n");
2275  for(unsigned int i = 0; i < pleio_deg; i++)
2276  cout<<gsl_vector_get(_eval[loc],i)<<" ";
2277  cout<<endl;
2278  #endif
2279 
2280  double eval;
2281  //take square root of eigenvalues, will be used in Gaussian as stdev
2282  for(unsigned int i = 0; i < pleio_deg; i++) {
2283 
2284  // check for positive matrix
2285  if(gsl_vector_get(_eval[loc],i) < 0)
2286  fatal("quanti::the mutation matrix is not a positive matrix (at least one eigenvalue is negative)\n\
2287  Please correct the values inside the matrix provided in input.\n");
2288 
2289  eval = gsl_vector_get(_eval[loc],i);
2290  eval = (eval < 0.000001 ? 0 : eval);
2291  gsl_vector_set( _eval[loc], i, sqrt(eval) );
2292  }
2293 
2294  #ifdef _DEBUG_
2295  // DEBUG OUTPUT ------------------------------------------------------
2296  cout << "_gsl_mutation_matrix eigen values (sqrt-ed): ";
2297  for(unsigned int i = 0; i < pleio_deg; i++)
2298  cout<<gsl_vector_get(_eval[loc],i)<<" ";
2299  cout << "\n_gsl_mutation_matrix eigen vectors: \n";
2300  for(unsigned int i = 0; i < pleio_deg; i++){
2301  for(unsigned int j = 0; j < pleio_deg; j++){
2302  cout<<gsl_matrix_get(_evect[loc],i,j)<<" | ";
2303  }
2304  cout<<endl;
2305  }
2306  #endif
2307 
2308 }// ----------------------------------------------------------------------------------------

References _effects_multivar, _eval, _evect, _gsl_mutation_matrix, _ws, fatal(), and message().

Referenced by setContinuousMutationModel_full_pleio(), and setContinuousMutationModel_var_pleio().

◆ set_trait_value_func_ptr()

void TProtoQuanti::set_trait_value_func_ptr ( bool  withVe)
680 {
681  if(withVe)
683  else
685 }
double set_trait_value_VE(const TTQuanti *ind, const unsigned int trait)
Definition: ttquanti.cc:2511
double set_trait_value_noVE(const TTQuanti *ind, const unsigned int trait)
Definition: ttquanti.cc:2518

References _set_trait_value_func_ptr, set_trait_value_noVE(), and set_trait_value_VE().

Referenced by LCE_QuantiModifier::execute(), and LCE_Breed_Quanti::setVefromVa().

◆ set_trait_value_noVE()

double TProtoQuanti::set_trait_value_noVE ( const TTQuanti ind,
const unsigned int  trait 
)
inline
2519 {
2520  return (this->*_set_genotype_func_ptr)(ind, trait);
2521 }

References _set_genotype_func_ptr.

Referenced by set_trait_value_func_ptr(), set_trait_value_VE(), and setParameters().

◆ set_trait_value_VE()

double TProtoQuanti::set_trait_value_VE ( const TTQuanti ind,
const unsigned int  trait 
)
inline
2512 {
2513  return set_trait_value_noVE(ind, trait) + RAND::Gaussian( _eVariance[trait] );
2514 }

References _eVariance, RAND::Gaussian(), and set_trait_value_noVE().

Referenced by set_trait_value_func_ptr(), and setParameters().

◆ setAlleleModel()

unsigned int TProtoQuanti::setAlleleModel ( )
806 {
807  string model("continuous");
808 
809  unsigned int ret_val;
810 
811  //checking allelic model
812  if (get_parameter("quanti_allele_model")->isSet()) {
813 
814  model = get_parameter("quanti_allele_model")->getArg();
815 
816  //---------------------------------------------------------------------------------------
817  // DIALLELIC MODELS
818 
819  if (model == "diallelic" || model == "diallelic_HC") { //for backward-compatibility with v <2.4.0
820 
821  // symmetrical allelic values are centered on zero with -a/+a values
822 
823  if(get_parameter("quanti_init_value")->isSet()){
824  error("\"quanti_allele_model diallelic\" needs to be initialized with \"quanti_init_freq\" provided by LCE \"quanti_init\" instead of \"quanti_init_value\". \n");
825  }
826 
827  ret_val = 1;
828 
829  } else if (model == "diallelic_asymmetrical") {
830 
831  // asymmetrical model allows for two arbitrary allelic values a/b at a locus
832 
833  if(get_parameter("quanti_init_value")->isSet()){
834  error("\"quanti_allele_model diallelic_HC\" needs to be initialized with \"quanti_init_freq\" provided by LCE \"quanti_init\" instead of \"quanti_init_value\". \n");
835  }
836 
837  ret_val = 2;
838 
839  //---------------------------------------------------------------------------------------
840  // CONTIUUM OF ALLELE MODELS
841 
842  } else if (model == "continuous") {
843 
844  ret_val = 3;
845 
846  } else if (model == "continuous_in_place" || model == "continuous_HC") { //for backward-compatibility with v <2.4.0
847 
848  ret_val = 4;
849 
850 
851  } else {
852  return error("\"quanti_allele_model\" has options \"diallelic\", \"diallelic_asymmetrical\", \"continuous\" or \"continuous_in_place\". \n");
853  }
854 
855  }
856  else { //default model: 'continuous"
857  ret_val = 3;
858  }
859 
860 
861 #ifdef _DEBUG_
862  message("quant::allele model is \"%s\"\n",model.c_str());
863 #endif
864  return ret_val;
865 }

References error(), SimComponent::get_parameter(), Param::getArg(), and message().

Referenced by setParameters().

◆ setContinuousMutationModel_full_pleio()

bool TProtoQuanti::setContinuousMutationModel_full_pleio ( )
1503 {
1504  //setting the mutation variance-covariance matrix
1505 
1506  // the pointer has been freed previously by a call to TProtoQuanti::deallocate_gsl_mutation_matrix_space in TProtoQuanti::setMutationParameters
1507  // we double-check with assert
1508  assert(_gsl_mutation_matrix == NULL);
1509  assert(_eval == NULL);
1510  assert(_evect == NULL);
1511  assert(_effects_multivar == NULL);
1512  assert(_ws == NULL);
1513 
1514  if(get_parameter("quanti_mutation_variance")->isSet()) {
1515 
1516  if(get_parameter("quanti_mutation_matrix")->isSet()) {
1517 
1518  warning("both \"quanti_mutation_variance\" and \"quanti_mutation_matrix\" are set, using the matrix only!\n");
1519 
1520  } else {
1521  // the variance are passed as single values because they apply to all traits equally
1522  // the sqrt-variance(s) are stored in _mutation_sigma, can be locus-specific
1523 
1524  if(!setMutationSigmaFromQuantiMutationVariance()) return false;
1525 
1526  //check if variance are locus-specific
1528 
1529  // pleiotropic loci for more than 2 traits, we need the full mutation matrix:
1530  if(_num_traits > 2) {
1531 
1532  //setting the mutation matrix
1533 
1535 
1536  // allocate memory for one m-matrix per locus
1538 
1539  for(unsigned int l = 0; l < _num_locus; ++l) {
1541 
1543  }
1544 
1545  } else { // !_mutationVarianceIsLocusSpecific
1546 
1547  // allocate memory for a single mutation matrix used for all loci
1549 
1551 
1553  }
1554  }
1555  }
1556  } //_end_ if quanti_mutation_variance is set
1557 
1558  if(get_parameter("quanti_mutation_matrix")->isSet()) {
1559 
1560  // full mutation matrix given in input, we need to check what kind of matrix is passed (if locus-specific or not)
1561  vector< vector<double> > _mut_matrix;
1562 
1563  // check the structure of the matrix passed in input, and set the locus-specific flag
1564  if(!readMatrixFromQuantiMutationMatrix(_mut_matrix)) return false;
1565 
1566  // fill and create mutation matrices --------------------------------------------------
1567  int loc_pos;
1568  size_t numRows = _mut_matrix.size();
1569 
1571  // set a new mutation matrix for each locus separately
1572  //each row of the input matrix will be used as a locus-specific m-matrix
1574 
1575  _mutation_sigma.reset(_num_locus, _num_traits); // this is used when PD = 2 or 1
1576 
1577  // checking that _mutation_correlation has been set:
1579 
1580  for(unsigned int loc = 0; loc < _num_locus; loc++){
1581 
1582  loc_pos = loc % numRows; //user may pass only a few rows that will be repeated across loci
1583 
1584  for(unsigned int i = 0; i < _num_traits; i++) // first _num_traits elements are the per-trait mut variance
1585  _mutation_sigma.set(loc, i, sqrt(_mut_matrix[loc_pos][i]));
1586 
1587  //set the locus-specific mutation matrix:
1588  _gsl_mutation_matrix[loc] = set_gsl_mutation_matrix(_num_traits, _mut_matrix[loc_pos]);
1589 
1590  if(_num_traits == 2) { // special case for bivariate Gaussian models
1591 
1592  _mutation_correlation.set(0, loc, gsl_matrix_get(_gsl_mutation_matrix[loc],0,1) / _mutation_sigma.get(loc,0) / _mutation_sigma.get(loc,1));
1593 
1594  } else {
1595 
1597  }
1598 
1599 #ifdef _DEBUG_
1600  cout << "\n-- _gsl_mutation_matrix for locus " << loc+1 << " \n";
1601  for(unsigned int i=0; i<_num_traits; ++i){
1602  for(unsigned int j=0; j<_num_traits; ++j){
1603  cout << gsl_matrix_get(_gsl_mutation_matrix[loc],i,j) << " | ";
1604  }
1605  cout << endl;
1606  }
1607 
1608  message("-- M-matrix decomposition:\n");
1609  for(unsigned int i = 0; i < _num_traits; i++)
1610  cout<<gsl_vector_get(_eval[loc],i)<<" ";
1611  cout<<endl;
1612  if(_num_traits == 2) message("-- mutation correlation: %f\n",_mutation_correlation.get(0,loc));
1613 #endif
1614  } //END for locus
1615 
1616  } else { //mutation is not locus-specific
1617  //create a single mutation matrix
1619 
1620  _mutation_sigma.reset(1, _num_traits); // this is used when PD = 2 or 1
1621 
1622  for(unsigned int i = 0; i < _num_traits; i++) // the diagonal of the input matrix elements are the per-trait mut variance
1623  _mutation_sigma.set(0, i, sqrt(_mut_matrix[i][i]));
1624 
1625  //set the mutation matrix: we have to read the input matrix as a full square matrix, not as an array-matrix
1626  _gsl_mutation_matrix[0] = gsl_matrix_alloc(_num_traits, _num_traits);
1627 
1628  //easiest is to read the input matrix into a TMatrix object (we know it isn't a variable matrix by now)
1629  TMatrix mat;
1630  get_parameter("quanti_mutation_matrix")->getMatrix(&mat);
1631 
1632  //convert it into a gsl_matrix
1633  mat.get_gsl_matrix(_gsl_mutation_matrix[0]);
1634 
1635  if(_num_traits == 2) { // special case for bivariate Gaussian models
1636 
1637  // reset the _mutation_correlation matrix for non-locus specific case:
1639 
1640  _mutation_correlation.set(0, 0, gsl_matrix_get(_gsl_mutation_matrix[0],0,1) / _mutation_sigma.get(0,0) / _mutation_sigma.get(0,1));
1641 
1642  } else { // more traits
1643 
1645  }
1646 
1647 
1648 #ifdef _DEBUG_
1649  message("-- Mutation matrix:\n");
1650  mat.show_up();
1651  message("-- M-matrix decomposition:\n");
1652  for(unsigned int i = 0; i < _num_traits; i++)
1653  cout<<gsl_vector_get(_eval[0],i)<<" ";
1654  cout<<endl;
1655  if(_num_traits == 2) message("-- mutation correlation: %f\n",_mutation_correlation.get(0,1));
1656 #endif
1657 
1658  }
1659  } // END if(get_parameter("quanti_mutation_matrix")->isSet())
1660  else if(!get_parameter("quanti_mutation_variance")->isSet()) {
1661  return error("\"quanti_mutation_matrix\" or \"quanti_mutation_variance\" must be specified!\n");
1662  }
1663 
1664  return true;
1665 }
void show_up()
Definition: tmatrix.h:328
unsigned int ncols() const
Definition: tmatrix.h:216
void set(unsigned int i, unsigned int j, double val)
Sets element at row i and column j to value val.
Definition: tmatrix.h:103
bool setMutationSigmaFromQuantiMutationVariance()
Definition: ttquanti.cc:1922
void set_mutation_matrix_decomposition(unsigned int loc, unsigned int pleio_deg)
Definition: ttquanti.cc:2259
gsl_matrix * set_gsl_mutation_matrix_from_sigma(unsigned int loc, unsigned int pleio_deg)
Definition: ttquanti.cc:2223
bool readMatrixFromQuantiMutationMatrix(vector< vector< double >> &varmat)
Definition: ttquanti.cc:2058
void allocate_gsl_mutation_matrix_space(unsigned int num_locus)
Definition: ttquanti.cc:2117

References _effects_multivar, _eval, _evect, _gsl_mutation_matrix, _mutation_correlation, _mutation_sigma, _mutationVarianceIsLocusSpecific, _num_locus, _num_traits, _ws, allocate_gsl_mutation_matrix_space(), error(), TMatrix::get(), SimComponent::get_parameter(), Param::getMatrix(), message(), TMatrix::ncols(), TMatrix::nrows(), readMatrixFromQuantiMutationMatrix(), TMatrix::reset(), TMatrix::set(), set_gsl_mutation_matrix(), set_gsl_mutation_matrix_from_sigma(), set_mutation_matrix_decomposition(), setMutationSigmaFromQuantiMutationVariance(), TMatrix::show_up(), and warning().

Referenced by setMutationModel_full_pleio().

◆ setContinuousMutationModel_no_pleio()

bool TProtoQuanti::setContinuousMutationModel_no_pleio ( )
1827 {
1828  //setting the mutation variance matrix
1829 
1830  if(get_parameter("quanti_mutation_variance")->isSet()) {
1831 
1832  if(get_parameter("quanti_mutation_matrix")->isSet()) {
1833 
1834  warning("both \"quanti_mutation_variance\" and \"quanti_mutation_matrix\" are set, not using the matrix in the non-pleiotropic case!\n");
1835 
1836  }
1837  // the variance are passed as single values because they apply to all traits equally
1838  // the sqrt-variance(s) are stored in _mutation_sigma, can be locus-specific
1839 #ifdef _DEBUG_
1840  message("quant::setting mutation variance (param is set).\n");
1841 #endif
1842 
1844 
1845  //check if variance are locus-specific
1847 
1848  } //_end_ if quanti_mutation_variance is set
1849 
1850  else if(get_parameter("quanti_mutation_matrix")->isSet()) {
1851 
1852  return error("quant::parameter \"quanti_mutation_matrix\" is not used under non-pleiotropic model, use \"quanti_mutation_variance\" instead.\n");
1853 
1854  } // END if(get_parameter("quanti_mutation_matrix")->isSet())
1855  else if(!get_parameter("quanti_mutation_variance")->isSet()) {
1856  return error("\"quanti_mutation_variance\" must be specified for the non-pleiotropic model of quantitative loci!\n");
1857  }
1858 
1859  return true;
1860 }
bool setMutationSigmaFromQuantiMutationVariance_no_pleio()
Definition: ttquanti.cc:1992

References _mutation_sigma, _mutationVarianceIsLocusSpecific, error(), SimComponent::get_parameter(), Param::isSet(), message(), TMatrix::nrows(), setMutationSigmaFromQuantiMutationVariance_no_pleio(), and warning().

Referenced by setMutationModel_no_pleio().

◆ setContinuousMutationModel_var_pleio()

bool TProtoQuanti::setContinuousMutationModel_var_pleio ( )
1670 {
1671 // cout << "TProtoQuanti::setContinuousMutationModel_var_pleio\n";
1672 
1673  // the pointer has been freed previously in TProtoQuanti_var_pleio::setMutationParameters
1674  // we double-check with assert
1675  assert(_gsl_mutation_matrix == NULL);
1676  assert(_eval == NULL);
1677  assert(_evect == NULL);
1678  assert(_effects_multivar == NULL);
1679  assert(_ws == NULL);
1680 
1681  // allocate memory
1683 
1684  unsigned int pleio_deg;
1685 
1686  //setting the mutation variance
1687  if(get_parameter("quanti_mutation_variance")->isSet()) {
1688 
1689  if(get_parameter("quanti_mutation_matrix")->isSet()) {
1690 
1691  warning("both \"quanti_mutation_variance\" and \"quanti_mutation_matrix\" are set, using the matrix only!\n");
1692 
1693  } else {
1694  // the variance are passed as single values because they apply to all traits equally
1695  // the sqrt-variance(s) are stored in _mutation_sigma, can be locus-specific
1696 
1697  if(!setMutationSigmaFromQuantiMutationVariance()) return false;
1698 
1699  //check if variance are locus-specific
1701 
1702  // we need one m-matrix per locus if locus is pleiotropic
1703  // even if all have same variance and _mutationVarianceIsLocusSpecific = false bcse PD varies among loci
1704  for(unsigned int loc = 0; loc < _num_locus; loc++){
1705 
1706  pleio_deg = _locus_table[loc][1];
1707 
1708  if(pleio_deg > 1) {
1709  //set the M-matrix for all pleiotropic loci, even though it is not used when PD == 2
1710  //setting the mutation matrix
1712 
1713  set_mutation_matrix_decomposition(loc, pleio_deg);
1714 
1715 
1716 #ifdef _DEBUG_
1717  cout << "_gsl_mutation_matrix for locus " << loc+1 << " \n";
1718  for(unsigned int i=0; i<pleio_deg; ++i){
1719  for(unsigned int j=0; j<pleio_deg; ++j){
1720  cout << gsl_matrix_get(_gsl_mutation_matrix[loc],i,j) << " | ";
1721  }
1722  cout << endl;
1723  }
1724 #endif
1725 
1726  } // END if PD > 1
1727  } // END for locus
1728  } // END if get_parameter("quanti_mutation_matrix")->isSet()
1729  } // END if(get_parameter("quanti_mutation_variance")->isSet())
1730 
1731 
1732 
1733  if(get_parameter("quanti_mutation_matrix")->isSet()) {
1734 
1735  vector< vector<double> > _mut_matrix;
1736 
1737  if(!readMatrixFromQuantiMutationMatrix(_mut_matrix)) return false;
1738 
1739  // we will store sigma in case some loci have PD = 1 or PD = 2
1741 
1742  // checking that _mutation_correlation has been set:
1744 
1745  int numVarInRow;
1746  int numRows = _mut_matrix.size();
1747  int numCovariance;
1748  int loc_pos;
1749 
1750  // set the mutation matrix for each locus separately
1751  for(unsigned int loc = 0; loc < _num_locus; loc++){
1752 
1753  pleio_deg = _locus_table[loc][1];
1754 
1755  loc_pos = loc % numRows; //user may pass only one row that will be repeated for all loci
1756 
1757  numVarInRow = _mut_matrix[loc_pos].size(); // number of diagonal elements
1758  numCovariance = (pleio_deg - 1)*pleio_deg/2; // number of off-diagonal elements
1759 
1760  // we accept 1 value (same var on all traits, no covar), pleio_deg values, or pleio_deg +numCovariance values:
1761  if( numVarInRow > 1 && numVarInRow != (int)pleio_deg && numVarInRow != (numCovariance + (int)pleio_deg) ){
1762  return error("number of values (%i) for locus %i in \"quanti_mutation_matrix\" at row %i \
1763 does not match with its pleiotropic degree of %i \n", numVarInRow, loc+1, loc_pos+1, pleio_deg);
1764  }
1765 
1766 #ifdef _DEBUG_
1767  // Print out mut_matrix for debugging purposes
1768  message("\nquant::input M-matrix for locus %i\n", loc_pos+1);
1769  for(unsigned int j=0; j<_mut_matrix[loc_pos].size(); ++j){
1770  message("%.3f | ",_mut_matrix[loc_pos][j]);
1771  }
1772  message("\n");
1773 #endif
1774 
1775  // we build the varcov vector in case only a single variance was passed:
1776  vector<double> varcov(pleio_deg);
1777 
1778  for(unsigned int i = 0; i < pleio_deg; i++) { // first pleio_deg elements are the per-trait mut variance
1779  _mutation_sigma.set(loc, i, sqrt(_mut_matrix[loc_pos][ i%numVarInRow]) ); //recycle if single value passed
1780  varcov[i] = _mut_matrix[loc_pos][ i%numVarInRow];
1781  }
1782  //set the mutation matrix: we either pass a pleio_deg copied set of a single variance or the original M-matrix
1783  _gsl_mutation_matrix[loc] = set_gsl_mutation_matrix(pleio_deg, (numVarInRow == 1 ? varcov : _mut_matrix[loc_pos] ) );
1784 
1785  set_mutation_matrix_decomposition(loc, pleio_deg);
1786 
1787  if(pleio_deg == 2) { // special case for bivariate Gaussian models
1788  _mutation_correlation.set(0, loc, gsl_matrix_get(_gsl_mutation_matrix[loc],0,1) / _mutation_sigma.get(loc,0) / _mutation_sigma.get(loc,1));
1789  }
1790 
1791 #ifdef _DEBUG_
1792  message("quant::GSL M-matrix for locus %i\n", loc+1);
1793  for(unsigned int i=0; i<pleio_deg; ++i){
1794  for(unsigned int j=0; j<pleio_deg; ++j){
1795  message("%.3f | ",gsl_matrix_get(_gsl_mutation_matrix[loc],i,j));
1796  }
1797  message("\n");
1798  }
1799 #endif
1800 
1801 
1802 #ifdef _DEBUG_
1803  message("-- Mutation matrix for locus %i with PD=%i:\n", loc+1, pleio_deg);
1804  // _mutation_matrix[loc].show_up();
1805  message("-- MMatrix decomposition:\n");
1806  for(unsigned int i = 0; i < pleio_deg; i++)
1807  message("%.3f ", gsl_vector_get(_eval[loc],i));
1808  cout<<endl;
1809  if(_num_traits == 2)
1810  message("-- mutation correlation: %f\n", _mutation_correlation.get(0,loc) ) ;
1811 #endif
1812 
1813  } //END for locus
1814 
1815  } // END if(get_parameter("quanti_mutation_matrix")->isSet())
1816  else if(!get_parameter("quanti_mutation_variance")->isSet()) {
1817  return error("\"quanti_mutation_matrix\" or \"quanti_mutation_variance\" must be specified!\n");
1818  }
1819 
1820 // cout << "TProtoQuanti::setContinuousMutationModel_var_pleio::end\n";
1821  return true;
1822 }

References _effects_multivar, _eval, _evect, _gsl_mutation_matrix, _locus_table, _mutation_correlation, _mutation_sigma, _mutationVarianceIsLocusSpecific, _num_locus, _num_traits, _ws, allocate_gsl_mutation_matrix_space(), error(), TMatrix::get(), SimComponent::get_parameter(), message(), TMatrix::ncols(), TMatrix::nrows(), readMatrixFromQuantiMutationMatrix(), TMatrix::reset(), TMatrix::set(), set_gsl_mutation_matrix(), set_gsl_mutation_matrix_from_sigma(), set_mutation_matrix_decomposition(), setMutationSigmaFromQuantiMutationVariance(), and warning().

Referenced by setMutationModel_var_pleio().

◆ setDiallelicMutationModel()

bool TProtoQuanti::setDiallelicMutationModel ( )
1349 {
1350  static bool warn_allele_once = false;
1351 
1352  if (!get_parameter("quanti_allele_value")->isSet()) {
1353 
1354  return error("in \"quanti\" trait, \"quanti_allele_value\" is not set for the diallelic model.\n");
1355 
1356  } else {
1357 
1358  // allele_value is a matrix nb_locus x 2 values
1359 
1360  // IMPORTANT:: This interface doesn't allow for trait-specific allelic values!!
1361 
1363 
1364  if (get_parameter("quanti_allele_value")->isMatrix()) { //locus-specific allelic values
1365 
1366  TMatrix tmp;
1367 
1368  get_parameter("quanti_allele_value")->getMatrix(&tmp);
1369 
1370  if (tmp.ncols() != _num_locus) {
1371  if(tmp.ncols() < _num_locus && !warn_allele_once) {
1372  warning("\"quanti_allele_value\" has less values than the number of loci, allelic values will be recycled among loci.\n");
1373  warn_allele_once = true;
1374  }
1375 
1376  if(tmp.ncols() > _num_locus && !warn_allele_once) {
1377  warning("\"quanti_allele_value\" has more values than the number of loci, only the first %i values will be used.\n", _num_locus);
1378  warn_allele_once = true;
1379  }
1380  }
1381 
1382  unsigned int nval = tmp.ncols();
1383 
1384  // we need to order the allele in decreasing order for later calculations of allele frequencies
1385  // such that p = freq of trait-increasing allele, q = freq of trait-decreasing allele
1386 
1387  double a1, a2;
1388 
1389  if (tmp.nrows() == 1) { // only 'a' is provided
1390 
1391 
1392  if(_allele_model == 1) { // store +a and -a allelic values, with +a at position 0
1393  for (unsigned i = 0; i < _num_locus; ++i) {
1394 
1395  a1 = tmp.get(0, i % nval); // recycle allelic values among loci, if necessary
1396 
1397  if(a1 < 0) a1 = -1.0*a1; // we need the positive value in the first position
1398 
1399  a2 = -1.0*a1;
1400 
1401  _allele_value.set(i, 0, a1);
1402  _allele_value.set(i, 1, a2);
1403  }
1404  }
1405  else if (_allele_model == 2) // "asymmetrical case, create allele values {0, a}
1406  {
1407  for (unsigned i = 0; i < _num_locus; ++i) {
1408 
1409  a1 = tmp.get(0, i % nval); // recycle allelic values among loci, if necessary
1410  _allele_value.set(i, 0, 0.0); // first allele is the ancestral allele with value 0
1411  _allele_value.set(i, 1, a1); // second allele is the derived allele with a != 0
1412  }
1413  } else
1414  return error("parameter \"quanti_allele_value\" should only be used with the \"diallelic\" allele models.\n ");
1415 
1416  } else if (tmp.nrows() == 2) { // store A and a allelic values, a != -A
1417 
1418 
1419  for (unsigned i = 0; i < _num_locus; ++i) {
1420 
1421  a1 = tmp.get(0, i % nval); // recycle allelic values among loci
1422  a2 = tmp.get(1, i % nval);
1423 
1424  //smallest first; but we keep the "ancestral" allele (value 0, if provided) at position 0 in all cases
1425  if(a1 != 0.0 && a1 > a2) {
1426  a1 = a2;
1427  a2 = tmp.get(0, i % nval);
1428  }
1429  _allele_value.set(i, 0, a1);
1430  _allele_value.set(i, 1, a2);
1431  }
1432 
1433  } else {
1434  return error("\"quanti_allele_value\" must get a matrix with a max. of 2 rows (and max. num. columns = num. loci).\n");
1435  }
1436 
1437  } else { //not a matrix, therefore no locus-specific allelic values
1438 
1439  double a1 = get_parameter_value("quanti_allele_value"), a2;
1440 
1441  if(a1 < 0) a1 = -1.0*a1;
1442  a2 = -1.0*a1;
1443 
1444  _allele_value.set_col(0, a1);
1445  _allele_value.set_col(1, a2);
1446 
1447  }
1448  }
1449 
1450  // we need a mapping of sequence position to allele value to read the allele value from the sequence
1451  if(_sequence_diallele_values[0]) {
1452  delete [] _sequence_diallele_values[0];
1453  _sequence_diallele_values[0] = NULL;
1454  }
1455 
1456  if(_sequence_diallele_values[1]) {
1457  delete [] _sequence_diallele_values[1];
1458  _sequence_diallele_values[1] = NULL;
1459  }
1460 
1461  _sequence_diallele_values[0] = new double [_seq_length];
1462  _sequence_diallele_values[1] = new double [_seq_length];
1463 
1464  unsigned int pos, locID;
1465  for(unsigned int i = 0; i < _num_traits; ++i) {
1466  for(unsigned int j = 0; j < get_num_locus(i); ++j) {
1467  pos = get_locus_seq_pos(j, i);
1468  locID = get_locus_ID(j, i);
1469  _sequence_diallele_values[0][pos] = _allele_value.get(locID, 0);
1470  _sequence_diallele_values[1][pos] = _allele_value.get(locID, 1);
1471  }
1472  }
1473 
1474  // detect equal-effects case for bulk bitstring genotype computation
1475  _equal_val_0 = _allele_value.get(0, 0);
1476  _equal_val_1 = _allele_value.get(0, 1);
1477  _equal_effects = true;
1478  for (unsigned int i = 1; i < _num_locus; ++i) {
1479  if (_allele_value.get(i, 0) != _equal_val_0 ||
1480  _allele_value.get(i, 1) != _equal_val_1) {
1481  _equal_effects = false;
1482  break;
1483  }
1484  }
1486 
1487  // build trait masks for bulk bitstring genotype computation
1488  // one bitstring per trait, with 1s at sequence positions belonging to that trait
1489  // works for all pleiotropy types (no_pleio, full_pleio, var_pleio)
1490  _trait_masks.clear();
1491  for (unsigned int t = 0; t < _num_traits; ++t) {
1492  _trait_masks.push_back(bitstring(_seq_length));
1493  for (unsigned int l = 0; l < get_num_locus(t); ++l)
1494  _trait_masks[t].set(_trait_table[t][l], true);
1495  }
1496 
1497  return true;
1498 }
virtual double get_parameter_value(std::string name)
Param value getter.
Definition: simcomponent.h:143
void set_col(unsigned int i, double val)
Sets element at column i to value val.
Definition: tmatrix.h:133
unsigned int get_locus_ID(unsigned int locus, unsigned int trait)
Definition: ttquanti.h:455
unsigned int get_locus_seq_pos(unsigned int loc, unsigned int trait)
Definition: ttquanti.h:453
unsigned int get_num_locus()
Definition: ttquanti.h:424
Non-template and faster implementation of std::bitset.
Definition: bitstring.h:57

References _allele_model, _allele_value, _equal_effects, _equal_val_0, _equal_val_1, _equal_val_diff, _num_locus, _num_traits, _seq_length, _sequence_diallele_values, _trait_masks, _trait_table, error(), TMatrix::get(), get_locus_ID(), get_locus_seq_pos(), get_num_locus(), SimComponent::get_parameter(), SimComponent::get_parameter_value(), Param::getMatrix(), TMatrix::ncols(), TMatrix::nrows(), TMatrix::reset(), TMatrix::set(), TMatrix::set_col(), and warning().

Referenced by setMutationModel_full_pleio(), setMutationModel_no_pleio(), and setMutationModel_var_pleio().

◆ setDominanceParameters()

bool TProtoQuanti::setDominanceParameters ( )
2312 {
2313  TMatrix tmp_mat;
2314 
2315 #ifdef _DEBUG_
2316  message("quant::setting dominance parameters\n");
2317 #endif
2318 
2319  _dominance_model = 0; // no dominance by default
2321 
2323  if(get_parameter("quanti_dominance_effects")->isSet())
2324  {
2325 
2327 
2328  if(get_parameter("quanti_dominance_effects")->isMatrix())
2329  {
2330 
2331  get_parameter("quanti_dominance_effects")->getMatrix(&tmp_mat);
2332 
2333  if(tmp_mat.nrows() > _num_traits)
2334  return error("the dominance effect matrix must hold at most as many rows as the number of quantitative trait.\n");
2335 
2336  if(tmp_mat.ncols() > _num_locus)
2337  return error("the dominance effect matrix must hold at most as many columns as the number of quantitative loci.\n");
2338 
2340 
2341  _equal_dom_coeff = true;
2342  double k = _dominance_effects.get(0,0);
2343  for(unsigned int i=0; i < _dominance_effects.nrows(); ++i) {
2344  for(unsigned int j=0; j < _dominance_effects.ncols(); ++j) {
2345  if(k != _dominance_effects.get(i,j)) {
2346  _equal_dom_coeff = false;
2347  break;
2348  }
2349  }
2350  }
2351  }
2352  else {
2353  _dominance_effects.assign( get_parameter_value("quanti_dominance_effects") );
2354  _equal_dom_coeff = true;
2355  }
2356 
2357  // set dominance flag active
2358  _dominance_model = 1; // internally, model 0 = no dominance
2359  }
2360 
2361 
2362 #ifdef _DEBUG_
2363  message("quant::dominance is set ? \"%s\"\n", (_dominance_model == 0 ? " no" : "yes"));
2364  if(_dominance_model) {
2365 
2366  message("quant::dominance coefficients (trait x locus table, 20 first loci):\n");
2367  for(unsigned int i = 0; i < _dominance_effects.nrows(); ++i)
2368  for(unsigned int j = 0; j < _dominance_effects.ncols() && j < 20; ++j)
2369  message("%.3f ", _dominance_effects.get(i,j));
2370  }
2371  message("\n");
2372 #endif
2373 
2374  return true;
2375 }
void assign(double val)
Assigns a value to all element of the matrix.
Definition: tmatrix.h:155
void copy_recycle(const TMatrix &mat)
Copy elements of 'mat', recycling elements of 'mat' if its size is smaller than current matrix.
Definition: tmatrix.h:90

References _dominance_effects, _dominance_model, _equal_dom_coeff, _num_locus, _num_traits, TMatrix::assign(), TMatrix::copy_recycle(), error(), TMatrix::get(), SimComponent::get_parameter(), SimComponent::get_parameter_value(), Param::getMatrix(), message(), TMatrix::ncols(), TMatrix::nrows(), and TMatrix::reset().

Referenced by setParameters().

◆ setEpistasisParameters()

bool TProtoQuanti::setEpistasisParameters ( )
690 {
691 
692  _epistasis = false;
693 
694  // set epistatic coefficients:
695 
696  if(get_parameter("quanti_epistatic_effects")->isSet()) {
697 
698  if(get_parameter("quanti_epistatic_network")->isSet()) {
699 
700  // --- sparse/network mode ---
701 
702  vector< vector<double> > net_mat, efx_mat;
703 
704  get_parameter("quanti_epistatic_network")->getVariableMatrix(&net_mat);
705  get_parameter("quanti_epistatic_effects")->getVariableMatrix(&efx_mat);
706 
707  if(net_mat.size() != efx_mat.size())
708  return error("\"quanti_epistatic_network\" and \"quanti_epistatic_effects\" must have the same number of rows (%i vs %i).\n",
709  (int)net_mat.size(), (int)efx_mat.size());
710 
711  // validate and count total interactions
712  _num_epi_coefs = 0;
713 
714  for(size_t r = 0; r < net_mat.size(); ++r) {
715 
716  unsigned int M = net_mat[r].size();
717 
718  if(M < 2)
719  return error("\"quanti_epistatic_network\" row %i must contain at least 2 loci (got %i).\n", (int)(r+1), M);
720 
721  unsigned int n_pairs = M * (M - 1) / 2;
722 
723  if(efx_mat[r].size() != n_pairs)
724  return error("\"quanti_epistatic_effects\" row %i must have %i values for %i loci (%i*(%i-1)/2), got %i.\n",
725  (int)(r+1), n_pairs, M, M, M, (int)efx_mat[r].size());
726 
727  for(unsigned int i = 0; i < M; ++i) {
728  int loc = (int)net_mat[r][i];
729  if(loc < 1 || loc > (int)_num_locus)
730  return error("\"quanti_epistatic_network\" row %i: locus index %i is out of range [1, %i].\n",
731  (int)(r+1), loc, _num_locus);
732  }
733 
734  _num_epi_coefs += n_pairs;
735  }
736 
739 
740  unsigned int idx = 0;
741 
742  for(size_t r = 0; r < net_mat.size(); ++r) {
743 
744  unsigned int M = net_mat[r].size();
745  unsigned int efx_idx = 0;
746 
747  for(unsigned int i = 0; i < M - 1; ++i) {
748  for(unsigned int j = i + 1; j < M; ++j) {
749  unsigned int loc_i = (unsigned int)net_mat[r][i] - 1; // 1-based to 0-based
750  unsigned int loc_j = (unsigned int)net_mat[r][j] - 1;
751  _epistatic_coefs_indices.set(idx, 0, min(loc_i, loc_j));
752  _epistatic_coefs_indices.set(idx, 1, max(loc_i, loc_j));
753  _epistatic_coefs_matrix.set(0, idx, efx_mat[r][efx_idx]);
754  efx_idx++;
755  idx++;
756  }
757  }
758  }
759 
760  } else {
761 
762  // --- dense mode (existing behavior) ---
763 
765 
766  unsigned int num_interact = _num_locus*(_num_locus-1)/2.0; //num of pairwise interactions
767 
768  assert(num_interact == _num_epi_coefs);
769 
771 
772  TMatrix readEpiCoefs;
773 
774  get_parameter("quanti_epistatic_effects")->getMatrix(&readEpiCoefs);
775 
776  if(readEpiCoefs.nrows() > 1)
777  return error("\"quanti_epistatic_effects\" must be an array, i.e., have one row only\n");
778 
779  if(readEpiCoefs.ncols() > _num_epi_coefs){
780 
781  return error("The number of epistatic coefficients provided with \"quanti_epistatic_effects\"\
782  must be at most equal to the total number of pairwise locus interactions (%i for %i loci).\n", _num_epi_coefs, _num_locus);
783 
784  }
785 
787 
789 
790  // Here _epistatic_coefs_indices covers only pairwise epistatic interactions
791  // and has dimensions nbCoefs x 2
793 
794  }
795 
796  _epistasis = true;
797  }
798 
799 
800  return true;
801 }
unsigned int length() const
Returns the number of elements in the matrix.
Definition: tmatrix.h:218
TMatrix nChooseKVec(int n, int k)
Definition: utils.cc:198
unsigned long nChooseK(int n, int k)
Definition: utils.cc:174

References _epistasis, _epistatic_coefs_indices, _epistatic_coefs_matrix, _num_epi_coefs, _num_locus, TMatrix::copy(), TMatrix::copy_recycle(), error(), SimComponent::get_parameter(), Param::getMatrix(), Param::getVariableMatrix(), TMatrix::length(), nChooseK(), nChooseKVec(), TMatrix::ncols(), TMatrix::nrows(), TMatrix::reset(), and TMatrix::set().

Referenced by setParameters().

◆ setGeneticMapParams()

bool TProtoQuanti::setGeneticMapParams ( )
649  {
650 
651  //bypass the genetic map for free recombination to save significant time:
652  //this is done whenever the recombination rate is set to 0.5
653 
654  if( TTProtoWithMap::isRecombinationFree("quanti")) { //test all possible options to set recomb rate = 0.5
655 
657 
659 
660  //necessary for the inherit_free function:
661  if(_all_chooser) delete [] _all_chooser;
662  _all_chooser = new bool[_num_locus];
663 
664  } else {
665  // loci are not independent, ie recomb rate < 0.5
666 
667  // the loci positions will be registered in the genetic map
668  if( !setGeneticMapParameters("quanti", _num_locus) ) return false;
669 
671 
672  }
673 
674  return true;
675 }
void inherit_low(sex_t SEX, TTQuanti *ind, const TTQuanti *parent)
Definition: ttquanti.cc:2601
void inherit_free(sex_t SEX, TTQuanti *ind, const TTQuanti *parent)
Definition: ttquanti.cc:2639
double _recombRate
Definition: ttrait_with_map.h:195
bool setGeneticMapParameters(string prefix, unsigned int numLoci=0)
Definition: ttrait_with_map.cc:126
bool isRecombinationFree(string prefix)
Definition: ttrait_with_map.cc:99

References _all_chooser, _inherit_fun_ptr, _num_locus, TTProtoWithMap::_recombRate, inherit_free(), inherit_low(), TTProtoWithMap::isRecombinationFree(), and TTProtoWithMap::setGeneticMapParameters().

Referenced by setParameters().

◆ setHeritabilityParams()

bool TProtoQuanti::setHeritabilityParams ( )
438  {
439 
440  // temporary TMatrix for parameters read-in
441  TMatrix tmp_mat;
442 
443 #ifdef _DEBUG_
444  message("quant::setting heritability parameters\n");
445 #endif
446  //---------------------------------------------------------------------------------------------
447  // ENVIRONMENTAL VARIANCE and HERITABILITY
448 
449  _eVariance.clear(); //it is empty by default, signaling that we do not add Ve to trait genotype
450 
451  if(get_parameter("quanti_environmental_variance")->isSet()){
452 
453  if(get_parameter("quanti_environmental_variance")->isMatrix())
454  {
455  // environmental effects can be trait-specific
456  get_parameter("quanti_environmental_variance")->getMatrix(&tmp_mat);
457 
458  if(tmp_mat.nrows() > 1)
459  return error("\"quanti_environmental_variance\" accepts only an array with one row. \
460 The matrix has %i rows.\n", tmp_mat.nrows());
461 
462  if(tmp_mat.ncols() > _num_traits)
463  return error("\"quanti_environmental_variance\" accepts an array with as many values as the number of traits. \
464 The matrix has %i columns.\n", tmp_mat.ncols());
465 
466  if(tmp_mat.ncols() < _num_traits)
467  warning("\"quanti_environmental_variance\" received an array with less values (%i) than the number of traits (%i). \
468 The values will be recycled among traits.", tmp_mat.ncols(), _num_traits);
469 
470  double var;
471 
472  for(unsigned int i = 0; i < _num_traits; i++) {
473 
474  var = tmp_mat.get(0, i%tmp_mat.ncols()); // recycle values if less values provided than number of traits
475 
476  if( var < 0 )
477  return error("\"quanti_environmental_variance\" received a negative value for trait %i!\n", i+1 );
478  else
479  _eVariance.push_back( sqrt(var) ); // store the SD to save time later
480  }
481 
482  } else { // single value provided, copied for all traits
483 
484  double var = get_parameter_value("quanti_environmental_variance");
485 
486  if( var < 0 )
487  return error("\"quanti_environmental_variance\" received a negative value!\n");
488 
489  for(unsigned int i = 0; i < _num_traits; ++i) {
490  _eVariance.push_back( sqrt(var) ); // store the SD to save time later
491  }
492 
493  }
494 
495  } // END if env variance
496 
497 #ifdef _DEBUG_
498  if(_eVariance.size() > 0) {
499 
500  message("quant::environmental variance is set to: ");
501 
502  for(unsigned int i = 0; i < _eVariance.size(); ++i)
503  message("%.3f, ", _eVariance[i]);
504 
505  message("\n");
506 
507  } else {
508 
509  message("quant::no environmental variance is set\n");
510  }
511 
512 #endif
513 
514  _h2.clear();
515 
516  if(get_parameter("quanti_heritability")->isSet()){
517 
518  if(get_parameter("quanti_heritability")->isMatrix()) // can be trait-specific
519  {
520  get_parameter("quanti_heritability")->getMatrix(&tmp_mat);
521 
522  if(tmp_mat.nrows() > 1)
523  return error("\"quanti_heritability\" accepts only an array with one row. \
524 The matrix has %i rows.\n", tmp_mat.nrows());
525 
526  if(tmp_mat.ncols() > _num_traits)
527  return error("\"quanti_heritability\" accepts an array with as many values as the number of traits. \
528 The matrix has %i columns.\n", tmp_mat.ncols());
529 
530  if(tmp_mat.ncols() < _num_traits)
531  warning("\"quanti_heritability\" received an array with less values (%i) than the number of traits (%i). \
532 The values will be recycled among traits.", tmp_mat.ncols(), _num_traits);
533 
534 
535  double h2;
536 
537  for(unsigned int i = 0; i < _num_traits; i++) {
538 
539  h2 = tmp_mat.get(0, i%_num_traits); // value recycling
540 
541  if( h2< 0 )
542  return error("\"quanti_heritability\" received a negative value for trait %i!\n", i+1 );
543  else
544  _h2.push_back( h2 ); // store the SD to save time later
545  }
546 
547  } else {
548 
549  double h2 = get_parameter_value("quanti_heritability");
550 
551  if( h2 < 0 )
552  return error("\"quanti_heritability\" received a negative value!\n");
553 
554  for(unsigned int i = 0; i < _num_traits; ++i) {
555  _h2.push_back( h2 ); // store the SD to save time later
556  }
557 
558  }
559  } //END IF isSet heritability
560 
561  _h2_setTime = 0;
562  if(get_parameter("quanti_heritability_setTime")->isSet()){
563  _h2_setTime = (unsigned int)get_parameter_value("quanti_heritability_setTime");
564  }
565 
566  _h2_isBroad = false;
567  if(get_parameter("quanti_heritability_isBroad")->isSet())
568  _h2_isBroad = (bool)get_parameter_value("quanti_heritability_isBroad");
569 
570 #ifdef _DEBUG_
571  if(_h2.size() > 0) {
572 
573  message("quant::heritability is set to: ");
574 
575  for(unsigned int i = 0; i < _eVariance.size(); ++i)
576  message("%.3f, ", _h2[i]);
577 
578  message("\n");
579 
580  } else {
581 
582  message("quant::no heritability is set, it will bepend on Ve (see above)\n");
583  }
584 
585  if(_h2_isBroad)
586  message("quant::heritability is set to \"broad sense\"\n");
587 #endif
588 
589  return true;
590 }

References _eVariance, _h2, _h2_isBroad, _h2_setTime, _num_traits, error(), TMatrix::get(), SimComponent::get_parameter(), SimComponent::get_parameter_value(), Param::getMatrix(), Param::isSet(), message(), TMatrix::ncols(), TMatrix::nrows(), and warning().

Referenced by setParameters().

◆ setInitialValuesParams()

bool TProtoQuanti::setInitialValuesParams ( )
594  {
595 
596  //---------------------------------------------------------------------------------------------
597  // INITIAL VALUES:
598 
599  if(get_parameter("quanti_init_value")->isSet()) {
600 
601  get_parameter("quanti_init_value")->getMatrix(&_init_value);
602 
603  if(_init_value.nrows() != 1 || _init_value.ncols() != _num_traits) {
604  return error("\"quanti_init_value\" must be an array of length equal to the number of traits!\n");
605  }
606 
607  }
608  else {
609  _init_value.reset(1,_num_traits, 0.0);
610  }
611 
612  if(get_parameter("quanti_init_model")->isSet()) {
613 
614  _doInitMutation = (unsigned int)get_parameter_value("quanti_init_model");
615 
616  } else {
617  _doInitMutation = 0;
618  }
619 
620  if(get_parameter("quanti_init_variance")->isSet()) {
621 
622  if(get_parameter("quanti_init_variance")->isMatrix()) {
623 
624  get_parameter("quanti_init_variance")->getMatrix(&_init_variance);
625 
627  return error("\"quanti_init_variance\" must be an array of length equal to the number of traits!\n");
628  }
629 
630  } else {
631  _init_variance.reset(1, _num_traits, get_parameter_value("quanti_init_variance"));
632  }
633 
634  }
635  else { // initial variance is not set
636 
637  // verify that the initial variance is set when needed
638  if(_doInitMutation == 2 && _allele_model > 2)
639  return error("the initial trait variance must be set with \"quanti_init_variance\" for init model 2 and continuous allelic model.\n");
640 
642  }
643 
644  return true;
645 }

References _allele_model, _doInitMutation, _init_value, _init_variance, _num_traits, error(), SimComponent::get_parameter(), SimComponent::get_parameter_value(), Param::getMatrix(), Param::isMatrix(), Param::isSet(), TMatrix::ncols(), TMatrix::nrows(), and TMatrix::reset().

Referenced by setParameters().

◆ setMutationCorrelation()

bool TProtoQuanti::setMutationCorrelation ( )
1865 {
1866  //---------------------------------------------------------------------------------------
1867  // MUTATIONAL CORRELATION
1868 
1869  // temporary TMatrix for parameters read-in
1870  TMatrix tmp_mat;
1871 
1872  _mutation_correlation.reset(1, _num_locus); // sets all elements to 0
1873 
1874  if(get_parameter("quanti_mutation_correlation")->isSet()) {
1875 
1876  if( get_parameter("quanti_mutation_matrix")->isSet() ){
1877 
1878  warning("\"quanti_mutation_correlation\" and \"quanti_mutation_matrix\" are set, we only use the mutation matrix. \"quanti_mutation_correlation\" is ignored.");
1879 
1880  } else if (_num_traits == 1) {
1881 
1882  warning("\"quanti_mutation_correlation\" is set but only one trait is modeled. Parameter is ignored.");
1883 
1884  } else {
1885 
1886  if(get_parameter("quanti_mutation_correlation")->isMatrix()) {
1887 
1888  get_parameter("quanti_mutation_correlation")->getMatrix(&tmp_mat);
1889 
1890  if(tmp_mat.nrows() > 1)
1891  return error("\"quanti_mutation_correlation\" must be an array with one row. The matrix has %i rows.\n", tmp_mat.nrows());
1892 
1893  if(tmp_mat.ncols() > _num_locus)
1894  return error("\"quanti_mutation_correlation\" accepts an array with as many values as the number of loci. \
1895 The array has %i values.\n", tmp_mat.ncols());
1896 
1897  if(tmp_mat.ncols() < _num_locus)
1898  warning("\"quanti_mutation_correlation\" received an array with less values (%i) than the number of loci (%i). \
1899 The values will be recycled among loci.", tmp_mat.ncols(), _num_locus);
1900 
1902 
1903  } else { // not a matrix but a single value
1904 
1905  double val = get_parameter_value("quanti_mutation_correlation");
1906 
1907  if(val < -1.0 || val > 1.0)
1908  return error("quant::value assigned to \"quanti_mutation_correlation\" must be within [-1, 1].\n");
1909 
1911 
1912  }
1913 
1914  }
1915  } // _end_ if param->isSet()
1916 
1917  return true;
1918 }

References _mutation_correlation, _num_locus, _num_traits, TMatrix::assign(), TMatrix::copy_recycle(), error(), SimComponent::get_parameter(), SimComponent::get_parameter_value(), Param::getMatrix(), TMatrix::ncols(), TMatrix::nrows(), TMatrix::reset(), and warning().

Referenced by setMutationModel_full_pleio(), and setMutationModel_var_pleio().

◆ setMutationModel_full_pleio()

bool TProtoQuanti::setMutationModel_full_pleio ( )
870 {
871 
872  //store a few important numbers
874 
875  // memory size of a single allele value
876 // _sizeofLocusType = sizeof(double); --> this is set in setParameters() depending on the allele type
877 
878  // size of data used to store pleiotropic allelic values at a locus
880 
881  // mutation correlation set from "quanti_mutation_correlation"
882  if(!setMutationCorrelation()) return false;
883 
884  // set the set trait/locus_table, will be used by stat and file handlers to access data
886 
887  if( _allele_model == 1 || _allele_model ==2 ) {
888  //---------------------------------------------------------------------------------------
889  // DIALLELIC LOCI
890 
891  if (_num_traits > 2) { // multivariate models, only for non-diallelic loci
892 
893  return error("quant::the di-allelic model with pleiotropy is only allowed for max. 2 quantitative traits.\n");
894 
895  } else { // there are 2 traits, otherwise the "no_pleio" version of the function is called
896 
897  if(!setDiallelicMutationModel()) return false;
898 
900 
901  }
902 
903  } else {
904  //---------------------------------------------------------------------------------------
905  // CONTIUUM OF ALLELE MODEL
906 
907  if(!setContinuousMutationModel_full_pleio()) return false;
908 
909  if (_num_traits == 2) { // bivariate models, only for non-diallelic loci
910 
913  else
915 
916 
917  } else if (_num_traits > 2) { // multivariate models, only for non-diallelic loci
918 
921  else
923 
924  }
925  }
926 
927  // SET POINTER TO MUTATE FUNCTION
928 
929  if(_genomic_mutation_rate == 0) {
930 
932 
933  } else if(_allele_model <= 2) { // diallelic models
934 
936 
937  } else if(_allele_model == 3) { // continuous
939  } else // continuous in-place
941 
942 
943  return true;
944 }
double * getMutationEffectMultivariateGaussian(unsigned int loc)
Definition: ttquanti.cc:2390
void setTraitAndLocusTables_full_pleio()
Definition: ttquanti.cc:1273
void mutate_nill(TTQuanti *ind)
Definition: ttquanti.cc:2663
double * getMutationEffectBivariateGaussian(unsigned int loc)
Definition: ttquanti.cc:2414
void mutate_inplace_full_pleio(TTQuanti *ind)
Definition: ttquanti.cc:2763
double * getMutationEffectBivariateDiallelic(unsigned int loc)
Definition: ttquanti.cc:2457
void mutate_diallelic_pleio(TTQuanti *ind)
Definition: ttquanti.cc:2812
double * getMutationEffectBivariateGaussianLocSpec(unsigned int loc)
Definition: ttquanti.cc:2424
double * getMutationEffectMultivariateGaussianLocSpec(unsigned int loc)
Definition: ttquanti.cc:2402
bool setDiallelicMutationModel()
Definition: ttquanti.cc:1348
bool setMutationCorrelation()
Definition: ttquanti.cc:1864
void mutate_full_pleio(TTQuanti *ind)
Definition: ttquanti.cc:2691
bool setContinuousMutationModel_full_pleio()
Definition: ttquanti.cc:1502

References _allele_model, _genomic_mutation_rate, _getMutationValues, _locusByteSize, _mutation_func_ptr, _mutationVarianceIsLocusSpecific, _num_locus, _num_traits, _seq_length, _sizeofLocusType, error(), getMutationEffectBivariateDiallelic(), getMutationEffectBivariateGaussian(), getMutationEffectBivariateGaussianLocSpec(), getMutationEffectMultivariateGaussian(), getMutationEffectMultivariateGaussianLocSpec(), mutate_diallelic_pleio(), mutate_full_pleio(), mutate_inplace_full_pleio(), mutate_nill(), setContinuousMutationModel_full_pleio(), setDiallelicMutationModel(), setMutationCorrelation(), and setTraitAndLocusTables_full_pleio().

Referenced by setParameters().

◆ setMutationModel_no_pleio()

bool TProtoQuanti::setMutationModel_no_pleio ( )
1145 {
1146 
1147  //---------------------------------------------------------------------------------------------
1148  // NON-PLEIOTROPIC TRAITS
1149 
1150  // size of data used to store allelic values at a locus -- here non-pleiotropic
1152 
1153  TMatrix tmp;
1154 
1155  if(_num_traits > 1) {
1156 #ifdef _DEBUG_
1157  message("quant::setting num loci per trait without pleiotropy.\n");
1158 #endif
1159 
1160 
1161  if(get_parameter("quanti_loci_per_trait")->isSet()) {
1162 
1163  get_parameter("quanti_loci_per_trait")->getMatrix(&tmp);
1164 
1165  if( tmp.nrows() > 1)
1166  return error("\"quanti_loci_per_trait\" must be an array with one row.\n");
1167 
1168  if( !(tmp.ncols() == _num_traits) )
1169  return error("\"quanti_loci_per_trait\" must hold a number of loci for each trait. Use \"quanti_loci\" if loci are equally distributed among traits.\n");
1170 
1171  if(tmp.rowSum(0) != _num_locus)
1172  return error("\"quanti_loci_per_trait\" must specify a total number of loci equal to \"quanti_loci\"\n");
1173 
1174 #ifdef _DEBUG_
1175  message("quant::found trait-specific number of loci.\n");
1176 #endif
1177 
1178  } else {
1179  // divide the tot num of loci into num of traits
1180  tmp.reset(1, _num_traits);
1181 
1182  unsigned int loc_per_trait = _num_locus / _num_traits;
1183 
1184  tmp.assign(loc_per_trait);
1185 
1186  if( _num_locus % _num_traits != 0) {
1187  warning("quant::number of loci is not a multiple of the number of trait, setting the number of loci per trait to %i.\n", _num_locus / _num_traits);
1188  warning("quant::resetting the total number of quantitative loci to %i\n", loc_per_trait*_num_traits);
1189  }
1190 
1191  _num_locus = loc_per_trait*_num_traits;
1192 
1193 #ifdef _DEBUG_
1194  message("quant::set equal number of loci per trait (%i).\n", (unsigned int)tmp.get(0,0));
1195 #endif
1196 
1197  }
1198 
1199 #ifdef _DEBUG_
1200  message("quant::setting trait and locus table for no-pleiotropy case.\n");
1201 #endif
1202 
1204  }
1205  else {
1206 
1207  tmp.reset(1, 1, _num_locus);
1208 
1210  }
1211 
1212  // _seq_length is equal to _num_locus
1214 
1215  //-----------------------------------------------------------------------------------------
1216  // SET MUTATION MODEL
1217 
1218 
1219  if( _allele_model <= 2 ) {
1220  //---------------------------------------------------------------------------------------
1221  // DIALLELIC LOCI
1222 
1223  if(!setDiallelicMutationModel()) return false;
1224 
1225  } else {
1226  //---------------------------------------------------------------------------------------
1227  // CONTIUUM OF ALLELE MODEL
1228 #ifdef _DEBUG_
1229  message("quant::setting continuous allele model for no-pleiotropy case.\n");
1230 #endif
1231 
1232  if(!setContinuousMutationModel_no_pleio()) return false;
1233 
1236  else
1238  }
1239 
1240  //-----------------------------------------------------------------------------------------
1241  // SET POINTER TO MUTATE FUNCTION
1242 
1243  if(_genomic_mutation_rate == 0) {
1244 
1246 
1247  } else if(_allele_model <= 2) {// di-allelic models
1248 
1250 
1251  } else if(_allele_model == 3) {
1252 
1254 
1255  } else
1257 
1258 //-----------------------------------------------------------------------------------------
1259 // ADDITIONAL CHECKS
1260 
1261  if(_paramSet->isSet("quanti_mutation_correlation"))
1262  warning("quant trait::\"quanti_mutation_correlation\" has no effect on non-pleiotropic loci, it can be removed.\n");
1263 
1264  if(_paramSet->isSet("quanti_pleio_matrix"))
1265  warning("quant trait::\"quanti_pleio_matrix\" has no effect on non-pleiotropic loci, it can be removed.\n");
1266 
1267 
1268  return true;
1269 }
bool isSet()
Accessor to the status flag.
Definition: param.h:288
double rowSum(unsigned int row)
Sum all elements in a row.
Definition: tmatrix.h:318
double * getMutationEffectUnivariateGaussian(unsigned int loc)
Definition: ttquanti.cc:2433
bool setContinuousMutationModel_no_pleio()
Definition: ttquanti.cc:1826
void mutate_diallelic_no_pleio(TTQuanti *ind)
Definition: ttquanti.cc:2878
void mutate_inplace_no_pleio(TTQuanti *ind)
Definition: ttquanti.cc:2743
double * getMutationEffectUnivariateGaussianLocSpec(unsigned int loc)
Definition: ttquanti.cc:2441
void setTraitAndLocusTables_no_pleio(TMatrix &mat)
Definition: ttquanti.cc:1305
void mutate_no_pleio(TTQuanti *ind)
Definition: ttquanti.cc:2670

References _allele_model, _genomic_mutation_rate, _getMutationValues, _locusByteSize, _mutation_func_ptr, _mutationVarianceIsLocusSpecific, _num_locus, _num_traits, SimComponent::_paramSet, _seq_length, _sizeofLocusType, TMatrix::assign(), error(), TMatrix::get(), SimComponent::get_parameter(), Param::getMatrix(), getMutationEffectUnivariateGaussian(), getMutationEffectUnivariateGaussianLocSpec(), ParamSet::isSet(), message(), mutate_diallelic_no_pleio(), mutate_inplace_no_pleio(), mutate_nill(), mutate_no_pleio(), TMatrix::ncols(), TMatrix::nrows(), TMatrix::reset(), TMatrix::rowSum(), setContinuousMutationModel_no_pleio(), setDiallelicMutationModel(), setTraitAndLocusTables_no_pleio(), and warning().

Referenced by setParameters().

◆ setMutationModel_var_pleio()

bool TProtoQuanti::setMutationModel_var_pleio ( )
949 {
950 
951  //---------------------------------------------------------------------------------------------
952  // VARIABLE PLEIOTROPY: Jobran Chebib
953 
954  // size of data used to store pleiotropic allelic values at a locus,
955  //here set same as sizeof a single allele as PD varies per locus
957 
958  // initializes pleiotropic connectivity matrix -- "quanti_pleio_matx" in init file
959  // the connectivity matrix holds 0's in absence of a locus effect on a trait, and 1's otherwise
960  // loci are fully pleiotropic by default (1's everywhere)
961 
962  // a matrix is provided in input
963 
964  get_parameter("quanti_pleio_matrix")->getMatrix(&_pleio_matx); //this resets/builds the TMatrix
965 
967  return error("quant::\"quanti_pleio-matrix\" must be an m by n matrix of length m equal to the number of loci and n equal to the number of traits!\n");
968  }
969 
970  // end reading pleiot matrix
971 
972 
973 #ifdef _DEBUG_
974  // print _pleio_matrix
975  message("\nquant::pleiotropy matrix dimensions: rows(loci) = %i, columns(traits) = %i, (first 25 loci)\n",_pleio_matx.getNbRows(),_pleio_matx.getNbCols());
976  for(unsigned int i = 0; i < _pleio_matx.getNbRows() && i < 25; i++) {
977  for(unsigned int j = 0; j < _pleio_matx.getNbCols(); j++){
978  message("%.0f ",_pleio_matx.get(i,j));
979  message(" | ");
980  }
981  message("\n");
982  }
983 #endif
984 
985  // create temp_table from _pleio_matx to build _trait_table and _locus_table
986  // records the locus-specific allele position affecting each trait, which depends on the PD of each locus
987 
988  vector< vector<unsigned int> > temp_table(_pleio_matx.ncols(),vector<unsigned int>(_pleio_matx.nrows()));
989 
990  if(_trait_locus_table.size() != 0) _trait_locus_table.clear();
991  // build table:
992  _trait_locus_table.assign(_pleio_matx.ncols(),vector<unsigned int>()); //trait X locus table, size of each row unknown yet
993 
994  unsigned int PD = 0, pos = 1; //pos = 1 because '0' is for no-effect of locus i on trait j
995 
996  for(unsigned int i = 0; i < _pleio_matx.nrows(); ++i){
997  // check that at least one trait is affected for each locus (row)
998  PD = 0;
999  for(unsigned int j = 0; j < _pleio_matx.ncols(); ++j){
1000 
1001  if(_pleio_matx.get(i,j) == 1){
1002  temp_table[j][i] = pos; // pos is the array index in the sequence where the allelic value will be located
1003  pos++;
1004  PD++;
1005  _trait_locus_table[j].push_back(i); //add locus ID if that locus affects trait j
1006  }
1007  else if(_pleio_matx.get(i,j) == 0){
1008  temp_table[j][i] = 0;
1009  }
1010  else return error("quant::\"quanti_pleio_matrix\" must only contain 0s and 1s \n");
1011  }
1012 
1013  if(PD == 0)
1014  return error("quanti_pleio_matrix has only 0's for locus %i. Loci must affect at least one trait.\n", i+1);
1015  }
1016 
1017 #ifdef _DEBUG_
1018  // print temp_table (for debugging purposes only)
1019  message("quant::pleiotropic locus sequence position per trait (temp_table) (first 25 loci/trait): \n");
1020  for(unsigned int i=0; i<temp_table.size(); ++i){
1021  for(unsigned int j=0; j<temp_table[i].size() && j < 25; ++j){
1022  cout << temp_table[i][j] << " | ";
1023  }
1024  message("\n");
1025  }
1026 #endif
1027 
1028  // build _trait_table from temp_table (trait x locus)
1029  // it sets the array index of each allele affecting each trait in the QTL sequence
1030  // the sequence is organized as locus-trait: alleles affecting a given trait are NOT contiguous in the sequence
1031  if(_trait_table.size() != 0) _trait_table.clear();
1032 
1033  for(size_t i = 0; i < temp_table.size(); ++i){ //trait-wise
1034 
1035  _trait_table.push_back(vector<unsigned int>());
1036 
1037  for(size_t j = 0; j < temp_table[i].size(); ++j){ //locus-wise, size is the number of loci affecting trait i
1038 
1039  if(temp_table[i][j] != 0){
1040  _trait_table[i].push_back(temp_table[i][j]-1); //position in sequence where causative alleles are located
1041  }
1042  }
1043  }
1044 
1045  // build _locus_table from _pleio_matx
1046  // table holding { start locus index in sequence , pleiotropic degree } on each row
1047  if(_locus_table.size() != 0) _locus_table.clear();
1048 
1049  unsigned int pos4 = 0; //counts position in sequence
1050  unsigned int tsize = 0; //counts n traits affected = PD
1051 
1052  for(unsigned int i=0; i<_pleio_matx.getNbRows(); ++i){ //locus-wise
1053 
1054  _locus_table.push_back(vector<unsigned int> (2));
1055 
1056  _locus_table[i][0] = pos4;
1057 
1058  for(unsigned int j=0; j<_pleio_matx.getNbCols(); ++j){ //trait-wise, sum the row
1059 
1060  if(_pleio_matx.get(i,j) == 1)
1061  tsize++;
1062  }
1063 
1064  _locus_table[i][1] = tsize;
1065 
1066  pos4 += tsize;
1067 
1068  tsize = 0;
1069  }
1070 
1071  // calculate _seq_length from _trait_table
1072  _seq_length = 0;
1073  for(unsigned int i=0; i<_trait_table.size(); ++i){
1074  _seq_length += _trait_table[i].size();
1075  }
1076 
1077  //-----------------------------------------------------------------------------------------
1078  // SET MUTATION MODEL
1079 
1080  // mutation correlation set from "quanti_mutation_correlation"
1081  if(!setMutationCorrelation()) return false;
1082 
1083  if(_allele_model < 3 && !setDiallelicMutationModel()) return false;
1084 
1085  if(_allele_model > 2 && ! setContinuousMutationModel_var_pleio()) return false;
1086 
1087  _getMutationValuesVarPleio.clear(); // dimensionality of mutations depends on pleiotropic degree
1088 
1089  for(unsigned int i=0; i < _num_locus; ++i){
1090 
1091  if (_locus_table[i][1] == 1) { // PD = 1, no pleiotropy at this locus
1092 
1095  else
1097 
1098  } else if (_locus_table[i][1] == 2) { // PD = 2
1099 
1102  else
1104 
1105  } else if (_locus_table[i][1] > 2) { // PD > 2
1106 
1107  if (_allele_model > 2) {
1108 
1109 // if(_mutationVarianceIsLocusSpecific)
1111 // else
1112 // _getMutationValuesVarPleio.push_back(&TProtoQuanti::getMutationEffectMultivariateGaussian);
1113 
1114  } else {
1115  return error("quant::the di-allelic model with pleiotropy is only allowed for max. 2 quantitative traits (locus %i has PD = %i)\n.", i+1, _locus_table[i][1]);
1116  }
1117 
1118  }
1119  }
1120 
1121  //-----------------------------------------------------------------------------------------
1122  // SET POINTER TO MUTATE FUNCTION
1123 
1124  if(_genomic_mutation_rate == 0) {
1125 
1127 
1128  } else if(_allele_model <= 2) {// di-allelic models
1129 
1131 
1132  } else if(_allele_model == 3) {// continuous model
1133 
1135 
1136  } else //model 4, in-place continuous model
1138 
1139  return true;
1140 }
unsigned int getNbRows() const
Gives the number of rows.
Definition: tmatrix.h:212
unsigned int getNbCols() const
Gives the number of columns.
Definition: tmatrix.h:215
void mutate_inplace_var_pleio(TTQuanti *ind)
Definition: ttquanti.cc:2788
void mutate_diallelic_var_pleio(TTQuanti *ind)
Definition: ttquanti.cc:2847
void mutate_var_pleio(TTQuanti *ind)
Definition: ttquanti.cc:2717
bool setContinuousMutationModel_var_pleio()
Definition: ttquanti.cc:1669

References _allele_model, _genomic_mutation_rate, _getMutationValuesVarPleio, _locus_table, _locusByteSize, _mutation_func_ptr, _mutationVarianceIsLocusSpecific, _num_locus, _num_traits, _pleio_matx, _seq_length, _sizeofLocusType, _trait_locus_table, _trait_table, error(), TMatrix::get(), SimComponent::get_parameter(), Param::getMatrix(), getMutationEffectBivariateGaussian(), getMutationEffectBivariateGaussianLocSpec(), getMutationEffectMultivariateGaussianLocSpec(), getMutationEffectUnivariateGaussian(), getMutationEffectUnivariateGaussianLocSpec(), TMatrix::getNbCols(), TMatrix::getNbRows(), message(), mutate_diallelic_var_pleio(), mutate_inplace_var_pleio(), mutate_nill(), mutate_var_pleio(), TMatrix::ncols(), TMatrix::nrows(), setContinuousMutationModel_var_pleio(), setDiallelicMutationModel(), and setMutationCorrelation().

Referenced by setParameters().

◆ setMutationSigmaFromQuantiMutationVariance()

bool TProtoQuanti::setMutationSigmaFromQuantiMutationVariance ( )
1923 {
1924 
1925 // message("quant::found \"quanti_mutation_variance\" in input, checking dimensionality: ");
1926 
1927  if(get_parameter("quanti_mutation_variance")->isMatrix()) {
1928 
1929 #ifdef _DEBUG_
1930  message("\nquant::found locus-specific mutation variance (param is matrix).\n");
1931 #endif
1932 
1933  TMatrix tmp;
1934 
1935  get_parameter("quanti_mutation_variance")->getMatrix(&tmp);
1936 
1937 // message("%i x %i\n",tmp.nrows(), tmp.ncols());
1938 
1939  if(tmp.nrows() > 1) {
1940  error("\"quanti_mutation_variance\" must be an array with a single row and as many columns as the number of loci.\
1941 The matrix passed has %i rows.\n", tmp.nrows());
1942 
1943  error("Note: use \"quanti_mutation_matrix\" to specify different variance-covariance parameters for different traits\n");
1944  return false;
1945  }
1946 
1947  if(tmp.ncols() > _num_locus)
1948  return error("\"quanti_mutation_variance\" accepts an array with max. as many values as the number of loci. \
1949 The array has %i columns.\n", tmp.ncols());
1950 
1951  if(tmp.ncols() < _num_locus)
1952  warning("\"quanti_mutation_variance\" received an array with less values (%i) than the number of loci (%i). \
1953 The values will be recycled among loci.\n", tmp.ncols(), _num_locus);
1954 
1955  // using an array means that the mutation effect size is different among loci
1956  // we do not look at locus-specific pleiotropy here, but set the matrix to the maximum pleiotropic degree = num traits
1957 
1959 
1960 // message("quant::setting locus-specific mutation variance\n");
1961 
1962  // copy the values for each locus to all traits equally
1963  for(unsigned int i = 0; i < _num_locus; ++i) {
1964 
1965  if(tmp.get(0, i % tmp.ncols()) < 0)
1966  return error("quant::values assigned to \"quanti_mutation_variance\" must by > 0.\n");
1967 
1968  _mutation_sigma.set_row(i, sqrt( tmp.get(0, i % tmp.ncols()) ) );
1969  }
1970 
1971  } else { // not a matrix but a single value, the matrix has a single row
1972 
1973 // message("1 x 1\nquant::setting equal mutation variance on all traits and for all loci\n");
1974 
1975  if(get_parameter_value("quanti_mutation_variance") < 0)
1976  return error("quant::value assigned to \"quanti_mutation_variance\" must by > 0.\n");
1977 
1978  _mutation_sigma.reset(1, _num_traits, sqrt( get_parameter_value("quanti_mutation_variance") ));
1979 
1980  }
1981 
1982 #ifdef _DEBUG_
1983  message("quant::mutation sigma matrix:\n");
1985 #endif
1986 
1987  return true;
1988 }
void set_row(unsigned int i, double val)
Sets all elements at row i to value val.
Definition: tmatrix.h:111

References _mutation_sigma, _num_locus, _num_traits, error(), TMatrix::get(), SimComponent::get_parameter(), SimComponent::get_parameter_value(), Param::getMatrix(), message(), TMatrix::ncols(), TMatrix::nrows(), TMatrix::reset(), TMatrix::set_row(), TMatrix::show_up(), and warning().

Referenced by setContinuousMutationModel_full_pleio(), and setContinuousMutationModel_var_pleio().

◆ setMutationSigmaFromQuantiMutationVariance_no_pleio()

bool TProtoQuanti::setMutationSigmaFromQuantiMutationVariance_no_pleio ( )
1993 {
1994 // message("quant::found \"quanti_mutation_variance\" in input, checking dimensionality for non-pleiotropic loci: ");
1995 
1996  if(get_parameter("quanti_mutation_variance")->isMatrix()) {
1997 
1998  TMatrix tmp;
1999 
2000  get_parameter("quanti_mutation_variance")->getMatrix(&tmp);
2001 
2002 // message("%i x %i\n",tmp.nrows(), tmp.ncols());
2003 
2004  if(tmp.nrows() > _num_traits)
2005  return error("\"quanti_mutation_variance\" has more rows than the number of traits for non-pleiotropic loci. Ignoring extra rows.\n", tmp.nrows());
2006 
2007  if(tmp.ncols() > _num_locus)
2008  return error("\"quanti_mutation_variance\" has more columns than the number of loci. The matrix has %i columns.\n", tmp.ncols());
2009 
2010  if(tmp.ncols() < _num_locus || tmp.nrows() < _num_traits)
2011  warning("quant::\"quanti_mutation_variance\" received less values than expected from the number of loci or traits. \
2012 The values will be recycled among loci and traits.\n");
2013 
2014  // using an array means the mutation effect size is different among loci
2015  // we do not look at locus-specific pleiotropy here, but set the matrix to the maximum pleiotropic degree = num traits
2016 
2017 // message("quant::setting locus-specific mutation variance for non-pleiotropic loci\n");
2018 
2019  _mutation_sigma.reset(_num_locus, 1); //each locus is affecting one trait only
2020 
2021  TMatrix expanded_mat(_num_traits, _num_locus);
2022 
2023  // copy elements at the right place when provided as trait-specific variance per block of loci, for instance.
2024  expanded_mat.copy_recycle(tmp);
2025 
2026  // copy trait-specific variances into the mutation sigma matrix first column
2027  for(unsigned int i = 0; i < _num_traits; ++i) {
2028  for(unsigned int j = 0, pos = _trait_table[i][0]; j < _trait_table[i].size(); ++j, ++pos){
2029 
2030  if(expanded_mat.get(i,pos) < 0)
2031  return error("quant::values assigned to \"quanti_mutation_variance\" must by > 0.\n");
2032 
2033  _mutation_sigma.set(pos, 0, sqrt(expanded_mat.get(i,pos)));
2034  }
2035  }
2036 
2037  } else { // not a matrix but a single value, the matrix has a single row
2038 
2039 // message("1 x 1\nquant::setting equal mutation variance across all quantitative loci\n");
2040 
2041  if(get_parameter_value("quanti_mutation_variance") < 0)
2042  return error("quant::value assigned to \"quanti_mutation_variance\" must by > 0.\n");
2043 
2044  _mutation_sigma.reset(1, 1, sqrt( get_parameter_value("quanti_mutation_variance") ));
2045 
2046  }
2047 
2048 #ifdef _DEBUG_
2049  message("quant::mutation sigma matrix:\n");
2051 #endif
2052 
2053  return true;
2054 }

References _mutation_sigma, _num_locus, _num_traits, _trait_table, TMatrix::copy_recycle(), error(), TMatrix::get(), SimComponent::get_parameter(), SimComponent::get_parameter_value(), Param::getMatrix(), message(), TMatrix::ncols(), TMatrix::nrows(), TMatrix::reset(), TMatrix::set(), TMatrix::show_up(), and warning().

Referenced by setContinuousMutationModel_no_pleio().

◆ setParameters()

bool TProtoQuanti::setParameters ( )
virtual

Implements SimComponent.

250 {
251 #ifdef _DEBUG_
252  message("Trait quant::setting parameters\n");
253 #endif
254 
255  // reset all pointers to GSL matrices and vectors etc.
256  // do it here, before changing num trait and num loci for a new simulation
258 
259  //---------------------------------------------------------------------------------------
260  // Mandatory parameters:
261 
262  // number of quantitative traits
263  _num_traits = (unsigned int)get_parameter_value("quanti_traits");
264 
265  // number of loci
266  _num_locus = (unsigned int)get_parameter_value("quanti_loci");
267 
268  _2L = 2*_num_locus;
269 
270  // set the genomic mutation rate
271  _mutation_rate = get_parameter_value("quanti_mutation_rate");
272 
274 
275  // set the allelic model
276  if( !(_allele_model = setAlleleModel()) ) return false;
277 
278  // check and set the datatype of the alleles, and size thereof
279  if(get_parameter("quanti_diallele_datatype")->isSet()) {
280 
281  _diallele_datatype = get_parameter("quanti_diallele_datatype")->getArg();
282 
283  if(_diallele_datatype != "byte" && _diallele_datatype != "bit")
284  return error("\"quanti_diallele_datatype\" received \"%s\", valid options are \"byte\" or \"bit\"\n",
285  _diallele_datatype.c_str());
286  }
287  else
288  _diallele_datatype = "bit";
289 
290  if(_allele_model <= 2)
291  _sizeofLocusType = sizeof(unsigned char); // only used for "byte" datatype; i.e. di-allelic loci
292  else
293  _sizeofLocusType = sizeof(double);
294 
295  //---------------------------------------------------------------------------------------
296  // type of pleiotropy and pleiotropy-dpdt parameters:
297 
298  string pleio = get_parameter("quanti_pleiotropy")->getArg();
299 
300  if(_num_traits == 1 || pleio == "no" || pleio == "n" || pleio == "") {
301 
302  _pleio_type = 0;
303 
304 #ifdef _DEBUG_
305  message("quant::%s pleiotropy, %i trait(s), %i loci\n", "no", _num_traits, _num_locus);
306 #endif
307 
308  if(!setMutationModel_no_pleio()) return false;
309 
310  } else if (pleio == "full" || pleio == "f") {
311 
312  if(get_parameter("quanti_pleio_matrix")->isSet())
313  warning("\"quanti_pleio_matrix\" is ignored when pleiotropy type is \"full\".\n");
314 
315  _pleio_type = 1;
316 
317 #ifdef _DEBUG_
318  message("quant::%s pleiotropy, %i trait(s), %i loci\n", "full", _num_traits, _num_locus);
319 #endif
320 
321  if (!setMutationModel_full_pleio()) return false;
322 
323  } else if (pleio == "var" || pleio == "variable" || pleio == "v") {
324 
325  if(!get_parameter("quanti_pleio_matrix")->isSet())
326  return error("\"quanti_pleio_matrix\" must be provided when pleiotropy type is \"variable\".\n");
327 
328  _pleio_type = 2;
329 
330 #ifdef _DEBUG_
331  message("quant::%s pleiotropy, %i trait(s), %i loci\n", "variable", _num_traits, _num_locus);
332 #endif
333 
334  if(!setMutationModel_var_pleio()) return false;
335 
336  } else {
337  return error("\"quanti_pleiotropy\" takes options: full (f), var(iable) (v), or no (n)\n");
338  }
339 
340 #ifdef _DEBUG_
341  // print _trait_table (for debugging purposes only
342  message("quant::pleiotropic locus sequence position per trait (_trait_table) (ID:pos of first 10 loci/trait): \n");
343  for(unsigned int i=0; i<_trait_table.size(); ++i){
344  message("trait %i:\n", i);
345  for(unsigned int j=0; j <_trait_table[i].size() && j < 10; ++j){
346  message("%i:%i | ", _trait_locus_table[i][j], _trait_table[i][j]);
347  }
348  message("\n");
349  }
350  message("\n_trait_size: %i\n", _trait_table.size());
351 
352  // print _locus_table (for debugging purposes only)
353  message("quant::pleiotropic degree per locus (_locus_table) (first position in sequence of a locus : PD; for the first 25 loci): \n");
354  for(unsigned int i = 0; i <_locus_table.size() && i < 25; ++i){
355  message(" %i: %i \n", _locus_table[i][0], _locus_table[i][1]);
356  }
357 
358  message("quant::total sequence length: %i\n", _seq_length);
359 #endif
360 
361  //---------------------------------------------------------------------------------------
362  // ENVIRONMENTAL VARIANCE AND HERITABILITY
363 
364  // check and set environmental variance and heritability parameters:
365  if( !setHeritabilityParams()) return false;
366 
367  // setting the pointer to the phenotype setter function
368  // called in TProtoQuanti::get_phenotypic_value, itself called by TTQuanti::set_value()
369  if(_eVariance.size() != 0 ) {
370 
372 
373  } else { // no environmental effect
374 
376 
377  }
378 
379  //---------------------------------------------------------------------------------------
380  // INITIAL TRAIT VALUES
381  if( !setInitialValuesParams()) return false;
382 
383  //---------------------------------------------------------------------------------------
384  // COMPUTING GENOTYPE VALUES: ADDITVITY and DOMINANCE
385 
386  if( !setDominanceParameters() ) return false;
387 
388  //---------------------------------------------------------------------------------------
389  // EPISTASIS
390  if( !setEpistasisParameters() ) return false;
391 
392 
393  //---------------------------------------------------------------------------------------
394  // set pointers to genotype value setter
395 
396  // epistasis is hidden in the additive and dominance value setter of the "epistatic" classes
397  // epistasis is thus allowed on top of dominance
398 
399 
400  // set function pointers to default k-dominance model if dominance is added
401  if(_dominance_model) {
402 
405 
406  } else {
407 
410 
411  }
412 
413 
414 
415  //---------------------------------------------------------------------------------------
416  // GENETIC MAP AND INHERIT FUNCTION POINTER
417 
418  if( !setGeneticMapParams()) return false;
419 
420 #ifdef _DEBUG_
421 
422  TTQuanti* trait = hatch();
423 
424  trait->init();
425  trait->init_sequence();
426  message("quant::parameters are set; display individual trait info:\n");
427  trait->show_up();
428 
429  delete trait;
430 
431 #endif
432 
433  return true;
434 }
unsigned int setAlleleModel()
Definition: ttquanti.cc:805
double set_genotype_value_dominance(const TTQuanti *ind, const unsigned int trait)
Definition: ttquanti.cc:2532
double set_genotype_value_additive(const TTQuanti *ind, const unsigned int trait)
Definition: ttquanti.cc:2525
bool setMutationModel_var_pleio()
Definition: ttquanti.cc:948
bool setMutationModel_no_pleio()
Definition: ttquanti.cc:1144
bool setDominanceParameters()
Definition: ttquanti.cc:2311
bool setInitialValuesParams()
Definition: ttquanti.cc:594
bool setGeneticMapParams()
Definition: ttquanti.cc:649
virtual TTQuanti * hatch()
Definition: ttquanti.cc:2898
bool setEpistasisParameters()
Definition: ttquanti.cc:689
bool setHeritabilityParams()
Definition: ttquanti.cc:438
bool setMutationModel_full_pleio()
Definition: ttquanti.cc:869
virtual void show_up()=0
Writes some info to stdout.
virtual void init()=0
Called to allocate the trait's genotypic sequences.
virtual void init_sequence()=0
Called at the start of each replicate, sets the initial genotypes.

References _2L, _allele_model, _diallele_datatype, _dominance_model, _eVariance, _genomic_mutation_rate, _getGenotypeWithDominance, _locus_table, _mutation_rate, _num_locus, _num_traits, _pleio_type, _seq_length, _set_genotype_func_ptr, _set_trait_value_func_ptr, _sizeofLocusType, _trait_locus_table, _trait_table, deallocate_gsl_mutation_matrix_space(), error(), get_genotype_dominance_k(), SimComponent::get_parameter(), SimComponent::get_parameter_value(), Param::getArg(), hatch(), TTrait::init(), TTrait::init_sequence(), message(), set_genotype_value_additive(), set_genotype_value_dominance(), set_trait_value_noVE(), set_trait_value_VE(), setAlleleModel(), setDominanceParameters(), setEpistasisParameters(), setGeneticMapParams(), setHeritabilityParams(), setInitialValuesParams(), setMutationModel_full_pleio(), setMutationModel_no_pleio(), setMutationModel_var_pleio(), TTrait::show_up(), and warning().

◆ setTraitAndLocusTables_full_pleio()

void TProtoQuanti::setTraitAndLocusTables_full_pleio ( )
1274 {
1275  // set the number of loci per trait in the _trait_table
1276  _trait_table.clear();
1277  _trait_table.assign(_num_traits, vector<unsigned int>(_num_locus));
1278 
1279  for(unsigned int i = 0; i < _num_traits; ++i) {
1280  for(unsigned int j = 0; j < _num_locus; ++j)
1281  _trait_table[i][j] = j*_num_traits + i;
1282  }
1283 
1284  // set the ID of loci affecting each trait in the _trait_locus_table
1285  _trait_locus_table.clear();
1286  _trait_locus_table.assign(_num_traits, vector<unsigned int>(_num_locus));
1287 
1288  for(unsigned int i = 0; i < _num_traits; ++i)
1289  for(unsigned int j = 0; j < _num_locus; ++j)
1290  _trait_locus_table[i][j] = j;
1291 
1292  // build _locus_table from _pleio_matx
1293  // table holding { start locus index in sequence , pleiotropic degree } on each row
1294  _locus_table.clear();
1295  _locus_table.assign(_num_locus, vector<unsigned int>(2));
1296 
1297  for(unsigned int i = 0; i < _num_locus; ++i) {
1298  _locus_table[i][0] = i*_num_traits;
1299  _locus_table[i][1] = _num_traits;
1300  }
1301 }

References _locus_table, _num_locus, _num_traits, _trait_locus_table, and _trait_table.

Referenced by setMutationModel_full_pleio().

◆ setTraitAndLocusTables_no_pleio()

void TProtoQuanti::setTraitAndLocusTables_no_pleio ( TMatrix mat)
1306 {
1307  // loci are contiguous, separated in chunks each affecting different traits
1308 
1309  // set the number of loci array position in the _trait_table
1310  // starting position in the sequence array of each locus set is the first value of each row
1311  _trait_table.clear();
1312 
1313  unsigned int loc = 0;
1314 
1315  for(unsigned int i = 0; i < _num_traits; ++i) {
1316 
1317  _trait_table.push_back(vector<unsigned int>(numLoc.get(0,i)));
1318 
1319  for(unsigned int j = 0; j < numLoc.get(0,i); ++j)
1320 
1321  _trait_table[i][j] = loc++;
1322  }
1323 
1324  assert(loc == _num_locus);
1325 
1326  // set the ID of loci affecting each trait in the _trait_locus_table,
1327  _trait_locus_table.clear();
1328  _trait_locus_table.assign(_num_traits, vector<unsigned int>());
1329 
1330  // here we just copy the _trait_table
1331  for(unsigned int i = 0; i < _num_traits; ++i) {
1332  _trait_locus_table[i].assign(_trait_table[i].begin(), _trait_table[i].end());
1333  }
1334 
1335  // build _locus_table from _pleio_matx
1336  // table holding { start locus index in sequence , pleiotropic degree } on each row
1337  _locus_table.clear();
1338  _locus_table.assign(_num_locus, vector<unsigned int>(2));
1339 
1340  for(unsigned int i = 0; i < _num_locus; ++i) {
1341  _locus_table[i][0] = i;
1342  _locus_table[i][1] = 1;
1343  }
1344 }

References _locus_table, _num_locus, _num_traits, _trait_locus_table, _trait_table, and TMatrix::get().

Referenced by setMutationModel_no_pleio().

◆ store_data()

virtual void TProtoQuanti::store_data ( BinaryStorageBuffer saver)
inlinevirtual

Implements StorableComponent.

587  {saver->store(&_seq_length,sizeof(int));}
void store(void *stream, unsigned int nb_bytes)
Definition: binarystoragebuffer.cc:16

References _seq_length, and BinaryStorageBuffer::store().

Friends And Related Function Documentation

◆ TTQuanti

friend class TTQuanti
friend

◆ TTQuanti_continuous

friend class TTQuanti_continuous
friend

◆ TTQuanti_continuous_full_pleio

friend class TTQuanti_continuous_full_pleio
friend

Referenced by hatch().

◆ TTQuanti_continuous_no_pleio

friend class TTQuanti_continuous_no_pleio
friend

Referenced by hatch().

◆ TTQuanti_continuous_single

friend class TTQuanti_continuous_single
friend

◆ TTQuanti_continuous_var_pleio

friend class TTQuanti_continuous_var_pleio
friend

Referenced by hatch().

Member Data Documentation

◆ _2L

unsigned int TProtoQuanti::_2L
protected

Diploid locus size, to save on useless operations during mutation.

Referenced by get_num_mutations(), and setParameters().

◆ _all_chooser

bool* TProtoQuanti::_all_chooser
private

◆ _allele_model

◆ _allele_value

◆ _diallele_datatype

string TProtoQuanti::_diallele_datatype
protected

Referenced by hatch(), and setParameters().

◆ _doInitMutation

unsigned int TProtoQuanti::_doInitMutation
private

◆ _dominance_effects

TMatrix TProtoQuanti::_dominance_effects
private

◆ _dominance_model

unsigned int TProtoQuanti::_dominance_model
private

◆ _effects_bivar

◆ _effects_multivar

◆ _epistasis

bool TProtoQuanti::_epistasis
private

◆ _epistatic_coefs_indices

TMatrix TProtoQuanti::_epistatic_coefs_indices
private

◆ _epistatic_coefs_matrix

TMatrix TProtoQuanti::_epistatic_coefs_matrix
private

◆ _equal_dom_coeff

bool TProtoQuanti::_equal_dom_coeff
private

◆ _equal_effects

bool TProtoQuanti::_equal_effects
private

◆ _equal_val_0

double TProtoQuanti::_equal_val_0
private

◆ _equal_val_1

double TProtoQuanti::_equal_val_1
private

◆ _equal_val_diff

double TProtoQuanti::_equal_val_diff
private

◆ _eval

◆ _eVariance

vector<double> TProtoQuanti::_eVariance
private

◆ _evect

◆ _freqExtractor

TTQFreqExtractor* TProtoQuanti::_freqExtractor
private

Referenced by loadFileServices(), and ~TProtoQuanti().

◆ _genomic_mutation_rate

◆ _getGenotypeWithDominance

double(TProtoQuanti::* TProtoQuanti::_getGenotypeWithDominance) (double, double, double)
private

Pointer to either dominance_h() or dominance_k() function computing the genotypic value with dominance.

Referenced by setParameters().

◆ _getMutationValues

double*(TProtoQuanti::* TProtoQuanti::_getMutationValues) (unsigned int)
private

◆ _getMutationValuesVarPleio

vector< double* (TProtoQuanti::* ) (unsigned int) > TProtoQuanti::_getMutationValuesVarPleio
private

Collection of pointers to mutation functions, which generate allele values in dependence of pleiotropic degree.

Referenced by getMutationEffectsVarPleio(), mutate_inplace_var_pleio(), mutate_var_pleio(), and setMutationModel_var_pleio().

◆ _gsl_mutation_matrix

◆ _h2

vector<double> TProtoQuanti::_h2
private

◆ _h2_isBroad

bool TProtoQuanti::_h2_isBroad
private

◆ _h2_setTime

unsigned int TProtoQuanti::_h2_setTime
private

◆ _inherit_fun_ptr

void(TProtoQuanti::* TProtoQuanti::_inherit_fun_ptr) (sex_t, TTQuanti *, const TTQuanti *)
private

Pointer to inheritance functions: either inherit_free() (r=0.5), or inherit_low() (r<0.5).

Referenced by inherit(), and setGeneticMapParams().

◆ _init_value

TMatrix TProtoQuanti::_init_value
private

◆ _init_variance

TMatrix TProtoQuanti::_init_variance
private

◆ _locus_table

vector< vector<unsigned int> > TProtoQuanti::_locus_table
private

Locus table, num_locus x 2, first column holds the start position of the alleles of each locus in the sequence, second column counts the number of alleles = pleiotropic degree.

Allelic values at a locus are contiguous in the sequence.

Referenced by get_locus_PD(), get_locus_start_pos(), get_sequence_block_size(), mutate_diallelic_var_pleio(), mutate_inplace_var_pleio(), mutate_var_pleio(), setContinuousMutationModel_var_pleio(), setMutationModel_var_pleio(), setParameters(), setTraitAndLocusTables_full_pleio(), and setTraitAndLocusTables_no_pleio().

◆ _locusByteSize

◆ _mutation_correlation

◆ _mutation_func_ptr

void(TProtoQuanti::* TProtoQuanti::_mutation_func_ptr) (TTQuanti *)
private

Pointer to mutation function, which depends on allele on model (HC, noHC, diallelic)

Referenced by mutate(), setMutationModel_full_pleio(), setMutationModel_no_pleio(), and setMutationModel_var_pleio().

◆ _mutation_rate

double TProtoQuanti::_mutation_rate
protected

◆ _mutation_sigma

◆ _mutationEffectIsFixedDiAllele

bool TProtoQuanti::_mutationEffectIsFixedDiAllele
private

◆ _mutationVarianceIsLocusSpecific

◆ _num_epi_coefs

unsigned int TProtoQuanti::_num_epi_coefs
private

◆ _num_locus

◆ _num_traits

◆ _ohtaStats

TTQOhtaStats* TProtoQuanti::_ohtaStats
private

Referenced by loadFileServices(), and ~TProtoQuanti().

◆ _pleio_matx

TMatrix TProtoQuanti::_pleio_matx
private

Pleiotropy matrix provided in input (num locu X num trait).

Gene (row)-trait (column) connectivity matrix.

Referenced by get_pleio_matrix(), setMutationModel_var_pleio(), and TProtoQuanti().

◆ _pleio_type

unsigned int TProtoQuanti::_pleio_type
protected

◆ _reader

TTQuantiFH* TProtoQuanti::_reader
private

Referenced by loadFileServices(), and ~TProtoQuanti().

◆ _seq_length

unsigned int TProtoQuanti::_seq_length
protected

◆ _sequence_diallele_values

double* TProtoQuanti::_sequence_diallele_values[2]
private

◆ _set_genotype_func_ptr

double(TProtoQuanti::* TProtoQuanti::_set_genotype_func_ptr) (const TTQuanti *, const unsigned int)
private

Pointer to functions get_genotype_value_additive() or get_genotype_value_dominance() computing the genotypic value of a trait as function of allele effect.

Referenced by get_genotypic_value(), set_trait_value_noVE(), and setParameters().

◆ _set_trait_value_func_ptr

double(TProtoQuanti::* TProtoQuanti::_set_trait_value_func_ptr) (const TTQuanti *, const unsigned int)
private

Pointer to either set_trait_value_VE() or set_trait_value_noVE() to compute phenotypic values.

Will call function to compute genotype values stored in _set_genotype_func_ptr.

Referenced by get_phenotypic_value(), set_trait_value_func_ptr(), and setParameters().

◆ _sizeofLocusType

◆ _stats

TTQuantiSH* TProtoQuanti::_stats
private

◆ _trait_locus_table

vector< vector<unsigned int> > TProtoQuanti::_trait_locus_table
private

Table storing the locus id of each locus affecting each trait (num trait X (variable length/trait)).

Referenced by get_allele_position(), get_locus_ID(), setMutationModel_var_pleio(), setParameters(), setTraitAndLocusTables_full_pleio(), and setTraitAndLocusTables_no_pleio().

◆ _trait_masks

vector<bitstring> TProtoQuanti::_trait_masks
private

◆ _trait_table

vector< vector<unsigned int> > TProtoQuanti::_trait_table
private

Trait table, (num trait X (variable length/trait)), holds, for each trait, the array position of causative alleles in the sequence.

Referenced by get_allele_position(), get_locus_seq_pos(), get_num_locus(), setDiallelicMutationModel(), setMutationModel_var_pleio(), setMutationSigmaFromQuantiMutationVariance_no_pleio(), setParameters(), setTraitAndLocusTables_full_pleio(), and setTraitAndLocusTables_no_pleio().

◆ _writer

TTQuantiFH* TProtoQuanti::_writer
private

Referenced by loadFileServices(), and ~TProtoQuanti().

◆ _ws


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

Generated for Nemo v2.4.0b by  doxygen 1.9.1 -- Nemo is hosted on  Download Nemo

Locations of visitors to this page
Catalogued on GSR