-
What's an efficient way to calculate an array of the number of mutations per site? Obviously I can loop through I quite often want to get a boolean array selecting only those sites that have exactly one mutation, so a quick shorthand would be useful. AI suggests this: def single_mutation_sites(ts):
diff_mask = np.diff(ts.mutations_site) != 0
return ts.mutations_site[np.concatenate(([True], diff_mask)) & np.concatenate((diff_mask, [True]))] Which I think is right? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 2 replies
-
I use |
Beta Was this translation helpful? Give feedback.
I use
numpy.bincount(ts.mutations_site, minlength=ts.num_sites)