Exemple #1
0
def report_stmt_types(stmts, plot_prefix=None):
    # Number of statements of different types
    stmt_types = [type(stmt) for stmt in stmts]
    stmt_type_counter = Counter(stmt_types)

    fig = plt.figure(figsize=(2, 3), dpi=300)
    ax = fig.gca()
    sorted_counts = sorted(stmt_type_counter.items(),
                           key=lambda x: x[1],
                           reverse=True)
    labels = [t.__name__ for t, _ in sorted_counts]

    logger.info('Distribution of statement types:')
    for stmt_type, count in sorted_counts:
        logger.info('%s: %d' % (stmt_type.__name__, count))

    if plot_prefix:
        x_coords = np.arange(len(sorted_counts))
        ax.bar(x_coords, [x[1] for x in sorted_counts])
        ax.set_xticks(x_coords + 0.4)
        ax.set_xticklabels(labels, rotation=90)
        pf.format_axis(ax)
        ax.set_ylabel('No. of statements')
        plt.subplots_adjust(left=0.29, bottom=0.34)
        plt.savefig('%s_stmt_types.pdf' % plot_prefix)
Exemple #2
0
def plot_stmt_counts(go_stmt_map, plot_filename, figsize=(3, 3)):
    # Put together counts for a figure
    pf.set_fig_params()
    fig = plt.figure(figsize=(8, 4), dpi=200)
    ax = fig.gca()
    counts = []
    for go_id in go_stmt_map.keys():
        counts.append(
            (go_stmt_map[go_id]['names'][0], len(go_stmt_map[go_id]['in_go']),
             len(go_stmt_map[go_id]['not_in_go'])))
    counts.sort(key=lambda x: x[1] + x[2], reverse=True)
    indices = np.arange(len(counts))
    width = 0.8
    in_go = [c[1] for c in counts]
    labels = [c[0] for c in counts]
    not_in_go = [c[2] for c in counts]
    p1 = ax.bar(indices, in_go, width, color='b')
    p2 = ax.bar(indices, not_in_go, width, color='r', bottom=in_go)
    ax.set_ylabel('No. of stmts')
    plt.xlim([-0.2, len(counts)])
    plt.xticks(indices + width / 2., labels, rotation='vertical')
    plt.legend((p1[0], p2[0]), ('In GO', 'Not in GO'),
               frameon=False,
               fontsize=7)
    plt.subplots_adjust(left=0.08, bottom=0.44, top=0.85, right=0.97)
    pf.format_axis(ax)
    fig.savefig(plot_filename)
def report_stmt_counts(results, plot_prefix=None):
    counts_per_paper = [(pmid, len(stmts)) for pmid, stmts in results.items()]
    counts = np.array([tup[1] for tup in counts_per_paper])
    logger.info("%.2f +/- %.2f statements per paper" %
                (np.mean(counts), np.std(counts)))
    logger.info("Median %d statements per paper" % np.median(counts))

    zero_pmids = [pmid for pmid, stmts in results.items() if len(stmts) == 0]
    logger.info('%s papers with no statements' % len(zero_pmids))

    # Distribution of numbers of statements
    if plot_prefix:
        plot_filename = '%s_stmts_per_paper.png' % plot_prefix
        logger.info('Plotting distribution of statements per paper in %s' %
                    plot_filename)
        fig = plt.figure(figsize=(2, 2), dpi=300)
        ax = fig.gca()
        ax.hist(counts, bins=20)
        # ax.set_xticks([0, 100, 200, 300, 400])
        pf.format_axis(ax)
        plt.subplots_adjust(left=0.23, bottom=0.16)
        ax.set_xlabel('No. of statements')
        ax.set_ylabel('No. of papers')
        fig = plt.gcf()
        fig.savefig(plot_filename, format='png')
        logger.info('plotted...')
Exemple #4
0
def plot_stmt_counts(go_stmt_map, plot_filename, figsize=(3, 3)):
    # Put together counts for a figure
    pf.set_fig_params()
    fig = plt.figure(figsize=(8, 4), dpi=200)
    ax = fig.gca()
    counts = []
    for go_id in go_stmt_map.keys():
        counts.append((go_stmt_map[go_id]['names'][0],
                       len(go_stmt_map[go_id]['in_go']),
                       len(go_stmt_map[go_id]['not_in_go'])))
    counts.sort(key=lambda x: x[1] + x[2], reverse=True)
    indices = np.arange(len(counts))
    width = 0.8
    in_go = [c[1] for c in counts]
    labels = [c[0] for c in counts]
    not_in_go = [c[2] for c in counts]
    p1 = ax.bar(indices, in_go, width, color='b')
    p2 = ax.bar(indices, not_in_go, width, color='r', bottom=in_go)
    ax.set_ylabel('No. of stmts')
    plt.xlim([-0.2, len(counts)])
    plt.xticks(indices + width/2., labels, rotation='vertical')
    plt.legend((p1[0], p2[0]), ('In GO', 'Not in GO'), frameon=False,
               fontsize=7)
    plt.subplots_adjust(left=0.08, bottom=0.44, top=0.85, right=0.97)
    pf.format_axis(ax)
    fig.savefig(plot_filename)
 def plot_sites(gene_count_subset, figsize, subplot_params, do_legend=True):
     ind = np.array(range(len(gene_count_subset)))
     plt.figure(figsize=figsize, dpi=150)
     width = 0.8
     handle_dict = {}
     for ix, (gene, freq) in enumerate(gene_count_subset):
         # Plot the stacked bars
         bottom = 0
         for site_freq, valid, mapped_res, mapped_pos, explanation \
                 in site_counts[gene]:
             # Don't show sites that are valid
             mapped = True if mapped_res and mapped_pos else False
             if valid:
                 color = 'gray'
                 handle_key = 'Valid'
             elif mapped and \
                     explanation.startswith('INFERRED_METHIONINE_CLEAVAGE'):
                 color = 'b'
                 handle_key = 'Methionine'
             elif mapped and \
                     explanation.startswith('INFERRED_MOUSE_SITE'):
                 color = 'c'
                 handle_key = 'Mouse'
             elif mapped and \
                     explanation.startswith('INFERRED_RAT_SITE'):
                 color = 'purple'
                 handle_key = 'Rat'
             elif mapped and \
                     explanation.startswith('INFERRED_ALTERNATIVE_ISOFORM'):
                 color = 'orange'
                 handle_key = 'Alternative isoform'
             elif mapped:
                 color = 'g'
                 handle_key = 'Manually mapped'
             elif not mapped and explanation is not None \
                                         and explanation != 'VALID':
                 color = 'r'
                 handle_key = 'Curated as incorrect'
             elif not valid:
                 assert False
             else:
                 assert False  # Make sure we handled all cases above
             handle_dict[handle_key] = \
                     plt.bar(ix + 0.4, site_freq, bottom=bottom,
                             color=color, linewidth=0.5, width=width)
             bottom += site_freq
     plt.xticks(ind + (width / 2.), [x[0] for x in gene_count_subset],
                rotation='vertical')
     plt.ylabel('Stmts with invalid sites')
     plt.xlim((0, max(ind) + 1))
     ax = plt.gca()
     pf.format_axis(ax)
     plt.subplots_adjust(**subplot_params)
     if do_legend:
         plt.legend(loc='upper right',
                    handles=list(handle_dict.values()),
                    labels=list(handle_dict.keys()),
                    fontsize=pf.fontsize,
                    frameon=False)
     plt.show()
Exemple #6
0
def parameter_sweep(model, sigma, ns):
    generate_equations(model)
    logp = [numpy.log10(p.value) for p in model.parameters]
    ts = numpy.linspace(0, 20*3600, 20*60)
    solver = Solver(model, ts)
    pf.set_fig_params()
    plt.figure(figsize=(1.8, 1), dpi=300)
    for i in range(ns):
        psample = sample_params(logp, 0.05)
        res = solver.run(param_values=psample)
        signal = res.observables['p53_active']
        plt.plot(signal, color=(0.7, 0.7, 0.7), alpha=0.3)
    # Highlighted
    colors = ['g', 'y', 'c']
    for c in colors:
        psample = sample_params(logp, 0.05)
        res = solver.run(param_values=psample)
        signal = res.observables['p53_active']
        plt.plot(signal, c)

    # Nominal
    solver = Solver(model, ts)
    res = solver.run()
    signal = res.observables['p53_active']
    plt.plot(signal, 'r')

    plt.xticks([])
    plt.xlabel('Time (a.u.)', fontsize=7)
    plt.ylabel('Active p53', fontsize=7)
    plt.yticks([])
    plt.ylim(ymin=0)
    pf.format_axis(plt.gca())
    plt.savefig(model.name + '_sample.pdf')
def report_stmt_counts(results, plot_prefix=None):
    counts_per_paper = [(pmid, len(stmts)) for pmid, stmts in results.items()]
    counts = np.array([tup[1] for tup in counts_per_paper])
    logger.info("%.2f +/- %.2f statements per paper" %
                (np.mean(counts), np.std(counts)))
    logger.info("Median %d statements per paper" % np.median(counts))

    zero_pmids = [pmid for pmid, stmts in results.items() if len(stmts) == 0]
    logger.info('%s papers with no statements' % len(zero_pmids))

    # Distribution of numbers of statements
    if plot_prefix:
        plot_filename = '%s_stmts_per_paper.png' % plot_prefix
        logger.info('Plotting distribution of statements per paper in %s' %
                    plot_filename)
        fig = plt.figure(figsize=(2, 2), dpi=300)
        ax = fig.gca()
        ax.hist(counts, bins=20)
        #ax.set_xticks([0, 100, 200, 300, 400])
        pf.format_axis(ax)
        plt.subplots_adjust(left=0.23, bottom=0.16)
        ax.set_xlabel('No. of statements')
        ax.set_ylabel('No. of papers')
        fig = plt.gcf()
        fig.savefig(plot_filename, format='png')
        logger.info('plotted...')
def parameter_sweep(model, sigma, ns):
    generate_equations(model)
    logp = [numpy.log10(p.value) for p in model.parameters]
    ts = numpy.linspace(0, 20 * 3600, 20 * 60)
    solver = Solver(model, ts)
    pf.set_fig_params()
    plt.figure(figsize=(1.8, 1), dpi=300)
    for i in range(ns):
        psample = sample_params(logp, 0.05)
        res = solver.run(param_values=psample)
        signal = res.observables['p53_active']
        plt.plot(signal, color=(0.7, 0.7, 0.7), alpha=0.3)
    # Highlighted
    colors = ['g', 'y', 'c']
    for c in colors:
        psample = sample_params(logp, 0.05)
        res = solver.run(param_values=psample)
        signal = res.observables['p53_active']
        plt.plot(signal, c)

    # Nominal
    solver = Solver(model, ts)
    res = solver.run()
    signal = res.observables['p53_active']
    plt.plot(signal, 'r')

    plt.xticks([])
    plt.xlabel('Time (a.u.)', fontsize=7)
    plt.ylabel('Active p53', fontsize=7)
    plt.yticks([])
    plt.ylim(ymin=0)
    pf.format_axis(plt.gca())
    plt.savefig(model.name + '_sample.pdf')
Exemple #9
0
def plot_results(g, stmt_uuids, stmt_nodes, stmt_node_nums, stmt_uuid_nums):
    norm_node_counts = np.array(stmt_node_nums) / len(g)
    norm_uuid_counts = np.array(stmt_uuid_nums) / len(g.edges())

    pf.set_fig_params()
    plt.ion()
    lengths = range(1, len(norm_uuid_counts)+1)
    plt.figure(figsize=(2, 2), dpi=150)
    plt.plot(lengths, norm_uuid_counts, color='orange', alpha=0.8,
             label='Statements')
    plt.plot(lengths, norm_node_counts, color='blue', alpha=0.8, label='Nodes')
    plt.legend(loc='upper left', fontsize=pf.fontsize, frameon=False)
    ax = plt.gca()
    pf.format_axis(ax)
def plot_site_count_dist(sites, num_sites=240):
    # Plot site frequencies, colored by validity
    sites.sort(key=lambda s: s[1], reverse=True)
    width = 0.8
    plt.figure(figsize=(11, 2), dpi=150)
    ind = np.arange(num_sites) + (width / 2.)
    for site_ix, site in enumerate(sites[:num_sites]):
        if site.valid:
            color = 'g'
        else:
            color = 'r'
        plt.bar(site_ix, site.freq, color=color)
    ax = plt.gca()
    pf.format_axis(ax)
    plt.show()
Exemple #11
0
def plot_result(model, sol):
    pf.set_fig_params()
    plt.ion()
    plt.figure(figsize=(1, 1), dpi=300)
    species_names = [str(s) for s in model.species]
    plt.plot(t, sol.y[:, species_names.index("MAPK1(T185='u', Y187='u')")],
             'b', label='MAPK1.uu')
    plt.plot(t, sol.y[:, species_names.index("MAPK1(T185='p', Y187='u')")] +
                sol.y[:, species_names.index("MAPK1(T185='u', Y187='p')")],
             'g', label='MAPK1.p')
    plt.plot(t, sol.y[:, species_names.index("MAPK1(T185='p', Y187='p')")],
             'r', label='MAPK1.pp')
    plt.xlabel('Time')
    plt.ylabel('Amount')
    plt.legend(loc='upper right', fontsize=4)
    plt.xticks([])
    plt.yticks([])
    pf.format_axis(plt.gca())
Exemple #12
0
def plot_result(model, sol):
    pf.set_fig_params()
    plt.ion()
    plt.figure(figsize=(1, 1), dpi=300)
    species_names = [str(s) for s in model.species]
    plt.plot(t, sol.y[:, species_names.index("MAPK1(T185='u', Y187='u')")],
             'b', label='MAPK1.uu')
    plt.plot(t, sol.y[:, species_names.index("MAPK1(T185='p', Y187='u')")] +
                sol.y[:, species_names.index("MAPK1(T185='u', Y187='p')")],
             'g', label='MAPK1.p')
    plt.plot(t, sol.y[:, species_names.index("MAPK1(T185='p', Y187='p')")],
             'r', label='MAPK1.pp')
    plt.xlabel('Time')
    plt.ylabel('Amount')
    plt.legend(loc='upper right', fontsize=4)
    plt.xticks([])
    plt.yticks([])
    pf.format_axis(plt.gca())
def report_evidence_distribution(stmts, list_length=10, plot_prefix=None):
    # Sort by evidence
    sorted_stmts = sorted(stmts, key=lambda x: len(x.evidence), reverse=True)
    logger.info('Top %d statements by evidence:' % list_length)
    for i in range(list_length):
        logger.info('%s: %d' % (sorted_stmts[i], len(sorted_stmts[i].evidence)))

    # Distribution of pieces of evidence
    if plot_prefix:
        fig = plt.figure(figsize=(2, 2), dpi=300)
        ax = fig.gca()
        ax.plot([len(stmt.evidence) for stmt in sorted_stmts])
        pf.format_axis(ax)
        ax.set_xlabel('Statement index')
        ax.set_ylabel('No. of sentences')
        ax.set_yscale('log')
        plt.subplots_adjust(left=0.23, bottom=0.16)
        plt.savefig('%s_evidence_dist.pdf' % plot_prefix)
    return sorted_stmts
def report_evidence_distribution(stmts, list_length=10, plot_prefix=None):
    # Sort by evidence
    sorted_stmts = sorted(stmts, key=lambda x: len(x.evidence), reverse=True)
    logger.info('Top %d statements by evidence:' % list_length)
    for i in range(list_length):
        logger.info('%s: %d' % (sorted_stmts[i], len(sorted_stmts[i].evidence)))

    # Distribution of pieces of evidence
    if plot_prefix:
        fig = plt.figure(figsize=(2, 2), dpi=300)
        ax = fig.gca()
        ax.plot([len(stmt.evidence) for stmt in sorted_stmts])
        pf.format_axis(ax)
        ax.set_xlabel('Statement index')
        ax.set_ylabel('No. of sentences')
        ax.set_yscale('log')
        plt.subplots_adjust(left=0.23, bottom=0.16)
        plt.savefig('%s_evidence_dist.pdf' % plot_prefix)
    return sorted_stmts
def plot_frequencies(counts, plot_filename, bin_interval):
    freq_dist = []
    bin_starts = range(0, len(counts), bin_interval)
    for bin_start_ix in bin_starts:
        bin_end_ix = bin_start_ix + bin_interval
        if bin_end_ix < len(counts):
            freq_dist.append(np.sum(counts[bin_start_ix:bin_end_ix]))
        else:
            freq_dist.append(np.sum(counts[bin_start_ix:]))
    freq_dist = np.array(freq_dist)
    fracs_total = np.cumsum(freq_dist) / float(np.sum(counts))

    fig = plt.figure(figsize=(2, 2), dpi=300)
    ax = fig.gca()
    ax.plot(bin_starts, fracs_total)
    pf.format_axis(ax)
    plt.subplots_adjust(left=0.23, bottom=0.16)
    ax.set_xlabel('String index')
    ax.set_ylabel('No. of occurrences')
    ax.set_ylim([0, 1])
    plt.savefig(plot_filename)
def plot_frequencies(counts, plot_filename, bin_interval):
    freq_dist = []
    bin_starts = xrange(0, len(counts), bin_interval)
    for bin_start_ix in bin_starts:
        bin_end_ix = bin_start_ix + bin_interval
        if bin_end_ix < len(counts):
            freq_dist.append(np.sum(counts[bin_start_ix:bin_end_ix]))
        else:
            freq_dist.append(np.sum(counts[bin_start_ix:]))
    freq_dist = np.array(freq_dist)
    fracs_total = np.cumsum(freq_dist) / float(np.sum(counts))

    fig = plt.figure(figsize=(2, 2), dpi=300)
    ax = fig.gca()
    ax.plot(bin_starts, fracs_total)
    pf.format_axis(ax)
    plt.subplots_adjust(left=0.23, bottom=0.16)
    ax.set_xlabel('String index')
    ax.set_ylabel('No. of occurrences')
    ax.set_ylim([0, 1])
    plt.savefig(plot_filename)
Exemple #17
0
def plot_pc_pe_mods(all_mods):
    dbs = Counter([row.source for row in all_mods])
    dbs = sorted([(k, v) for k, v in dbs.items()],
                 key=lambda x: x[1],
                 reverse=True)
    plt.ion()
    width = 0.8
    ind = np.arange(len(dbs)) + (width / 2.)
    plt.figure(figsize=(2, 2), dpi=150)
    for db_ix, (db, db_freq) in enumerate(dbs):
        db_mods = [row for row in all_mods if row.source == db]
        valid = [row for row in db_mods if row.valid == 1]
        invalid = [row for row in db_mods if row.valid == 0]
        h_valid = plt.bar(db_ix, len(valid), width=width, color='g')
        h_invalid = plt.bar(db_ix,
                            len(invalid),
                            width=0.8,
                            color='r',
                            bottom=len(valid))
    plt.xticks(ind, [db[0] for db in dbs])
    ax = plt.gca()
    pf.format_axis(ax)
    plt.show()
def report_stmt_types(stmts, plot_prefix=None):
    # Number of statements of different types
    stmt_types = [type(stmt) for stmt in stmts]
    stmt_type_counter = Counter(stmt_types)

    fig = plt.figure(figsize=(2, 3), dpi=300)
    ax = fig.gca()
    sorted_counts = sorted(stmt_type_counter.items(), key=lambda x: x[1],
                           reverse=True)
    labels = [t.__name__ for t, n in sorted_counts]

    logger.info('Distribution of statement types:')
    for stmt_type, count in sorted_counts:
        logger.info('%s: %d' % (stmt_type.__name__, count))

    if plot_prefix:
        x_coords = np.arange(len(sorted_counts))
        ax.bar(x_coords, [x[1] for x in sorted_counts])
        ax.set_xticks(x_coords + 0.4)
        ax.set_xticklabels(labels, rotation=90)
        pf.format_axis(ax)
        ax.set_ylabel('No. of statements')
        plt.subplots_adjust(left=0.29, bottom=0.34)
        plt.savefig('%s_stmt_types.pdf' % plot_prefix)
Exemple #19
0
        trial_results_uniq.append(len(trial_stmts_uniq))
        trial_results_top.append(len(trial_stmts_top))
        trial_results_filt.append(len(trial_stmts_filt))

    results.append((np.mean(trial_results), np.std(trial_results)))
    results_uniq.append((np.mean(trial_results_uniq), np.std(trial_results_uniq)))
    results_top.append((np.mean(trial_results_top), np.std(trial_results_top)))
    results_filt.append((np.mean(trial_results_filt), np.std(trial_results_filt)))

results = np.array(results)
results_uniq = np.array(results_uniq)
results_top = np.array(results_top)
results_filt = np.array(results_filt)

plt.ion()

plt.figure(figsize=(3, 3), dpi=150)
plt.plot(sample_sizes, results[:,0], label='Raw', marker='.')
plt.plot(sample_sizes, results_uniq[:,0], label='Unique', marker='.')
plt.plot(sample_sizes, results_top[:, 0], label='Top-level', marker='.')
plt.plot(sample_sizes, results_filt[:,0], label='P 0.9', marker='.')

