コード例 #1
0
def compare_cumulative_yields(df, path, palette=None, title=None):
    if palette is None:
        palette = plotly.colors.DEFAULT_PLOTLY_COLORS * 5
    dfs = check_valid_time_and_sort(df, "start_time").set_index("start_time")

    logging.info(
        "NanoComp: Creating cumulative yield plots using {} reads.".format(
            len(dfs)))
    cum_yield_gb = Plot(path=path +
                        "NanoComp_CumulativeYieldPlot_Gigabases.html",
                        title="Cumulative yield")
    data = []
    annotations = []
    for sample, color in zip(df["dataset"].unique(), palette):
        cumsum = dfs.loc[dfs["dataset"] == sample,
                         "lengths"].cumsum().resample('10T').max() / 1e9
        data.append(
            go.Scatter(x=cumsum.index.total_seconds() / 3600,
                       y=cumsum,
                       opacity=0.75,
                       name=sample,
                       marker=dict(color=color)))
        annotations.append(
            dict(xref='paper',
                 x=0.99,
                 y=cumsum[-1],
                 xanchor='left',
                 yanchor='middle',
                 text='{}Gb'.format(round(cumsum[-1])),
                 showarrow=False))

    cum_yield_gb.html = plotly.offline.plot(
        {
            "data":
            data,
            "layout":
            go.Layout(barmode='overlay',
                      title=title or cum_yield_gb.title,
                      xaxis=dict(title="Time (hours)"),
                      yaxis=dict(title="Yield (gigabase)"),
                      annotations=annotations)
        },
        output_type="div",
        show_link=False)

    cum_yield_gb.fig = go.Figure({
        "data":
        data,
        "layout":
        go.Layout(barmode='overlay',
                  title=title or cum_yield_gb.title,
                  xaxis=dict(title="Time (hours)"),
                  yaxis=dict(title="Yield (gigabase)"),
                  annotations=annotations)
    })
    cum_yield_gb.save()
    return [cum_yield_gb]
コード例 #2
0
ファイル: compplots.py プロジェクト: RADnovogene/nanoplotter
def compare_cumulative_yields(df, path, palette=None, title=None):
    if palette is None:
        palette = plotly.colors.DEFAULT_PLOTLY_COLORS * 5
    dfs = check_valid_time_and_sort(df, "start_time").set_index("start_time")

    logging.info(
        "Nanoplotter: Creating cumulative yield plots using {} reads.".format(
            len(dfs)))
    cum_yield_gb = Plot(path=path +
                        "NanoComp_CumulativeYieldPlot_Gigabases.html",
                        title="Cumulative yield")
    data = []
    for d, c in zip(df["dataset"].unique(), palette):
        s = dfs.loc[dfs["dataset"] == d,
                    "lengths"].cumsum().resample('10T').max() / 1e9
        data.append(
            go.Scatter(x=s.index.total_seconds() / 3600,
                       y=s,
                       opacity=0.75,
                       name=d,
                       marker=dict(color=c)))
    cum_yield_gb.html = plotly.offline.plot(
        {
            "data":
            data,
            "layout":
            go.Layout(
                barmode='overlay',
                title=title or cum_yield_gb.title,
                xaxis=dict(title="Time (hours)"),
                yaxis=dict(title="Yield (gigabase)"),
            )
        },
        output_type="div",
        show_link=False)

    cum_yield_gb.fig = go.Figure({
        "data":
        data,
        "layout":
        go.Layout(
            barmode='overlay',
            title=title or cum_yield_gb.title,
            xaxis=dict(title="Time (hours)"),
            yaxis=dict(title="Yield (gigabase)"),
        )
    })
    cum_yield_gb.save()
    return [cum_yield_gb]
