Skip to content

Commit

Permalink
Check that the number of haplotypes meets a minimum
Browse files Browse the repository at this point in the history
  • Loading branch information
szhan committed Jun 18, 2024
1 parent 9f8d850 commit 13afd05
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions lshmm/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -409,6 +409,9 @@ def get_index_in_emission_matrix_diploid(ref_genotype, query_genotype):
# Miscellaneous functions.
def estimate_mutation_probability(num_haps):
"""Return the mutation probability as defined by A2 and A3 in Li & Stephens (2003)."""
if num_haps < 3:
err_msg = "Number of haplotypes must be at least 3."
raise ValueError(err_msg)
theta_tilde = 1 / np.sum([1 / k for k in range(1, num_haps - 1)])
prob_mutation = 0.5 * (theta_tilde / (num_haps + theta_tilde))
return prob_mutation

0 comments on commit 13afd05

Please sign in to comment.