I was trying to use plink in nextflow. My first process will split the input (single bed|bim|fam file) into 22 chromosomes (each with bed|bim|fam files) which would be used in subsequent processes. My code and error log is below. Any help?
params.dir='data/'
params.publish="output2/"
Channel
.fromFilePairs("${params.dir}*.{bed,bim,fam}",size:3)
.set {data}
Channel
.of(1..22)
.set {chr_names}
process step1a {
publishDir params.publish
input:
tuple val(sample_name), path(bfiles) from data
output:
tuple val("${prefix}"), path("${prefix}.step1a.{bed,bim,fam}") into step1a_results
tuple val("${prefix}"), path("${prefix}.step1b.{bed,bim,fam}") into step1a_out
tuple val("${prefix}"), path("${prefix}.step1b.bim") into step1a_bims
path("${prefix}.log") into step1a_logs
path("${prefix}.step1a.dupvar") into step1a_duplicates
path("${prefix}.step1a.log") into step1a_log
path("${prefix}.step1b.log") into step1_log
script:
prefix=chr"${chr_names}"
"""
plink --bfile "${sample_name}" --chr "${chr_names}" --out "${prefix}" --make-bed
plink --bfile "${prefix}" --list-duplicate-vars ids-only suppress-first --out "${prefix}.step1a"
plink --bfile "${prefix}" --exclude "${prefix}.step1a.dupvar" --make-bed --out "${prefix}.step1a"
plink --bfile "${prefix}.step1a" --snps-only just-acgt --make-bed --out "${prefix}.step1b"
"""
}
process step1b {
publishDir params.publish
input:
tuple val(sample_name), path(bfiles) from step1a_out
tuple val(bims), path("${prefix}.step1b.bim") from step1a_bims
output:
tuple val("${sample_name}"), path("${sample_name}.step1c.{bed,bim,fam}") into step1b_results
path("${sample_name}.step1c.log") into step1b_logs
path("${sample_name}.step1b.snplist.txt") into step1b_snplist
script:
"""
awk '{ if ((\\\$5=="T" && \\\$6=="A")||(\\\$5=="A" && \\\$6=="T")||(\\\$5=="C" && \\\$6=="G")||(\\\$5=="G" && \\\$6=="C")) print \\\$2, "ambig" ; else print \\\$2 ;}' "${prefix}.step1b.bim" | grep ambig > "${prefix}.step1b.snplist.txt"
plink --bfile "${prefix}.step1b --exclude "${prefix}.step1b.snplist.txt" --make-bed --out "${prefix}.step1c"
"""
}
The error message is:
N E X T F L O W ~ version 20.10.0
Launching `t4.hf` [zen_picasso] - revision: b0ff8db413
[- ] process > step1a -
[- ] process > step1b -
Error executing process > 'step1a (1)'
Caused by:
[- ] process > step1a -
[- ] process > step1b -
Error executing process > 'step1a (1)'
Caused by:
No signature of method: chr() is applicable for argument types: (org.codehaus.groovy.runtime.GStringImpl) values: [DataflowQueue(queue=[DataflowVariable(value=1), DataflowVariable(value=2), DataflowVariable(value=3), DataflowVariable(value=4), DataflowVariable(value=5), DataflowVariable(value=6), DataflowVariable(value=7), DataflowVariable(value=8), DataflowVariable(value=9), DataflowVariable(value=10), DataflowVariable(value=11), DataflowVariable(value=12), DataflowVariable(value=13), DataflowVariable(value=14), DataflowVariable(value=15), DataflowVariable(value=16), DataflowVariable(value=17), DataflowVariable(value=18), DataflowVariable(value=19), DataflowVariable(value=20), DataflowVariable(value=21), DataflowVariable(value=22), DataflowVariable(value=groovyx.gpars.dataflow.operator.PoisonPill@28c22659)])]
Possible solutions: run(), run(), any(), is(java.lang.Object), use([Ljava.lang.Object;), tap(groovy.lang.Closure)
Source block:
prefix=chr"${chr_names}"
"""
plink --bfile "${sample_name}" --chr "${chr_names}" --out "${prefix}" --make-bed
plink --bfile "${prefix}" --list-duplicate-vars ids-only suppress-first --out "${prefix}.step1a"
plink --bfile "${prefix}" --exclude "${prefix}.step1a.dupvar" --make-bed --out "${prefix}.step1a"
plink --bfile "${prefix}.step1a" --snps-only just-acgt --make-bed --out "${prefix}.step1b"
"""
Tip: when you have fixed the problem you can continue the execution adding the option `-resume` to the run command line
If I use "prefix=chr"${chr_names}" " inside the code block (""") it shows: unknown variable 'prefix'