Skip to content

Commit

Permalink
Violin plot: filter Inf values (#2380)
Browse files Browse the repository at this point in the history
* Violin plot: filter Inf values

* [automated] Update CHANGELOG.md

---------

Co-authored-by: MultiQC Bot <multiqc-bot@seqera.io>
  • Loading branch information
vladsavelyev and multiqc-bot committed Feb 25, 2024
1 parent 24abb02 commit 9379f89
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
- Fix: infinite `dmax` or `dmin` fail JSON dump load in JavaScript ([#2354](https://github.com/MultiQC/MultiQC/pull/2354))
- Fix: wrap `full_figure_for_development` in try to handle Kaleido error ([#2359](https://github.com/MultiQC/MultiQC/pull/2359))
- Generic font family for Plotly ([#2368](https://github.com/MultiQC/MultiQC/pull/2368))
- Violin plot: filter Inf values ([#2380](https://github.com/MultiQC/MultiQC/pull/2380))

### New modules

Expand Down
6 changes: 3 additions & 3 deletions multiqc/plots/plotly/violin.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,10 +91,10 @@ def create(
values_are_numeric = all(isinstance(v, (int, float)) for v in value_by_sample.values())
values_are_integer = all(isinstance(v, int) for v in value_by_sample.values())
if values_are_numeric:
# Remove NaN values
value_by_sample = {s: v for s, v in value_by_sample.items() if not math.isnan(v)}
# Remove NaN and Inf values
value_by_sample = {s: v for s, v in value_by_sample.items() if np.isfinite(v)}
if not value_by_sample:
logger.warning(f"All values are NaN for metric: {header['title']}")
logger.warning(f"All values are NaN or Inf for metric: {header['title']}")
continue

header["show_points"] = len(value_by_sample) <= config.violin_min_threshold_no_points
Expand Down

0 comments on commit 9379f89

Please sign in to comment.