HiCExplorer icon indicating copy to clipboard operation
HiCExplorer copied to clipboard

hicInterIntraTAD: ZeroDivisionError: division by zero

Open mdozmorov opened this issue 3 years ago • 3 comments

hicInterIntraTAD seems to be very useful; however, I immediately ran into the division by zero error. Is it possible to account for such (likely, frequent) events?

ERROR:hicexplorer.hicInterIntraTAD:division by zeroTraceback (most recent call last):
  File "/home/mdozmorov/miniconda3/envs/HiCExplorer/lib/python3.7/site-packages/hicexplorer/hicInterIntraTAD.py", line 224, in computeInterIntraTADs
    inter_left_density = inter_left_number_of_contacts_nnz / inter_left_number_of_contacts
ZeroDivisionError: division by zero
$ hicInfo --version
hicInfo 3.7.2
$ python --version
Python 3.7.12

The command itself:

hicInterIntraTAD --matrix ${MATRIX} \
	         --tadDomains ${TADDOMAINS} \
	         --outFileName ${OUTFILENAME} \
	         --outFileNameRatioPlot ${OUTPLOT} \
	         --threads 24

Thanks, Mikhail

mdozmorov avatar Dec 16 '21 00:12 mdozmorov

Hi Mikhail,

Thanks for reporting this bug. I will take care to fix it.

Best,

Joachim

joachimwolff avatar Dec 20 '21 10:12 joachimwolff

Hi @joachimwolff

I have the same issue, did you get any chances to fix this bug?

thx

cgirardot avatar Mar 31 '22 09:03 cgirardot

Hi @joachimwolff

reading the code, I have simply conditioned the code at line 213 (and line 224 ) and set the inter_right_density and inter_left_density to 0 when inter_right_number_of_contacts (inter_left_number_of_contacts) is 0.

For instance:

inter_right_density = 0
if inter_right_number_of_contacts > 0:
    inter_right_density = inter_right_number_of_contacts_nzz / inter_right_number_of_contacts

do you see an issue with this fix?

cgirardot avatar Mar 31 '22 11:03 cgirardot