def linkage(counts_table):
"""
Return the linkage disequilibrium (D) for an arbitrary number of
loci given their contingency table.
"""
probs_table = frequency_to_probability(counts_table)
marginal_probs = get_marginal_probabilities(probs_table)
if either_locus_not_detected(marginal_probs):
return np.NAN
exp_freqs = marginal_probs.prod(axis=0)[0]
observed = probs_table.flat[-1]
if observed == 0:
return np.NAN
return observed - exp_freqs
评论列表
文章目录