This repository has been archived by the owner on Jun 2, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
rnaseq.scm
280 lines (266 loc) · 9.88 KB
/
rnaseq.scm
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
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
;;; GNU Guix --- Functional package management for GNU
;;; Copyright © 2017 Roel Janssen <roel@gnu.org>
;;;
;;; This file is not officially part of GNU Guix.
;;;
;;; GNU Guix 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.
;;;
;;; GNU Guix 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.
;;;
;;; You should have received a copy of the GNU General Public License
;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
(define-module (umcu workflows rnaseq)
#:use-module (guix processes)
#:use-module (guix workflows)
#:use-module (guix gexp)
#:use-module (gnu packages bioinformatics)
#:use-module (gnu packages statistics)
#:use-module (umcu packages bioconductor)
#:use-module (umcu packages fastqc)
#:use-module (umcu packages picard)
#:use-module (umcu packages sambamba)
#:use-module (umcu packages star))
(define-public rnaseq-quality-control
(process
(name "quality-control")
(version "1.0")
(package-inputs
`(("fastqc" ,fastqc-bin-0.11.4)))
(data-inputs
'("/path/to/sample_R1_001.fastq.gz"))
(output-path "/path/to/rnaseq-out")
(run-time (complexity
(space (* 100 1024 1024)) ; Hundred megabytes
(time #f))) ; One minute
(procedure
#~(begin
(unless (stat #$output-path #f)
(mkdir #$output-path))
(map (lambda (sample)
(system*
(string-append #$@(assoc-ref package-inputs "fastqc") "/bin/fastqc")
sample "-o" #$output-path))
'#$data-inputs)))
(synopsis "Generate quality control reports for FastQ files")
(description "This process generates quality control reports for FastQ
files. It takes each item from the list DATA-INPUTS as a FastQ file.")))
(define-public rnaseq-align
(process
(name "align")
(version "1.0")
(package-inputs
`(("star" ,star-2.4.2a)))
(data-inputs
'(("samples" '("/path/to/sample_R1_001.fastq.gz"))
("genome-directory" "/path/to/GENOMES/STAR")
("species" "Homo_sapiens.GRCh37")))
(output-path "/path/to/rnaseq-out")
(run-time (complexity
(space (+ (stat:size
(stat (string-append
(car (assoc-ref data-inputs "genome-directory")) "/"
(car (assoc-ref data-inputs "species")) "/Genome")))
(* 500 1024 1024))) ; Genome size + 500 megabytes
(time (* 60 10)) ; Ten minutes
(threads 32)))
(procedure
#~(begin
(unless (stat #$output-path #f)
(mkdir #$output-path))
(for-each (lambda (sample)
(system*
(string-append #$@(assoc-ref package-inputs "star") "/bin/STAR")
"--genomeDir"
#$(string-append
(car (assoc-ref data-inputs "genome-directory")) "/"
(car (assoc-ref data-inputs "species")))
"--runThreadN" #$(number->string (complexity-threads run-time))
"--outFileNamePrefix" (string-append sample "_")
"--outReadsUnmapped" "Fastx"
"--outSAMtype" "BAM" "SortedByCoordinate"
"--readFilesCommand" "zcat"
"--readFilesIn" (string-append
(for-each
(lambda (sample)
(format #f "~a," sample))
(assoc-ref data-inputs "samples")))
#$(assoc-ref data-inputs "samples"))))))
(synopsis "Align reads from FastQ files against reference genome")
(description "Produce a BAM file, a chimeric junctions table, a chimeric
junctions SAM, a splice junction table and logfiles.")))
(define-public rnaseq-add-read-groups
(process
(name "add-read-groups")
(version "1.0")
(package-inputs
`(("picard" ,picard-bin-1.141)))
(data-inputs
'(("samples" '(""))))
(output-path "/path/to/rnaseq-out")
(run-time (complexity
(space (* 16 1024 1024 1024))
(time (* 6 3600))))
(procedure #~(begin (display "Not implemented yet!")))
(synopsis "Add read group information to the BAM files")
(description "This process adds read group information to BAM files
using Picard's AddOrReplaceReadGroups function.")))
(define-public rnaseq-sort-and-index
(process
(name "sort-and-index")
(version "1.0")
(package-inputs
`(("sambamba" ,sambamba)))
(data-inputs
'(("samples" '(""))))
(output-path "/path/to/rnaseq-out")
(run-time (complexity
(space (* 2 1024 1024 1024))
(time (* 6 3600))))
(procedure #~(begin (display "Not implemented yet!")))
(synopsis "Sort and index BAM files")
(description "This process sorts and indexes BAM files.")))
(define-public rnaseq-feature-readcount
(process
(name "feature-readcount")
(version "1.0")
(package-inputs
`(("htseq" ,htseq)))
(data-inputs
'(("samples" '(""))))
(output-path "/path/to/rnaseq-out")
(run-time (complexity
(space (* 2 1024 1024 1024))
(time (* 6 3600))))
(procedure #~(begin (display "Not implemented yet!")))
(synopsis "Number of mapped reads per feature")
(description "")))
(define-public rnaseq-collect-alignment-metrics
(process
(name "collect-alignment-metrics")
(version "1.0")
(package-inputs
`(("picard" ,picard-bin-1.141)))
(data-inputs
'(("samples" '(""))))
(output-path "/path/to/rnaseq-out")
(run-time (complexity
(space (* 2 1024 1024 1024))
(time (* 6 3600))))
(procedure #~(begin (display "Not implemented yet!")))
(synopsis "Report quality statistics of sorted BAM files")
(description "")))
(define-public rnaseq-merge-read-features
(process
(name "merge-read-features")
(version "1.0")
(output-path "/path/to/rnaseq-out")
(run-time (complexity
(space (* 2 1024 1024 1024))
(time (* 6 3600))))
(procedure #~(begin (display "Not implemented yet!")))
(synopsis "Merge feature read count into one table")
(description "")))
(define-public rnaseq-compute-rpkm-values
(process
(name "compute-rpkm-values")
(version "1.0")
(package-inputs
`(("r" ,r)
("r-edger" ,r-edger)))
(data-inputs
'(("samples" '(""))))
(output-path "/path/to/rnaseq-out")
(run-time (complexity
(space (* 2 1024 1024 1024))
(time (* 6 3600))))
(procedure #~(begin (display "Not implemented yet!")))
(synopsis "Compute reads per kilobase per million (RPKM) values")
(description "")))
(define-public rnaseq-variant-calling
(process
(name "variant-calling")
(version "1.0")
(package-inputs
`(("picard" ,picard-bin-1.141)))
(data-inputs
'(("samples" '(""))))
(output-path "/path/to/rnaseq-out")
(run-time (complexity
(space (* 2 1024 1024 1024))
(time (* 6 3600))))
(procedure #~(begin (display "Not implemented yet!")))
(synopsis "Variant calling, filtering and annotation")
(description "This process calls variants, filters and annotates these
variants using Picard.")))
(define-public rnaseq-normalize-read-counts
(process
(name "normalize-read-counts")
(version "1.0")
(package-inputs
`(("r" ,r)
("r-deseq" ,r-deseq)))
(data-inputs
'(("samples" '(""))))
(output-path "/path/to/rnaseq-out")
(run-time (complexity
(space (* 2 1024 1024 1024))
(time (* 6 3600))))
(procedure #~(begin (display "Not implemented yet!")))
(synopsis "Normalize read counts by their size factor")
(description "")))
(define-public rnaseq-differential-expression
(process
(name "differential-expression")
(version "1.0")
(package-inputs
`(("r" ,r)
("r-deseq2" ,r-deseq2)))
(data-inputs
'(("samples" '(""))))
(output-path "/path/to/rnaseq-out")
(run-time (complexity
(space (* 2 1024 1024 1024))
(time (* 6 3600))))
(procedure #~(begin (display "Not implemented yet!")))
(synopsis "Do a differential expression analysis")
(description "")))
(define (rnaseq-pipeline input output)
(workflow
(name "rnaseq-pipeline")
(version "1.0")
(input input)
(output output)
(processes
`(,rnaseq-quality-control
,rnaseq-align
,rnaseq-add-read-groups
,rnaseq-sort-and-index
,rnaseq-feature-readcount
,rnaseq-collect-alignment-metrics
,rnaseq-variant-calling
,rnaseq-merge-read-features
,rnaseq-compute-rpkm-values
,rnaseq-normalize-read-counts
,rnaseq-differential-expression))
(restrictions
`((,rnaseq-add-read-groups ,rnaseq-align)
(,rnaseq-sort-and-index ,rnaseq-add-read-groups)
(,rnaseq-variant-calling ,rnaseq-sort-and-index)
(,rnaseq-collect-alignment-metrics ,rnaseq-sort-and-index)
(,rnaseq-feature-readcount ,rnaseq-sort-and-index)
(,rnaseq-merge-read-features ,rnaseq-feature-readcount)
(,rnaseq-compute-rpkm-values ,rnaseq-merge-read-features)
(,rnaseq-normalize-read-counts ,rnaseq-merge-read-features)
(,rnaseq-differential-expression ,rnaseq-merge-read-features)))
(synopsis "RNA sequencing pipeline used at the UMC Utrecht.")
(description "The RNAseq pipeline can do quality control on FastQ and BAM
files; align reads against a reference genome; count reads in features;
normalize read counts; calculate RPKMs and perform DE analysis of standard
designs.")))
(define-public rnaseq-workflow (rnaseq-pipeline "input" "output"))