Skip to content

Commit

Permalink
Failed batch runs (#33)
Browse files Browse the repository at this point in the history
* Reports, add reports to packages, colors, ordered pandas sort (#28)

* Sort by #Reads instead of %Reads to avoid floating point errors

* Fix x-axis spacing on some reports

* Add break to header matching loop to prevent match statements being printed after failure

* Check all headers and only error if there are unmatched values

* Fix indent

* Remove missing_header variable

* Fix tick marks

* Squashed 'CRISPResso2/CRISPRessoReports/' changes from 7d9b4e5..e18807d

* X-axis tick fix on fig 6a

* Fix function name from styles to config

* Squashed 'CRISPResso2/CRISPRessoReports/' changes from e18807d..e9da7bf

git-subtree-dir: CRISPResso2/CRISPRessoReports
git-subtree-split: e9da7bff794058e1fcdb3dc9ced79871c6a30e18

* Add CRISPRessoReports to packages

* Colors only with pro

* changed tuple to list for matplotlib change (#31)

* wgs and batch failed runs implementation

* Added failed run functionality including shared function, edits to Report, and displaying with HTML and Javascript

* Merge CRISPRessoReports master into failed-batch-runs

* Cole's failed-batch-runs review and changes (#36)

* Fix showing link to report in CLI (only show in web)

* Remove styling of jumbotron

The p-5 added some weird space at the top of the container, the rounded-3 did
not make a difference (because there is no background), and the h-100 also did
not make a difference.

* Remove extra spaces at end of the line

* Remove color legend from figure caption in plot 4f

* Refactor fig_reports.html partial to reduce duplication

* Add opacity to custom colors on allele quilt plot

* Remove extra spaces

* Change default color of deletion

It looked too similar to `N` and was difficult to tell apart.

* Refactor plot 10c, refactor displaying of figures

This commit adds flexbox to the plots, this was mainly for plots 10b and 10c
because their alignment was off.

* Add more plots to get the correct percentages for width

* Remove setting the height of the plots

* Check for failed batch info before retrieving it in `make_multi_report_from_folder`

* Fix extraneous whitespace in `fig_reports` partial

* Only load certain resources when on web mode

* Move jQuery import to bottom of the page to improve performance

* Extract out report footer buttons to partial

* Fix too many closing divs in batchReport.html

* Refactor failed runs to be a partial

* Move the failed run JS to the partial

This has the benefit of keeping the relevant code close, and also prevents the
error that we were running into before where `chevronIcon` wasn't found when
there were no failed runs (because the element wasn't there).

* Remove `report_name` id because it probably has spaces

* Move existing Plotly plots to batchReport from multiReport

* Fix typo in fig 11c and resize it to 40%

---------

Co-authored-by: Samuel Nichols <[email protected]>
Co-authored-by: mbowcut2 <[email protected]>
Co-authored-by: Cole Lyman <[email protected]>
  • Loading branch information
4 people committed Nov 8, 2024
1 parent 18efdea commit 2bd6590
Show file tree
Hide file tree
Showing 21 changed files with 425 additions and 694 deletions.
1 change: 1 addition & 0 deletions CRISPResso2/CRISPRessoAggregateCORE.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
import traceback
from datetime import datetime
from CRISPResso2 import CRISPRessoShared
from CRISPResso2 import CRISPRessoPlot
from CRISPResso2.CRISPRessoReports import CRISPRessoReport
from CRISPResso2.CRISPRessoMultiProcessing import get_max_processes, run_plot

Expand Down
20 changes: 7 additions & 13 deletions CRISPResso2/CRISPRessoBatchCORE.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,6 @@
from CRISPResso2 import CRISPRessoMultiProcessing
from CRISPResso2.CRISPRessoReports import CRISPRessoReport

if CRISPRessoShared.is_C2Pro_installed():
import CRISPRessoPro
C2PRO_INSTALLED = True
else:
C2PRO_INSTALLED = False

import logging

logger = logging.getLogger(__name__)
Expand Down Expand Up @@ -115,7 +109,7 @@ def main():
crispresso_options_for_batch = list(crispresso_options-options_to_ignore)

CRISPRessoShared.check_file(args.batch_settings)
custom_config = CRISPRessoShared.check_custom_config(args)
config = CRISPRessoShared.check_custom_config(args)

if args.zip_output and not args.place_report_in_output_folder:
warn('Invalid arguement combination: If zip_output is True then place_report_in_output_folder must also be True. Setting place_report_in_output_folder to True.')
Expand Down Expand Up @@ -643,7 +637,7 @@ def main():
'sgRNA_intervals': sub_sgRNA_intervals,
'sgRNA_sequences': consensus_guides,
'quantification_window_idxs': include_idxs,
'custom_colors': custom_config['colors'],
'custom_colors': config['colors'],
}
debug('Plotting nucleotide percentage quilt for amplicon {0}, sgRNA {1}'.format(amplicon_name, sgRNA))
plot(
Expand All @@ -666,7 +660,7 @@ def main():
'save_also_png': save_png,
'sgRNA_intervals': sub_sgRNA_intervals,
'quantification_window_idxs': include_idxs,
'custom_colors': custom_config['colors']
'custom_colors': config['colors']
}
debug('Plotting nucleotide conversion map for amplicon {0}, sgRNA {1}'.format(amplicon_name, sgRNA))
plot(
Expand Down Expand Up @@ -694,7 +688,7 @@ def main():
'sgRNA_intervals': consensus_sgRNA_intervals,
'sgRNA_sequences': consensus_guides,
'quantification_window_idxs': include_idxs,
'custom_colors': custom_config['colors'],
'custom_colors': config['colors'],
}
debug('Plotting nucleotide quilt for {0}'.format(amplicon_name))
plot(
Expand All @@ -718,7 +712,7 @@ def main():
'save_also_png': save_png,
'sgRNA_intervals': consensus_sgRNA_intervals,
'quantification_window_idxs': include_idxs,
'custom_colors': custom_config['colors']
'custom_colors': config['colors']
}
debug('Plotting nucleotide conversion map for {0}'.format(amplicon_name))
plot(
Expand All @@ -742,7 +736,7 @@ def main():
'mod_pct_df': modification_percentage_summary_df,
'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,
'custom_colors': custom_config['colors'],
'custom_colors': config['colors'],
}
debug('Plotting nucleotide quilt for {0}'.format(amplicon_name))
plot(
Expand All @@ -761,7 +755,7 @@ def main():
'conversion_nuc_from': args.conversion_nuc_from,
'conversion_nuc_to': args.conversion_nuc_to,
'save_also_png': save_png,
'custom_colors': custom_config['colors']
'custom_colors': config['colors']
}
debug('Plotting BE nucleotide conversion map for {0}'.format(amplicon_name))
plot(
Expand Down
37 changes: 18 additions & 19 deletions CRISPResso2/CRISPRessoCORE.py
Original file line number Diff line number Diff line change
Expand Up @@ -3553,7 +3553,7 @@ def save_count_vectors_to_file(vectors, vectorNames, refSeq, filename):
info('Making Plots...')
###############################################################################################################################################
save_png = True
custom_config = CRISPRessoShared.check_custom_config(args)
config = CRISPRessoShared.check_custom_config(args)
if args.suppress_report:
save_png = False

Expand Down Expand Up @@ -3787,7 +3787,7 @@ def count_alternate_alleles(sub_base_vectors, ref_name, ref_sequence, ref_total_
'sgRNA_mismatches': sgRNA_mismatches,
'sgRNA_sequences': sgRNA_sequences,
'quantification_window_idxs': include_idxs_list,
'custom_colors': custom_config["colors"],
'custom_colors': config["colors"],
}
debug('Plotting nucleotide quilt across amplicon')
plot(CRISPRessoPlot.plot_nucleotide_quilt, plot_2a_input)
Expand Down Expand Up @@ -3836,7 +3836,7 @@ def count_alternate_alleles(sub_base_vectors, ref_name, ref_sequence, ref_total_
'sgRNA_mismatches': sgRNA_mismatches,
'sgRNA_sequences': sgRNA_sequences,
'quantification_window_idxs': new_include_idx,
'custom_colors': custom_config["colors"],
'custom_colors': config["colors"],
}
debug('Plotting nucleotide distribuition around {0} for {1}'.format(sgRNA_legend, ref_name))
plot(CRISPRessoPlot.plot_nucleotide_quilt, plot_2b_input)
Expand Down Expand Up @@ -4017,7 +4017,7 @@ def count_alternate_alleles(sub_base_vectors, ref_name, ref_sequence, ref_total_
),
},
'plot_root': plot_root,
'custom_colors': custom_config["colors"],
'custom_colors': config["colors"],
'save_also_png': save_png,
}
debug('Plotting amplication modifications for {0}'.format(ref_name))
Expand Down Expand Up @@ -4047,7 +4047,7 @@ def count_alternate_alleles(sub_base_vectors, ref_name, ref_sequence, ref_total_
'Mutation position distribution', ref_name,
),
'plot_root': plot_root,
'custom_colors': custom_config["colors"],
'custom_colors': config["colors"],
'save_also_png': save_png,
}
debug('Plotting modification frequency for {0}'.format(ref_name))
Expand Down Expand Up @@ -4076,7 +4076,7 @@ def count_alternate_alleles(sub_base_vectors, ref_name, ref_sequence, ref_total_
),
'ref_name': ref_name,
'plot_root': plot_root,
'custom_colors': custom_config["colors"],
'custom_colors': config["colors"],
'save_also_png': save_png,
}
debug('Plotting quantification window locations for {0}'.format(ref_name))
Expand Down Expand Up @@ -4134,7 +4134,7 @@ def count_alternate_alleles(sub_base_vectors, ref_name, ref_sequence, ref_total_
'n_total': N_TOTAL,
'ref_len': ref_len,
'ref_name': ref_names[0],
'custom_colors': custom_config["colors"],
'custom_colors': config["colors"],
'save_also_png': save_png,
}
if ref_name == ref_names[0]:
Expand Down Expand Up @@ -4207,8 +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"],
'custom_colors': config["colors"],
}
debug('Plotting HDR nucleotide quilt')
plot(CRISPRessoPlot.plot_nucleotide_quilt, plot_4g_input)
Expand Down Expand Up @@ -4311,7 +4310,7 @@ def count_alternate_alleles(sub_base_vectors, ref_name, ref_sequence, ref_total_
ref_name,
),
'plot_root': plot_root,
'custom_colors': custom_config["colors"],
'custom_colors': config["colors"],
'save_also_png': save_png,
'ref_name': ref_name,
}
Expand Down Expand Up @@ -4354,8 +4353,7 @@ def count_alternate_alleles(sub_base_vectors, ref_name, ref_sequence, ref_total_
'fig_filename_root': fig_filename_root,
'save_also_png': save_png,
'quantification_window_idxs': include_idxs_list,
'custom_colors': custom_config['colors'],
'ref_name': ref_name,
'custom_colors': config['colors']
}
debug('Plotting substitutions across reference for {0}'.format(ref_name))
plot(CRISPRessoPlot.plot_subs_across_ref, plot_10a_input)
Expand All @@ -4374,7 +4372,7 @@ def count_alternate_alleles(sub_base_vectors, ref_name, ref_sequence, ref_total_
),
'fig_filename_root': fig_filename_root,
'save_also_png': save_png,
'custom_colors': custom_config['colors']
'custom_colors': config['colors']
}
debug('Plotting substitution frequency barplot for {0}'.format(ref_name))
plot(CRISPRessoPlot.plot_sub_freqs, plot_10b_input)
Expand All @@ -4389,7 +4387,7 @@ def count_alternate_alleles(sub_base_vectors, ref_name, ref_sequence, ref_total_
'plot_title': get_plot_title_with_ref_name('Substitution frequency\nin quantification window', ref_name),
'fig_filename_root': fig_filename_root,
'save_also_png': save_png,
'custom_colors': custom_config['colors']
'custom_colors': config['colors']
}
debug('Plotting substitution frequency barplot in quantification window for {0}'.format(ref_name))
plot(CRISPRessoPlot.plot_sub_freqs, plot_10c_input)
Expand Down Expand Up @@ -4481,6 +4479,7 @@ def count_alternate_alleles(sub_base_vectors, ref_name, ref_sequence, ref_total_
'sgRNA_names': sgRNA_names,
'sgRNA_mismatches': sgRNA_mismatches,
'annotate_wildtype_allele': args.annotate_wildtype_allele,
'custom_colors': config["colors"],
}
debug('Plotting allele distribution around cut for {0}'.format(ref_name))
plot(CRISPRessoPlot.plot_alleles_table, plot_9_input)
Expand Down Expand Up @@ -4567,7 +4566,7 @@ def count_alternate_alleles(sub_base_vectors, ref_name, ref_sequence, ref_total_
'conversion_nuc_from': args.conversion_nuc_from,
'fig_filename_root': fig_filename_root,
'save_also_png': save_png,
'custom_colors': custom_config['colors'],
'custom_colors': config['colors'],
}
debug('Plotting conversion at {0}s around the {1} for {2}'.format(args.conversion_nuc_from, sgRNA_legend, ref_name))
plot(
Expand All @@ -4587,7 +4586,7 @@ def count_alternate_alleles(sub_base_vectors, ref_name, ref_sequence, ref_total_
'conversion_nuc_from': args.conversion_nuc_from,
'fig_filename_root': fig_filename_root,
'save_also_png': save_png,
'custom_colors': custom_config['colors']
'custom_colors': config['colors']
}
debug('Plotting non-reference conversion at {0}s around the {1} for {2}'.format(args.conversion_nuc_from, sgRNA_legend, ref_name))
plot(
Expand All @@ -4610,7 +4609,7 @@ def count_alternate_alleles(sub_base_vectors, ref_name, ref_sequence, ref_total_
'conversion_nuc_from': args.conversion_nuc_from,
'fig_filename_root': fig_filename_root,
'save_also_png': save_png,
'custom_colors': custom_config['colors']
'custom_colors': config['colors']
}
debug('Plotting scaled non-reference conversion at {0}s around the {1} for {2}'.format(args.conversion_nuc_from, sgRNA_legend, ref_name))
plot(
Expand Down Expand Up @@ -4808,7 +4807,7 @@ def get_scaffold_len(row, scaffold_start_loc, scaffold_seq):
'sgRNA_mismatches': sgRNA_mismatches,
'sgRNA_sequences': sgRNA_sequences,
'quantification_window_idxs': include_idxs_list,
'custom_colors': custom_config['colors']
'custom_colors': config['colors']
}
info('Plotting prime editing nucleotide percentage quilt', {'percent_complete': 96})
plot(CRISPRessoPlot.plot_nucleotide_quilt, plot_11a_input)
Expand Down Expand Up @@ -4869,7 +4868,7 @@ def get_scaffold_len(row, scaffold_start_loc, scaffold_seq):
'sgRNA_mismatches': sgRNA_mismatches,
'sgRNA_sequences': sgRNA_sequences,
'quantification_window_idxs': new_include_idx,
'custom_colors': custom_config['colors']
'custom_colors': config['colors']
}
info('Plotting nucleotide quilt', {'percent_complete': 97})
plot(CRISPRessoPlot.plot_nucleotide_quilt, plot_11b_input)
Expand Down
1 change: 1 addition & 0 deletions CRISPResso2/CRISPRessoCompareCORE.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import sys
import traceback
from CRISPResso2 import CRISPRessoShared
from CRISPResso2 import CRISPRessoPlot
from CRISPResso2.CRISPRessoReports import CRISPRessoReport

import logging
Expand Down
Loading

0 comments on commit 2bd6590

Please sign in to comment.