本文整理汇总了Python中pytadbit.Chromosome.add_experiment方法的典型用法代码示例。如果您正苦于以下问题:Python Chromosome.add_experiment方法的具体用法?Python Chromosome.add_experiment怎么用?Python Chromosome.add_experiment使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pytadbit.Chromosome
的用法示例。
在下文中一共展示了Chromosome.add_experiment方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: main
# 需要导入模块: from pytadbit import Chromosome [as 别名]
# 或者: from pytadbit.Chromosome import add_experiment [as 别名]
def main():
opts, params = get_options()
if opts.inabc:
zscores = parse_zscores(opts.inabc)
models = generate_3d_models(zscores, opts.resolution, start=1,
n_models=opts.nmodels,
n_keep=opts.nkeep, n_cpus=opts.ncpus,
keep_all=False, verbose=False,
outfile=None,
config=params)
else:
crm = 'crm'
xnam = 'X'
crmbit=Chromosome(crm)
crmbit.add_experiment(xnam, resolution=opts.resolution, xp_handler=opts.incrm)
exp = crmbit.experiments[xnam]
models = exp.model_region(start=opts.start, end=opts.end,
n_models=opts.nmodels,
n_keep=opts.nkeep, n_cpus=opts.ncpus,
keep_all=False, verbose=False,
config=params)
if opts.save:
models.save_models('%s/models_%s_%s.pik' % (opts.out, opts.start,
opts.start + opts.nmodels))
for i in xrange(int(opts.cmm)):
models.write_cmm(i, opts.out)
if opts.full_report:
models.cluster_models(dcutoff=200)
models.cluster_analysis_dendrogram(n_best_clusters=10)
models.model_consistency()
示例2: load_hic_data
# 需要导入模块: from pytadbit import Chromosome [as 别名]
# 或者: from pytadbit.Chromosome import add_experiment [as 别名]
def load_hic_data(opts, xnames):
"""
Load Hi-C data
"""
# Start reading the data
crm = Chromosome(opts.crm, species=(
opts.species.split('_')[0].capitalize() + opts.species.split('_')[1]
if '_' in opts.species else opts.species),
centromere_search=opts.centromere,
assembly=opts.assembly) # Create chromosome object
# Load three different experimental data sets named TR1, TR2 and BR.
# Data obtained from Hou et al (2012) Molecular Cell.
# doi:10.1016/j.molcel.2012.08.031
logging.info("\tReading input data...")
for xnam, xpath, xnorm in zip(xnames, opts.data, opts.norm):
crm.add_experiment(
xnam, exp_type='Hi-C', enzyme=opts.enzyme,
cell_type=opts.cell,
identifier=opts.identifier, # general descriptive fields
project=opts.project, # user descriptions
resolution=opts.res,
hic_data=xpath,
norm_data=xnorm)
if not xnorm:
logging.info("\tNormalizing HiC data of %s..." % xnam)
crm.experiments[xnam].normalize_hic(iterations=5)
if opts.beg > crm.experiments[-1].size:
raise Exception('ERROR: beg parameter is larger than chromosome size.')
if opts.end > crm.experiments[-1].size:
logging.info('WARNING: end parameter is larger than chromosome ' +
'size. Setting end to %s.\n' % (crm.experiments[-1].size *
opts.res))
opts.end = crm.experiments[-1].size
return crm
示例3: load_genome_from_tad_def
# 需要导入模块: from pytadbit import Chromosome [as 别名]
# 或者: from pytadbit.Chromosome import add_experiment [as 别名]
def load_genome_from_tad_def(genome_path, res, verbose=False):
"""
Search, at a given path, for chromosome folders containing TAD
definitions in tsv files.
:param genome_path: Path where to search for TADbit chromosomes
:param res: Resolution at were saved chromosomes
:param False verbose:
:returns: a dictionary with all TADbit chromosomes found
"""
ref_genome = {}
for crm in listdir(genome_path):
crm_path = os.path.join(genome_path, crm)
if not isfile(crm_path):
continue
if crm in ref_genome:
raise Exception('More than 1 TAD definition file found\n')
crm = crm.replace('.tsv', '').replace('chr', '').upper()
if verbose:
print ' Chromosome:', crm
crmO = Chromosome(crm)
crmO.add_experiment('sample', res)
crmO.experiments[0].load_tad_def(crm_path)
ref_genome[crm] = crmO
return ref_genome
示例4: test_08_changing_resolution
# 需要导入模块: from pytadbit import Chromosome [as 别名]
# 或者: from pytadbit.Chromosome import add_experiment [as 别名]
def test_08_changing_resolution(self):
if CHKTIME:
t0 = time()
test_chr = Chromosome(name='Test Chromosome', max_tad_size=260000)
test_chr.add_experiment('exp1', 20000, tad_def=exp4,
hic_data=PATH + '/20Kb/chrT/chrT_D.tsv',
silent=True)
exp = test_chr.experiments['exp1']
sum20 = sum(exp.hic_data[0].values())
exp.set_resolution(80000)
sum80 = sum(exp.hic_data[0].values())
check_hic(exp.hic_data[0], exp.size)
exp.set_resolution(160000)
sum160 = sum(exp.hic_data[0].values())
check_hic(exp.hic_data[0], exp.size)
exp.set_resolution(360000)
sum360 = sum(exp.hic_data[0].values())
check_hic(exp.hic_data[0], exp.size)
exp.set_resolution(2400000)
sum2400 = sum(exp.hic_data[0].values())
check_hic(exp.hic_data[0], exp.size)
exp.set_resolution(40000)
sum40 = sum(exp.hic_data[0].values())
check_hic(exp.hic_data[0], exp.size)
exp.set_resolution(20000)
sum21 = sum(exp.hic_data[0].values())
check_hic(exp.hic_data[0], exp.size)
exp.set_resolution(40000)
sum41 = sum(exp.hic_data[0].values())
check_hic(exp.hic_data[0], exp.size)
self.assertTrue(sum20 == sum80 == sum160 == sum360 == sum40 \
== sum21 == sum2400 == sum41)
if CHKTIME:
print '8', time() - t0
示例5: test_12_3d_modelling_optimization
# 需要导入模块: from pytadbit import Chromosome [as 别名]
# 或者: from pytadbit.Chromosome import add_experiment [as 别名]
def test_12_3d_modelling_optimization(self):
"""
quick test to generate 3D coordinates from 3? simple models???
"""
if CHKTIME:
t0 = time()
try:
__import__('IMP')
except ImportError:
warn('IMP not found, skipping test\n')
return
test_chr = Chromosome(name='Test Chromosome', max_tad_size=260000)
test_chr.add_experiment('exp1', 20000, tad_def=exp4,
hic_data=PATH + '/20Kb/chrT/chrT_D.tsv')
exp = test_chr.experiments[0]
exp.load_hic_data(PATH + '/20Kb/chrT/chrT_A.tsv')
exp.filter_columns(silent=True)
exp.normalize_hic(silent=True, factor=None)
result = exp.optimal_imp_parameters(50, 70, n_cpus=4,
n_models=8, n_keep=2,
lowfreq_range=[-0.6],
upfreq_range=(0, 1.1, 1.1),
maxdist_range=[500, 600],
verbose=False)
# get best correlations
config = result.get_best_parameters_dict()
wanted = {'maxdist': 600.0, 'upfreq': 0.0, 'kforce': 5,
'dcutoff': 2,
'reference': '', 'lowfreq': -0.6, 'scale': 0.01}
self.assertEqual([round(i, 4) for i in config.values()if not type(i) is str],
[round(i, 4) for i in wanted.values()if not type(i) is str])
if CHKTIME:
print '12', time() - t0
示例6: test_08_changing_resolution
# 需要导入模块: from pytadbit import Chromosome [as 别名]
# 或者: from pytadbit.Chromosome import add_experiment [as 别名]
def test_08_changing_resolution(self):
if ONLY and ONLY != "08":
return
if CHKTIME:
t0 = time()
test_chr = Chromosome(name="Test Chromosome", max_tad_size=260000)
test_chr.add_experiment("exp1", 20000, tad_def=exp4, hic_data=PATH + "/20Kb/chrT/chrT_D.tsv", silent=True)
exp = test_chr.experiments["exp1"]
sum20 = sum(exp.hic_data[0].values())
exp.set_resolution(80000)
sum80 = sum(exp.hic_data[0].values())
check_hic(exp.hic_data[0], exp.size)
exp.set_resolution(160000)
sum160 = sum(exp.hic_data[0].values())
check_hic(exp.hic_data[0], exp.size)
exp.set_resolution(360000)
sum360 = sum(exp.hic_data[0].values())
check_hic(exp.hic_data[0], exp.size)
exp.set_resolution(2400000)
sum2400 = sum(exp.hic_data[0].values())
check_hic(exp.hic_data[0], exp.size)
exp.set_resolution(40000)
sum40 = sum(exp.hic_data[0].values())
check_hic(exp.hic_data[0], exp.size)
exp.set_resolution(20000)
sum21 = sum(exp.hic_data[0].values())
check_hic(exp.hic_data[0], exp.size)
exp.set_resolution(40000)
sum41 = sum(exp.hic_data[0].values())
check_hic(exp.hic_data[0], exp.size)
self.assertTrue(sum20 == sum80 == sum160 == sum360 == sum40 == sum21 == sum2400 == sum41)
if CHKTIME:
print "8", time() - t0
示例7: test_07_forbidden_regions
# 需要导入模块: from pytadbit import Chromosome [as 别名]
# 或者: from pytadbit.Chromosome import add_experiment [as 别名]
def test_07_forbidden_regions(self):
if ONLY and ONLY != "07":
return
if CHKTIME:
t0 = time()
test_chr = Chromosome(name="Test Chromosome", max_tad_size=260000, centromere_search=True)
test_chr.add_experiment("exp1", 20000, tad_def=exp4, hic_data=PATH + "/20Kb/chrT/chrT_D.tsv", silent=True)
# Values with square root normalization.
# brks = [2.0, 7.0, 12.0, 18.0, 38.0, 43.0, 49.0,
# 61.0, 66.0, 75.0, 89.0, 94.0, 99.0]
brks = [3.0, 14.0, 19.0, 33.0, 38.0, 43.0, 49.0, 61.0, 66.0, 71.0, 83.0, 89.0, 94.0, 99.0]
tads = test_chr.experiments["exp1"].tads
found = [tads[t]["end"] for t in tads if tads[t]["score"] > 0]
self.assertEqual(brks, found)
items1 = test_chr.forbidden.keys(), test_chr.forbidden.values()
test_chr.add_experiment("exp2", 20000, tad_def=exp3, hic_data=PATH + "/20Kb/chrT/chrT_C.tsv", silent=True)
items2 = test_chr.forbidden.keys(), test_chr.forbidden.values()
know1 = ([38, 39], ["Centromere", "Centromere"])
# know1 = ([32, 33, 34, 38, 39, 19, 20, 21, 22,
# 23, 24, 25, 26, 27, 28, 29, 30, 31],
# [None, None, None, 'Centromere', 'Centromere',
# None, None, None, None, None, None, None,
# None, None, None, None, None, None])
know2 = ([38], ["Centromere"])
self.assertEqual(items1, know1)
self.assertEqual(items2, know2)
if CHKTIME:
print "7", time() - t0
示例8: test_13_3d_modelling_centroid
# 需要导入模块: from pytadbit import Chromosome [as 别名]
# 或者: from pytadbit.Chromosome import add_experiment [as 别名]
def test_13_3d_modelling_centroid(self):
"""
quick test to generate 3D coordinates from 3? simple models???
"""
if ONLY and "13" not in ONLY:
return
if CHKTIME:
t0 = time()
try:
__import__("IMP")
except ImportError:
warn("IMP not found, skipping test\n")
return
test_chr = Chromosome(name="Test Chromosome", max_tad_size=260000)
test_chr.add_experiment("exp1", 20000, tad_def=exp4, hic_data=PATH + "/20Kb/chrT/chrT_D.tsv", silent=True)
exp = test_chr.experiments[0]
exp.load_hic_data(PATH + "/20Kb/chrT/chrT_A.tsv", silent=True)
exp.filter_columns(silent=True)
exp.normalize_hic(silent=True, factor=None)
models = exp.model_region(
51,
71,
ncopies=4,
n_models=10,
n_keep=10,
n_cpus=10,
# verbose=3,
config={"kforce": 5, "maxdist": 500, "scale": 0.01, "upfreq": 0.5, "lowfreq": -0.5},
)
models.save_models("models.pick")
avg = models.average_model()
nmd = len(models)
print "I'm here test 13"
示例9: main
# 需要导入模块: from pytadbit import Chromosome [as 别名]
# 或者: from pytadbit.Chromosome import add_experiment [as 别名]
def main():
"""
main function
"""
opts = get_options()
crm = Chromosome(':P')
for i, data in enumerate(opts.data):
crm.add_experiment('exp' + str(i), resolution=int(opts.resolution[i]),
hic_data=data)
crm.experiments['exp' + str(i)].normalize_hic()
if len(opts.data) > 1:
exp = crm.experiments[0] + crm.experiments[1]
for i in range(2, len(opts.data)):
exp += crm.experiments[i]
else:
exp = crm.experiments[0]
if opts.abc:
exp.write_interaction_pairs(opts.output, normalized=opts.norm,
zscored=False)
else:
if type(opts.output) == file:
out = opts.output
else:
out = open(opts.output, 'w')
out.write(exp.print_hic_matrix(print_it=False,
normalized=opts.norm))
示例10: test_08_changing_resolution
# 需要导入模块: from pytadbit import Chromosome [as 别名]
# 或者: from pytadbit.Chromosome import add_experiment [as 别名]
def test_08_changing_resolution(self):
test_chr = Chromosome(name='Test Chromosome', max_tad_size=260000)
test_chr.add_experiment('exp1', 20000, tad_def=exp4,
hic_data='20Kb/chrT/chrT_D.tsv')
exp = test_chr.experiments['exp1']
sum20 = sum(exp.hic_data[0])
exp.set_resolution(80000)
sum80 = sum(exp.hic_data[0])
check_hic(exp.hic_data[0], exp.size)
exp.set_resolution(160000)
sum160 = sum(exp.hic_data[0])
check_hic(exp.hic_data[0], exp.size)
exp.set_resolution(360000)
sum360 = sum(exp.hic_data[0])
check_hic(exp.hic_data[0], exp.size)
exp.set_resolution(2400000)
sum2400 = sum(exp.hic_data[0])
check_hic(exp.hic_data[0], exp.size)
exp.set_resolution(40000)
sum40 = sum(exp.hic_data[0])
check_hic(exp.hic_data[0], exp.size)
exp.set_resolution(20000)
sum21 = sum(exp.hic_data[0])
check_hic(exp.hic_data[0], exp.size)
exp.set_resolution(40000)
sum41 = sum(exp.hic_data[0])
check_hic(exp.hic_data[0], exp.size)
self.assertTrue(sum20 == sum80 == sum160 == sum360 == sum40 \
== sum21 == sum2400 == sum41)
示例11: main
# 需要导入模块: from pytadbit import Chromosome [as 别名]
# 或者: from pytadbit.Chromosome import add_experiment [as 别名]
def main():
matrix_path = sys.argv[1]
config_string = sys.argv[2]
compute_keep = sys.argv[3]
uf, lf, md = config_string.split(':')
lf = float(lf)
uf = float(uf)
md = int (md)
config = {'reference' : '', 'kforce' : 5,
'maxdist' : md,
'upfreq' : uf,
'lowfreq' : lf,
'scale' : 0.01,
'kbending' : 0.0,
}
compute, keep = map(int, compute_keep.split(':'))
chrom = Chromosome('chr')
chrom.add_experiment('sample', norm_data=matrix_path, resolution=15000)
exp = chrom.experiments[0]
models = exp.model_region(n_models=compute, n_keep=keep, n_cpus=8, config=config)
models.save_models('models_%s.pickle' % (config_string))
示例12: test_11_write_interaction_pairs
# 需要导入模块: from pytadbit import Chromosome [as 别名]
# 或者: from pytadbit.Chromosome import add_experiment [as 别名]
def test_11_write_interaction_pairs(self):
if ONLY and ONLY != '11':
return
"""
writes interaction pair file.
"""
if CHKTIME:
t0 = time()
test_chr = Chromosome(name='Test Chromosome', max_tad_size=260000)
test_chr.add_experiment('exp1', 20000, tad_def=exp4,
hic_data=PATH + '/20Kb/chrT/chrT_D.tsv')
exp = test_chr.experiments[0]
exp.load_hic_data(PATH + '/20Kb/chrT/chrT_A.tsv', silent=True)
exp.filter_columns(silent=True)
exp.normalize_hic(factor=None, silent=True)
exp.get_hic_zscores(zscored=False)
exp.write_interaction_pairs('lala')
lines = open('lala').readlines()
self.assertEqual(len(lines), 4674)
self.assertEqual(lines[25], '1\t28\t0.612332461036\n')
self.assertEqual(lines[2000], '26\t70\t0.0738742984321\n')
system('rm -f lala')
if CHKTIME:
print '11', time() - t0
示例13: tad_clustering
# 需要导入模块: from pytadbit import Chromosome [as 别名]
# 或者: from pytadbit.Chromosome import add_experiment [as 别名]
def tad_clustering(self):
test_chr = Chromosome(name="Test Chromosome", resolution=20000)
test_chr.add_experiment("chrT/chrT_A.tsv", name="exp1")
test_chr.find_TAD(["exp1"])
all_tads = list(test_chr.iter_tads("exp1"))
align1, align2 = optimal_cmo(all_tads[4], all_tads[8], 9)
self.assertEqual(align1, [1, 2, "-", "-", "-", "-", 3, "-", 4, 5, 6, "-", 7, 8])
self.assertEqual(align2, [2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15])
示例14: test_12_3d_modelling_optimization
# 需要导入模块: from pytadbit import Chromosome [as 别名]
# 或者: from pytadbit.Chromosome import add_experiment [as 别名]
def test_12_3d_modelling_optimization(self):
"""
quick test to generate 3D coordinates from 3? simple models???
"""
if ONLY and "12" not in ONLY:
return
if CHKTIME:
t0 = time()
try:
__import__("IMP")
except ImportError:
warn("IMP not found, skipping test\n")
return
test_chr = Chromosome(name="Test Chromosome", max_tad_size=260000)
test_chr.add_experiment(
"exp1", 20000, tad_def=exp4, hic_data=PATH + "/20Kb/chrT/chrT_D.tsv"
) # norm_data para dar directamente la matrix normalizada
exp = test_chr.experiments[0]
exp.load_hic_data(PATH + "/20Kb/chrT/chrT_A.tsv")
exp.filter_columns(silent=True)
exp.normalize_hic(silent=True, factor=None)
result = exp.optimal_imp_parameters(
50,
70,
ncopies=4,
n_cpus=1, # It can be that this function requires also the raw hic_data matrix
n_models=8,
n_keep=2,
lowfreq_range=[-0.6],
upfreq_range=(0, 1.1, 1.1),
maxdist_range=[500, 600],
verbose=True,
)
# get best correlations
config = result.get_best_parameters_dict()
# Save the models and the contact map
# result.save_model or result.save_data
# result.write_cmm to visualize the best models
# result.write_xyz to visualize the best models
wanted = {
"maxdist": 600.0,
"upfreq": 0.0,
"kforce": 5,
"dcutoff": 2,
"reference": "",
"lowfreq": -0.6,
"scale": 0.01,
}
self.assertEqual(
[round(i, 4) for i in config.values() if not type(i) is str],
[round(i, 4) for i in wanted.values() if not type(i) is str],
)
if CHKTIME:
print "12", time() - t0
示例15: test_09_hic_normalization
# 需要导入模块: from pytadbit import Chromosome [as 别名]
# 或者: from pytadbit.Chromosome import add_experiment [as 别名]
def test_09_hic_normalization(self):
"""
TODO: check with Davide's script
"""
test_chr = Chromosome(name='Test Chromosome', max_tad_size=260000)
test_chr.add_experiment('exp1', 20000, tad_def=exp4,
hic_data='20Kb/chrT/chrT_D.tsv')
exp = test_chr.experiments[0]
exp.load_experiment('20Kb/chrT/chrT_A.tsv')
exp.get_hic_zscores()
exp.get_hic_zscores(zscored=False)