Commit 3c461bd0 authored by Carlos GO's avatar Carlos GO
Browse files

plotting script

parent 4b556f0c
import sys
import numpy as np
import numpy
from mayavi import mlab
import matplotlib.pyplot as plt
R = 0.0019872041
T = 310.15
def landscape_plot(beta=1, alpha=1):
x = np.linspace(-80, 0, 200)
y = np.linspace(0, 1, 200)
xx, yy = np.meshgrid(x, y)
z = np.exp((-1 * beta * xx) / (R*T) - (alpha * yy))
# z = (-1 * beta * xx) - (alpha * yy)
plt.plot(np.exp(-1 * beta * x / (R*T)))
plt.show()
plt.scatter(xx,yy, c=z)
plt.xlabel("Energy")
plt.ylabel("Unpaired")
plt.title("beta=0.01, alpha=1 unpaired fitness")
cb = plt.colorbar()
cb.set_label("Fitness")
plt.show()
sys.exit()
print(z)
mlab.figure(bgcolor=(1,1,1))
mlab.surf(x, y, z )
mlab.axes(xlabel='energy', ylabel='paired', zlabel='fitness', color=(0,0,0))
mlab.show()
if __name__ == "__main__":
landscape_plot(beta=.01, alpha=1)
pass
......@@ -21,26 +21,31 @@ def struc_plot(dfs, sse='multi', mode='mutations'):
# dfs = (structure_info(df) for df in dfs)
# strucs = pd.concat(dfs).groupby(mode).mean()
# pickle.dump(strucs, open("lehm_df_muts.csv", "wb"))
strucs = pickle.load(open("lehm_df_muts.csv", "rb"))
strucs = pickle.load(open(f"Data/lin2_df_{mode}.pickle", "rb"))
sse_mean = strucs[sse]
# k = 100
# s_l = list(sse_mean)
# bins = [np.mean(s_l[i:i+k]) for i in range(0, len(s_l) - k)]
sns.tsplot(sse_mean)
plt.xlabel("Multiloops")
plt.ylabel("Energy")
plt.title("Energy based mutation rate")
# plt.savefig("multi_lehm_mut.pdf", format="pdf")
# sns.tsplot(bins)
plt.xlabel(f"{mode}")
plt.ylabel(f"{sse}")
plt.title("linear mutation rate")
# plt.savefig(f"Figures/stnd1_{mode}_{sse}.pdf", format="pdf")
plt.show()
# print(sse_mean)
def mut_plot():
sig = lambda e: 1 / (3 + np.exp(-e/15))
# sig = lambda e: 1 / (3 + np.exp(-e/15))
sig = lambda e: 1 / (80 + np.exp(-e/25))
print(sig(-80))
plt.plot([sig(x) for x in np.arange(-80, 0, 1)])
plt.xticks(np.arange(0, 80, 10), np.arange(-80, 0, 10))
plt.show()
if __name__ == "__main__":
path = "maternal_50_adaptive_0.csv"
# path = "maternal_50_.adaptive_0.csv"
dfs = (pd.read_csv(f"maternal_lehm_{i}.csv") for i in range(20))
struc_plot(dfs, sse='multi', mode='mutations')
struc_plot(dfs, sse='multi', mode='generation')
# mut_plot()
pass
import sys
import matplotlib.pyplot as plt
import numpy as np
import pandas as pd
plt.style.use('fivethirtyeight')
labels = {'orig': 'original',
'lin2': 'energy-mut',
'norm': 'gauss-fitness',
'nosel3': 'no-selecion',
'unp': 'unpaired-objective',
'beta01': 'beta=0.1'}
def maternal_plot(exps, feature='multi', mode='mutations'):
for e in exps:
df = pd.read_csv(f"Data/{e}_df_{mode}_mean.csv")
plt.plot(df[feature], label=f'{labels[e]}')
plt.xlabel(mode)
plt.ylabel(feature)
plt.legend()
plt.tight_layout()
plt.show()
pass
def subfigs(exps, dim1, dim2, mode='mutations', feature='multi'):
count = 1
modes = ['mutations']
features = ['multi', 'energy']
for mode in modes:
for feature in features:
plt.subplot(len(modes), len(features), count)
count += 1
for e in exps:
df = pd.read_csv(f"Data/{e}_df_{mode}_mean.csv")
plt.plot(df[feature], label=f'{labels[e]}')
plt.ylabel(feature)
plt.xlabel(mode)
plt.legend()
plt.tight_layout()
plt.show()
if __name__ == "__main__":
exps = ['orig', 'unp', 'nosel3', 'norm', 'beta01', 'lin2']
# maternal_plot(exps, feature='entropy')
subfigs(exps, 2, 3)
pass
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment