Visualizing .h5 and .cool files in UCSC Genome Browser

588 views
Skip to first unread message

David da Silva Pires

unread,
Mar 14, 2022, 2:04:39 PM3/14/22
to UCSC Genome Browser Discussion List, Natalia Karla Bellini
Hi guys.

We are working with HiC experiments, according to a pipeline that involves the software HiCExplorer:

The final output of the pipeline are files in the formats .h5 and .cool. We would like to visualize these results at UCSC Genome Browser, but it seems that the only acceptable format is .hic, from the programa Juicer.

Is there a way to directly visualize .h5 or .cool files at UCSC Genome Browser? If not, can you suggest a tool to convert from these formats to .hic?

Thanks in advance.

Best regards.

--
DAVID DA SILVA PIRES
Especialista de Laboratório
LABORATÓRIO DE CICLO CELULAR
Tel: +55 11 2627-9734
www.butantan.gov.br

Esta mensagem, incluindo seus anexos, tem caráter confidencial e seu conteúdo é restrito ao destinatário da mensagem. Se você não for o(a) destinatário(a) final ou recebeu esta mensagem por engano, você não pode copiar, utilizar, divulgar ou agir baseado nesta mensagem ou qualquer informação nela contida. Por gentileza comunique imediatamente o remetente desta mensagem e a remova de seu sistema. Qualquer uso não autorizado, replicação ou disseminação desta mensagem ou parte dela é expressamente proibido. As informações ou opiniões pessoais do remetente nela contida podem não refletir o ponto de vista do Instituto / Fundação que apenas é divulgado por colaboradores devidamente autorizados. Eventuais Dados Pessoais contidos nesta mensagem, estão protegidos e em conformidade com a Lei Geral de Proteção de Dados - LGPD.

Daniel Schmelter

unread,
Mar 14, 2022, 8:34:19 PM3/14/22
to David da Silva Pires, UCSC Genome Browser Discussion List, Natalia Karla Bellini

Hello David,

Thank you for contacting the Genome Browser and for your question about converting other file formats into the .hic format accepted at the Genome Browser.

The UCSC Genome Browser does not have any integrated conversion tools or utilities. For these conversions, you will need to find an outside tool. We at the Genome Browser do not have the ability to develop such a tool at this time. We have noted your request.

A brief search on this topic resulted in a few leads.

https://hicexplorer.readthedocs.io/en/latest/content/tools/hicConvertFormat.html
https://www.biostars.org/p/360254/

If you do explore these tools, please share your findings so we might better our documentation for future users. Thank you in advance and I wish you all the best.

I hope this was helpful. If you have any more questions, please reply-all to our public support email at gen...@soe.ucsc.edu. For private communication, please reply-all to genom...@soe.ucsc.edu.


--

---
You received this message because you are subscribed to the Google Groups "UCSC Genome Browser Public Support" group.
To unsubscribe from this group and stop receiving emails from it, send an email to genome+un...@soe.ucsc.edu.
To view this discussion on the web visit https://groups.google.com/a/soe.ucsc.edu/d/msgid/genome/CA%2BYvowVg8DOZHaLKguzcMKB9f5gfy0mh%3DK6St%3DHa%2BxzDidMfng%40mail.gmail.com.

David da Silva Pires

unread,
Mar 21, 2022, 12:47:26 PM3/21/22
to Daniel Schmelter, UCSC Genome Browser Discussion List, Natalia Karla Bellini
Hi Daniel.

Thank you very much for the reply: it was very useful for us.

Based on the second URL you shared, we managed to convert from h5 to hic format as well as set up a track in our private genome browser.

As we are going to apply the solution to many files, we wrote a script to automate the conversion task, which we share below.

We are very grateful for the support that you and the entire team of UCSC Genome Browser have always given us. Thanks again.

Here is the script:

========================================================================================
#!/usr/bin/env bash

# h5ToHic.bash
#  
# This script converts a file from h5 to hic format.
# It receives two arguments:
#    1) h5 filename to be converted into hic format.
#    2) the chrom sizes file of the genome to which the h5 file is related to. This file is composed
#       of two columns, the first one is the name of a chromosome and the second one is the size of
#       the corresponding chromosome. It should be sorted in decreasing order.
#
# Reference:
#    https://www.biostars.org/p/360254/

# Error code.
ERR_WRONG_NUM_ARGS=1

# Checking command line.
if [[ $# != 2 ]]
then
  echo "You are supposed to pass two parameters:"
  echo "   1) h5 filename to be converted into hic format."
  echo "   2) chrom sizes file."
  echo "Example: ${0} file.h5 genome-chromSizes.txt"
  exit ${ERR_WRONG_NUM_ARGS}
fi

# Parsing parameters.
H5_FILE=${1}
CHROM_SIZES=${2}

# Removing the extension to get only the filename.
FILENAME=${1%.h5}

# Converting from h5 to ginteractions format.
hicConvertFormat --matrices ${H5_FILE} --outFileName ${FILENAME}.ginteractions --inputFormat h5 \
  --outputFormat ginteractions

# Short format preparation to make the file compatible with Juicer Pre.
awk -F "\t" '{print 0, $1, $2, 0, 0, $4, $5, 1, $7}' ${FILENAME}.ginteractions.tsv > \
  ${FILENAME}.ginteractions.tsv.short

# Sorting by 2nd column and then 6th column (in the case of a tie), required by Juicer Pre.
sort -k2,2d -k6,6d ${FILENAME}.ginteractions.tsv.short > ${FILENAME}.ginteractions.tsv.short.sorted

# Converting the sorted short format with score file to hic format with different resolutions.
juicer_tools pre -r 10000,20000,50000,100000,250000,500000,1000000 \
   ${FILENAME}.ginteractions.tsv.short.sorted ${FILENAME}.hic ${CHROM_SIZES}

# Removing temporary files.
rm ${FILENAME}.ginteractions.tsv{,.short,.short.sorted}

exit 0
========================================================================================

One can easily modify the script to convert from .cool to .hic format (by just changing the argument to the parameter --inputFormat of hicConvertFormat command).

Best regards.

--
DAVID DA SILVA PIRES
Especialista de Laboratório
LABORATÓRIO DE CICLO CELULAR
Tel: +55 11 2627-9734
www.butantan.gov.br
Reply all
Reply to author
Forward
0 new messages