Skip to content

Commit

Permalink
Reports, add reports to packages, colors, ordered pandas sort (#28)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
Snicker7 authored Aug 14, 2023
1 parent 2e9e6bf commit 3fb59cf
Show file tree
Hide file tree
Showing 31 changed files with 1,919 additions and 1,198 deletions.
2 changes: 1 addition & 1 deletion CRISPResso2/CRISPRessoAggregateCORE.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
from datetime import datetime
from CRISPResso2 import CRISPRessoShared
from CRISPResso2 import CRISPRessoPlot
from CRISPResso2 import CRISPRessoReport
from CRISPResso2.CRISPRessoReports import CRISPRessoReport
from CRISPResso2.CRISPRessoMultiProcessing import get_max_processes, run_plot


Expand Down
9 changes: 8 additions & 1 deletion CRISPResso2/CRISPRessoBatchCORE.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
from CRISPResso2 import CRISPRessoShared
from CRISPResso2 import CRISPRessoPlot
from CRISPResso2 import CRISPRessoMultiProcessing
from CRISPResso2 import CRISPRessoReport
from CRISPResso2.CRISPRessoReports import CRISPRessoReport

import logging

Expand Down Expand Up @@ -91,6 +91,7 @@ def main():
crispresso_options_for_batch = list(crispresso_options-options_to_ignore)

CRISPRessoShared.check_file(args.batch_settings)
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 @@ -596,6 +597,7 @@ def main():
'save_also_png': save_png,
'sgRNA_intervals': sub_sgRNA_intervals,
'quantification_window_idxs': include_idxs,
'custom_colors': config['colors'],
}
debug('Plotting nucleotide percentage quilt for amplicon {0}, sgRNA {1}'.format(amplicon_name, sgRNA))
plot(
Expand All @@ -620,6 +622,7 @@ def main():
'save_also_png': save_png,
'sgRNA_intervals': sub_sgRNA_intervals,
'quantification_window_idxs': include_idxs,
'custom_colors': config['colors']
}
debug('Plotting nucleotide conversion map for amplicon {0}, sgRNA {1}'.format(amplicon_name, sgRNA))
plot(
Expand All @@ -646,6 +649,7 @@ def main():
'save_also_png': save_png,
'sgRNA_intervals': consensus_sgRNA_intervals,
'quantification_window_idxs': include_idxs,
'custom_colors': config['colors'],
}
debug('Plotting nucleotide quilt for {0}'.format(amplicon_name))
plot(
Expand All @@ -669,6 +673,7 @@ def main():
'save_also_png': save_png,
'sgRNA_intervals': consensus_sgRNA_intervals,
'quantification_window_idxs': include_idxs,
'custom_colors': config['colors']
}
debug('Plotting nucleotide conversion map for {0}'.format(amplicon_name))
plot(
Expand All @@ -692,6 +697,7 @@ def main():
'mod_pct_df': modification_percentage_summary_df,
'fig_filename_root': this_nuc_pct_quilt_plot_name,
'save_also_png': save_png,
'custom_colors': config['colors'],
}
debug('Plotting nucleotide quilt for {0}'.format(amplicon_name))
plot(
Expand All @@ -710,6 +716,7 @@ def main():
'conversion_nuc_from': args.conversion_nuc_from,
'conversion_nuc_to': args.conversion_nuc_to,
'save_also_png': save_png,
'custom_colors': config['colors']
}
debug('Plotting BE nucleotide conversion map for {0}'.format(amplicon_name))
plot(
Expand Down
33 changes: 26 additions & 7 deletions CRISPResso2/CRISPRessoCORE.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@


from CRISPResso2 import CRISPRessoCOREResources
from CRISPResso2 import CRISPRessoReport
from CRISPResso2.CRISPRessoReports import CRISPRessoReport
from CRISPResso2 import CRISPRessoShared
from CRISPResso2 import CRISPRessoPlot
from CRISPResso2 import CRISPResso2Align
Expand Down Expand Up @@ -3363,6 +3363,7 @@ def save_count_vectors_to_file(vectors, vectorNames, refSeq, filename):
info('Making Plots...')
###############################################################################################################################################
save_png = True
config = CRISPRessoShared.check_custom_config(args)
if args.suppress_report:
save_png = False

Expand Down Expand Up @@ -3407,6 +3408,7 @@ def count_alternate_alleles(sub_base_vectors, ref_name, ref_sequence, ref_total_
else:
process_pool = None
process_futures = None

plot = partial(
CRISPRessoMultiProcessing.run_plot,
num_processes=n_processes,
Expand Down Expand Up @@ -3592,6 +3594,7 @@ def count_alternate_alleles(sub_base_vectors, ref_name, ref_sequence, ref_total_
'sgRNA_names': sgRNA_names,
'sgRNA_mismatches': sgRNA_mismatches,
'quantification_window_idxs': include_idxs_list,
'custom_colors': config["colors"],
}
debug('Plotting nucleotide quilt across amplicon')
plot(CRISPRessoPlot.plot_nucleotide_quilt, plot_2a_input)
Expand Down Expand Up @@ -3638,6 +3641,7 @@ def count_alternate_alleles(sub_base_vectors, ref_name, ref_sequence, ref_total_
'sgRNA_names': sgRNA_names,
'sgRNA_mismatches': sgRNA_mismatches,
'quantification_window_idxs': new_include_idx,
'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 @@ -3815,6 +3819,7 @@ def count_alternate_alleles(sub_base_vectors, ref_name, ref_sequence, ref_total_
),
},
'plot_root': plot_root,
'custom_colors': config["colors"],
'save_also_png': save_png,
}
debug('Plotting amplication modifications for {0}'.format(ref_name))
Expand Down Expand Up @@ -3844,12 +3849,13 @@ def count_alternate_alleles(sub_base_vectors, ref_name, ref_sequence, ref_total_
'Mutation position distribution', ref_name,
),
'plot_root': plot_root,
'custom_colors': config["colors"],
'save_also_png': save_png,
}
debug('Plotting modification frequency for {0}'.format(ref_name))
plot(CRISPRessoPlot.plot_modification_frequency, plot_4b_input)
crispresso2_info['results']['refs'][ref_name]['plot_4b_root'] = os.path.basename(plot_root)
crispresso2_info['results']['refs'][ref_name]['plot_4b_caption'] = "Figure 4b: Frequency of insertions (red), deletions (purple), and substitutions (green) across the entire amplicon, including modifications outside of the quantification window."
crispresso2_info['results']['refs'][ref_name]['plot_4b_caption'] = "Figure 4b: Frequency of insertions, deletions, and substitutions across the entire amplicon, including modifications outside of the quantification window."
crispresso2_info['results']['refs'][ref_name]['plot_4b_data'] = [('Modification frequency', os.path.basename(mod_count_filename))]

