Skip to content

Commit

Permalink
WIP: Allelic R-squared
Browse files Browse the repository at this point in the history
  • Loading branch information
szhan committed Feb 25, 2024
1 parent 1b974b8 commit 9a3132b
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion python/tests/beagle_numba.py
Original file line number Diff line number Diff line change
Expand Up @@ -620,9 +620,10 @@ def compute_estimated_allelic_r_squared(
), "Lengths of alleles and allele probabilities differ."
# Genotype probabilities for ith sample out of n samples.
# Dossges: P(RR) = 0, P(RA or AR) = 1, P(AA) = 2.
# TODO: Refactor so that genotyped are the input.
y = np.zeros((n, 3), dtype=np.float64)
u = y[:, 1] + 2 * y[:, 2] # E[X | y_i].
z = np.argmax(y, axis=1) # Most likely imputed genotype of ith sample.
u = y[:, 1] + 2 * y[:, 2] # E[X | y_i].
w = y[:, 1] + 4 * y[:, 2] # E[X^2 | y_i].
term_1 = (np.sum(z * u) - (1 / n) * (np.sum(u) * np.sum(z))) ** 2
term_2 = np.sum(w) - (1 / n) * np.sum(u) ** 2
Expand Down

0 comments on commit 9a3132b

Please sign in to comment.