<p>If you are certain your input files exist, I think the issue might be that the <a href="https://www.nextflow.io/docs/latest/channel.html#frompath" rel="nofollow noreferrer">fromPath</a> factory method emits file paths, but your <em>ALIGNMENT</em> process is expecting a <a href="https://www.nextflow.io/docs/latest/process.html#input-type-tuple" rel="nofollow noreferrer">tuple</a>. One solution is to use the <a href="https://www.nextflow.io/docs/latest/operator.html#map" rel="nofollow noreferrer">map</a> operator to transform the input channel into a tuple, for example (untested and ignoring the publishDir directive):</p>
<pre><code>params.reads = '/Volumes/matthews/AHR_ER_project_files/FASTQ/TCDD_AHR_Rep_ChIPSeq_1.fastq.gz'
params.genome = '/Users/siddhaduio.no/Desktop/All_omics_tools/bowtie2-2.4.4-macos-x86_64/hg38_index/human_hg38_index.*.bt2'
</code></pre>
<pre><code>process ALIGNMENT {

    tag &quot;ALIGNMENT ${sample_id}&quot;

    conda 'bowtie2'

    input:
    tuple val(sample_id), path(reads)
    path bowtie_index

    output:
    tuple val(sample_id), path(&quot;{sample_id}.aligned.bam&quot;), emit: aligned_bam

    script:
    def bt2_idx = bowtie_index[0].simpleName

    &quot;&quot;&quot;
    bowtie2 \\
        -p 64 \\
        -q \\
        -x &quot;<span class="math-container">${bt2_idx}" \\
        -U "$</span>{reads.join(',')}&quot; \\
        -S &quot;${sample_id}.aligned.bam&quot;
    &quot;&quot;&quot;
}
</code></pre>
<pre><code>workflow {

    fastq_reads = channel.fromPath( params.reads ).map { fastq -&gt;
        tuple( fastq.simpleName, fastq )
    }

    bowtie_index_files = files( params.genome )


    ALIGNMENT( fastq_reads, bowtie_index_files )
}
</code></pre>
<p>Run using:</p>
<pre><code>nextflow run main.nf -with-conda
</code></pre>

CC BY-SA 4.0
2024-09-08T23:40:00.157Z
2024-09-08T23:40:00.157Z
Steve
<p>I am trying to learn nextflow and use the process and workflow below to align some Chip seq reads.</p>
<p>For the command below, I am getting the error: <code>Path value cannot be null</code></p>
<p>My genome index files are named <code>human_hg38_index.*.bt2</code> within the folder that I have specified within <code>params.genome</code>.</p>
<p>I was wondering how do I fix this error?</p>
<p>Thanks!</p>
<pre><code>#!/usr/bin/env nextflow

params.reads = '/Volumes/matthews/AHR_ER_project_files/FASTQ/TCDD_AHR_Rep_ChIPSeq_1.fastq.gz'
params.genome = '/Users/siddhaduio.no/Desktop/All_omics_tools/bowtie2-2.4.4-macos-x86_64/hg38_index/'
params.outdir = '/Volumes/matthews/AHR_ER_project_files/FASTQ/results'

workflow {
  fastq_reads = channel.fromPath(params.reads)
  index_file= channel.fromPath(params.genome)

  ALIGNMENT(index_file,fastq_reads)
}

process ALIGNMENT {
  tag {&quot;ALIGNMENT {sample_id}&quot;} 
  label 'bowtie2'
    publishDir &quot;${params.outdir}/bowtie2_align&quot;, mode:'copy', pattern: &quot;*.bam&quot;

  input:

    path genome
    tuple val( sample_id ), path( reads )

  output:

    path( &quot;{sample_id}.aligned.bam&quot; ), emit: aligned_bam

  script:
    &quot;&quot;&quot;
    /Users/siddhaduio.no/Desktop/All_omics_tools/bowtie2-2.4.4-macos-x86_64/bowtie2 -p 64 -q -x {genome} -U {sample_id}.fastq.gz -S {sample_id}.aligned.bam
    &quot;&quot;&quot;
} 
</code></pre>

<nextflow>
Path value cannot be null error in nextflow
# Path value cannot be null error in nextflow

(Asked by: username_0 on 2024-09-08)

I am trying to learn nextflow and use the process and workflow below to align some Chip seq reads.
For the command below, I am getting the error: Path value cannot be null
My genome index files are named human_hg38_index.*.bt2 within the folder that I have specified within params.genome.
I was wondering how do I fix this error?
Thanks!
#!/usr/bin/env nextflow

params.reads = '/Volumes/matthews/AHR_ER_project_files/FASTQ/TCDD_AHR_Rep_ChIPSeq_1.fastq.gz'
params.genome = '/Users/siddhaduio.no/Desktop/All_omics_tools/bowtie2-2.4.4-macos-x86_64/hg38_index/'
params.outdir = '/Volumes/matthews/AHR_ER_project_files/FASTQ/results'

workflow {
  fastq_reads = channel.fromPath(params.reads)
  index_file= channel.fromPath(params.genome)

  ALIGNMENT(index_file,fastq_reads)
}

process ALIGNMENT {
  tag {"ALIGNMENT {sample_id}"} 
  label 'bowtie2'
    publishDir "${params.outdir}/bowtie2_align", mode:'copy', pattern: "*.bam"

  input:

    path genome
    tuple val( sample_id ), path( reads )

  output:

    path( "{sample_id}.aligned.bam" ), emit: aligned_bam

  script:
    """
    /Users/siddhaduio.no/Desktop/All_omics_tools/bowtie2-2.4.4-macos-x86_64/bowtie2 -p 64 -q -x {genome} -U {sample_id}.fastq.gz -S {sample_id}.aligned.bam
    """
}

**Tags:** nextflow

---

## 1 answers

### Answer by username_1 on 2024-09-08. Score: 2

If you are certain your input files exist, I think the issue might be that the fromPath factory method emits file paths, but your ALIGNMENT process is expecting a tuple. One solution is to use the map operator to transform the input channel into a tuple, for example (untested and ignoring the publishDir directive):
params.reads = '/Volumes/matthews/AHR_ER_project_files/FASTQ/TCDD_AHR_Rep_ChIPSeq_1.fastq.gz'
params.genome = '/Users/siddhaduio.no/Desktop/All_omics_tools/bowtie2-2.4.4-macos-x86_64/hg38_index/human_hg38_index.*.bt2'

process ALIGNMENT {

    tag "ALIGNMENT ${sample_id}"

    conda 'bowtie2'

    input:
    tuple val(sample_id), path(reads)
    path bowtie_index

    output:
    tuple val(sample_id), path("{sample_id}.aligned.bam"), emit: aligned_bam

    script:
    def bt2_idx = bowtie_index[0].simpleName

    """
    bowtie2 \\
        -p 64 \\
        -q \\
        -x "${bt2_idx}" \\
        -U "${reads.join(',')}" \\
        -S "${sample_id}.aligned.bam"
    """
}

workflow {

    fastq_reads = channel.fromPath( params.reads ).map { fastq ->
        tuple( fastq.simpleName, fastq )
    }

    bowtie_index_files = files( params.genome )


    ALIGNMENT( fastq_reads, bowtie_index_files )
}

Run using:
nextflow run main.nf -with-conda


---

