Skip to content

Preserve genotype values and annotations when computing Dask arrays - #461

Open
antonsoo wants to merge 1 commit into
cggh:masterfrom
antonsoo:fix/genotype-dask-compute-order
Open

antonsoo wants to merge 1 commit into
cggh:masterfrom
antonsoo:fix/genotype-dask-compute-order

Conversation

@antonsoo

Copy link
Copy Markdown

Computing a genotype array or vector with a mask or phasing annotation currently fails:

import numpy as np
import allel

g = allel.GenotypeDaskArray(np.array([[[0, 1], [1, 1]]], dtype="i1"))
g.mask = [[False, True]]
g.is_phased = [[True, False]]
r = g.compute()  # before: TypeError, because annotation flags are used as genotypes

da.compute returns values, mask and phasing in the requested order, but the wrapper consumes them from the end. Consume from the front instead. The result retains the original integer genotypes, mask and phasing; unannotated computation is unchanged.

Regressions cover arrays/vectors, haploid/diploid/triploid calls, missing calls and all four annotation combinations. Eighteen cases fail before and all 24 pass after.

Also replayed 512 observed 1000 Genomes chromosome-22 variants across 2,504 samples through Zarr, three chunk layouts, slices and vectors. All 39 wrapper cases pass here versus nine on main and released 1.3.13. Values and observed phase flags match an independent VCF parser. A deliberately constructed QC mask, allele counts and pairwise diversity match independent NumPy calculations. Twelve existing direct-count controls stay unchanged.

Validation: full Python 3.12 / NumPy 1.26 suite passes, 905 tests; Python 3.10 / NumPy 2.2 Dask tests and the same recorded-data workload also pass. CI lint passes. This is independent of the copy repair in #460.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant