Skip to content

Commit

Permalink
Add threshold for state probabilities
Browse files Browse the repository at this point in the history
  • Loading branch information
szhan committed Feb 6, 2024
1 parent b1643e9 commit 4906434
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion python/tests/beagle_numba.py
Original file line number Diff line number Diff line change
Expand Up @@ -391,6 +391,10 @@ def interpolate_allele_probs(sm, ref_h, typed_pos, untyped_pos, typed_cm, untype
else:
probs[i, a] += w * sm[k - 1, j]
probs[i, a] += (1 - w) * sm[k, j]
# Zero trivial probabilities.
# TODO: Investigate whether this arbitrary threshold matters.
_THRESHOLD = min(0.005, 1 / h)
probs[probs < _THRESHOLD] = 0
# Rescale probabilities.
# TODO: Check if this is necessary. Could this be a subtle source of error?
probs_rescaled = probs / np.sum(probs, axis=1)[:, np.newaxis]
Expand All @@ -399,7 +403,7 @@ def interpolate_allele_probs(sm, ref_h, typed_pos, untyped_pos, typed_cm, untype

def get_map_alleles(allele_probs):
"""
Compute the maximum a posteriori alleles at ungenotyped markers of a query haplotype,
Compute maximum a posteriori alleles at the ungenotyped markers of a query haplotype,
based on posterior marginal allele probabilities.
The imputed alleles is an array of size x.
Expand Down

0 comments on commit 4906434

Please sign in to comment.