plot_root = _jp(
Expand All @@ -3872,6 +3878,7 @@ def count_alternate_alleles(sub_base_vectors, ref_name, ref_sequence, ref_total_
),
'ref_name': ref_name,
'plot_root': plot_root,
'custom_colors': config["colors"],
'save_also_png': save_png,
}
debug('Plotting quantification window locations for {0}'.format(ref_name))
Expand All @@ -3880,7 +3887,7 @@ def count_alternate_alleles(sub_base_vectors, ref_name, ref_sequence, ref_total_
plot_4c_input,
)
crispresso2_info['results']['refs'][ref_name]['plot_4c_root'] = os.path.basename(plot_root)
crispresso2_info['results']['refs'][ref_name]['plot_4c_caption'] = "Figure 4c: Frequency of insertions (red), deletions (purple), and substitutions (green) across the entire amplicon, considering only modifications that overlap with the quantification window."
crispresso2_info['results']['refs'][ref_name]['plot_4c_caption'] = "Figure 4c: Frequency of insertions, deletions, and substitutions across the entire amplicon, considering only modifications that overlap with the quantification window."
crispresso2_info['results']['refs'][ref_name]['plot_4c_data'] = [('Modification frequency in quantification window', os.path.basename(quant_window_mod_count_filename))]

#Position dependent indels plot
Expand Down Expand Up @@ -3928,6 +3935,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': config["colors"],
'save_also_png': save_png,
}
if ref_name == ref_names[0]:
Expand Down Expand Up @@ -3997,6 +4005,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,
'custom_colors': config["colors"],
}
debug('Plotting HDR nucleotide quilt')
plot(CRISPRessoPlot.plot_nucleotide_quilt, plot_4g_input)
Expand Down Expand Up @@ -4097,12 +4106,13 @@ def count_alternate_alleles(sub_base_vectors, ref_name, ref_sequence, ref_total_
ref_name,
),
'plot_root': plot_root,
'custom_colors': config["colors"],
'save_also_png': save_png,
}
debug('Plotting non-coding mutation positions for {0}'.format(ref_name))
plot(CRISPRessoPlot.plot_non_coding_mutations, plot_7_input)
crispresso2_info['results']['refs'][ref_name]['plot_7_root'] = os.path.basename(plot_root)
crispresso2_info['results']['refs'][ref_name]['plot_7_caption'] = "Figure 7: Reads with insertions (red), deletions (purple), and substitutions (green) mapped to reference amplicon position exclusively in noncoding region/s (that is, without mutations affecting coding sequences). The predicted cleavage site is indicated by a vertical dashed line. Only sequence positions directly adjacent to insertions or directly affected by deletions or substitutions are plotted."
crispresso2_info['results']['refs'][ref_name]['plot_7_caption'] = "Figure 7: Reads with insertions, deletions, and substitutions mapped to reference amplicon position exclusively in noncoding region/s (that is, without mutations affecting coding sequences). The predicted cleavage site is indicated by a vertical dashed line. Only sequence positions directly adjacent to insertions or directly affected by deletions or substitutions are plotted."
crispresso2_info['results']['refs'][ref_name]['plot_7_data'] = []

plot_root = _jp('8.'+ref_plot_name+'Potential_splice_sites_pie_chart')
Expand Down Expand Up @@ -4136,6 +4146,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': config['colors']
}
debug('Plotting substitutions across reference for {0}'.format(ref_name))
plot(CRISPRessoPlot.plot_subs_across_ref, plot_10a_input)
Expand All @@ -4153,7 +4164,8 @@ def count_alternate_alleles(sub_base_vectors, ref_name, ref_sequence, ref_total_
'Substitution frequency\nin entire amplicon', ref_name,
),
'fig_filename_root': fig_filename_root,
'save_also_png': save_png
'save_also_png': save_png,
'custom_colors': config['colors']
}
debug('Plotting substitution frequency barplot for {0}'.format(ref_name))
plot(CRISPRessoPlot.plot_sub_freqs, plot_10b_input)
Expand All @@ -4167,7 +4179,8 @@ def count_alternate_alleles(sub_base_vectors, ref_name, ref_sequence, ref_total_
'alt_nuc_counts': alt_nuc_counts,
'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
'save_also_png': save_png,
'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 @@ -4258,6 +4271,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 @@ -4344,6 +4358,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': 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 @@ -4363,6 +4378,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': 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 @@ -4384,7 +4400,8 @@ 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
'save_also_png': save_png,
'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 @@ -4576,6 +4593,7 @@ def get_scaffold_len(row, scaffold_start_loc, scaffold_seq):
'sgRNA_names': sgRNA_names,
'sgRNA_mismatches': sgRNA_mismatches,
'quantification_window_idxs': include_idxs_list,
'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 @@ -4634,6 +4652,7 @@ def get_scaffold_len(row, scaffold_start_loc, scaffold_seq):
'sgRNA_names': sgRNA_names,
'sgRNA_mismatches': sgRNA_mismatches,
'quantification_window_idxs': new_include_idx,
'custom_colors': config['colors']
}
info('Plotting nucleotide quilt', {'percent_complete': 97})
plot(CRISPRessoPlot.plot_nucleotide_quilt, plot_11b_input)
Expand Down
2 changes: 1 addition & 1 deletion CRISPResso2/CRISPRessoCompareCORE.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
import argparse
from CRISPResso2 import CRISPRessoShared
from CRISPResso2 import CRISPRessoPlot
from CRISPResso2 import CRISPRessoReport
from CRISPResso2.CRISPRessoReports import CRISPRessoReport

import logging

Expand Down
2 changes: 1 addition & 1 deletion CRISPResso2/CRISPRessoMetaCORE.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
from CRISPResso2 import CRISPRessoShared
from CRISPResso2 import CRISPRessoPlot
from CRISPResso2 import CRISPRessoMultiProcessing
from CRISPResso2 import CRISPRessoReport
from CRISPResso2.CRISPRessoReports import CRISPRessoReport


import logging
Expand Down
Loading

0 comments on commit 3fb59cf

Please sign in to comment.