Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix "square": True for scatter plot. Make the GATK BaseRecalibrator plot square #2189

Merged
merged 7 commits into from
Nov 21, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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