Skip to content

Commit c359718

Browse files
committed
Use sgkit.distarray for Hardy-Weinberg Equilibrium
1 parent c552a84 commit c359718

File tree

3 files changed

+4
-5
lines changed

3 files changed

+4
-5
lines changed

.github/workflows/cubed.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,4 +30,4 @@ jobs:
3030
3131
- name: Test with pytest
3232
run: |
33-
pytest -v sgkit/tests/test_aggregation.py -k 'test_count_call_alleles or test_sample_stats or (test_count_variant_alleles and not test_count_variant_alleles__chunked[call_genotype]) or (test_variant_stats and not test_variant_stats__chunks[chunks2-False])' --use-cubed
33+
pytest -v sgkit/tests/test_{aggregation,hwe}.py -k 'test_count_call_alleles or test_hwep or test_sample_stats or (test_count_variant_alleles and not test_count_variant_alleles__chunked[call_genotype]) or (test_variant_stats and not test_variant_stats__chunks[chunks2-False])' --use-cubed

sgkit/stats/aggregation.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -457,9 +457,8 @@ def genotype_coords(
457457
G = da.map_blocks(_index_as_genotype, X, K, new_axis=1, chunks=chunks)
458458
# allow enough room for all alleles and separators
459459
dtype = "|S{}".format(max_chars * ploidy + ploidy - 1)
460-
S = da.map_blocks(
461-
genotype_as_bytes, G, False, max_chars, drop_axis=1, dtype=dtype
462-
).astype("U")
460+
S = da.map_blocks(genotype_as_bytes, G, False, max_chars, drop_axis=1, dtype=dtype)
461+
S = da.astype(S, "U{}".format(max_chars * ploidy + ploidy - 1))
463462
new_ds = create_dataset({variables.genotype_id: ("genotypes", S)})
464463
ds = conditional_merge_datasets(ds, new_ds, merge)
465464
if assign_coords:

sgkit/stats/hwe.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
from typing import Hashable, Optional
22

3-
import dask.array as da
43
import numpy as np
54
from xarray import Dataset
65

6+
import sgkit.distarray as da
77
from sgkit import variables
88
from sgkit.accelerate import numba_jit
99
from sgkit.stats.aggregation import count_variant_genotypes

0 commit comments

Comments
 (0)