-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.nf
169 lines (137 loc) · 4.29 KB
/
main.nf
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
/*
* Copyright (c) 2023, David Fandrei.
*
* This file is part of 'RNA-X', a simple pipeline for bulk RNA-seq implementing Kallisto.
*
* RNA-X is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* RNA-X is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*/
params.reads = null
params.outdir = "$projectDir/results"
params.adapter="$projectDir/assets/trimmomatic/adapters/TruSeq3-PE.fa"
params.transcriptome_fasta="$projectDir/assets/transcriptomes/gencode.v42.transcripts.fa.gz"
params.annotation="$projectDir/assets/transcriptomes/homo_sapiens/Homo_sapiens.GRCh38.96.gtf"
params.chromosome_file="$projectDir/assets/transcriptomes/chromInfo.hg19.tsv"
log.info """\
R N A - X P I P E L I N E
===================================
reads : ${params.reads}
transcriptome: ${params.transcriptome_fasta}
outdir : ${params.outdir}
adapter : ${params.adapter}
annotation : ${params.annotation}
"""
.stripIndent()
/* fastqc process
*/
process FASTQC {
tag "FASTQC on $sample_id"
publishDir "${params.outdir}/$sample_id", mode: 'copy'
input:
tuple val(sample_id), path(reads)
tuple val(sample_id), path(trimmed_read_1), path(trimmed_read_2)
output:
path "fastqc_${sample_id}_untrimmed"
path "fastqc_${sample_id}_trimmed"
script:
"""
fastqc.sh "fastqc_${sample_id}_untrimmed" "${reads}"
fastqc.sh "fastqc_${sample_id}_trimmed" "${trimmed_read_1} ${trimmed_read_2}"
"""
}
/* MultiQC upon completion
*/
process MULTIQC {
publishDir params.outdir, mode:'copy'
input:
path '*'
output:
path 'multiqc_report.html'
script:
"""
multiqc .
"""
}
/* Trimming process
*/
process TRIMMING {
tag "Trimming on $sample_id"
/* publishDir "${params.outdir}/$sample_id/trim_results" */
input:
tuple val(sample_id), path(reads)
output:
tuple val(sample_id), path("paired_${sample_id}_1.fastq.gz"), path("paired_${sample_id}_2.fastq.gz")
script:
"""
trimmomatic.sh "$sample_id" "$reads" $params.adapter
"""
}
/* Kallisto
*/
process INDEX {
tag "Indexing using Kallisto"
input:
path transcriptome
output:
path 'kallisto_index'
script:
"""
kallisto index -i kallisto_index $transcriptome
"""
}
process QUANTIFICATION {
memory '13 GB'
tag "Kallisto on $sample_id"
publishDir "$params.outdir/kallisto", mode: 'copy'
input:
path kallisto_index
tuple val(sample_id), path(read_1), path(read_2)
output:
path "kallisto"
script:
"""
kallisto quant -i $kallisto_index -o "kallisto_${sample_id}" -t 4 --genomebam --gtf ${params.annotation} --chromosomes ${params.chromosome_file} ${read_1} ${read_2}
"""
}
process MERGEFILES {
publishDir "$params.outdir/kallisto", mode: 'copy'
input:
path "*"
output:
path "transcript_tpms_all_samples.tsv"
script:
"""
transcriptome_all_files.sh .
"""
}
workflow {
Channel
.fromFilePairs(params.reads, checkIfExists: true)
.set { read_pairs_ch }
trimming_ch = TRIMMING(read_pairs_ch)
fastqc_ch = FASTQC(read_pairs_ch, trimming_ch)
index_ch = INDEX(params.transcriptome_fasta)
quant_ch = QUANTIFICATION(index_ch, trimming_ch)
MULTIQC(quant_ch.mix(fastqc_ch).collect())
MERGEFILES(quant_ch)
}
workflow.onComplete {
def msg = """\
Pipeline execution summary
---------------------------
Completed at: ${workflow.complete}
Duration: ${workflow.duration}
Success : ${workflow.success}
workDir : ${workflow.workDir}
exit status : ${workflow.exitStatus}
"""
.stripIndent()
log.info ( workflow.success ? "\nDone! Open the following report in your browser --> $params.outdir/multiqc_report.html \nThe file containing tpm for all samples is stored here --> $params.outdir/kallisto/transcript_tpms_all_samples.tsv" : "Oops .. something went wrong" )
}