yezhengSTAT / mHiC

MIT License
22 stars 10 forks source link

Step 5 - ZeroDivisionError: float division by zero #15

Open bgbrink opened 4 years ago

bgbrink commented 4 years ago

I have an issue when running Step 5 of the pipeline. This is the traceback:

Traceback (most recent call last):
  File "/work/project/ladsie_002/mHiC/s5_prior.py", line 1050, in <module>
    main()
  File "/work/project/ladsie_002/mHiC/s5_prior.py", line 319, in main
    (x,y,yerr)= calculateProbabilities(mainDic, binStats,resolution,os.path.join(outputPath,libName+".fithic_pass1"), observedIntraInRangeSum)
  File "/work/project/ladsie_002/mHiC/s5_prior.py", line 755, in calculateProbabilities
    var = M2/(possPairsInRange-1)
ZeroDivisionError: float division by zero

possPairsInRange is read from a dictionary called binStats. I logged the content of this dictionary:

DEBUG:root:binStats: 
{0: [(0, 300000), 329, 760675, 98.7, 0, 0, [300000], 329], 
1: [(300001, 400000), 299, 523328, 119.6, 0, 0, [400000], 299], 
2: [(400001, 500000), 271, 391211, 135.5, 0, 0, [500000], 271], 
3: [(500001, 600000), 243, 304743, 145.8, 0, 0, [600000], 243], 
4: [(600001, 700000), 219, 244700, 153.3, 0, 0, [700000], 219], 
5: [(700001, 800000), 195, 201130, 155.99999999999997, 0, 0, [800000], 195], 
6: [(800001, 900000), 174, 168379, 156.6, 0, 0, [900000], 174], 
7: [(900001, 1000000), 156, 144378, 156.0, 0, 0, [1000000], 156], 
8: [(1000001, 1100000), 141, 126066, 155.10000000000002, 0, 0, [1100000], 141], 
9: [(1100001, 1200000), 128, 110003, 153.6, 0, 0, [1200000], 128], 
10: [(1200001, 1300000), 115, 95290, 149.49999999999997, 0, 0, [1300000], 115], 
11: [(1300001, 1400000), 102, 82664, 142.79999999999998, 0, 0, [1400000], 102], 
12: [(1400001, 1500000), 91, 74238, 136.5, 0, 0, [1500000], 91], 
13: [(1500001, 1600000), 84, 66794, 134.4, 0, 0, [1600000], 84], 
14: [(1600001, 1700000), 77, 60122, 130.9, 0, 0, [1700000], 77], 
15: [(1700001, 1800000), 71, 53821, 127.8, 0, 0, [1800000], 71], 
16: [(1800001, 1900000), 65, 49074, 123.5, 0, 0, [1900000], 65], 
17: [(1900001, 2000000), 59, 43626, 118.0, 0, 0, [2000000], 59], 
18: [(2000001, 2100000), 53, 38878, 111.29999999999998, 0, 0, [2100000], 53], 
19: [(2100001, 2200000), 47, 34500, 103.40000000000002, 0, 0, [2200000], 47], 
20: [(2200001, 2300000), 43, 32011, 98.89999999999999, 0, 0, [2300000], 43], 
21: [(2300001, 2400000), 40, 29470, 96.0, 0, 0, [2400000], 40], 
22: [(2400001, 2500000), 38, 27630, 95.0, 0, 0, [2500000], 38], 
23: [(2500001, 2600000), 36, 25574, 93.6, 0, 0, [2600000], 36], 
24: [(2600001, 2700000), 34, 23976, 91.80000000000001, 0, 0, [2700000], 34], 
25: [(2700001, 2800000), 32, 21830, 89.6, 0, 0, [2800000], 32], 
26: [(2800001, 2900000), 30, 20212, 87.0, 0, 0, [2900000], 30], 
27: [(2900001, 3000000), 28, 18608, 84.0, 0, 0, [3000000], 28], 
28: [(3000001, 3100000), 26, 16811, 80.6, 0, 0, [3100000], 26], 
29: [(3100001, 3200000), 24, 14927, 76.8, 0, 0, [3200000], 24], 
30: [(3200001, 3300000), 22, 13669, 72.6, 0, 0, [3300000], 22], 
31: [(3300001, 3400000), 20, 11810, 68.0, 0, 0, [3400000], 20], 
32: [(3400001, 3500000), 18, 10482, 63.0, 0, 0, [3500000], 18], 
33: [(3500001, 3600000), 16, 9427, 57.6, 0, 0, [3600000], 16], 
34: [(3600001, 3700000), 14, 8200, 51.8, 0, 0, [3700000], 14], 
35: [(3700001, 3800000), 12, 6717, 45.599999999999994, 0, 0, [3800000], 12], 
36: [(3800001, 3900000), 10, 5445, 39.0, 0, 0, [3900000], 10], 
37: [(3900001, 4000000), 8, 3963, 32.0, 0, 0, [4000000], 8], 
38: [(4000001, 4100000), 6, 3179, 24.599999999999998, 0, 0, [4100000], 6], 
39: [(4100001, 4200000), 5, 2646, 21.0, 0, 0, [4200000], 5], 
40: [(4200001, 4300000), 4, 2011, 17.2, 0, 0, [4300000], 4], 
41: [(4300001, 4400000), 3, 1315, 13.200000000000001, 0, 0, [4400000], 3], 
42: [(4400001, 4500000), 2, 690, 9.0, 0, 0, [4500000], 2], 
43: [(4500001, 4600000), 1, 196, 4.6, 0, 0, [4600000], 1]}

possPairsInRange is the second element of each value, so in the last entry (#43) it goes down to 1, which should be the cause of the above error, since var = M2/(possPairsInRange-1) yields a division by zero.

yezhengSTAT commented 4 years ago

Would you mind sharing your input values and maybe a few lines from the input files? This step is modified from Fit-Hi-C. Have you successfully run Fit-Hi-C for significant interaction detection before?