census node per lineage, not segment: closes #2540 - #2541
Conversation
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## main #2541 +/- ##
=======================================
Coverage 93.81% 93.82%
=======================================
Files 20 20
Lines 12216 12223 +7
Branches 2250 2254 +4
=======================================
+ Hits 11461 11468 +7
Misses 574 574
Partials 181 181
Flags with carried forward coverage won't be shown. Click here to find out more.
🚀 New features to boost your workflow:
|
|
Verification that (after fixing it) the new test catches the bug without this fix: |
|
What does this affect? So I think it definitely is a bug, in that we're calling things different nodes that aren't really; but this only affects census nodes: it's not going to change anything about the subsequent simulation. So, it's a pretty minor bug. It'd only affect people who wanted to see how many distinct ancestors there were at a given time using a census event I got curious: how big of an effect is this? Here's a jupyter notebook: |
|
(Note: one might naively hope that adding census nodes literally does not change the output of the simulation, seed-by-seed, except for the census nodes, but this turns out not to be true; I'm not actually sure why.) |
This is almost never the case, and it's rarely worth the effort of figuring out exactly why. I wouldn't worry about it. |
jeromekelleher
left a comment
There was a problem hiding this comment.
I agree, this is the correct approach. Thanks @petrelharp!
Let's drop the inaccurate comment though
|
This code nerd sniped me: thianks to the code pointed to by #2540 I thought I knew how to make this work with DTWF at integer times. That was wrong: the DTWF generation comes after the census event, so the problem there is elsewhere (and more complicated, looks like). But still, this last commit makes the census event a bit more general: it now won't fail if there happens to be a pre-existing node at the given time. I think this is pretty straightforward and not fraught with peril but if we are nervous I could revert to commit n-1 to just get the comment update. |
jeromekelleher
left a comment
There was a problem hiding this comment.
LGTM, happy to merge once we have test coverage at a reasonable level.
abf050d to
e88f959
Compare
and check for existing nodes
e88f959 to
96be30d
Compare


I think this was a conceptual error: all segments in a given lineage at a given time point in the simulation are in the same genome (=node=haplosome), and hence in doing a census event we should assign a single node to each lineage, not each segment.
If we agree, this needs an update to the CHANGELOG (and maybe another test? I'm not sure if we've a good way to test this).
Also note the test that triggers #2540 (but this - I think - fixes).