Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Check that the number of haplotypes meets a minimum #108

Merged
merged 1 commit into from
Jun 18, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading