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

SV Liftover Code #240

Open
wants to merge 26 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
a8e6eff
Add output saving keys for gSV, sSV, gSNP
yashpatel6 Jan 28, 2025
7f7c9e9
Update call-gSV to always run in workflow
yashpatel6 Jan 28, 2025
e0fc4af
Update gSV workflow to identify outputs and handle run when gSV not e…
yashpatel6 Jan 28, 2025
e81da93
Update gSV runner to output output directory
yashpatel6 Jan 28, 2025
3b11f59
Output sample ID from YAML creation for gSV
yashpatel6 Jan 28, 2025
72f251c
Update StableLift to liftover only Delly and not Manta gSV
yashpatel6 Jan 28, 2025
9b5d823
Add output identification workflow for call-gSV
yashpatel6 Jan 28, 2025
fe374e3
Add option to schema
yashpatel6 Jan 29, 2025
ccf0a7f
Update pipeline selector with gSV option
yashpatel6 Jan 29, 2025
77bfb9b
Update to check for gSV output for liftover
yashpatel6 Jan 29, 2025
68e722a
Add output identification info to call-sSV runner
yashpatel6 Jan 30, 2025
f562735
Add sSV to schema
yashpatel6 Jan 30, 2025
52e0a8c
Add sSV to selector and update logic for enabling StableLift
yashpatel6 Jan 30, 2025
eabe899
Add sSV as precursor to StableLift
yashpatel6 Jan 30, 2025
9469655
Filter out Manta-sSV
yashpatel6 Jan 30, 2025
9fa79d1
Fix syntax
yashpatel6 Jan 30, 2025
bafb796
Update YAML creation to output ID
yashpatel6 Jan 30, 2025
df124e5
Add output identification for call-sSV
yashpatel6 Jan 30, 2025
8fe2cf9
Update workflow to identify outputs
yashpatel6 Jan 30, 2025
7e3e2b6
Use .bcf format for DELLY
yashpatel6 Jan 30, 2025
ef0b324
Update comment
yashpatel6 Jan 31, 2025
6e3ca17
Fix channel mixing
yashpatel6 Jan 31, 2025
591b279
Update SV output detection to look for VCFs
yashpatel6 Jan 31, 2025
9261240
Disable selection of SV liftover
yashpatel6 Jan 31, 2025
4f13fe4
Update CHANGELOG
yashpatel6 Jan 31, 2025
3aab0e4
Disable looking for VCF Delly output for now
yashpatel6 Jan 31, 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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm
### Added

- StableLift for sSNV liftover
- StableLift for SV liftover

## [6.2.0] - 2024-11-22

Expand Down
5 changes: 4 additions & 1 deletion config/input_handler.config
Original file line number Diff line number Diff line change
Expand Up @@ -327,7 +327,10 @@ input_handler {
'call-sCNA': [:],
'recalibrate-BAM': ['BAM':'', 'contamination_table':''],
'calculate-targeted-coverage': ['expanded-intervals': ''],
'convert-BAM2FASTQ': []
'convert-BAM2FASTQ': [],
'call-gSV': [:],
'call-sSV': [:],
'call-gSNP': [:]
];

return default_data_map;
Expand Down
19 changes: 10 additions & 9 deletions config/pipeline_selector.config
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,9 @@ pipeline_selector {
'call-sSV': ['recalibrate-BAM'],
'call-sCNA': ['recalibrate-BAM'],
'call-SRC': ['call-sSNV', 'call-sCNA'],
'StableLiftsSNV': ['call-sSNV']
'StableLiftsSNV': ['call-sSNV'],
'StableLiftgSV': ['call-gSV'],
'StableLiftsSV': ['call-sSV']
]

