-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathnextflowScriptDev.nf
143 lines (117 loc) · 2.51 KB
/
nextflowScriptDev.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
/*
* Pipeline input parameters
*/
log.info """\
R N A S E Q - N F P I P E L I N E
===================================
reads : ${params.reads}
analysisdir : ${params.analysisdir}
"""
.stripIndent(true)
/*
* Sub-sample to 250k reads, 1M lines
*/
process SUBSAMPLE {
publishDir "${params.analysisdir}/1M_Subsample"
input:
tuple val(sample_id), path(reads)
output:
tuple val(sample_id), path("1M-${sample_id}_R1.fastq"), path("1M-${sample_id}_R2.fastq"), emit: reads
script:
"""
gzip -cd ${reads[0]} | head -4000000 > 1M-${sample_id}_R1.fastq
gzip -cd ${reads[1]} | head -4000000 > 1M-${sample_id}_R2.fastq
"""
}
/*
* Perform FastQC
*/
process FASTQC {
publishDir "${params.analysisdir}/1M_fastqc"
input:
tuple val(sample_id), path(read1), path(read2)
output:
file "*fastqc*"
script:
"""
# Load module
module load fastqc
# FastQC files
fastqc ${read1} ${read2}
"""
}
/*
* Perform trimming
*/
process TRIMMING {
publishDir "${params.analysisdir}/trimgalore_outs"
input:
tuple val(sample_id), path(reads)
output:
tuple val(sample_id), path("*val*.fq.gz"), emit: reads
path("*report.txt"), optional: true, emit: report
script:
"""
# Load module
module load trimgalore/0.6.5
# Run trimgalore
# Options --length, -e, --stringency, --quality are set to default
trim_galore --quality 20 \
--length 20 \
-j ${NSLOTS} \
--paired \
--stringency 1 \
-e 0.1 \
${reads}
"""
}
/*
* Perform FastQC, post trimming
*/
process FASTQC_PT {
publishDir "${params.analysisdir}/post_trim_fastqc"
input:
tuple val(sample_id), path(reads)
output:
file "*fastqc*"
script:
"""
# Load module
module load fastqc
# FastQC files
fastqc ${reads}
"""
}
/*
* Perform MultiQC
*/
process MULTIQC {
publishDir "${params.analysisdir}", mode:'copy'
input:
file("*")
file("*")
output:
path("multiqc_report.html")
script:
"""
module load anaconda3/2023.03
conda activate multiqc-env
# Run multiqc
multiqc .
"""
}
/*
* Define workflow
*/
workflow {
Channel
.fromFilePairs(params.reads, checkIfExists: true)
.set { read_pairs_ch }
SUBSAMPLE(read_pairs_ch)
FASTQC(SUBSAMPLE.out.reads)
ch_fastqc = FASTQC.out
TRIMMING(read_pairs_ch)
FASTQC_PT(TRIMMING.out.reads)
ch_fastqc_trim = FASTQC_PT.out
MULTIQC(ch_fastqc.collect(), ch_fastqc_trim.collect())
}