Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
92afcd0
Merge branch 'master' of github.com:Clinical-Genomics/BALSAMIC
mathiasbio Nov 21, 2024
67c6701
Merge branch 'master' into develop
mathiasbio Nov 21, 2024
fdac88e
feat: add sex check (#1516)
mathiasbio Jan 23, 2025
36c2c56
feat: add option to disable normal hardfilter (#1509)
mathiasbio Jan 31, 2025
44dfdb9
fix: remove tga whole genome gcbias metric (#1521)
mathiasbio Feb 4, 2025
0d3afc8
fix: create tnscope mnvs (#1524)
mathiasbio Feb 7, 2025
012345c
merge master
mathiasbio Feb 10, 2025
22323f9
fix: lower required threads for annotation rules (#1528)
mathiasbio Feb 14, 2025
e0459b8
fix: merge snv variants script (#1499)
mathiasbio Feb 14, 2025
5f234df
fix: vardict errors (#1537)
mathiasbio Feb 18, 2025
cfc2ae5
fix: somalier container (#1538)
mathiasbio Feb 18, 2025
1d73f3d
feat: small updates oncogenic, dux4 and QC thresholds (#1527)
mathiasbio Feb 18, 2025
0ec90f1
feat: add SOR filter to WGS TN (#1506)
mathiasbio Feb 18, 2025
fef4bf0
feat: add mem option (#1535)
fevac Feb 20, 2025
5f98732
feat: disable sv calling in tnscope (#1541)
fevac Feb 28, 2025
edf3743
feat: tscope tga update filters and settings (#1526)
mathiasbio Mar 3, 2025
c8e9bda
changelog
mathiasbio Mar 3, 2025
a70c8c4
fix: remove vardict parallelization per chrom (#1544)
mathiasbio Mar 5, 2025
7383390
Merge branch 'release_v17.0.0' of github.com:Clinical-Genomics/BALSAM…
mathiasbio Mar 5, 2025
07e35e4
fix bug in memory allocation
mathiasbio Mar 5, 2025
eb685f1
feat: Add clinvarID to VCF (#1547)
mathiasbio Mar 7, 2025
28eb344
Merge branch 'release_v17.0.0' of github.com:Clinical-Genomics/BALSAM…
mathiasbio Mar 11, 2025
f6d5de5
Merge branch 'master' of github.com:Clinical-Genomics/BALSAMIC
mathiasbio Mar 11, 2025
fac859a
merge master
mathiasbio Mar 11, 2025
baa2e84
fix: tumor qc threshold wgs (#1555)
mathiasbio Mar 19, 2025
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
40 changes: 39 additions & 1 deletion BALSAMIC/assets/scripts/collect_qc_metrics.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,17 @@
@click.argument("output_path", type=click.Path(exists=False), required=True)
@click.argument("multiqc_data_path", type=click.Path(exists=True), required=True)
@click.argument("counts_path", nargs=-1, type=click.Path(exists=True), required=False)
@click.option(
"--sex-prediction-path",
type=click.Path(exists=True),
required=False,
help="Path to sex prediction json (optional for balsamic-qc)",
)
def collect_qc_metrics(
config_path: Path,
output_path: Path,
multiqc_data_path: Path,
sex_prediction_path: Path,
counts_path: List[Path],
):
"""Extracts the requested metrics from a JSON multiqc file and saves them to a YAML file
Expand All @@ -37,6 +44,7 @@ def collect_qc_metrics(
config_path: Path; case config file path
output_path: Path; destination path for the extracted YAML formatted metrics
multiqc_data_path: Path; multiqc JSON path from which the metrics will be extracted
sex_prediction_path: Path; sex prediction JSON path from which sex prediction info will be extracted
counts_path: Path; list of variant caller specific files containing the number of variants
"""

Expand All @@ -50,6 +58,10 @@ def collect_qc_metrics(
for count in counts_path:
metrics += get_variant_metrics(count)

# Sex check
if sex_prediction_path:
metrics += get_sex_check_metrics(sex_prediction_path, config)

# Relatedness
analysis_type = get_analysis_type(config)
if analysis_type == "paired" and "Somalier" in multiqc_data["report_data_sources"]:
Expand Down Expand Up @@ -108,6 +120,32 @@ def get_multiqc_data_source(multiqc_data: dict, sample: str, tool: str) -> str:
)


def get_sex_check_metrics(sex_prediction_path: str, config: dict) -> list:
"""Retrieves the sex check metrics and returns them as a Metric list."""
metric = "compare_predicted_to_given_sex"
case_id: str = config["analysis"]["case_id"]
sex_prediction: dict = read_json(sex_prediction_path)

given_sex: str = config["analysis"]["gender"]

sex_check_metrics = []

for sample_type in ["tumor", "normal"]:
if sample_type in sex_prediction:
predicted_sex = sex_prediction[sample_type]["predicted_sex"]
sex_prediction_metrics = Metric(
id=f"{case_id}_{sample_type}",
input=os.path.basename(sex_prediction_path),
name=metric.upper(),
step="sex_check",
value=predicted_sex,
condition={"norm": "eq", "threshold": given_sex},
).model_dump()
sex_check_metrics.append(sex_prediction_metrics)

return sex_check_metrics


def get_relatedness_metrics(multiqc_data: dict) -> list:
"""Retrieves the relatedness metrics and returns them as a Metric list."""
source_tool = "Somalier"
Expand Down Expand Up @@ -186,7 +224,7 @@ def get_metric_condition(
req_metrics = requested_metrics[metric]["condition"]
if sequencing_type == "wgs" and (
(metric == "PCT_60X" and sample_type == "normal")
or (metric == "PCT_15X" and sample_type == "tumor")
or (metric == "MEDIAN_COVERAGE" and sample_type == "tumor")
):
req_metrics = None

Expand Down
2 changes: 1 addition & 1 deletion BALSAMIC/assets/scripts/edit_vcf_info.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ def edit_vcf_info(input_vcf, output_vcf, variant_caller):

with open(output_vcf, "wb"):
for variant in vcf:
variant.INFO["FOUND_IN"] = variant_caller + "|" + output_vcf
variant.INFO["FOUND_IN"] = variant_caller
new_vcf.write_record(variant)
new_vcf.close()
vcf.close()
Expand Down
6 changes: 3 additions & 3 deletions BALSAMIC/assets/scripts/igh_dux4_detection.sh
Original file line number Diff line number Diff line change
Expand Up @@ -55,11 +55,11 @@ get_supporting_reads() {
# Set information for tumor and normal
supporting_reads_tumor=$(get_supporting_reads $tumor_bam)
samples_header="TUMOR"
samples_field="${supporting_reads_tumor}"
samples_field="0/1:${supporting_reads_tumor}"
if [ -n "$normal_bam" ]; then
supporting_reads_normal=$(get_supporting_reads $normal_bam)
samples_header="NORMAL\tTUMOR"
samples_field="${supporting_reads_normal}\t${supporting_reads_tumor}"
samples_field="0/0:${supporting_reads_normal}\t0/1:${supporting_reads_tumor}"
fi


Expand All @@ -82,7 +82,7 @@ echo "vcf filter: $vcf_filter"
echo '##INFO=<ID=IMPRECISE,Number=0,Type=Flag,Description="Imprecise structural variation">'
echo '##FORMAT=<ID=DV,Number=1,Type=Integer,Description="Number of paired-ends that support the event">'
echo -e "#CHROM\tPOS\tID\tREF\tALT\tQUAL\tFILTER\tINFO\tFORMAT\t${samples_header}"
echo -e "${igh_chr}\t${igh_pos}\tsamtools_igh_dux4\tN\tN[${dux4_chr}:${dux4_pos}[\t.\t${vcf_filter}\tSVTYPE=BND;IMPRECISE;\tDV\t${samples_field}"
echo -e "${igh_chr}\t${igh_pos}\tsamtools_igh_dux4\tN\tN[${dux4_chr}:${dux4_pos}[\t.\t${vcf_filter}\tSVTYPE=BND;IMPRECISE;\tGT:DV\t${samples_field}"
} >> $output_vcf_tmp

bgzip $output_vcf_tmp
Expand Down
Loading
Loading