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

feat: extract additional WGS metrics #907

Merged
merged 9 commits into from
Apr 11, 2022
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 8 additions & 3 deletions BALSAMIC/assets/scripts/collect_qc_metrics.py
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ def collect_qc_metrics(

def capture_kit_resolve_type(capture_kit: str):
"""Resolves the capture_kit type (NoneType or String)"""

if capture_kit == "None":
return None
else:
Expand All @@ -67,9 +68,12 @@ def get_multiqc_data_source(multiqc_data: dict, sample: str, tool: str) -> str:
A source file that was used to produce a specific metric
"""

# Use case: splits multiqc_picard_dups into ['multiqc', 'picard', 'dup'] in order to retrieve the
# ["report_data_sources"]["Picard"]["DuplicationMetrics"] values from multiqc_data.json
subtool_name = tool[:-1].split("_")
if tool == "multiqc_general_stats":
subtool_name = ["multiqc", "FastQC", "all_sections"]
else:
# Use case: splits multiqc_picard_dups into ['multiqc', 'picard', 'dup'] in order to retrieve the
# ["report_data_sources"]["Picard"]["DuplicationMetrics"] values from multiqc_data.json
subtool_name = tool[:-1].split("_")

# Nested json fetching
for source_tool in multiqc_data["report_data_sources"]:
Expand Down Expand Up @@ -139,6 +143,7 @@ def extract(data, output_metrics, sample=None, source=None):

if isinstance(data, dict):
for k in data:
# Ignore UMI and reverse reads metrics
if "umi" not in k:
if k in requested_metrics:
output_metrics.append(
Expand Down
11 changes: 10 additions & 1 deletion BALSAMIC/constants/quality_check_reporting.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,5 +90,14 @@
"FOLD_80_BASE_PENALTY": {"condition": {"norm": "lt", "threshold": 1.8}},
},
},
"wgs": {"FOLD_80_BASE_PENALTY": {"condition": {"norm": "lt", "threshold": 1.8}}},
"wgs": {
"MEAN_INSERT_SIZE": {"condition": None},
"MEDIAN_COVERAGE": {"condition": None},
"FastQC_mqc-generalstats-fastqc-percent_duplicates": {"condition": None},
"PCT_15X": {"condition": None},
"PCT_30X": {"condition": None},
"PCT_60X": {"condition": None},
"PCT_100X": {"condition": None},
"FOLD_80_BASE_PENALTY": {"condition": {"norm": "lt", "threshold": 1.8}},
ivadym marked this conversation as resolved.
Show resolved Hide resolved
},
}
11 changes: 10 additions & 1 deletion BALSAMIC/utils/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -739,6 +739,15 @@ class MetricModel(BaseModel):
value: Any = ...
condition: Optional[MetricConditionModel] = ...

@validator("name")
def validate_name(cls, name, values):
"""Updates the name if the source is FastQC"""

if "fastqc-percent_duplicates" in name:
return "PERCENT_DUPLICATION_R" + values["input"].split("_")[-2]

return name


class MetricValidationModel(BaseModel):
"""Defines the metric validation model
Expand All @@ -753,7 +762,7 @@ class MetricValidationModel(BaseModel):
metrics: List[MetricModel]

@validator("metrics", each_item=True)
def check_squares(cls, metric):
def validate_metrics(cls, metric):
"""Checks if a metric meets its filtering condition"""

if metric.condition and not VALID_OPS[metric.condition.norm](
Expand Down
1 change: 1 addition & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ Added:
* Snakemake rule for creating `.cgh` files from `CNVkit` outputs #858
* SVdb to TGA workflow #871
* SVdb merge SV and CNV #871
* Additional WGS metrics to be stored in ``<case>_metrics_deliverables.yaml`` #907

Changed:
^^^^^^^^
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,14 @@
"DuplicationMetrics": {
"concatenated_tumor_XXXXXX_R": "tests/test_data/qc_files/analysis/bam/concatenated_tumor_XXXXXX_R.sorted.mrkdup.txt"
}
},
"FastQC": {
"all_sections": {
"concatenated_tumor_XXXXXX_R_2": "tests/test_data/qc_files/analysis/fastqc/concatenated_tumor_XXXXXX_R_2_fastqc.zip",
"concatenated_normal_XXXXXX_R_1": "tests/test_data/qc_files/analysis/fastqc/concatenated_normal_XXXXXX_R_1_fastqc.zip",
"concatenated_normal_XXXXXX_R_2": "tests/test_data/qc_files/analysis/fastqc/concatenated_normal_XXXXXX_R_2_fastqc.zip",
"concatenated_tumor_XXXXXX_R_1": "tests/test_data/qc_files/analysis/fastqc/concatenated_tumor_XXXXXX_R_1_fastqc.zip"
}
}
},
"report_saved_raw_data": {
Expand Down Expand Up @@ -76,6 +84,24 @@
"READ_PAIR_DUPLICATES": 18741892.0,
"PERCENT_DUPLICATION": 0.391429
}
},
"multiqc_general_stats": {
"concatenated_tumor_XXXXXX_R_2": {
"FastQC_mqc-generalstats-fastqc-percent_duplicates": 15.03521942842923,
"FastQC_mqc-generalstats-fastqc-total_sequences": 600529762.0
},
"concatenated_normal_XXXXXX_R_1": {
"FastQC_mqc-generalstats-fastqc-percent_duplicates": 14.426654287440797,
"FastQC_mqc-generalstats-fastqc-total_sequences": 464581551.0
},
"concatenated_normal_XXXXXX_R_2": {
"FastQC_mqc-generalstats-fastqc-percent_duplicates": 14.214689357571501,
"FastQC_mqc-generalstats-fastqc-total_sequences": 464581551.0
},
"concatenated_tumor_XXXXXX_R_1": {
"FastQC_mqc-generalstats-fastqc-percent_duplicates": 15.213739762327492,
"FastQC_mqc-generalstats-fastqc-total_sequences": 600529762.0
}
}
}
}