Modify the sfs plot
parent
2b5dc75f30
commit
20d66bf1cc
|
|
@ -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
|
||||
|
||||
|
|
|
|||
12
sfs_tools.py
12
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()
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue