Skip to content

Have treeSeqRememberIndividuals actually remember individuals? #10

Closed

Description

@petrelharp

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:

  1. 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).

  2. It was unclear what was meant by some properties (e.g., age and position) 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:

  1. Keep a separate remembered_individual_table.
  2. Whenever individuals are remembered, we check if they already are remembered, and if not, append them to the remembered_individual_table and append their nodes to the list of remembered node IDs.
  3. 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)
  4. 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 the alive flag 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

  1. bhaller commented on Jul 4, 2018

    @bhaller
    Contributor

    We'd need a policy for what happens if someone got remembered twice (keep their data from the first time, maybe?).

    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".

  2. petrelharp commented on Jul 4, 2018

    @petrelharp
    CollaboratorAuthor

    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.

    Oh dear - yes, it has to, to make loading back in of the .trees file 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.

  3. bhaller commented on Jul 4, 2018

    @bhaller
    Contributor

    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.

    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?

  4. petrelharp commented on Jul 4, 2018

    @petrelharp
    CollaboratorAuthor

    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 that treeSeqRememberIndividuals() 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 treeSeqRememberIndividuals was called, because that's what's in the remembered_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 as alive.

    For example:

    1. Generation 10: remember individual 1, who is age 3.

      • in remembered_individual_table, individual 1 is age 3.
    2. Generation 12: output tree sequence; individual 1 is still alive.

      • in remembered_individual_table, individual 1 is age 3.
      • in the output tables, individual 1 is age 5 and marked as alive
    3. Generation 20: output tree sequence, individual 1 has died.

      • in remembered_individual_table, individual 1 is age 3.
      • in the output tables, individual 1 is age 3 and not marked as alive.
  5. bhaller commented on Jul 5, 2018

    @bhaller
    Contributor

    Yes, I think this is the way it needs to work. It's a bit strange, but seems best overall.

  6. bhaller commented on Aug 16, 2018

    @bhaller
    Contributor

    OK, reviewing this. You wrote:

    Generation 12: output tree sequence; individual 1 is still alive.
    in remembered_individual_table, individual 1 is age 3.
    in the output tables, individual 1 is age 5 and marked as alive

    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 with remembered_individual_table. So I guess you are proposing that the output table would contain individual 1 at its assigned position near the beginning, within the remembered_individual_table section, but that its age entry would get patched, at save time, with its current age at time of saving, and its alive flag would be patched to true (whereas entries in the remembered_individual_table would presumably all have false, so that we don't have to maintain those values as the simulation runs)? Does this sound right?

  7. petrelharp commented on Aug 17, 2018

    @petrelharp
    CollaboratorAuthor

    Yes, exactly.

  8. petrelharp commented on Sep 26, 2018

    @petrelharp
    CollaboratorAuthor

    Oh! We did this!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions