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

fix allele frequency calculation in slim code, or disallow multiple drawn mutations per MutationType #608

Closed
grahamgower opened this issue Oct 3, 2020 · 1 comment
Milestone

Comments

@grahamgower
Copy link
Member

The allele frequency calculation in the slim engine (used for allele frequency conditioning) currently assumes there is only one mutation per MutationType.

// Return the allele frequency of a drawn mutation in the specified population.
// Assumes there's only one mutation of the given type.
function (float$)af(object$ mut_type, object$ pop) {
mut = sim.mutationsOfType(mut_type);
if (length(mut) == 0) {
return 0.0;
}
return sim.mutationFrequencies(pop, mut);
}

But a user could easily break this by drawing two mutations of the same mutation type. See note here:

@attr.s(kw_only=True)
class DrawMutation(ExtendedEvent):
"""
TODO: docstring.
Draw a new mutation with the given mutation type in the given population
at the given genomic coordinate. The mutation will be added to one randomly
chosen chromosome in the given population.
If save=True, the simulation state is saved before the mutation is
introduced, to facilitate the save/restore mechanism used for allele
frequency conditioning.
FIXME: Drawing multiple mutations using the same mutation type causes
erroneous allele frequency calculation in the SLiM code!
Multiple drawn mutations should be disallowed, or the allele frequency
calculation should somehow be tied to specific drawn mutations.
See SLiM documentation for addNewDrawnMutation().
"""

@nspope
Copy link
Collaborator

nspope commented Sep 26, 2022

Fixed by #1341. We're opting to disallow multiple DrawMutation events at the same site for the time being.

@nspope nspope closed this as completed Sep 26, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants