Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Load .hic file for Compartments and TADs detection? #316

Closed
awezmm opened this issue Mar 26, 2020 · 2 comments
Closed

Load .hic file for Compartments and TADs detection? #316

awezmm opened this issue Mar 26, 2020 · 2 comments

Comments

@awezmm
Copy link

awezmm commented Mar 26, 2020

How can I load data from a .hic file for Compartments and TADs detection?

@david-castillo
Copy link
Contributor

Hi,
We don't support .hic directly but you have two simple options:

  1. Convert .hic to .mcool format for example with https://hicexplorer.readthedocs.io/en/latest/ and then use tadbit like:
from pytadbit import Chromosome, Experiment
cool_file = 'matrix=my_matrix.mcool'
exp = Experiment('exp1', hic_data=cool_file, resolution=my_resolution)
hic_data = exp.hic_data[0]

and then use the hic_data object to find compartments and tads like in https://3dgenomes.github.io/TADbit/tutorial/tutorial_8-Compartments_and_TADs_detection.html

  1. Use straw (https://github.com/aidenlab/straw) or similar to create a text matrix and then build your own hic_data object like
from pytadbit import HiC_data
filename = 'my_matrix.dat'
resolution=my_resolution
size = int(full_size_in_bp/resolution)
my_chroms={'chr_name1':chr_size1_in_bp/resolution,'chr_name2':chr_size2_in_bp/resolution}
hic_tup = {int(int(line.split()[0])/resolution)+int(int(line.split()[1])/resolution)*size:int(line.split()[2])
            for line in open(filename)}

hic_data = HiC_data(hic_tup,size=size,resolution=resolution,chromosomes=my_chroms)

and then use the hic_data object to find compartments and tads like in https://3dgenomes.github.io/TADbit/tutorial/tutorial_8-Compartments_and_TADs_detection.html

The advantage of option 2 is that is faster than option 1 if you are just interested in a single chromosome.

Regards

@awezmm
Copy link
Author

awezmm commented Apr 10, 2020

Great, thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants