Efficient metadata - #658
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## multitrait #658 +/- ##
==============================================
- Coverage 76.89% 76.88% -0.01%
==============================================
Files 117 117
Lines 78701 78701
Branches 14287 14283 -4
==============================================
- Hits 60515 60509 -6
- Misses 18186 18192 +6 🚀 New features to boost your workflow:
|
|
I changed the base of this PR to point to multitrait, FYI, which seems to be what you want. |
Huh, how odd! I could swear I set that up when I made the branch – but perhaps not. :-O Thanks! |
|
Are you otherwise happy with my fix, @petrelharp? |
| for tree in ts.trees(): | ||
| if tree.num_roots > 1: # not fully coalesced | ||
| heights[tree.index] = ts.metadata['SLiM']['tick'] | ||
| heights[tree.index] = uncoalesced_height |
There was a problem hiding this comment.
This is not necessary any more! I see that below we recapitate, implying that this tree sequence has all the input roots, and so the heights of all the roots should all be equal to the tick value (+/- 1) already!
|
See my PR to this PR, #659. |
|
OK, hmm. If you look at recipe 18.10 in the draft SLiM 6 manual (or recipe 17.10 in the SLiM 5.2 manual, which I think is pretty much the same), the goal is to see a plot showing the tree height along the chromosome before and after recapitation. Post-recapitation that's easy, but pre-recapitation I guess there was some issue that required patching the tree heights when coalescence hasn't been reached. You write "A lot of that wasn't necessary any more!" Did something change, in tskit or pyslim or somewhere, that made what we were doing unnecessary? Or was it unnecessary all along? I'd just like to understand this better, for fear of accidental breakage. I'm pretty sure that you were the primary author of this recipe, back in the day – I don't think I wrote this Python code! – so was past-you incorrect, or did the ground shift in some way? (And also: is the new code in fact better than the old code? It is actually one line longer than the old code, but I don't really understand what the new code is doing.) I'm happy to accept your PR, I just want to double-check that all of this truly makes sense and is correct. Also, please provide a new paragraph for the manual write-up that explains what your new code is doing, and why. The old text looks like this:
Thanks! |
OK. In the context of this specific recipe the check for all roots having the same time is unneeded, but I guess it's pedagogically useful, sure. And now I see what it's doing;
Yeah, I don't want to do that, because the y-axis for the two plots is (intentionally and usefully) on different scales; with a single plot it is difficult to see what the pre-recapitation heights really look like. (In the manual the plot is combined, but that is using a y-axis scale that uses a cube root, which is a bit unconventional but brings out the needed detail. :->).
Groovy. When I got a chance I'll merge this in, fix the plotting back the way it was (or you can fix your PR here, if you have a moment), and merge it in. Thanks! |
|
Merged, done, thanks! |

Draft fix to make metadata access efficient in recipe 18.10; see tskit-dev/tskit#3472 (comment).
@petrelharp The function that uses the metadata gets called twice in this script, so it still accesses the metadata twice. I wasn't sure whether it would make sense to define a global, or pass the value as a parameter, etc., to get the number of metadata accesses down to one; for this script it seems like overkill, but maybe it would provide a better example in terms of pedagogy – really emphasizing that users should try to get their metadata accesses down to the bare minimum. Let me know what you think the best thing is here.
Once this PR is finalized and approved I'll modify the manual's discussion of this recipe to emphasize that minimizing metadata access is important. :->