我有一个 nextflow 脚本,它在单个 vcf 文件上运行几个进程。文件名为“bos_taurus.vcf”,位于目录/input_files/bos_taurus.vcf 中。目录 input_files/还包含另一个文件“sacharomyces_cerevisea.vcf”。我希望我的 nextflow 脚本能够处理这两个文件。我试图使用像 ch_1 = channel.fromPath("/input_files/*.vcf") 这样的 glob 模式,但遗憾的是我找不到可行的解决方案。非常感谢任何帮助。
#!/usr/bin/env nextflow
nextflow.enable.dsl=2
// here I tried to use globbing
params.input_files = "/mnt/c/Users/Lenovo/Desktop/STUDIA/BIOINFORMATYKA/SEMESTR_V/PRACOWNIA_INFORMATYCZNA/nextflow/projekt/input_files/*.vcf"
params.results_dir = "/mnt/c/Users/Lenovo/Desktop/STUDIA/BIOINFORMATYKA/SEMESTR_V/PRACOWNIA_INFORMATYCZNA/nextflow/projekt/results"
file_channel = Channel.fromPath( params.input_files, checkIfExists: true )
// how can I make this process work on two files simultanously
process FILTERING {
publishDir("${params.results_dir}/after_filtering", mode: 'copy')
input:
path(input_files)
output:
path("*")
script:
"""
vcftools --vcf ${input_files} --mac 1 --minQ 20 --recode --recode-INFO-all --out after_filtering.vcf
"""
}
最佳答案
请注意,如果您的 VCF 文件实际上是 bgzip压缩和tabix索引,您可以改为使用 fromFilePairs工厂方法来创建你的输入 channel 。例如:
params.vcf_files = "./input_files/*.vcf.gz{,.tbi}"
params.results_dir = "./results"
process FILTERING {
tag { sample }
publishDir("${params.results_dir}/after_filtering", mode: 'copy')
input:
tuple val(sample), path(indexed_vcf)
output:
tuple val(sample), path("${sample}.filtered.vcf")
"""
vcftools \\
--vcf "${indexed_vcf.first()}" \\
--mac 1 \\
--minQ 20 \\
--recode \\
--recode-INFO-all \\
--out "${sample}.filtered.vcf"
"""
}
workflow {
vcf_files = Channel.fromFilePairs( params.vcf_files, checkIfExists: true )
FILTERING( vcf_files ).view()
}
结果:
$ nextflow run main.nf
N E X T F L O W ~ version 22.10.0
Launching `main.nf` [thirsty_torricelli] DSL2 - revision: 8f69ad5638
executor > local (3)
[7d/dacad6] process > FILTERING (C) [100%] 3 of 3 ✔
[A, /path/to/work/84/f9f00097bcd2b012d3a5e105b9d828/A.filtered.vcf]
[B, /path/to/work/cb/9f6f78213f0943013990d30dbb9337/B.filtered.vcf]
[C, /path/to/work/7d/dacad693f06025a6301c33fd03157b/C.filtered.vcf]
请注意 BCFtools得到积极维护,旨在替代 VCFtools。在生产流水线中,BCFtools 应该是首选。
关于groovy - 用于处理给定目录中所有文件的 Nextflow 脚本,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/75177038/