#pf.set_fig_params()
ax = plt.gca()
ax.set_xscale('log')
ax.set_yscale('log')
pf.format_axis(ax, tick_padding=3, label_padding=3)
ax.set_xlabel('Number of Articles')
ax.set_ylabel('Number of Statements')
plt.legend(loc='lower right', frameon=False)
Exemple #20
0
def plot_annot_stats(csv_file, output_base):
    site_df = pd.read_csv(csv_file)
    # Drop rows with error_code (invalid gene names in BEL)
    site_df = site_df[site_df.ERROR_CODE.isna()]
    #sources = site_df.SOURCE.unique()
    sources = [
        'psp', 'signor', 'hprd', 'pid', 'reactome', 'bel', 'reach', 'sparser',
        'rlimsp'
    ]
    fig_valid = plt.figure(figsize=(1.8, 2.2), dpi=150)
    fig_mapped = plt.figure(figsize=(1.8, 2.2), dpi=150)
    for ix, source in enumerate(sources):
        source_anns = site_df[site_df.SOURCE == source]
        valid = source_anns[source_anns.VALID == True]
        invalid = source_anns[source_anns.VALID != True]
        unmapped = invalid[invalid.MAPPED_RES.isna()
                           | invalid.MAPPED_POS.isna()]
        mapped = source_anns[~source_anns.MAPPED_RES.isna()
                             & ~source_anns.MAPPED_POS.isna()]
        print("%s, %d, %d, %d, %d" %
              (source, len(valid), len(invalid), len(unmapped), len(mapped)))
        # Plot for valid stats
        fig_valid.gca().bar(ix,
                            height=len(valid),
                            color='blue',
                            label='In Ref Seq')
        fig_valid.gca().bar(ix,
                            height=len(invalid),
                            bottom=len(valid),
                            color='red',
                            label='Not in Ref Seq')
        # Plot for mapped stats
        fig_mapped.gca().bar(ix,
                             height=len(valid),
                             color='blue',
                             label='In Ref Seq')
        fig_mapped.gca().bar(ix,
                             height=len(mapped),
                             bottom=len(valid),
                             color='green')
        fig_mapped.gca().bar(ix,
                             height=len(unmapped),
                             bottom=(len(valid) + len(mapped)),
                             color='red')
    plt.xticks(range(len(sources)), sources, rotation="vertical")
    plt.ylabel('Unique Site Annotations')
    plt.subplots_adjust(left=0.31, bottom=0.25, top=0.90)
    #plt.legend(loc='upper right', fontsize=pf.fontsize)
    for fig in (fig_valid, fig_mapped):
        ax = fig.gca()
        pf.format_axis(ax)
    fig_valid.savefig('%s_valid_counts.pdf' % output_base)
    fig_mapped.savefig('%s_mapped_counts.pdf' % output_base)

    results = []
    # Now generate the plot of invalid site proportions
    fig_valid = plt.figure(figsize=(1.8, 2.2), dpi=150)
    fig_mapped = plt.figure(figsize=(1.8, 2.2), dpi=150)
    for ix, source in enumerate(sources):
        source_anns = site_df[site_df.SOURCE == source]
        valid = source_anns[source_anns.VALID == True]
        invalid = source_anns[source_anns.VALID != True]
        unmapped = invalid[invalid.MAPPED_RES.isna()
                           | invalid.MAPPED_POS.isna()]
        mapped = source_anns[~source_anns.MAPPED_RES.isna()
                             & ~source_anns.MAPPED_POS.isna()]
        pct_mapped = 100 * len(mapped) / len(source_anns)
        pct_unmapped = 100 * len(unmapped) / len(source_anns)
        pct_valid = 100 * len(valid) / len(source_anns)
        pct_invalid = 100 * len(invalid) / len(source_anns)
        results.append([
            source,
            len(source_anns),
            len(valid),
            round(100 * len(valid) / len(source_anns), 1),
            len(invalid),
            round(100 * len(invalid) / len(source_anns), 1),
            len(mapped),
            round(100 * len(mapped) / len(invalid), 1)
        ])
        #print("%s, %d, %d, %d, %d" % (source, len(valid), len(invalid),
        #                              len(unmapped), len(mapped)))
        fig_valid.gca().bar(ix, height=pct_valid, color='blue')
        fig_valid.gca().bar(ix,
                            height=pct_invalid,
                            bottom=pct_valid,
                            color='red')
        fig_mapped.gca().bar(ix, height=pct_valid, color='blue')
        fig_mapped.gca().bar(ix,
                             height=pct_mapped,
                             bottom=pct_valid,
                             color='green')
        fig_mapped.gca().bar(ix,
                             height=pct_unmapped,
                             bottom=(pct_valid + pct_mapped),
                             color='red')
    plt.xticks(range(len(sources)), sources, rotation="vertical")
    plt.ylabel('Pct. Unique Site Annotations')
    plt.subplots_adjust(left=0.31, bottom=0.25, top=0.90)
    for fig in (fig_valid, fig_mapped):
        ax = fig.gca()
        pf.format_axis(ax)
    fig_valid.savefig('%s_valid_pcts.pdf' % output_base)
    fig_mapped.savefig('%s_mapped_pcts.pdf' % output_base)
    result_df = pd.DataFrame.from_records(results,
                                          columns=[
                                              'SOURCE', 'TOTAL', 'VALID',
                                              'VALID_PCT', 'INVALID',
                                              'INVALID_PCT', 'MAPPED',
                                              'MAPPED_PCT_INVALID'
                                          ])
    result_df.to_csv('%s_result_df.csv' % output_base)
    return result_df
