-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathread_all_scores.py
executable file
·1675 lines (1464 loc) · 75.1 KB
/
read_all_scores.py
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
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
#!/usr/bin/env python2
import cPickle as pickle
import pandas as pd
pd.options.mode.chained_assignment = None # default='warn'
import numpy as np
import os
import sys
import shutil
from stats import fraction_correct, mae as calc_mae, bootstrap_xy_stat
import scipy
import json
import subprocess
import collections
import copy
import string
import random
import re
import copy
csv_paths = [
'data/zemu_1.2-60000_rscript_validated-ref-id_01.csv.gz',
'data/zemu_1.2-60000_rscript_validated-ref-id_30.csv.gz',
'data/zemu_1.2-60000_rscript_validated-ref-id_50.csv.gz',
'data/zemu_1.2-60000_rscript_validated-ref-WildTypeComplex_01.csv.gz',
'data/zemu_1.2-60000_rscript_validated-ref-WildTypeComplex_30.csv.gz',
'data/zemu_1.2-60000_rscript_validated-ref-WildTypeComplex_50.csv.gz',
'data/zemu_control-69aa526-id_01.csv.gz',
'data/zemu_control-69aa526-id_30.csv.gz',
'data/zemu_control-69aa526-id_50.csv.gz',
'data/zemu_control-69aa526-WildTypeComplex_01.csv.gz',
'data/zemu_control-69aa526-WildTypeComplex_30.csv.gz',
'data/zemu_control-69aa526-WildTypeComplex_50.csv.gz',
'data/ddg_monomer_16_003-zemu-2-id_01.csv.gz',
'data/ddg_monomer_16_003-zemu-2-id_30.csv.gz',
'data/ddg_monomer_16_003-zemu-2-id_50.csv.gz',
'data/ddg_monomer_16_003-zemu-2-WildTypeComplex_01.csv.gz',
'data/ddg_monomer_16_003-zemu-2-WildTypeComplex_30.csv.gz',
'data/ddg_monomer_16_003-zemu-2-WildTypeComplex_50.csv.gz',
'data/zemu-brub_1.6-nt10000-id_01.csv.gz',
'data/zemu-brub_1.6-nt10000-id_30.csv.gz',
'data/zemu-brub_1.6-nt10000-id_50.csv.gz',
'data/zemu-brub_1.6-nt10000-WildTypeComplex_01.csv.gz',
'data/zemu-brub_1.6-nt10000-WildTypeComplex_30.csv.gz',
'data/zemu-brub_1.6-nt10000-WildTypeComplex_50.csv.gz',
'data/zemu-values-id_01.csv.gz',
'data/zemu_1.2-60000_rscript_simplified-t14-id_01.csv.gz',
'data/zemu_1.2-60000_rscript_simplified-t14-id_30.csv.gz',
'data/zemu_1.2-60000_rscript_simplified-t14-id_50.csv.gz',
'data/zemu_1.2-60000_rscript_simplified-t14-WildTypeComplex_01.csv.gz',
'data/zemu_1.2-60000_rscript_simplified-t14-WildTypeComplex_30.csv.gz',
'data/zemu_1.2-60000_rscript_simplified-t14-WildTypeComplex_50.csv.gz'
]
output_dir = 'output'
latex_output_dir = os.path.join( output_dir, 'latex' )
output_fig_path = os.path.join( output_dir, 'figures_and_tables' )
main_template_latex_file = os.path.join( 'latex_templates', 'figs_and_tables.tex' )
if not os.path.isdir( output_fig_path ):
os.makedirs( output_fig_path )
if not os.path.isdir( latex_output_dir ):
os.makedirs( latex_output_dir )
# Import subsets
with open('subsets.json') as f:
subsets = json.load(f)
# Import here as they can be slow, and are unneeded if plots aren't going to be made
import matplotlib
matplotlib.use('Agg')
import matplotlib.pyplot as plt
import seaborn as sns
current_palette = [
(0.29803921568627451, 0.44705882352941179, 0.69019607843137254),
(0.33333333333333331, 0.6588235294117647, 0.40784313725490196),
(0.7686274509803922, 0.30588235294117649, 0.32156862745098042),
(0.50588235294117645, 0.44705882352941179, 0.69803921568627447),
(0.80000000000000004, 0.72549019607843135, 0.45490196078431372),
(0.39215686274509803, 0.70980392156862748, 0.80392156862745101),
]
for csv_path in csv_paths:
if not os.path.isfile(csv_path):
print csv_path
assert( os.path.isfile(csv_path) )
if not os.path.isdir(output_dir):
os.makedirs(output_dir)
display_mut_types = [
'complete', 's2l', 'sing_ala', 'mult_mut', 'mult_none_ala',
]
mut_types = {
'complete' : 'Complete dataset',
'sing_mut' : 'Single mutation',
'mult_mut' : 'Multiple mutations',
'mult_all_ala' : 'Multiple mutations, all to alanine',
'mult_none_ala' : 'Multiple mutations, none to alanine',
's2l' : 'Small-to-large mutation(s)',
'l2s' : 'Large-to-small',
'ala' : 'Mutation(s) to alanine',
'sing_ala' : 'Single mutation to alanine',
'res_gte25' : 'Res. $>=$ 2.5 Ang.',
'res_lte15' : 'Res. $<=$ 1.5 Ang.',
'res_gt15_lt25' : '1.5 Ang. $<$ Res. $<$ 2.5 Ang.',
'some_s2l' : 'Some small-to-large',
'some_l2s' : 'Some large-to-small',
'antibodies' : 'Antibodies',
'stabilizing' : 'Stabilizing',
'neutral' : 'Neutral',
'positive' : 'Positive',
's2l_stabilizing' : 'Small-to-large and stabilizing',
'SS-all-None' : 'Loop',
'SS-all-H' : 'Alpha Helix',
'SS-all-E' : 'Strand',
'SS-all-T' : 'Turn',
'SS-all-B' : 'Beta Bridge',
'SS-all-G' : 'Helix-3',
# 'SS-all-I' : 'Helix-5',
'SS-all-S' : 'Bend',
}
for cut_off in [0.05, 0.1, 0.25]:
for stat_type in ['mean']:
for comparison_type, comparison_type_name in [('lt', '<'), ('gte', '>=')]:
mut_types[ 'buried_%s%.2f_%s' % (comparison_type, cut_off, stat_type) ] = '%s solvent exposure %s %.2f' % (stat_type.capitalize(), comparison_type_name, cut_off)
run_names = {
'zemu_1.2-60000_rscript_validated-t14' : 'flex ddG',
'zemu_1.2-60000_rscript_simplified-t14' : 'flex ddG',
'zemu_1.2-60000_rscript_validated-ref' : 'flex ddG (REF energy)',
'zemu-brub_1.6-nt10000' : 'flex ddG (1.6 kT)',
'ddg_monomer_16_003-zemu-2' : 'ddG monomer',
'zemu_control' : 'no backrub control',
'zemu-values' : 'ZEMu paper',
'zemu_control-69aa526-noglypivot' : 'no backrub control',
'zemu_control-69aa526' : 'no backrub control',
'tal_GAM' : 'GAM (Talaris)',
'ref_GAM' : 'GAM (REF)',
'control_GAM' : 'GAM (No backrub control, Talaris)',
}
run_colors = {
run_name : current_palette[i]
for i, run_name in enumerate([
'zemu_1.2-60000_rscript_simplified-t14',
'zemu_control-69aa526',
'zemu-values',
'ddg_monomer_16_003-zemu-2',
])
}
sorting_type_descriptions = {
'id' : 'Structures are not sorted, and are randomly added to the ensemble. ',
'WildTypeComplex' : 'Structures are sorted by their minimized wild-type complex energy. ',
}
sorting_type_descriptions_short = {
'id' : 'unsorted structures',
'WildTypeComplex' : 'structures sorted by wild-type complex energy',
}
def make_fig_components_text(fc, run_name, score_method, structure_order):
matching_uses = set()
score_method = int(score_method)
for use_name, uses_list in fc.iteritems():
for other_run_name, other_structure_order, other_score_method in uses_list:
if other_run_name == run_name and other_structure_order == structure_order and other_score_method == score_method:
matching_uses.add( use_name )
return '; '.join(sorted(list(matching_uses)))
def figure_components():
# Figure to run map
def append_all_structs_helper( runs_steps, structure_orders ):
l = []
for run_name, step_num in runs_steps:
for structure_order in structure_orders:
for i in xrange(1, 51):
if i == 50 and structure_order == 'WildTypeComplex':
l.append( (run_name, '%s_%02d' % ('id', i), step_num ) )
else:
l.append( (run_name, '%s_%02d' % (structure_order, i), step_num ) )
return l
fig_4 = [ ('zemu_control-69aa526', 'id_50', 8) ]
for step in np.arange(0,50001,2500):
fig_4.append( ('zemu_1.2-60000_rscript_simplified-t14', 'id_50', step) )
total_ddg_score_figure_components = {
'Figure 2' : [
('zemu_1.2-60000_rscript_simplified-t14', 'id_50', 35000),
('zemu_control-69aa526', 'id_50', 8),
],
'Figure 3' : append_all_structs_helper([('zemu_1.2-60000_rscript_simplified-t14', 35000), ('zemu_control-69aa526', 8)], ['WildTypeComplex']),
'Figure 4' : fig_4,
'Figure 5' : [
('tal_GAM', 'id_50', 12),
('control_GAM', 'id_50', 12),
],
'Table 2' : [
('zemu_1.2-60000_rscript_simplified-t14', 'id_50', 35000),
('zemu_control-69aa526', 'id_50', 8),
('zemu-values', 'id_01', 11),
('ddg_monomer_16_003-zemu-2', 'id_50', 8),
],
'Table S2' : [
('zemu-brub_1.6-nt10000', 'id_50', 10000),
('zemu_1.2-60000_rscript_simplified-t14', 'id_50', 10000),
],
'Table S3' : [
('zemu_1.2-60000_rscript_simplified-t14', 'id_50', 35000),
('zemu_control-69aa526', 'id_50', 8),
('zemu-values', 'id_01', 11),
('ddg_monomer_16_003-zemu-2', 'id_50', 8),
],
'Table S4' : append_all_structs_helper([('zemu_1.2-60000_rscript_simplified-t14', 35000), ('zemu_control-69aa526', 8)], ['WildTypeComplex']),
'Table S5' : append_all_structs_helper([('ddg_monomer_16_003-zemu-2', 8), ('zemu_control-69aa526', 8)], ['WildTypeComplex']),
'Table S6' : append_all_structs_helper([('zemu_1.2-60000_rscript_simplified-t14', 35000), ('zemu_control-69aa526', 8)], ['id']),
'Table S7' : fig_4,
'Table S8' : [
('zemu_1.2-60000_rscript_simplified-t14', 'id_50', 35000),
('zemu_1.2-60000_rscript_validated-ref', 'id_50', 35000),
],
'Table S9' : [
('tal_GAM', 'id_50', 12),
('control_GAM', 'id_50', 12),
('ref_GAM', 'id_50', 12),
],
'Table S10' : append_all_structs_helper([('zemu_1.2-60000_rscript_simplified-t14', 35000), ('zemu_control-69aa526', 8)], ['id']),
'Table S11' : append_all_structs_helper([('zemu_1.2-60000_rscript_simplified-t14', 35000), ('zemu_control-69aa526', 8)], ['id']),
'Figure S2' : append_all_structs_helper([('ddg_monomer_16_003-zemu-2', 8), ('zemu_control-69aa526', 8)], ['WildTypeComplex']),
'Figure S3' : append_all_structs_helper([('zemu_1.2-60000_rscript_simplified-t14', 35000), ('zemu_control-69aa526', 8)], ['id']),
'Figure S4' : append_all_structs_helper([('zemu_1.2-60000_rscript_simplified-t14', 35000), ('zemu_control-69aa526', 8)], ['id']),
'Figure S5' : append_all_structs_helper([('zemu_1.2-60000_rscript_simplified-t14', 35000), ('zemu_control-69aa526', 8)], ['id']),
'Figure S7' : [
('zemu_1.2-60000_rscript_validated-ref', 'id_50', 35000),
('ref_GAM', 'id_50', 12),
],
'Figure S8' : [
('tal_GAM', 'id_50', 12),
],
}
partial_ddg_score_figure_components = copy.deepcopy( total_ddg_score_figure_components )
fig_s1 = []
for step in np.arange(0,50001,2500):
fig_s1.extend( append_all_structs_helper( [('zemu_1.2-60000_rscript_simplified-t14', step)], ['WildTypeComplex']) )
partial_ddg_score_figure_components['Figure S1'] = fig_s1 # Not used now, but could be in the future
return total_ddg_score_figure_components
cached_loaded_df_initialized = False
cached_loaded_df = None
cached_df_path = '/tmp/read_all_scores.hdf'
def load_df():
global cached_loaded_df_initialized
global cached_loaded_df
if cached_loaded_df_initialized:
return cached_loaded_df.copy()
elif os.path.isfile(cached_df_path):
print 'Loading cached HDF'
df = pd.read_hdf( cached_df_path )
cached_loaded_df = df.copy()
cached_loaded_df_initialized = True
print 'Done loading HDF\n'
return df
print 'Performing initial .csv load'
# Load CSVs
df = pd.read_csv( csv_paths[0] )
for csv_path in csv_paths[1:]:
df = df.append( pd.read_csv( csv_path ) )
# Load GAM
for run_name, csv_path in [
('tal_GAM', os.path.join('gam', 'tal_GAM_terms.csv')),
('ref_GAM', os.path.join('gam', 'ref_GAM_terms.csv')),
('control_GAM', os.path.join('gam', 'control_GAM_terms.csv')),
]:
gam_df = pd.read_csv( csv_path )
assert( len(gam_df) == 1240 )
gam_df['DataSetID'] = range(1, 1241)
gam_df = gam_df.assign( PredictionRunName = run_name )
gam_df = gam_df.assign( ScoreMethodID = 12 )
gam_df = gam_df.assign( PredictionID = None )
gam_df = gam_df.assign( StructureOrder = 'id_50' )
gam_df['total'] = gam_df[ [x for x in gam_df.columns if x.endswith('_GAM')] ].sum( axis = 1 )
gam_df = gam_df[ ['PredictionRunName', 'DataSetID', 'ScoreMethodID', 'total', 'exp_data', 'StructureOrder'] ]
gam_df.columns = [ 'PredictionRunName', 'DataSetID', 'ScoreMethodID', 'total', 'ExperimentalDDG', 'StructureOrder' ]
df = df.append( gam_df )
# Finish up
df = add_score_categories( df )
df = df.drop_duplicates( ['PredictionRunName', 'DataSetID', 'PredictionID', 'ScoreMethodID', 'MutType', 'total', 'ExperimentalDDG', 'StructureOrder'] )
cached_loaded_df_initialized = True
cached_loaded_df = df.copy()
df.to_hdf( cached_df_path, 'read_all_scores' )
print 'Done loading csvs\n'
return df
def add_score_categories(df, mut_type_subsets = None):
if mut_type_subsets == None or 'complete' in mut_type_subsets or 'MutType' not in df.columns:
df = df.assign( MutType = 'complete' )
if mut_type_subsets == None or 'stabilizing' in mut_type_subsets:
stabilizing = df.loc[ (df['MutType'] == 'complete') & (df['ExperimentalDDG'] <= -1.0) ].copy()
stabilizing.loc[:,'MutType'] = 'stabilizing'
df = df.append( stabilizing )
# Add s2l_stabilizing
s2l_stabilizing = df.loc[ (df['MutType'] == 's2l') & (df['ExperimentalDDG'] <= -1.0) ].copy()
s2l_stabilizing.loc[:,'MutType'] = 's2l_stabilizing'
df = df.append( s2l_stabilizing )
if mut_type_subsets == None or 'neutral' in mut_type_subsets:
neutral = df.loc[ (df['MutType'] == 'complete') & (df['ExperimentalDDG'] > -1.0) & (df['ExperimentalDDG'] < 1.0) ].copy()
neutral.loc[:,'MutType'] = 'neutral'
df = df.append( neutral )
if mut_type_subsets == None or 'positive' in mut_type_subsets:
positive = df.loc[ (df['MutType'] == 'complete') & (df['ExperimentalDDG'] >= 1.0) ].copy()
positive.loc[:,'MutType'] = 'positive'
df = df.append( positive )
for subset_name, subset_keys in subsets.iteritems():
if mut_type_subsets == None or subset_name in mut_type_subsets:
subset_df = df.loc[ (df['MutType'] == 'complete') & (df['DataSetID'].isin(subset_keys)) ].copy()
assert( len(subset_df) > 0 )
subset_df.loc[:,'MutType'] = subset_name
df = df.append( subset_df )
return df
def save_latex( latex_template_file, sub_dict, out_tex_name = None, long_table = False, wrap_command = None ):
if 'fig-path' in sub_dict:
shutil.copy( sub_dict['fig-path'], latex_output_dir )
sub_dict['fig-path'] = os.path.basename( sub_dict['fig-path'] )
if out_tex_name == None:
out_tex_name = os.path.basename( latex_template_file )
if not out_tex_name.endswith( '.tex' ):
out_tex_name += '.tex'
with open(latex_template_file, 'r') as f:
latex_template = f.read()
for key in sub_dict:
latex_key = '%%%%%s%%%%' % key
latex_template = latex_template.replace( latex_key, sub_dict[key] )
if long_table:
latex_lines = latex_template.split('\n')
new_lines = []
for line in latex_lines:
if '\\begin{table}' in line or '\\end{tabular}' in line:
continue
elif 'begin{tabular}' in line:
col_sorting = line.strip()[ len('\\begin{tabular}') : ]
new_lines.append( '\\begin{longtable}' + col_sorting )
elif 'end{table}' in line:
new_lines.append( '\\end{longtable}' )
else:
new_lines.append(line)
latex_template = '\n'.join( new_lines )
if wrap_command != None:
latex_template = '{' + wrap_command + '\n' + latex_template + '\n}'
with open( os.path.join( latex_output_dir, out_tex_name ), 'w') as f:
f.write( latex_template )
def isfloat(x):
try:
x = float(x)
except ValueError:
return False
return True
def compile_latex():
shutil.copy( main_template_latex_file, latex_output_dir )
for i in xrange( 0, 3 ):
output = subprocess.check_output( ['xelatex', os.path.basename( main_template_latex_file )[:-4] ], cwd = latex_output_dir )
def make_results_df( generate_plots = False, print_statistics = False, use_cached_if_available = True ):
results_csv_path = os.path.join(output_dir, 'results.csv')
if use_cached_if_available and os.path.isfile( results_csv_path ):
results_df = pd.read_csv( results_csv_path )
return results_df
df = load_df()
# Add 'complete' to front of list so scaling is calculated first
mut_types = sorted( df['MutType'].drop_duplicates().values )
mut_types.insert(0, mut_types.pop( mut_types.index('complete') ) )
structure_orders = sorted( df['StructureOrder'].drop_duplicates().values )
maes_unscaled = []
fcs_unscaled = []
fcs_unscaled_correct = []
fcs_unscaled_considered = []
fcs = []
fcs_correct = []
fcs_considered = []
fc_zeros = []
fc_zeros_correct = []
fc_zeros_considered = []
maes = []
rs = []
slopes = []
df_mut_types = []
df_structure_orders = []
prediction_runs = []
steps = []
ns = []
scaling_factors = {}
scaling_slopes = []
scaling_intercepts = []
for prediction_run in sorted( df['PredictionRunName'].drop_duplicates().values ):
for structure_order in structure_orders:
for mut_type in mut_types:
outer_sub_df = df.loc[ (df['MutType'] == mut_type) & (df['StructureOrder'] == structure_order) & (df['PredictionRunName'] == prediction_run) ]
num_steps = float( len(outer_sub_df['ScoreMethodID'].drop_duplicates().values) )
if generate_plots:
outer_fig = plt.figure(figsize=(8.5, 8.5), dpi=600)
outer_ax = outer_fig.add_subplot(1, 1, 1)
for step_i, step in enumerate( sorted( outer_sub_df['ScoreMethodID'].drop_duplicates().values ) ):
sub_df = outer_sub_df.loc[ outer_sub_df['ScoreMethodID'] == step ]
sub_output_dir = os.path.join(output_dir, prediction_run.replace('.', ''))
sub_output_dir = os.path.join(sub_output_dir, mut_type)
sub_output_dir = os.path.join(sub_output_dir, structure_order)
outer_fig_path = os.path.join(sub_output_dir, 'all_steps.pdf')
sub_output_dir = os.path.join(sub_output_dir, str(step))
if not os.path.isdir(sub_output_dir) and generate_plots:
os.makedirs(sub_output_dir)
slope, intercept, r_value, p_value, std_err = scipy.stats.linregress( sub_df['total'], sub_df['ExperimentalDDG'] )
rs.append(r_value)
slopes.append(slope)
if mut_type == 'complete':
assert( (prediction_run, structure_order, step) not in scaling_factors )
scaling_factors[(prediction_run, structure_order, step)] = (slope, intercept)
sub_df.loc[:,'scaled_total'] = sub_df.loc[:,'total'] * scaling_factors[(prediction_run, structure_order, step)][0] + scaling_factors[(prediction_run, structure_order, step)][1]
scaling_slopes.append( scaling_factors[(prediction_run, structure_order, step)][0] )
scaling_intercepts.append( scaling_factors[(prediction_run, structure_order, step)][1] )
fc_unscaled, fc_unscaled_correct, fc_unscaled_considered = fraction_correct(
sub_df['total'].values,
sub_df['ExperimentalDDG'].values,
)
fcs_unscaled.append(fc_unscaled)
fcs_unscaled_correct.append(fc_unscaled_correct)
fcs_unscaled_considered.append(fc_unscaled_considered)
fc, fc_correct, fc_considered = fraction_correct(
sub_df['scaled_total'].values,
sub_df['ExperimentalDDG'].values,
)
fcs.append(fc)
fcs_correct.append(fc_correct)
fcs_considered.append(fc_considered)
fc_zero, fc_zero_correct, fc_zero_considered = fraction_correct(
sub_df['total'].values,
sub_df['ExperimentalDDG'].values,
x_cutoff = 0.00000001,
y_cutoff = 0.00000001,
)
fc_zeros.append(fc_zero)
fc_zeros_correct.append(fc_zero_correct)
fc_zeros_considered.append(fc_zero_considered)
mae_unscaled = calc_mae( sub_df['total'], sub_df['ExperimentalDDG'] )
maes_unscaled.append(mae_unscaled)
mae = calc_mae( sub_df['scaled_total'], sub_df['ExperimentalDDG'] )
maes.append(mae)
df_mut_types.append(mut_type)
df_structure_orders.append(structure_order)
prediction_runs.append(prediction_run)
steps.append(step)
ns.append(len(sub_df['ExperimentalDDG']))
if print_statistics:
print mut_type, structure_order, prediction_run
print 'R:', '%.3f' % r_value
print 'slope:', '%.3f' % slope
print 'FC:', '%.3f' % fc
print 'MAE:', '%.3f' % mae
print
if generate_plots:
fig = plt.figure(figsize=(8.5, 8.5), dpi=300)
ax = fig.add_subplot(1, 1, 1)
sns.regplot(y="total", x="ExperimentalDDG", data = sub_df, ax=ax, scatter_kws = { 's' : 4.5 } )
sns.regplot(
y="total", x="ExperimentalDDG", data = sub_df, ax=outer_ax,
color = ( float(num_steps - step_i) / num_steps, 0, ( float(step_i) / num_steps ) ),
scatter_kws = { 's' : 2 },
)
ax.set_xlabel( 'Experimental ddG' )
ax.set_ylabel( 'ddG prediction' )
fig_path = os.path.join(sub_output_dir, 'total_vs_experimental.pdf')
fig.savefig( fig_path )
plt.close(fig)
if generate_plots:
outer_fig.savefig(outer_fig_path)
plt.close(outer_fig)
results_df = pd.DataFrame( {
'PredictionRun' : prediction_runs,
'MutTypes' : df_mut_types,
'StructureOrder' : df_structure_orders,
'FractionCorrect' : fcs,
'FractionCorrect-count_correct' : fcs_correct,
'FractionCorrect-count_considered' : fcs_considered,
'FractionCorrect_unscaled' : fcs_unscaled,
'FractionCorrect-count_correct-unscaled' : fcs_unscaled_correct,
'FractionCorrect-count_considered-unscaled' : fcs_unscaled_considered,
'FractionCorrect-zero_boundary-unscaled' : fc_zeros,
'FractionCorrect-count_correct-zero_boundary-unscaled' : fc_zeros_correct,
'FractionCorrect-count_considered-zero_boundary-unscaled' : fc_zeros_considered,
'MAE' : maes,
'MAE_unscaled' : maes_unscaled,
'Slope' : slopes,
'ScalingSlopes' : scaling_slopes,
'ScalingIntercepts' : scaling_intercepts,
'Step' : steps,
'R' : rs,
'N' : ns,
} )
sort_cols = [
'FractionCorrect_unscaled',
'R',
'MAE_unscaled',
]
ascendings = [False, False, True]
for sort_col, asc in zip(sort_cols, ascendings):
results_df.sort_values( sort_col, inplace = True, ascending = asc )
# print results_df[ ['PredictionRun', 'MutTypes', 'StructureOrder', 'Step', sort_col] ].head(n=20)
new_column_order = [
'PredictionRun', 'N', 'MutTypes', 'Step', 'StructureOrder',
'R', 'MAE', 'MAE_unscaled',
'Slope', 'ScalingIntercepts', 'ScalingSlopes',
]
for col in sorted(results_df.columns):
if col not in new_column_order:
new_column_order.append( col )
assert( set(new_column_order) == set(results_df.columns) )
results_df = results_df[new_column_order]
results_df.sort_values('R', ascending = False).to_csv( results_csv_path )
if print_statistics:
print results_csv_path
print
return results_df
def figure_mult_non_ala():
exp_run_name = 'zemu_1.2-60000_rscript_simplified-t14'
control_run_name = 'zemu_control-69aa526'
zemu_run_name = 'zemu-values'
force_backrub_step = 35000
point_size = 6.0
alpha = 1.0
scatter_kws = { 's' : point_size, 'alpha' : alpha }
line_kws = { 'linewidth' : 0.8 }
df = load_df()
exp_colname = 'Experimental ddG'
pred_colname = 'Rosetta Score'
display_subset = 'mult_none_ala'
df = df.rename( columns = {'ExperimentalDDG' : exp_colname} )
df = df.rename( columns = {'total' : pred_colname} )
sns.set_style("whitegrid")
fig = plt.figure(
figsize=(6, 8.5), dpi=600
)
df_a = df.loc[ (df['PredictionRunName'] == exp_run_name) & (df['MutType'] == display_subset) & (df['ScoreMethodID'] == force_backrub_step) & (df['StructureOrder'] == 'id_50') ]
ax1 = fig.add_subplot( 2, 1, 1 )
df_b = df.loc[ (df['PredictionRunName'] == zemu_run_name) & (df['MutType'] == display_subset) ]
ax2 = fig.add_subplot( 2, 1, 2 )
sns.regplot(
y = pred_colname, x = exp_colname,
data = df_a, ax = ax1,
scatter_kws = scatter_kws,
line_kws = line_kws,
ci = None,
color = run_colors[exp_run_name],
)
sns.regplot(
y = pred_colname, x = exp_colname,
data = df_b, ax = ax2,
scatter_kws = scatter_kws,
line_kws = line_kws,
ci = None,
color = run_colors[exp_run_name],
)
# ax1.set_xlabel('')
ax2.set_ylabel('ZEMu score')
fig.suptitle(mut_types[display_subset])
out_path = os.path.join( output_fig_path, 'fig-scatter_mult-non-ala.pdf' )
fig.savefig( out_path )
def figure_scatter( force_backrub_step = 35000 ):
exp_run_name = 'zemu_1.2-60000_rscript_simplified-t14'
control_run_name = 'zemu_control-69aa526'
point_size = 4.8
alpha = 0.55
scatter_kws = { 's' : point_size, 'alpha' : alpha }
line_kws = { 'linewidth' : 0.8 }
df = load_df()
exp_colname = 'Experimental ddG'
pred_colname = 'Rosetta Score'
top_subset = 'complete'
bottom_subset = 's2l'
df = df.rename( columns = {'ExperimentalDDG' : exp_colname} )
df = df.rename( columns = {'total' : pred_colname} )
sns.set_style("whitegrid")
fig = plt.figure(
figsize=(8.5, 8.5), dpi=600
)
complete_corrs = df.loc[ (df['MutType'] == top_subset) & (df['PredictionRunName'] == exp_run_name) ].groupby( 'ScoreMethodID' )[[pred_colname,exp_colname]].corr().ix[0::2,exp_colname].sort_values( ascending = False )
best_step_a = force_backrub_step
df_a = df.loc[ (df['PredictionRunName'] == exp_run_name) & (df['MutType'] == top_subset) & (df['ScoreMethodID'] == best_step_a) ]
ax1 = fig.add_subplot( 2, 2, 1 )
complete_corrs = df.loc[ (df['MutType'] == top_subset) & (df['PredictionRunName'] == control_run_name) ].groupby( 'ScoreMethodID' )[[pred_colname,exp_colname]].corr().ix[0::2,exp_colname].sort_values( ascending = False )
best_step_b = complete_corrs.index[0][0]
df_b = df.loc[ (df['PredictionRunName'] == control_run_name) & (df['MutType'] == top_subset) & (df['ScoreMethodID'] == best_step_b) ]
ax2 = fig.add_subplot( 2, 2, 2 )
complete_corrs = df.loc[ (df['MutType'] == bottom_subset) & (df['PredictionRunName'] == exp_run_name) ].groupby( 'ScoreMethodID' )[[pred_colname,exp_colname]].corr().ix[0::2,exp_colname].sort_values( ascending = False )
best_step_c = force_backrub_step
df_c = df.loc[ (df['PredictionRunName'] == exp_run_name) & (df['MutType'] == bottom_subset) & (df['ScoreMethodID'] == best_step_c) ]
ax3 = fig.add_subplot( 2, 2, 3 )
complete_corrs = df.loc[ (df['MutType'] == bottom_subset) & (df['PredictionRunName'] == control_run_name) ].groupby( 'ScoreMethodID' )[[pred_colname,exp_colname]].corr().ix[0::2,exp_colname].sort_values( ascending = False )
best_step_d = complete_corrs.index[0][0]
df_d = df.loc[ (df['PredictionRunName'] == control_run_name) & (df['MutType'] == bottom_subset) & (df['ScoreMethodID'] == best_step_d) ]
ax4 = fig.add_subplot( 2, 2, 4 )
xmin = min( df_a[pred_colname].min(), df_b[pred_colname].min(), df_c[pred_colname].min(), df_d[pred_colname].min() )
xmax = max( df_a[pred_colname].max(), df_b[pred_colname].max(), df_c[pred_colname].max(), df_d[pred_colname].max() )
ymin = min( df_a[exp_colname].min(), df_b[exp_colname].min(), df_c[exp_colname].min(), df_d[exp_colname].min() )
ymax = max( df_a[exp_colname].max(), df_b[exp_colname].max(), df_c[exp_colname].max(), df_d[exp_colname].max() )
ax1.set_xlim( xmin, xmax )
ax1.set_ylim( ymin, ymax )
ax2.set_xlim( xmin, xmax )
ax2.set_ylim( ymin, ymax )
ax3.set_xlim( xmin, xmax )
ax3.set_ylim( ymin, ymax )
ax4.set_xlim( xmin, xmax )
ax4.set_ylim( ymin, ymax )
sns.regplot(
y = pred_colname, x = exp_colname,
data = df_a, ax = ax1,
scatter_kws = scatter_kws,
line_kws = line_kws,
ci = None,
color = run_colors[exp_run_name],
)
sns.regplot(
y = pred_colname, x = exp_colname,
data = df_b, ax = ax2,
scatter_kws = scatter_kws,
line_kws = line_kws,
ci = None,
color = run_colors[control_run_name],
)
sns.regplot(
y = pred_colname, x = exp_colname,
data = df_c, ax = ax3,
scatter_kws = scatter_kws,
line_kws = line_kws,
ci = None,
color = run_colors[exp_run_name],
)
sns.regplot(
y = pred_colname, x = exp_colname,
data = df_d, ax = ax4,
scatter_kws = scatter_kws,
line_kws = line_kws,
ci = None,
color = run_colors[control_run_name],
)
# ax2.set_xticklabels([])
ax1.set_xlabel('')
ax2.set_xlabel('')
ax2.set_ylabel('')
# ax2.set_yticklabels([])
ax4.set_ylabel('')
ax3.set_xlabel('Experimental $\Delta\Delta G$')
ax4.set_xlabel('Experimental $\Delta\Delta G$')
ax1.set_title( '(a) Flex ddG - %s' % (mut_types[top_subset]) )
ax2.set_title( '(b) Control - %s' % (mut_types[top_subset] ) )
ax3.set_title( '(c) Flex ddG - %s' % (mut_types[bottom_subset]) )
ax4.set_title( '(d) Control - %s' % (mut_types[bottom_subset]) )
# Assert that these lengths are equal since N is displayed for top and bottom together
assert( len(df_a) == len(df_b) )
assert( len(df_c) == len(df_d) )
out_path = os.path.join( output_fig_path, 'fig-scatter.pdf' )
bottom_subset_label = mut_types[bottom_subset].capitalize()
if bottom_subset_label.strip() == 'Small-to-large mutation(s)':
bottom_subset_label = 'Small-to-large mutation(s) subset'
sub_dict = {
'exp-method-name' : run_names[exp_run_name],
'numsteps-a' : str( best_step_a ),
'numsteps-c' : str( best_step_c ),
'top-subset' : mut_types[top_subset].capitalize(),
'top-n' : str( len(df_a) ),
'control-method-name' : run_names[control_run_name],
'bottom-subset' : mut_types[bottom_subset].capitalize(),
'bottom-n' : str( len(df_c) ),
'fig-path' : out_path,
}
fig.savefig( out_path )
save_latex( 'latex_templates/figure-scatter.tex', sub_dict )
print out_path
def table_composition():
# Dataset composition
df = load_df()
df = df.drop_duplicates( ['PredictionRunName', 'DataSetID', 'PredictionID', 'ScoreMethodID', 'MutType', 'total', 'ExperimentalDDG', 'StructureOrder'] )
control_df = df.loc[ (df['PredictionRunName'] == 'zemu_control-69aa526') & (df['ScoreMethodID'] == 8 ) ]
ns = []
mut_type_names = []
for mut_type in display_mut_types:
ns.append( len( control_df.loc[ control_df['MutType'] == mut_type ] ) )
mut_type_names.append( mut_types[mut_type] )
table_df = pd.DataFrame( {
'Name' : mut_type_names,
'n' : ns,
} )
table_df = table_df[ ['n', 'Name'] ] # Order columns correctly
table_df.sort_values( 'n', inplace = True, ascending = False )
# print 'Table 1:'
# print table_df.head( n = 20 )
save_latex( 'latex_templates/table-composition.tex', { 'table-comp' : table_df.to_latex( index=False ) } )
table_df.to_csv( os.path.join(output_fig_path, 'table_comp.csv') )
def table_versions():
save_latex( 'latex_templates/table-versions.tex', run_names )
def steps_vs_corr( output_figure_name, mut_type_subsets, control_run = 'zemu_control-69aa526', force_control_in_axes = True, max_backrub_steps = 50000, structure_order = 'id_50' ):
exp_run_name = 'zemu_1.2-60000_rscript_simplified-t14'
df = load_df()
exp_colname = 'Experimental ddG'
pred_colname = 'Rosetta Score'
df = df.rename( columns = {'ExperimentalDDG' : exp_colname} )
df = df.rename( columns = {'total' : pred_colname} )
# Filter to desired StructureOrder
if structure_order != None:
df = df.loc[ df['StructureOrder'] == structure_order ]
if max_backrub_steps != None:
df = df.loc[ df['ScoreMethodID'] <= max_backrub_steps ]
sns.set_style("white")
fig = plt.figure(
figsize=(10.0, 8.5), dpi=600
)
fig.subplots_adjust( wspace = 0.6, hspace = 0.3)
# fig.suptitle('$\Delta\Delta G$ prediction performance vs. number of backrub sampling steps')
r_axes = []
r_min = float('inf')
r_max = float('-inf')
mae_axes = []
mae_min = float('inf')
mae_max = float('-inf')
ns = []
legend_lines = []
legend_labels = []
data_table = []
for ax_i, mut_type_subset in enumerate( mut_type_subsets ):
ax = fig.add_subplot( 2, 2, ax_i + 1 )
ax.set_title( '(%s) - %s' % (string.ascii_lowercase[ax_i], mut_types[mut_type_subset]) )
ax.set_ylabel("Pearson's R")
ax.set_xlabel("Backrub Step")
ns.append( len(df.loc[ (df['PredictionRunName'] == exp_run_name) & (df['MutType'] == mut_type_subset ) & (df['ScoreMethodID'] == df['ScoreMethodID'].drop_duplicates().values[0]) ]) )
rs = df.loc[ (df['PredictionRunName'] == exp_run_name) & (df['MutType'] == mut_type_subset ) ].groupby('ScoreMethodID')[[pred_colname, exp_colname]].corr().ix[0::2, exp_colname].reset_index()
maes = df.loc[ (df['PredictionRunName'] == exp_run_name) & (df['MutType'] == mut_type_subset ) ].groupby('ScoreMethodID')[[pred_colname, exp_colname]].apply( lambda x: calc_mae( x[exp_colname], x[pred_colname] ) )
assert( len(rs) == len(maes) )
for name, group in df.loc[ (df['PredictionRunName'] == exp_run_name) & (df['MutType'] == mut_type_subset ) ].groupby('ScoreMethodID'):
assert( len(group) == len(subsets[mut_type_subset]) )
exp_rs_plot, = ax.plot(
rs['ScoreMethodID'], rs['Experimental ddG'],
'o',
linestyle = 'None',
color = run_colors[exp_run_name],
)
r_min = min( r_min, min(rs['Experimental ddG']) )
r_max = max( r_max, max(rs['Experimental ddG']) )
ax2 = ax.twinx()
ax2.yaxis.set_major_formatter(matplotlib.ticker.FormatStrFormatter('%.2f'))
ax2.set_ylabel("MAE")
exp_mae_plot, = ax2.plot(
maes.index, maes.values,
'P',
linestyle = 'None',
color = ( 1.0 + np.array(run_colors[exp_run_name]) ) / 2.0,
)
mae_min = min( mae_min, min(maes.values) )
mae_max = max( mae_max, max(maes.values) )
ax.yaxis.set_major_formatter(matplotlib.ticker.FormatStrFormatter('%.2f'))
# Get control performance values
control_rs = df.loc[ (df['PredictionRunName'] == control_run) & (df['MutType'] == mut_type_subset ) ].groupby('ScoreMethodID')[[pred_colname, exp_colname]].corr().ix[0::2, exp_colname].reset_index()
assert( len(control_rs) == 1 )
control_r = control_rs['Experimental ddG'][0]
control_rs_plot, = ax.plot(
[0], [control_r],
marker = 'o',
linestyle = 'None',
color = run_colors[control_run],
)
control_maes = df.loc[ (df['PredictionRunName'] == control_run) & (df['MutType'] == mut_type_subset ) ].groupby('ScoreMethodID')[[pred_colname, exp_colname]].apply( lambda x: calc_mae( x[exp_colname], x[pred_colname] ) )
assert( len(control_maes.values) == 1 )
control_mae = control_maes.values[0]
control_mae_plot, = ax2.plot(
[0], [control_mae],
marker = 'P',
linestyle = 'None',
color = ( 1.0 + np.array(run_colors[control_run]) ) / 2.0,
)
np.testing.assert_array_equal( rs['ScoreMethodID'], maes.index )
data_table.append( (run_names[control_run], mut_types[mut_type_subset], 0, control_r, control_mae) )
for step_num, r, mae in zip(rs['ScoreMethodID'], rs['Experimental ddG'], maes.values):
if step_num in [2500, 35000] or step_num % 10000 == 0:
data_table.append( (run_names[exp_run_name], mut_types[mut_type_subset], step_num, r, mae) )
if force_control_in_axes:
r_min = min( r_min, control_r )
r_max = max( r_max, control_r )
mae_min = min( mae_min, control_mae )
mae_max = max( mae_max, control_mae )
if ax_i == 0:
legend_lines.extend( [exp_rs_plot, control_rs_plot, exp_mae_plot, control_mae_plot] )
legend_labels.extend( [
'R - ' + run_names[exp_run_name],
'R - ' + run_names[control_run],
'MAE - ' + run_names[exp_run_name],
'MAE - ' + run_names[control_run],
] )
r_axes.append( ax )
mae_axes.append( ax2 )
r_range = r_max - r_min
r_min -= r_range * 0.1
r_max += r_range * 0.1
mae_range = mae_max - mae_min
mae_min -= mae_range * 0.1
mae_max += mae_range * 0.1
for r_ax, mae_ax in zip(r_axes, mae_axes):
r_ax.set_ylim( [r_min, r_max] )
mae_ax.set_ylim( [mae_min, mae_max] )
r_ax.set_zorder( mae_ax.get_zorder() + 10 )
r_ax.patch.set_visible(False)
out_path = os.path.join( output_fig_path, '%s.pdf' % output_figure_name )
underlying_name = '%s-underlying-data' % output_figure_name
color_description = ''
if exp_run_name == 'zemu_1.2-60000_rscript_simplified-t14':
color_description += '\nPredictions generated with the Flex ddG protocol are shown in blue.'
elif exp_run_name == 'ddg_monomer_16_003-zemu-2':
color_description += '\nPredictions generated with the ddg\_monomer method are shown in purple.'
color_description += '\nPredictions generated with the no backrub control protocol are shown in green.'
sub_dict = {
'panel-a' : '%s (n=%d)' % ( mut_types[ mut_type_subsets[0] ].capitalize(), ns[0] ),
'panel-b' : '%s (n=%d)' % ( mut_types[ mut_type_subsets[1] ].capitalize(), ns[1] ),
'panel-c' : '%s (n=%d)' % ( mut_types[ mut_type_subsets[2] ].capitalize(), ns[2] ),
'panel-d' : '%s (n=%d)' % ( mut_types[ mut_type_subsets[3] ].capitalize(), ns[3] ),
'fig-label' : output_figure_name,
'fig-path' : out_path,
'underlying-label' : 'tab:%s' % underlying_name,
'color-description' : color_description,
}
leg = plt.figlegend(
legend_lines, legend_labels, loc = 'lower center', labelspacing=0.0,
markerscale = 1.3,
fontsize = 13,
ncol = 2,
)
fig.savefig( out_path )
save_latex( 'latex_templates/steps-vs-corr.tex', sub_dict, out_tex_name = output_figure_name )
fig.savefig( out_path )
print out_path
# Save underlying data
data_table = pd.DataFrame.from_records(
data_table,
columns = ['Run', 'Subset', 'Backrub Step', 'R', 'MAE'],
)
latex_lines = data_table.to_latex( float_format = '%.2f', index = False ).split('\n')
latex_lines = [r'\begin{table}'] + latex_lines + ['\caption[]{Selection of key data shown in \cref{fig:%s}}' % output_figure_name, '\label{tab:%s}' % underlying_name, r'\end{table}', '']
with open( 'output/latex/%s.tex' % underlying_name, 'w' ) as f:
f.write( '\n'.join(latex_lines) )
def figure_structs_vs_corr(
exp_run_name = 'zemu_1.2-60000_rscript_simplified-t14', force_backrub_step = 35000, max_backrub_step = 50000,
mut_type_subsets = ['complete', 's2l', 'mult_none_ala', 'sing_ala'],
extra_fig_name = None,
):
sorting_types = ['WildTypeComplex', 'id']
base_path = 'data/by_struct/%s-%s_%02d.csv.gz'
control_base_path = 'data/by_struct/%s-%s_%02d.csv.gz'
number_of_structures = 50
control_run = 'zemu_control-69aa526'
for sorting_type in sorting_types:
structure_orders = []
df = None
for struct_id in xrange(1, number_of_structures + 1):
csv_path = base_path % (exp_run_name, sorting_type, struct_id)
assert( os.path.isfile( csv_path ) )
if struct_id == 1:
df = pd.read_csv( csv_path )
else:
df = df.append( pd.read_csv( csv_path ) )
control_csv_path = control_base_path % (control_run, sorting_type, struct_id)
df = df.append( pd.read_csv( control_csv_path ) )
structure_orders.append( '%s_%02d' % (sorting_type, struct_id) )
df['StructureOrder'] = df['StructureOrder'].apply(
lambda s: int( s.split('_')[1] )
)
df = add_score_categories(df, mut_type_subsets = mut_type_subsets)
point_size = 4.5
alpha = 0.6
scatter_kws = { 's' : point_size, 'alpha' : alpha }
line_kws = { 'linewidth' : 0.9 }
exp_colname = 'Experimental ddG'
pred_colname = 'Rosetta Score'
df = df.rename( columns = {'ExperimentalDDG' : exp_colname} )
df = df.rename( columns = {'total' : pred_colname} )
if max_backrub_step != None:
df = df.loc[ df['ScoreMethodID'] <= max_backrub_step ]
sns.set_style("white")
fig = plt.figure(
figsize = [10.0, 8.5], dpi=600
)
fig.subplots_adjust( wspace = 0.6, hspace = 0.3)
# fig.suptitle('$\Delta\Delta G$ prediction performance vs. number of structural ensemble members', fontsize=20)
r_axes = []
r_min = float('inf')
r_max = float('-inf')
mae_axes = []