3DGenomes / TADbit

TADbit is a complete Python library to deal with all steps to analyze, model and explore 3C-based data. With TADbit the user can map FASTQ files to obtain raw interaction binned matrices (Hi-C like matrices), normalize and correct interaction matrices, identify and compare the so-called Topologically Associating Domains (TADs), build 3D models from the interaction matrices, and finally, extract structural properties from the models. TADbit is complemented by TADkit for visualizing 3D models
GNU General Public License v3.0
100 stars 61 forks source link

TADs calls problem #338

Open shiyi-pan opened 3 years ago

shiyi-pan commented 3 years ago

Hi, I want to detect TADs using this amazing software but I met some problem. here is my code, I just have one experiment

from pytadbit import Chromosome from pytadbit.parsers.hic_parser import load_hic_data_from_bam species = 'soybean' base_path = 'results/fragment/{0}/03_filtering/validreads12{0}.bam' bias_path = 'results/fragment/{0}/04_normalizing/validreads12{0}ICE{1}kb.biases' reso = 100000 hic_data = load_hic_data_from_bam(base_path.format(species), resolution=reso, region='Chr03', biases=bias_path.format(species, reso // 1000), ncpus=8) chrname = 'Chr03' crm = Chromosome(chrname) crm.add_experiment('NN1138-2', hic_data=[hic_data.get_matrix(focus='Chr03')], norm_data=[hic_data.get_matrix(focus='Chr03',normalized=True)], resolution=reso) crm.find_tad(['NN1138-2'], n_cpus=8)

I followed this workflow described in tutorial but I confused because there is no outfile , could you give me some advise ? Thank you very much.

shiyi-pan commented 3 years ago

Hi, I find a function 'save_chromosome' can the Chromosome object with TAD definition . I'm not sure it contain the TADs and it's a binary file. Is there a function that can write the TADs into a text file ? thank you very much.

david-castillo commented 3 years ago

Hi,

Inside Cromosome you have a list of experiments (like here https://3dgenomes.github.io/TADbit/tutorial/tutorial_8-Compartments_and_TADs_detection.html)

Each experiment has an attribute tads (exp.tads) with the list of start and end of border, strength and density. You also have a function to save them to text: https://3dgenomes.github.io/TADbit/reference/reference_experiment.html#pytadbit.experiment.Experiment.write_tad_borders

David

shiyi-pan commented 3 years ago

Thank you for your reply,David. here is my code:

crm.find_tad(['NN1138'], n_cpus=8) exp = crm.get_experiment("NN1138") exp.write_tad_borders(density=False, savedata='results/fragment/Chr03_tad_borders.txt', normalized=False)

here is my result:

start end score

1 1 4 2.0 2 5 14 3.0 3 15 19 5.0 4 20 29 5.0

I have two questions . am I understand your answer correctly and is the numbers of start and end represent the bins ?