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
We need a nice simple way to dump neutral mutations on a tree sequence. What about:
defmutate(tree_sequence, mutation_rate, model=None):
""" Returns a copy of the specified tree sequence with mutations thrown down under the specified model. If model is None, the default is simple infinite sites mutations. """# Do stuffreturnnew_tree_sequence
Any thoughts @petrelharp or @molpopgen? I'm trying to keep it simple but leave the door open for more complex mutation in the future with the model argument. Maybe the rate parameter is a mistake though, and all the parameters should be subsumed into the MutationModel?
We can also do a version that takes a table collection as an argument I guess. I would imagine that most mutation models will need the trees though...
This is something that I'd been meaning to bring up. There are a couple of complications, one of which is specific, I think, to forward simulation.
The first is allowing the mutation rate to vary along the region being simulated. I think this would be handy for forward and backwards simulations.
The second issue is the idea of "mutate since". For many forward sims, many interesting things involve analyzing the simulation over time. For example, I may wish to get Tajima's D every 10 generations. To do that, I need to simplify and add mutations up to "now", and then add mutations again for the portion of the tree corresponding to [now+1,now+10].
All good ideas, thank @molpopgen and @petrelharp. For varying rates across the sequence, we could provide a "mutation_map" parameter that's analogous to a recombination map. It wouldn't be hard to do, it's basically just two numpy arrays.
The since or start_time parameter would be no problem at all.
The idea of a MutationModel is to allow for more complicated models of sequence evolution than simple infinite sites mutations. Presumably these need lots of parameters, and so rather than making the mutate function very complicated with lots of parameters, some of which only apply for different models and so on, we just wrap up the parameters required for these specific models in class the specifies this model.
So, I guess the main practical question for now is whether the initial version of this should look like:
Does the idea of an overall rate translate to all the different mutation models?
We also need the concept of an alphabet I think. Currently msprime generations '0'/'1' mutations, but we should also allow for nucleotides. Is this a parameter of the mutation model or the mutate function?
I'm trying to think ahead to future complications, and you guys know a lot more about this stuff than I do, so I'd really appreciate your thoughts here!
Does the idea of an overall rate translate to all the different mutation models?
I think ti does - any reasonable mutation model depends on time; and the mutation rate is just a time scaling. Any unreasonable one can ignore it. =)
We also need the concept of an alphabet I think.
I think this is a parameter of the mutation model (sometimes): for an infinite alleles model, the alphabet is infinite, not a parameter.
A mutation model, seems like, will get the state at the parent node and the length of the branch, and will produce either no mutation or a derived state. I don't think we can think of all the possible parameters for mutation models, so I'd stick with the only required parameter being mutation_rate.
Does the idea of an overall rate translate to all the different mutation models?
Yes. The challenge for the implementer of a mutation model comes from mapping variation in mutation rate back onto the trees. The approach that I use, and that SLiM uses, is to have an overall mutation rate and a series of weights associated with different "mutation classes". Those classes will tend to be something like ([start,stop), details about the kind of mutation to generate). Given that the [start,stop) for these regions will never perfectly overlap with marginal tree [left,right)s, one needs the total time in each marginal tree to re-weight as you go along the sequence.
We also need the concept of an alphabet I think. Currently msprime generations '0'/'1' mutations, but we should also allow for nucleotides. Is this a parameter of the mutation model or the mutate function?
Agree with @petrelharp -- this is a property of the model.
I'm trying to think ahead to future complications, and you guys know a lot more about this stuff than I do, so I'd really appreciate your thoughts here!
This method should have an option that will keep any existing sites or mutations, instead of overwriting them. (and, perhaps this should be the default?)
This method should have an option that will keep any existing sites or mutations, instead of overwriting them. (and, perhaps this should be the default?)
I agree it should have this option, but perhaps not as the default behaviour (seems like this could be surprising behaviour to coalescent simulator users). How about a binary flag overwrite=False by default?
Activity
molpopgen commentedon May 2, 2018
This is something that I'd been meaning to bring up. There are a couple of complications, one of which is specific, I think, to forward simulation.
The first is allowing the mutation rate to vary along the region being simulated. I think this would be handy for forward and backwards simulations.
The second issue is the idea of "mutate since". For many forward sims, many interesting things involve analyzing the simulation over time. For example, I may wish to get Tajima's D every 10 generations. To do that, I need to simplify and add mutations up to "now", and then add mutations again for the portion of the tree corresponding to [now+1,now+10].
I'd like to hear your thoughts on this.
petrelharp commentedon May 2, 2018
Agree!! The table version I'd think would just load the tables into a ts then write out the tables again after.
What's the idea for the MutationModel?
petrelharp commentedon May 2, 2018
Agree on @molpopgen's suggestions also. Sounds like "mutation since" could be a parameter; varying rates would go into MutationModel?
jeromekelleher commentedon May 3, 2018
All good ideas, thank @molpopgen and @petrelharp. For varying rates across the sequence, we could provide a "mutation_map" parameter that's analogous to a recombination map. It wouldn't be hard to do, it's basically just two numpy arrays.
The
sinceorstart_timeparameter would be no problem at all.The idea of a
MutationModelis to allow for more complicated models of sequence evolution than simple infinite sites mutations. Presumably these need lots of parameters, and so rather than making themutatefunction very complicated with lots of parameters, some of which only apply for different models and so on, we just wrap up the parameters required for these specific models in class the specifies this model.So, I guess the main practical question for now is whether the initial version of this should look like:
or
Does the idea of an overall rate translate to all the different mutation models?
We also need the concept of an alphabet I think. Currently msprime generations '0'/'1' mutations, but we should also allow for nucleotides. Is this a parameter of the mutation model or the
mutatefunction?I'm trying to think ahead to future complications, and you guys know a lot more about this stuff than I do, so I'd really appreciate your thoughts here!
petrelharp commentedon May 3, 2018
I think ti does - any reasonable mutation model depends on time; and the mutation rate is just a time scaling. Any unreasonable one can ignore it. =)
I think this is a parameter of the mutation model (sometimes): for an infinite alleles model, the alphabet is infinite, not a parameter.
A mutation model, seems like, will get the state at the parent node and the length of the branch, and will produce either no mutation or a derived state. I don't think we can think of all the possible parameters for mutation models, so I'd stick with the only required parameter being
mutation_rate.molpopgen commentedon May 3, 2018
Yes. The challenge for the implementer of a mutation model comes from mapping variation in mutation rate back onto the trees. The approach that I use, and that SLiM uses, is to have an overall mutation rate and a series of weights associated with different "mutation classes". Those classes will tend to be something like ([start,stop), details about the kind of mutation to generate). Given that the [start,stop) for these regions will never perfectly overlap with marginal tree [left,right)s, one needs the total time in each marginal tree to re-weight as you go along the sequence.
Agree with @petrelharp -- this is a property of the model.
petrelharp commentedon May 24, 2018
This method should have an option that will keep any existing sites or mutations, instead of overwriting them. (and, perhaps this should be the default?)
(mentioned in MesserLab/SLiM#8)
I think we can do this by (1) generating new mutations as usual; (2) sorting, deduplicating, and adding mutation parents.
jeromekelleher commentedon May 30, 2018
I agree it should have this option, but perhaps not as the default behaviour (seems like this could be surprising behaviour to coalescent simulator users). How about a binary flag
overwrite=Falseby default?