You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: QtSLiM/help/SLiMHelpClasses.html
+1-1Lines changed: 1 addition & 1 deletion
Original file line number
Diff line number
Diff line change
@@ -740,7 +740,7 @@
740
740
<pclass="p6"><spanclass="s3">As of SLiM 3.0, this method will read and restore the ages of individuals if that information is present in the output file and the simulation is based upon the nonWF model.<spanclass="Apple-converted-space"></span>If ages are present but the simulation uses a WF model, an error will result; the WF model does not use age information.<spanclass="Apple-converted-space"></span>If ages are not present but the simulation uses a nonWF model, an error will also result; the nonWF model requires age information.</span></p>
741
741
<pclass="p6"><spanclass="s3">As of SLiM 3.3, this method will restore the nucleotides of nucleotide-based mutations, and will restore the ancestral nucleotide sequence, if that information is present in the output file.<spanclass="Apple-converted-space"></span>Loading an output file that contains nucleotide information in a non-nucleotide-based model, and <i>vice versa</i>, will produce an error.</span></p>
742
742
<pclass="p6">As of SLiM 3.5, this method will read and restore the pedigree IDs of individuals and genomes if that information is present in the output file (as requested with <spanclass="s1">outputFull(pedigreeIDs=T)</span>) <i>and</i> if SLiM’s optional pedigree tracking has been enabled with <spanclass="s1">initializeSLiMOptions(keepPedigrees=T)</span>.</p>
743
-
<pclass="p6">This method can also be used to read tree-sequence (<spanclass="s1">.trees</span>) files saved by <spanclass="s1">treeSeqOutput()</span> or generated by the Python <spanclass="s1">pyslim</span> package.<spanclass="Apple-converted-space"></span>Beginning with SLiM 4, the <spanclass="s1">subpopMap</span> parameter may be supplied to re-order the populations of the input tree sequence when it is loaded in to SLiM.<spanclass="Apple-converted-space"></span>This parameter must have a value that is a <spanclass="s1">Dictionary</span>; the keys of this dictionary should be SLiM population identifiers as <spanclass="s1">string</span> values (e.g., <spanclass="s1">"p2"</span>), and the values should be indexes of populations in the input tree sequence; a key/value pair of <spanclass="s1">"p2", 4</span> would mean that the fourth population in the input should become <spanclass="s1">p2</span> on loading into SLiM.<spanclass="Apple-converted-space"></span>If <spanclass="s1">subpopMap</span> is non-<spanclass="s1">NULL</span>, <i>all</i> populations in the tree sequence must be explicitly mapped, even if their index will not change and even if they will not be used by SLiM.<spanclass="Apple-converted-space"></span>For instance, suppose we have a tree sequence in which population <spanclass="s1">0</span> is unused, population <spanclass="s1">1</span> is not a SLiM population (for example, an ancestral population produced by <spanclass="s1">msprime</span>), and population 2 is a SLiM population, and we want to load this in with population 2 as <spanclass="s1">p0</span> in SLiM.<spanclass="Apple-converted-space"></span>To do this, we could supply a value of <spanclass="s1">Dictionary("p0", 2, "p1", 1, "p2", 0)</span> for <spanclass="s1">subpopMap</span>.<spanclass="Apple-converted-space"></span>Although this cannot be used to remove populations in the tree sequence, note that it may <i>add</i> populations that will be visible when <spanclass="s1">treeSeqOutput()</span> is called (although these will not be SLiM populations); if, in this example, we had used <spanclass="s1">Dictionary("p0", 0, "p1", 1, "p5", 2)</span> and then we wrote the result out with <spanclass="s1">treeSeqOutput()</span>, the resulting tree sequence would have six populations, although three of them would be empty and would not be used by SLiM.<spanclass="Apple-converted-space"></span>The use of subpopMap makes it easier to load simulation data that was generated in Python, since that typically uses an id of <spanclass="s1">0</span>.<spanclass="Apple-converted-space"></span>The <spanclass="s1">subpopMap</span> parameter may not be used with file formats other than tree-sequence files, at the present time; setting up the correct subpopulation ids is typically easier when working with those other formats.</p>
743
+
<pclass="p6">This method can also be used to read tree-sequence (<spanclass="s1">.trees</span>) files saved by <spanclass="s1">treeSeqOutput()</span> or generated by the Python <spanclass="s1">pyslim</span> package.<spanclass="Apple-converted-space"></span>Beginning with SLiM 4, the <spanclass="s1">subpopMap</span> parameter may be supplied to re-order the populations of the input tree sequence when it is loaded in to SLiM.<spanclass="Apple-converted-space"></span>This parameter must have a value that is a <spanclass="s1">Dictionary</span>; the keys of this dictionary should be SLiM population identifiers as <spanclass="s1">string</span> values (e.g., <spanclass="s1">"p2"</span>), and the values should be indexes of populations in the input tree sequence; a key/value pair of <spanclass="s1">"p2", 4</span> would mean that the fifth population in the input (the one at zero-based index <spanclass="s1">4</span>) should become <spanclass="s1">p2</span> on loading into SLiM.<spanclass="Apple-converted-space"></span>If <spanclass="s1">subpopMap</span> is non-<spanclass="s1">NULL</span>, <i>all</i> populations in the tree sequence must be explicitly mapped, even if their index will not change and even if they will not be used by SLiM; the only exception is for unused slots in the population table, which can be explicitly remapped but do not have to be.<spanclass="Apple-converted-space"></span>For instance, suppose we have a tree sequence in which population <spanclass="s1">0</span> is unused, population <spanclass="s1">1</span> is not a SLiM population (for example, an ancestral population produced by <spanclass="s1">msprime</span>), and population 2 is a SLiM population, and we want to load this in with population 2 as <spanclass="s1">p0</span> in SLiM.<spanclass="Apple-converted-space"></span>To do this, we could supply a value of <spanclass="s1">Dictionary("p0", 2, "p1", 1, "p2", 0)</span> for <spanclass="s1">subpopMap</span>, or we could leave out slot <spanclass="s1">0</span> since it is unused, with <spanclass="s1">Dictionary("p0", 2, "p1", 1)</span>.<spanclass="Apple-converted-space"></span>Although this facility cannot be used to remove populations in the tree sequence, note that it may <i>add</i> populations that will be visible when <spanclass="s1">treeSeqOutput()</span> is called (although these will not be SLiM populations); if, in this example, we had used <spanclass="s1">Dictionary("p0", 0, "p1", 1, "p5", 2)</span> and then we wrote the result out with <spanclass="s1">treeSeqOutput()</span>, the resulting tree sequence would have six populations, although three of them would be empty and would not be used by SLiM.<spanclass="Apple-converted-space"></span>The use of <spanclass="s1">subpopMap</span> makes it easier to load simulation data that was generated in Python, since that typically uses an id of <spanclass="s1">0</span>.<spanclass="Apple-converted-space"></span>The <spanclass="s1">subpopMap</span> parameter may not be used with file formats other than tree-sequence files, at the present time; setting up the correct subpopulation ids is typically easier when working with those other formats.<spanclass="Apple-converted-space"></span>Note the <spanclass="s1">tskit</span> command-line interface can be used, like <spanclass="s1">python3 -m tskit populations file.trees</span>, to find out the number of subpopulations in a tree-sequence file and their IDs.</p>
744
744
<pclass="p6">When loading a tree sequence, a crosscheck of the loaded data will be performed to ensure that the tree sequence was well-formed and was loaded correctly.<spanclass="Apple-converted-space"></span>When running a Release build of SLiM, however, this crosscheck will only occur the first time that <spanclass="s1">readFromPopulationFile()</span> is called to load a tree sequence; subsequent calls will not perform this crosscheck, for greater speed when running models that load saved population state many times (such as models that are conditional on fixation).<spanclass="Apple-converted-space"></span>If you suspect that a tree sequence file might be corrupted or read incorrectly, running a Debug build of SLiM enables crosschecks after every load.</p>
<pclass="p6">Force an immediate recalculation of fitness values for all individuals in all subpopulations.<spanclass="Apple-converted-space"></span>Normally fitness values are calculated at a fixed point in each tick, and those values are cached and used until the next recalculation.<spanclass="Apple-converted-space"></span>If simulation parameters are changed in script in a way that affects fitness calculations, and if you wish those changes to take effect immediately rather than taking effect at the next automatic recalculation, you may call <spanclass="s1">recalculateFitness()</span> to force an immediate recalculation and recache.</p>
\cf2 This method can also be used to read tree-sequence (
5979
5980
\f3\fs18 .trees
5980
5981
\f4\fs20 ) files saved by
5981
5982
\f3\fs18 treeSeqOutput()
@@ -5991,15 +5992,17 @@ This method can also be used to read tree-sequence (
5991
5992
\f3\fs18 "p2"
5992
5993
\f4\fs20 ), and the values should be indexes of populations in the input tree sequence; a key/value pair of
5993
5994
\f3\fs18 "p2", 4
5994
-
\f4\fs20 would mean that the fourth population in the input should become
5995
+
\f4\fs20 would mean that the fifth population in the input (the one at zero-based index
5996
+
\f3\fs18 4
5997
+
\f4\fs20 ) should become
5995
5998
\f3\fs18 p2
5996
5999
\f4\fs20 on loading into SLiM. If
5997
6000
\f3\fs18 subpopMap
5998
6001
\f4\fs20 is non-
5999
6002
\f3\fs18 NULL
6000
6003
\f4\fs20 ,
6001
6004
\f1\i all
6002
-
\f4\i0 populations in the tree sequence must be explicitly mapped, even if their index will not change and even if they will not be used by SLiM. For instance, suppose we have a tree sequence in which population
6005
+
\f4\i0 populations in the tree sequence must be explicitly mapped, even if their index will not change and even if they will not be used by SLiM; the only exception is for unused slots in the population table, which can be explicitly remapped but do not have to be. For instance, suppose we have a tree sequence in which population
6003
6006
\f3\fs18 0
6004
6007
\f4\fs20 is unused, population
6005
6008
\f3\fs18 1
@@ -6011,21 +6014,30 @@ This method can also be used to read tree-sequence (
6011
6014
\f3\fs18 Dictionary("p0", 2, "p1", 1, "p2", 0)
6012
6015
\f4\fs20 for
6013
6016
\f3\fs18 subpopMap
6014
-
\f4\fs20 . Although this cannot be used to remove populations in the tree sequence, note that it may
6017
+
\f4\fs20 , or we could leave out slot
6018
+
\f3\fs18 0
6019
+
\f4\fs20 since it is unused, with
6020
+
\f3\fs18 Dictionary("p0", 2, "p1", 1)
6021
+
\f4\fs20 . Although this facility cannot be used to remove populations in the tree sequence, note that it may
6015
6022
\f1\i add
6016
6023
\f4\i0 populations that will be visible when
6017
6024
\f3\fs18 treeSeqOutput()
6018
6025
\f4\fs20 is called (although these will not be SLiM populations); if, in this example, we had used
6019
6026
\f3\fs18 Dictionary("p0", 0, "p1", 1, "p5", 2)
6020
6027
\f4\fs20 and then we wrote the result out with
6021
6028
\f3\fs18 treeSeqOutput()
6022
-
\f4\fs20 , the resulting tree sequence would have six populations, although three of them would be empty and would not be used by SLiM. The use of subpopMap makes it easier to load simulation data that was generated in Python, since that typically uses an id of
6029
+
\f4\fs20 , the resulting tree sequence would have six populations, although three of them would be empty and would not be used by SLiM. The use of
6030
+
\f3\fs18 subpopMap
6031
+
\f4\fs20 makes it easier to load simulation data that was generated in Python, since that typically uses an id of
6023
6032
\f3\fs18 0
6024
6033
\f4\fs20 . The
6025
6034
\f3\fs18 subpopMap
6026
-
\f4\fs20 parameter may not be used with file formats other than tree-sequence files, at the present time; setting up the correct subpopulation ids is typically easier when working with those other formats.\
\cf2 When loading a tree sequence, a crosscheck of the loaded data will be performed to ensure that the tree sequence was well-formed and was loaded correctly. When running a Release build of SLiM, however, this crosscheck will only occur the first time that
6035
+
\f4\fs20 parameter may not be used with file formats other than tree-sequence files, at the present time; setting up the correct subpopulation ids is typically easier when working with those other formats. Note the
6036
+
\f3\fs18 tskit
6037
+
\f4\fs20 command-line interface can be used, like
6038
+
\f3\fs18 python3 -m tskit populations file.trees
6039
+
\f4\fs20 , to find out the number of subpopulations in a tree-sequence file and their IDs.\
6040
+
When loading a tree sequence, a crosscheck of the loaded data will be performed to ensure that the tree sequence was well-formed and was loaded correctly. When running a Release build of SLiM, however, this crosscheck will only occur the first time that
6029
6041
\f3\fs18 readFromPopulationFile()
6030
6042
\f4\fs20 is called to load a tree sequence; subsequent calls will not perform this crosscheck, for greater speed when running models that load saved population state many times (such as models that are conditional on fixation). If you suspect that a tree sequence file might be corrupted or read incorrectly, running a Debug build of SLiM enables crosschecks after every load.\
// Start by checking that no remap entry references a population table index that is out of range
6783
+
if (pop_count == 0)
6784
+
EIDOS_TERMINATION << "ERROR (Species::__RemapSubpopulationIDs): the population table is empty, and therefore cannot be remapped." << EidosTerminate(nullptr);
//std::cout << "index " << table_index << " being remapped to " << remapped_index << std::endl;
6792
+
6793
+
if (table_index < 0)
6794
+
EIDOS_TERMINATION << "ERROR (Species::__RemapSubpopulationIDs): (internal error) index " << table_index << " is out of range (less than zero)." << EidosTerminate(nullptr);
6795
+
if (table_index >= (int64_t)pop_count)
6796
+
EIDOS_TERMINATION << "ERROR (Species::__RemapSubpopulationIDs): index " << table_index << " is out of range (last valid index " << ((int64_t)pop_count - 1) << ")." << EidosTerminate(nullptr);
6797
+
}
6798
+
6799
+
// OK, population table indices are in range; check the population table entry remappings one by one
6782
6800
for (tsk_size_t pop_index = 0; pop_index < pop_count; pop_index++)
0 commit comments