From d2c2be18a6bb64b0e742cc24c4665980a24324bc Mon Sep 17 00:00:00 2001 From: Cole Lyman Date: Mon, 13 May 2024 09:41:32 -0600 Subject: [PATCH] Showing sgRNA sequences on hover in CRISPRessoPro (#432) * Passing sgRNA sequences to regular and Batch D3 plots (#73) * Sam/try plots (#71) * Fix batch mode pandas warning. (#70) * refactor to call method on DataFrame, rather than Series. Removes warning. * Fix pandas future warning in CRISPRessoWGS --------- Co-authored-by: Cole Lyman * Functional * Cole/fix status file name (#69) * Update config file logging messages This removes printing the exception (which is essentially a duplicate), and adds a condition if no config file was provided. Also changes `json` to `config` so that it is more clear. * Fix divide by zero when no amplicons are present in Batch mode * Don't append file_prefix to status file name * Place status files in output directories * Update tests branch for file_prefix addition * Load D3 and plotly figures with pro with multiple amplicons * Update batch * Fix bug in CRISPRessoCompare with pointing to report datas with file_prefix Before this fix, when using a file_prefix the second run that was compared would not be displayed as a data in the first figure of the report. * Import CRISPRessoPro instead of importing the version When installed via conda, the version is not available * Remove `get_amplicon_output` unused function from CRISPRessoCompare Also remove unused argparse import * Implement `get_matching_allele_files` in CRISPRessoCompare and accompanying unit tests * Allow for matching of multiple guides in the same amplicon * Fix pandas FutureWarning * Change test branch back to master --------- Co-authored-by: Sam * Try catch all futures * Fix test fail plots * Point test to try-plots * Fix d3 not showing and plotly mixing with matplotlib * Use logger for warnings and debug statements * Point tests back at master --------- Co-authored-by: mbowcut2 <55161542+mbowcut2@users.noreply.github.com> Co-authored-by: Cole Lyman * Sam/fix plots (#72) * Fix batch mode pandas warning. (#70) * refactor to call method on DataFrame, rather than Series. Removes warning. * Fix pandas future warning in CRISPRessoWGS --------- Co-authored-by: Cole Lyman * Functional * Cole/fix status file name (#69) * Update config file logging messages This removes printing the exception (which is essentially a duplicate), and adds a condition if no config file was provided. Also changes `json` to `config` so that it is more clear. * Fix divide by zero when no amplicons are present in Batch mode * Don't append file_prefix to status file name * Place status files in output directories * Update tests branch for file_prefix addition * Load D3 and plotly figures with pro with multiple amplicons * Update batch * Fix bug in CRISPRessoCompare with pointing to report datas with file_prefix Before this fix, when using a file_prefix the second run that was compared would not be displayed as a data in the first figure of the report. * Import CRISPRessoPro instead of importing the version When installed via conda, the version is not available * Remove `get_amplicon_output` unused function from CRISPRessoCompare Also remove unused argparse import * Implement `get_matching_allele_files` in CRISPRessoCompare and accompanying unit tests * Allow for matching of multiple guides in the same amplicon * Fix pandas FutureWarning * Change test branch back to master --------- Co-authored-by: Sam * Try catch all futures * Fix test fail plots * Fix d3 not showing and plotly mixing with matplotlib --------- Co-authored-by: mbowcut2 <55161542+mbowcut2@users.noreply.github.com> Co-authored-by: Cole Lyman * Remove token from integration tests file * Provide sgRNA_sequences to plot_nucleotide_quilt plots * Passing sgRNA_sequences to plot * Refactor check for determining when to use CRISPREssoPro or matplotlib for Batch plots * Add max-height to Batch report samples * Change testing branch * Fix wrong check for large Batch plots * Update integration_tests.yml to point back at master --------- Co-authored-by: Samuel Nichols Co-authored-by: mbowcut2 <55161542+mbowcut2@users.noreply.github.com> Co-authored-by: Cole Lyman * Push new releases to ECR (#74) * Create aws_ecr.yml (#1) * Update aws_ecr.yml * Update aws_ecr.yml * Update aws_ecr.yml * Update aws_ecr.yml * Update aws_ecr.yml * Update aws_ecr.yml * Update aws_ecr.yml * Update aws_ecr.yml * Update aws_ecr.yml * Update aws_ecr.yml * Update aws_ecr.yml * Update aws_ecr.yml * Update aws_ecr.yml * Update aws_ecr.yml * Update aws_ecr.yml * Update aws_ecr.yml * Update aws_ecr.yml * Update aws_ecr.yml * Update aws_ecr.yml * Update aws_ecr.yml * Update aws_ecr.yml * Update aws_ecr.yml * us-east-1 * Update aws_ecr.yml * Update aws_ecr.yml * Update aws_ecr.yml * Update aws_ecr.yml * Update aws_ecr.yml * Fix d3 sgRNA sequences (#76) * Pass correct sgRNA_sequences to d3 plot * Pass correct sgRNA sequence to prime editor plot for d3 * Resize plotly (#75) * Sam/try plots (#71) * Fix batch mode pandas warning. (#70) * refactor to call method on DataFrame, rather than Series. Removes warning. * Fix pandas future warning in CRISPRessoWGS --------- Co-authored-by: Cole Lyman * Functional * Cole/fix status file name (#69) * Update config file logging messages This removes printing the exception (which is essentially a duplicate), and adds a condition if no config file was provided. Also changes `json` to `config` so that it is more clear. * Fix divide by zero when no amplicons are present in Batch mode * Don't append file_prefix to status file name * Place status files in output directories * Update tests branch for file_prefix addition * Load D3 and plotly figures with pro with multiple amplicons * Update batch * Fix bug in CRISPRessoCompare with pointing to report datas with file_prefix Before this fix, when using a file_prefix the second run that was compared would not be displayed as a data in the first figure of the report. * Import CRISPRessoPro instead of importing the version When installed via conda, the version is not available * Remove `get_amplicon_output` unused function from CRISPRessoCompare Also remove unused argparse import * Implement `get_matching_allele_files` in CRISPRessoCompare and accompanying unit tests * Allow for matching of multiple guides in the same amplicon * Fix pandas FutureWarning * Change test branch back to master --------- Co-authored-by: Sam * Try catch all futures * Fix test fail plots * Point test to try-plots * Fix d3 not showing and plotly mixing with matplotlib * Use logger for warnings and debug statements * Point tests back at master --------- Co-authored-by: mbowcut2 <55161542+mbowcut2@users.noreply.github.com> Co-authored-by: Cole Lyman * Sam/fix plots (#72) * Fix batch mode pandas warning. (#70) * refactor to call method on DataFrame, rather than Series. Removes warning. * Fix pandas future warning in CRISPRessoWGS --------- Co-authored-by: Cole Lyman * Functional * Cole/fix status file name (#69) * Update config file logging messages This removes printing the exception (which is essentially a duplicate), and adds a condition if no config file was provided. Also changes `json` to `config` so that it is more clear. * Fix divide by zero when no amplicons are present in Batch mode * Don't append file_prefix to status file name * Place status files in output directories * Update tests branch for file_prefix addition * Load D3 and plotly figures with pro with multiple amplicons * Update batch * Fix bug in CRISPRessoCompare with pointing to report datas with file_prefix Before this fix, when using a file_prefix the second run that was compared would not be displayed as a data in the first figure of the report. * Import CRISPRessoPro instead of importing the version When installed via conda, the version is not available * Remove `get_amplicon_output` unused function from CRISPRessoCompare Also remove unused argparse import * Implement `get_matching_allele_files` in CRISPRessoCompare and accompanying unit tests * Allow for matching of multiple guides in the same amplicon * Fix pandas FutureWarning * Change test branch back to master --------- Co-authored-by: Sam * Try catch all futures * Fix test fail plots * Fix d3 not showing and plotly mixing with matplotlib --------- Co-authored-by: mbowcut2 <55161542+mbowcut2@users.noreply.github.com> Co-authored-by: Cole Lyman * Remove token from integration tests file * Pass div id for plotly * Remove debug --------- Co-authored-by: mbowcut2 <55161542+mbowcut2@users.noreply.github.com> Co-authored-by: Cole Lyman --------- Co-authored-by: Trevor Martin <60452953+trevormartinj7@users.noreply.github.com> Co-authored-by: Samuel Nichols Co-authored-by: mbowcut2 <55161542+mbowcut2@users.noreply.github.com> --- .github/workflows/aws_ecr.yml | 47 ++++++++++++++++ CRISPResso2/CRISPRessoAggregateCORE.py | 8 +++ CRISPResso2/CRISPRessoBatchCORE.py | 55 +++++++++++++++---- CRISPResso2/CRISPRessoCORE.py | 7 +++ .../CRISPRessoReports/CRISPRessoReport.py | 11 ++++ .../templates/batchReport.html | 14 ++--- .../shared/partials/failed_runs.html | 2 +- tests/unit_tests/test_CRISPRessoBatchCORE.py | 44 +++++++++++++++ 8 files changed, 169 insertions(+), 19 deletions(-) create mode 100644 .github/workflows/aws_ecr.yml create mode 100644 tests/unit_tests/test_CRISPRessoBatchCORE.py diff --git a/.github/workflows/aws_ecr.yml b/.github/workflows/aws_ecr.yml new file mode 100644 index 00000000..ea4e7c98 --- /dev/null +++ b/.github/workflows/aws_ecr.yml @@ -0,0 +1,47 @@ +name: Push Docker image to Amazon ECR + +on: + release: + types: + - edited + - released + branches: + - master + +jobs: + build-and-push: + name: Build and Push Docker image + runs-on: ubuntu-latest + + steps: + - name: Checkout + uses: actions/checkout@v2 + + - id: get_version + name: Get version + uses: jannemattila/get-version-from-tag@v3 + + - name: Configure AWS credentials + uses: aws-actions/configure-aws-credentials@v1 + with: + aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }} + aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} + aws-region: us-east-1 + + - name: Login to Amazon ECR + id: login-ecr + uses: aws-actions/amazon-ecr-login@v1 + + - name: Build, tag, and push the image to Amazon ECR + id: build-image + env: + AWS_ACCOUNT: ${{ secrets.AWS_ACCOUNT_ID }} + ECR_REPOSITORY: 'crispresso2' + AWS_REGION: 'us-east-1' + IMAGE_TAG: ${{ steps.get_version.outputs.version }} + run: | + # Build a docker container and push it to ECR + docker build -t $AWS_ACCOUNT.dkr.ecr.$AWS_REGION.amazonaws.com/$ECR_REPOSITORY:$IMAGE_TAG . + echo "Pushing image to ECR..." + docker push $AWS_ACCOUNT.dkr.ecr.$AWS_REGION.amazonaws.com/$ECR_REPOSITORY:$IMAGE_TAG + echo "::set-output name=image::$AWS_ACCOUNT.dkr.ecr.$AWS_REGION.amazonaws.com/$ECR_REPOSITORY:$IMAGE_TAG" 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 4e387f98..83826bf0 100644 --- a/CRISPResso2/CRISPRessoBatchCORE.py +++ b/CRISPResso2/CRISPRessoBatchCORE.py @@ -49,6 +49,33 @@ def check_library(library_name): np = check_library('numpy') +def should_plot_large_plots(num_rows, c2pro_installed, use_matplotlib, large_plot_cutoff=300): + """Determine if large plots should be plotted. + + Parameters + ---------- + num_rows : int + Number of rows in the dataframe. + c2pro_installed : bool + Whether CRISPRessoPro is installed. + use_matplotlib : bool + Whether to use matplotlib when CRISPRessoPro is installed, i.e. value + of `--use_matplotlib`. + large_plot_cutoff : int, optional + Number of samples at which to not plot large plots with matplotlib. + Note that each sample has 6 rows in the datafame. Defaults to 300. + + Returns + ------- + bool + Whether to plot large plots. + """ + return ( + (not use_matplotlib and c2pro_installed) + or (num_rows / 6) < large_plot_cutoff + ) + + def main(): try: start_time = datetime.now() @@ -388,14 +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'] = {} - - large_plot_cutoff = 300 + crispresso2_info['results']['general_plots']['allele_modification_line_plot_divs'] = {} percent_complete_start, percent_complete_end = 90, 99 if all_amplicons: @@ -580,7 +607,7 @@ def main(): sub_modification_percentage_summary_filename = _jp(amplicon_plot_name + 'Modification_percentage_summary_around_sgRNA_'+sgRNA+'.txt') sub_modification_percentage_summary_df.to_csv(sub_modification_percentage_summary_filename, sep='\t', index=None) - if not args.suppress_plots and not args.suppress_batch_summary_plots and (nucleotide_percentage_summary_df.shape[0] / 6) < large_plot_cutoff: + if not args.suppress_plots and not args.suppress_batch_summary_plots and should_plot_large_plots(sub_nucleotide_percentage_summary_df.shape[0], C2PRO_INSTALLED, args.use_matplotlib): # plot for each guide # show all sgRNA's on the plot sub_sgRNA_intervals = [] @@ -614,6 +641,7 @@ def main(): 'fig_filename_root': f'{this_window_nuc_pct_quilt_plot_name}.json' if not args.use_matplotlib and C2PRO_INSTALLED else this_window_nuc_pct_quilt_plot_name, 'save_also_png': save_png, 'sgRNA_intervals': sub_sgRNA_intervals, + 'sgRNA_sequences': consensus_guides, 'quantification_window_idxs': include_idxs, 'custom_colors': custom_config['colors'], } @@ -628,7 +656,7 @@ def main(): crispresso2_info['results']['general_plots']['summary_plot_labels'][plot_name] = 'Composition of each base around the guide ' + sgRNA + ' for the amplicon ' + amplicon_name crispresso2_info['results']['general_plots']['summary_plot_datas'][plot_name] = [('Nucleotide frequencies', os.path.basename(nucleotide_frequency_summary_filename)), ('Modification frequencies', os.path.basename(modification_frequency_summary_filename))] - if args.base_editor_output and (sub_nucleotide_percentage_summary_df.shape[0] / 6) < large_plot_cutoff: + if args.base_editor_output and should_plot_large_plots(sub_nucleotide_percentage_summary_df.shape[0], False, args.use_matplotlib): this_window_nuc_conv_plot_name = _jp(amplicon_plot_name + 'Nucleotide_conversion_map_around_sgRNA_'+sgRNA) conversion_map_input = { 'nuc_pct_df': sub_nucleotide_percentage_summary_df, @@ -656,7 +684,7 @@ def main(): ] # done with per-sgRNA plots - if not args.suppress_plots and not args.suppress_batch_summary_plots: # plot the whole region + if not args.suppress_plots and not args.suppress_batch_summary_plots and should_plot_large_plots(nucleotide_percentage_summary_df.shape[0], C2PRO_INSTALLED, args.use_matplotlib): # plot the whole region this_nuc_pct_quilt_plot_name = _jp(amplicon_plot_name.replace('.', '') + 'Nucleotide_percentage_quilt') nucleotide_quilt_input = { 'nuc_pct_df': nucleotide_percentage_summary_df, @@ -664,6 +692,7 @@ def main(): 'fig_filename_root': f'{this_nuc_pct_quilt_plot_name}.json' if not args.use_matplotlib and C2PRO_INSTALLED else this_nuc_pct_quilt_plot_name, 'save_also_png': save_png, 'sgRNA_intervals': consensus_sgRNA_intervals, + 'sgRNA_sequences': consensus_guides, 'quantification_window_idxs': include_idxs, 'custom_colors': custom_config['colors'], } @@ -679,7 +708,7 @@ def main(): crispresso2_info['results']['general_plots']['summary_plot_titles'][plot_name] = '' crispresso2_info['results']['general_plots']['summary_plot_labels'][plot_name] = 'Composition of each base for the amplicon ' + amplicon_name crispresso2_info['results']['general_plots']['summary_plot_datas'][plot_name] = [('Nucleotide frequencies', os.path.basename(nucleotide_frequency_summary_filename)), ('Modification frequencies', os.path.basename(modification_frequency_summary_filename))] - if args.base_editor_output and (sub_nucleotide_percentage_summary_df.shape[0] / 6) < large_plot_cutoff: + if args.base_editor_output and should_plot_large_plots(nucleotide_percentage_summary_df.shape[0], False, args.use_matplotlib): this_nuc_conv_plot_name = _jp(amplicon_plot_name + 'Nucleotide_conversion_map') conversion_map_input = { 'nuc_pct_df': nucleotide_percentage_summary_df, @@ -706,7 +735,7 @@ def main(): crispresso2_info['results']['general_plots']['summary_plot_datas'][plot_name] = [('Nucleotide frequencies', os.path.basename(nucleotide_frequency_summary_filename)), ('Modification frequencies', os.path.basename(modification_frequency_summary_filename))] else: # guides are not the same - if not args.suppress_plots and not args.suppress_batch_summary_plots: + if not args.suppress_plots and not args.suppress_batch_summary_plots and should_plot_large_plots(nucleotide_percentage_summary_df.shape[0], C2PRO_INSTALLED, args.use_matplotlib): this_nuc_pct_quilt_plot_name = _jp(amplicon_plot_name.replace('.', '') + 'Nucleotide_percentage_quilt') nucleotide_quilt_input = { 'nuc_pct_df': nucleotide_percentage_summary_df, @@ -724,7 +753,7 @@ def main(): nuc_pct_quilt_plot_names.append(plot_name) crispresso2_info['results']['general_plots']['summary_plot_labels'][plot_name] = 'Composition of each base for the amplicon ' + amplicon_name crispresso2_info['results']['general_plots']['summary_plot_datas'][plot_name] = [('Nucleotide frequencies', os.path.basename(nucleotide_frequency_summary_filename)), ('Modification frequencies', os.path.basename(modification_frequency_summary_filename))] - if args.base_editor_output and (sub_nucleotide_percentage_summary_df.shape[0] / 6) < large_plot_cutoff: + if args.base_editor_output and should_plot_large_plots(nucleotide_percentage_summary_df.shape[0], False, args.use_matplotlib): this_nuc_conv_plot_name = _jp(amplicon_plot_name + 'Nucleotide_percentage_quilt') conversion_map_input = { 'nuc_pct_df': nucleotide_percentage_summary_df, @@ -745,7 +774,7 @@ def main(): crispresso2_info['results']['general_plots']['summary_plot_datas'][plot_name] = [('Nucleotide frequencies', os.path.basename(nucleotide_frequency_summary_filename)), ('Modification frequencies', os.path.basename(modification_frequency_summary_filename))] # allele modification frequency heatmap and line plots - if C2PRO_INSTALLED and not args.use_matplotlib and not args.suppress_plots and not args.suppress_batch_summary_plots and (nucleotide_percentage_summary_df.shape[0] / 6) < large_plot_cutoff: + if C2PRO_INSTALLED and not args.use_matplotlib and not args.suppress_plots and not args.suppress_batch_summary_plots: if guides_all_same: sgRNA_intervals = [consensus_sgRNA_intervals] * modification_frequency_summary_df.shape[0] else: @@ -771,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( @@ -799,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( @@ -831,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/CRISPRessoCORE.py b/CRISPResso2/CRISPRessoCORE.py index a3a57b9f..45ec50c1 100644 --- a/CRISPResso2/CRISPRessoCORE.py +++ b/CRISPResso2/CRISPRessoCORE.py @@ -3785,6 +3785,7 @@ def count_alternate_alleles(sub_base_vectors, ref_name, ref_sequence, ref_total_ 'sgRNA_intervals': sgRNA_intervals, 'sgRNA_names': sgRNA_names, 'sgRNA_mismatches': sgRNA_mismatches, + 'sgRNA_sequences': sgRNA_sequences, 'quantification_window_idxs': include_idxs_list, 'custom_colors': custom_config["colors"], } @@ -3833,6 +3834,7 @@ def count_alternate_alleles(sub_base_vectors, ref_name, ref_sequence, ref_total_ 'sgRNA_intervals': new_sgRNA_intervals, 'sgRNA_names': sgRNA_names, 'sgRNA_mismatches': sgRNA_mismatches, + 'sgRNA_sequences': sgRNA_sequences, 'quantification_window_idxs': new_include_idx, 'custom_colors': custom_config["colors"], } @@ -4184,6 +4186,7 @@ def count_alternate_alleles(sub_base_vectors, ref_name, ref_sequence, ref_total_ sgRNA_intervals = refs[ref_names_for_hdr[0]]['sgRNA_intervals'] sgRNA_names = refs[ref_names_for_hdr[0]]['sgRNA_names'] sgRNA_mismatches = refs[ref_names_for_hdr[0]]['sgRNA_mismatches'] + sgRNA_sequences = refs[ref_names_for_hdr[0]]['sgRNA_sequences'] # include_idxs_list = refs[ref_names_for_hdr[0]]['include_idxs'] include_idxs_list = [] # the quantification windows may be different between different amplicons @@ -4204,6 +4207,7 @@ def count_alternate_alleles(sub_base_vectors, ref_name, ref_sequence, ref_total_ 'quantification_window_idxs': include_idxs_list, 'sgRNA_names': sgRNA_names, 'sgRNA_mismatches': sgRNA_mismatches, + 'sgRNA_sequences': sgRNA_sequences, 'custom_colors': custom_config["colors"], } debug('Plotting HDR nucleotide quilt') @@ -4789,6 +4793,7 @@ def get_scaffold_len(row, scaffold_start_loc, scaffold_seq): sgRNA_intervals = refs[ref_names[0]]['sgRNA_intervals'] sgRNA_names = refs[ref_names[0]]['sgRNA_names'] sgRNA_mismatches = refs[ref_names[0]]['sgRNA_mismatches'] + sgRNA_sequences = refs[ref_names[0]]['sgRNA_sequences'] include_idxs_list = refs[ref_names[0]]['include_idxs'] plot_root = _jp('11a.Prime_editing_nucleotide_percentage_quilt') @@ -4801,6 +4806,7 @@ def get_scaffold_len(row, scaffold_start_loc, scaffold_seq): 'sgRNA_intervals': sgRNA_intervals, 'sgRNA_names': sgRNA_names, 'sgRNA_mismatches': sgRNA_mismatches, + 'sgRNA_sequences': sgRNA_sequences, 'quantification_window_idxs': include_idxs_list, 'custom_colors': custom_config['colors'] } @@ -4861,6 +4867,7 @@ def get_scaffold_len(row, scaffold_start_loc, scaffold_seq): 'sgRNA_intervals': new_sgRNA_intervals, 'sgRNA_names': sgRNA_names, 'sgRNA_mismatches': sgRNA_mismatches, + 'sgRNA_sequences': sgRNA_sequences, 'quantification_window_idxs': new_include_idx, 'custom_colors': custom_config['colors'] } 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 59bd6f5b..c01ff1f2 100644 --- a/CRISPResso2/CRISPRessoReports/templates/batchReport.html +++ b/CRISPResso2/CRISPRessoReports/templates/batchReport.html @@ -58,7 +58,7 @@
{{report_name}}
-
+
{% for run_name in run_names %} {{run_name}} {% endfor %} @@ -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]}}