Skip to content

Commit

Permalink
Fix "square": True for scatter plot. Make the GATK BaseRecalibrator…
Browse files Browse the repository at this point in the history
… plot square (#2189)

* GATK: make base recalibrator square

* [automated] Update CHANGELOG.md

* Calculate max_val for square in python plotting code

* Unneeded refactoring

* Fix changelog

* FIx CSP

---------

Co-authored-by: MultiQC Bot <multiqc-bot@seqera.io>
  • Loading branch information
vladsavelyev and multiqc-bot committed Nov 21, 2023
1 parent 40d8ff1 commit fa2e848
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 0 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,14 @@

### MultiQC updates

- Fix the `"square": True` flag to scatter plot to actually make the plot square ([#2189](https://github.com/ewels/MultiQC/pull/2189))

### New Modules

### Module updates

- **GATK**: square the BaseRecalibrator scatter plot ([#2189](https://github.com/ewels/MultiQC/pull/2189))

## [MultiQC v1.18](https://github.com/ewels/MultiQC/releases/tag/v1.18) - 2023-11-17

### Highlights
Expand Down
3 changes: 3 additions & 0 deletions CSP.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@
# (Content Security Policy), you will need the following scripts allowlisted:

script-src 'self'
# 1.19
'sha256-/C57+E7g4T7gJpkhM4cBNKuHqniEVV8thOcQDOUy640=' # multiqc/templates/default/assets/js/multiqc_plotting.js

# 1.18
'sha256-aY1YMeLr1IxkwxjBe0x60QzbuT4u5Mh/QC6brcAN9Do=' # multiqc/templates/default/assets/js/multiqc_tables.js

Expand Down
4 changes: 4 additions & 0 deletions multiqc/modules/gatk/base_recalibrator.py
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,7 @@ def add_reported_vs_empirical_section(self):

# Build data label configs for this data type
data_labels.append({"name": "{} Reported vs. Empirical Quality", "ylab": "Empirical quality score"})

plot = scatter.plot(
sample_data,
pconfig={
Expand All @@ -185,6 +186,9 @@ def add_reported_vs_empirical_section(self):
"ylab": "Empirical quality score",
"xDecimals": False,
"data_labels": data_labels,
"xmin": 0,
"ymin": 0,
"square": True,
},
)

Expand Down
12 changes: 12 additions & 0 deletions multiqc/plots/scatter.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,18 @@ def plot(data, pconfig=None):
d.append(this_series)
plotdata.append(d)

if pconfig.get("square"):
# Find the max value
max_val = 0
for d in plotdata:
for s in d:
max_val = max(max_val, s["x"], s["y"])
max_val = 1.02 * max_val # add 2% padding
pconfig["xmax"] = max_val
pconfig["ymax"] = max_val
# Making sure HighCharts doesn't get creative in adding different paddings
pconfig["endOnTick"] = False

# Add on annotation data series
try:
if pconfig.get("extra_series"):
Expand Down
2 changes: 2 additions & 0 deletions multiqc/templates/default/assets/js/multiqc_plotting.js
Original file line number Diff line number Diff line change
Expand Up @@ -981,6 +981,7 @@ function plot_scatter_plot(target, ds) {
allowDecimals: config["xDecimals"],
plotBands: config["xPlotBands"],
plotLines: config["xPlotLines"],
endOnTick: config["endOnTick"],
},
yAxis: {
title: {
Expand All @@ -995,6 +996,7 @@ function plot_scatter_plot(target, ds) {
allowDecimals: config["yDecimals"],
plotBands: config["yPlotBands"],
plotLines: config["yPlotLines"],
endOnTick: config["endOnTick"],
},
plotOptions: {
series: {
Expand Down

0 comments on commit fa2e848

Please sign in to comment.