Пример #1
0
def _plot_genes_job(gene, region_series_fits, filename, bin_centers):
    with interactive(False):
        print 'Saving figure for gene {}'.format(gene)
        fig = _plot_gene_inner(gene,
                               region_series_fits,
                               change_distribution_bin_centers=bin_centers)
        save_figure(fig, filename, b_close=True)
Пример #2
0
def _plot_exons_job(gene, region, exons_series_fits, filename):
    with interactive(False):
        print 'Saving Exons figure for gene {} on region {}'.format(
            gene, region)
        exons_chunks = split_list(exons_series_fits, cfg.exons_per_plot)
        for i, chunk in enumerate(exons_chunks):
            fig = _plot_exons_inner(gene, region, chunk, i + 1,
                                    len(exons_chunks))
            curr_fig_filename = filename[:-4] + cfg.exon_separator + str(
                i + 1) + filename[-4:] if i > 0 else filename
            save_figure(fig, curr_fig_filename, b_close=True, b_square=False)
Пример #3
0
def _plot_series_job(series, fit, filename, use_correlations, change_distribution, figure_kw):
    if figure_kw is None:
        figure_kw = {}
    with interactive(False):
        print 'Saving figure for {}@{}'.format(series.gene_name, series.region_name)
        if use_correlations:
            preds = fit.with_correlations.LOO_predictions
        else:
            preds = fit.LOO_predictions
        fig = plot_one_series(series, fit.fitter.shape, fit.theta, preds, change_distribution=change_distribution, **figure_kw)
        save_figure(fig, filename, b_close=True)
Пример #4
0
def _plot_series_job(series, fit, filename, use_correlations,
                     change_distribution, figure_kw):
    if figure_kw is None:
        figure_kw = {}
    with interactive(False):
        print 'Saving figure for {}@{}'.format(series.gene_name,
                                               series.region_name)
        if use_correlations:
            preds = fit.with_correlations.LOO_predictions
        else:
            preds = fit.LOO_predictions
        fig = plot_one_series(series,
                              fit.fitter.shape,
                              fit.theta,
                              preds,
                              change_distribution=change_distribution,
                              **figure_kw)
        save_figure(fig, filename, b_close=True)
Пример #5
0
def create_score_distribution_html(fits, use_correlations, dirname):
    ensure_dir(dirname)
    with interactive(False):
        hist_filename = 'R2-hist.png'
        fig = plot_score_distribution(fits,use_correlations)
        save_figure(fig, join(dirname,hist_filename), b_close=True)
        
        if use_correlations:
            scatter_filename = 'comparison-scatter.png'
            fig = plot_score_comparison_scatter_for_correlations(fits)
            save_figure(fig, join(dirname,scatter_filename), b_close=True)
            
            delta_hist_filename = 'R2-delta-hist.png'
            fig = plot_score_improvement_histogram_for_correlations(fits)
            save_figure(fig, join(dirname,delta_hist_filename), b_close=True)
                        
    image_size = "50%"
    from jinja2 import Template
    import shutil
    html = Template("""
<html>
<head>
    <link rel="stylesheet" type="text/css" href="score-distribution.css">
</head>
<body>
<center><H1>R2 Score Distribution</H1></center>

<a href="{{hist_filename}}"> <img src="{{hist_filename}}" height="{{image_size}}"></a>

{% if use_correlations %}
    <a href="{{delta_hist_filename}}"> <img src="{{delta_hist_filename}}" height="{{image_size}}"></a>
    <a href="{{scatter_filename}}"> <img src="{{scatter_filename}}" height="{{image_size}}"></a>
{% endif %}

</body>
</html>    
""").render(**locals())
    filename = join(dirname,'scores.html')
    with open(filename, 'w') as f:
        f.write(html)
    shutil.copy(join(resources_dir(),'score-distribution.css'), dirname)
Пример #6
0
def create_score_distribution_html(fits, use_correlations, dirname):
    ensure_dir(dirname)
    with interactive(False):
        hist_filename = 'R2-hist.png'
        fig = plot_score_distribution(fits, use_correlations)
        save_figure(fig, join(dirname, hist_filename), b_close=True)

        if use_correlations:
            scatter_filename = 'comparison-scatter.png'
            fig = plot_score_comparison_scatter_for_correlations(fits)
            save_figure(fig, join(dirname, scatter_filename), b_close=True)

            delta_hist_filename = 'R2-delta-hist.png'
            fig = plot_score_improvement_histogram_for_correlations(fits)
            save_figure(fig, join(dirname, delta_hist_filename), b_close=True)

    image_size = "50%"

    import shutil
    html = get_jinja_env().get_template('R2.jinja').render(**locals())
    filename = join(dirname, 'scores.html')
    with open(filename, 'w') as f:
        f.write(html)
    shutil.copy(join(resources_dir(), 'score-distribution.css'), dirname)
Пример #7
0
def _plot_genes_job(gene, region_series_fits, filename, bin_centers):
    with interactive(False):
        print 'Saving figure for gene {}'.format(gene)
        fig = _plot_gene_inner(gene, region_series_fits, change_distribution_bin_centers=bin_centers)
        save_figure(fig, filename, b_close=True)