-
Notifications
You must be signed in to change notification settings - Fork 14
/
Makefile
263 lines (224 loc) · 10.1 KB
/
Makefile
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
REFS = data/references
FIGS = results/figures
TABLES = results/tables
TEMP = data/temp
PROC = data/process
FINAL = submission/
CODE = code/learning
print-%:
@echo '$*=$($*)'
################################################################################
#
# Part 1: Retrieve the subsampled shared file, taxonomy and metadata files that Marc Sze
# published in https://github.com/SchlossLab/Sze_CRCMetaAnalysis_mBio_2018
#
# Copy from Github
#
################################################################################
data/baxter.0.03.subsample.shared\
data/metadata.tsv : code/learning/load_datasets.batch
bash code/learning/load_datasets.batch
################################################################################
#
# Part 2: Model analysis in R
#
# Run scripts to perform all the models on the dataset and generate AUC values
# Each model has to be submitted seperately.
# These will generate 100 datasplit results for 7 models
# Submit each rule on the HPC parallelized.
# First 7 rules should finish before we move on to combining step at rule 8
#
################################################################################
$(TEMP)/traintime_XGBoost_%.csv\
$(TEMP)/all_imp_features_cor_results_XGBoost_%.csv\
$(TEMP)/all_imp_features_non_cor_results_XGBoost_%.csv\
$(TEMP)/all_hp_results_XGBoost_%.csv\
$(TEMP)/best_hp_results_XGBoost_%.csv : data/baxter.0.03.subsample.shared\
data/metadata.tsv\
$(CODE)/generateAUCs.R\
$(CODE)/model_pipeline.R\
$(CODE)/model_interpret.R\
$(CODE)/main.R\
$(CODE)/model_selection.R
Rscript code/learning/main.R $* "XGBoost"
$(TEMP)/traintime_Random_Forest_%.csv\
$(TEMP)/all_imp_features_cor_results_Random_Forest_%.csv\
$(TEMP)/all_imp_features_non_cor_results_Random_Forest_%.csv\
$(TEMP)/all_hp_results_Random_Forest_%.csv\
$(TEMP)/best_hp_results_Random_Forest_%.csv : data/baxter.0.03.subsample.shared\
data/metadata.tsv\
$(CODE)/generateAUCs.R\
$(CODE)/model_pipeline.R\
$(CODE)/model_interpret.R\
$(CODE)/main.R\
$(CODE)/model_selection.R
Rscript code/learning/main.R $* "Random_Forest"
$(TEMP)/traintime_Decision_Tree_%.csv\
$(TEMP)/all_imp_features_cor_results_Decision_Tree_%.csv\
$(TEMP)/all_imp_features_non_cor_results_Decision_Tree_%.csv\
$(TEMP)/all_hp_results_Decision_Tree_%.csv\
$(TEMP)/best_hp_results_Decision_Tree_%.csv : data/baxter.0.03.subsample.shared\
data/metadata.tsv\
$(CODE)/generateAUCs.R\
$(CODE)/model_pipeline.R\
$(CODE)/model_interpret.R\
$(CODE)/main.R\
$(CODE)/model_selection.R
Rscript code/learning/main.R $* "Decision_Tree"
$(TEMP)/traintime_RBF_SVM_%.csv\
$(TEMP)/all_imp_features_cor_results_RBF_SVM_%.csv\
$(TEMP)/all_imp_features_non_cor_results_RBF_SVM_%.csv\
$(TEMP)/all_hp_results_RBF_SVM_%.csv\
$(TEMP)/best_hp_results_RBF_SVM_%.csv : data/baxter.0.03.subsample.shared\
data/metadata.tsv\
$(CODE)/generateAUCs.R\
$(CODE)/model_pipeline.R\
$(CODE)/model_interpret.R\
$(CODE)/main.R\
$(CODE)/model_selection.R
Rscript code/learning/main.R $* "RBF_SVM"
$(TEMP)/traintime_L1_Linear_SVM_%.csv\
$(TEMP)/all_imp_features_cor_results_L1_Linear_SVM_%.csv\
$(TEMP)/all_imp_features_non_cor_results_L1_Linear_SVM_%.csv\
$(TEMP)/all_hp_results_L1_Linear_SVM_%.csv\
$(TEMP)/best_hp_results_L1_Linear_SVM_%.csv : data/baxter.0.03.subsample.shared\
data/metadata.tsv\
$(CODE)/generateAUCs.R\
$(CODE)/model_pipeline.R\
$(CODE)/model_interpret.R\
$(CODE)/main.R\
$(CODE)/model_selection.R
Rscript code/learning/main.R $* "L1_Linear_SVM"
$(TEMP)/traintime_L2_Linear_SVM_%.csv\
$(TEMP)/all_imp_features_cor_results_L2_Linear_SVM_%.csv\
$(TEMP)/all_imp_features_non_cor_results_L2_Linear_SVM_%.csv\
$(TEMP)/all_hp_results_L2_Linear_SVM_%.csv\
$(TEMP)/best_hp_results_L2_Linear_SVM_%.csv : data/baxter.0.03.subsample.shared\
data/metadata.tsv\
$(CODE)/generateAUCs.R\
$(CODE)/model_pipeline.R\
$(CODE)/model_interpret.R\
$(CODE)/main.R\
$(CODE)/model_selection.R
Rscript code/learning/main.R $* "L2_Linear_SVM"
$(TEMP)/traintime_L2_Logistic_Regression_%.csv\
$(TEMP)/all_imp_features_cor_results_L2_Logistic_Regression_%.csv\
$(TEMP)/all_imp_features_non_cor_results_L2_Logistic_Regression_%.csv\
$(TEMP)/all_hp_results_L2_Logistic_Regression_%.csv\
$(TEMP)/best_hp_results_L2_Logistic_Regression_%.csv : data/baxter.0.03.subsample.shared\
data/metadata.tsv\
$(CODE)/generateAUCs.R\
$(CODE)/model_pipeline.R\
$(CODE)/model_interpret.R\
$(CODE)/main.R\
$(CODE)/model_selection.R
Rscript code/learning/main.R $* "L2_Logistic_Regression"
# Create variable names with patterns to describe temporary files
SEEDS=$(shell seq 0 99)
OBJECTS=L1_Linear_SVM L2_Linear_SVM L2_Logistic_Regression RBF_SVM Decision_Tree Random_Forest XGBoost
BEST_REPS_FILES = $(foreach S,$(SEEDS),$(foreach O,$(OBJECTS),$(TEMP)/best_hp_results_$(O)_$(S).csv))
ALL_REPS_FILES = $(foreach S,$(SEEDS),$(foreach O,$(OBJECTS),$(TEMP)/all_hp_results_$(O)_$(S).csv))
COR_IMP_REPS_FILES = $(foreach S,$(SEEDS),$(foreach O,$(OBJECTS),$(TEMP)/all_imp_features_cor_results_$(O)_$(S).csv))
NON_COR_IMP_REPS_FILES = $(foreach S,$(SEEDS),$(foreach O,$(OBJECTS),$(TEMP)/all_imp_features_non_cor_results_$(O)_$(S).csv))
TIME_REPS_FILES = $(foreach S,$(SEEDS),$(foreach O,$(OBJECTS),$(TEMP)/traintime_$(O)_$(S).csv))
# Create variable names with patterns to describe processed files that are combined
BEST_COMB_FILES = $(foreach O,$(OBJECTS),$(PROC)/combined_best_hp_results_$(O).csv)
ALL_COMB_FILES = $(foreach O,$(OBJECTS),$(PROC)/combined_all_hp_results_$(O).csv)
COR_COMB_FILES = $(foreach O,$(OBJECTS),$(PROC)/combined_all_imp_features_cor_results_$(O).csv)
NON_COR_COMB_FILES = $(foreach O,$(OBJECTS),$(PROC)/combined_all_imp_features_non_cor_results_$(O).csv)
TIME_COMB_FILES = $(foreach O,$(OBJECTS),$(PROC)/traintime_$(O).csv)
# Combine all the files generated from each submitted job
$(BEST_COMB_FILES)\
$(ALL_COMB_FILES)\
$(COR_COMB_FILES)\
$(NON_COR_COMB_FILES)\
$(TIME_COMB_FILES)\ : $(BEST_REPS_FILES)\
$(ALL_REPS_FILES)\
$(COR_IMP_REPS_FILES)\
$(NON_COR_IMP_REPS_FILES)\
$(TIME_REPS_FILES)\
code/cat_csv_files.sh
bash code/cat_csv_files.sh
# Take the individual correlated importance files of linear models which have weights of each feature for each datasplit and create feature rankings for each datasplit
# Then combine each feature ranking into 1 combined file
DATA=feature_ranking
$(PROC)/combined_L1_Linear_SVM_$(DATA).tsv\
$(PROC)/combined_L2_Linear_SVM_$(DATA).tsv\
$(PROC)/combined_L2_Logistic_Regression_$(DATA).tsv : $(L2_LOGISTIC_REGRESSION_COR_IMP_REPS)\
$(L1_LINEAR_SVM_COR_IMP_REPS)\
$(L2_LINEAR_SVM_COR_IMP_REPS)\
code/learning/get_feature_rankings.R\
code/merge_feature_ranks.sh
Rscript code/learning/get_feature_rankings\
bash code/merge_feature_ranks.sh
################################################################################
#
# Part 3: Figure and table generation
#
# Run scripts to generate figures and tables
#
################################################################################
# Figure 2 shows the generalization performance of all the models tested.
submission/Figure_2.tiff : $(CODE)/functions.R\
$(CODE)/Figure2.R\
$(BEST_COMB_FILES)
Rscript $(CODE)/Figure2.R
# Figure 3 shows the linear model interpretation with weight rankings
submission/Figure_3.tiff : $(CODE)/functions.R\
$(CODE)/Figure3.R\
data/baxter.taxonomy\
$(PROC)/combined_L1_Linear_SVM_$(DATA).tsv\
$(PROC)/combined_L2_Linear_SVM_$(DATA).tsv\
$(PROC)/combined_L2_Logistic_Regression_$(DATA).tsv
Rscript $(CODE)/Figure3.R
# Figure 4 shows non-linear model interpretation with permutation importance
submission/Figure_4.tiff : $(CODE)/functions.R\
$(CODE)/Figure4.R\
$(BEST_COMB_FILES)\
$(COR_COMB_FILES)\
$(NON_COR_COMB_FILES)
Rscript $(CODE)/Figure4.R
# Figure 5 shows training times of each model
submission/Figure_5.tiff : $(CODE)/functions.R\
$(CODE)/Figure5.R\
$(TIME_COMB_FILES)
Rscript $(CODE)/Figure5.R
# Figure S1 shows the hyper-parameter tuning AUC values of linear models
submission/Figure_S1.tiff : $(CODE)/functions.R\
$(CODE)/FigureS1.R\
$(ALL_COMB_FILES)
Rscript $(CODE)/FigureS1.R
# Figure S2 shows the hyper-parameter tuning AUC values of non-linear models
submission/Figure_S2.tiff : $(CODE)/functions.R\
$(CODE)/FigureS1.R\
$(ALL_COMB_FILES)
Rscript $(CODE)/FigureS2.R
# Table 1 is a summary of the compelxity properties of all the models tested.
submission/TableS1.pdf : submission/Table1.Rmd\
submission/header.tex
R -e "rmarkdown::render('submission/Table1.Rmd', clean=TRUE)"
################################################################################
#
# Part 4: Pull it all together
#
# Render the manuscript
#
################################################################################
submission/manuscript.% : submission/mbio.csl\
submission/references.bib\
submission/manuscript.Rmd
R -e 'rmarkdown::render("submission/manuscript.Rmd", clean=FALSE)'
mv submission/manuscript.knit.md submission/manuscript.md
rm submission/manuscript.utf8.md
# module load perl-modules latexdiff/1.2.0
submission/marked_up.pdf : submission/manuscript.tex
git cat-file -p 9b2670432e7:submission/manuscript.tex > submission/manuscript_old.tex
latexdiff submission/manuscript_old.tex submission/manuscript.tex > submission/marked_up.tex
pdflatex -output-directory=submission submission/marked_up.tex
rm submission/marked_up.aux
rm submission/marked_up.log
rm submission/marked_up.out
rm submission/marked_up.tex
rm submission/manuscript_old.tex
submission/manuscript.docx : submission/manuscript.tex
pandoc submission/manuscript.tex -o submission/manuscript.docx