diff --git a/CRISPResso2/CRISPRessoAggregateCORE.py b/CRISPResso2/CRISPRessoAggregateCORE.py index 59d8897f..7e5b9b0d 100644 --- a/CRISPResso2/CRISPRessoAggregateCORE.py +++ b/CRISPResso2/CRISPRessoAggregateCORE.py @@ -614,12 +614,14 @@ def main(): crispresso2_info['results']['general_plots']['allele_modification_heatmap_plot_titles'] = {} crispresso2_info['results']['general_plots']['allele_modification_heatmap_plot_labels'] = {} crispresso2_info['results']['general_plots']['allele_modification_heatmap_plot_datas'] = {} + crispresso2_info['results']['general_plots']['allele_modification_heatmap_plot_divs'] = {} crispresso2_info['results']['general_plots']['allele_modification_line_plot_names'] = [] crispresso2_info['results']['general_plots']['allele_modification_line_plot_paths'] = {} crispresso2_info['results']['general_plots']['allele_modification_line_plot_titles'] = {} crispresso2_info['results']['general_plots']['allele_modification_line_plot_labels'] = {} crispresso2_info['results']['general_plots']['allele_modification_line_plot_datas'] = {} + crispresso2_info['results']['general_plots']['allele_modification_line_plot_divs'] = {} if guides_all_same: sgRNA_intervals = [consensus_sgRNA_intervals] * modification_frequency_summary_df.shape[0] else: @@ -645,11 +647,13 @@ def main(): plot_name = 'CRISPRessoAggregate_percentage_of_{0}_across_alleles_{1}_heatmap'.format(modification_type.lower(), amplicon_name) plot_path = '{0}.html'.format(_jp(plot_name)) + heatmap_div_id = '{0}-allele-modification-heatmap-{1}'.format(amplicon_name.lower(), modification_type.lower()) allele_modification_heatmap_input = { 'sample_values': modification_df, 'sample_sgRNA_intervals': sgRNA_intervals, 'plot_path': plot_path, 'title': modification_type, + 'div_id': heatmap_div_id, } plot( CRISPRessoPlot.plot_allele_modification_heatmap, @@ -671,15 +675,18 @@ def main(): ), ), ] + crispresso2_info['results']['general_plots']['allele_modification_heatmap_plot_divs'][plot_name] = heatmap_div_id plot_name = 'CRISPRessoAggregate_percentage_of_{0}_across_alleles_{1}_line'.format(modification_type.lower(), amplicon_name) plot_path = '{0}.html'.format(_jp(plot_name)) + line_div_id = '{0}-allele-modification-line-{1}'.format(amplicon_name.lower(), modification_type.lower()) allele_modification_line_input = { 'sample_values': modification_df, 'sample_sgRNA_intervals': sgRNA_intervals, 'plot_path': plot_path, 'title': modification_type, + 'div_id': line_div_id, } plot( CRISPRessoPlot.plot_allele_modification_line, @@ -700,6 +707,7 @@ def main(): ), ), ] + crispresso2_info['results']['general_plots']['allele_modification_line_plot_divs'][plot_name] = line_div_id crispresso2_info['results']['general_plots']['window_nuc_pct_quilt_plot_names'] = window_nuc_pct_quilt_plot_names crispresso2_info['results']['general_plots']['nuc_pct_quilt_plot_names'] = nuc_pct_quilt_plot_names diff --git a/CRISPResso2/CRISPRessoBatchCORE.py b/CRISPResso2/CRISPRessoBatchCORE.py index f6ca5550..83826bf0 100644 --- a/CRISPResso2/CRISPRessoBatchCORE.py +++ b/CRISPResso2/CRISPRessoBatchCORE.py @@ -415,12 +415,14 @@ def main(): crispresso2_info['results']['general_plots']['allele_modification_heatmap_plot_titles'] = {} crispresso2_info['results']['general_plots']['allele_modification_heatmap_plot_labels'] = {} crispresso2_info['results']['general_plots']['allele_modification_heatmap_plot_datas'] = {} + crispresso2_info['results']['general_plots']['allele_modification_heatmap_plot_divs'] = {} crispresso2_info['results']['general_plots']['allele_modification_line_plot_names'] = [] crispresso2_info['results']['general_plots']['allele_modification_line_plot_paths'] = {} crispresso2_info['results']['general_plots']['allele_modification_line_plot_titles'] = {} crispresso2_info['results']['general_plots']['allele_modification_line_plot_labels'] = {} crispresso2_info['results']['general_plots']['allele_modification_line_plot_datas'] = {} + crispresso2_info['results']['general_plots']['allele_modification_line_plot_divs'] = {} percent_complete_start, percent_complete_end = 90, 99 if all_amplicons: @@ -798,12 +800,13 @@ def main(): plot_name = 'CRISPRessoBatch_percentage_of_{0}_across_alleles_{1}_heatmap'.format(modification_type.lower(), amplicon_name) plot_path = '{0}.html'.format(_jp(plot_name)) + heatmap_div_id = '{0}-allele-modification-heatmap-{1}'.format(amplicon_name.lower(), modification_type.lower()) allele_modification_heatmap_input = { 'sample_values': modification_df, 'sample_sgRNA_intervals': sgRNA_intervals, 'plot_path': plot_path, 'title': modification_type, - 'amplicon_name': amplicon_name, + 'div_id': heatmap_div_id, } debug('Plotting allele modification heatmap for {0}'.format(amplicon_name)) plot( @@ -826,16 +829,18 @@ def main(): ), ), ] + crispresso2_info['results']['general_plots']['allele_modification_heatmap_plot_divs'][plot_name] = heatmap_div_id plot_name = 'CRISPRessoBatch_percentage_of_{0}_across_alleles_{1}_line'.format(modification_type.lower(), amplicon_name) plot_path = '{0}.html'.format(_jp(plot_name)) + line_div_id = '{0}-allele-modification-line-{1}'.format(amplicon_name.lower(), modification_type.lower()) allele_modification_line_input = { 'sample_values': modification_df, 'sample_sgRNA_intervals': sgRNA_intervals, 'plot_path': plot_path, 'title': modification_type, - 'amplicon_name': amplicon_name, + 'div_id': line_div_id, } debug('Plotting allele modification line plot for {0}'.format(amplicon_name)) plot( @@ -858,6 +863,7 @@ def main(): ), ), ] + crispresso2_info['results']['general_plots']['allele_modification_line_plot_divs'][plot_name] = line_div_id #end if amp_found_count > 0 (how many folders had information for this amplicon) #end per-amplicon analysis diff --git a/CRISPResso2/CRISPRessoReports/CRISPRessoReport.py b/CRISPResso2/CRISPRessoReports/CRISPRessoReport.py index 8e86084e..eb16730a 100644 --- a/CRISPResso2/CRISPRessoReports/CRISPRessoReport.py +++ b/CRISPResso2/CRISPRessoReports/CRISPRessoReport.py @@ -261,6 +261,10 @@ def make_batch_report_from_folder(crispressoBatch_report_file, crispresso2_info, allele_modification_heatmap_plot['datas'] = crispresso2_info['results']['general_plots']['allele_modification_heatmap_plot_datas'] else: allele_modification_heatmap_plot['datas'] = {} + if 'allele_modification_heatmap_plot_divs' in crispresso2_info['results']['general_plots']: + allele_modification_heatmap_plot['divs'] = crispresso2_info['results']['general_plots']['allele_modification_heatmap_plot_divs'] + else: + allele_modification_heatmap_plot['divs'] = {} allele_modification_line_plot = {} if 'allele_modification_line_plot_names' in crispresso2_info['results']['general_plots']: @@ -283,6 +287,10 @@ def make_batch_report_from_folder(crispressoBatch_report_file, crispresso2_info, allele_modification_line_plot['datas'] = crispresso2_info['results']['general_plots']['allele_modification_line_plot_datas'] else: allele_modification_line_plot['datas'] = {} + if 'allele_modification_line_plot_divs' in crispresso2_info['results']['general_plots']: + allele_modification_line_plot['divs'] = crispresso2_info['results']['general_plots']['allele_modification_line_plot_divs'] + else: + allele_modification_line_plot['divs'] = {} allele_modification_heatmap_plot['htmls'] = {} for heatmap_plot_name, heatmap_plot_path in allele_modification_heatmap_plot['paths'].items(): @@ -572,6 +580,7 @@ def fill_default(dictionary, key, default_type=list): ('titles', list), ('labels', dict), ('datas', dict), + ('divs', dict) ] for dictionary in dictionaries: for key, default_type in keys_and_default_types: @@ -618,11 +627,13 @@ def fill_default(dictionary, key, default_type=list): allele_modification_heatmap_plot_titles=allele_modification_heatmap_plot['titles'], allele_modification_heatmap_plot_labels=allele_modification_heatmap_plot['labels'], allele_modification_heatmap_plot_datas=allele_modification_heatmap_plot['datas'], + allele_modification_heatmap_plot_divs=allele_modification_heatmap_plot['divs'], allele_modification_line_plot_names=allele_modification_line_plot['names'], allele_modification_line_plot_htmls=allele_modification_line_plot['htmls'], allele_modification_line_plot_titles=allele_modification_line_plot['titles'], allele_modification_line_plot_labels=allele_modification_line_plot['labels'], allele_modification_line_plot_datas=allele_modification_line_plot['datas'], + allele_modification_line_plot_divs=allele_modification_line_plot['divs'], C2PRO_INSTALLED=C2PRO_INSTALLED, )) diff --git a/CRISPResso2/CRISPRessoReports/templates/batchReport.html b/CRISPResso2/CRISPRessoReports/templates/batchReport.html index 3b030fcc..c01ff1f2 100644 --- a/CRISPResso2/CRISPRessoReports/templates/batchReport.html +++ b/CRISPResso2/CRISPRessoReports/templates/batchReport.html @@ -147,10 +147,10 @@
{{report_data['titles'][plot_name]}}
{{allele_modification_heatmap_plot_titles[heatmap_plot_name]}}
@@ -175,13 +175,13 @@
{{allele_modification_heatmap_plot_titles[heatmap_plot_name]}}