You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
mutate fails with a large number of mutations per site #806
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?
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?
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.
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?
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...
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?
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
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)
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...
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!
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...
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;
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.
Activity
petrelharp commentedon Sep 6, 2019
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 msprimeandpip uninstall tskituntil you don't have any versions left, thenpip installthem again) and see if this still happens? If so, then tell us: how big is the tree sequence? (Tell mets.sequence_lengthandts.num_edgesandmax(ts.tables.nodes.time).) And, what operating system are you using?santaci commentedon Sep 6, 2019
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_lengthis51304566.0, thenum_edgesis6250589, and themax(nomu_nonWF.tables.nodes.time)is58016.0.The operating system I am working under is macOS Mojave v. 10.14.5.
petrelharp commentedon Sep 6, 2019
Hm, just to make sure - does it still say the error is in
core.cat line 413? And, what istskit.__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?
santaci commentedon Sep 9, 2019
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...
petrelharp commentedon Sep 9, 2019
Thanks. I get the same error! Will investigate.
petrelharp commentedon Sep 9, 2019
One small note: you said it only had one mutation, but actually it has 32,460 at 4,625 sites:
... which should be fine, but thought you'd want to know.
petrelharp commentedon Sep 9, 2019
Ah-ha: in fact you've got like 5,000 mutations at each of five sites:
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?
[-]overlaying neutral mutations on a tree with a single mutation already on it[/-][+]mutate fails with a large number of mutations per site[/+]petrelharp commentedon Sep 9, 2019
Here's a MWE:
which produces
Also note that the
chunk_sizeis 8192 but in this example thesizeis 480000.santaci commentedon Sep 9, 2019
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!
petrelharp commentedon Sep 9, 2019
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!
petrelharp commentedon Sep 9, 2019
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_getneeds to actually handle the case thatsize >= 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...
jeromekelleher commentedon Sep 11, 2019
I think this is a bug all right @petrelharp, and you're right,
tsk_blkalloc_getprobably 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;petrelharp commentedon Sep 11, 2019
Alternatively, we could just
mallocit.jeromekelleher commentedon Sep 11, 2019
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.
Fixed memory allocation error in mutgen.
Fixed memory allocation error in mutgen.
Fixed memory allocation error in mutgen.