questions on conditioning selective sweep on fixation (or establishment)

18 views
Skip to first unread message

Max Shpak

unread,
Jun 23, 2022, 12:32:59 PM6/23/22
to slim-discuss
I am running a of three subpopulations where one of them experiences a selective sweep. I would like to condition the simulations on fixation (or establishment) of the mutation in this subpopulation.

I have a general question about the syntax of the Eidos conditional statements on pg. 163 of the manual, i.e.

    1000:100000 late() {
    if (sim.countOfMutationsOfType(m2) == 0)
   {
   fixed = (sum(sim.substitutions.mutationType == m2) == 1);
    if (fixed)
   {
   cat(simID + ": FIXED\n");
   sim.simulationFinished();
   }

Unless I'm misunderstanding something, if the first condition countOfMutationsOfType(m2)==0 is true, then by definition there can be no mutations of type 2, so how could (given this condition) fixed (as defined below) be true?
fixed = (sum(sim.substitutions.mutationType == m2) == 1);
    if (fixed)

Doesn't the fixed condition contradict the prior countofmutation==0 condition?

Additionally, if in my model I specify 3 subpopulations p1,p2,p3, would the correct syntax for checking for fixation in p3 be:

fixed = (sum(p3.substitutions.mutationType == m2) == 1);

i.e. with p3 in place of sim, or do I need to use some other object?

Ben Haller

unread,
Jun 23, 2022, 4:33:35 PM6/23/22
to Max Shpak, slim-discuss
Hi Max!

Regarding your first question: The difference is between mutations still being simulated (typically because they are still segregating), which is what countOfMutationsOfType() is counting, versus "substitutions", which are a different category of objects representing mutations that are no longer being simulated because they have fixed and then been removed from the simulation.  See section 1.5.2 for the conceptual discussion of this distinction, which is a pretty fundamental one in SLiM.  So when the number of "mutations" of type m2 is zero, that means there is no m2 mutation still segregating.  That can be because it has been lost (in which case "substitution" object will exist) or because it has "fixed" (in which case a "substitution" object will exist).  That is what that code snippet is testing, to determine the fate of the m2 mutation.

And as for the second question: SLiM thinks only about "fixation" in terms of population-wide fixation.  If a mutation reaches a frequency of 1.0 within a particular subpopulation, SLiM never considers that to be "fixation", and a substitution object will never be created; that only happens when the mutation reaches a frequency of 1.0 across the whole population (again, see section 1.5.2 for discussion; the whole of section 1.5 is a good idea to read carefully before working with SLiM, really).  So no, you cannot check "p3.substitutions", and indeed that property does not exist – since substitutions are always across the whole population, they are always accessed through "sim.substitutions".  If you want to detect that a mutation has reached a frequency of 1.0 in a particular subpopulation, use the mutationFrequencies() method – for example, "if (sim.mutationFrequencies(p3, myMut) == 1.0) ...".

I hope this clarifies things.  Happy modeling!

Cheers,
-B.

Benjamin C. Haller
Messer Lab
Cornell University


Max Shpak wrote on 6/23/22 9:32 AM:
--
SLiM forward genetic simulation: http://messerlab.org/slim/
---
You received this message because you are subscribed to the Google Groups "slim-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to slim-discuss...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/slim-discuss/a9c6631a-2885-4f45-9d85-61212b8f57bbn%40googlegroups.com.

Reply all
Reply to author
Forward
0 new messages