Skip to content

Commit 35c511b

Browse files
committed
add dominanceCoeff to Mutation, and related work
1 parent a494c45 commit 35c511b

22 files changed

Lines changed: 293 additions & 160 deletions

QtSLiM/QtSLiMTablesDrawer.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -552,7 +552,7 @@ QVariant QtSLiMMutTypeTableModel::data(const QModelIndex &p_index, int role) con
552552
}
553553
else if (p_index.column() == 1)
554554
{
555-
return QVariant(QString("%1").arg(static_cast<double>(mutationType->dominance_coeff_), 0, 'f', 3));
555+
return QVariant(QString("%1").arg(static_cast<double>(mutationType->default_dominance_coeff_), 0, 'f', 3));
556556
}
557557
else if (p_index.column() == 2)
558558
{

QtSLiM/help/SLiMHelpClasses.html

Lines changed: 38 additions & 32 deletions
Large diffs are not rendered by default.

SLiMgui/SLiMHelpClasses.rtf

Lines changed: 93 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -5900,6 +5900,41 @@ You can get the
59005900
\f4\fs20 object with which the mutation is associated.\
59015901
\pard\pardeftab720\li720\fi-446\ri720\sb180\sa60\partightenfactor0
59025902

5903+
\f3\fs18 \cf2 dominanceCoeff => (float$)\
5904+
\pard\pardeftab720\li547\ri720\sb60\sa60\partightenfactor0
5905+
5906+
\f4\fs20 \cf2 The dominance coefficient of the mutation, taken from the default dominance coefficient of its
5907+
\f3\fs18 MutationType
5908+
\f4\fs20 . If a mutation has a
5909+
\f3\fs18 selectionCoeff
5910+
\f4\fs20 of
5911+
\f1\i s
5912+
\f4\i0 and a
5913+
\f3\fs18 dominanceCoeff
5914+
\f4\fs20 of
5915+
\f1\i h
5916+
\f4\i0 , the multiplicative fitness effect of the mutation in a homozygote is 1+
5917+
\f1\i s
5918+
\f4\i0 , and in a heterozygote is 1+
5919+
\f1\i hs
5920+
\f4\i0 . The dominance coefficient of a mutation can be changed with the
5921+
\f3\fs18 setDominanceCoeff()
5922+
\f4\fs20 method.\
5923+
Note that this property has a quirk: it is stored internally in SLiM using a single-precision float, not the double-precision float type normally used by Eidos. This means that if you set a mutation
5924+
\f3\fs18 mut
5925+
\f4\fs20 \'92s dominance coefficient to some number
5926+
\f3\fs18 x
5927+
\f4\fs20 ,
5928+
\f3\fs18 mut.dominanceCoeff==x
5929+
\f4\fs20 may be
5930+
\f3\fs18 F
5931+
\f4\fs20 due to floating-point rounding error. Comparisons of floating-point numbers for exact equality is often a bad idea, but this is one case where it may fail unexpectedly. Instead, it is recommended to use the
5932+
\f3\fs18 id
5933+
\f4\fs20 or
5934+
\f3\fs18 tag
5935+
\f4\fs20 properties to identify particular mutations.\
5936+
\pard\pardeftab720\li720\fi-446\ri720\sb180\sa60\partightenfactor0
5937+
59035938
\f3\fs18 \cf0 id => (integer$)\
59045939
\pard\pardeftab720\li547\ri720\sb60\sa60\partightenfactor0
59055940

@@ -5993,27 +6028,27 @@ nucleotide <\'96> (string$)\
59936028
\f5 \
59946029
\pard\pardeftab720\li720\fi-446\ri720\sb180\sa60\partightenfactor0
59956030

5996-
\f3\fs18 \cf0 selectionCoeff => (float$)\
6031+
\f3\fs18 \cf2 selectionCoeff => (float$)\
59976032
\pard\pardeftab720\li547\ri720\sb60\sa60\partightenfactor0
59986033

5999-
\f4\fs20 \cf0 The selection coefficient of the mutation, drawn from the distribution of fitness effects of its
6034+
\f4\fs20 \cf2 The selection coefficient of the mutation, drawn from the distribution of fitness effects of its
60006035
\f3\fs18 MutationType
6001-
\f5\fs20 .
6002-
\f4 \cf2 \expnd0\expndtw0\kerning0
6003-
If a mutation has a
6036+
\f4\fs20 . If a mutation has a
60046037
\f3\fs18 selectionCoeff
60056038
\f4\fs20 of
60066039
\f1\i s
6040+
\f4\i0 and a
6041+
\f3\fs18 dominanceCoeff
6042+
\f4\fs20 of
6043+
\f1\i h
60076044
\f4\i0 , the multiplicative fitness effect of the mutation in a homozygote is 1+
60086045
\f1\i s
6009-
\f4\i0 ; in a heterozygote it is 1+
6046+
\f4\i0 , and in a heterozygote is 1+
60106047
\f1\i hs
6011-
\f4\i0 , where
6012-
\f1\i h
6013-
\f4\i0 is the dominance coefficient kept by the mutation type.
6014-
\f5 \cf0 \kerning1\expnd0\expndtw0 \
6015-
6016-
\f4 Note that this property has a quirk: it is stored internally in SLiM using a single-precision float, not the double-precision float type normally used by Eidos. This means that if you set a mutation
6048+
\f4\i0 . The selection coefficient of a mutation can be changed with the
6049+
\f3\fs18 setSelectionCoeff()
6050+
\f4\fs20 method.\
6051+
Note that this property has a quirk: it is stored internally in SLiM using a single-precision float, not the double-precision float type normally used by Eidos. This means that if you set a mutation
60176052
\f3\fs18 mut
60186053
\f4\fs20 \'92s selection coefficient to some number
60196054
\f3\fs18 x
@@ -6025,8 +6060,7 @@ nucleotide <\'96> (string$)\
60256060
\f3\fs18 id
60266061
\f4\fs20 or
60276062
\f3\fs18 tag
6028-
\f4\fs20 properties to identify particular mutations.
6029-
\f5 \
6063+
\f4\fs20 properties to identify particular mutations.\
60306064
\pard\pardeftab720\li720\fi-446\ri720\sb180\sa60\partightenfactor0
60316065

60326066
\f3\fs18 \cf0 subpopID <\'96> (integer$)\
@@ -6064,39 +6098,52 @@ If you don\'92t care which subpopulation a mutation originated in, the
60646098
\f1\fs22 methods\
60656099
\pard\pardeftab720\li720\fi-446\ri720\sb180\sa60\partightenfactor0
60666100

6067-
\f3\i0\fs18 \cf0 \'96\'a0(void)setMutationType(io<MutationType>$\'a0mutType)
6101+
\f3\i0\fs18 \cf2 \'96\'a0(void)setDominanceCoeff(float$\'a0dominanceCoeff)\
6102+
\pard\pardeftab720\li547\ri720\sb60\sa60\partightenfactor0
6103+
6104+
\f4\fs20 \cf2 Set the dominance coefficient of the mutation to
6105+
\f3\fs18 dominanceCoeff
6106+
\f4\fs20 . The dominance coefficient will be changed for all individuals that possess the mutation, since they all share a single
6107+
\f3\fs18 Mutation
6108+
\f4\fs20 object (note that the selection coefficient will remain unchanged).\
6109+
Changing this will normally affect the fitness values calculated toward the end of the current tick; if you want current fitness values to be affected, you can call the
6110+
\f3\fs18 Species
6111+
\f4\fs20 method
6112+
\f3\fs18 recalculateFitness()
6113+
\f4\fs20 \'96 but see the documentation of that method for caveats.\
6114+
\pard\pardeftab720\li720\fi-446\ri720\sb180\sa60\partightenfactor0
6115+
6116+
\f3\fs18 \cf0 \'96\'a0(void)setMutationType(io<MutationType>$\'a0mutType)
60686117
\f5 \
60696118
\pard\pardeftab720\li547\ri720\sb60\sa60\partightenfactor0
60706119

6071-
\f4\fs20 \cf0 Set the mutation type of the mutation to
6120+
\f4\fs20 \cf2 Set the mutation type of the mutation to
60726121
\f3\fs18 mutType
60736122
\f4\fs20 (which may be specified as either an
60746123
\f3\fs18 integer
60756124
\f4\fs20 identifier or a
60766125
\f3\fs18 MutationType
6077-
\f4\fs20 object). This implicitly changes the dominance coefficient of the mutation to that of the new mutation type, since the dominance coefficient is a property of the mutation type. On the other hand, the selection coefficient of the mutation is not changed, since it is a property of the mutation object itself; it can be changed explicitly using the
6126+
\f4\fs20 object). The selection coefficients and dominance coefficients of existing mutations are not changed, since they are properties of the mutation objects themselves; they can be changed explicitly using the
60786127
\f3\fs18 setSelectionCoeff()
6079-
\f4\fs20 method if so desired.\
6080-
The mutation type of a mutation is normally a constant in simulations, so be sure you know what you are doing. Changing this will normally affect the fitness values calculated toward the end of the current tick; if you want current fitness values to be affected, you can call the
6081-
\f3\fs18 Species
6082-
\f4\fs20 method
6083-
\f3\fs18 recalculateFitness()
6084-
\f4\fs20 \'96 but see the documentation of that method for caveats.\
6128+
\f4\fs20 and
6129+
\f3\fs18 setDominanceCoeff()
6130+
\f4\fs20 methods of
6131+
\f3\fs18 Mutation
6132+
\f4\fs20 if so desired.\
60856133
\pard\pardeftab720\li547\ri720\sb60\sa60\partightenfactor0
60866134
\cf2 \expnd0\expndtw0\kerning0
60876135
In nucleotide-based models, a restriction applies: nucleotide-based mutations may not be changed to a non-nucleotide-based mutation type, and non-nucleotide-based mutations may not be changed to a nucleotide-based mutation type.\
60886136
\pard\pardeftab720\li720\fi-446\ri720\sb180\sa60\partightenfactor0
60896137

6090-
\f3\fs18 \cf0 \kerning1\expnd0\expndtw0 \'96\'a0(void)setSelectionCoeff(float$\'a0selectionCoeff)
6091-
\f5 \
6138+
\f3\fs18 \cf2 \kerning1\expnd0\expndtw0 \'96\'a0(void)setSelectionCoeff(float$\'a0selectionCoeff)\
60926139
\pard\pardeftab720\li547\ri720\sb60\sa60\partightenfactor0
60936140

6094-
\f4\fs20 \cf0 Set the selection coefficient of the mutation to
6141+
\f4\fs20 \cf2 Set the selection coefficient of the mutation to
60956142
\f3\fs18 selectionCoeff
60966143
\f4\fs20 . The selection coefficient will be changed for all individuals that possess the mutation, since they all share a single
60976144
\f3\fs18 Mutation
6098-
\f4\fs20 object (note that the dominance coefficient will remain unchanged, as it is determined by the mutation type).\
6099-
This is normally a constant in simulations, so be sure you know what you are doing; often setting up a
6145+
\f4\fs20 object (note that the dominance coefficient will remain unchanged).\
6146+
Often setting up a
61006147
\f3\fs18 mutationEffect()
61016148
\f4\fs20 callback is preferable, in order to modify the selection coefficient in a more limited and controlled fashion. Changing this will normally affect the fitness values calculated toward the end of the current tick; if you want current fitness values to be affected, you can call the
61026149
\f3\fs18 Species
@@ -6394,14 +6441,16 @@ Note that these distributions can in principle produce selection coefficients sm
63946441
\fs20 \
63956442
\pard\pardeftab720\li720\fi-446\ri720\sb180\sa60\partightenfactor0
63966443

6397-
\f3\fs18 \cf0 dominanceCoeff <\'96> (float$)\
6398-
\pard\pardeftab720\li547\ri720\sb60\sa60\partightenfactor0
6444+
\f3\fs18 \cf2 dominanceCoeff <\'96> (float$)\
6445+
\pard\pardeftab397\li547\ri720\sb60\sa60\partightenfactor0
63996446

6400-
\f4\fs20 \cf0 The dominance coefficient used for mutations of this type when heterozygous. Changing this will normally affect the fitness values calculated toward the end of the current tick; if you want current fitness values to be affected, you can call the
6401-
\f3\fs18 Species
6447+
\f4\fs20 \cf2 The default dominance coefficient used for mutations of this type when heterozygous. This default value is taken by new mutations of this mutation type when they are created, as the value of their
6448+
\f3\fs18 dominanceCoeff
6449+
\f4\fs20 property, but that can be changed later with the
6450+
\f3\fs18 Mutation
64026451
\f4\fs20 method
6403-
\f3\fs18 recalculateFitness()
6404-
\f4\fs20 \'96 but see the documentation of that method for caveats.\
6452+
\f3\fs18 setDominanceCoeff()
6453+
\f4\fs20 .\
64056454
Note that the dominance coefficient is not bounded. A dominance coefficient greater than
64066455
\f3\fs18 1.0
64076456
\f4\fs20 may be used to achieve an overdominance effect. By making the selection coefficient very small and the dominance coefficient very large, an overdominance scenario in which both homozygotes have the same fitness may be approximated, to a nearly arbitrary degree of precision.\
@@ -6417,8 +6466,7 @@ Note that this property has a quirk: it is stored internally in SLiM using a sin
64176466
\f3\fs18 id
64186467
\f4\fs20 or
64196468
\f3\fs18 tag
6420-
\f4\fs20 properties to identify particular mutation types.
6421-
\f5 \
6469+
\f4\fs20 properties to identify particular mutation types.\
64226470
\pard\pardeftab720\li720\fi-446\ri720\sb180\sa60\partightenfactor0
64236471

64246472
\f3\fs18 \cf2 hemizygousDominanceCoeff <\'96> (float$)\
@@ -6428,7 +6476,7 @@ Note that this property has a quirk: it is stored internally in SLiM using a sin
64286476
\f3\fs18 1.0
64296477
\f4\fs20 , and is used only in models where null haplosomes are present; the
64306478
\f3\fs18 dominanceCoeff
6431-
\f4\fs20 property is the dominance coefficient used in most circumstances. Changing this will normally affect the fitness values calculated toward the end of the current tick; if you want current fitness values to be affected, you can call the
6479+
\f4\fs20 property of the mutation is the dominance coefficient used in most circumstances. Changing this will normally affect the fitness values calculated toward the end of the current tick; if you want current fitness values to be affected, you can call the
64326480
\f3\fs18 Species
64336481
\f4\fs20 method
64346482
\f3\fs18 recalculateFitness()
@@ -13288,6 +13336,12 @@ Note that this method is only for use in nonWF models, in which migration is man
1328813336
\f4\fs20 object with which the mutation is associated.\
1328913337
\pard\pardeftab720\li720\fi-446\ri720\sb180\sa60\partightenfactor0
1329013338

13339+
\f3\fs18 \cf2 dominanceCoeff => (float$)\
13340+
\pard\pardeftab720\li547\ri720\sb60\sa60\partightenfactor0
13341+
13342+
\f4\fs20 \cf2 The dominance coefficient of the mutation, carried over from the original mutation object.\
13343+
\pard\pardeftab720\li720\fi-446\ri720\sb180\sa60\partightenfactor0
13344+
1329113345
\f3\fs18 \cf0 id => (integer$)\
1329213346
\pard\pardeftab720\li547\ri720\sb60\sa60\partightenfactor0
1329313347

@@ -13360,12 +13414,10 @@ nucleotide <\'96> (string$)\
1336013414
\f5 \
1336113415
\pard\pardeftab720\li720\fi-446\ri720\sb180\sa60\partightenfactor0
1336213416

13363-
\f3\fs18 \cf0 selectionCoeff => (float$)\
13417+
\f3\fs18 \cf2 selectionCoeff => (float$)\
1336413418
\pard\pardeftab720\li547\ri720\sb60\sa60\partightenfactor0
1336513419

13366-
\f4\fs20 \cf0 The selection coefficient of the mutation, drawn from the distribution of fitness effects of its
13367-
\f3\fs18 MutationType
13368-
\f5\fs20 .\
13420+
\f4\fs20 \cf2 The selection coefficient of the mutation, carried over from the original mutation object.\
1336913421
\pard\pardeftab720\li720\fi-446\ri720\sb180\sa60\partightenfactor0
1337013422

1337113423
\f3\fs18 \cf0 subpopID <\'96> (integer$)\

SLiMgui/SLiMWindowController.mm

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4419,7 +4419,7 @@ - (id)tableView:(NSTableView *)aTableView objectValueForTableColumn:(NSTableColu
44194419
}
44204420
else if (aTableColumn == mutTypeDominanceColumn)
44214421
{
4422-
return [NSString stringWithFormat:@"%.3f", mutationType->dominance_coeff_];
4422+
return [NSString stringWithFormat:@"%.3f", mutationType->default_dominance_coeff_];
44234423
}
44244424
else if (aTableColumn == mutTypeDFETypeColumn)
44254425
{

VERSIONS

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,9 @@ multitrait branch:
3232
tag <-> (integer$)
3333
type => (string$)
3434
add Community property allTraits => (object<Trait>)
35+
add a dominanceCoeff property to Mutation, with a value inherited from MutationType's property (which is now just the default value)
36+
add dominanceCoeff properties to Mutation and Substitution
37+
add a setDominanceCoeff() method to Mutation, yay!
3538

3639

3740
version 5.0 (Eidos version 4.0):

core/chromosome.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1035,15 +1035,15 @@ MutationIndex Chromosome::DrawNewMutation(std::pair<slim_position_t, GenomicElem
10351035
const GenomicElementType &genomic_element_type = *(source_element.genomic_element_type_ptr_);
10361036
MutationType *mutation_type_ptr = genomic_element_type.DrawMutationType();
10371037

1038-
double selection_coeff = mutation_type_ptr->DrawSelectionCoefficient();
1038+
slim_selcoeff_t selection_coeff = static_cast<slim_selcoeff_t>(mutation_type_ptr->DrawSelectionCoefficient());
10391039

10401040
// NOTE THAT THE STACKING POLICY IS NOT ENFORCED HERE, SINCE WE DO NOT KNOW WHAT HAPLOSOME WE WILL BE INSERTED INTO! THIS IS THE CALLER'S RESPONSIBILITY!
10411041
MutationIndex new_mut_index = SLiM_NewMutationFromBlock();
10421042

10431043
// 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
10441044
Mutation *mutation = gSLiM_Mutation_Block + new_mut_index;
10451045

1046-
new (mutation) Mutation(mutation_type_ptr, index_, p_position.first, selection_coeff, p_subpop_index, p_tick, -1);
1046+
new (mutation) Mutation(mutation_type_ptr, index_, p_position.first, selection_coeff, mutation_type_ptr->default_dominance_coeff_, p_subpop_index, p_tick, -1);
10471047

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

@@ -1401,13 +1401,13 @@ MutationIndex Chromosome::DrawNewMutationExtended(std::pair<slim_position_t, Gen
14011401
// Draw mutation type and selection coefficient, and create the new mutation
14021402
MutationType *mutation_type_ptr = genomic_element_type.DrawMutationType();
14031403

1404-
double selection_coeff = mutation_type_ptr->DrawSelectionCoefficient();
1404+
slim_selcoeff_t selection_coeff = static_cast<slim_selcoeff_t>(mutation_type_ptr->DrawSelectionCoefficient());
14051405

14061406
// NOTE THAT THE STACKING POLICY IS NOT ENFORCED HERE! THIS IS THE CALLER'S RESPONSIBILITY!
14071407
MutationIndex new_mut_index = SLiM_NewMutationFromBlock();
14081408
Mutation *mutation = gSLiM_Mutation_Block + new_mut_index;
14091409

1410-
new (mutation) Mutation(mutation_type_ptr, index_, position, selection_coeff, p_subpop_index, p_tick, nucleotide);
1410+
new (mutation) Mutation(mutation_type_ptr, index_, position, selection_coeff, mutation_type_ptr->default_dominance_coeff_, p_subpop_index, p_tick, nucleotide);
14111411

14121412
// Call mutation() callbacks if there are any
14131413
if (p_mutation_callbacks)

core/core.pro

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,8 @@ SOURCES += \
112112
species.cpp \
113113
species_eidos.cpp \
114114
subpopulation.cpp \
115-
substitution.cpp
115+
substitution.cpp \
116+
trait.cpp
116117

117118
HEADERS += \
118119
chromosome.h \
@@ -137,4 +138,5 @@ HEADERS += \
137138
spatial_map.h \
138139
species.h \
139140
subpopulation.h \
140-
substitution.h
141+
substitution.h \
142+
trait.h

0 commit comments

Comments
 (0)