[vds] Fix local_to_global to support non-ascending local alleles#12543
[vds] Fix local_to_global to support non-ascending local alleles#12543danking merged 3 commits intohail-is:mainfrom
Conversation
| @@ -82,21 +82,18 @@ def local_to_global(array, local_alleles, n_alleles, fill_value, number): | |||
| ------- | |||
There was a problem hiding this comment.
We should have an example that uses the fields of a VDS. Do we have a VDS in the tests we can use for that purpose?
There was a problem hiding this comment.
don't have a vds in tests, nope.
There was a problem hiding this comment.
per the slack thread, I really want to hide this behind a packaged option in to_dense_mt or something to reindex multiple fields
| assert hl.eval(hl.vds.local_to_global(lad, local_alleles, 4, 0, number='R')) == [1, 9, 0, 10] | ||
| assert hl.eval(hl.vds.local_to_global(lpl, local_alleles, 4, 999, number='G')) == [1001, 1002, 1005, 999, 999, 999, 1004, 1003, 999, 0] | ||
|
|
||
| assert hl.eval(hl.vds.local_to_global([0, 1, 2, 3, 4, 5], [0, 2, 1], 3, 0, number='G')) == [0, 3, 5, 1, 4, 2] No newline at end of file |
There was a problem hiding this comment.
Hmm. I think I'm missing something. Do I have a step wrong here:
1, as a local GT triangle number, definitionally equivalent to0/1in local alleles which is0/2in global alleles (LA[1] == 2in this example)2in global GT triangle number.
local genotypes triangle numbers:
0 1 2
3 4
5
local genotypes as local alleles:
0/0 0/1 0/2
1/1 1/2
2/2
local genotypes as global alleles:
0/0 0/2 0/1
2/2 2/1
1/1
local genotypes as global triangle numbers:
0 2 1
5 4
3
There was a problem hiding this comment.
The triangles go the other way:
0/0
0/1 1/1
0/2 1/2 2/2
0
1 2
3 4 5
The intuition here is that the addition of a 2 allele shouldn't affect any indices of calls involving only 0 and 1 alleles.
Fixes #12534