Browse Source

Compute proportion of information used for theta plots

tforest 11 months ago
parent
commit
87bef76e28
1 changed files with 11 additions and 11 deletions
  1. 11 11
      swp2.py

+ 11 - 11
swp2.py View File

@@ -262,14 +262,6 @@ def plot_all_epochs_thetafolder(folder_path, mu, tgen, title = "Title", theta_sc
262 262
             # divide by N0
263 263
             y[i] = y[i]/N0
264 264
             x[i] = x[i]/N0
265
-        sum_theta_i = 0
266
-        print(epoch, x, y)
267
-        for i in range(2, len(y)-1):
268
-            sum_theta_i=y[i] / (i-1)
269
-        prop = []
270
-        for k in range(2, len(y)-1):
271
-            prop.append(y[k+1] / (k - 1) / sum_theta_i)
272
-        #print(epoch, prop)
273 265
         plt.plot(x, y, 'o', linestyle = "-", alpha=0.75, lw=2, label = str(epoch)+' BrkPt | Lik='+greatest_likelihood)
274 266
         if theta_scale:
275 267
             plt.xlabel("Coal. time")
@@ -294,15 +286,15 @@ def plot_all_epochs_thetafolder(folder_path, mu, tgen, title = "Title", theta_sc
294 286
     # number of monomorphic sites
295 287
     L = L_stored
296 288
     S0 = L-S
297
-    print("SFS", SFS_stored)
298
-    print("S", S, "L", L, "S0=", S0)
289
+    # print("SFS", SFS_stored)
290
+    # print("S", S, "L", L, "S0=", S0)
299 291
     # compute Ln
300 292
     Ln = log_facto(S+S0) - log_facto(S0) + np.log(float(S0)/(S+S0)) * S0
301 293
     for xi in range(0, len(SFS_stored)):
302 294
         p_i = SFS_stored[xi] / float(S+S0)
303 295
         Ln += np.log(p_i) * SFS_stored[xi] - log_facto(SFS_stored[xi])
304 296
     res = Ln
305
-    print(res)
297
+    # print(res)
306 298
     # basic plot likelihood
307 299
     plt.figure(figsize=(5000/my_dpi, 2800/my_dpi), dpi=my_dpi)
308 300
     plt.rcParams['font.size'] = '18'
@@ -362,6 +354,14 @@ def plot_test_theta(folder_path, mu, tgen, title = "Title", theta_scale = True,
362 354
                 N0 = y[0]
363 355
         for i in range(len(y)):
364 356
             y[i] = y[i]/N0
357
+        # compute the proportion of information used at each bin of the SFS
358
+        sum_theta_i = 0
359
+        for i in range(2, len(y)-1):
360
+            sum_theta_i+=y[i] / (i-1)
361
+        prop = []
362
+        for k in range(2, len(y)-1):
363
+            prop.append(y[k] / (k - 1) / sum_theta_i)
364
+        # plot 
365 365
         plt.plot(x, y, 'o', linestyle="dotted", alpha=0.75, lw=2, label = str(epoch)+' brks')
366 366
         plt.xlabel("# breaks")
367 367
         plt.ylabel("theta")