Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature idea: new methods to species regarding substitutions #481

Open
vsudbrack opened this issue Oct 30, 2024 · 1 comment
Open

Feature idea: new methods to species regarding substitutions #481

vsudbrack opened this issue Oct 30, 2024 · 1 comment

Comments

@vsudbrack
Copy link

I was wondering if it could be useful to add methods for species that handle substitutions similarly to how genome (or individual) methods handle mutations. For instance:

sim.substitutionsOfType(mutType id);
sim.sumOfSubstitutionsOfType(mutType id);
sim.countOfSubstitutionsOfType(mutType id);

I think any simulation of quantitative traits could benefit, as the trait of an individual of species sim based on mutations of type m1 (e.g. "n" with mean 0 and given variance) could be readily written as

phenos = sim.sumOfSubstitutionsOfType(m1) + inds.sumOfMutationsOfType(m1);

A few recipes that could benefit from it (from a quick CTRL+F in the manual):

  • Recipe 9.1 (and similarly Recipes 9.2, 9.5.2, 9.7, 11.2, 12.3, 17.3):
    From fixed = (sum(sim.substitutions.mutationType == m2) == 1); to fixed = (sim.countOfSubstitutionsOfType(m2) > 0);
  • Recipe 9.6.1:
    From if (sum(sim.substitutions.selectionCoeff) == 0.0) to if (sim.sumOfSubstitutionsOfType(m1) == 0.0)

More generally, one could think of a new callback substitute(<mutType>) which takes place every time a mutation of a given type is about to become a substitution. This could be ideal to end simulations as soon as a fixation event takes place, e.g.

substitute(m1) { sim.simulationFinished(); }

(present in many Recipes of sweeps) or, to update a baseline trait-value (that is, to overcome the need for sumOfSubstitutionsOfType(m1) in my example of quantitative traits above, as one could write

substitute(m1) { defineGlobal("BASELINE_TRAIT", BASELINE_TRAIT + mut.selectionCoeff); }

and then

phenos = BASELINE_TRAIT + inds.sumOfMutationsOfType(m1);

or even to have a mutation-based policy of substitution (e.g., by returning T or F from the callback). This idea being shared, I do think a new callback for this might be an overkill.

On a different aspect, but also regarding Substitutions, I wonder if outputSubstitutions() would be more aligned with the SLiMverse vocabulary than the current outputFixedMutations(). But that's a detail :)

@bhaller
Copy link
Contributor

bhaller commented Oct 30, 2024

Hi @vsudbrack. I've been working on a redesign of some parts of SLiM to better support quantitative traits. The design will automatically update the baseline offset of the trait after substitution, as you suggest here; so I think that aspect of your proposal is not necessary with that new design. But I like your other suggestions. Not sure whether the new callback type would really pay for itself; each new callback type just makes SLiM even more complicated, of course. It would help with that narrow problem of halting when a substitution occurs, but it doesn't strike me as having a lot of other uses (since the baseline issue will be taken care of). Anyhow, I'll think on all this, thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants