BlanchetteLab / HIFI

Hi-C Interaction Frequency Inference (HIFI): High-resolution estimation of DNA-DNA interaction frequency from Hi-C data
23 stars 2 forks source link

Contact matrix element divided by zero #14

Open yasumasak opened 3 years ago

yasumasak commented 3 years ago

Hi, I found that some contacts were missing after running HIFI. It was caused when gs==0 at line 405 of HIFI.cpp, producing NaN for an element of matrix T. I just solved this by modifying line 405 as below if (s!=0 && gs!=0) { T.set(i,j,s/gs);} Is it a reasonable solution?

zhyanlin commented 3 years ago

Hi, I think it is a reasonable solution, but may be problematic. You could double-check my suggestions below as I am not an author of this software: If you do this modification, have you checked the initial value of T? I think you need to set it to 0 or some values. Maybe something like: if(gs!=0) { T.set(i,j,s/gs);} else T.set(i,j,0).

Also, are you working with a very low coverage dataset? In most cases, gs should be greater than 0.

If you find more contacts are missing. It may due to HIFI does not output all values by default. There is an argument (minOutput) to control the smallest contact value that it reports.

yasumasak commented 3 years ago

Thank you for the reply. What I found were missing contacts of very close ones (most of them were against the same fragments) with very large initial contact values. I think those should not be 0. By just skipping gs==0 by if (s!=0 && gs!=0) { T.set(i,j,s/gs);}
the contact values were calculated in next iterations. s!=0 may not be necessary though.