def test_count_call_alleles__chunked(): rs = np.random.RandomState(0) calls = rs.randint(0, 1, size=(50, 10, 2)) ds = get_dataset(calls) ac1 = count_call_alleles(ds) # Coerce from numpy to multiple chunks in all dimensions ds["call_genotype"] = ds["call_genotype"].chunk(chunks=(5, 5, 1)) # type: ignore[arg-type] ac2 = count_call_alleles(ds) xr.testing.assert_equal(ac1, ac2) # type: ignore[no-untyped-call]
def test_count_call_alleles__chunked(): rs = np.random.RandomState(0) calls = rs.randint(0, 1, size=(50, 10, 2)) ds = get_dataset(calls) ac1 = count_call_alleles(ds) # Coerce from numpy to multiple chunks in all dimensions ds["call_genotype"] = ds["call_genotype"].chunk(chunks=(5, 5, 1)) ac2 = count_call_alleles(ds) assert isinstance(ac2["call_allele_count"].data, da.Array) xr.testing.assert_equal(ac1, ac2)
def test_count_call_alleles__higher_ploidy(): ds = count_call_alleles( get_dataset( [ [[-1, -1, 0], [-1, -1, 1], [-1, -1, 2]], [[0, 1, 2], [1, 2, 3], [-1, -1, -1]], ], n_allele=4, n_ploidy=3, )) ac = ds["call_allele_count"] np.testing.assert_equal( ac, np.array([ [[1, 0, 0, 0], [0, 1, 0, 0], [0, 0, 1, 0]], [[1, 1, 1, 0], [0, 1, 1, 1], [0, 0, 0, 0]], ]), )
def test_count_call_alleles__missing_data(): ds = count_call_alleles( get_dataset([ [[-1, -1], [-1, -1], [-1, -1]], [[-1, -1], [0, 0], [-1, 1]], [[1, 1], [-1, -1], [-1, 0]], [[1, 1], [1, 1], [1, 1]], ])) ac = ds["call_allele_count"] np.testing.assert_equal( ac, np.array([ [[0, 0], [0, 0], [0, 0]], [[0, 0], [2, 0], [0, 1]], [[0, 2], [0, 0], [1, 0]], [[0, 2], [0, 2], [0, 2]], ]), )
def test_count_call_alleles__multi_variant_multi_sample(): ds = count_call_alleles( get_dataset([ [[0, 0], [0, 0], [0, 0]], [[0, 0], [0, 0], [0, 1]], [[1, 1], [0, 1], [1, 0]], [[1, 1], [1, 1], [1, 1]], ])) ac = ds["call_allele_count"] np.testing.assert_equal( ac, np.array([ [[2, 0], [2, 0], [2, 0]], [[2, 0], [2, 0], [1, 1]], [[0, 2], [1, 1], [1, 1]], [[0, 2], [0, 2], [0, 2]], ]), )
def test_count_call_alleles__single_variant_single_sample(): ds = count_call_alleles(get_dataset([[[1, 0]]])) ac = ds["call_allele_count"] np.testing.assert_equal(ac, np.array([[[1, 1]]]))