예제 #1
0
def draw_read_pos_stats(stats, plot_fhand):
    n_read_groups = len(stats['5_read_pos_counts'])
    figure, canvas = get_fig_and_canvas(n_read_groups, 2)
    n_plot = 0
    for read_group in stats['5_read_pos_counts'].keys():
        rg_stat = {
            '5_read_pos_counts': stats['5_read_pos_counts'][read_group],
            '3_read_pos_counts': stats['3_read_pos_counts'][read_group],
            '5_read_pos_boxplot': stats['5_read_pos_boxplot'][read_group],
            '3_read_pos_boxplot': stats['3_read_pos_boxplot'][read_group]
        }
        n_plot += 1
        axes1 = figure.add_subplot(n_read_groups, 2, n_plot)
        if read_group is None:
            title = "Pos. counted from 5'"
        else:
            title = "Pos. counted from 5' (rg: {})".format(read_group)
        _draw_one_read_pos_stats(rg_stat, axes1, '5_read_pos_boxplot',
                                 '5_read_pos_counts', title)
        if read_group is None:
            title = "Pos. counted from 3'"
        else:
            title = "Pos. counted from 3' (rg: {})".format(read_group)
        n_plot += 1
        axes2 = figure.add_subplot(n_read_groups, 2, n_plot)
        _draw_one_read_pos_stats(rg_stat, axes2, '3_read_pos_boxplot',
                                 '3_read_pos_counts', title)
    canvas.print_figure(plot_fhand)
    plot_fhand.flush()
예제 #2
0
def draw_read_pos_stats(stats, plot_fhand):
    n_read_groups = len(stats['5_read_pos_counts'])
    figure, canvas = get_fig_and_canvas(n_read_groups, 2)
    n_plot = 0
    for read_group in stats['5_read_pos_counts'].keys():
        rg_stat = {'5_read_pos_counts': stats['5_read_pos_counts'][read_group],
                   '3_read_pos_counts': stats['3_read_pos_counts'][read_group],
                   '5_read_pos_boxplot': stats['5_read_pos_boxplot'][read_group],
                   '3_read_pos_boxplot': stats['3_read_pos_boxplot'][read_group]}
        n_plot += 1
        axes1 = figure.add_subplot(n_read_groups, 2, n_plot)
        if read_group is None:
            title = "Pos. counted from 5'"
        else:
            title = "Pos. counted from 5' (rg: {})".format(read_group)
        _draw_one_read_pos_stats(rg_stat, axes1, '5_read_pos_boxplot',
                                 '5_read_pos_counts', title)
        if read_group is None:
            title = "Pos. counted from 3'"
        else:
            title = "Pos. counted from 3' (rg: {})".format(read_group)
        n_plot += 1
        axes2 = figure.add_subplot(n_read_groups, 2, n_plot)
        _draw_one_read_pos_stats(rg_stat, axes2, '3_read_pos_boxplot',
                                 '3_read_pos_counts', title)
    canvas.print_figure(plot_fhand)
    plot_fhand.flush()
예제 #3
0
def plot_in_genome(iterator, out_base, labels):
    xsize = 100
    ysize = 10

    for chrom, x_vals, y_vals in window_data_by_chrom(iterator):
        fig, canvas = get_fig_and_canvas(figsize=(xsize, ysize))

        num_axes = len(y_vals)
        for index, plotname in enumerate(labels.keys()):
            plot_label = labels[plotname]
            axes = fig.add_subplot(num_axes, 1, index + 1)
            axes.plot(x_vals, y_vals[plotname])
            title = plot_label['title'] + ' for chromosome {}'.format(chrom)
            axes.set_title(title)
            axes.set_ylabel(plot_label['ylabel'])

        axes.set_xlabel('Position in chromosome')

        fhand = open(out_base + '.' + str(chrom) + '.png', 'w')

        canvas.print_figure(fhand, dpi=300)
        fhand.flush()
예제 #4
0
def plot_in_genome(iterator, out_base, labels):
    xsize = 100
    ysize = 10

    for chrom, x_vals, y_vals in window_data_by_chrom(iterator):
        fig, canvas = get_fig_and_canvas(figsize=(xsize, ysize))

        num_axes = len(y_vals)
        for index, plotname in enumerate(labels.keys()):
            plot_label = labels[plotname]
            axes = fig.add_subplot(num_axes, 1, index + 1)
            axes.plot(x_vals, y_vals[plotname])
            title = plot_label['title'] + ' for chromosome {}'.format(chrom)
            axes.set_title(title)
            axes.set_ylabel(plot_label['ylabel'])

        axes.set_xlabel('Position in chromosome')

        fhand = open(out_base + '.' + str(chrom) + '.png', 'w')

        canvas.print_figure(fhand, dpi=300)
        fhand.flush()