File size: 5,474 Bytes
34393ef
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
import numpy as np
import matplotlib.pyplot as plt
import matplotlib.patches as mpatches
import seaborn as sns
import argparse

sns.set()
sns.set_style('ticks')

colors = ["#3c5068", "#acbab6", "#dcd3cd", "#d4a6a6"]

params = {'legend.fontsize': 32,
        'figure.figsize': (32, 10),
        'axes.labelsize': 34,
        'axes.titlesize':34,
        'xtick.labelsize':34,
        'ytick.labelsize':24}

#POSTER
params = {'legend.fontsize': 50,
        'figure.figsize': (54, 18),
        'axes.labelsize': 60,
        'axes.titlesize':60,
        'xtick.labelsize':60,
        'ytick.labelsize':36}

plt.rcParams.update(params)


np.random.seed(25)


DISPLAY_DIFF = True

K = 100

PREFIX = ''

# MRL, TE

TYPE = 'MRL'

DISPLAY_DIFF = True

if TYPE == 'REGULAR':
    PREFIX = 'outputs/'
elif TYPE == 'MIXED':
    PREFIX = 'outputs_mixed/'
elif TYPE == 'GC_CONTROLED':
    PREFIX = 'outputs/gc_'

if DISPLAY_DIFF:
    TYPE = 'MMRL'
    TITLE = "A"

    init = []
    with open(f'./../src/mrl_te_optimization/outputs/init_mrl_FMRL.txt') as f:
        scores = f.readlines()
        init = [float(score.replace('\n','')) for score in scores]

    opt = []
    with open(f'./../src/mrl_te_optimization/outputs/opt_mrl_FMRL.txt') as f:
        scores = f.readlines()
        opt = [float(score.replace('\n','')) for score in scores]


    init = np.array(init)
    opt = np.array(opt)

    diffs = (opt - init)/init

    print("FramePool MRL optimization:")
    print(f"Average Opt: {np.average(opt)}")
    print(f"Average Init: {np.average(init)}")
    print(f"Max Opt: {np.max(opt)}")
    print(f"Max Init: {np.max(init)}")
    print(f"Max Increase (wrt Init) : {np.max(opt/init)}")
    print(f"Average Increase (wrt Init) : {np.mean(opt/init)}")
    print(f"Average Percent Increase (wrt Init): {np.average(diffs)}")

    indices = np.argsort(opt)[::-1]

    init_large = []
    init_small = []
    opt_large = []
    opt_small = []

    for i in range(len(indices)):
        if diffs[indices[i]] >= 0:
            init_small.append(init[indices[i]])
            init_large.append(0)
            opt_small.append(0)
            opt_large.append(opt[indices[i]])
        else:
            init_large.append(init[indices[i]])
            init_small.append(0)
            opt_large.append(0)
            opt_small.append(opt[indices[i]])

    width = 1.0/(len(indices))
    bins = [(i+1) * width for i in range(len(indices))]
    
    ns = [i * width for i in range(len(indices))]
    fig, axs = plt.subplots(1,2)

    axs[0].bar(x=ns, bottom=0, width=width, height=opt_large, color=colors[0], edgecolor="white")
    axs[0].bar(x=ns, bottom=0, width=width, height=opt_small, color=colors[0], edgecolor="white")
    axs[0].bar(x=ns, bottom=0, width=width, height=init_small, color=colors[3], edgecolor="white")
    axs[0].bar(x=ns, bottom=0, width=width, height=init_large, color=colors[3], edgecolor="white")

    axs[0].set_title(TITLE,loc='left',weight='bold',fontsize=64)
    axs[0].set_xticks([])
    
    TYPE = "FMRL"
    TITLE = "B"

    init = []

    with open(f'./../src/mrl_te_optimization/outputs/init_mrl_TE.txt') as f:
        scores = f.readlines()
        init = [float(score.replace('\n','')) for score in scores]

    opt = []
    with open(f'./../src/mrl_te_optimization/outputs/opt_mrl_TE.txt') as f:
        scores = f.readlines()
        opt = [float(score.replace('\n','')) for score in scores]


    init = np.power(10,init)
    init = np.array(init)
    opt = np.power(10,opt)
    opt = np.array(opt)
    
    diffs = (opt - init)/init

    print("MTtrans 3R TE optimization:")
    print(f"Average Opt: {np.average(opt)}")
    print(f"Average Init: {np.average(init)}")
    print(f"Max Opt: {np.max(opt)}")
    print(f"Max Init: {np.max(init)}")
    print(f"Max Increase (wrt Init) : {np.max(opt/init)}")
    print(f"Average Increase (wrt Init) : {np.mean(opt/init)}")
    print(f"Max Increase (wrt Natural) : {np.max(opt/np.power(10,-0.63))}")
    print(f"Average Percent Increase (wrt Init): {np.average(diffs)}")

    indices = np.argsort(opt)[::-1]

    init_large = []
    init_small = []
    opt_large = []
    opt_small = []

    for i in range(len(indices)):
        if diffs[indices[i]] >= 0:
            init_small.append(init[indices[i]])
            init_large.append(0)
            opt_small.append(0)
            opt_large.append(opt[indices[i]])
        else:
            init_large.append(init[indices[i]])
            init_small.append(0)
            opt_large.append(0)
            opt_small.append(opt[indices[i]])

    axs[1].bar(x=ns, bottom=0, width=width, height=opt_large, color=colors[0], edgecolor="white")
    axs[1].bar(x=ns, bottom=0, width=width, height=opt_small, color=colors[0], edgecolor="white")
    axs[1].bar(x=ns, bottom=0, width=width, height=init_small, color=colors[3], edgecolor="white")
    axs[1].bar(x=ns, bottom=0, width=width, height=init_large, color=colors[3], edgecolor="white")
    axs[1].set_title(TITLE,loc='left',weight='bold',fontsize=64)
    axs[1].set_xticks([])

    orange_patch = mpatches.Patch(color=colors[3], label='Initial')
    blue_patch = mpatches.Patch(color=colors[0], label='Optimized')
    fig.legend(handles=[orange_patch,blue_patch],loc='upper right')

    axs[0].set_ylabel('Predicted MRL')
    axs[1].set_ylabel('Predicted TE')
    
    axs[0].set_xlabel('UTR Samples')
    axs[1].set_xlabel('UTR Samples')

    fig.tight_layout()

    plt.savefig(f'./plots/mrl_te_all.png')