Skip to content

Commit

Permalink
Add MEDIAN_TARGET_COVERAGE to HsMetrics. Fix RnaSeqMetrics regex
Browse files Browse the repository at this point in the history
  • Loading branch information
vladsavelyev committed Nov 2, 2023
1 parent b4e3a37 commit 0c51184
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 12 deletions.
11 changes: 9 additions & 2 deletions multiqc/modules/picard/HsMetrics.py
Original file line number Diff line number Diff line change
Expand Up @@ -238,6 +238,13 @@ def _general_stats_table(module, data):
"scale": "Blues",
"suffix": " X",
}
headers["MEDIAN_TARGET_COVERAGE"] = {
"title": "Median Target Coverage",
"description": "The median coverage of reads that mapped to target regions of an experiment.",
"min": 0,
"suffix": "X",
"scale": "GnBu",
}
try:
covs = picard_config["general_stats_target_coverage"]
assert isinstance(covs, list)
Expand All @@ -249,7 +256,7 @@ def _general_stats_table(module, data):
for c in covs:
headers["PCT_TARGET_BASES_{}X".format(c)] = {
"id": f"{module.anchor}_target_bases_{c}X",
"title": "% Target Bases {}X".format(c),
"title": "Target Bases ≥ {}X".format(c),
"description": "Percent of target bases with coverage ≥ {}X".format(c),
"max": 100,
"min": 0,
Expand Down Expand Up @@ -345,7 +352,7 @@ def _generate_table_header_config(table_cols, hidden_table_cols):
"description": FIELD_DESCRIPTIONS[h] if h in FIELD_DESCRIPTIONS else None,
}
if h.find("PCT") > -1:
headers[h]["title"] = "% {}".format(headers[h]["title"])
headers[h]["title"] = headers[h]["title"]
headers[h]["modify"] = lambda x: x * 100.0
headers[h]["max"] = 100
headers[h]["suffix"] = "%"
Expand Down
2 changes: 1 addition & 1 deletion multiqc/modules/picard/MarkDuplicates.py
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ def save_table_results(s_name, keys, parsed_data, recompute_merged_metrics):
# Add to general stats table
headers = {
"PERCENT_DUPLICATION": {
"title": "% Dups",
"title": "Duplication",
"description": "Mark Duplicates - Percent Duplication",
"max": 100,
"min": 0,
Expand Down
8 changes: 4 additions & 4 deletions multiqc/modules/picard/RnaSeqMetrics.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,15 +100,15 @@ def parse_reports(module):
# Add to general stats table
headers = dict()
headers["PCT_RIBOSOMAL_BASES"] = {
"title": "% rRNA",
"title": "rRNA",
"description": "Percent of aligned bases overlapping ribosomal RNA regions",
"max": 100,
"min": 0,
"suffix": "%",
"scale": "Reds",
}
headers["PCT_MRNA_BASES"] = {
"title": "% mRNA",
"title": "mRNA",
"description": "Percent of aligned bases overlapping UTRs and coding regions of mRNA transcripts",
"max": 100,
"min": 0,
Expand All @@ -130,9 +130,9 @@ def parse_reports(module):
warn_rrna = ""
rrna_missing = []
for s_name, metrics in data_by_sample.items():
if metrics["RIBOSOMAL_BASES"] == "":
if metrics["RIBOSOMAL_BASES"] == "NA":
rrna_missing.append(s_name)
if len(rrna_missing):
if rrna_missing:
if len(rrna_missing) < 5:
missing_samples = "for samples <code>{}</code>".format("</code>, <code>".join(rrna_missing))
else:
Expand Down
4 changes: 2 additions & 2 deletions multiqc/modules/picard/RrbsSummaryMetrics.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ def parse_reports(module):
# Add to general stats table
headers = dict()
headers["PCT_CPG_BASES_CONVERTED"] = {
"title": "% CpG Methylated",
"title": "CpG Methylated",
"description": "Percentage of times a CpG cytosine was converted",
"max": 100,
"min": 0,
Expand All @@ -81,7 +81,7 @@ def parse_reports(module):
"modify": lambda x: 100 - util.multiply_hundred(x),
}
headers["PCT_NON_CPG_BASES_CONVERTED"] = {
"title": "% Non-CpG Methylated",
"title": "Non-CpG Methylated",
"description": "Percentage of times a non-CpG cytosine was converted",
"max": 100,
"min": 0,
Expand Down
2 changes: 1 addition & 1 deletion multiqc/modules/picard/TargetedPcrMetrics.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ def parse_reports(module):
# Add to general stats table
headers = {
"PCT_AMPLIFIED_BASES": {
"title": "% Amplified Bases",
"title": "Amplified Bases",
"description": "The fraction of aligned bases that mapped to or near an amplicon.",
"min": 0,
"max": 100,
Expand Down
4 changes: 2 additions & 2 deletions multiqc/modules/picard/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ def is_line_right_before_table(
picard_classes = [picard_class]
return (
(line.startswith("## METRICS CLASS") or line.startswith("## HISTOGRAM"))
and (not picard_classes or any(c in line for c in picard_classes))
and (not picard_classes or any(c.upper() in line.upper() for c in picard_classes))
or sentieon_algo
and line.startswith("#SentieonCommandLine:")
and f" --algo {sentieon_algo}" in line
Expand Down Expand Up @@ -132,7 +132,7 @@ def extract_sample_name(

picard_command = (
line.startswith("# ")
and any(pt in line for pt in picard_tools)
and any(pt.upper() in line.upper() for pt in picard_tools)
and any(
f" {po}=" in line.upper()
or f" --{po}=" in line.upper()
Expand Down

0 comments on commit 0c51184

Please sign in to comment.