Exemple #21
0
pa = PysbAssembler()
pa.add_statements(stmts)
pa.make_model()
t = np.linspace(0, 25000)
sol = Solver(pa.model, t)
sol.run()

pf.set_fig_params()
plt.ion()
plt.figure(figsize=(1, 1), dpi=300)
species_names = [str(s) for s in pa.model.species]
plt.plot(t,
         sol.y[:, species_names.index("MAPK1(T185='u', Y187='u')")],
         'b',
         label='MAPK1.uu')
plt.plot(t,
         sol.y[:, species_names.index("MAPK1(T185='p', Y187='u')")] +
         sol.y[:, species_names.index("MAPK1(T185='u', Y187='p')")],
         'g',
         label='MAPK1.p')
plt.plot(t,
         sol.y[:, species_names.index("MAPK1(T185='p', Y187='p')")],
         'r',
         label='MAPK1.pp')
plt.xlabel('Time')
plt.ylabel('Amount')
plt.legend(loc='upper right', fontsize=4)
plt.xticks([])
plt.yticks([])
pf.format_axis(plt.gca())
Exemple #22
0
# Condition 1
off = []
on = ['Growth_factor_proteins']
avgs = get_sim_avgs(bn_str, off=off, on=on)
jun_ext_noinh = avgs['JUN']
# Condition 2
off = ['MAP2K1', 'MAP2K2']
on = ['Growth_factor_proteins']
avgs = get_sim_avgs(bn_str, off=off, on=on)
jun_ext_inh = avgs['JUN']
# Condition 3
off = ['MAP2K1', 'MAP2K2', 'MAPK8', 'MAPK9']
on = ['Growth_factor_proteins']
avgs = get_sim_avgs(bn_str, off=off, on=on)
jun_ext_inh2 = avgs['JUN']

pf.set_fig_params()
plt.figure(figsize=(4,4), dpi=300)
plt.ion()
plt.plot(jun_basic_noinh, 'r', linewidth=2, label='Basic model, no inhibitor')
plt.plot(jun_basic_inh, 'r--', linewidth=2, label='Basic model, MEK inhibitor')
plt.plot(jun_ext_noinh, 'b', linewidth=2, label='Extended model, no inhibitor')
plt.plot(jun_ext_inh, 'b--', linewidth=2, label='Extended model, MEK inhibitor')
plt.plot(jun_ext_inh2, 'g--', linewidth=2, label='Extended model, MEK+JNK inhibitor')
plt.ylim(-0.01, 1.01)
plt.ylabel('Average JUN activity')
plt.xlabel('Time steps')
plt.legend()
pf.format_axis(plt.gca())
plt.show()
    total_paths = np.sum(path_counts)
    print(path_counts)
    print(total_paths)

    # Plot num paths vs length
    plt.show
    plt.figure(figsize=(5, 2), dpi=150)
    ypos = list(range(1, MAX_DEPTH + 1))
    plt.bar(ypos, path_counts, align='center')
    #plt.xticks(ypos, str_names[:num_genes], rotation='vertical')
    ax = plt.gca()
    plt.ylabel('Number of paths')
    plt.xlabel('Path length')
    ax.set_yscale('log')
    #plt.subplots_adjust(bottom=0.3)
    pf.format_axis(ax)
    """
    cfpg_list = []
    total_cf_paths = 0
    for i, pg in enumerate(result['pg_list']):
        print("Generating CFPG %d" % i)
        cfpg = CFPG.from_pg(pg)
        total_cf_paths += cfpg.count_paths()
    print("total paths (with cycles)", total_paths)
    print("total cycle-free paths", total_cf_paths)
    """

    # Length distribution
    pg_path_lengths = Counter([len(p) - 1 for p in result['pg_paths']])
    #nx_path_lengths = Counter([len(p)-1 for p in result['nx_paths']])
    lengths = range(1, MAX_DEPTH + 1)