Skip to content

Commit a0df764

Browse files
committed
change initializeMutationType[Nuc]() to have [Ns$ distributionType = NULL]
1 parent 90beaed commit a0df764

File tree

6 files changed

+60
-21
lines changed

6 files changed

+60
-21
lines changed

QtSLiM/help/SLiMHelpFunctions.html

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -103,12 +103,12 @@
103103
<p class="p3">Set a mutation rate map from data read from the file at <span class="s3">path</span>.<span class="Apple-converted-space">  </span>This function is essentially a wrapper for <span class="s3">initializeMutationRate()</span> that uses <span class="s3">readCSV()</span> and passes the data through.<span class="Apple-converted-space">  </span>The file is expected to contain two columns of data.<span class="Apple-converted-space">  </span>The first column must be <span class="s3">integer</span> start positions for rate map regions; the first region should start at position <span class="s3">0</span> if the map’s positions are <span class="s3">0</span>-based, or at position <span class="s3">1</span> if the map’s positions are <span class="s3">1</span>-based; in the latter case, <span class="s3">1</span> will be subtracted from every position since SLiM uses <span class="s3">0</span>-based positions.<span class="Apple-converted-space">  </span>The second column must be <span class="s3">float</span> rates, relative to the scaling factor specified in <span class="s3">scale</span>; for example, if a given rate is <span class="s3">1.2</span> and <span class="s3">scale</span> is <span class="s3">1e-8</span> (the default), the rate used will be <span class="s3">1.2e-8</span>.<span class="Apple-converted-space">  </span>No column header line should be present; the file should start immediately with numerical data.<span class="Apple-converted-space">  </span>The expected separator between columns is a tab character by default, but may be passed in <span class="s3">sep</span>; the expected decimal separator is a period by default, but may be passed in <span class="s3">dec</span>.<span class="Apple-converted-space">  </span>Once read, the map is converted into a rate map specified with end positions, rather than start positions, and the position given by <span class="s3">lastPosition</span> is used as the end of the last rate region; it should be the last position of the chromosome.</p>
104104
<p class="p3">See <span class="s3">readCSV()</span> for further details on <span class="s3">sep</span> and <span class="s3">dec</span>, which are passed through to it; and see <span class="s3">initializeMutationRate()</span> for details on how the rate map is validated and used, and how the <span class="s3">sex</span> parameter is used.</p>
105105
<p class="p3">This function is written in Eidos, and its source code can be viewed with <span class="s3">functionSource()</span>, so you can copy and modify its code if you need to modify its functionality.</p>
106-
<p class="p2">(object&lt;MutationType&gt;$)initializeMutationType(is$ id, numeric$ dominanceCoeff, string$ distributionType, ...)</p>
106+
<p class="p2">(object&lt;MutationType&gt;$)initializeMutationType(is$ id, numeric$ dominanceCoeff, <span class="s8">[Ns$ distributionType = NULL]</span>, ...)</p>
107107
<p class="p3">Add a mutation type at initialization time.<span class="Apple-converted-space">  </span>The <span class="s3">id</span> must not already be used for any mutation type in the simulation.<span class="Apple-converted-space">  </span>The <span class="s3">id</span> parameter may be either an <span class="s3">integer</span> giving the ID of the new mutation type, or a <span class="s3">string</span> giving the name of the new mutation type (such as <span class="s3">"m5"</span> to specify an ID of 5).<span class="Apple-converted-space">  </span>The global symbol for the new mutation type, such as <span class="s3">m5</span>, is immediately available; the return value also provides the new object.</p>
108-
<p class="p3">The <span class="s3">dominanceCoeff</span> parameter supplies the default dominance coefficient for the mutation type, for all traits; <span class="s3">0.0</span> produces no dominance, <span class="s3">1.0</span> complete dominance, and values greater than <span class="s3">1.0</span>, overdominance.<span class="Apple-converted-space">  </span>The default dominance coefficient for the mutation type for a specific trait can subsequently be configured with the <span class="s3">setDefaultDominanceForTrait()</span> method if desired.<span class="Apple-converted-space">  </span>Note that the mutation type’s default hemizygous dominance coefficient is not supplied to this function; it always defaults to <span class="s3">1.0</span>, but can subsequently be configured with the <span class="s3">setDefaultHemizygousDominanceForTrait()</span> method if desired.</p>
109-
<p class="p3">The <span class="s3">distributionType</span> and the ellipsis parameters together define the distribution of effect size (DES) for the mutation type, for all traits.<span class="Apple-converted-space">  </span>The DES for the mutation type for a specific trait can subsequently be separately configured with the <span class="s3">setEffectDistributionForTrait()</span> method if desired.<span class="Apple-converted-space">  </span>The <span class="s3">distributionType</span> parameter may be <span class="s3">"f"</span>, in which case the ellipsis <span class="s3">...</span> should supply a <span class="s3">numeric$</span> fixed selection coefficient; <span class="s3">"e"</span>, in which case the ellipsis should supply a <span class="s3">numeric$</span> mean selection coefficient for an exponential distribution; <span class="s3">"g"</span>, in which case the ellipsis should supply a <span class="s3">numeric$</span> mean selection coefficient and a <span class="s3">numeric$</span> alpha shape parameter for a gamma distribution; <span class="s3">"n"</span>, in which case the ellipsis should supply a <span class="s3">numeric$</span> mean selection coefficient and a <span class="s3">numeric$</span> sigma (standard deviation) parameter for a normal distribution; <span class="s3">"p"</span>, in which case the ellipsis should supply a <span class="s3">numeric$</span> mean selection coefficient and a <span class="s3">numeric$</span> scale parameter for a Laplace distribution; <span class="s3">"w"</span>, in which case the ellipsis should supply a <span class="s3">numeric$</span> <span class="s7">λ</span> scale parameter and a <span class="s3">numeric$</span> k shape parameter for a Weibull distribution; or <span class="s3">"s"</span>, in which case the ellipsis should supply a <span class="s3">string$</span> Eidos script parameter.<span class="Apple-converted-space">  </span>See the <span class="s3">MutationType</span> class documentation for discussion of the various DESs and their uses.</p>
108+
<p class="p3">The <span class="s3">dominanceCoeff</span> parameter supplies the default dominance coefficient for the mutation type, for all traits; <span class="s3">0.0</span> produces no dominance, <span class="s3">1.0</span> complete dominance, and values greater than <span class="s3">1.0</span>, overdominance.<span class="Apple-converted-space">  </span>The default dominance coefficient for the mutation type for a specific trait can subsequently be configured with the <span class="s3">setDefaultDominanceForTrait()</span> method if desired.<span class="Apple-converted-space">  </span>Note that the mutation type’s default hemizygous dominance coefficient is not supplied to this function; it always defaults to <span class="s3">1.0</span>, but the <span class="s3">setDefaultHemizygousDominanceForTrait()</span> method can configure it subsequently if desired.</p>
109+
<p class="p3">The <span class="s3">distributionType</span> and the ellipsis parameters together define the distribution of effect size (DES) for the mutation type, for all traits.<span class="Apple-converted-space">  </span>The DES for the mutation type for a specific trait can subsequently be separately configured with the <span class="s3">setEffectDistributionForTrait()</span> method if desired.<span class="Apple-converted-space">  </span>The <span class="s3">distributionType</span> parameter may be <span class="s3">"f"</span>, in which case the ellipsis <span class="s3">...</span> should supply a <span class="s3">numeric$</span> fixed selection coefficient; <span class="s3">"e"</span>, in which case the ellipsis should supply a <span class="s3">numeric$</span> mean selection coefficient for an exponential distribution; <span class="s3">"g"</span>, in which case the ellipsis should supply a <span class="s3">numeric$</span> mean selection coefficient and a <span class="s3">numeric$</span> alpha shape parameter for a gamma distribution; <span class="s3">"n"</span>, in which case the ellipsis should supply a <span class="s3">numeric$</span> mean selection coefficient and a <span class="s3">numeric$</span> sigma (standard deviation) parameter for a normal distribution; <span class="s3">"p"</span>, in which case the ellipsis should supply a <span class="s3">numeric$</span> mean selection coefficient and a <span class="s3">numeric$</span> scale parameter for a Laplace distribution; <span class="s3">"w"</span>, in which case the ellipsis should supply a <span class="s3">numeric$</span> <span class="s7">λ</span> scale parameter and a <span class="s3">numeric$</span> k shape parameter for a Weibull distribution; or <span class="s3">"s"</span>, in which case the ellipsis should supply a <span class="s3">string$</span> Eidos script parameter.<span class="Apple-converted-space">  </span>If <span class="s3">distributionType</span> is <span class="s3">NULL</span> (the default), a fixed effect of <span class="s3">0.0</span> is used, representing a neutral DES; this is equivalent to type <span class="s3">"f"</span> except that the value <span class="s3">0.0</span> is assumed and must not be supplied.<span class="Apple-converted-space">  </span>See the <span class="s3">MutationType</span> class documentation for discussion of the various DESs and their uses.</p>
110110
<p class="p3"><span class="s1">Note that by default in WF models, all mutations of a given mutation type will be converted into </span><span class="s2">Substitution</span><span class="s1"> objects when they reach fixation, for efficiency reasons.<span class="Apple-converted-space">  </span>If you need to disable this conversion, to keep mutations of a given type active in the simulation even after they have fixed, you can do so by setting the </span><span class="s2">convertToSubstitution</span><span class="s1"> property of </span><span class="s2">MutationType</span><span class="s1"> to </span><span class="s2">F</span><span class="s1">.<span class="Apple-converted-space">  </span>In contrast, by default in nonWF models mutations will not be converted into </span><span class="s2">Substitution</span><span class="s1"> objects when they reach fixation; </span><span class="s2">convertToSubstitution</span><span class="s1"> is </span><span class="s2">F</span><span class="s1"> by default in nonWF models.<span class="Apple-converted-space">  </span>To enable conversion in nonWF models for neutral mutation types with no indirect fitness effects, you should therefore set </span><span class="s2">convertToSubstitution</span><span class="s1"> to </span><span class="s2">T</span><span class="s1">.</span></p>
111-
<p class="p4"><span class="s1">(object&lt;MutationType&gt;$)initializeMutationTypeNuc(is$ id, numeric$ dominanceCoeff, string$ distributionType, ...)</span></p>
111+
<p class="p4"><span class="s1">(object&lt;MutationType&gt;$)initializeMutationTypeNuc(is$ id, numeric$ dominanceCoeff, </span>[Ns$ distributionType = NULL]<span class="s1">, ...)</span></p>
112112
<p class="p3"><span class="s1">Add a nucleotide-based mutation type at initialization time.<span class="Apple-converted-space">  </span>This function is identical to </span><span class="s2">initializeMutationType()</span><span class="s1"> except that the new mutation type will be nucleotide-based – in other words, mutations belonging to the new mutation type will have an associated nucleotide.<span class="Apple-converted-space">  </span>This function may be called only in nucleotide-based models (as enabled by the </span><span class="s2">nucleotideBased</span><span class="s1"> parameter to </span><span class="s2">initializeSLiMOptions()</span><span class="s1">).</span></p>
113113
<p class="p3"><span class="s1">Nucleotide-based mutations always use a </span><span class="s2">mutationStackGroup</span><span class="s1"> of </span><span class="s2">-1</span><span class="s1"> and a </span><span class="s2">mutationStackPolicy</span><span class="s1"> of </span><span class="s2">"l"</span><span class="s1">.<span class="Apple-converted-space">  </span>This ensures that a new nucleotide mutation always replaces any previously existing nucleotide mutation at a given position, regardless of the mutation types of the nucleotide mutations.<span class="Apple-converted-space">  </span>These values are set automatically by </span><span class="s2">initializeMutationTypeNuc()</span><span class="s1">, and may not be changed.</span></p>
114114
<p class="p3"><span class="s1">See the documentation for </span><span class="s2">initializeMutationType()</span><span class="s1"> for all other discussion.</span></p>

