-
Notifications
You must be signed in to change notification settings - Fork 0
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
Sfitz vcf sample orders #237
Changes from 17 commits
29f12b2
689ab27
f47305f
53786f1
97a2db4
9ea2ee9
f2aac72
1bd4c83
975ab0a
6f42173
e6c037a
81728fc
279b3a5
b9a0a8b
a0fc5cc
f1ea45a
475d085
e9f60ea
6b15501
fc27ff8
20fe628
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 |
---|---|---|
|
@@ -10,6 +10,36 @@ Intersect Options: | |
- vcf2maf_extra_args: ${params.vcf2maf_extra_args} | ||
==================================== | ||
""" | ||
process reorder_samples_BCFtools { | ||
container params.docker_image_BCFtools | ||
publishDir path: "${params.workflow_output_dir}/intermediate/${task.process.split(':')[-1]}", | ||
mode: "copy", | ||
pattern: "*.vcf.gz", | ||
enabled: params.save_intermediate_files | ||
publishDir path: "${params.workflow_log_output_dir}", | ||
mode: "copy", | ||
pattern: ".command.*", | ||
saveAs: { "${task.process.split(':')[-1]}-${algorithm}/log${file(it).getName()}" } | ||
|
||
input: | ||
tuple val(algorithm), path(gzvcf) | ||
path indices | ||
val tumor_id | ||
val normal_id | ||
|
||
output: | ||
path "*-reorder.vcf.gz", emit: gzvcf | ||
path ".command.*" | ||
|
||
script: | ||
""" | ||
set -euo pipefail | ||
infile=\$(basename ${gzvcf} .vcf.gz) | ||
outfile="\${infile}-reorder.vcf.gz" | ||
bcftools view -s ${tumor_id},${normal_id} --output \${outfile} ${gzvcf} | ||
""" | ||
} | ||
|
||
process intersect_VCFs_BCFtools { | ||
container params.docker_image_BCFtools | ||
publishDir path: "${params.workflow_output_dir}/output", | ||
|
@@ -29,20 +59,20 @@ process intersect_VCFs_BCFtools { | |
saveAs: { "${task.process.split(':')[-1]}/log${file(it).getName()}" } | ||
|
||
input: | ||
path vcfs | ||
path gzvcf | ||
path indices | ||
path intersect_regions | ||
path intersect_regions_index | ||
|
||
output: | ||
path "*.vcf.gz", emit: intersect_vcf | ||
path "*.vcf.gz.tbi", emit: intersect_idx | ||
path "*.vcf.gz", emit: gzvcf | ||
path "*.vcf.gz.tbi", emit: idx | ||
path ".command.*" | ||
path "isec-2-or-more/*.txt" | ||
path "isec-1-or-more/*.txt", emit: isec | ||
|
||
script: | ||
vcf_list = vcfs.join(' ') | ||
vcf_list = gzvcf.join(' ') | ||
regions_command = params.use_intersect_regions ? "--regions-file ${intersect_regions}" : "" | ||
""" | ||
set -euo pipefail | ||
|
@@ -54,13 +84,13 @@ process intersect_VCFs_BCFtools { | |
${regions_command} \ | ||
${vcf_list} | ||
awk '/Using the following file names:/{x=1;next} x' isec-2-or-more/README.txt \ | ||
| sed 's/.vcf.gz\$/-intersect.vcf.gz/' \ | ||
| sed 's/-reorder.vcf.gz\$/-intersect.vcf.gz/' \ | ||
| while read a b c d; do | ||
mv \$a \$d | ||
mv \$a.tbi \$d.tbi | ||
done | ||
# intersect, keeping all variants, to create presence/absence list of variants in each VCF | ||
bcftools isec \ | ||
bcftools isec --nfiles +1\ | ||
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. Testing with just two tools revealed that the default behavior of bcftools isec depends on the number of vcfs being intersected. Adding |
||
--output-type z \ | ||
--prefix isec-1-or-more \ | ||
${regions_command} \ | ||
|
@@ -109,7 +139,7 @@ process concat_VCFs_BCFtools { | |
path indices | ||
|
||
output: | ||
path "*concat.vcf", emit: concat_vcf | ||
path "*concat.vcf", emit: vcf | ||
path ".command.*" | ||
|
||
script: | ||
|
@@ -146,7 +176,7 @@ process convert_VCF_vcf2maf { | |
val tumor_id | ||
|
||
output: | ||
path "*.maf", emit: concat_maf | ||
path "*.maf", emit: maf | ||
path ".command.*" | ||
|
||
script: | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,8 +3,16 @@ include { compress_file_blarchive} from './common' addParams( | |
blarchive_publishDir : "${params.workflow_output_dir}/output", | ||
blarchive_enabled : true | ||
) | ||
include { intersect_VCFs_BCFtools; plot_VennDiagram_R; concat_VCFs_BCFtools ; convert_VCF_vcf2maf } from './intersect-processes.nf' | ||
include { compress_index_VCF } from '../external/pipeline-Nextflow-module/modules/common/index_VCF_tabix/main.nf' addParams( | ||
include { reorder_samples_BCFtools; intersect_VCFs_BCFtools; plot_VennDiagram_R; concat_VCFs_BCFtools ; convert_VCF_vcf2maf } from './intersect-processes.nf' | ||
include { compress_index_VCF as compress_index_VCF_reordered } from '../external/pipeline-Nextflow-module/modules/common/index_VCF_tabix/main.nf' addParams( | ||
options: [ | ||
output_dir: params.workflow_output_dir, | ||
log_output_dir: params.workflow_log_output_dir, | ||
bgzip_extra_args: params.bgzip_extra_args, | ||
tabix_extra_args: params.tabix_extra_args, | ||
is_output_file: false | ||
]) | ||
include { compress_index_VCF as compress_index_VCF_concat } from '../external/pipeline-Nextflow-module/modules/common/index_VCF_tabix/main.nf' addParams( | ||
options: [ | ||
output_dir: params.workflow_output_dir, | ||
log_output_dir: params.workflow_log_output_dir, | ||
|
@@ -21,54 +29,73 @@ def sortVcfs(List paths) { | |
|
||
workflow intersect { | ||
take: | ||
tool_vcfs | ||
tool_gzvcfs | ||
tool_indices | ||
script_dir_ch | ||
normal_id | ||
tumor_id | ||
|
||
main: | ||
vcfs_ch = tool_vcfs | ||
tool_gzvcfs_ch = tool_gzvcfs | ||
.flatten() | ||
.map{ it -> ["${file(it).getName().split('-')[0]}", it]} | ||
tool_indices_ch = tool_indices | ||
.flatten() | ||
reorder_samples_BCFtools( | ||
tool_gzvcfs_ch, | ||
tool_indices_ch, | ||
normal_id, | ||
tumor_id | ||
) | ||
compress_index_VCF_reordered(reorder_samples_BCFtools.out.gzvcf | ||
.map{ it -> ["${file(it).getName().split('-')[0]}-SNV", it]} | ||
) | ||
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. Consider converting this tool extraction from the filename into a function since it's duplicated several times 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. done! Ready for your review @maotian06 ! |
||
gzvcfs = compress_index_VCF_reordered.out.index_out | ||
.map{ it -> it[1] } | ||
.collect() | ||
.map { sortVcfs(it) } | ||
indices = compress_index_VCF_reordered.out.index_out | ||
.map{ it -> it[2] } | ||
.collect() | ||
intersect_VCFs_BCFtools( | ||
vcfs_ch, | ||
tool_indices, | ||
gzvcfs, | ||
indices, | ||
params.intersect_regions, | ||
params.intersect_regions_index | ||
) | ||
plot_VennDiagram_R( | ||
script_dir_ch, | ||
intersect_VCFs_BCFtools.out.isec, | ||
) | ||
intersect_vcfs_ch = intersect_VCFs_BCFtools.out.intersect_vcf | ||
intersect_vcfs = intersect_VCFs_BCFtools.out.gzvcf | ||
.map { sortVcfs(it) } | ||
concat_VCFs_BCFtools( | ||
intersect_vcfs_ch, | ||
intersect_VCFs_BCFtools.out.intersect_idx | ||
intersect_vcfs, | ||
intersect_VCFs_BCFtools.out.idx | ||
) | ||
convert_VCF_vcf2maf( | ||
concat_VCFs_BCFtools.out.concat_vcf, | ||
concat_VCFs_BCFtools.out.vcf, | ||
params.reference, | ||
normal_id, | ||
tumor_id | ||
) | ||
compress_index_VCF(concat_VCFs_BCFtools.out.concat_vcf | ||
compress_index_VCF_concat(concat_VCFs_BCFtools.out.vcf | ||
.map{ it -> ['SNV', it]} | ||
) | ||
compress_file_blarchive(convert_VCF_vcf2maf.out.concat_maf | ||
compress_file_blarchive(convert_VCF_vcf2maf.out.maf | ||
.map{ it -> ['MAF', it]} | ||
) | ||
file_for_sha512 = intersect_VCFs_BCFtools.out.intersect_vcf | ||
file_for_sha512 = intersect_VCFs_BCFtools.out.gzvcf | ||
.flatten() | ||
.map{ it -> ["${file(it).getName().split('_')[0]}-SNV-vcf", it]} | ||
.mix(intersect_VCFs_BCFtools.out.intersect_idx | ||
.map{ it -> ["${file(it).getName().split('-')[0]}-vcf", it]} | ||
.mix(intersect_VCFs_BCFtools.out.idx | ||
.flatten() | ||
.map{ it -> ["${file(it).getName().split('_')[0]}-SNV-idx", it]} | ||
.map{ it -> ["${file(it).getName().split('-')[0]}-idx", it]} | ||
) | ||
.mix(compress_index_VCF.out.index_out | ||
.mix(compress_index_VCF_concat.out.index_out | ||
.map{ it -> ["concat-${it[0]}-vcf", it[1]] } | ||
) | ||
.mix(compress_index_VCF.out.index_out | ||
.mix(compress_index_VCF_concat.out.index_out | ||
.map{ it -> ["concat-${it[0]}-index", it[2]] } | ||
) | ||
.mix(compress_file_blarchive.out.compressed_file | ||
|
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.
Updating these names as I had failed to make them reflect the status of the compression and the channel (vs list), improving readability.