Skip to content

Commit

Permalink
Qualimap: BamQC: add percentage on target (#2020)
Browse files Browse the repository at this point in the history
* qualimap bamqc: add percentage on target

* Update multiqc/modules/qualimap/QM_BamQC.py

* Update multiqc/modules/qualimap/QM_BamQC.py

* rename the regions_mapped_reads metric

* Review tweaks

* Changelog

---------

Co-authored-by: Vlad Savelyev <vladislav.sav@gmail.com>
Co-authored-by: Phil Ewels <phil.ewels@seqera.io>
  • Loading branch information
3 people committed Sep 14, 2023
1 parent e3907d0 commit d601907
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 23 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,8 @@ This idea goes way back to [issue #290](https://github.com/ewels/MultiQC/issues/
- fix `UnicodeDecodeError` when parsing `fastqc_data.txt`: try latin-1 or fail gracefully ([#2024](https://github.com/ewels/MultiQC/issues/2024))
- **Kaiju**:
- Fix `UnboundLocalError` on outputs when Kanju was run with the `-e` flag ([#2023](https://github.com/ewels/MultiQC/pull/2023))
- **Qualimap**
- BamQC: Include `% On Target` in General Stats table ([#2019](https://github.com/ewels/MultiQC/issues/2019))

## [MultiQC v1.15](https://github.com/ewels/MultiQC/releases/tag/v1.15) - 2023-08-04

Expand Down
59 changes: 36 additions & 23 deletions multiqc/modules/qualimap/QM_BamQC.py
Original file line number Diff line number Diff line change
Expand Up @@ -135,12 +135,17 @@ def parse_genome_results(self, f):
try:
self.general_stats_data[s_name]["total_reads"] = d["total_reads"]
self.general_stats_data[s_name]["mapped_reads"] = d["mapped_reads"]
d["percentage_aligned"] = (d["mapped_reads"] / d["total_reads"]) * 100
self.general_stats_data[s_name]["percentage_aligned"] = d["percentage_aligned"]
self.general_stats_data[s_name]["general_error_rate"] = d["general_error_rate"] * 100
self.general_stats_data[s_name]["general_error_rate"] = d["general_error_rate"] * 100.0
self.general_stats_data[s_name]["mean_coverage"] = d["mean_coverage"]
self.general_stats_data[s_name]["regions_size"] = d["regions_size"]
self.general_stats_data[s_name]["regions_mapped_reads"] = d["regions_mapped_reads"]
try:
d["percentage_aligned"] = (d["mapped_reads"] / d["total_reads"]) * 100.0
self.general_stats_data[s_name]["percentage_aligned"] = d["percentage_aligned"]
d["percentage_aligned_on_target"] = (d["regions_mapped_reads"] / d["mapped_reads"]) * 100.0
self.general_stats_data[s_name]["percentage_aligned_on_target"] = d["percentage_aligned_on_target"]
except ZeroDivisionError:
pass
except KeyError:
pass

Expand Down Expand Up @@ -582,25 +587,25 @@ def general_stats_headers(self):
"suffix": "X",
"scale": "BuPu",
}
self.general_stats_headers["percentage_aligned"] = {
"title": "% Aligned",
"description": "% mapped reads",
self.general_stats_headers["percentage_aligned_on_target"] = {
"title": "% On target",
"description": "% mapped reads on target region",
"max": 100,
"min": 0,
"suffix": "%",
"scale": "YlGn",
}
self.general_stats_headers["mapped_reads"] = {
"title": "{} Aligned".format(config.read_count_prefix),
"description": "Number of mapped reads ({})".format(config.read_count_desc),
"scale": "RdYlGn",
"shared_key": "read_count",
self.general_stats_headers["regions_size"] = {
"title": "{} Region size".format(config.read_count_prefix),
"description": "Size of target region",
"suffix": " bp",
"scale": "PuBuGn",
"hidden": True,
}
self.general_stats_headers["total_reads"] = {
"title": "{} Total reads".format(config.read_count_prefix),
"description": "Number of reads ({})".format(config.read_count_desc),
"scale": "Blues",
self.general_stats_headers["regions_mapped_reads"] = {
"title": "{} On target".format(config.read_count_prefix),
"description": "Number of mapped reads on target region ({})".format(config.read_count_desc),
"scale": "RdYlGn",
"shared_key": "read_count",
"hidden": True,
}
Expand All @@ -614,20 +619,28 @@ def general_stats_headers(self):
"format": "{0:.2f}",
"hidden": True,
}
self.general_stats_headers["regions_size"] = {
"title": "{} Region size".format(config.read_count_prefix),
"description": "Size of target region",
"suffix": " bp",
"scale": "PuBuGn",
"hidden": True,
self.general_stats_headers["percentage_aligned"] = {
"title": "% Aligned",
"description": "% mapped reads",
"max": 100,
"min": 0,
"suffix": "%",
"scale": "YlGn",
}
self.general_stats_headers["regions_mapped_reads"] = {
self.general_stats_headers["mapped_reads"] = {
"title": "{} Aligned".format(config.read_count_prefix),
"description": "Number of mapped reads on target region ({})".format(config.read_count_desc),
"description": "Number of mapped reads ({})".format(config.read_count_desc),
"scale": "RdYlGn",
"shared_key": "read_count",
"hidden": True,
}
self.general_stats_headers["total_reads"] = {
"title": "{} Total reads".format(config.read_count_prefix),
"description": "Number of reads ({})".format(config.read_count_desc),
"scale": "Blues",
"shared_key": "read_count",
"hidden": True,
}


def _calculate_bases_within_thresholds(bases_by_depth, total_size, depth_thresholds):
Expand Down

0 comments on commit d601907

Please sign in to comment.