Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions bin/fastqc.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/usr/bin/env bash
sample_id="$1"
id="$1"
reads="$2"

mkdir fastqc_${sample_id}_logs
fastqc -o fastqc_${sample_id}_logs -f fastq -q ${reads}
mkdir fastqc_${id}_logs
fastqc -o fastqc_${id}_logs -f fastq -q ${reads}
4 changes: 4 additions & 0 deletions data/allreads.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
gut,https://raw.githubusercontent.com/nextflow-io/rnaseq-nf/refs/heads/master/data/ggal/ggal_gut_1.fq,https://raw.githubusercontent.com/nextflow-io/rnaseq-nf/refs/heads/master/data/ggal/ggal_gut_2.fq
liver,https://raw.githubusercontent.com/nextflow-io/rnaseq-nf/refs/heads/master/data/ggal/ggal_liver_1.fq,https://raw.githubusercontent.com/nextflow-io/rnaseq-nf/refs/heads/master/data/ggal/ggal_liver_2.fq
lung,https://raw.githubusercontent.com/nextflow-io/rnaseq-nf/refs/heads/master/data/ggal/ggal_lung_1.fq,https://raw.githubusercontent.com/nextflow-io/rnaseq-nf/refs/heads/master/data/ggal/ggal_lung_2.fq
spleen,https://raw.githubusercontent.com/nextflow-io/rnaseq-nf/refs/heads/master/data/ggal/ggal_spleen_1.fq,https://raw.githubusercontent.com/nextflow-io/rnaseq-nf/refs/heads/master/data/ggal/ggal_spleen_2.fq
1 change: 1 addition & 0 deletions data/gut.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
gut,https://raw.githubusercontent.com/nextflow-io/rnaseq-nf/refs/heads/master/data/ggal/ggal_gut_1.fq,https://raw.githubusercontent.com/nextflow-io/rnaseq-nf/refs/heads/master/data/ggal/ggal_gut_2.fq
94 changes: 72 additions & 22 deletions main.nf
Original file line number Diff line number Diff line change
Expand Up @@ -4,36 +4,86 @@
* Proof of concept of a RNAseq pipeline implemented with Nextflow
*/

// enable v2 operators (required for static type checking)
nextflow.preview.operators = true

/*
* Default pipeline parameters. They can be overriden on the command line eg.
* given `params.foo` specify on the run command line `--foo some_value`.
*/

params.reads = "$baseDir/data/ggal/ggal_gut_{1,2}.fq"
params.transcriptome = "$baseDir/data/ggal/ggal_1_48850000_49020000.Ggal71.500bpflank.fa"
params.outdir = "results"
params.multiqc = "$baseDir/multiqc"

// enable static type checking
nextflow.preview.typeChecking = true

// import modules
include { RNASEQ } from './modules/rnaseq'
include { FastqPair ; Sample } from './modules/rnaseq'
include { MULTIQC } from './modules/multiqc'

/*
* Pipeline parameters. They can be overridden on the command line, e.g.
* `params.reads` can be specified as `--reads '...'`.
*/
params {
// The input read-pair files
reads: List<FastqPair>

// The input transcriptome file
transcriptome: Path

// Directory containing multiqc configuration
multiqc: Path = "${projectDir}/multiqc"
}

/*
* main script flow
* Entry workflow
*/
workflow {
main:
log.info """\
R N A S E Q - N F P I P E L I N E
===================================
reads : ${params.reads*.id.join(',')}
transcriptome: ${params.transcriptome}
outdir : ${workflow.outputDir}
""".stripIndent()

(samples_ch, index) = RNASEQ( channel.fromList(params.reads), params.transcriptome )

multiqc_files_ch = samples_ch
.flatMap { sample -> [sample.fastqc, sample.quant] }
.collect()

multiqc_report = MULTIQC( multiqc_files_ch, params.multiqc )

publish:
index = index
samples = samples_ch
multiqc_report = multiqc_report

onComplete:
log.info(
workflow.success
? "\nDone! Open the following report in your browser --> ${workflow.outputDir}/multiqc_report.html\n"
: "Oops .. something went wrong"
)
}

/*
* Pipeline outputs. By default they will be saved to the 'results' directory.
*/
output {
index: Path {
path '.'
}

samples: Channel<Sample> {
path { sample ->
sample.fastqc >> "fastqc/${sample.id}"
sample.quant >> "quant/${sample.id}"
}
index {
path 'samples.csv'
header true
}
}

log.info """\
R N A S E Q - N F P I P E L I N E
===================================
transcriptome: ${params.transcriptome}
reads : ${params.reads}
outdir : ${params.outdir}
"""

read_pairs_ch = channel.fromFilePairs( params.reads, checkIfExists: true )
RNASEQ( params.transcriptome, read_pairs_ch )
MULTIQC( RNASEQ.out, params.multiqc )
multiqc_report: Path {
path '.'
}
}
13 changes: 7 additions & 6 deletions modules/fastqc/main.nf
Original file line number Diff line number Diff line change
@@ -1,18 +1,19 @@
params.outdir = 'results'

process FASTQC {
tag "FASTQC on $sample_id"
tag "$id"
conda 'bioconda::fastqc=0.12.1'
publishDir params.outdir, mode:'copy'

input:
tuple val(sample_id), path(reads)
id : String
fastq_1 : Path
fastq_2 : Path

output:
path "fastqc_${sample_id}_logs", emit: logs
id : String = id
fastqc : Path = file("fastqc_${id}_logs")

script:
"""
fastqc.sh "$sample_id" "$reads"
fastqc.sh "$id" "$fastq_1 $fastq_2"
"""
}
4 changes: 2 additions & 2 deletions modules/index/main.nf
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@ process INDEX {
conda 'bioconda::salmon=1.10.3'

input:
path transcriptome
transcriptome : Path

output:
path 'index'
file('index')

script:
"""
Expand Down
8 changes: 3 additions & 5 deletions modules/multiqc/main.nf
Original file line number Diff line number Diff line change
@@ -1,15 +1,13 @@
params.outdir = 'results'

process MULTIQC {
conda 'bioconda::multiqc=1.27.1'
publishDir params.outdir, mode:'copy'

input:
path '*'
path config
inputs : Bag<Path>
config : Path

output:
path 'multiqc_report.html', emit: report
file('multiqc_report.html')

script:
"""
Expand Down
13 changes: 8 additions & 5 deletions modules/quant/main.nf
Original file line number Diff line number Diff line change
@@ -1,17 +1,20 @@

process QUANT {
tag "$pair_id"
tag "$id"
conda 'bioconda::salmon=1.10.3'

input:
path index
tuple val(pair_id), path(reads)
id : String
fastq_1 : Path
fastq_2 : Path
index : Path

output:
path pair_id
id : String = id
quant : Path = file("quant_${id}")

script:
"""
salmon quant --threads $task.cpus --libType=U -i $index -1 ${reads[0]} -2 ${reads[1]} -o $pair_id
salmon quant --threads $task.cpus --libType=U -i $index -1 ${fastq_1} -2 ${fastq_2} -o quant_$id
"""
}
37 changes: 25 additions & 12 deletions modules/rnaseq.nf
Original file line number Diff line number Diff line change
@@ -1,19 +1,32 @@
params.outdir = 'results'

include { INDEX } from './index'
include { QUANT } from './quant'
include { FASTQC } from './fastqc'

workflow RNASEQ {
take:
transcriptome
read_pairs_ch

main:
INDEX(transcriptome)
FASTQC(read_pairs_ch)
QUANT(INDEX.out, read_pairs_ch)
take:
reads : Channel<FastqPair>
transcriptome : Path

emit:
QUANT.out | concat(FASTQC.out) | collect
}
main:
index = INDEX(transcriptome)
fastqc_ch = reads.map(FASTQC)
quant_ch = reads.map(QUANT, index: index)
samples_ch = fastqc_ch.join(quant_ch, 'id')

emit:
samples : Channel<Sample> = samples_ch
index : Path = index
}

record FastqPair {
id : String
fastq_1 : Path
fastq_2 : Path
}

record Sample {
id : String
fastqc : Path
quant : Path
}
34 changes: 11 additions & 23 deletions nextflow.config
Original file line number Diff line number Diff line change
Expand Up @@ -17,16 +17,20 @@ manifest {
}

/*
* default params
* params for default test data
*/

params.outdir = "results"
params.reads = "${projectDir}/data/ggal/ggal_gut_{1,2}.fq"
params.transcriptome = "${projectDir}/data/ggal/ggal_1_48850000_49020000.Ggal71.500bpflank.fa"
params.multiqc = "${projectDir}/multiqc"
params.reads = "${projectDir}/data/gut.csv"
params.transcriptome = "https://raw.githubusercontent.com/nextflow-io/rnaseq-nf/refs/heads/master/data/ggal/ggal_1_48850000_49020000.Ggal71.500bpflank.fa"

/*
* defines execution profiles for different environments
* publish settings
*/

workflow.output.mode = 'copy'

/*
* execution profiles for different environments
*/

profiles {
Expand All @@ -35,7 +39,7 @@ profiles {
}

'all-reads' {
params.reads = "${projectDir}/data/ggal/ggal_*_{1,2}.fq"
params.reads = "${projectDir}/data/allreads.csv"
}

'arm64' {
Expand Down Expand Up @@ -84,8 +88,6 @@ profiles {
}

'batch' {
params.reads = 's3://rnaseq-nf/data/ggal/lung_{1,2}.fq'
params.transcriptome = 's3://rnaseq-nf/data/ggal/transcript.fa'
process.container = 'docker.io/nextflow/rnaseq-nf:v1.3.1'
process.executor = 'awsbatch'
process.queue = 'nextflow-ci'
Expand All @@ -94,15 +96,7 @@ profiles {
aws.batch.cliPath = '/home/ec2-user/miniconda/bin/aws'
}

's3-data' {
process.container = 'docker.io/nextflow/rnaseq-nf:v1.3.1'
params.reads = 's3://rnaseq-nf/data/ggal/lung_{1,2}.fq'
params.transcriptome = 's3://rnaseq-nf/data/ggal/transcript.fa'
}

'google-batch' {
params.transcriptome = 'gs://rnaseq-nf/data/ggal/transcript.fa'
params.reads = 'gs://rnaseq-nf/data/ggal/gut_{1,2}.fq'
params.multiqc = 'gs://rnaseq-nf/multiqc'
process.executor = 'google-batch'
process.container = 'docker.io/nextflow/rnaseq-nf:v1.3.1'
Expand All @@ -113,12 +107,6 @@ profiles {
google.region = 'europe-west2'
}

'gs-data' {
process.container = 'docker.io/nextflow/rnaseq-nf:v1.3.1'
params.transcriptome = 'gs://rnaseq-nf/data/ggal/transcript.fa'
params.reads = 'gs://rnaseq-nf/data/ggal/gut_{1,2}.fq'
}

'azure-batch' {
process.container = 'docker.io/nextflow/rnaseq-nf:v1.3.1'
workDir = 'az://nf-scratch/work'
Expand Down
29 changes: 21 additions & 8 deletions nextflow_schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,27 @@
"fa_icon": "fas fa-terminal",
"description": "Define where the pipeline should find input data and save output data.",
"properties": {
"outdir": {
"type": "string",
"format": "directory-path",
"description": "The output directory where the results will be saved. You have to use absolute paths to storage on Cloud infrastructure.",
"fa_icon": "fas fa-folder-open",
"default": "results"
},
"reads": {
"type": "string",
"type": "array",
"items": {
"type": "object",
"properties": {
"id": {
"type": "string"
},
"fastq_1": {
"type": "string",
"format": "file-path",
"exists": true
},
"fastq_2": {
"type": "string",
"format": "file-path",
"exists": true
}
},
"required": ["id", "fastq_1", "fastq_2"]
},
"description": "The input read-pair files",
"fa_icon": "fas fa-folder-open",
"default": "${projectDir}/data/ggal/ggal_gut_{1,2}.fq"
Expand All @@ -32,6 +44,7 @@
},
"multiqc": {
"type": "string",
"description": "Directory containing multiqc configuration",
"fa_icon": "fas fa-folder-open",
"default": "${projectDir}/multiqc"
}
Expand Down
Loading