Channel names must consist only alphanumeric characters including underscores. Your channel called 'plink-data' contains a hyphen. This is problematic because it is interpreted as a minus() operation to remove 'data' from 'plink'. You get a NullPointerException since 'plink' hasn't been defined. You can test this easily with the following example:
Channel
.of(1..23, 'X', 'Y')
.set { chr-names }
chr-names.view()
Results:
Cannot invoke method minus() on null object
The solution is to just use an underscore instead of a hyphen:
Channel
.of(1..23, 'X', 'Y')
.set { chr_names }
chr_names.view()
Follow-up issues:
I think if you want to use the bfiles plink option (and I think this is reasonable), I think it makes the most sense to just keep your bfiles in a tuple:
Channel
.fromFilePairs( "${params.input_dir}/*.{bed,bim,fam}", size: 3 )
.set { plink_data }
process test1{
publishDir params.publish_dir
module 'plink'
input:
tuple val(sample_name), path(bfiles) from plink_data
output:
tuple val("${sample_name}-t1"), path("${sample_name}-t1.{bed,bim,fam}") into test1_results
"""
plink \\
--bfile "${sample_name}" \\
--maf 0.05 \\
--make-bed \\
--out "${sample_name}-t1"
"""
}
process test2{
publishDir params.publish_dir
module 'plink'
input:
tuple val(sample_name), path(bfiles) from test1_results
output:
tuple val("${sample_name}-t2"), path("${sample_name}-t2.{bed,bim,fam}") into test2_results
"""
plink \\
--bfile "${sample_name}" \\
--maf 0.01 \\
--make-bed \\
--out "${sample_name}-t2"
"""
}
If you need to reference each bfile separately, you could just unpack the tuple and reference each file accordingly:
Channel
.fromFilePairs( "${params.input_dir}/*.{bed,bim,fam}", size: 3 )
.map { group_key, files -> tuple( group_key, *files ) }
.set { plink_data }
process test1{
publishDir params.publish_dir
module 'plink'
input:
tuple val(sample_name), path(bed), path(bim), path(fam) from plink_data
output:
tuple val("${sample_name}-t1"), path("${sample_name}-t1.{bed,bim,fam}") into test1_results
"""
plink \\
--bed "${bed}" \\
--bim "${bim}" \\
--fam "${fam}" \\
--maf 0.05 \\
--make-bed \\
--out "${sample_name}-t1"
"""
}
process test2{
publishDir params.publish_dir
module 'plink'
input:
tuple val(sample_name), path(bed), path(bim), path(fam) from test1_results
output:
tuple val("${sample_name}-t2"), path("${sample_name}-t2.{bed,bim,fam}") into test2_results
"""
plink \\
--bed "${bed}" \\
--bim "${bim}" \\
--fam "${fam}" \\
--maf 0.01 \\
--make-bed \\
--out "${sample_name}-t2"
"""
}
Note that in the first example, bfiles
could be replaced with "*"
since no reference is made to the tuple of bfiles anyway. Also note that the list of files produced using the fromFilesPairs operator are returned in lexicographic order.