sfs plotting
parent
592b16e7f3
commit
ecc6fd23fc
14
sfs_tools.py
14
sfs_tools.py
|
|
@ -208,6 +208,7 @@ def barplot_sfs(sfs, xlab, ylab, folded=True, title = "Barplot", transformed =
|
|||
# else:
|
||||
# sfs_val.append(ksi)
|
||||
if transformed:
|
||||
ylab = r'$ \phi_i $'
|
||||
if folded:
|
||||
val = ((k*(2*n - k)) / (2*n))*(ksi)
|
||||
else:
|
||||
|
|
@ -215,6 +216,9 @@ def barplot_sfs(sfs, xlab, ylab, folded=True, title = "Barplot", transformed =
|
|||
else:
|
||||
val = ksi
|
||||
sfs_val.append(val)
|
||||
|
||||
if not transformed and not normalized:
|
||||
ylab = r'$ \eta_i $'
|
||||
|
||||
#terminal case, same for folded or unfolded
|
||||
if transformed:
|
||||
|
|
@ -223,19 +227,21 @@ def barplot_sfs(sfs, xlab, ylab, folded=True, title = "Barplot", transformed =
|
|||
last_bin = list(sfs.values())[n-1]
|
||||
sfs_val[-1] = last_bin
|
||||
if normalized:
|
||||
ylab = "Fraction of SNPs"
|
||||
#ylab = "Fraction of SNPs "
|
||||
ylab = r'$ \phi_i $'
|
||||
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)+"]"
|
||||
title = title+" (n="+str(len(sfs_val))+") [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='-')
|
||||
print("Transformed SFS ( n =",len(sfs_val), ") :", sfs_val)
|
||||
#plt.axhline(y=1/n, color='r', linestyle='-')
|
||||
else:
|
||||
if normalized:
|
||||
# then plot a theoritical distribution as 1/i
|
||||
|
|
|
|||
Loading…
Reference in New Issue