SLiMgui/SLiMHelpFunctions.rtf

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -870,7 +870,7 @@ This function is written in Eidos, and its source code can be viewed with
870870
\f2\fs20 , so you can copy and modify its code if you need to modify its functionality.\
871871
\pard\pardeftab543\li720\fi-446\ri720\sb180\sa60\partightenfactor0
872872

873-
\f1\fs18 \cf0 (object<MutationType>$)initializeMutationType(is$\'a0id, numeric$\'a0dominanceCoeff, string$\'a0distributionType, ...)
873+
\f1\fs18 \cf0 (object<MutationType>$)initializeMutationType(is$\'a0id, numeric$\'a0dominanceCoeff, \cf2 [Ns$\'a0distributionType\'a0=\'a0NULL]\cf0 , ...)
874874
\f4 \
875875
\pard\pardeftab543\li547\ri720\sb60\sa60\partightenfactor0
876876

@@ -899,9 +899,9 @@ The
899899
\f1\fs18 setDefaultDominanceForTrait()
900900
\f2\fs20 method if desired. Note that the mutation type\'92s default hemizygous dominance coefficient is not supplied to this function; it always defaults to
901901
\f1\fs18 1.0
902-
\f2\fs20 , but can subsequently be configured with the
902+
\f2\fs20 , but the
903903
\f1\fs18 setDefaultHemizygousDominanceForTrait()
904-
\f2\fs20 method if desired.\
904+
\f2\fs20 method can configure it subsequently if desired.\
905905
The
906906
\f1\fs18 distributionType
907907
\f2\fs20 and the ellipsis parameters together define the distribution of effect size (DES) for the mutation type, for all traits. The DES for the mutation type for a specific trait can subsequently be separately configured with the
@@ -948,11 +948,20 @@ The
948948
\f1\fs18 "s"
949949
\f2\fs20 , in which case the ellipsis should supply a
950950
\f1\fs18 string$
951-
\f2\fs20 Eidos script parameter. See the
951+
\f2\fs20 Eidos script parameter. If
952+
\f1\fs18 distributionType
953+
\f2\fs20 is
954+
\f1\fs18 NULL
955+
\f2\fs20 (the default), a fixed effect of
956+
\f1\fs18 0.0
957+
\f2\fs20 is used, representing a neutral DES; this is equivalent to type
958+
\f1\fs18 "f"
959+
\f2\fs20 except that the value
960+
\f1\fs18 0.0
961+
\f2\fs20 is assumed and must not be supplied. See the
952962
\f1\fs18 MutationType
953963
\f2\fs20 class documentation for discussion of the various DESs and their uses.\
954-
\pard\pardeftab543\li547\ri720\sb60\sa60\partightenfactor0
955-
\cf2 \expnd0\expndtw0\kerning0
964+
\expnd0\expndtw0\kerning0
956965
Note that by default in WF models, all mutations of a given mutation type will be converted into
957966
\f1\fs18 Substitution
958967
\f2\fs20 objects when they reach fixation, for efficiency reasons. If you need to disable this conversion, to keep mutations of a given type active in the simulation even after they have fixed, you can do so by setting the
@@ -974,7 +983,8 @@ Note that by default in WF models, all mutations of a given mutation type will b
974983
\f2\fs20 .\
975984
\pard\pardeftab543\li720\fi-446\ri720\sb180\sa60\partightenfactor0
976985

977-
\f1\fs18 \cf2 (object<MutationType>$)initializeMutationTypeNuc(is$\'a0id, numeric$\'a0dominanceCoeff, string$\'a0distributionType, ...)\
986+
\f1\fs18 \cf2 (object<MutationType>$)initializeMutationTypeNuc(is$\'a0id, numeric$\'a0dominanceCoeff, \kerning1\expnd0\expndtw0 [Ns$\'a0distributionType\'a0=\'a0NULL]\expnd0\expndtw0\kerning0
987+
, ...)\
978988
\pard\pardeftab543\li547\ri720\sb60\sa60\partightenfactor0
979989

980990
\f2\fs20 \cf2 Add a nucleotide-based mutation type at initialization time. This function is identical to
@@ -1332,7 +1342,6 @@ If
13321342
\f1\fs18 initializeChromosome()
13331343
\f2\fs20 , allowing a different mutation run count to be specified for each chromosome in multi-chromosome models.\expnd0\expndtw0\kerning0
13341344
\
1335-
\pard\pardeftab720\li547\ri720\sb60\sa60\partightenfactor0
13361345
\cf0 \kerning1\expnd0\expndtw0 If
13371346
\f1\fs18 preventIncidentalSelfing
13381347
\f2\fs20 is
@@ -1412,7 +1421,6 @@ If
14121421
\f2\fs20 for
14131422
\f1\fs18 checkInfiniteLoops
14141423
\f2\fs20 to disable these checks. There is no way to turn these checks on or off for individual loops; it is a global setting.\
1415-
\pard\pardeftab720\li547\ri720\sb60\sa60\partightenfactor0
14161424
\cf0 This function will likely be extended with further options in the future, added on to the end of the argument list. Using named arguments with this call is recommended for readability. Note that turning on optional features may increase the runtime and memory footprint of SLiM.\
14171425
\pard\pardeftab720\li720\fi-446\ri720\sb180\sa60\partightenfactor0
14181426

VERSIONS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,7 @@ multitrait branch:
109109
allow the destination subpop to be given as a source, iff all rates supplied are 0.0, to stop all migration: allSubpops.setMigrationRates(allSubpops, 0.0)
110110
fix #567, plot windows can have their aspect ratio distorted due to screen size and other constraints
111111
add Individual class method +(void)demandPhenotype([Nio<Trait> trait = NULL], [l$ forceRecalc = F])
112+
extend initializeMutationType() and initializeMutationTypeNuc() to make the effect distribution optional with [Ns$ distributionType = NULL], where NULL is equivalent to `"f", 0.0`
112113

113114

114115
version 5.1 (Eidos version 4.1):

core/community_eidos.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -120,9 +120,9 @@ const std::vector<EidosFunctionSignature_CSP> *Community::ZeroTickFunctionSignat
120120
sim_0_signatures_.emplace_back((EidosFunctionSignature *)(new EidosFunctionSignature(gStr_initializeInteractionType, nullptr, kEidosValueMaskObject | kEidosValueMaskSingleton, gSLiM_InteractionType_Class, "SLiM"))
121121
->AddIntString_S("id")->AddString_S(gStr_spatiality)->AddLogical_OS(gStr_reciprocal, gStaticEidosValue_LogicalF)->AddNumeric_OS(gStr_maxDistance, gStaticEidosValue_FloatINF)->AddString_OS(gStr_sexSegregation, gStaticEidosValue_StringDoubleAsterisk));
122122
sim_0_signatures_.emplace_back((EidosFunctionSignature *)(new EidosFunctionSignature(gStr_initializeMutationType, nullptr, kEidosValueMaskObject | kEidosValueMaskSingleton, gSLiM_MutationType_Class, "SLiM"))
123-
->AddIntString_S("id")->AddNumeric_S("dominanceCoeff")->AddString_S("distributionType")->AddEllipsis());
123+
->AddIntString_S("id")->AddNumeric_S("dominanceCoeff")->AddString_OSN("distributionType", gStaticEidosValueNULL)->AddEllipsis());
124124
sim_0_signatures_.emplace_back((EidosFunctionSignature *)(new EidosFunctionSignature(gStr_initializeMutationTypeNuc, nullptr, kEidosValueMaskObject | kEidosValueMaskSingleton, gSLiM_MutationType_Class, "SLiM"))
125-
->AddIntString_S("id")->AddNumeric_S("dominanceCoeff")->AddString_S("distributionType")->AddEllipsis());
125+
->AddIntString_S("id")->AddNumeric_S("dominanceCoeff")->AddString_OSN("distributionType", gStaticEidosValueNULL)->AddEllipsis());
126126
sim_0_signatures_.emplace_back((EidosFunctionSignature *)(new EidosFunctionSignature(gStr_initializeRecombinationRate, nullptr, kEidosValueMaskVOID, "SLiM"))
127127
->AddNumeric("rates")->AddInt_ON("ends", gStaticEidosValueNULL)->AddString_OS("sex", gStaticEidosValue_StringAsterisk));
128128
sim_0_signatures_.emplace_back((EidosFunctionSignature *)(new EidosFunctionSignature(gStr_initializeTrait, nullptr, kEidosValueMaskObject | kEidosValueMaskSingleton, gSLiM_Trait_Class, "SLiM"))->AddString_S("name")->AddString_S("type")->AddFloat_OSN("baselineOffset", gStaticEidosValueNULL)->AddFloat_OSN("individualOffsetMean", gStaticEidosValueNULL)->AddFloat_OSN("individualOffsetSD", gStaticEidosValueNULL)->AddLogical_OS("directFitnessEffect", gStaticEidosValue_LogicalF));

0 commit comments

Comments
 (0)