Description
This would be a useful thing to have, because some things we might want to have about ancestors (e.g. spatial location) is stored in the individual table, not in the node table.
But, if we do this, we need to think some things through:
-
Currently, we said that the individual table was in 1-to-1 mapping with the currently alive individuals. We could change this by adding an "alive" flag (either in metadata or in the flags column).
-
It was unclear what was meant by some properties (e.g.,
ageandposition) for non-alive individuals. I guess what they would mean is "whatever they were when the individuals got Remembered", which seems fine and consistent. We'd need a policy for what happens if someone got remembered twice (keep their data from the first time, maybe?).
Currently, we make the individual table anew whenver outputting the tree sequence. If we remember individuals, it would be easiest if the remembered individuals were always the first ones: then we would not have to ever update the individual property of the remembered nodes; when remembering new individuals, we would just append them on the end of the remembered-individual-table.
Proposal:
- Keep a separate
remembered_individual_table. - Whenever individuals are remembered, we check if they already are remembered, and if not, append them to the
remembered_individual_tableand append their nodes to the list of remembered node IDs. - Simplifying requires nothing new, because simplification does not (currently) touch the individual property of the node table, so retained nodes will still point to the right individuals. (need to check that simplify actually preserves the information, though)
- On writing out tables, an individual table is added to the table collection by first copying in the
remembered_individual_table, then adding on all alive individuals who aren't already remembered,
and setting thealiveflag in all of these.
Note that we need an alive flag to cover the case where some individuals are both alive and remembered. (Well, if we were willing to rearrange the individual table, then we could guarantee that all alive individuals came at the end of the table, so we'd only need to store how may there were, but it seems cleaner to store the flag and not have to rearrange the table.)
Activity
bhaller commentedon Jul 4, 2018
There is also a bit of an odd question when it comes to individuals that are both remembered and alive. Does their entry contain the information at the time point when they were remembered, even if it has subsequently changed? Presumably not – presumably entries for living individuals contain the current information for those individuals. So then once that individual dies, does its entry then revert to the information that was present at the time it was remembered? That's pretty weird. There is always this tension, with the tree-seq tables, with mutable information, unfortunately. Between "up to date info" versus "info at time of recording".
petrelharp commentedon Jul 4, 2018
Oh dear - yes, it has to, to make loading back in of the
.treesfile work. So, then I propose that the policy be that the most recent time they were remembered (which includes writing out the tree sequence file!) be what is recorded in the individual table.bhaller commentedon Jul 4, 2018
Are you proposing that writing out a file would permanently remember all of the extant individuals, as if treeSeqRememberIndividuals() had been called on them? Or just that they would be considered "remembered" in terms of this most of "most recent time remembered", for what info gets written out?
petrelharp commentedon Jul 4, 2018
I guess I'm proposing:
Individuals would only be part of the individual table forevermore (i.e., permanently remembered) if
treeSeqRememberIndividuals()had been called on them. Usually, these individuals would have information as it was at the time thattreeSeqRememberIndividuals()was called. However, I am proposing that if a permanently remembered individual is alive when the tree sequence is written out to file, then their information will be whatever it is at that time.However, if a tree sequence is written out again in the future when that individual is not alive, then their information in the individual table will be as it was when
treeSeqRememberIndividualswas called, because that's what's in theremembered_individual_table, and the output individual table starts from a copy of this. We'd at least be able to tell this had happened, because in the tree sequence produced by the first call, the individual is marked asalive.For example:
Generation 10: remember individual 1, who is age 3.
remembered_individual_table, individual 1 is age 3.Generation 12: output tree sequence; individual 1 is still alive.
remembered_individual_table, individual 1 is age 3.aliveGeneration 20: output tree sequence, individual 1 has died.
remembered_individual_table, individual 1 is age 3.alive.bhaller commentedon Jul 5, 2018
Yes, I think this is the way it needs to work. It's a bit strange, but seems best overall.
bhaller commentedon Aug 16, 2018
OK, reviewing this. You wrote:
So individual 1 is in
remembered_individual_table, recorded with an age of 3, and your proposal is that the output table would always begin withremembered_individual_table. So I guess you are proposing that the output table would contain individual 1 at its assigned position near the beginning, within theremembered_individual_tablesection, but that its age entry would get patched, at save time, with its current age at time of saving, and itsaliveflag would be patched totrue(whereas entries in theremembered_individual_tablewould presumably all havefalse, so that we don't have to maintain those values as the simulation runs)? Does this sound right?petrelharp commentedon Aug 17, 2018
Yes, exactly.
petrelharp commentedon Sep 26, 2018
Oh! We did this!