示例#1
0
def template_vdom_motif_pair(main_motif,
                             motif_pair,
                             lpdata,
                             dfab,
                             profile_mapping,
                             figures_dir,
                             figures_url,
                             cache=False,
                             **kwargs):

    motif_figs = []
    other = motif_pair[0] if motif_pair[0] != main_motif else motif_pair[1]
    # HACK - pass the tasks
    for task in ['Oct4', 'Sox2', 'Nanog', 'Klf4']:
        figs, dist_seq = motif_pair_figs(main_motif, task, motif_pair, lpdata,
                                         dfab, **kwargs)
        motif_figs += figs
        if task == profile_mapping[main_motif]:
            dist_seq_fig = dist_seq

    return details(
        summary(b(main_motif), f" (perturb {other})"), *[
            details(
                summary(k), *[
                    cache_fig(x,
                              figures_dir,
                              figures_url,
                              str(i) + "-" + main_motif + "<>" + other + "-" +
                              k,
                              width=840 if k is not "Distance" else 400,
                              cache=cache) for i, x in enumerate(v)
                ]) for k, v in dist_seq_fig + motif_figs
        ])
示例#2
0
def vdm_heatmaps(seqlets,
                 d,
                 included_samples,
                 tasks,
                 pattern,
                 top_n=None,
                 pssm_fig=None,
                 opened=False,
                 resize_width=200):
    ex_signal, ex_contrib_profile, ex_contrib_counts, ex_seq, sort_idx = get_signal(
        seqlets, d, included_samples, tasks, resize_width=resize_width)

    if top_n is not None:
        sort_idx = sort_idx[:top_n]
    return div(
        details(summary("Sequence:"),
                pssm_fig,
                br(),
                fig2vdom(
                    heatmap_sequence(ex_seq,
                                     sort_idx=sort_idx,
                                     figsize_tmpl=(10, 15),
                                     aspect='auto')),
                open=opened),
        details(
            summary("ChIP-nexus counts:"),
            fig2vdom(
                multiple_plot_stranded_profile(
                    ex_signal, figsize_tmpl=(20 / len(ex_signal), 3))),
            # TODO - change
            fig2vdom(
                multiple_heatmap_stranded_profile(ex_signal,
                                                  sort_idx=sort_idx,
                                                  figsize=(20, 20))),
            open=opened),
        details(summary("Contribution scores (profile)"),
                fig2vdom(
                    multiple_heatmap_contribution_profile(ex_contrib_profile,
                                                          sort_idx=sort_idx,
                                                          figsize=(20, 20))),
                open=opened),
        details(summary("Contribution scores (counts)"),
                fig2vdom(
                    multiple_heatmap_contribution_profile(ex_contrib_counts,
                                                          sort_idx=sort_idx,
                                                          figsize=(20, 20))),
                open=opened))
示例#3
0
def template_vdom_metacluster(name,
                              n_patterns,
                              n_seqlets,
                              important_for,
                              patterns,
                              is_open=False):
    return details(summary(
        b(name), f", # patterns: {n_patterns},"
        f" # seqlets: {n_seqlets}, "
        "important for: ", b(important_for)),
                   ul([li(pattern) for pattern in patterns], start=0),
                   id=name,
                   open=is_open)
示例#4
0
def template_vdom_pattern(name,
                          n_seqlets,
                          trimmed_motif,
                          full_motif,
                          figures_url,
                          add_plots={},
                          metacluster=""):

    return details(
        summary(
            name,
            f": # seqlets: {n_seqlets}",
            # br(),
            trimmed_motif),  # ", rc: ",  motif_rc),
        details(
            summary("Aggregated profiles and contribution scores)"),
            img(src=figures_url + "/agg_profile_contribcores.png", width=840),
        ),
        details(
            summary("Aggregated hypothetical contribution scores)"),
            img(src=figures_url + "/agg_profile_hypcontribscores.png",
                width=840),
        ),
        details(
            summary("Sequence"),
            full_motif,
            br(),
            img(src=figures_url + "/heatmap_seq.png", width=840 // 2),
        ),
        details(
            summary("ChIP-nexus counts"),
            img(src=figures_url + "/profile_aggregated.png", width=840),
            img(src=figures_url + "/profile_heatmap.png", width=840),
        ),
        details(
            summary("Importance scores (profile)"),
            img(src=figures_url + "/contrib_profile.png", width=840),
        ),
        details(
            summary("Importance scores (counts)"),
            img(src=figures_url + "/contrib_counts.png", width=840),
        ),
        *[details(summary(k), *v) for k, v in add_plots.items()],
        id=metacluster + "/" + name)