Skip to content

Commit

Permalink
Fix plots and improve plot error handling (pinellolab#431)
Browse files Browse the repository at this point in the history
* 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 <[email protected]>

* 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 <[email protected]>

* 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 <[email protected]>
Co-authored-by: Cole Lyman <[email protected]>

* 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 <[email protected]>

* 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 <[email protected]>

* Try catch all futures

* Fix test fail plots

* Fix d3 not showing and plotly mixing with matplotlib

---------

Co-authored-by: mbowcut2 <[email protected]>
Co-authored-by: Cole Lyman <[email protected]>

* Remove token from integration tests file

---------

Co-authored-by: Samuel Nichols <[email protected]>
Co-authored-by: mbowcut2 <[email protected]>
  • Loading branch information
3 people committed Nov 8, 2024
1 parent 9631067 commit 5eee80c
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 13 deletions.
1 change: 0 additions & 1 deletion .github/workflows/integration_tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@ jobs:
uses: actions/checkout@v3
with:
repository: edilytics/CRISPResso2_tests
token: ${{ secrets.ACCESS_CRISPRESSO2_TESTS }}
# ref: '<BRANCH-NAME>' # Use this to specify a branch other than master

- name: Run Basic
Expand Down
8 changes: 4 additions & 4 deletions CRISPResso2/CRISPRessoCORE.py
Original file line number Diff line number Diff line change
Expand Up @@ -3776,11 +3776,11 @@ def count_alternate_alleles(sub_base_vectors, ref_name, ref_sequence, ref_total_
mod_df_for_plot.insert(0, 'Batch', ref_name)

plot_root = _jp('2a.'+ ref_plot_name + 'Nucleotide_percentage_quilt')
pro_output_name = f'plot_{os.path.basename(plot_root)}.json'
pro_output_name = os.path.join(OUTPUT_DIRECTORY, f'plot_{os.path.basename(plot_root)}.json')
plot_2a_input = {
'nuc_pct_df': nuc_df_for_plot,
'mod_pct_df': mod_df_for_plot,
'fig_filename_root': f'{_jp(pro_output_name)}' if not args.use_matplotlib and C2PRO_INSTALLED else plot_root,
'fig_filename_root': pro_output_name if not args.use_matplotlib and C2PRO_INSTALLED else plot_root,
'save_also_png': save_png,
'sgRNA_intervals': sgRNA_intervals,
'sgRNA_names': sgRNA_names,
Expand Down Expand Up @@ -3825,11 +3825,11 @@ def count_alternate_alleles(sub_base_vectors, ref_name, ref_sequence, ref_total_
for x in include_idxs_list:
new_include_idx += [x - new_sel_cols_start]
plot_root = _jp('2b.'+ ref_plot_name + 'Nucleotide_percentage_quilt_around_' + sgRNA_label)
pro_output_name = f'plot_{os.path.basename(plot_root)}.json'
pro_output_name = os.path.join(OUTPUT_DIRECTORY, f'plot_{os.path.basename(plot_root)}.json')
plot_2b_input = {
'nuc_pct_df': nuc_df_for_plot.iloc[:, sel_cols],
'mod_pct_df': mod_df_for_plot.iloc[:, sel_cols],
'fig_filename_root': f'{_jp(pro_output_name)}' if not args.use_matplotlib and C2PRO_INSTALLED else plot_root,
'fig_filename_root': pro_output_name if not args.use_matplotlib and C2PRO_INSTALLED else plot_root,
'save_also_png': save_png,
'sgRNA_intervals': new_sgRNA_intervals,
'sgRNA_names': sgRNA_names,
Expand Down
1 change: 0 additions & 1 deletion CRISPResso2/CRISPRessoReports/CRISPRessoReport.py
Original file line number Diff line number Diff line change
Expand Up @@ -597,7 +597,6 @@ def fill_default(dictionary, key, default_type=list):
'datas': [],
'htmls': [],
}

for html in sub_html_files:
sub_html_files[html] = crispresso_data_path + sub_html_files[html]
with open(crispresso_multi_report_file, 'w', encoding="utf-8") as outfile:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
{%- if amplicon_name is defined -%}
{%- if 'htmls' in report_data['figures'] and fig_name in report_data['figures']['htmls'][amplicon_name] -%}
{{report_data['figures']['htmls'][amplicon_name][fig_name]|safe}}
{%- else -%}
{%- elif fig_name in report_data['figures']['locs'][amplicon_name] -%}
<a href="{{report_data['crispresso_data_path']}}{{report_data['figures']['locs'][amplicon_name][fig_name]}}.pdf"><img src="{{report_data['crispresso_data_path']}}{{report_data['figures']['locs'][amplicon_name][fig_name]}}.png" width='{{width}}'></a>
{% endif -%}
<label class="labelpadding">{{report_data['figures']['captions'][amplicon_name][fig_name]}}</label>
Expand All @@ -23,12 +23,14 @@
{%- else %}
{%- if 'htmls' in report_data['figures'] and fig_name in report_data['figures']['htmls'] -%}
{{report_data['figures']['htmls'][fig_name]|safe}}
{%- else -%}
{%- elif fig_name in report_data['figures']['locs'] -%}
<a href="{{report_data['crispresso_data_path']}}{{report_data['figures']['locs'][fig_name]}}.pdf"><img src="{{report_data['crispresso_data_path']}}{{report_data['figures']['locs'][fig_name]}}.png" width='{{width}}'></a>
{% endif -%}
<label class="labelpadding">{{report_data['figures']['captions'][fig_name]}}</label>
{%- for (data_label,data_path) in report_data['figures']['datas'][fig_name] %}
<p class="m-0"><small>Data: <a href="{{report_data['crispresso_data_path']}}{{data_path}}">{{data_label}}</a></small></p>
{%- endfor -%}
{% if fig_name in report_data['figures']['captions'] and fig_name in report_data['figures']['datas'] %}
<label class="labelpadding">{{report_data['figures']['captions'][fig_name]}}</label>
{%- for (data_label,data_path) in report_data['figures']['datas'][fig_name] %}
<p class="m-0"><small>Data: <a href="{{report_data['crispresso_data_path']}}{{data_path}}">{{data_label}}</a></small></p>
{%- endfor -%}
{%- endif %}
{%- endif %}
</div>
</div>

0 comments on commit 5eee80c

Please sign in to comment.