-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmain.nf
211 lines (135 loc) · 5.45 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
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
#!/usr/bin/env nextflow
import groovy.json.JsonSlurper
// DSL2
nextflow.preview.dsl=2
version = '1.0'
/*
* Command line input parameter
*/
// include helper functions
include { complete_message } from './lib/params/messages'
include { error_message } from './lib/params/messages'
include { combine_params } from './lib/params/params_utilities'
include { readParamsFromJsonSettings } from './lib/params/params_utilities'
include { validate_params } from './lib/params/params_utilities'
include { check_mutually_exclusive_params } from './lib/params/params_utilities'
include { helpMessage } from './lib/params/params_utilities'
include { cfmsinfer_corr } from './lib/modules/feature_workflows'
include { load_features } from './lib/modules/feature_workflows'
include { build_featmat } from './lib/modules/featmat_processes'
include { format_goldstandards} from './lib/modules/goldstandard_workflows'
include { label_featmat } from './lib/modules/featmat_processes'
include { get_labeled_rows } from './lib/modules/featmat_processes'
include { add_group_column } from './lib/modules/featmat_processes'
include { training } from './lib/modules/training_workflows'
include { cfmsinfer_eval } from './lib/modules/eval_processes'
include { get_fdr_threshold } from './lib/modules/cluster_processes'
include { cluster_interactions } from './lib/modules/cluster_workflows'
/*
* SET UP PARAMETERS
*/
// CDM new process, mini argparse checks for type and for choices
if ( !(params.entrypoint instanceof Integer) ||
!(params.exitpoint instanceof Integer)){
println("Error: entrypoint and exitpoint parameters must both be integers between 1 and 5")
println(params.entrypoint)
println(params.exitpoint)
exit 0
}
def user_steps = params.entrypoint..params.exitpoint
def relevantParams = combine_params(user_steps, params)
// Very slightly modifies from hlatyping to not access config directly (deprecated)
// The path to the parameter json with definitions is a parameter
paramsWithUsage = readParamsFromJsonSettings(params, relevantParams)
// Show help message
if (params.help){
helpMessage(paramsWithUsage)
exit 0
}
errors = []
errors = check_mutually_exclusive_params(params, errors)
errors = validate_params(params, paramsWithUsage, errors)
if (errors){
println errors
exit 0
}
workflow {
//////////////////////////////////////////////////////
//// Get or load features
// Calculate features from elution profiles
if ( 1 in user_steps ) {
features = cfmsinfer_corr()
}
// Load existing already generated features
else if ( params.entrypoint == 2 ) {
features = load_features()
}
////
//////////////////////////////////////////////////////
//////////////////////////////////////////////////////
//// Get or load feature matrix
if (2 in user_steps){
featmat = build_featmat(features)
}
else if (params.entrypoint == 3 || params.entrypoint == 4){
featmat = file(params.existing_feature_matrix)
}
////
/////////////////////////////////////////////////////
////////////////////////////////////////////////////
//// Get or load gold standards (generate_labels = true to generate)
if ( 3 in user_steps || 5 in user_steps ){
if (params.goldstandard_complexes){
labels = format_goldstandards(file(params.goldstandard_complexes), featmat)
postrain = labels[0]
negtrain = labels[1]
postest = labels[2]
negtest = labels[3]
traincomplexgroups = labels[4]
}
else {
postrain = file(params.postrain)
negtrain = file(params.negtrain)
postest = file(params.postest)
negtest = file(params.negtest)
}
}
////
//////////////////////////////////////////////////////
//////////////////////////////////////////////////////
//// Get or load labeled feature matrix ( entrypoint = 4 to load)
if ( 3 in user_steps){
featmat_labeled = label_featmat(featmat, postrain, negtrain)
}
// Add warning if only positive or negative labels found
else if (params.entrypoint == 4){
featmat_labeled = file(params.existing_feature_matrix_labeled)
}
////
//////////////////////////////////////////////////////
//////////////////////////////////////////////////////
//// Get or load scored interactions ( entrypoint = 5 to load)
if ( 4 in user_steps ) {
if (params.traincomplexgroups){
traincomplexgroups = file(params.traincomplexgroups)
}
featmat_labeled1 = get_labeled_rows(featmat_labeled)
featmat_labeled1 = add_group_column(featmat_labeled1, traincomplexgroups)[0]
scored_interactions = training(featmat_labeled1, featmat)
}
else if(params.entrypoint == 5){
scored_interactions = file(params.scored_interactions)
}
//// Cluster scored interactions
if ( 5 in user_steps) {
precisionrecall = cfmsinfer_eval(scored_interactions, postrain, negtrain, postest, negtest)
scorethreshold = get_fdr_threshold(precisionrecall[0])
clustering = cluster_interactions(scored_interactions, scorethreshold[0])
}
}
workflow.onComplete {
complete_message(params, workflow, version)
}
workflow.onError {
error_message(workflow)
}