deeptools / HiCExplorer

HiCExplorer is a powerful and easy to use set of tools to process, normalize and visualize Hi-C data.
https://hicexplorer.readthedocs.org
GNU General Public License v3.0
231 stars 70 forks source link

`hicInterIntraTAD` not working on matrices generated by `hicSumMatrices` #797

Closed sebastian-gregoricchio closed 1 year ago

sebastian-gregoricchio commented 2 years ago

Dear all, I am using HiCExplorer version 3.7.2

I generated two matrices.h5 by hicSumMatrices --matrices {list_of_matrices_to_sum} --outFileName {output_matrix}, in order to merge 3 replicates of two different conditions (let's call them A and B).

Now I would like to compare the intra-TAD score of condition A vs B at specific TADs called in the control condition A.

Therefore I run the following command:

hicInterIntraTAD \
--matrix matrix_conditionA_40kb.resolution_normalized_corrected.h5 \
--tadDomains TADs_conditionA_40kb.resolution_domains.bed \
--outFileName ConditionA_40kb_IntraInterTAD_of_conditonA_scores.tzt \
-t 8

However I get this error message:

ERROR:hicexplorer.hicInterIntraTAD:division by zeroTraceback (most recent call last):
  File "/home/user/.conda/envs/HiC/lib/python3.8/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

So I was wondering: there is another possibility to calculate the intraTADs density/score? Such as use any of the hicFindTADs outputs?

Thank you in advance for your help!

sebastian-gregoricchio commented 2 years ago

I solved the problem by substituting the numerator of the division as follows in all occurrences:

import numpy as np
[...]
inter_left_density = np.float64(inter_left_number_of_contacts_nnz) / inter_left_number_of_contacts
inter_right_density = np.float64(inter_right_number_of_contacts_nzz) / inter_right_number_of_contacts

In that why when division by 0 happens I get NaN