Esempio n. 1
0
def do_bootstrap():
    """
    Do a bootstrap analysis on GO p-values.
    """
    logging.info(
        'Running GO bootstrap analysis with %d samples: topGO method=%s',
        options.num_bootstrap_samples, options.topgo_method)
    transcriptional_programs, factor_universe, target_universe = tp_threshold.threshold_tps(
    )
    genes_2_GO, go_context = go.initialise_go_context(factor_universe,
                                                      target_universe,
                                                      options.go_ontologies)
    tp_sizes = filter(
        None, map(len, (tp.targets for tp in transcriptional_programs)))
    p_values = list()
    for sample in generate_bootstrap_samples(options.num_bootstrap_samples,
                                             target_universe, tp_sizes):
        go_analysis = dict(
            (ontology,
             go.try_go_analysis(go_data, sample, 1., options.topgo_method))
            for ontology, go_data in go_context.targets_go_data.iteritems())
        best_p_value = min(
            map(topgo.p_value_from_r,
                map(topgo.best_p_value, go_analysis.values())))
        p_values.append(best_p_value)
    logging.info('GO bootstrap analysis completed')
    return p_values
Esempio n. 2
0
def do_bootstrap():
    """
    Do a bootstrap analysis on GO p-values.
    """
    logging.info('Running GO bootstrap analysis with %d samples: topGO method=%s', options.num_bootstrap_samples, options.topgo_method)
    transcriptional_programs, factor_universe, target_universe = tp_threshold.threshold_tps()
    genes_2_GO, go_context = go.initialise_go_context(factor_universe, target_universe, options.go_ontologies)
    tp_sizes = filter(None, map(len, (tp.targets for tp in transcriptional_programs)))
    p_values = list()
    for sample in generate_bootstrap_samples(options.num_bootstrap_samples, target_universe, tp_sizes):
        go_analysis = dict(
            (
                ontology,
                go.try_go_analysis(
                    go_data,
                    sample,
                    1.,
                    options.topgo_method
                )
            )
            for ontology, go_data
            in go_context.targets_go_data.iteritems()
        )
        best_p_value = min(map(topgo.p_value_from_r, map(topgo.best_p_value, go_analysis.values())))
        p_values.append(best_p_value)
    logging.info('GO bootstrap analysis completed')
    return p_values
Esempio n. 3
0
def go_analysis():
    logging.info('Running GO analysis: p-value threshold=%e; topGO method=%s',
                 options.go_p_value_threshold, options.topgo_method)
    transcriptional_programs, factor_universe, target_universe = tp_threshold.threshold_tps(
    )
    genes_2_GO, go_context = go.initialise_go_context(factor_universe,
                                                      target_universe,
                                                      options.go_ontologies)
    go_analyses = list()
    f = open(os.path.join(options.output_dir, 'go-analyses.txt'), 'w')
    for tp in transcriptional_programs:
        go_analysis = go.TPGoAnalysis(tp, go_context,
                                      options.go_p_value_threshold,
                                      options.topgo_method)
        go_analysis.print_go_analyses(f,
                                      options.go_p_value_threshold,
                                      log=True)
        go_analysis.print_go_analyses(sys.stdout, options.go_p_value_threshold)
        go_analyses.append(go_analysis)
    f.close()
    write_latex(go_analyses)