-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.nf
More file actions
197 lines (161 loc) · 6.03 KB
/
main.nf
File metadata and controls
197 lines (161 loc) · 6.03 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
184
185
186
187
188
189
190
191
192
193
194
195
196
197
/**
* Knowledge Graph-Based Drug Target Discovery Pipeline
*
* Main Nextflow workflow orchestrating knowledge graph analysis, cross-validation,
* and drug target prediction across multiple disease indications.
*
* Pipeline Modes:
* - kgs: Generate knowledge graph overview and feature analysis
* - upset: Create UpSet plots for target/gene overlaps
* - data: Download ChEMBL molecules and MeSH tree structure
* - scores: Compute clinical scores and extract pathway genes
* - cv: Perform cross-validation across KGs and indications
* - predictions: Generate drug target predictions and consensus analysis
*
* Knowledge Graphs:
* - Hetionet: Integrative biomedical knowledge graph
* - BioKG: Biological knowledge graph
* - OpenBioLink: Open biomedical link prediction dataset
* - PrimeKG: Precision medicine knowledge graph
*
* Disease Indications:
* - Breast, lung, bowel, prostate cancer
* - Melanoma
* - Type 2 diabetes
* - Cardiovascular disease
*/
include { chembl; mesh } from './modules/data'
include { clinical_scores } from './modules/clinical_scores'
include { pathway_genes } from './modules/pathway_genes'
include { cv; cv_combine; range; range_combine } from './modules/cv'
include { compute; pr_combine; targets; training_sets; baselines; sabcs; sabcs_consensus } from './modules/predictions'
include { upset } from './modules/upset'
include { kgs_overview } from './modules/kgs'
workflow {
// ─── Knowledge Graphs ──────────────────────────────────────────────────────
kgs = Channel.of(
'hetionet',
'biokg',
'openbiolink',
'primekg'
)
// ─── Knowledge Graph Overview ─────────────────────────────────────────────
if (params.mode == 'kgs') {
ipynb = Channel.fromPath('s3://alethiotx-artemis/data/kgs/features/kgs.ipynb')
kgs_overview(ipynb)
}
// ─── UpSet Plot Generation ────────────────────────────────────────────────
if (params.mode == 'upset') {
upset()
}
// ─── External Data Download ───────────────────────────────────────────────
if (params.mode == 'data') {
chembl()
mesh()
}
// ─── Clinical Scores & Pathway Genes ──────────────────────────────────────
if (params.mode == 'scores') {
clinical_scores()
pathway_genes()
}
// ─── Cross-Validation ─────────────────────────────────────────────────────
if (params.mode == 'cv') {
// Disease indications
indications = Channel.of(
"breast",
"lung",
"bowel",
"prostate",
"melanoma",
"diabetes",
"cardiovascular"
)
// Analysis types: binary, multiclass (2/3/5 bins), regression
usecases = Channel.of(
'binary',
'multiclass',
'regression'
)
// Run CV across all KG x indication x use case combinations
cv(
kgs
.combine(indications)
.combine(usecases)
)
// Aggregate and visualize CV results
cv_combine(
cv.out
.collect()
)
// Feature subsampling analysis (10,000 total features in Hetionet)
subsample = Channel.of(30000, 20000, 10000, 5000, 1000, 500, 100, 50, 10, 5)
range(
subsample
)
// Combine feature range results with polynomial smoothing
range_combine(
range.out
.collect()
)
}
// ─── Drug Target Predictions ──────────────────────────────────────────────
if (params.mode == 'predictions') {
// Clinical trial filters: All, Unique per indication, Approved only
ct_unique = Channel.of('All', 'Unique', 'Approved')
// Random Forest probability thresholds
probs = Channel.of(0.5, 0.6, 0.7, 0.8, 0.9)
// Pathway gene feature counts: 0 (none), 100 (top), 300 (extended)
p_genes = Channel.of(0, 100, 300)
// Cross-validation iterations for stability
iterations = Channel.of(1, 2, 3, 4, 5, 6, 7, 8, 9, 10)
// Generate predictions across all parameter combinations
compute(
kgs
.combine(ct_unique)
.combine(probs)
.combine(p_genes)
.combine(iterations)
)
// Aggregate prediction overlaps and compute sensitivity/specificity
pr_combine(
compute.out.predictions
.collect()
)
// Aggregate target probabilities for all indications
targets(
compute.out.targets
.collect()
)
// Aggregate training set labels for all indications
training_sets(
compute.out.training
.collect()
)
// Analyze SABCS breast cancer target overlaps
sabcs(
compute.out.sabcs
.collect()
)
// Compute baseline statistics by indication
baselines(
targets.out.pickle,
pr_combine.out.combined_csv
)
// Generate consensus predictions across KGs for SABCS targets
sabcs_consensus(
targets.out.pickle
)
}
// ─── Post Predictions calculations only (no need to rerun compute)──────────────────────────────────────────────
if (params.mode == 'post_predictions') {
// Compute baseline statistics by indication
baselines(
's3://alethiotx-artemis/figs/predicted_targets/all_targets.pickle',
's3://alethiotx-artemis/figs/predictions/data/all.csv'
)
// Generate consensus predictions across KGs for SABCS targets
sabcs_consensus(
's3://alethiotx-artemis/figs/predicted_targets/all_targets.pickle'
)
}
}