NBISweden / workshop-reproducible-research

NBIS/Elixir course: Tools for Reproducible Research
https://nbisweden.github.io/workshop-reproducible-research/
Creative Commons Attribution 4.0 International
57 stars 33 forks source link

Nextflow splitCsv(header: true) error #233

Closed johnne closed 1 year ago

johnne commented 1 year ago

When a header is added to the samplesheet, e.g.:

id,path
a,a.txt
b,b.txt

and the main.nf file contains:

// Workflow definition
workflow {
    // Define input files
    ch_input = Channel
        .fromPath ( "first_samplesheet.csv" )
        .splitCsv(header: true)
        .map      { row -> tuple(row[0], file(row[0])) }
    // Run workflow
    CONVERT_TO_UPPER_CASE( ch_input )
}

I get the following error:

N E X T F L O W ~ version 22.10.6 Launching main.nf [hungry_colden] DSL2 - revision: 20f3ce4059 [- ] process > CONVERT_TO_UPPER_CASE - Argument of file function cannot be null -- Check script 'main.nf' at line: 9 or see '.nextflow.log' file for more details

If I change the workflow definition to:

// Workflow definition
workflow {
    // Define input files
    ch_input = Channel
        .fromPath ( "first_samplesheet.csv" )
        .splitCsv(header: true)
        .map      { row -> tuple(row.id, file(row.path)) }
    // Run workflow
    CONVERT_TO_UPPER_CASE( ch_input )
}

it completes without errors. So it appears that the column names specified in the header must also be references in the map function of the channel definition?

fasterius commented 1 year ago

Thanks for the catch, I added more info in the tutorial now!