-
Notifications
You must be signed in to change notification settings - Fork 4
/
Snakefile
182 lines (165 loc) · 5.98 KB
/
Snakefile
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
configfile: "parameters.yaml"
rule all:
input:
expand("data/matches/{feature_method}/{kmer}mers.csv", feature_method="shap_values", kmer=config["KMER"]),
expand("data/matches/{feature_method}/{kmer}mers.csv", feature_method="saliency_map", kmer=config["KMER"]),
expand("data/svm/{feature_method}/results_svm_{kmer}mer.csv", feature_method="shap_values", kmer=config["KMER"]),
expand("data/svm/{feature_method}/results_svm_{kmer}mer.csv", feature_method="saliency_map", kmer=config["KMER"]),
"data/test/clustering_metrics.csv",
"data/test/metrics.csv",
expand("data/plots/confusion_matrix_{kmer}mer.pdf", kmer=config["KMER"]),
## 12. match relevant kmers
# shap values
rule match_relevant_kmers_shap_values:
input:
expand("data/shap_values/{clade}/relevant_kmers.csv", clade=config["CLADES"]),
config["PATH_REFERENCE_GENOME"],
"mutations_reference.json"
params:
feature_method="shap_values",
relevant_kmers_to_match=50
output:
expand("data/matches/{feature_method}/{kmer}mers.csv", feature_method="shap_values", kmer=config["KMER"])
shell:
"python3 src/match_relevant_kmers.py {params.feature_method} {params.relevant_kmers_to_match}"
# saliency maps
rule match_relevant_kmers_saliency_map:
input:
expand("data/saliency_map/{clade}/relevant_kmers.csv", clade=config["CLADES"]),
config["PATH_REFERENCE_GENOME"],
"mutations_reference.json"
params:
feature_method="saliency_map",
relevant_kmers_to_match=50
output:
expand("data/matches/{feature_method}/{kmer}mers.csv", feature_method="saliency_map", kmer=config["KMER"])
shell:
"python3 src/match_relevant_kmers.py {params.feature_method} {params.relevant_kmers_to_match}"
## 11. svm experiment
# shap values
rule svm_shap_values:
input:
expand("data/shap_values/{clade}/relevant_kmers.csv", clade=config["CLADES"]),
params:
feature_method="shap_values",
kmer=config["KMER"]
output:
expand("data/svm/{feature_method}/results_svm_{kmer}mer.csv", feature_method="shap_values", kmer=config["KMER"])
shell:
"python3 src/svm_experiment.py {params.feature_method}"
# saliency map
rule svm_saliency_map:
input:
expand("data/saliency_map/{clade}/relevant_kmers.csv", clade=config["CLADES"]),
params:
feature_method="saliency_map",
output:
expand("data/svm/{feature_method}/results_svm_{kmer}mer.csv", feature_method="saliency_map", kmer=config["KMER"])
shell:
"python3 src/svm_experiment.py {params.feature_method}"
## 10. feature importance methods
# shap values
rule shap:
input:
"data/test/predictions.csv",
expand("data/saliency_map/{clade}/representative_FCGR.npy", clade=config["CLADES"]),
output:
expand("data/shap_values/{clade}/relevant_kmers.csv", clade=config["CLADES"]),
expand("data/shap_values/{clade}/shap_values.npy", clade=config["CLADES"]),
script:
"src/shap_values.py"
# saliency map
rule saliency_map:
input:
"data/test/predictions.csv"
output:
expand("data/saliency_map/{clade}/relevant_kmers.csv", clade=config["CLADES"]),
expand("data/saliency_map/{clade}/representative_FCGR.npy", clade=config["CLADES"]),
expand("data/saliency_map/{clade}/saliency_map.npy", clade=config["CLADES"]),
script:
"src/saliency_map.py"
## 9. generate plots
rule plots:
input:
"data/train/training_log.csv",
"data/test/predictions.csv"
output:
expand("data/plots/confusion_matrix_{kmer}mer.pdf", kmer=config["KMER"]),
expand("data/plots/accuracy_{kmer}mer.pdf", kmer=config["KMER"]),
expand("data/plots/loss_{kmer}mer.pdf", kmer=config["KMER"]),
script:
"src/plots.py"
## 8. clustering metrics
rule clustering_metrics:
input:
"data/test/predictions.csv",
"data/test/embeddings.npy"
output:
"data/test/clustering_metrics.csv"
script:
"src/clustering_metrics.py"
## 7. classification metrics
rule classification_metrics:
input:
"data/test/embeddings.npy",
"data/test/predictions.csv",
output:
"data/test/metrics.csv",
"data/test/accuracy.txt",
"data/test/curve_pr.pdf"
script:
"src/classification_metrics.py"
## 6. test model
rule test_model:
input:
"data/train/datasets.json",
"data/train/training_log.csv"
output:
"data/test/embeddings.npy",
"data/test/predictions.csv"
script: "src/test.py"
## 5. train model
rule train_model:
input:
"data/train/datasets.json",
expand("data/fcgr-{kmer}-mer/generated_fcgr.txt", kmer=config["KMER"])
output:
"data/train/training_log.csv",
"data/train/preprocessing.json"
script:
"src/train.py"
## 4. train, val, test sets
rule split_data:
input:
expand("data/fcgr-{kmer}-mer/generated_fcgr.txt", kmer=config["KMER"]),
output:
"data/train/datasets.json",
"data/train/summary_labels.csv"
script:
"src/split_data.py"
## 3. Generate FCGR
rule generate_fcgr:
input:
expand("data/{specie}/extracted_sequences.txt", specie=config["SPECIE"])
output:
expand("data/fcgr-{kmer}-mer/generated_fcgr.txt", kmer=config["KMER"])
script:
"src/fasta2fcgr.py"
## 2. Extract undersampled sequences in individual fasta files
rule extract_sequences:
input:
"data/train/undersample_by_clade.csv"
output:
expand("data/{specie}/extracted_sequences.txt", specie=config["SPECIE"])
script:
"src/extract_sequences.py"
## 1. Undersample sequences from metadata
rule undersample_sequences:
input:
config["PATH_METADATA"],
output:
"data/train/undersample_by_clade.csv",
"data/train/selected_by_clade.csv",
"data/train/available_by_clade.csv",
script:
"src/undersample_sequences.py"