Skip to content

Commit f11417a

Browse files
committed
trait effect/dominance properties/methods for Mutation and Substitution
1 parent 167ee4a commit f11417a

19 files changed

Lines changed: 969 additions & 42 deletions

QtSLiM/help/SLiMHelpClasses.html

Lines changed: 15 additions & 2 deletions
Large diffs are not rendered by default.

SLiMgui/SLiMHelpClasses.rtf

Lines changed: 144 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4183,10 +4183,11 @@ See also
41834183
\f4\fs20 objects;
41844184
\f3\fs18 NULL
41854185
\f4\fs20 represents all of the traits in the species, in the order in which they were defined.\
4186-
\pard\pardeftab397\li547\ri720\sb60\sa60\partightenfactor0
4187-
\cf2 The parameter
4186+
The parameter
4187+
\f3\fs18 offset
4188+
\f4\fs20 must follow one of four patterns. In the first pattern,
41884189
\f3\fs18 offset
4189-
\f4\fs20 must follow one of four patterns. In the first pattern, offset is
4190+
\f4\fs20 is
41904191
\f3\fs18 NULL
41914192
\f4\fs20 ; this draws the offset for each of the specified traits from each trait\'92s individual-offset distribution (defined by each trait\'92s
41924193
\f3\fs18 individualOffsetMean
@@ -6146,7 +6147,45 @@ If you don\'92t care which subpopulation a mutation originated in, the
61466147
\f1\fs22 methods\
61476148
\pard\pardeftab720\li720\fi-446\ri720\sb180\sa60\partightenfactor0
61486149

6149-
\f3\i0\fs18 \cf2 \'96\'a0(void)setDominanceCoeff(float$\'a0dominanceCoeff)\
6150+
\f3\i0\fs18 \cf2 \'96\'a0(float)dominanceForTrait([Nio<Trait>\'a0trait\'a0=\'a0NULL])\
6151+
\pard\pardeftab720\li547\ri720\sb60\sa60\partightenfactor0
6152+
6153+
\f4\fs20 \cf2 Returns the mutation\'92s dominance coefficient for the trait(s) specified by
6154+
\f3\fs18 trait
6155+
\f4\fs20 ; for both multiplicative traits and additive traits this is the dominance coefficient
6156+
\f1\i h
6157+
\f4\i0 . The traits can be specified as
6158+
\f3\fs18 integer
6159+
\f4\fs20 indices of traits in the species, or directly as
6160+
\f3\fs18 Trait
6161+
\f4\fs20 objects;
6162+
\f3\fs18 NULL
6163+
\f4\fs20 represents all of the traits in the species, in the order in which they were defined. Dominance coefficients for a given target mutation will be returned consecutively in the order in which the traits are specified by
6164+
\f3\fs18 trait
6165+
\f4\fs20 .\
6166+
\pard\pardeftab720\li720\fi-446\ri720\sb180\sa60\partightenfactor0
6167+
6168+
\f3\fs18 \cf2 \'96\'a0(float)effectForTrait([Nio<Trait>\'a0trait\'a0=\'a0NULL])\
6169+
\pard\pardeftab720\li547\ri720\sb60\sa60\partightenfactor0
6170+
6171+
\f4\fs20 \cf2 Returns the mutation\'92s effect size for the trait(s) specified by
6172+
\f3\fs18 trait
6173+
\f4\fs20 ; for multiplicative traits, this is typically the selection coefficient
6174+
\f1\i s
6175+
\f4\i0 , whereas for additive traits it is typically the additive effect size
6176+
\f1\i a
6177+
\f4\i0 . The traits can be specified as
6178+
\f3\fs18 integer
6179+
\f4\fs20 indices of traits in the species, or directly as
6180+
\f3\fs18 Trait
6181+
\f4\fs20 objects;
6182+
\f3\fs18 NULL
6183+
\f4\fs20 represents all of the traits in the species, in the order in which they were defined. Effects for a given target mutation will be returned consecutively in the order in which the traits are specified by
6184+
\f3\fs18 trait
6185+
\f4\fs20 .\
6186+
\pard\pardeftab720\li720\fi-446\ri720\sb180\sa60\partightenfactor0
6187+
6188+
\f3\fs18 \cf2 \'96\'a0(void)setDominanceCoeff(float$\'a0dominanceCoeff)\
61506189
\pard\pardeftab720\li547\ri720\sb60\sa60\partightenfactor0
61516190

