-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.nf
More file actions
executable file
·136 lines (109 loc) · 4.06 KB
/
main.nf
File metadata and controls
executable file
·136 lines (109 loc) · 4.06 KB
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
#!/usr/bin/env nextflow
def helpMessage() {
log.info"""
================================================================
mageck-nf
================================================================
Statistical analysis of multiplexed CRISPR-Cas9 / shRNA screens
Usage:
nextflow run zuberlab/mageck-nf
Options:
--contrasts Tab-delimited text file specifying the contrasts
to be analyzed. (Defaults to 'contrasts.txt')
The following columns are required:
- name: name of contrasts
- control: control samples (comma separated)
- treatment: treatment samples (comma separated)
- norm_method: normalization method
- fdr_method: multiple testing adjustment method
- lfc_method: method to combine guides / hairpins
--counts Tab-delimited test file containing the raw counts.
(Defaults to 'counts_mageck.txt')
This file must conform to the input requirements of
MAGeCK 0.5.7 (http://mageck.sourceforge.net)
--resultsDir Directory name to save results to. (Defaults to
'results')
Profiles:
standard local execution
docker local execution with docker
singularity local execution with singularity
slurm IMPIMBA2 cluster execution with singularity
Docker:
zuberlab/mageck-nf:latest
Author:
Jesse J. Lipp (jesse.lipp@imp.ac.at)
""".stripIndent()
}
if (params.help){
helpMessage()
exit 0
}
Channel
.fromPath( params.contrasts )
.splitCsv(sep: '\t', header: true)
.set { contrastsMageck }
Channel
.fromPath( params.counts )
.set { countsMageck }
Channel
.fromPath( params.cnv )
.set { cnvMageck }
process mageck {
tag { parameters.name }
publishDir path: "${params.resultsDir}/${parameters.name}",
mode: 'copy',
overwrite: 'true',
saveAs: {filename ->
if (filename.indexOf(".log") > 0) "$filename"
else if (filename.indexOf(".normalized.txt") > 0) "$filename"
else null
}
input:
val(parameters) from contrastsMageck
each file(counts) from countsMageck
each file(cnv) from cnvMageck
output:
set val("${parameters.name}"), file('*.sgrna_summary.txt'), file('*.gene_summary.txt') into resultsMageck
file('*.log') into logsMageck
file('*.normalized.txt') into normalizedMageck
script:
rra_params = params.min_rra_window > 0 ? "--additional-rra-parameters '-p ${params.min_rra_window}'" : ''
cnv_file = cnv.exists() & parameters.cnv_correction != '' ? "--cnv-norm ${cnv}" : ""
cnv_cellline = cnv.exists() & parameters.cnv_correction != '' ? "--cell-line ${parameters.cnv_correction}" : ""
"""
prefilter_counts.R \
${counts} \
${parameters.control} \
${params.min_count} > counts_filtered.txt
mageck test \
--output-prefix ${parameters.name} \
--count-table counts_filtered.txt \
--control-id ${parameters.control} \
--treatment-id ${parameters.treatment} \
--norm-method ${parameters.norm_method} \
--adjust-method ${parameters.fdr_method} \
--gene-lfc-method ${parameters.lfc_method} \
--normcounts-to-file \
${rra_params} \
${cnv_file} \
${cnv_cellline}
"""
}
process postprocess {
tag { name }
publishDir path: "${params.resultsDir}/${name}",
mode: 'copy',
overwrite: 'true'
input:
set val(name), file(guides), file(genes) from resultsMageck
output:
set val(name), file('*_stats.txt') into processedMageck
file('*.pdf') into qcMageck
script:
"""
postprocess_mageck.R ${guides} ${genes}
"""
}
workflow.onComplete {
println ( workflow.success ? "COMPLETED!" : "FAILED" )
}