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
Allow truncated samples (with missing data to left and right) #153
I think it shouldn't be too hard to allow samples with missing data, presumably marked as a variant whose allelic state is set to tskit.NULL using the current notation this would be an allelic state equal to constants.UNKNOWN_ALLELE e.g.
Allowing missing sites in the zarr storage would require setting sites.genotypes to dtype=np.int8 rather than np.uint8, but I guess that's fine. It would need a bit of hacking to pass the various error checks, and to skip matching that bit of the sample against the ancestors. But we have the code to do that for ancestor matching anyway, so I assume it would be a reasonably easy change.
(modified to reflect the fact that we currently use tsinfer.constants.UNKNOWN_ALLELE == 255)
I'm happy to code this up, if @jeromekelleher gives it the go-ahead.
One other thing we would need to do is to adjust the generate_ancestors() step to account for missing values. I don't think this would be too difficult though.
We need to allow constants.UNKNOWN_ALLELE in add_sites in the SampleData method, without having to specify it in the alleles array. This should work whether the value for constants.UNKNOWN_ALLELE is negative or positive. DONE, including tests
The ancestor building process needs to know about constants.UNKNOWN_ALLELE when deciding on consensus variants - this includes how to deal with them in the error buffer. PARTIALLY DONE
Any ancestral haplotypes that contain a break, such that the focal sites are separated by a region where none of the derived samples have data, should be split into separate ancestral haplotypes. (on consultation with Jerome, I think we don't need to do this. If the user presents us with samples that have missing chunks in the middle of an otherwise contiguous haplotype, we should simply assume that there is good reason to assume they are indeed on the same haplotype)
We need to check that the Li & Stevens process allows missing data, both (a) in the reference panel against which matches occur, and (b) in the haplotype which we are trying to match. NOT DONE
When matching the samples, we should only match in the region from the leftmost known allele to the rightmost known allele (unknown sites in-between are tackled by 2. above). DONE with tests, using the trim_region function
When mapping the inference sites back to original sites (in get_samples_tree_sequence()), we need to trim the edges in the produced tree sequence such that if there is an entirely unknown region to the left or right (no data for any of the samples), then there is no tree in that region. I think it should, however, be OK to have a tree in a leftmost region if there are non-inference sites there. DONE, including tests
Activity
hyanwong commentedon Jun 14, 2019
I'm happy to code this up, if @jeromekelleher gives it the go-ahead.
One other thing we would need to do is to adjust the
generate_ancestors()step to account for missing values. I don't think this would be too difficult though.jeromekelleher commentedon Jun 15, 2019
There's a general issue about how to represent missing data in tskit over here. We'd want to use the same encoding here whichever way we do it.
But yes, definitely something we want to support; thanks!
hyanwong commentedon Jun 21, 2019
Just some notes about my current implementation (at https://github.com/hyanwong/tsinfer/tree/allow-UNKNOWN_ALLELE-in-samples).
constants.UNKNOWN_ALLELEin add_sites in the SampleData method, without having to specify it in theallelesarray. This should work whether the value forconstants.UNKNOWN_ALLELEis negative or positive. DONE, including testsconstants.UNKNOWN_ALLELEwhen deciding on consensus variants - this includes how to deal with them in the error buffer. PARTIALLY DONEAny ancestral haplotypes that contain a break, such that the focal sites are separated by a region where none of the derived samples have data, should be split into separate ancestral haplotypes.(on consultation with Jerome, I think we don't need to do this. If the user presents us with samples that have missing chunks in the middle of an otherwise contiguous haplotype, we should simply assume that there is good reason to assume they are indeed on the same haplotype)get_samples_tree_sequence()), we need to trim the edges in the produced tree sequence such that if there is an entirely unknown region to the left or right (no data for any of the samples), then there is no tree in that region. I think it should, however, be OK to have a tree in a leftmost region if there are non-inference sites there. DONE, including testsjeromekelleher commentedon Jun 21, 2019
Sounds great, thanks Yan!
[-]Allow samples with missing data[/-][+]Allow truncated samples (with missing data to left and right)[/+]hyanwong commentedon Feb 7, 2020
Replaced with #224