Skip to content

Commit

Permalink
Minor edits to comments
Browse files Browse the repository at this point in the history
  • Loading branch information
szhan committed Mar 6, 2024
1 parent e8f6de5 commit 2a266c0
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions python/tests/beagle_numba.py
Original file line number Diff line number Diff line change
Expand Up @@ -830,7 +830,7 @@ def compute_individual_scores(
:return: Genotype probabilities and allele dosages.
:rtype: tuple(numpy.ndarray, numpy.ndarray)
"""
n = len(alleles_1) # Number of individuals
n = len(alleles_1) # Number of individuals.
assert len(alleles_2) == n, "Lengths of alleles differ."
assert n > 0, "There must be at least one individual."
assert len(allele_probs_1) == n, "Lengths of alleles and probabilities differ."
Expand Down Expand Up @@ -879,18 +879,18 @@ def compute_allelic_r_squared(gt_probs):
:rtype: float
"""
_MIN_R2_DEN = 1e-8
n = len(gt_probs) # Number of individuals
n = len(gt_probs) # Number of individuals.
assert n > 0, "There must be at least one individual."
assert gt_probs.shape[1] == 3, "Three genotypes are considered."
f = 1 / n
z = np.argmax(gt_probs, axis=1) # Most likely imputed genotypes
z = np.argmax(gt_probs, axis=1) # Most likely imputed genotypes.
u = gt_probs[:, 1] + 2 * gt_probs[:, 2] # E[X | y_i]
w = gt_probs[:, 1] + 4 * gt_probs[:, 2] # E[X^2 | y_i]
cov = np.sum(z * u) - np.sum(z) * np.sum(u) * f
var_best = np.sum(z**2) - np.sum(z) ** 2 * f
var_exp = np.sum(w) - np.sum(u) ** 2 * f
den = var_best * var_exp
# Minimum of allelic R^2 is zero. See BEAGLE code.
# Minimum of allelic R^2 is zero.
allelic_rsq = 0 if den < _MIN_R2_DEN else cov**2 / den
return allelic_rsq

Expand Down

0 comments on commit 2a266c0

Please sign in to comment.