-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path__main__.sh
383 lines (305 loc) · 11.1 KB
/
__main__.sh
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
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
# Compute pairwise antigenic distances between Thai viruses
# from cartography distances
Rscript --vanilla Scripts/antigenicDist_prep/thai_map.R
# Quantify expected antigenic distance resulting from
# measurement uncertainties
Rscript --vanilla Scripts/antigenicDist_uncertainty/getTiterTableWithNoise.R
for i in $(seq 1 100 ); do
export SLURM_ARRAY_TASK_ID=$i
Rscript --vanilla Scripts/antigenicDist_uncertainty/inferCoords.R
done
# Fit substitution model for each individual protein
# ..................................................
# There are 10 non-overlapping protein products of dengue
# which are further processed into 14 proteins
for i in $(seq 1 14 ); do
export SLURM_ARRAY_TASK_ID=$i
Rscript --vanilla Scripts/fitEffects/nnls.R thai_map AA
done
# summarize the fits
Rscript --vanilla \
Scripts/plotEffects/summarizeFit.R \
03-fits/nnls/thai_map/AA/adj_none/aasub
# Envelope protein (E)
# .....................
# Extract envelope protein from AA data
Rscript --vanilla \
Scripts/sequence_prep/aa_sampleProteins2length.R \
"02-processedData/AA_Envelope" \
--outLength 495 \
--nSamples 1 \
-ip 3 \
--sortsite
# make predictions (100-fold)
for i in $(seq 1 100 ); do
export SLURM_ARRAY_TASK_ID=$i
Rscript --vanilla Scripts/plotEffects/predictDist.R \
thai_map \
03-fits/nnls/thai_map/AA/adj_none/aasub/envelope_protein_E \
--fasta 02-processedData/AA_Envelope/1.fasta
done
# examine fits
Rscript -e "rmarkdown::render(
'Scripts/plotEffects/plotEffects_E.R'
, output_dir = 'Reports'
, output_file = 'Reports/effects_E.html'
, knit_root_dir = getwd()
)"
# Find candidate protein(s) that harbor signals
# beyond linkage with E
# .....................
# Generate random sequences to the length of each protein
# to see if the protein has more signal than the average of the polyprotein
# .........................................................................
nSamples=20
# generate sequences
for proteinLength in $(grep -oE "[0-9]+$" 02-processedData/AA_lengths.txt ) ; do
Rscript --vanilla \
Scripts/sequence_prep/aa_random2length.R \
"02-processedData/AA_random2length_${proteinLength}" \
${proteinLength} \
${nSamples}
done
# fit nnls with these sequences
for d in $(ls -d 02-processedData/AA_random2length_* ) ; do
for i in $(seq 1 $nSamples ); do
export SLURM_ARRAY_TASK_ID=$i
seqdir=$(basename $d )
Rscript --vanilla Scripts/fitEffects/nnls.R thai_map ${seqdir}
done
done
# summarize RMSE of the fits
for fitdir in $(ls -d 03-fits/nnls/thai_map/AA_random2length_*/adj_none/aasub ) ; do
Rscript --vanilla \
Scripts/plotEffects/summarizeFit.R \
${fitdir}
done
# Downsample E to the size of each protein
# to assess whether the protein has excess/equivalent/less signal
# compared to E
# .............
nSamples=20
# generate subsampled E sequences
for proteinLength in $(grep -oE "[0-9]+$" 02-processedData/AA_lengths.txt ) ; do
Rscript --vanilla \
Scripts/sequence_prep/aa_sample2length.R \
"02-processedData/AA_sample2length_${proteinLength}" \
${proteinLength} \
${nSamples} \
"envelope protein E"
done
# fit nnls with these sequences
for seqdir in $(ls -d 02-processedData/AA_sample2length_* ); do
for iSample in $(seq 1 ${nSamples} ); do
export SLURM_ARRAY_TASK_ID=1
Rscript --vanilla Scripts/fitEffects/nnls.R thai_map $(basename ${seqdir} )/${iSample}
done
done
# summarize RMSE of the fits
for fitdir in $(ls -d 03-fits/nnls/thai_map/AA_sample2length_*/* | grep -E "AA_sample2length_[0-9]+" ) ; do
Rscript --vanilla \
Scripts/plotEffects/summarizeFit.R \
${fitdir}/adj_none/aasub
done
# Where are the sites that harbor these additional signals
# beyond linkage with E
# .....................
nSamples=300
for proteinLength in 30 60 ; do
# Generate random 30 or 60AA downsamples of NS2A
Rscript --vanilla \
Scripts/sequence_prep/aa_sampleProteins2length.R \
"02-processedData/AA_NS2A_${proteinLength}" \
--outLength ${proteinLength} \
--nSamples ${nSamples} \
-ip 7
# Estimate the effect sizes, adjusted for E
for i in $(seq 1 $nSamples ); do
export SLURM_ARRAY_TASK_ID=$i
Rscript --vanilla \
Scripts/fitEffects/nnls.R \
thai_map \
AA_NS2A_${proteinLength} \
--adjfasta 02-processedData/AA_Envelope/1.fasta \
--adjname adj_envelope
done
# Generate random 30 or 60AA
# from sites other than E and NS2A
Rscript --vanilla \
Scripts/sequence_prep/aa_sampleProteins2length.R \
"02-processedData/AA_polyNonE_${proteinLength}" \
--outLength ${proteinLength} \
--nSamples ${nSamples} \
-ip 1 5 6 8 9 10 12 11 14
# Estimate the effect sizes, adjusted for E
for i in $(seq 1 $nSamples ); do
export SLURM_ARRAY_TASK_ID=$i
Rscript --vanilla \
Scripts/fitEffects/nnls.R \
thai_map \
AA_polyNonE_${proteinLength} \
--adjfasta 02-processedData/AA_Envelope/1.fasta \
--adjname adj_envelope
done
done
# Summarize the fits
for proteinLength in 30 60 ; do
# NS2A sites
Rscript --vanilla \
Scripts/plotEffects/summarizeFit.R \
03-fits/nnls/thai_map/AA_NS2A_${proteinLength}/adj_envelope/aasub
# Other sites
Rscript --vanilla \
Scripts/plotEffects/summarizeFit.R \
03-fits/nnls/thai_map/AA_polyNonE_${proteinLength}/adj_envelope/aasub
done
# Generate report: 30AA
Rscript -e "rmarkdown::render(
'Scripts/plotEffects/plotAdjustedEffects.R'
, output_dir = 'Reports'
, output_file = 'Reports/NS2A_30_adjE.html'
, knit_root_dir = getwd()
, params = list(
fitdir = '03-fits/nnls/thai_map/AA_NS2A_30/adj_envelope/aasub'
, nulldir = '03-fits/nnls/thai_map/AA_polyNonE_30/adj_envelope/aasub'
, aadir = '02-processedData/AA_NS2A_30/'
, lengthAdj = 495
)
)"
# Generate report: 60AA
Rscript -e "rmarkdown::render(
'Scripts/plotEffects/plotAdjustedEffects.R'
, output_dir = 'Reports'
, output_file = 'Reports/NS2A_60_adjE.html'
, knit_root_dir = getwd()
, params = list(
fitdir = '03-fits/nnls/thai_map/AA_NS2A_60/adj_envelope/aasub'
, nulldir = '03-fits/nnls/thai_map/AA_polyNonE_60/adj_envelope/aasub'
, aadir = '02-processedData/AA_NS2A_60/'
, lengthAdj = 495
)
)"
# Compare positions identified from sampling 30 vs 60 AA
# : revealed 62 sites embedding signals beyond linkage with E
Rscript -e "rmarkdown::render(
'Scripts/plotEffects/compareAdjustedEffects.R'
, output_dir = 'Reports'
, output_file = 'Reports/NS2A_compare_adjE.html'
, knit_root_dir = getwd()
, params = list(
effectdir = '04-plots/fits_adjusted'
)
)"
# Are these 62 sites mapped to the antigenic signals by chance?
# .............................................................
positionFile="04-plots/compare_adjusted/positions_NS2A_beyondE.txt"
# E + 62 NS2A sites
# .................
# Generate subset of NS2A sites that likely harbors signals beyond E
Rscript --vanilla \
Scripts/sequence_prep/aa_subsetPositions.R \
"02-processedData/AA_NS2A_beyondE" \
-ip 7 \
--positionFile ${positionFile}
# Fit the effect sizes, and get the performance measures
export SLURM_ARRAY_TASK_ID=1
Rscript --vanilla \
Scripts/fitEffects/nnls.R \
thai_map \
AA_NS2A_beyondE \
--adjfasta 02-processedData/AA_Envelope/1.fasta \
--adjname adj_envelope
# Summarize results
Rscript --vanilla \
Scripts/plotEffects/summarizeFit.R \
"03-fits/nnls/thai_map/AA_NS2A_beyondE/adj_envelope/aasub"
# E + 62 NS2A sites (permuted)
# .................
# Permute NS2A sites that likely harbors signals beyond E
# (within site permutation across viruses)
# to break the non-random associations with diversity kept the same.
Rscript --vanilla \
Scripts/sequence_prep/aa_permute.R \
"02-processedData/AA_NS2A_beyondE_permuted" \
--aaver "AA_NS2A_beyondE" \
-ip 1 \
-n 100 \
--seed 58900
for i in $(seq 1 100 ); do
export SLURM_ARRAY_TASK_ID=$i
Rscript --vanilla \
Scripts/fitEffects/nnls.R \
thai_map \
AA_NS2A_beyondE_permuted \
--adjfasta 02-processedData/AA_Envelope/1.fasta \
--adjname adj_envelope
done
# Summarize results
Rscript --vanilla \
Scripts/plotEffects/summarizeFit.R \
"03-fits/nnls/thai_map/AA_NS2A_beyondE_permuted/adj_envelope/aasub"
# E + 62 other sites
# ..................
# Generate random AA with the same number as the number of sites
# suspected to harbor signals beyond E
# from sites other than E and NS2A
proteinLength=$( wc -l ${positionFile} | awk '{print $1}' )
Rscript --vanilla \
Scripts/sequence_prep/aa_sampleProteins2length.R \
"02-processedData/AA_polyNonE_${proteinLength}" \
--outLength ${proteinLength} \
--nSamples ${nSamples} \
-ip 1 5 6 8 9 10 12 11 14
for i in $(seq 1 $nSamples ); do
export SLURM_ARRAY_TASK_ID=$i
Rscript --vanilla \
Scripts/fitEffects/nnls.R \
thai_map \
AA_polyNonE_${proteinLength} \
--adjfasta 02-processedData/AA_Envelope/1.fasta \
--adjname adj_envelope
done
# Summarize results
export NOT_SAVE_ESTIMATES="TRUE" # do not save d,p,v estimates
Rscript --vanilla \
Scripts/plotEffects/summarizeFit.R \
"03-fits/nnls/thai_map/AA_polyNonE_${proteinLength}/adj_envelope/aasub"
# Sumarize the effect sizes of these 62 NS2A sites
# (adjusted for E)
# .....................................................
# make predictions (100-fold): when using E + 62 NS2A
for i in $(seq 1 100 ); do
export SLURM_ARRAY_TASK_ID=$i
Rscript --vanilla Scripts/plotEffects/predictDist.R \
thai_map \
03-fits/nnls/thai_map/AA_NS2A_beyondE/adj_envelope/aasub/subset \
--fasta 02-processedData/AA_Envelope/1.fasta \
--fasta 02-processedData/AA_NS2A_beyondE/subset.fasta
done
# Generate report: 62AA
Rscript -e "rmarkdown::render(
'Scripts/plotEffects/plotAdjustedEffects.R'
, output_dir = 'Reports'
, output_file = 'Reports/NS2A_beyondE.html'
, knit_root_dir = getwd()
, params = list(
fitdir = '03-fits/nnls/thai_map/AA_NS2A_beyondE/adj_envelope/aasub'
, nulldir = '03-fits/nnls/thai_map/AA_polyNonE_62/adj_envelope/aasub'
, aadir = '02-processedData/AA_NS2A_beyondE/'
, lengthAdj = 495
)
)"
# Generate report: Excess signal evaluations
Rscript -e "rmarkdown::render(
'Scripts/plotEffects/plotSignalExcess.R'
, output_dir = 'Reports'
, output_file = 'Reports/SignalExcessFromE.html'
, knit_root_dir = getwd()
, params = list(plotdir = '04-plots/beyondE')
)"
# E-NS2A coevolution
# ..................
sh Scripts/coevolution/coevolution.sh
# Observable effects of point substitutions
# ..................
Rscript --vanilla Scripts/validation/effects.R