diff --git a/__init__.py b/__init__.py index 0f057a6..127df37 100644 --- a/__init__.py +++ b/__init__.py @@ -1,2 +1,2 @@ -from frst import sfs_tools, customgraphics, vcf_utils, sfs_tools, stats_sfs, dependences +from frst import sfs_tools, customgraphics, vcf_utils, sfs_tools, stats_sfs, dependences, swp2 diff --git a/sfs_tools.py b/sfs_tools.py index 22d576e..f08caa3 100755 --- a/sfs_tools.py +++ b/sfs_tools.py @@ -227,11 +227,23 @@ def barplot_sfs(sfs, xlab, ylab, folded=True, title = "Barplot", transformed = sum_val = sum(sfs_val) for k, sfs_bin in enumerate(sfs_val): sfs_val[k] = sfs_bin / sum_val + #print(sum(sfs_val)) #build the plot title = title+" (n="+str(len(sfs_val)+1)+") [folded="+str(folded)+"]"+" [transformed="+str(transformed)+"]" print("SFS =", sfs) + if folded: + xlab = "Minor allele frequency" if transformed: print("Transformed SFS ( n =",len(sfs_val)+1, ") :", sfs_val) + plt.axhline(y=1/n, color='r', linestyle='-') + else: + if normalized: + # then plot a theoritical distribution as 1/i + expected_y = [1/(2*x+1) for x in list(sfs.keys())] + print(sum(expected_y)) + plt.plot([x for x in list(sfs.keys())], expected_y, color='r', linestyle='-') + #print(expected_y) + customgraphics.barplot(x = [x for x in list(sfs.keys())], y= sfs_val, xlab = xlab, ylab = ylab, title = title) plt.show()