forked from nf-core/deepmodeloptim
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathdeepmodeloptim.nf
More file actions
183 lines (149 loc) · 6.81 KB
/
deepmodeloptim.nf
File metadata and controls
183 lines (149 loc) · 6.81 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
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
/*
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
IMPORT MODULES / SUBWORKFLOWS / FUNCTIONS
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
*/
//
// SUBWORKFLOW: Consisting of a mix of local and nf-core/modules
//
include { softwareVersionsToYAML } from '../subworkflows/nf-core/utils_nfcore_pipeline'
include { methodsDescriptionText } from '../subworkflows/local/utils_nfcore_deepmodeloptim_pipeline'
include { CHECK_MODEL_WF } from '../subworkflows/local/check_model'
include { PREPROCESS_IBIS_BEDFILE_TO_STIMULUS } from '../subworkflows/local/preprocess_ibis_bedfile_to_stimulus'
include { SPLIT_DATA_CONFIG_SPLIT_WF } from '../subworkflows/local/split_data_config_split'
include { SPLIT_DATA_CONFIG_TRANSFORM_WF } from '../subworkflows/local/split_data_config_transform'
include { SPLIT_CSV_WF } from '../subworkflows/local/split_csv'
include { TRANSFORM_CSV_WF } from '../subworkflows/local/transform_csv'
include { TUNE_WF } from '../subworkflows/local/tune'
include { EVALUATION_WF } from '../subworkflows/local/evaluation'
include { ENCODE_CSV } from '../modules/local/stimulus/encode'
//
// MODULES: Consisting of nf-core/modules
//
include { CUSTOM_GETCHROMSIZES } from '../modules/nf-core/custom/getchromsizes'
/*
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
RUN MAIN WORKFLOW
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
*/
workflow DEEPMODELOPTIM {
take:
ch_data
ch_data_config
ch_model
ch_model_config
ch_initial_weights
ch_preprocessing_config
ch_genome
tune_trials_range
tune_replicates
prediction_data
main:
// TODO collect all the versions files from the different processes
ch_versions = Channel.empty()
// ==============================================================================
// preprocess data
// ==============================================================================
if (params.preprocessing_config) {
// create genome index
CUSTOM_GETCHROMSIZES(ch_genome)
ch_genome_sizes = CUSTOM_GETCHROMSIZES.out.sizes
// preprocess bedfile into stimulus format
PREPROCESS_IBIS_BEDFILE_TO_STIMULUS(
ch_data,
ch_preprocessing_config.filter{it.protocol == 'ibis'},
ch_genome,
ch_genome_sizes
)
ch_data = PREPROCESS_IBIS_BEDFILE_TO_STIMULUS.out.data
}
// ==============================================================================
// split meta yaml split config file into individual yaml files
// ==============================================================================
SPLIT_DATA_CONFIG_SPLIT_WF( ch_data_config )
ch_yaml_sub_config_split = SPLIT_DATA_CONFIG_SPLIT_WF.out.sub_config
// ==============================================================================
// split csv data file
// ==============================================================================
SPLIT_CSV_WF(
ch_data,
ch_yaml_sub_config_split
)
ch_split_data = SPLIT_CSV_WF.out.split_data
// ==============================================================================
// split meta yaml transform config file into individual yaml files
// ==============================================================================
SPLIT_DATA_CONFIG_TRANSFORM_WF( ch_yaml_sub_config_split )
ch_yaml_sub_config = SPLIT_DATA_CONFIG_TRANSFORM_WF.out.sub_config
// ==============================================================================
// transform csv file
// ==============================================================================
TRANSFORM_CSV_WF(
ch_split_data,
ch_yaml_sub_config
)
ch_transformed_data = TRANSFORM_CSV_WF.out.transformed_data
// ==============================================================================
// check model
// ==============================================================================
// pre-step to check everything is fine
// to do so we only run the first element of the sorted channel, as we don't need
// to check on each transformed data
// we sort the channel so that we always get the same input, as the default order
// of the channel depends on which process finishes first (run in parallel)
ch_check_input_data = ch_transformed_data.toSortedList().flatten().buffer(size:2).first()
ch_check_input_config = ch_yaml_sub_config.toSortedList().flatten().buffer(size:2).first()
CHECK_MODEL_WF (
ch_check_input_data,
ch_check_input_config,
ch_model,
ch_model_config,
ch_initial_weights
)
// ==============================================================================
// tune model
// ==============================================================================
// Create dependancy WF dependency to ensure TUNE_WF runs after CHECK_MODEL_WF finished
ch_transformed_data = CHECK_MODEL_WF.out.concat(ch_transformed_data)
.filter{it} // remove the empty element from the check model
TUNE_WF(
ch_transformed_data,
ch_yaml_sub_config,
ch_model,
ch_model_config,
ch_initial_weights,
tune_trials_range,
tune_replicates
)
// ==============================================================================
// Evaluation
// ==============================================================================
// Now the data config will not work if passed in full
// We need to pass in the split data config, any of them, for the predict modules
// This will be changed in the future
ENCODE_CSV(
prediction_data,
TUNE_WF.out.data_config_tmp.first()
)
prediction_data = ENCODE_CSV.out.encoded
prediction_data = prediction_data.combine(TUNE_WF.out.data_config_tmp.first().map{meta,file -> file})
EVALUATION_WF(
TUNE_WF.out.model_tmp,
prediction_data
)
// Software versions collation remains as comments
softwareVersionsToYAML(ch_versions)
.collectFile(
storeDir: "${params.outdir}/pipeline_info",
name: 'nf_core_' + 'deepmodeloptim_software_' + 'versions.yml',
sort: true,
newLine: true
).set { ch_collated_versions }
emit:
versions = ch_versions // channel: [ path(versions.yml) ]
}
/*
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
THE END
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
*/