Ver código fonte

Modify the sfs plot

tforest 1 ano atrás
pai
commit
20d66bf1cc
2 arquivos alterados com 13 adições e 1 exclusões
  1. 1 1
      __init__.py
  2. 12 0
      sfs_tools.py

+ 1 - 1
__init__.py Ver arquivo

@@ -1,2 +1,2 @@
1
-from frst import sfs_tools, customgraphics, vcf_utils, sfs_tools, stats_sfs, dependences
1
+from frst import sfs_tools, customgraphics, vcf_utils, sfs_tools, stats_sfs, dependences, swp2
2 2
 

+ 12 - 0
sfs_tools.py Ver arquivo

@@ -227,11 +227,23 @@ def barplot_sfs(sfs,  xlab, ylab, folded=True, title = "Barplot", transformed =
227 227
         sum_val = sum(sfs_val)
228 228
         for k, sfs_bin in enumerate(sfs_val):
229 229
             sfs_val[k] = sfs_bin / sum_val
230
+        #print(sum(sfs_val))
230 231
     #build the plot
231 232
     title = title+" (n="+str(len(sfs_val)+1)+") [folded="+str(folded)+"]"+" [transformed="+str(transformed)+"]"
232 233
     print("SFS =", sfs)
234
+    if folded:
235
+        xlab = "Minor allele frequency"
233 236
     if transformed:
234 237
         print("Transformed SFS ( n =",len(sfs_val)+1, ") :", sfs_val)
238
+        plt.axhline(y=1/n, color='r', linestyle='-')
239
+    else:
240
+        if normalized:
241
+            # then plot a theoritical distribution as 1/i
242
+            expected_y = [1/(2*x+1) for x in list(sfs.keys())]
243
+            print(sum(expected_y))
244
+            plt.plot([x for x in list(sfs.keys())], expected_y, color='r', linestyle='-')
245
+            #print(expected_y)
246
+            
235 247
     customgraphics.barplot(x = [x for x in list(sfs.keys())], y= sfs_val, xlab = xlab, ylab = ylab, title = title)
236 248
     plt.show()
237 249