当前位置: 首页>>代码示例>>Python>>正文


Python pytadbit.Chromosome类代码示例

本文整理汇总了Python中pytadbit.Chromosome的典型用法代码示例。如果您正苦于以下问题:Python Chromosome类的具体用法?Python Chromosome怎么用?Python Chromosome使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了Chromosome类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: main

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()
开发者ID:dbau,项目名称:tadbit,代码行数:35,代码来源:model_region.py

示例2: load_hic_data

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
开发者ID:Adrimel,项目名称:tadbit,代码行数:35,代码来源:model_and_analyze.py

示例3: test_11_write_interaction_pairs

    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
开发者ID:kangk1204,项目名称:TADbit,代码行数:25,代码来源:test_all.py

示例4: test_08_changing_resolution

    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
开发者ID:lelou6666,项目名称:TADbit,代码行数:35,代码来源:test_all.py

示例5: test_13_3d_modelling_centroid

    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"
开发者ID:MarcoDiS,项目名称:TADbit,代码行数:35,代码来源:test_all.py

示例6: test_08_changing_resolution

    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
开发者ID:MarcoDiS,项目名称:TADbit,代码行数:34,代码来源:test_all.py

示例7: test_06_tad_clustering

    def test_06_tad_clustering(self):
        if ONLY and ONLY != "06":
            return
        if CHKTIME:
            t0 = time()

        test_chr = Chromosome(
            name="Test Chromosome",
            experiment_tads=[exp4],
            experiment_names=["exp1"],
            experiment_hic_data=[PATH + "/20Kb/chrT/chrT_D.tsv"],
            experiment_resolutions=[20000, 20000],
            silent=True,
        )
        all_tads = []
        for _, tad in test_chr.iter_tads("exp1", normed=False):
            all_tads.append(tad)
        # align1, align2, _ = optimal_cmo(all_tads[7], all_tads[10], 7,
        #                                method='score')
        align1, align2, _ = optimal_cmo(all_tads[1], all_tads[3], 7, method="score")
        # Values with square root normalization.
        # self.assertEqual(align1, [0, 1, '-', 2, 3, '-', 4, 5, 6, 7, 8, 9, 10])
        # self.assertEqual(align2,[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12])
        self.assertEqual(align1, [0, 1, 2, "-", "-", 3, 4, 5, 6, 7, 8, "-", 9])
        self.assertEqual(align2, [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12])
        if CHKTIME:
            print "6", time() - t0
开发者ID:MarcoDiS,项目名称:TADbit,代码行数:27,代码来源:test_all.py

示例8: test_07_forbidden_regions

    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
开发者ID:MarcoDiS,项目名称:TADbit,代码行数:29,代码来源:test_all.py

示例9: test_04_chromosome_batch

    def test_04_chromosome_batch(self):
        if ONLY and ONLY != '04':
            return
        if CHKTIME:
            t0 = time()

        test_chr = Chromosome(name='Test Chromosome',
                              experiment_resolutions=[20000]*3,
                              experiment_hic_data=[
                                  PATH + '/20Kb/chrT/chrT_A.tsv',
                                  PATH + '/20Kb/chrT/chrT_D.tsv',
                                  PATH + '/20Kb/chrT/chrT_C.tsv'],
                              experiment_names=['exp1', 'exp2', 'exp3'],
                              silent=True)
        test_chr.find_tad(['exp1', 'exp2', 'exp3'], batch_mode=True,
                          verbose=False, silent=True)
        tads = test_chr.get_experiment('batch_exp1_exp2_exp3').tads
        found = [tads[t]['end'] for t in tads if tads[t]['score'] > 0]
        # Values obtained with square root normalization.
        #self.assertEqual([3.0, 8.0, 16.0, 21.0, 28.0, 35.0, 43.0,
        #                  49.0, 61.0, 66.0, 75.0, 89.0, 94.0, 99.0], found)
        self.assertEqual([3.0, 14.0, 19.0, 33.0, 43.0, 49.0, 61.0, 66.0,
                           71.0, 89.0, 94.0, 99.0], found)
        
        if CHKTIME:
            print '4', time() - t0