61526191
\f4\fs20 \cf2 Set the dominance coefficient of the mutation to
@@ -6161,6 +6200,68 @@ Changing this will normally affect the fitness values calculated toward the end
61616200
\f4\fs20 \'96 but see the documentation of that method for caveats.\
61626201
\pard\pardeftab720\li720\fi-446\ri720\sb180\sa60\partightenfactor0
61636202

6203+
\f3\fs18 \cf2 +\'a0(void)setDominanceForTrait([Nio<Trait>\'a0trait\'a0=\'a0NULL], [Nif\'a0dominance\'a0=\'a0NULL])\
6204+
\pard\pardeftab720\li547\ri720\sb60\sa60\partightenfactor0
6205+
6206+
\f4\fs20 \cf2 Sets the mutation\'92s dominance coefficient(s) for the trait(s) specified by
6207+
\f3\fs18 trait
6208+
\f4\fs20 . The traits can be specified as
6209+
\f3\fs18 integer
6210+
\f4\fs20 indices of traits in the species, or directly as
6211+
\f3\fs18 Trait
6212+
\f4\fs20 objects;
6213+
\f3\fs18 NULL
6214+
\f4\fs20 represents all of the traits in the species, in the order in which they were defined.\
6215+
The parameter
6216+
\f3\fs18 dominance
6217+
\f4\fs20 must follow one of four patterns. In the first pattern,
6218+
\f3\fs18 dominance
6219+
\f4\fs20 is
6220+
\f3\fs18 NULL
6221+
\f4\fs20 ; this sets the dominance for each of the specified traits to the default dominance coefficient from the mutation type of the mutation in each target mutation. (Note that mutation dominance coefficients are automatically set to these defaults when a mutation is created; this re-sets default dominance values.) In the second pattern,
6222+
\f3\fs18 dominance
6223+
\f4\fs20 is a singleton value; this sets the given dominance for each of the specified traits in each target mutation. In the third pattern,
6224+
\f3\fs18 dominance
6225+
\f4\fs20 is of length equal to the number of specified traits; this sets the dominance for each of the specified traits to the corresponding dominance value in each target mutation. In the fourth pattern,
6226+
\f3\fs18 dominance
6227+
\f4\fs20 is of length equal to the number of specified traits times the number of target mutations; this uses
6228+
\f3\fs18 dominance
6229+
\f4\fs20 to provide a different dominance coefficient for each trait in each mutation, using consecutive values from
6230+
\f3\fs18 dominance
6231+
\f4\fs20 to set the dominance for each of the specified traits in one mutation before moving to the next mutation.\
6232+
\pard\pardeftab720\li720\fi-446\ri720\sb180\sa60\partightenfactor0
6233+
6234+
\f3\fs18 \cf2 +\'a0(void)setEffectForTrait([Nio<Trait>\'a0trait\'a0=\'a0NULL], [Nif\'a0effect\'a0=\'a0NULL])\
6235+
\pard\pardeftab720\li547\ri720\sb60\sa60\partightenfactor0
6236+
6237+
\f4\fs20 \cf2 Sets the mutation\'92s effect(s) for the trait(s) specified by
6238+
\f3\fs18 trait
6239+
\f4\fs20 . The traits can be specified as
6240+
\f3\fs18 integer
6241+
\f4\fs20 indices of traits in the species, or directly as
6242+
\f3\fs18 Trait
6243+
\f4\fs20 objects;
6244+
\f3\fs18 NULL
6245+
\f4\fs20 represents all of the traits in the species, in the order in which they were defined.\
6246+
The parameter
6247+
\f3\fs18 effect
6248+
\f4\fs20 must follow one of four patterns. In the first pattern,
6249+
\f3\fs18 effect
6250+
\f4\fs20 is
6251+
\f3\fs18 NULL
6252+
\f4\fs20 ; this draws the effect for each of the specified traits from the corresponding distribution of effect sizes from the mutation type of the mutation in each target mutation. (Note that mutation offsets are automatically drawn from these distributions when a mutation is created; this re-draws new effect values.) In the second pattern,
6253+
\f3\fs18 effect
6254+
\f4\fs20 is a singleton value; this sets the given effect for each of the specified traits in each target mutation. In the third pattern,
6255+
\f3\fs18 effect
6256+
\f4\fs20 is of length equal to the number of specified traits; this sets the effect for each of the specified traits to the corresponding effect value in each target mutation. In the fourth pattern,
6257+
\f3\fs18 effect
6258+
\f4\fs20 is of length equal to the number of specified traits times the number of target mutations; this uses
6259+
\f3\fs18 effect
6260+
\f4\fs20 to provide a different effect value for each trait in each mutation, using consecutive values from
6261+
\f3\fs18 effect
6262+
\f4\fs20 to set the effect for each of the specified traits in one mutation before moving to the next mutation.\
6263+
\pard\pardeftab720\li720\fi-446\ri720\sb180\sa60\partightenfactor0
6264+
61646265
\f3\fs18 \cf2 \'96\'a0(void)setMutationType(io<MutationType>$\'a0mutType)\
61656266
\pard\pardeftab720\li547\ri720\sb60\sa60\partightenfactor0
61666267

@@ -13912,12 +14013,48 @@ nucleotide <\'96> (string$)\
1391214013
\f1\i\fs22 \cf0 5.18.2
1391314014
\f2\fs18 Substitution
1391414015
\f1\fs22 methods\
13915-
\pard\pardeftab397\fi274\ri720\sb40\sa40\partightenfactor0
14016+
\pard\pardeftab720\li720\fi-446\ri720\sb180\sa60\partightenfactor0
1391614017

13917-
\f5\i0 \cf0 \
14018+
\f3\i0\fs18 \cf2 \'96\'a0(float)dominanceForTrait([Nio<Trait>\'a0trait\'a0=\'a0NULL])\
14019+
\pard\pardeftab720\li547\ri720\sb60\sa60\partightenfactor0
14020+
14021+
\f4\fs20 \cf2 Returns the substitution\'92s dominance coefficient for the trait(s) specified by
14022+
\f3\fs18 trait
14023+
\f4\fs20 , carried over from the original mutation object. For both multiplicative traits and additive traits this is the dominance coefficient
14024+
\f1\i h
14025+
\f4\i0 . The traits can be specified as
14026+
\f3\fs18 integer
14027+
\f4\fs20 indices of traits in the species, or directly as
14028+
\f3\fs18 Trait
14029+
\f4\fs20 objects;
14030+
\f3\fs18 NULL
14031+
\f4\fs20 represents all of the traits in the species, in the order in which they were defined. Dominance coefficients for a given target substitution will be returned consecutively in the order in which the traits are specified by
14032+
\f3\fs18 trait
14033+
\f4\fs20 .
14034+
\f5\fs22 \cf0 \
14035+
\pard\pardeftab720\li720\fi-446\ri720\sb180\sa60\partightenfactor0
14036+
14037+
\f3\fs18 \cf2 \'96\'a0(float)effectForTrait([Nio<Trait>\'a0trait\'a0=\'a0NULL])\
14038+
\pard\pardeftab720\li547\ri720\sb60\sa60\partightenfactor0
14039+
14040+
\f4\fs20 \cf2 Returns the substitution\'92s effect size for the trait(s) specified by
14041+
\f3\fs18 trait
14042+
\f4\fs20 , carried over from the original mutation object. For multiplicative traits, this is typically the selection coefficient
14043+
\f1\i s
14044+
\f4\i0 , whereas for additive traits it is typically the additive effect size
14045+
\f1\i a
14046+
\f4\i0 . The traits can be specified as
14047+
\f3\fs18 integer
14048+
\f4\fs20 indices of traits in the species, or directly as
14049+
\f3\fs18 Trait
14050+
\f4\fs20 objects;
14051+
\f3\fs18 NULL
14052+
\f4\fs20 represents all of the traits in the species, in the order in which they were defined. Effects for a given target substitution will be returned consecutively in the order in which the traits are specified by
14053+
\f3\fs18 trait
14054+
\f4\fs20 .\
1391814055
\pard\pardeftab720\ri720\sb360\sa60\partightenfactor0
1391914056

13920-
\f0\b \cf2 5.19 Class Trait\
14057+
\f0\b\fs22 \cf2 5.19 Class Trait\
1392114058
\pard\pardeftab720\ri720\sb120\sa60\partightenfactor0
1392214059

1392314060
\f1\i\b0 \cf2 5.19.1

VERSIONS

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,10 @@ multitrait branch:
6060
shift from a single global mutation block into per-species mutation blocks, and make a new C++ class, MutationBlock, to encapsulate this
6161
this is a forced move because we want the mutation block to have a separate buffer of per-trait state for mutations, and the number of traits varies among species
6262
add effect size and dominance coefficient properties to Mutation and Substitution (but not hooked up to the simulation yet)
63+
add -effectForTrait([Nio<Trait> traits = NULL]) and -dominanceForTrait([Nio<Trait> traits = NULL]) methods to Mutation and Substitution
64+
add +setEffectForTrait([Nio<Trait> traits = NULL], [Nif effect = NULL]) and +setDominanceForTrait([Nio<Trait> traits = NULL], [Nif dominance = NULL]) methods to Mutation
65+
add <trait>Effect and <trait>Dominance properties to Mutation, both read-write float$
66+
add <trait>Effect and <trait>Dominance properties to Substitution, both read-only float$
6367

6468

6569
version 5.1 (Eidos version 4.1):

core/chromosome.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1045,7 +1045,7 @@ MutationIndex Chromosome::DrawNewMutation(std::pair<slim_position_t, GenomicElem
10451045
// A nucleotide value of -1 is always used here; in nucleotide-based models this gets patched later, but that is sequence-dependent and background-dependent
10461046
Mutation *mutation = mutation_block->mutation_buffer_ + new_mut_index;
10471047

1048-
new (mutation) Mutation(mutation_type_ptr, index_, p_position.first, selection_coeff, mutation_type_ptr->effect_distributions_[0].default_dominance_coeff_, p_subpop_index, p_tick, -1); // FIXME MULTITRAIT
1048+
new (mutation) Mutation(mutation_type_ptr, index_, p_position.first, selection_coeff, mutation_type_ptr->DefaultDominanceForTrait(0), p_subpop_index, p_tick, -1); // FIXME MULTITRAIT
10491049

10501050
// addition to the main registry and the muttype registries will happen if the new mutation clears the stacking policy
10511051

@@ -1414,7 +1414,7 @@ MutationIndex Chromosome::DrawNewMutationExtended(std::pair<slim_position_t, Gen
14141414
MutationIndex new_mut_index = mutation_block->NewMutationFromBlock();
14151415
Mutation *mutation = mutation_block->mutation_buffer_ + new_mut_index;
14161416

1417-
new (mutation) Mutation(mutation_type_ptr, index_, position, selection_coeff, mutation_type_ptr->effect_distributions_[0].default_dominance_coeff_, p_subpop_index, p_tick, nucleotide); // FIXME MULTITRAIT
1417+
new (mutation) Mutation(mutation_type_ptr, index_, position, selection_coeff, mutation_type_ptr->DefaultDominanceForTrait(0), p_subpop_index, p_tick, nucleotide); // FIXME MULTITRAIT
14181418

14191419
// Call mutation() callbacks if there are any
14201420
if (p_mutation_callbacks)

core/haplosome.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2907,7 +2907,7 @@ EidosValue_SP Haplosome_Class::ExecuteMethod_addNewMutation(EidosGlobalStringID
29072907

29082908
MutationIndex new_mut_index = mutation_block->NewMutationFromBlock();
29092909

2910-
Mutation *new_mut = new (mut_block_ptr + new_mut_index) Mutation(mutation_type_ptr, chromosome->Index(), position, static_cast<slim_effect_t>(selection_coeff), mutation_type_ptr->effect_distributions_[0].default_dominance_coeff_, origin_subpop_id, origin_tick, (int8_t)nucleotide); // FIXME MULTITRAIT
2910+
Mutation *new_mut = new (mut_block_ptr + new_mut_index) Mutation(mutation_type_ptr, chromosome->Index(), position, static_cast<slim_effect_t>(selection_coeff), mutation_type_ptr->DefaultDominanceForTrait(0), origin_subpop_id, origin_tick, (int8_t)nucleotide); // FIXME MULTITRAIT
29112911

29122912
// This mutation type might not be used by any genomic element type (i.e. might not already be vetted), so we need to check and set pure_neutral_
29132913
// The selection coefficient might have been supplied by the user (i.e., not be from the mutation type's DFE), so we set all_pure_neutral_DFE_ also
@@ -3407,7 +3407,7 @@ EidosValue_SP Haplosome_Class::ExecuteMethod_readHaplosomesFromMS(EidosGlobalStr
34073407

34083408
MutationIndex new_mut_index = mutation_block->NewMutationFromBlock();
34093409

3410-
Mutation *new_mut = new (mut_block_ptr + new_mut_index) Mutation(mutation_type_ptr, chromosome->Index(), position, static_cast<slim_effect_t>(selection_coeff), mutation_type_ptr->effect_distributions_[0].default_dominance_coeff_, subpop_index, origin_tick, nucleotide); // FIXME MULTITRAIT
3410+
Mutation *new_mut = new (mut_block_ptr + new_mut_index) Mutation(mutation_type_ptr, chromosome->Index(), position, static_cast<slim_effect_t>(selection_coeff), mutation_type_ptr->DefaultDominanceForTrait(0), subpop_index, origin_tick, nucleotide); // FIXME MULTITRAIT
34113411

34123412
// This mutation type might not be used by any genomic element type (i.e. might not already be vetted), so we need to check and set pure_neutral_
34133413
if (selection_coeff != 0.0)
@@ -3966,7 +3966,7 @@ EidosValue_SP Haplosome_Class::ExecuteMethod_readHaplosomesFromVCF(EidosGlobalSt
39663966
if (info_domcoeffs.size() > 0)
39673967
dominance_coeff = info_domcoeffs[alt_allele_index];
39683968
else
3969-
dominance_coeff = mutation_type_ptr->effect_distributions_[0].default_dominance_coeff_; // FIXME MULTITRAIT
3969+
dominance_coeff = mutation_type_ptr->DefaultDominanceForTrait(0); // FIXME MULTITRAIT
39703970

39713971
// get the selection coefficient from S, or draw one from the mutation type
39723972
slim_effect_t selection_coeff;

core/individual.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4202,7 +4202,7 @@ const std::vector<EidosMethodSignature_CSP> *Individual_Class::Methods(void) con
42024202
methods->emplace_back((EidosInstanceMethodSignature *)(new EidosInstanceMethodSignature(gStr_relatedness, kEidosValueMaskFloat))->AddObject("individuals", gSLiM_Individual_Class)->AddArgWithDefault(kEidosValueMaskNULL | kEidosValueMaskInt | kEidosValueMaskString | kEidosValueMaskObject | kEidosValueMaskOptional | kEidosValueMaskSingleton, "chromosome", gSLiM_Chromosome_Class, gStaticEidosValueNULL));
42034203
methods->emplace_back((EidosInstanceMethodSignature *)(new EidosInstanceMethodSignature(gStr_haplosomesForChromosomes, kEidosValueMaskObject, gSLiM_Haplosome_Class))->AddArgWithDefault(kEidosValueMaskNULL | kEidosValueMaskInt | kEidosValueMaskString | kEidosValueMaskObject | kEidosValueMaskOptional, "chromosomes", gSLiM_Chromosome_Class, gStaticEidosValueNULL)->AddInt_OSN("index", gStaticEidosValueNULL)->AddLogical_OS("includeNulls", gStaticEidosValue_LogicalT));
42044204
methods->emplace_back((EidosInstanceMethodSignature *)(new EidosInstanceMethodSignature(gStr_offsetForTrait, kEidosValueMaskFloat))->AddIntObject_ON("trait", gSLiM_Trait_Class, gStaticEidosValueNULL));
4205-
methods->emplace_back((EidosInstanceMethodSignature *)(new EidosClassMethodSignature(gStr_setOffsetForTrait, kEidosValueMaskVOID))->AddIntObject_ON("trait", gSLiM_Trait_Class, gStaticEidosValueNULL)->AddNumeric_ON("offset", gStaticEidosValueNULL));
4205+
methods->emplace_back((EidosClassMethodSignature *)(new EidosClassMethodSignature(gStr_setOffsetForTrait, kEidosValueMaskVOID))->AddIntObject_ON("trait", gSLiM_Trait_Class, gStaticEidosValueNULL)->AddNumeric_ON("offset", gStaticEidosValueNULL));
42064206
methods->emplace_back((EidosInstanceMethodSignature *)(new EidosInstanceMethodSignature(gStr_sharedParentCount, kEidosValueMaskInt))->AddObject("individuals", gSLiM_Individual_Class));
42074207
methods->emplace_back(((EidosInstanceMethodSignature *)(new EidosInstanceMethodSignature(gStr_sumOfMutationsOfType, kEidosValueMaskFloat | kEidosValueMaskSingleton))->AddIntObject_S("mutType", gSLiM_MutationType_Class))->DeclareAcceleratedImp(Individual::ExecuteMethod_Accelerated_sumOfMutationsOfType));
42084208
methods->emplace_back((EidosInstanceMethodSignature *)(new EidosInstanceMethodSignature(gStr_uniqueMutationsOfType, kEidosValueMaskObject, gSLiM_Mutation_Class))->AddIntObject_S("mutType", gSLiM_MutationType_Class)->MarkDeprecated());
@@ -4264,7 +4264,7 @@ EidosValue_SP Individual_Class::ExecuteMethod_setOffsetForTrait(EidosGlobalStrin
42644264

42654265
// get the trait indices, with bounds-checking
42664266
std::vector<int64_t> trait_indices;
4267-
species->GetTraitIndicesFromEidosValue(trait_indices, trait_value, "offsetForTrait");
4267+
species->GetTraitIndicesFromEidosValue(trait_indices, trait_value, "setOffsetForTrait");
42684268
int trait_count = (int)trait_indices.size();
42694269

42704270
if (offset_value->Type() == EidosValueType::kValueNULL)
@@ -5013,7 +5013,7 @@ EidosValue_SP Individual_Class::ExecuteMethod_readIndividualsFromVCF(EidosGlobal
50135013
if (info_domcoeffs.size() > 0)
50145014
dominance_coeff = info_domcoeffs[alt_allele_index];
50155015
else
5016-
dominance_coeff = mutation_type_ptr->effect_distributions_[0].default_dominance_coeff_; // FIXME MULTITRAIT
5016+
dominance_coeff = static_cast<slim_effect_t>(mutation_type_ptr->DefaultDominanceForTrait(0)); // FIXME MULTITRAIT
50175017

50185018
// get the selection coefficient from S, or draw one from the mutation type
50195019
slim_effect_t selection_coeff;

0 commit comments

Comments
 (0)