4dn-dcic / hic2cool

Lightweight converter between hic and cool contact matrices.
MIT License
66 stars 7 forks source link

Calling Cooler.pixels raises KeyError: 'nnz' if multiple processes specified in hic2cool convert #52

Open nefclan opened 4 years ago

nefclan commented 4 years ago

hic2cool 0.8.3 cooler, version 0.8.6.post0

hic2cool convert -r 10000 -p 4 $INPUT_DIR/${sample}.hic $COOLER_FILE
>>> pixels = coolfh.pixels(join=True) 
File "/xxxx/lib/python3.6/site-packages/cooler/api.py", line 286, in pixels
    cooler/api.py", line 286, in pixels
KeyError: 'nnz'

Converted cool's info.

>>> coolfh.info.keys()
dict_keys(['bin-size', 'bin-type', 'creation-date', 'format', 'format-url', 
'format-version', 'generated-by', 'genome-assembly', 'graphs', 'nbins', 
'nchroms', 'statistics', 'storage-mode'])

Manually dump juicer .hic file and convert to sparse matrix file and use

cooler load -f coo $SEG_FILE $MATRIX_FILE $COOLER_FILE
>>> coolfh.info.keys()
dict_keys(['bin-size', 'bin-type', 'creation-date', 'format', 'format-url', 
'format-version', 'generated-by', 'genome-assembly', 'metadata', 'nbins', 
'nchroms', 'nnz', 'storage-mode', 'sum'])

Looks like hic2cool didn't write 'nnz' information which should be equal to the number of total pixels (number of lines of $MATRIX_FILE).

SooLee commented 4 years ago

@nefclan Thank you for reporting this. Do you get the same problem when you run it with -p 1?

nefclan commented 4 years ago

@nefclan Thank you for reporting this. Do you get the same problem when you run it with -p 1?

That's it! I ran with -p 1, this error never shows up.