开发者ID:kangk1204,项目名称:TADbit,代码行数:26,代码来源:test_all.py

示例10: test_04_chromosome_batch

    def test_04_chromosome_batch(self):
        if ONLY and ONLY != "04":
            return
        if CHKTIME:
            t0 = time()

        test_chr = Chromosome(
            name="Test Chromosome",
            experiment_resolutions=[20000] * 3,
            experiment_hic_data=[
                PATH + "/20Kb/chrT/chrT_A.tsv",
                PATH + "/20Kb/chrT/chrT_D.tsv",
                PATH + "/20Kb/chrT/chrT_C.tsv",
            ],
            experiment_names=["exp1", "exp2", "exp3"],
            silent=True,
        )
        test_chr.find_tad(["exp1", "exp2", "exp3"], batch_mode=True, verbose=False, silent=True)
        tads = test_chr.get_experiment("batch_exp1_exp2_exp3").tads
        found = [tads[t]["end"] for t in tads if tads[t]["score"] > 0]
        # Values obtained with square root normalization.
        # self.assertEqual([3.0, 8.0, 16.0, 21.0, 28.0, 35.0, 43.0,
        #                  49.0, 61.0, 66.0, 75.0, 89.0, 94.0, 99.0], found)
        self.assertEqual([3.0, 14.0, 19.0, 33.0, 43.0, 49.0, 61.0, 66.0, 71.0, 89.0, 94.0, 99.0], found)

        if CHKTIME:
            print "4", time() - t0
开发者ID:MarcoDiS,项目名称:TADbit,代码行数:27,代码来源:test_all.py

示例11: main

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))
开发者ID:3DGenomes,项目名称:TADbit,代码行数:26,代码来源:model_from_matrix.py

示例12: load_genome_from_tad_def

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
开发者ID:MarcoDiS,项目名称:TADbit,代码行数:26,代码来源:remap_tads_maf_alignment.py

示例13: test_08_changing_resolution

 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)
开发者ID:dbau,项目名称:tadbit,代码行数:29,代码来源:test_all.py

示例14: test_12_3d_modelling_optimization

    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
开发者ID:lelou6666,项目名称:TADbit,代码行数:35,代码来源:test_all.py

示例15: test_03_tad_multi_aligner

    def test_03_tad_multi_aligner(self):

        if CHKTIME:
            t0 = time()

        test_chr = Chromosome(name='Test Chromosome', centromere_search=True,
                              experiment_tads=[exp1, exp2, exp3, exp4],
                              experiment_hic_data=[
                                  PATH + '/40Kb/chrT/chrT_A.tsv',
                                  PATH + '/20Kb/chrT/chrT_B.tsv',
                                  PATH + '/20Kb/chrT/chrT_C.tsv',
                                  PATH + '/20Kb/chrT/chrT_D.tsv'],
                              experiment_names=['exp1', 'exp2', 'exp3', 'exp4'],
                              experiment_resolutions=[40000,20000,20000,20000],
                              silent=True)
        for exp in test_chr.experiments:
            exp.normalize_hic(silent=True, factor=None)

        test_chr.align_experiments(verbose=False, randomize=False,
                                   method='global')
        _, (score1, pval1) = test_chr.align_experiments(verbose=False,
                                                        method='global',
                                                        randomize=True, rnd_num=100)
        _, (_, pval2) = test_chr.align_experiments(verbose=False, randomize=True,
                                                   rnd_method='shuffle', rnd_num=100)
        # Values with alignments obtained with square root normalization.
        #self.assertEqual(round(-26.095, 3), round(score1, 3))
        #self.assertEqual(round(0.001, 1), round(pval1, 1))
        #self.assertTrue(abs(0.175 - pval2) < 0.2)
        self.assertEqual(round(-11.002, 3), round(score1, 3))
        self.assertEqual(round(0.001, 1), round(pval1, 1))
        self.assertTrue(abs(0.04 - pval2) < 0.1)
        if CHKTIME:
            print '3', time() - t0
开发者ID:mrG7,项目名称:TADbit,代码行数:34,代码来源:test_all.py


注:本文中的pytadbit.Chromosome类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。