Skip to content

Commit 1af6343

Browse files
Remove check on PL values when computing local alleles
1 parent 3d7bfec commit 1af6343

File tree

1 file changed

+0
-30
lines changed

1 file changed

+0
-30
lines changed

bio2zarr/vcf2zarr/icf.py

Lines changed: 0 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -540,36 +540,6 @@ def bincount_nonzero(arr, *, minlength):
540540
bincount_nonzero, axis=1, arr=depths, minlength=allele_count
541541
)
542542
allele_counts += depths_allele_counts
543-
if "PL" in variant.FORMAT:
544-
likelihoods = variant.format("PL")
545-
likelihoods.clip(0, None, out=likelihoods)
546-
# n is the indices of the nonzero likelihoods
547-
n = np.tile(np.arange(likelihoods.shape[1]), (likelihoods.shape[0], 1))
548-
assert n.shape == likelihoods.shape
549-
n[likelihoods <= 0] = 0
550-
ploidy = variant.ploidy
551-
552-
if ploidy == 1:
553-
a = n
554-
b = np.zeros_like(a)
555-
elif ploidy == 2:
556-
# We have n = b(b+1) / 2 + a
557-
# We need to compute a and b
558-
b = np.ceil(np.sqrt(2 * n + 9 / 4) - 3 / 2).astype(int)
559-
a = (n - b * (b + 1) / 2).astype(int)
560-
else:
561-
# TODO: Handle all possible ploidy
562-
raise ValueError(f"Cannot handle ploidy = {ploidy}")
563-
564-
a_counts = np.apply_along_axis(
565-
np.bincount, axis=1, arr=a, minlength=allele_count
566-
)
567-
b_counts = np.apply_along_axis(
568-
np.bincount, axis=1, arr=b, minlength=allele_count
569-
)
570-
assert a_counts.shape == b_counts.shape == allele_counts.shape
571-
allele_counts += a_counts
572-
allele_counts += b_counts
573543

574544
allele_counts[:, 0] = 0 # We don't count the reference allele
575545
max_row_length = 1

0 commit comments

Comments
 (0)