In [1]:
from pytadbit import Chromosome
# initiate a chromosome object that will store all Hi-C data and analysis
my_chrom = Chromosome(name='My fisrt chromosome', centromere_search=True)
# load Hi-C data
my_chrom.add_experiment('First Hi-C experiment', hic_data="../../scripts/sample_data/HIC_k562_chr19_chr19_100000_obs.txt", resolution=100000)
my_chrom.add_experiment('Second Hi-C experiment', hic_data="../../scripts/sample_data/HIC_gm06690_chr19_chr19_100000_obs.txt", resolution=100000)
# Filter and normalize Hi-C matrices
my_chrom.experiments['First Hi-C experiment'].filter_columns()
my_chrom.experiments['Second Hi-C experiment'].filter_columns()
my_chrom.experiments['First Hi-C experiment'].normalize_hic(iterations=30, max_dev=0.1)
my_chrom.experiments['Second Hi-C experiment'].normalize_hic(iterations=30, max_dev=0.1)
# run core tadbit function to find TADs, on each experiment
my_chrom.find_tad('First Hi-C experiment', ncpus=4)
my_chrom.find_tad('Second Hi-C experiment', ncpus=4)
print my_chrom.experiments
In [2]:
my_chrom.align_experiments(names=["First Hi-C experiment", "Second Hi-C experiment"])
print my_chrom.alignment
In [3]:
score, pval = my_chrom.align_experiments(randomize=True, rnd_method="interpolate",
rnd_num=100)
print 'score:', score
print 'p-value:', pval
In [4]:
ali = my_chrom.alignment[('First Hi-C experiment', 'Second Hi-C experiment')]
print ali
In [5]:
ali.draw()
Note that this function can also be zoomed in.
In [6]:
ali.draw(focus=(1, 250))
In [7]:
xpr = my_chrom.experiments[0]
my_chrom.tad_density_plot(0, focus=(1, 300))
In [8]:
ali.get_column(3)
Out[8]:
In [9]:
cond1 = lambda x: x['score'] > 7
In [10]:
ali.get_column(cond1=cond1)
Out[10]:
In [11]:
cond2 = lambda x: x['pos'] > 50
ali.get_column(cond1=cond1, cond2=cond2)
Out[11]:
In [12]:
ali.get_column(cond1=cond1, cond2=cond2, min_num=1)
Out[12]: