Nextflow does not have an env
process directive. If stringtie
is not already in your $PATH
, you'll need to append it before running nextflow
, for example:
export PATH="${PATH}:/data/selena/stringtie-2.2.1"
nextflow run de-pipeline.nf
However, you may prefer to avoid local tool installations altogether, and use either the conda
or container
process directives. The latter will however require a container runtime, like Docker or Singularity.
You may also consider including a 'sample name' or some sort of sample identifier in your config file, which I suspect is just a simple tab-separated file of filenames. This would greatly simplify your workflow. For example:
params.samplesheet = './samples.tsv'
params.genome = './genomes/GRCh38/GRCh38'
params.gtf = './Homo_sapiens.GRCh38.gtf'
genome_name = file( params.genome ).name
genome_path = file( params.genome ).parent
params.outdir = './results'
process HISAT2 {
tag { sample }
publishDir "${params.outdir}/HISAT2/${sample}", mode: 'copy'
cpus 16
input:
tuple val(sample), path(reads)
path genome_dir
output:
tuple val(sample), path("${sample}.sam")
script:
def (r1, r2) = reads
"""
hisat2 \\
-p ${task.cpus} \\
-x "${genome_dir}/${genome_name}" \\
-1 "${r1}" \\
-2 "${r2}" \\
-S "${sample}.sam"
"""
}
process SAMtools_sort {
tag { sample }
input:
tuple val(sample), path(bam)
output:
tuple val(sample), path("${sample}.sorted.bam")
"""
samtools sort \\
-o "${sample}.sorted.bam" \\
"${bam}"
"""
}
process StringTie {
tag { sample }
publishDir "${params.outdir}/StringTie/${sample}", mode: 'copy'
input:
tuple val(sample), path(bam)
path gtf
output:
tuple val(sample), path("${sample}.gtf")
"""
stringtie \\
-e \\
-G "${gtf}" \\
-o "${sample}.gtf" \\
"${bam}"
"""
}
workflow {
gtf = file( params.gtf )
Channel
.fromPath( params.samplesheet )
.splitCsv( sep: '\t' )
.map { sample, fq1, fq2 ->
def reads = tuple( file(fq1), file(fq2) )
tuple( sample, reads )
}
.set { samples }
HISAT2( samples, genome_path )
SAMtools_sort( HISAT2.out )
StringTie( SAMtools_sort.out, gtf )
}
Where the contents of the input sample sheet (e.g. samples.tsv
) looks like:
sample_A /path/to/reads/A_R1.fastq.gz /path/to/reads/A_R2.fastq.gz
sample_B /path/to/reads/B_R1.fastq.gz /path/to/reads/B_R2.fastq.gz
sample_C /path/to/reads/C_R1.fastq.gz /path/to/reads/C_R2.fastq.gz
Results:
$ nextflow run main.nf
N E X T F L O W ~ version 22.04.0
Launching `main.nf` [adoring_poisson] DSL2 - revision: 43e8c59949
executor > local (9)
[60/1cba2f] process > HISAT2 (sample_A) [100%] 3 of 3 ✔
[0a/931a07] process > SAMtools_sort (sample_A) [100%] 3 of 3 ✔
[6d/7689a2] process > StringTie (sample_A) [100%] 3 of 3 ✔