if (input_type == 'BAM') {
Expand Down Expand Up @@ -137,22 +139,21 @@ pipeline_selector {
'call_sSV': 'call-sSV',
'call_sCNA': 'call-sCNA',
'call_SRC': 'call-SRC',
'StableLift': 'StableLiftsSNV'
'StableLift': ['StableLiftsSNV', 'StableLiftgSV', 'StableLiftsSV']
];

pipeline_name_map.each { pipeline_key, pipeline ->
if (!params.pipeline_params.containsKey(pipeline_key)) {
params.pipeline_params[pipeline_key] = ['is_pipeline_enabled': false];
}

params.pipeline_params[pipeline_key].is_pipeline_enabled = pipelines.contains(pipeline);
if (pipeline_key == 'StableLift') {
List requested_liftovers = pipeline.findAll{ element -> pipelines.contains(element) };

if (pipeline_key == 'StableLift' && pipelines.contains(pipeline)) {
if (!params.pipeline_params[pipeline_key].containsKey('lift_modes')) {
params.pipeline_params[pipeline_key]['lift_modes'] = []
}

params.pipeline_params[pipeline_key]['lift_modes'] << pipeline
params.pipeline_params[pipeline_key]['is_pipeline_enabled'] = (requested_liftovers) ? true : false;
params.pipeline_params[pipeline_key]['lift_modes'] = (requested_liftovers) ?: [];
} else {
params.pipeline_params[pipeline_key].is_pipeline_enabled = pipelines.contains(pipeline);
}
}
}
Expand Down
2 changes: 2 additions & 0 deletions config/schema.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,8 @@ requested_pipelines:
- call-sCNA
- call-SRC
- StableLiftsSNV
# - StableLiftgSV
# - StableLiftsSV
help: 'List of pipelines to run'
override_realignment:
type: 'Bool'
Expand Down
2 changes: 1 addition & 1 deletion config/template.config
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ params {

sample_mode = 'paired' // Choose from: 'single', 'paired', 'multi'

// Select pipeline(s) to run. Choices: 'align-DNA', 'recalibrate-BAM', 'generate-SQC-BAM', 'calculate-targeted-coverage', 'call-gSNP', 'call-mtSNV', 'call-sSNV', 'call-sSV', 'call-gSV', 'call-sCNA', 'StableLiftsSNV'
// Select pipeline(s) to run. Choices: 'align-DNA', 'recalibrate-BAM', 'generate-SQC-BAM', 'calculate-targeted-coverage', 'call-gSNP', 'call-mtSNV', 'call-sSNV', 'call-sSV', 'call-gSV', 'call-sCNA', 'StableLiftsSNV', 'StableLiftsSV', 'StableLiftgSV'
requested_pipelines = ['align-DNA', 'recalibrate-BAM', 'generate-SQC-BAM', 'call-gSNP', 'call-mtSNV', 'call-sSNV', 'call-sSV', 'call-gSV', 'call-sCNA']

// Override conversion to FASTQ and re-alignment with BAM input
Expand Down
8 changes: 4 additions & 4 deletions module/StableLift/workflow.nf
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,13 @@ workflow stable_lift {
.map{ it ->
def samples = [];
params.sample_data.each { s, s_data ->
if (s_data.state == 'normal') {
return;
}
params.StableLift.lift_modes.each { raw_mode ->
def mode = raw_mode.replace('StableLift', '');
if (!s_data.containsKey("call-${mode}" as String)) {
return;
}
s_data["call-${mode}"].each { tool, data ->
if (tool == 'BCFtools-Intersect') {
if (['BCFtools-Intersect', 'Manta-gSV', 'Manta-sSV'].contains(tool)) {
return;
}
samples.add([
Expand Down
2 changes: 1 addition & 1 deletion module/call_gSV/create_YAML_call_gSV.nf
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ process create_YAML_call_gSV {
)

output:
path(input_yaml), emit: call_gsv_yaml
tuple val(sample_id), path(input_yaml), emit: call_gsv_yaml

exec:
input_yaml = "call_gSV_input.yaml"
Expand Down
42 changes: 42 additions & 0 deletions module/call_gSV/identify_outputs.nf
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
include { identify_file } from '../common'
include { sanitize_string } from '../../external/pipeline-Nextflow-module/modules/common/generate_standardized_filename/main.nf'

workflow identify_call_gsv_outputs {
take:
och_call_gsv

main:
och_call_gsv.map{ call_gsv_out ->
def raw_sample_id = call_gsv_out[0];
def sample_id = sanitize_string(raw_sample_id);
def gsv_output_dir = new File(call_gsv_out[1].toString());
def gsv_output_pattern = /(.*)-([\d\.]*)$/;

def output_info = [
'Manta': ['Manta-gSV', "Manta-*${sample_id}*candidateSV.vcf.gz"],
// 'DELLY': ['Delly2-gSV', "DELLY-*${sample_id}*gSV.vcf.gz"]
]

def outputs_to_check = [];
def match = null;

gsv_output_dir.eachFile { file ->
match = (file.name =~ gsv_output_pattern);
if (match) {
outputs_to_check << [match[0][1], file.name];
}
}

outputs_to_check.each { output_tool, output_dir_name ->
params.sample_data[raw_sample_id]['call-gSV'][output_info[output_tool][0]] = identify_file("${gsv_output_dir}/${output_dir_name}/output/${output_info[output_tool][1]}");
}

return 'done';
}
.collect()
.map{ 'done' }
.set{ och_call_gsv_identified }

emit:
och_call_gsv_identified = och_call_gsv_identified
}
4 changes: 3 additions & 1 deletion module/call_gSV/run_call_gSV.nf
Original file line number Diff line number Diff line change
Expand Up @@ -25,15 +25,17 @@ process run_call_gSV {
pattern: "call-gSV-*/*"

input:
path(input_yaml)
tuple val(sample_id), path(input_yaml)

output:
tuple val(sample_id), path(output_directory), emit: identify_call_gsv_out, optional: true
path "call-gSV-*/*", optional: true
path ".command.*"
val('done'), emit: complete
env EXIT_CODE, emit: exit_code

script:
output_directory = "call-gSV-*/${sample_id}"
String params_to_dump = combine_input_with_params(params.call_gSV.metapipeline_arg_map, new File(input_yaml.toRealPath().toString()))
String setup_commands = generate_graceful_error_controller(task.ext)
String weblog_args = generate_weblog_args()
Expand Down
120 changes: 70 additions & 50 deletions module/call_gSV/workflow.nf
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
include { create_YAML_call_gSV } from "${moduleDir}/create_YAML_call_gSV"
include { run_call_gSV } from "${moduleDir}/run_call_gSV" addParams( log_output_dir: params.metapipeline_log_output_dir )
include { mark_pipeline_complete; mark_pipeline_exit_code } from "../pipeline_status"
include { identify_call_gsv_outputs } from "./identify_outputs"

/*
* Main workflow for calling the call-gSV pipeline
Expand All @@ -16,60 +17,79 @@ workflow call_gSV {
take:
modification_signal
main:
// Watch for pipeline ordering
Channel.watchPath( "${params.pipeline_status_directory}/*.ready" )
.until{ it -> it.name == "${params.this_pipeline}.ready" }
.ifEmpty('done')
.collect()
.map{ 'done' }
.set{ pipeline_predecessor_complete }
if (!params.call_gSV.is_pipeline_enabled) {
modification_signal.until{ it == 'done' }.ifEmpty('done')
.map{ it ->
mark_pipeline_complete(params.this_pipeline);
mark_pipeline_exit_code(params.this_pipeline, 0);
return 'done';
}
.set{ completion_signal }
} else {
// Watch for pipeline ordering
Channel.watchPath( "${params.pipeline_status_directory}/*.ready" )
.until{ it -> it.name == "${params.this_pipeline}.ready" }
.ifEmpty('done')
.collect()
.map{ 'done' }
.set{ pipeline_predecessor_complete }

// Extract inputs from data structure
modification_signal.until{ it == 'done' }.ifEmpty('done')
.mix(pipeline_predecessor_complete)
.collect()
.map{ it ->
def samples = [];
params.sample_data.each { s, s_data ->
samples.add(['patient': s_data['patient'], 'sample': s, 'state': s_data['state'], 'bam': s_data['recalibrate-BAM']['BAM']]);
};
return samples
}
.flatten()
.reduce(['normal': [] as Set, 'tumor': [] as Set]) { a, b ->
a[b.state] += b;
return a
}
.set{ ich }
// Extract inputs from data structure
modification_signal.until{ it == 'done' }.ifEmpty('done')
.mix(pipeline_predecessor_complete)
.collect()
.map{ it ->
def samples = [];
params.sample_data.each { s, s_data ->
samples.add(['patient': s_data['patient'], 'sample': s, 'state': s_data['state'], 'bam': s_data['recalibrate-BAM']['BAM']]);
};
return samples
}
.flatten()
.reduce(['normal': [] as Set, 'tumor': [] as Set]) { a, b ->
a[b.state] += b;
return a
}
.set{ ich }

ich
.map{ it -> it.normal }
.flatten()
.unique{ [it.patient, it.sample, it.state] }
.map{ it -> [params.patient, it['sample'], it['bam']] }
.set{ input_ch_create_YAML }
ich
.map{ it -> it.normal }
.flatten()
.unique{ [it.patient, it.sample, it.state] }
.map{ it -> [params.patient, it['sample'], it['bam']] }
.set{ input_ch_create_YAML }

create_YAML_call_gSV(input_ch_create_YAML)
create_YAML_call_gSV(input_ch_create_YAML)

run_call_gSV(create_YAML_call_gSV.out.call_gsv_yaml)
run_call_gSV(create_YAML_call_gSV.out.call_gsv_yaml)

run_call_gSV.out.complete
.mix( pipeline_predecessor_complete )
.collect()
.map{ it ->
mark_pipeline_complete(params.this_pipeline);
return 'done';
}
.mix(
run_call_gSV.out.exit_code
.map{ it -> (it as Integer) }
.sum()
.map { exit_code ->
mark_pipeline_exit_code(params.this_pipeline, exit_code);
return 'done';
}
identify_call_gsv_outputs(
modification_signal.until{ it == 'done' }
.mix( run_call_gSV.out.identify_call_gsv_out )
)
.collect()
.map { it -> return 'done'; }
.set{ completion_signal }

run_call_gSV.out.complete
.mix( identify_call_gsv_outputs.out.och_call_gsv_identified )
.mix( pipeline_predecessor_complete )
.collect()
.map{ it ->
mark_pipeline_complete(params.this_pipeline);
return 'done';
}
.mix(
run_call_gSV.out.exit_code
.map{ it -> (it as Integer) }
.sum()
.map { exit_code ->
mark_pipeline_exit_code(params.this_pipeline, exit_code);
return 'done';
}
)
.collect()
.map { it -> return 'done'; }
.set{ completion_signal }
}

emit:
completion_signal = completion_signal
}
2 changes: 1 addition & 1 deletion module/call_sSV/create_YAML_call_sSV.nf
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ process create_YAML_call_sSV {
)

output:
path(input_yaml)
tuple val(tumor_id), path(input_yaml)

exec:
input_yaml = 'call_sSV_input.yaml'
Expand Down
42 changes: 42 additions & 0 deletions module/call_sSV/identify_outputs.nf
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
include { identify_file } from '../common'
include { sanitize_string } from '../../external/pipeline-Nextflow-module/modules/common/generate_standardized_filename/main.nf'

workflow identify_call_ssv_outputs {
take:
och_call_ssv

main:
och_call_ssv.map{ call_ssv_out ->
def raw_sample_id = call_ssv_out[0];
def sample_id = sanitize_string(raw_sample_id);
def ssv_output_dir = new File(call_ssv_out[1].toString());
def ssv_output_pattern = /(.*)-([\d\.]*)$/;

def output_info = [
'Manta': ['Manta-sSV', "Manta-*${sample_id}*candidateSV.vcf.gz"],
// 'DELLY': ['Delly2-sSV', "DELLY-*${sample_id}.vcf.gz"]
]

def outputs_to_check = [];
def match = null;

ssv_output_dir.eachFile { file ->
match = (file.name =~ ssv_output_pattern);
if (match) {
outputs_to_check << [match[0][1], file.name];
}
}

outputs_to_check.each { output_tool, output_dir_name ->
params.sample_data[raw_sample_id]['call-sSV'][output_info[output_tool][0]] = identify_file("${ssv_output_dir}/${output_dir_name}/output/${output_info[output_tool][1]}");
}

return 'done';
}
.collect()
.map{ 'done' }
.set{ och_call_ssv_identified }

emit:
och_call_ssv_identified = och_call_ssv_identified
}
4 changes: 3 additions & 1 deletion module/call_sSV/run_call_sSV.nf
Original file line number Diff line number Diff line change
Expand Up @@ -25,15 +25,17 @@ process run_call_sSV {
saveAs: { "${task.process.replace(':', '/')}-${task.index}/log${file(it).getName()}" }

input:
path(input_yaml)
tuple val(sample_id), path(input_yaml)

output:
tuple val(sample_id), path(output_directory), emit: identify_call_ssv_out, optional: true
path "call-sSV-*/*", optional: true
path ".command.*"
val('done'), emit: complete
env EXIT_CODE, emit: exit_code

script:
output_directory = "call-sSV-*/${sample_id}"
String params_to_dump = combine_input_with_params(params.call_sSV.metapipeline_arg_map, new File(input_yaml.toRealPath().toString()))
String setup_commands = generate_graceful_error_controller(task.ext)
String weblog_args = generate_weblog_args()
Expand Down
Loading
Loading