-
Notifications
You must be signed in to change notification settings - Fork 61
Add GATK contamination check to complement VerifyBamID2 #758
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
base: dev
Are you sure you want to change the base?
Changes from all commits
083ab65
12ae427
65de844
2693819
879655b
c90b425
2bdd2c3
d1cf134
d8a2ec0
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -58,7 +58,7 @@ process { | |
| ext.args = "--TMP_DIR ." | ||
| ext.prefix = { "${meta.id}_sorted_md" } | ||
| publishDir = [ | ||
| enabled: !params.save_mapped_as_cram, | ||
| enabled: true, | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I am curious why do you want to change this? |
||
| path: { "${params.outdir}/alignment" }, | ||
| mode: params.publish_dir_mode, | ||
| saveAs: { filename -> filename.equals('versions.yml') ? null : filename } | ||
|
|
@@ -67,7 +67,7 @@ process { | |
|
|
||
| withName: '.*ALIGN:ALIGN_BWA_BWAMEM2_BWAMEME:SAMTOOLS_INDEX_MARKDUP' { | ||
| publishDir = [ | ||
| enabled: !params.save_mapped_as_cram, | ||
| enabled: true, | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. and this |
||
| path: { "${params.outdir}/alignment" }, | ||
| mode: params.publish_dir_mode, | ||
| saveAs: { filename -> filename.equals('versions.yml') ? null : filename } | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,46 @@ | ||
| /* | ||
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | ||
| Config file for GATK contamination checking modules | ||
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | ||
| */ | ||
|
|
||
| process { | ||
|
|
||
| // | ||
| // GATK GetPileupSummaries | ||
| // | ||
| withName: '.*:CONTAMINATION_CHECK:GATK4_GETPILEUPSUMMARIES' { | ||
| ext.args = '' | ||
| ext.prefix = { "${meta.id}_pileups" } | ||
| publishDir = [ | ||
| path: { "${params.outdir}/qc/contamination/pileups" }, | ||
| mode: params.publish_dir_mode, | ||
| saveAs: { filename -> filename.equals('versions.yml') ? null : filename } | ||
| ] | ||
| } | ||
|
|
||
| // | ||
| // GATK CalculateContamination | ||
| // | ||
| withName: '.*:CONTAMINATION_CHECK:GATK4_CALCULATECONTAMINATION' { | ||
| ext.args = '' | ||
| ext.prefix = { "${meta.id}_contamination" } | ||
| publishDir = [ | ||
| path: { "${params.outdir}/qc/contamination" }, | ||
| mode: params.publish_dir_mode, | ||
| saveAs: { filename -> filename.equals('versions.yml') ? null : filename } | ||
| ] | ||
| } | ||
|
|
||
| // | ||
| // Parse contamination results for MultiQC | ||
| // | ||
| withName: '.*:RAREDISEASE:PARSE_CONTAMINATION' { | ||
| ext.prefix = { "${meta.id}_contamination" } | ||
| publishDir = [ | ||
| path: { "${params.outdir}/multiqc" }, | ||
| mode: params.publish_dir_mode, | ||
| pattern: '*_mqc.tsv' | ||
| ] | ||
| } | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| name: parse_contamination | ||
| channels: | ||
| - conda-forge | ||
| - bioconda | ||
| - defaults | ||
| dependencies: | ||
| - python=3.11 |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,61 @@ | ||
| process PARSE_CONTAMINATION { | ||
| tag "$meta.id" | ||
| label 'process_single' | ||
|
|
||
| conda "${moduleDir}/environment.yml" | ||
| container "${ workflow.containerEngine == 'singularity' && !task.ext.singularity_pull_docker_container ? | ||
| 'https://depot.galaxyproject.org/singularity/python:3.11' : | ||
| 'biocontainers/python:3.11' }" | ||
|
|
||
| input: | ||
| tuple val(meta), path(contamination_table) | ||
|
|
||
| output: | ||
| tuple val(meta), path("*_contamination_mqc.tsv"), emit: mqc_table | ||
| path "versions.yml" , emit: versions | ||
|
|
||
| when: | ||
| task.ext.when == null || task.ext.when | ||
|
|
||
| script: | ||
| def prefix = task.ext.prefix ?: "${meta.id}" | ||
| """ | ||
| #!/usr/bin/env python3 | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can you make this a module binary? We have had issues in the past with some systems interpreting indents differently. |
||
|
|
||
| import csv | ||
|
|
||
| # Read GATK contamination table | ||
| with open("${contamination_table}", 'r') as f: | ||
| lines = f.readlines() | ||
| # Skip header, get contamination value | ||
| data_line = lines[1].strip().split('\\t') | ||
| sample = data_line[0] | ||
| contamination = float(data_line[1]) | ||
| contamination_pct = contamination * 100 | ||
|
|
||
| # Write MultiQC custom content file | ||
| with open("${prefix}_contamination_mqc.tsv", 'w') as out: | ||
| # Header with MultiQC configuration | ||
| out.write("# id: 'gatk_contamination'\\n") | ||
| out.write("# section_name: 'GATK Contamination'\\n") | ||
| out.write("# description: 'Sample contamination estimates from GATK CalculateContamination'\\n") | ||
| out.write("# plot_type: 'generalstats'\\n") | ||
| out.write("# pconfig:\\n") | ||
| out.write("# contamination_pct:\\n") | ||
| out.write("# title: 'Contamination'\\n") | ||
| out.write("# description: 'Estimated sample contamination percentage'\\n") | ||
| out.write("# max: 10\\n") | ||
| out.write("# min: 0\\n") | ||
| out.write("# scale: 'RdYlGn-rev'\\n") | ||
| out.write("# suffix: '%'\\n") | ||
| out.write("# format: '{:,.2f}'\\n") | ||
| # Data | ||
| out.write("Sample\\tcontamination_pct\\n") | ||
| out.write(f"${meta.id}\\t{contamination_pct:.4f}\\n") | ||
|
|
||
| # Create versions file | ||
| with open("versions.yml", 'w') as v: | ||
| v.write('"${task.process}":\\n') | ||
| v.write(' python: "3.11"\\n') | ||
| """ | ||
| } | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Also can you add a stub section? |
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,29 @@ | ||
| name: parse_contamination | ||
| description: Parse GATK CalculateContamination output for MultiQC | ||
| keywords: | ||
| - contamination | ||
| - MultiQC | ||
| - parsing | ||
| tools: | ||
| - python: | ||
| description: Python programming language | ||
| homepage: https://www.python.org/ | ||
| input: | ||
| - meta: | ||
| type: map | ||
| description: Groovy Map containing sample information | ||
| - contamination_table: | ||
| type: file | ||
| description: GATK CalculateContamination output table | ||
| pattern: "*.contamination.table" | ||
| output: | ||
| - mqc_table: | ||
| type: file | ||
| description: MultiQC custom content table | ||
| pattern: "*_contamination_mqc.tsv" | ||
| - versions: | ||
| type: file | ||
| description: File containing software versions | ||
| pattern: "versions.yml" | ||
| authors: | ||
| - "56053vujinovic" |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can add your log entries to 2.7.0dev since its the one in development. And don't forget to link the PR to your entries ;)
Also, we have a separate table for parameters and new tools under the
##Fixedsection of 2.7.0dev, so you can add that information there.