Skip to content

mutate fails with a large number of mutations per site #806

Closed

Description

@santaci

Hello there, I have a treeseq I've produced in slim with a single mutation which is under selection. I've been trying to overlay neutral mutations upon that tree but without any success in keeping the aforementioned selected mutation.

Briefly, if I do the following after loading in my tree with pyslim:
nonWF_mut = msprime.mutate(nomu_nonWF, rate=2.36e-8, random_seed=1, keep=True)
I obtain the following error:
Assertion failed: (size < self->chunk_size), function tsk_blkalloc_get, file lib/subprojects/tskit/tskit/core.c, line 413.
Abort trap: 6

If I adjust my overlaying of mutations to keep=False then it works fine. Unfortunately for what I'm trying to model, keeping the mutation is crucial. Any ideas as to what may be causing me to get the above error message?

Activity

  1. petrelharp commented on Sep 6, 2019

    @petrelharp
    Contributor

    Oh dear, that's something to do with memory management. First, could you do a fresh install (if you installed with pip, first pip uninstall msprime and pip uninstall tskit until you don't have any versions left, then pip install them again) and see if this still happens? If so, then tell us: how big is the tree sequence? (Tell me ts.sequence_length and ts.num_edges and max(ts.tables.nodes.time).) And, what operating system are you using?

  2. santaci commented on Sep 6, 2019

    @santaci
    Author

    Oh dear, that's something to do with memory management. First, could you do a fresh install (if you installed with pip, first pip uninstall msprime and pip uninstall tskit until you don't have any versions left, then pip install them again) and see if this still happens? If so, then tell us: how big is the tree sequence? (Tell me ts.sequence_length and ts.num_edges and max(ts.tables.nodes.time).) And, what operating system are you using?

    So I have successfully uninstalled both msprime and tskit and have reinstalled them I get the same error unfortunately.

    The treeseq file itself is 233 MB. The sequence_length is 51304566.0, the num_edges is 6250589, and the max(nomu_nonWF.tables.nodes.time) is 58016.0.

    The operating system I am working under is macOS Mojave v. 10.14.5.

  3. petrelharp commented on Sep 6, 2019

    @petrelharp
    Contributor

    Hm, just to make sure - does it still say the error is in core.c at line 413? And, what is tskit.__version__? In 0.2.2 that assert does not appear at line 413, so I'm suspicious.

    But, I think we'll need the tree sequence to debug. Could you post the slim script and its random seed, if it didn't take too long to run, or else put the tree sequence somewhere downloadable?

  4. santaci commented on Sep 9, 2019

    @santaci
    Author

    Hi Peter,
    Yes, it's definitely at line 413, even after uninstalling and reinstalling msprime and tskit...
    The tree is a product of two slim models and the tree itself takes a bit of time to produce. I've provided a shareable link to the tree instead: https://drive.google.com/file/d/1HciOU2poVBia6qhBIxBWKgjc1o0PTtON/view?usp=sharing

    Having looked at the number of sites and mutations there seems to be something off. There might be an issue when I try to remove mutations from the tree in Slim...

  5. petrelharp commented on Sep 9, 2019

    @petrelharp
    Contributor

    Thanks. I get the same error! Will investigate.

  6. petrelharp commented on Sep 9, 2019

    @petrelharp
    Contributor

    One small note: you said it only had one mutation, but actually it has 32,460 at 4,625 sites:

    >>> ts.num_mutations
    32460
    >>> ts.num_sites
    4625
    

    ... which should be fine, but thought you'd want to know.

  7. petrelharp commented on Sep 9, 2019

    @petrelharp
    Contributor

    Ah-ha: in fact you've got like 5,000 mutations at each of five sites:

    >>> for s in ts.sites():
    ...   if len(s.mutations) > 1:
    ...     print("{} mutations at position {}".format(len(s.mutations), s.position))
    ... 
    5402 mutations at position 1447849.0
    5223 mutations at position 6294365.0
    5885 mutations at position 32360744.0
    5820 mutations at position 38770781.0
    5510 mutations at position 45020664.0
    

    This shouldn't cause an error, but it does (a bug, we'll fix it). But in the meantime: did you mean for this to happen?

  8. changed the title [-]overlaying neutral mutations on a tree with a single mutation already on it[/-] [+]mutate fails with a large number of mutations per site[/+] on Sep 9, 2019
  9. petrelharp commented on Sep 9, 2019

    @petrelharp
    Contributor

    Here's a MWE:

    t = msprime.simulate(2).tables
    t.sites.add_row(0.5, '')
    p = -1
    for j in range(5000):
        p = t.mutations.add_row(0, 0, bytes(j), p)
    
    ts = t.tree_sequence()
    msprime.mutate(ts, rate=1e-8, random_seed=1, keep=True)
    

    which produces

    python3: lib/subprojects/tskit/tskit/core.c:413: tsk_blkalloc_get: Assertion `size < self->chunk_size' failed.
    Aborted
    

    Also note that the chunk_size is 8192 but in this example the size is 480000.

  10. santaci commented on Sep 9, 2019

    @santaci
    Author

    No, actually I realised that I hadn't been removing mutations as I thought I had which is probably why I've ended up with several mutations on a few sites.

    In fact, now that I've edited my code to actually remove these unwanted neutral mutations, although this seems to be on the SLiM side of things, I come across this:
    add_mutation: Table column too large; cannot be more than 2**31 bytes.
    Which is strange since I'm attempting to remove mutations rather than add them..

    In any case it's good to know that the bug was coming from having too many mutations per site and that I have to troubleshoot on the SLiM side of things now...

    Thank you very much for looking into this!

  11. petrelharp commented on Sep 9, 2019

    @petrelharp
    Contributor

    In fact, now that I've edited my code to actually remove these unwanted neutral mutations, although this seems to be on the SLiM side of things, I come across this:
    add_mutation: Table column too large; cannot be more than 2**31 bytes.

    Ah-ha, another thing that you probably don't really want here, but we're working on fixing. I think you may want to look for help on the SLiM mailing list with your recipe. Thanks for the report!

  12. petrelharp commented on Sep 9, 2019

    @petrelharp
    Contributor

    I'm not sure what to do about this, @jeromekelleher - the block size on the allocator is determined here and the error occurs here. Maybe just tsk_blkalloc_get needs to actually handle the case that size >= chunk_size?

    And, do we need to actually fix this? I think so: although @santaci didn't mean to do this, it seems not unreasonable that someone might really want to in the future...

  13. jeromekelleher commented on Sep 11, 2019

    @jeromekelleher
    Member

    I think this is a bug all right @petrelharp, and you're right, tsk_blkalloc_get probably needs to support allocs > size. In principle this should be possible, but it could be subtle and tricky to actually do. Probably the right thing to do is to just look at the incoming mutations and make an appropriate block size based on that;

  14. added this to the Release 0.7.2 milestone on Sep 11, 2019
  15. petrelharp commented on Sep 11, 2019

    @petrelharp
    Contributor

    Alternatively, we could just malloc it.

  16. jeromekelleher commented on Sep 11, 2019

    @jeromekelleher
    Member

    Alternatively, we could just malloc it.

    Or we could do that. Getting everything airtight in terms of error handling can be tricky though: part of the attraction of using the block allocator is that it makes cleaning up in the case of failures a lot easier.

  17. added 3 commits that reference this issue on Dec 4, 2019
    3398789
    1438af8
    8e57d9c
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

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions