Skip to content

Commit

Permalink
Matplotlib Compatibility Fix (pinellolab#464)
Browse files Browse the repository at this point in the history
* D3-Enhancements (#78)

* 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 <cole@colelyman.com>

* 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 <snic9004@gmail.com>

* 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 <cole@colelyman.com>

* 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 <cole@colelyman.com>

* 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 <snic9004@gmail.com>

* 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 <cole@colelyman.com>

* 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

* Fix typo and move flexiguide to debug (#77)

* Change flexiguide output to debug level

* Fix typo in fastp merged output file name

* Adding id tags for d3 script enhancements

* pointing to test branch

* Add amplicon_name parameter to allele heatmap and line plots

* Add function to extract quantification window regions from include_idxs

* Scale the quantification window according to the coordinates of the sgRNA plot

* added c2pro check, added space in args.json

* Correct the quantification window indexes for multiple guides

* Fix name of nucleotide conversion plot when guides are not the same

* Fix jinja variables that aren't found

* Fix multiple guide errors where the wrong sgRNA sequence was associated in d3 plot

* Remove unneeded variable and extra whitespace

* Switch test branch to master

---------

Co-authored-by: Samuel Nichols <Snic9004@gmail.com>
Co-authored-by: mbowcut2 <55161542+mbowcut2@users.noreply.github.com>
Co-authored-by: Cole Lyman <cole@colelyman.com>

* Fix divide by zero error when there are no shared amplicons in Compare

* Try catch for matplotlib compatibility

---------

Co-authored-by: Trevor Martin <60452953+trevormartinj7@users.noreply.github.com>
Co-authored-by: Samuel Nichols <Snic9004@gmail.com>
Co-authored-by: mbowcut2 <55161542+mbowcut2@users.noreply.github.com>
Co-authored-by: Kendell Clement <k.clement.dev@gmail.com>
  • Loading branch information
5 people committed Nov 8, 2024
1 parent 9f22c2e commit 5db71c4
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 9 deletions.
3 changes: 2 additions & 1 deletion CRISPResso2/CRISPRessoCompareCORE.py
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,8 @@ def get_plot_title_with_ref_name(plotTitle, refName):
sig_counts = {} # number of bp significantly modified (bonferonni corrected fisher pvalue)
sig_counts_quant_window = {}
percent_complete_start, percent_complete_end = 10, 90
percent_complete_step = (percent_complete_end - percent_complete_start) / len(amplicon_names_in_both)
if amplicon_names_in_both:
percent_complete_step = (percent_complete_end - percent_complete_start) / len(amplicon_names_in_both)
for amplicon_name in amplicon_names_in_both:
percent_complete = percent_complete_start + percent_complete_step * amplicon_names_in_both.index(amplicon_name)
info('Loading data for amplicon %s' % amplicon_name, {'percent_complete': percent_complete})
Expand Down
36 changes: 28 additions & 8 deletions CRISPResso2/CRISPRessoPlot.py
Original file line number Diff line number Diff line change
Expand Up @@ -364,8 +364,13 @@ def plot_indel_size_distribution(
fancybox=True,
shadow=True,
)
lgd.legendHandles[0].set_height(3)
lgd.legendHandles[1].set_height(3)
# Try catch block to account for updated naming conventions in matplotlib v3.9.0
try:
lgd.legendHandles[0].set_height(3)
lgd.legendHandles[1].set_height(3)
except AttributeError as e:
lgd.legend_handles[0].set_height(3)
lgd.legend_handles[1].set_height(3)

ax.tick_params(left=True, bottom=True)
fig.savefig(plot_root + '.pdf', pad_inches=1, bbox_inches='tight')
Expand Down Expand Up @@ -413,8 +418,13 @@ def plot_frequency_deletions_insertions(
fancybox=True,
shadow=True,
)
lgd.legendHandles[0].set_height(6)
lgd.legendHandles[1].set_height(6)
# Try catch block to account for updated naming conventions in matplotlib v3.9.0
try:
lgd.legendHandles[0].set_height(6)
lgd.legendHandles[1].set_height(6)
except AttributeError as e:
lgd.legend_handles[0].set_height(6)
lgd.legend_handles[1].set_height(6)

ax.set_xlim([-1, xmax_ins])
y_label_values= np.round(
Expand Down Expand Up @@ -447,8 +457,13 @@ def plot_frequency_deletions_insertions(
fancybox=True,
shadow=True,
)
lgd.legendHandles[0].set_height(6)
lgd.legendHandles[1].set_height(6)
# Try catch block to account for updated naming conventions in matplotlib v3.9.0
try:
lgd.legendHandles[0].set_height(6)
lgd.legendHandles[1].set_height(6)
except AttributeError as e:
lgd.legend_handles[0].set_height(6)
lgd.legend_handles[1].set_height(6)

ax.set_xlim([-1 * xmax_del, 1])
y_label_values = np.round(
Expand Down Expand Up @@ -481,8 +496,13 @@ def plot_frequency_deletions_insertions(
fancybox=True,
shadow=True,
)
lgd.legendHandles[0].set_height(6)
lgd.legendHandles[1].set_height(6)
# Try catch block to account for updated naming conventions in matplotlib v3.9.0
try:
lgd.legendHandles[0].set_height(6)
lgd.legendHandles[1].set_height(6)
except AttributeError as e:
lgd.legend_handles[0].set_height(6)
lgd.legend_handles[1].set_height(6)

ax.set_xlim([-1, xmax_mut])
y_label_values= np.round(
Expand Down

0 comments on commit 5db71c4

Please sign in to comment.