As discussed in #946, this would make adding mutations to different time chunks of a tree sequence really possible, and would be a good idea more generally.
Needs to get added to tskit first, https://github.com/tskit-dev/tskit/issues/513
whoops, sorry, wrong repository. =) But this will remind us to update the mutation code.
Waiting on #1114
We now have a time column, anyone want to fill it in? Should be a straightforward update.
I'll give it a go.
Hello -- chiming in with a particular question, and I hope this is an appropriate thread for it. I haven't followed all the discussions super closely but just caught up now.
I've been playing with the mutation time feature, which is awesome, and right now I've taken a tree sequence, sampled a lot of mutations, and plotted the distribution over times. Since msprime gave me unknown times, I used the following code:
temp_ts = msprime.mutate(simulation, rate=args.mu*10, random_seed=seed)
temp_tables = temp_ts.dump_tables()
temp_tables.compute_mutation_times()
temp_ts = temp_tables.tree_sequence()
mutation_times = np.array([m.time for m in temp_ts.mutations()])
histogram = np.histogram(mutation_times, interval_bins, density=False)[0]
However, I was surprised that compute_mutation_times() currently gives the midpoint time from the node below and node above, rather than a uniform sampling over the height of the branch. Am I correct in guessing that uniform sampling, because it involves randomness, is instead a feature for msprime? This is really exciting, thanks @mufernando and everyone else for working on it.
@brianzhang01 thanks for reminding me of this. We've discussed this issue in the original mutation time work: https://github.com/tskit-dev/tskit/issues/513#issuecomment-639539212 The end result was to add as a future feature sampling uniformly, and getting round the need for random-ness by passing in a random array. However it seems there are other uses for randomness (e.g. https://github.com/tskit-dev/tskit/pull/815#issuecomment-682989666) so I'm starting to think we bite the bullet and solve the MIT-compatible source of randomness problem.
Long story short - this is planned and I should have made an issue! (thought I had but can't find it!)
Issue now at https://github.com/tskit-dev/tskit/issues/849
Thanks @benjeffery for catching me up! So it seems like on the tskit side, you'll be working on the pseudorandom uniform sampling in compute_mutation_times(), and this issue will also add pseudorandom uniform sampling on the msprime side? (simulate / mutate / sim_mutations) For me, I would be happy if just one of these were in (I'll roll my own in the meantime using the Python API). I'll also comment on the tskit issue you linked.
Closing this as times supported since #1179.