コード例 #3
0
def active_pores_over_time(df, path, palette=None, title=None):
    if palette is None:
        palette = plotly.colors.DEFAULT_PLOTLY_COLORS * 5
    dfs = check_valid_time_and_sort(df, "start_time").set_index("start_time")

    logging.info("NanoComp: Creating active pores plot using {} reads.".format(
        len(dfs)))
    active_pores = Plot(path=path + "NanoComp_ActivePoresOverTime.html",
                        title="Active pores over time")
    data = []
    for sample, color in zip(df["dataset"].unique(), palette):
        pores = dfs.loc[dfs["dataset"] == sample,
                        "channelIDs"].resample('10T').nunique()
        data.append(
            go.Scatter(x=pores.index.total_seconds() / 3600,
                       y=pores,
                       opacity=0.75,
                       name=sample,
                       marker=dict(color=color)))

    active_pores.html = plotly.offline.plot(
        {
            "data":
            data,
            "layout":
            go.Layout(
                barmode='overlay',
                title=title or active_pores.title,
                xaxis=dict(title="Time (hours)"),
                yaxis=dict(title="Active pores (per 10 minutes)"),
            )
        },
        output_type="div",
        show_link=False)

    active_pores.fig = go.Figure({
        "data":
        data,
        "layout":
        go.Layout(
            barmode='overlay',
            title=title or active_pores.title,
            xaxis=dict(title="Time (hours)"),
            yaxis=dict(title="Active pores (per 10 minutes)"),
        )
    })
    active_pores.save()
    return active_pores
コード例 #4
0
ファイル: compplots.py プロジェクト: RADnovogene/nanoplotter
def compare_sequencing_speed(df, figformat, path, title=None, palette=None):
    logging.info(
        "Nanoplotter: creating comparison of sequencing speed over time.")
    seq_speed = Plot(path=path + "NanoComp_sequencing_speed_over_time." +
                     figformat,
                     title="Sequencing speed over time")
    dfs = check_valid_time_and_sort(df, "start_time")
    dfs['timebin'] = add_time_bins(dfs)
    ax = sns.violinplot(x=dfs["timebin"],
                        y=dfs["lengths"] / dfs["duration"],
                        hue=dfs["dataset"],
                        inner=None,
                        cut=0,
                        linewidth=0)
    ax.set(xlabel='Interval (hours)',
           ylabel="Sequencing speed (nucleotides/second)")
    plt.xticks(rotation=45, ha='center', fontsize=8)
    seq_speed.fig = ax.get_figure()
    seq_speed.save(format=figformat)
    plt.close("all")
    return [seq_speed]
コード例 #5
0
def compare_sequencing_speed(df, path, settings, title=None):
    logging.info(
        "NanoComp: creating comparison of sequencing speed over time.")
    seq_speed = Plot(path=path + "NanoComp_sequencing_speed_over_time.html",
                     title="Sequencing speed over time")

    dfs = check_valid_time_and_sort(df, "start_time").set_index("start_time")
    dfs = dfs.loc[dfs["duration"] > 0]

    palette = plotly.colors.DEFAULT_PLOTLY_COLORS * 5

    data = []
    for sample, color in zip(df["dataset"].unique(), palette):
        seqspeed = (dfs.loc[dfs["dataset"] == sample, "lengths"] /
                    dfs.loc[dfs["dataset"] == sample,
                            "duration"]).resample('30T').median()
        data.append(
            go.Scatter(x=seqspeed.index.total_seconds() / 3600,
                       y=seqspeed,
                       opacity=0.75,
                       name=sample,
                       mode='lines',
                       marker=dict(color=color)))

    seq_speed.fig = go.Figure({"data": data})

    seq_speed.fig.update_layout(
        title=title or seq_speed.title,
        title_x=0.5,
        xaxis_title='Interval (hours)',
        yaxis_title="Sequencing speed (nucleotides/second)")

    seq_speed.html = seq_speed.fig.to_html(full_html=False,
                                           include_plotlyjs='cdn')
    seq_speed.save(settings)
    return [seq_speed]