I've put together a slightly hacky and long winded way to go from .cool
to .hic
Firstly, use the hicConvertFormat
tool from the HiCExplorer package (which I installed using conda) to convert your .cool
file into a ginteractions file:
hicConvertFormat -m /path/to/file.cool -o /path/to/file.ginteractions --inputFormat cool --outputFormat ginteractions
This will create the file file.ginteractions.tsv
. Next, we will do some format preparation on this file to make it compatible with juicer pre. Documentation on the input formats accepted can be found here: https://github.com/aidenlab/juicer/wiki/Pre . I opted to make the file into short format with score, which has columns like:
<str1> <chr1> <pos1> <frag1> <str2> <chr2> <pos2> <frag2> <score>
The ginteractions file does not contain fragment or strand information, so I put dummy variables for those (since they are not used for the conversion to .hic
anyway) and made sure that the dummy variables for frag1 and frag2 were different, using the following awk command:
awk -F "\t" '{print 0, $1, $2, 0, 0, $4, $5, 1, $7}' file.ginteractions.tsv > file.ginteractions.tsv.short
Sometimes this file will need to be sorted as juicer requires a specific chromosome ordering. So you can run:
sort -k2,2d -k6,6d file.ginteractions.tsv.short > file.ginteractions.tsv.short.sorted
I downloaded juicer tools from here: https://github.com/aidenlab/juicer/wiki/Download and set the following alias. However, you may need to increase the resourced allocated to the JVM for very large files:
alias juicer='java -Xms512m -Xmx2048m -jar path/to/juicer_tools_1.22.01.jar'
So that converting the short format with score file is done with the following:
juicer pre -r 10000,20000,50000,100000,250000,500000,1000000 /path/to/file.ginteractions.tsv.short.sorted /path/to/file.ginteractions.tsv.short.sorted.hic /path/to/chrom.sizes
Where the chrom.sizes
file contains two columns: <chrom> <chrom size>
. The -r
flag here specifies the resolutions you would like your .hic
file to include.
I am one of the main developers of HiGlass, and I agree that our setup could and should be easier. Where specifically do you get stuck? Also, feel free to join our slack channel (http://bit.ly/higlass-slack) if you need quick help.
maybe you can try pairLiftOver https://github.com/XiaoTaoWang/pairLiftOver