예제 #1
0
def main(cmdline=None):
    parser = make_parser()
    args = parser.parse_args(cmdline)

    sep = models.get_seperator(args.sep)
    libraries = models.load_library_tables(args.libraries, sep)
    fastqs = dict(find_fastqs(libraries))

    dag = generate_star_rsem_analysis(args, libraries, fastqs)
    print(dag)
    
    return 0
예제 #2
0
def main(cmdline=None):
    parser = make_parser()
    args = parser.parse_args(cmdline)
    env = Environment(loader=PackageLoader('woldrnaseq', 'templates'))
    sep = models.get_seperator(args.sep)

    experiments = models.load_experiments([args.experiments], sep)
    libraries = models.load_library_tables([args.libraries], sep)

    samstats = models.load_all_samstats(libraries)
    distribution = models.load_all_distribution(libraries)
    coverage = models.load_all_coverage(libraries)


    seen_libraries = set()
    experiment_report = {}
    transcript_library_plots = []
    plots = {}
    plot_handle = itertools.count()
    for experiment in experiments:
        scores = models.load_correlations(experiment)
        quantifications = models.load_quantifications(experiment, args.quantification)

        coverage_handle = str(next(plot_handle))
        plots[coverage_handle] = make_coverage_plot(coverage, experiments, experiment)
        distribution_handle = str(next(plot_handle))
        plots[distribution_handle] = make_distribution_plot(distribution, experiments, experiment)
        spearman_filename = make_correlation_heatmap(scores, 'rafa_spearman', experiment)
        spike_variance_handle = str(next(plot_handle))
        plots[spike_variance_handle] = make_spikein_variance_plot(quantifications, experiments, experiment)

        library_ids = experiments[experiment]
        seen_libraries.update(set(library_ids))
        for library_id in library_ids:
            transcript_handle = str(next(plot_handle))
            plots[transcript_handle] = make_spikein_per_transcript_plot(
                quantifications, library_id, args.quantification)
            transcript_library_plots.append(transcript_handle)

        experiment_report[experiment] = {
            'samstats': samstats.select(lambda x: x in library_ids).to_html(),
            'spearman': scores.rafa_spearman.to_html(),
            'coverage': coverage_handle,
            'distribution': distribution_handle,
            'spearman_plot': spearman_filename,
            'spike_variance': spike_variance_handle,
        }

    spare_libraries = set(libraries.index).difference(seen_libraries)
    print(libraries.index)
    print(seen_libraries)
    print(spare_libraries)

    script, plot_divs = components(plots)

    template = env.get_template('rnaseq.html')
    page = template.render(
        experiments=experiments,
        experiment_report=experiment_report,
        transcript_library_plots=transcript_library_plots,
        plot_divs=plot_divs,
        bokeh_script=script,
        )
    with open(args.output, 'wt') as outstream:
        outstream.write(page)