Skip to content

Commit

Permalink
Rename function and improve docs
Browse files Browse the repository at this point in the history
  • Loading branch information
szhan committed Aug 31, 2023
1 parent 29c3d12 commit f02f1a2
Showing 1 changed file with 10 additions and 9 deletions.
19 changes: 10 additions & 9 deletions python/tests/test_beagle.py
Original file line number Diff line number Diff line change
Expand Up @@ -325,26 +325,27 @@ def compute_state_probability_matrix(fm, bm, ref_h, query_h, rho, mu):
return (sm, fwd_hap_probs, bwd_hap_probs)


def interpolate_haplotype_probability_matrix(
def interpolate_allele_probabilities(
fwd_hap_probs, bwd_hap_probs, genotyped_pos, imputed_pos
):
"""
Compute the interpolated haplotype probability matrix of a query haplotype.
Compute the interpolated allele probabilities at the imputed markers
of a query haplotype.
The forward and backward haplotype probability matrices are of size (m, 2),
where m is the number of genotyped markers in the query haplotype.
where m is the number of genotyped markers.
Here, we assume all biallelic sites, hence the 2.
The interpolated haplotype probability matrix is of size (x, 2),
where x is the number of imputed markers in the query haplotype.
where x is the number of imputed markers.
Again, we assume all biallelic sites, hence the 2.
This implementation is based on Equation 2 (the rearranged one) in BB2016.
:param fwd_hap_probs: Forward haplotype probability matrix.
:param bwd_hap_probs: Backward haplotype probability matrix.
:param genotyped_pos: Site positions of genotyped markers.
:param imputed_pos: Site positions of imputed markers.
:param numpy.ndarray fwd_hap_probs: Forward haplotype probability matrix.
:param numpy.ndarray bwd_hap_probs: Backward haplotype probability matrix.
:param numpy.ndarray genotyped_pos: Site positions of genotyped markers.
:param numpy.ndarray imputed_pos: Site positions of imputed markers.
:return: Interpolated haplotype probability matrix.
:rtype: numpy.ndarray
"""
Expand Down Expand Up @@ -535,7 +536,7 @@ def run_beagle(ref_h, query_h, pos):
assert bwd_hap_probs.shape == (m, 2)
# Interpolate haplotype probabilities
# from genotype markers to imputed markers
i_hap_probs = interpolate_haplotype_probability_matrix(
i_hap_probs = interpolate_allele_probabilities(
fwd_hap_probs, bwd_hap_probs, genotyped_pos, imputed_pos
)
assert i_hap_probs.shape == (x, 2)
Expand Down

0 comments on commit f02f1a2

Please sign in to comment.