Skip to content

Add store_segments=True and store_pairs=True to the ibd_segments method #1712

Closed

Description

@jeromekelleher

See #1708 for more background on the ibd_segments method (currently find_ibd)

The idea here is that the IbdSegments gives us access to useful simple summaries of the IBD segments, which may be all we need for some purposes. Then, storing the segments (or indeed, even the pairs) would be unnecessary and we'd save a lot of time an memory by not storing them.

If store_pairs is false, store_segments is also necessarily false. We'd have to be careful about the semantics of the IdbSegments class in these cases, but I think the simplest and most logical thing to do would be to raise an error if someone tries to access information that hasn't been stored.

Then, we could argue about what the defaults should be.

Any thoughts @gtsambos @petrelharp ?

Activity

  1. added this to the Python 0.3.8 milestone on Sep 16, 2021
  2. gtsambos commented on Sep 17, 2021

    @gtsambos
    Member

    This also sounds good to me, though I'll probably have a few more questions about the semantics too. I'm not totally clear on how you could have store_segments=True with store_pairs=False -- don't you need to know the pair to lookup the segments?

  3. jeromekelleher commented on Sep 17, 2021

    @jeromekelleher
    MemberAuthor

    Yes, you're right, store_segments implies store_pairs.

  4. gtsambos commented on Sep 17, 2021

    @gtsambos
    Member

    Ah sorry, I think I meant this the other way around -- but i can actually see some applications when just the pairs and not the segments might be wanted.

  5. jeromekelleher commented on Sep 17, 2021

    @jeromekelleher
    MemberAuthor

    If store_segments is False and store_pairs is True, then we keep a segment_list for each pair (we find an IBD segment for), but we only update the running totals of num_segments and total_span instead of actually storing the segments themselves. This would save a lot of memory.

  6. petrelharp commented on Sep 17, 2021

    @petrelharp
    Contributor

    Sounds good to me! Since it'll be qutie easy to get a very big object, I'd suggest that store_segments default to False, so that people can first run the method to see how many segments they'd get at a given threshold and then turn on storing segments to actually get them.

  7. jeromekelleher commented on Sep 17, 2021

    @jeromekelleher
    MemberAuthor

    Great, that's exactly what I was thinking.

  8. gtsambos commented on Sep 17, 2021

    @gtsambos
    Member

    Can we guesstimate (or give a sensible lower bond) for the size the object based on the number of pairs and segments? That might be more useful than just the number of segments since I imagine that's the constraint that users will be thinking about.

  9. petrelharp commented on Sep 17, 2021

    @petrelharp
    Contributor

    That seems like a very tricky thing to do in general...

  10. jeromekelleher commented on Sep 18, 2021

    @jeromekelleher
    MemberAuthor

    That's easy I think - we know how many segments and pairs there are and we know how much memory each one takes. We could do this in Python as part of the __str__ implementation. Probably best do it as a follow up though.

  11. added 3 commits that reference this issue on Oct 8, 2021
    49cd0e1
    408980c
    e47f3be
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

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions