Repository navigation
First pass at solving #25 - #40
Conversation
|
I've just pushed the addition of the [isSample = T] parameter to treeSeqRememberIndividuals() so you can play around with that. Note "isSample" not "is_sample"; the Eidos APIs use camelCase. |
|
Thanks! I'll wait until Peter is around before actually implementing anything, I think - I don't want to risk going down a blind alley. |
|
Hey, @hyanwong; are you still doing something with this pull request, or can it be closed? |
|
Thanks for reminding me! I would still like this, and will add it to my long list. I'm hopefully seeing @petrelharp in early october, so might have time to chat to him about this then (sorry for leaving this dangling - lots of other tskit development on my plate at the moment). |
|
OK, no worries. :-> |
|
Hey @hyanwong. Figured I'd do my yearly check with you that you still want this PR here. ;-> |
😆 - I will ask @petrelharp if this is still the best solution. |
|
Hah, how about that. This does seem quite useful, and is a nice simple solution to the problem! I don't see anything wrong with it or anticipate problems with the scheme, although I could be forgetting some wrinkle. |
|
So where does that leave us? Should this PR get rebased and merged? Is there more to be done with it? |
|
I think that this PR just describes the solution, but doesn't implement it. (and we should also test it somehow...) |
Yes, I think that's right. It's just a description. Should I work this up into an actually coded PR, as @petrelharp thinks it is the right approach? |
Ah, I see. As you can tell, I haven't been paying close attention. :-> At present, I have no particular opinion on this, since I don't really know what it is or what problem it would solve for people. :-> Should I now take the time to inform myself about it? Among the things I'm not clear on is whether this has any significant impact on SLiM itself, or if we're just adding a flag in SLiM for later use on the tskit side. If it's the latter, then I'm not sure I necessarily need to wrap my head around all the details...? Sorry, been a bit swamped lately so I'm trying to keep things off my plate to the extent practicable. :-> |
|
Here's a quick summary: currently, the tree sequence keeps around old nodes but not their corresponding individuals. So if someone wants to know what the spatial location (for instance) of some ancestor in the trees was, they'd have to explicitly Remember that individual... and so they'd have to probably Remember everyone, ever, which gets infeasible quickly. Yan is proposing to make it so people can optionally ask to keep around as well those individuals associated with nodes. The most common use case I would think would be to just run Quicker summary: I'm convinced it's a good idea, and the effect will be an optional increase in memory usage (like maybe making tables 10% or 20% bigger?). It will also affect the precise details of how the table curation works, but not much. |
|
Thinking about this a bit more, it seems like this would be better as just an option to |
I see. This synopsis is very helpful, thanks. I could certainly add that option to So. If we're going to put the option on And is this going to actually happen now-ish? If so, I'm happy to make the necessary changes to |
|
Thanks @petrelharp - what you say sounds very sensible. Sorry for the slackness on my part following this up. I guess we could wipe this PR and just incorporate by hand/eye anything I've written in the docs that's still useful? It sounds like Peter and you know how to implement this - is that right? Do I need to do anything, other than look over documentation etc? |
|
Well, I've not got the bandwidth to do this right now... |
I know how to do the Eidos front end for it, if @petrelharp knows how to do the internals. :-> |
OK, let's put it back on the back burner until you do, then, as I certainly don't know how to do the internal bits of it. :-> So, see y'all next year? :-> |
|
I've just been chatting to @mmosmond who might be able to help with this. Or to prod me into doing something about it :) |
|
@bhaller and @petrelharp - @mmosmond had prodded me enough to take a crack at this, but I would need a few pointers to get started. In particular, where in the codebase should I add individuals to the tables? A quick glance through the codebase suggests in SLiMSim::RecordNewGenome, where the comment says "This records information about an individual" - although the code only appears to change the node and edge tables, and doesn't currently add anything to the individuals table. If I add to the individuals table in that function, then I presumably have to check, when explicitly adding individuals via SLiMSim::AddIndividualsToTable, whether the individuals are in the table already, so I don't add them twice, but just change the flags on existing individuals. How do I do this? For the SLiM API, I'm assuming that I set some sort of flag on the When I know what the way forward is, I'll amend the current PR to document what I think it the suggested new behaviour. |
|
That does seem like a good place to do it, I agree. And, that's the right place to do it, because that's when the individual is brand-new, so we don't need to check if they're already in the table, I think. The AddIndividualsToTable method already checks if the individuals are already present, so for efficiency we'll probably want to skip that somehow. I think a good first step would be to amend the implementation notes to include specification of what happens to individuals without any flags. I think this is easy - just "they stick around" - but maybe I'm not thinking of something. And then go edit the bits of the code that do those things to make sure they do reasonable things with non-flagged individuals? |
Thanks @petrelharp - very useful.
How do we map the IDs of the individuals passed in to
Yes, I agree, I need to rework that file first, also see #130 |
I'm not sure what you mean? If you don't need to check for whether the individuals are already in the table, then all you need to do is to add them to the individual table. If the pedigree ID isn't available yet, that'll be a problem, because you need it to construct the metadata struct, but I think (hope?) it should be at that point? There's no back-referencing to the individual table by SLiM, so you don't need to, e.g., tell SLiM somehow which row in the table you put the individual in. (That sort of referencing happens through the nodes.) |
|
Make sure the PR is working off of an up-to-date base before proceeding; source files got reorganized for the 3.5 release, so if you don't rebase the PR before starting to work you will have a merge from hell later on. The diff in SLiMHelpClasses.rtf will just need to be thrown away and re-created; probably best to save all of the doc changes for the final push on this. The reason is that the internal coding of the RTF file changes whenever it is re-generated from the doc itself (which I do on my end, that's not something you can do), so the diff as it exists in the PR now is worthless and needs to be thrown out. RecordNewGenome() is one possible choice for where to put it, but SetCurrentNewIndividual() might be a better choice – notably, because RecordNewGenome() will be called twice for each new individual (diploidy) whereas SetCurrentNewIndividual() will be called just once. It gets called when a new individual is created. The current reason for its existence is to call RecordTablePosition() to mark the table state prior to recording the new individual, because proposed new individuals can be backed out if a modifyChild() callback returns F; that case will need to be handled correctly. When that happens, RetractNewIndividual() is called. So I would suggest doing whatever recording you need to do in SetCurrentNewIndividual() (note that the genome objects for the new individual are not yet set up at that point, however), and changing RecordTablePosition() to record the position for the individuals table as well, and then making RetractNewIndividual() reset the individual table to the marked position as well. The pedigree ID of the new individual should be set up, yes; it would be in p_individual->pedigree_id_, in SetCurrentNewIndividual(). Of course this work should only happen when a "record all individuals" flag is set, and ideally that flag should only need to be checked one time, in SetCurrentNewIndividual(), to minimize overhead in the case where this feature is not enabled. Generating new individuals is such a tight bottleneck in SLiM that adding the check of a single boolean flag slows SLiM down noticeably, so tread very lightly. Adding the flag to initializeTreeSeq() would be my department; changing the Eidos API for calls is a bit technical. So, let me know here what exactly you want me to do there (what the flag should be named), once you have got the PR rebased to the current GitHub master branch head, and I'll do it. (How do I do it? Can I just check out and commit changes to this pull request? Or do I do a pull request based off of this pull request? I'll probably need a bit of guidance on the Git semantics of this, unaccustomed as I am to public coding. :->) Right now this PR contains changes intended to add a new flag, isSample, to treeSeqRememberIndividuals(). Is that still a part of the design? If not, then this PR doesn't really contain any changes that will be retained going forward, right? But this comment thread is worth keeping. |
I mean, if
Ah, do I add the pedigree ID as metadata when adding to the individuals table then? |
|
This looks great! I don't see any issues, just a bit more testing:
Hm - maybe we should also add the treerec tests to the automatic github tests. |
Great.
Yes, I guess it could. I have some ideas about how to improve the testing code, actually, but maybe we should do this one step at a time? Should I open up another issue?
I don't really know what additions are required for pyslim. I'm not that au-fait with how it all fits together (feeling my way here). Perhaps you could elaborate on the additions @petrelharp ?
I guess that would be useful (and would have picked up that previous segfault bug). They don't take long to run at the moment, and should be even quicker if we parallelize. |
Oh, good - it's kinda ad-hoc at the moment. Up to you whether to implement changes in a separate PR, but we should discuss changes in a separate issue, probably. |
Searching for "remembered" should give a good idea of this. Let's see, looks like
|
Just chiming in to say: the python tests are up to you guys, stage it however makes sense for you, just tell me when to approve the PRs. :->
I don't know whether GitHub Actions provides multiple cores when it's running a job. So parallelizing might not make any difference (might even be a little slower). This sounds like a great idea to me, in any case – it would have been lovely to have that segfault picked up prior to release :-O. I don't know how to make this change, though – @grahamgower set up the GitHib Actions stuff. We also do CI on Travis-CI at present, but I'm moving away from that. GitHub Actions has been doing a great job, and Travis-CI is kind of a disaster ever since they got bought. So don't worry about adding these tests to the Travis-CI jobs, only to the GitHub Actions jobs. |
This is in |
Yes, I just don't really know how it works or how to change it. No doubt that can be deduced, though. :-> |
Only 2 cores are available, according to the docs. Hopefully it's not too hard to see how the current actions workflow runs the tests and just add new lines for any additional tests? |
a795f2e to
dbc45df
Compare
|
OK, I think this is ready for merge. But before merging, check that you are OK with the last commit in this PR, @bhaller , which simply tidies up the formatting of |
Oh geez, thanks for fixing those - a number of them were my fault, and I kept forgetting to rectify that. |
Probably good to have all those space/tab issues resolved – at least in this file. An ongoing minor annoyance. This crops up all over the codebase now because Qt Creator seems to insist on converting tabs to spaces, and seems to have no pref that I can find to prevent it from doing so, aargh. Definitely good for it to be done as a separate commit, thanks for that. I'll merge as soon as @petrelharp has a chance to reply to my latest comment; I'm still worried about the flag values. Are there test(s) in the test suite you guys work with that round-trip tree-sequence files? I.e., run a SLiM sim for a little while, save out a tree sequence, read it in, run it some more, and save out a final TS, compared to simply running and saving without the save/load in the middle, to ensure that the save/load doesn't change anything about the state of the simulation? (Random number seed issues have to be considered of course.) Doing this in conjunction with retaining individuals in each generation would ensure that the retain flag is round-tripping correctly, which would be reassuring. But I'm also worried about the reuse of the same flag value as the old first-gen flag, as I mention in the comment. Is there any reason not to just leave that old value unused, and use a new value for the new flag? |
|
(To be clear, if your test suite doesn't do that kind of round-tripping, I'm not asking that you add such tests now, as part of this PR. My R-based test suite does include round-tripping tests, and I'll be adding new tests that do that in conjunction with "retaining", so this will get tested in the end. I'm just wondering whether you're also testing this in your test suite, mostly out of curiosity. I realized it might sound like I'm asking you to do a bunch more work here, which I'm not. :->) |
Well picked up. I didn't do this sort of testing, and as you point out, I probably should have done. Therefore I'm particularly glad that it might get tested by you :) |
I shall do my best. :-> |
dbc45df to
a8298d9
Compare
|
Better |
|
Merged! Thanks @hyanwong @petrelharp @mmosmond, this is a very nice feature! |
|
There's still a bug in the documentation (here, or maybe it's here, I don't know): should instead be something like |
Oh, how annoying. Thanks for spotting that. Sorry. I was convinced that I had caught all those. @bhaller - what's the best way to fix that. If it's in the pages doc I guess that you can simply adjust it as Peter says? |
|
Hmm, actually, I wonder if we can write it in such a way that it will continue to be true even if (when) we add the |
|
Just fixed it, pushed. Thanks for the catch. |
There's some of this sort of thing in the pyslim tests. Not in the tests that are in |
For discussion with @petrelharp - currently no implementation, only documentation for suggested changes. See #25 (comment)