Skip to content

Commit

Permalink
[fix] nucleotide diversity - account also for reference base
Browse files Browse the repository at this point in the history
  • Loading branch information
LaraFuhrmann authored and DrYak committed Mar 16, 2023
1 parent 72452b3 commit 507246a
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion workflow/scripts/compute_diversity_measures.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,11 @@ def population_nucleotide_diversity(df_mutations, length):
if N == 0:
continue
freq = df_temp["frequency"].to_numpy()
ref_freq = 1 - freq.sum()

position_pnd = freq**2
postion_pi = ( 1 - position_pnd.sum() )
postion_pi = ( 1 - (position_pnd.sum() + ref_freq**2))* N / (N-1 )

pi += postion_pi

return float(pi / length)
Expand Down

0 comments on commit 507246a

Please sign in to comment.