TADbit icon indicating copy to clipboard operation
TADbit copied to clipboard

TADs calls problem

Open shiyi-pan opened this issue 3 years ago • 3 comments

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/valid_reads12_{0}.bam' bias_path = 'results/fragment/{0}/04_normalizing/valid_reads12_{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 avatar Dec 22 '20 13:12 shiyi-pan

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.

shiyi-pan avatar Dec 23 '20 07:12 shiyi-pan

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

david-castillo avatar Dec 23 '20 17:12 david-castillo

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 ?

shiyi-pan avatar Dec 24 '20 03:12 shiyi-pan