Skip to content

Commit

Permalink
Fixed bug in dxy calculation
Browse files Browse the repository at this point in the history
  • Loading branch information
simonhmartin committed May 27, 2015
1 parent e998a24 commit 5b9cf32
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions egglib_sliding_windows.py
Original file line number Diff line number Diff line change
Expand Up @@ -157,9 +157,11 @@ def dxy(align): # "align" if the egglib alignment object, this consistes of sequ
diffs = sum(sA != sB for sA, sB in zippedSeqs if sA != "N" and sB != "N")
#sites = sum(sA != "N" and sB != "N" for sA, sB in zippedSeqs)
sites = len([site for site in zippedSeqs if site[0] != "N" and site[1] != "N"])

#now add this pairwise dxy to the total and add 1 to the number of pairs considered
pairwiseSum += 1.0*diffs/sites
totalPairs += 1
#after considering all positions for each pair of haplotypes, return the average pairwise pi
return 1.0 * diffs/sites
return pairwiseSum/totalPairs


def px(align):
Expand Down

0 comments on commit 5b9cf32

Please sign in to comment.