tforest 1 anno fa
parent
commit
ecc6fd23fc
1 ha cambiato i file con 10 aggiunte e 4 eliminazioni
  1. 10 4
      sfs_tools.py

+ 10 - 4
sfs_tools.py Vedi File

@@ -208,6 +208,7 @@ def barplot_sfs(sfs,  xlab, ylab, folded=True, title = "Barplot", transformed =
208 208
         #     else:
209 209
         #         sfs_val.append(ksi)
210 210
         if transformed:
211
+            ylab = r'$ \phi_i $'
211 212
             if folded:
212 213
                 val = ((k*(2*n - k)) / (2*n))*(ksi)
213 214
             else:
@@ -215,6 +216,9 @@ def barplot_sfs(sfs,  xlab, ylab, folded=True, title = "Barplot", transformed =
215 216
         else:
216 217
             val = ksi
217 218
         sfs_val.append(val)
219
+
220
+        if not transformed and not normalized:
221
+            ylab = r'$ \eta_i $'
218 222
             
219 223
     #terminal case, same for folded or unfolded
220 224
     if transformed:
@@ -223,19 +227,21 @@ def barplot_sfs(sfs,  xlab, ylab, folded=True, title = "Barplot", transformed =
223 227
         last_bin = list(sfs.values())[n-1]
224 228
     sfs_val[-1] = last_bin
225 229
     if normalized:
226
-        ylab = "Fraction of SNPs"
230
+        #ylab = "Fraction of SNPs "
231
+        ylab = r'$ \phi_i $'
227 232
         sum_val = sum(sfs_val)
228 233
         for k, sfs_bin in enumerate(sfs_val):
229 234
             sfs_val[k] = sfs_bin / sum_val
235
+        
230 236
         #print(sum(sfs_val))
231 237
     #build the plot
232
-    title = title+" (n="+str(len(sfs_val)+1)+") [folded="+str(folded)+"]"+" [transformed="+str(transformed)+"]"
238
+    title = title+" (n="+str(len(sfs_val))+") [folded="+str(folded)+"]"+" [transformed="+str(transformed)+"]"
233 239
     print("SFS =", sfs)
234 240
     if folded:
235 241
         xlab = "Minor allele frequency"
236 242
     if transformed:
237
-        print("Transformed SFS ( n =",len(sfs_val)+1, ") :", sfs_val)
238
-        plt.axhline(y=1/n, color='r', linestyle='-')
243
+        print("Transformed SFS ( n =",len(sfs_val), ") :", sfs_val)
244
+        #plt.axhline(y=1/n, color='r', linestyle='-')
239 245
     else:
240 246
         if normalized:
241 247
             # then plot a theoritical distribution as 1/i