Skip to content

Commit 2499c9e

Browse files
committed
fix #564, initializeMutationRateFromFile() needs a sex parameter
1 parent 7c75433 commit 2499c9e

4 files changed

Lines changed: 10 additions & 7 deletions

File tree

QtSLiM/help/SLiMHelpFunctions.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -99,9 +99,9 @@
9999
<p class="p3"><span class="s1">If the optional </span><span class="s2">sex</span><span class="s1"> parameter is </span><span class="s2">"*"</span><span class="s1"> (the default), then the supplied mutation rate map will be used for both sexes (which is the only option for hermaphroditic simulations).<span class="Apple-converted-space">  </span>In sexual simulations </span><span class="s2">sex</span><span class="s1"> may be </span><span class="s2">"M"</span><span class="s1"> or </span><span class="s2">"F"</span><span class="s1"> instead, in which case the supplied mutation rate map is used only for that sex (i.e., when generating a gamete from a parent of that sex).<span class="Apple-converted-space">  </span>In this case, two calls must be made to </span><span class="s2">initializeMutationRate()</span><span class="s1">, one for each sex, even if a rate of zero is desired for the other sex; no default mutation rate map is supplied.</span></p>
100100
<p class="p3"><span class="s1">In nucleotide-based models, </span><span class="s2">initializeMutationRate()</span><span class="s1"> may not be called.<span class="Apple-converted-space">  </span>Instead, the desired sequence-based mutation rate(s) should be expressed in the </span><span class="s2">mutationMatrix</span><span class="s1"> parameter to </span><span class="s2">initializeGenomicElementType()</span><span class="s1">.<span class="Apple-converted-space">  </span>If variation in the mutation rate along the chromosome is desired, </span><span class="s2">initializeHotspotMap()</span><span class="s1"> should be used.</span></p>
101101
<p class="p3">The <span class="s3">initializeMutationRateFromFile()</span> function is a useful convenience function if you wish to read the mutation rate map from a file.</p>
102-
<p class="p4">(void)initializeMutationRateFromFile(string$ path, integer$ lastPosition, [float$ scale = 1.0e-08], [string$ sep = "\t"], [string$ dec = "."])</p>
102+
<p class="p4">(void)initializeMutationRateFromFile(string$ path, integer$ lastPosition, [float$ scale = 1.0e-08], [string$ sep = "\t"], [string$ dec = "."], [string$ sex = "*"])</p>
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>
104-
<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.</p>
104+
<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>
106106
<p class="p2">(object&lt;MutationType&gt;$)initializeMutationType(is$ id, numeric$ dominanceCoeff, string$ distributionType, ...)</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>

SLiMgui/SLiMHelpFunctions.rtf

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -812,7 +812,7 @@ If the optional
812812
\f2\fs20 function is a useful convenience function if you wish to read the mutation rate map from a file.\
813813
\pard\pardeftab543\li720\fi-446\ri720\sb180\sa60\partightenfactor0
814814

815-
\f1\fs18 \cf2 (void)initializeMutationRateFromFile(string$\'a0path, integer$\'a0lastPosition, [float$\'a0scale\'a0=\'a01.0e-08], [string$\'a0sep\'a0=\'a0"\\t"], [string$\'a0dec\'a0=\'a0"."])\
815+
\f1\fs18 \cf2 (void)initializeMutationRateFromFile(string$\'a0path, integer$\'a0lastPosition, [float$\'a0scale\'a0=\'a01.0e-08], [string$\'a0sep\'a0=\'a0"\\t"], [string$\'a0dec\'a0=\'a0"."], [string$\'a0sex\'a0=\'a0"*"])\
816816
\pard\pardeftab543\li547\ri720\sb60\sa60\partightenfactor0
817817

818818
\f2\fs20 \cf2 Set a mutation rate map from data read from the file at
@@ -862,7 +862,9 @@ See
862862
\f1\fs18 dec
863863
\f2\fs20 , which are passed through to it; and see
864864
\f1\fs18 initializeMutationRate()
865-
\f2\fs20 for details on how the rate map is validated and used.\
865+
\f2\fs20 for details on how the rate map is validated and used, and how the
866+
\f1\fs18 sex
867+
\f2\fs20 parameter is used.\
866868
This function is written in Eidos, and its source code can be viewed with
867869
\f1\fs18 functionSource()
868870
\f2\fs20 , so you can copy and modify its code if you need to modify its functionality.\

VERSIONS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,7 @@ multitrait branch:
8383
Mutation: add read-write <trait-name>HemizygousDominance property to Mutation
8484
Substitution: add read-only <trait-name>HemizygousDominance property
8585
policy change: the nucleotide and nucleotideValue properties of Substitution are now read-only (I think it was a bug that they were ever read-write...?)
86+
fix #564, initializeMutationRateFromFile() needs a `sex` parameter; I'm doing this in multitrait to avoid the annoying doc conflicts
8687

8788

8889
version 5.1 (Eidos version 4.1):

core/slim_functions.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ const std::vector<EidosFunctionSignature_CSP> *Community::SLiMFunctionSignatures
9393
sim_func_signatures_.emplace_back((EidosFunctionSignature *)(new EidosFunctionSignature("summarizeIndividuals", SLiM_ExecuteFunction_summarizeIndividuals, kEidosValueMaskFloat, "SLiM"))->AddObject("individuals", gSLiM_Individual_Class)->AddInt("dim")->AddNumeric("spatialBounds")->AddString_S("operation")->AddLogicalEquiv_OSN("empty", gStaticEidosValue_Float0)->AddLogical_OS("perUnitArea", gStaticEidosValue_LogicalF)->AddString_OSN("spatiality", gStaticEidosValueNULL));
9494
sim_func_signatures_.emplace_back((EidosFunctionSignature *)(new EidosFunctionSignature("treeSeqMetadata", SLiM_ExecuteFunction_treeSeqMetadata, kEidosValueMaskObject | kEidosValueMaskSingleton, gEidosDictionaryRetained_Class, "SLiM"))->AddString_S("filePath")->AddLogical_OS("userData", gStaticEidosValue_LogicalT));
9595

96-
sim_func_signatures_.emplace_back((EidosFunctionSignature *)(new EidosFunctionSignature("initializeMutationRateFromFile", gSLiMSourceCode_initializeMutationRateFromFile, kEidosValueMaskVOID, "SLiM"))->AddString_S("path")->AddInt_S("lastPosition")->AddFloat_OS("scale", EidosValue_Float_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Float(1e-8)))->AddString_OS("sep", gStaticEidosValue_StringTab)->AddString_OS("dec", gStaticEidosValue_StringPeriod));
96+
sim_func_signatures_.emplace_back((EidosFunctionSignature *)(new EidosFunctionSignature("initializeMutationRateFromFile", gSLiMSourceCode_initializeMutationRateFromFile, kEidosValueMaskVOID, "SLiM"))->AddString_S("path")->AddInt_S("lastPosition")->AddFloat_OS("scale", EidosValue_Float_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Float(1e-8)))->AddString_OS("sep", gStaticEidosValue_StringTab)->AddString_OS("dec", gStaticEidosValue_StringPeriod)->AddString_OS("sex", gStaticEidosValue_StringAsterisk));
9797
sim_func_signatures_.emplace_back((EidosFunctionSignature *)(new EidosFunctionSignature("initializeRecombinationRateFromFile", gSLiMSourceCode_initializeRecombinationRateFromFile, kEidosValueMaskVOID, "SLiM"))->AddString_S("path")->AddInt_S("lastPosition")->AddFloat_OS("scale", EidosValue_Float_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Float(1e-8)))->AddString_OS("sep", gStaticEidosValue_StringTab)->AddString_OS("dec", gStaticEidosValue_StringPeriod)->AddString_OS("sex", gStaticEidosValue_StringAsterisk));
9898

9999
// Internal SLiM functions
@@ -1018,7 +1018,7 @@ R"V0G0N({
10181018
#pragma mark Other built-in functions
10191019
#pragma mark -
10201020

1021-
#pragma mark (void)initializeMutationRateFromFile(s$ path, i$ lastPosition, [f$ scale=1e-8], [s$ sep="\t"], [s$ dec="."])
1021+
#pragma mark (void)initializeMutationRateFromFile(s$ path, i$ lastPosition, [f$ scale=1e-8], [s$ sep="\t"], [s$ dec="."], [string$ sex = "*"])
10221022
const char *gSLiMSourceCode_initializeMutationRateFromFile =
10231023
R"V0G0N({
10241024
errbase = "ERROR (initializeMutationRateFromFile): ";
@@ -1055,7 +1055,7 @@ R"V0G0N({
10551055
else
10561056
ends = c(ends[1:(size(ends)-1)] - base - 1, lastPosition);
10571057
1058-
initializeMutationRate(rates * scale, ends);
1058+
initializeMutationRate(rates * scale, ends, sex);
10591059
})V0G0N";
10601060

10611061
#pragma mark (void)initializeRecombinationRateFromFile(s$ path, i$ lastPosition, [f$ scale=1e-8], [s$ sep="\t"], [s$ dec="."], [string$ sex = "*"])

0 commit comments

Comments
 (0)