Start preparing manuscript.tex towards submission format and working on code
This commit is contained in:
@@ -4,45 +4,236 @@ import json
|
||||
import os
|
||||
import numpy as np
|
||||
from ast import literal_eval
|
||||
import string
|
||||
import matplotlib.cm as cm
|
||||
# import Code.csv_generation.SA_collection
|
||||
# todo: run some and test
|
||||
# todo: Model fI, rheo_{}_corr, AUC_{}_corr
|
||||
# %% rheo_{}_ex.csv, AUC_{}_ex.csv
|
||||
|
||||
## AUC ###################
|
||||
AUC_shift = pd.DataFrame(columns=['alteration', 'RS Pyramidal', 'RS Inhibitory', 'FS', 'IB',
|
||||
'RS Pyramidal +$K_V1.1$','RS Inhibitory +$K_V1.1$', 'FS +$K_V1.1$','Cb stellate',
|
||||
'Cb stellate +$K_V1.1$', 'Cb stellate $\Delta$$K_V1.1$', 'STN', 'STN +$K_V1.1$',
|
||||
'STN $\Delta$$K_V1.1$'])
|
||||
|
||||
AUC_slope = pd.DataFrame(columns=['alteration', 'RS Pyramidal', 'RS Inhibitory', 'FS', 'IB',
|
||||
'RS Pyramidal +$K_V1.1$','RS Inhibitory +$K_V1.1$', 'FS +$K_V1.1$','Cb stellate',
|
||||
'Cb stellate +$K_V1.1$', 'Cb stellate $\Delta$$K_V1.1$', 'STN', 'STN +$K_V1.1$',
|
||||
'STN $\Delta$$K_V1.1$'])
|
||||
|
||||
AUC_g = pd.DataFrame(columns=['alteration', 'RS Pyramidal', 'RS Inhibitory', 'FS', 'IB',
|
||||
'RS Pyramidal +$K_V1.1$','RS Inhibitory +$K_V1.1$', 'FS +$K_V1.1$','Cb stellate',
|
||||
'Cb stellate +$K_V1.1$', 'Cb stellate $\Delta$$K_V1.1$', 'STN', 'STN +$K_V1.1$',
|
||||
'STN $\Delta$$K_V1.1$'])
|
||||
|
||||
script_dir = os.path.dirname(os.path.realpath("__file__"))
|
||||
fname = os.path.join(script_dir, )
|
||||
# f = h5py.File(fname, "r")
|
||||
|
||||
models = ['RS_pyramidal', 'RS_inhib', 'FS','RS_pyramidal_Kv', 'RS_inhib_Kv', 'FS_Kv', 'Cb_stellate','Cb_stellate_Kv',
|
||||
'Cb_stellate_Kv_only','STN','STN_Kv', 'STN_Kv_only']
|
||||
model_labels = ['RS Pyramidal','RS Inhibitory', 'FS','RS Pyramidal +$K_V1.1$','RS Inhibitory +$K_V1.1$',
|
||||
'FS +$K_V1.1$','Cb stellate','Cb stellate +$K_V1.1$',
|
||||
'Cb stellate $\Delta$$K_V1.1$','STN','STN +$K_V1.1$', 'STN $\Delta$$K_V1.1$']
|
||||
|
||||
|
||||
|
||||
shift_interest = 'n'
|
||||
for i in range(len(models)):
|
||||
with open('../Sensitivity_Analysis/Data/SA_summary_df/{}_shift_AUC.json'.format(models[i])) as json_file:
|
||||
data = pd.read_json(json_file, convert_dates=False, convert_axes=False)
|
||||
data.replace(0., np.NaN, inplace=True)
|
||||
data = (data - data.loc['0', :])/ data.loc['0', :] # normalize AUC
|
||||
data.sort_index(inplace=True)
|
||||
AUC_shift[model_labels[i]] =data[shift_interest]
|
||||
AUC_shift['alteration'] = AUC_shift.index
|
||||
|
||||
|
||||
|
||||
slope_interest = 's'
|
||||
for i in range(len(models)):
|
||||
with open('../Sensitivity_Analysis/Data/SA_summary_df/{}_slope_AUC.json'.format(models[i])) as json_file:
|
||||
data = pd.read_json(json_file, convert_dates=False, convert_axes=False)
|
||||
data.replace(0., np.NaN, inplace=True)
|
||||
data = (data - data.loc['1.0', :])/ data.loc['1.0', :] # normalize AUC
|
||||
data.sort_index(inplace=True)
|
||||
try:
|
||||
AUC_slope[model_labels[i]] = data[slope_interest]
|
||||
except:
|
||||
pass
|
||||
AUC_slope['alteration'] = AUC_slope.index
|
||||
|
||||
g_interest = 'Kd'
|
||||
for i in range(len(models)):
|
||||
with open('../Sensitivity_Analysis/Data/SA_summary_df/{}_g_AUC.json'.format(models[i])) as json_file:
|
||||
data = pd.read_json(json_file, convert_dates=False, convert_axes=False)
|
||||
data.replace(0., np.NaN, inplace=True)
|
||||
data = (data - data.loc['1.0', :])/ data.loc['1.0', :] # normalize AUC
|
||||
data.sort_index(inplace=True)
|
||||
AUC_g[model_labels[i]] =data[g_interest]
|
||||
AUC_g['alteration'] = AUC_g.index
|
||||
|
||||
AUC_shift.to_csv('AUC_shift_ex.csv')
|
||||
AUC_slope.to_csv('AUC_slope_ex.csv')
|
||||
AUC_g.to_csv('AUC_g_ex.csv')
|
||||
|
||||
|
||||
## rheobase ###################
|
||||
|
||||
rheo_shift = pd.DataFrame(columns=['alteration', 'RS Pyramidal', 'RS Inhibitory', 'FS', 'IB',
|
||||
'RS Pyramidal +$K_V1.1$','RS Inhibitory +$K_V1.1$', 'FS +$K_V1.1$','Cb stellate',
|
||||
'Cb stellate +$K_V1.1$', 'Cb stellate $\Delta$$K_V1.1$', 'STN', 'STN +$K_V1.1$',
|
||||
'STN $\Delta$$K_V1.1$'])
|
||||
|
||||
rheo_slope = pd.DataFrame(columns=['alteration', 'RS Pyramidal', 'RS Inhibitory', 'FS', 'RS Pyramidal +$K_V1.1$',
|
||||
'RS Inhibitory +$K_V1.1$', 'FS +$K_V1.1$', 'Cb stellate', 'Cb stellate +$K_V1.1$',
|
||||
'Cb stellate $\Delta$$K_V1.1$', 'STN', 'STN +$K_V1.1$','STN $\Delta$$K_V1.1$'])
|
||||
|
||||
rheo_g = pd.DataFrame(columns=['alteration', 'RS Pyramidal', 'RS Inhibitory', 'FS', 'IB',
|
||||
'RS Pyramidal +$K_V1.1$','RS Inhibitory +$K_V1.1$', 'FS +$K_V1.1$','Cb stellate',
|
||||
'Cb stellate +$K_V1.1$', 'Cb stellate $\Delta$$K_V1.1$', 'STN', 'STN +$K_V1.1$',
|
||||
'STN $\Delta$$K_V1.1$'])
|
||||
|
||||
script_dir = os.path.dirname(os.path.realpath("__file__"))
|
||||
fname = os.path.join(script_dir, )
|
||||
|
||||
models = ['RS_pyramidal', 'RS_inhib', 'FS', 'RS_pyramidal_Kv', 'RS_inhib_Kv', 'FS_Kv', 'Cb_stellate', 'Cb_stellate_Kv', 'Cb_stellate_Kv_only', 'STN',
|
||||
'STN_Kv',
|
||||
'STN_Kv_only']
|
||||
model_labels = ['RS Pyramidal','RS Inhibitory', 'FS','RS Pyramidal +$K_V1.1$', 'RS Inhibitory +$K_V1.1$', 'FS +$K_V1.1$',
|
||||
'Cb stellate', 'Cb stellate +$K_V1.1$', 'Cb stellate $\Delta$$K_V1.1$', 'STN', 'STN +$K_V1.1$',
|
||||
'STN $\Delta$$K_V1.1$']
|
||||
|
||||
shift_interest = 's'
|
||||
for i in range(len(models)):
|
||||
with open('../Sensitivity_Analysis/Data/SA_summary_df/{}_shift_rheo.json'.format(models[i])) as json_file:
|
||||
data = pd.read_json(json_file, convert_dates=False, convert_axes=False)
|
||||
data.replace(0., np.NaN, inplace=True)
|
||||
data = (data - data.loc['0', :]) #/ data.loc['0', :] # normalize AUC
|
||||
data.sort_index(inplace=True)
|
||||
try:
|
||||
rheo_shift[model_labels[i]] = data[shift_interest]
|
||||
except:
|
||||
pass
|
||||
rheo_shift['alteration'] = rheo_shift.index
|
||||
|
||||
slope_interest = 'u'
|
||||
for i in range(len(models)):
|
||||
with open('../Sensitivity_Analysis/Data/SA_summary_df/{}_slope_rheo.json'.format(models[i])) as json_file:
|
||||
|
||||
data = pd.read_json(json_file, convert_dates=False, convert_axes=False)
|
||||
data.replace(0., np.NaN, inplace=True)
|
||||
data = (data - data.loc['1.0', :]) #/ data.loc['1.0', :] # normalize AUC
|
||||
data.sort_index(inplace=True)
|
||||
try:
|
||||
rheo_slope[model_labels[i]] = data[slope_interest]
|
||||
except:
|
||||
pass
|
||||
rheo_slope['alteration'] = rheo_slope.index
|
||||
|
||||
g_interest = 'Leak'
|
||||
for i in range(len(models)):
|
||||
with open('../Sensitivity_Analysis/Data/SA_summary_df/{}_g_rheo.json'.format(models[i])) as json_file:
|
||||
data = pd.read_json(json_file, convert_dates=False, convert_axes=False)
|
||||
data.replace(0., np.NaN, inplace=True)
|
||||
data = (data - data.loc['1.0', :]) #/ data.loc['1.0', :] # normalize AUC
|
||||
data.sort_index(inplace=True)
|
||||
rheo_g[model_labels[i]] = data[g_interest]
|
||||
rheo_g['alteration'] = rheo_g.index
|
||||
|
||||
|
||||
rheo_shift.to_csv('rheo_shift_ex.csv')
|
||||
rheo_slope.to_csv('rheo_slope_ex.csv')
|
||||
rheo_g.to_csv('rheo_g_ex.csv')
|
||||
|
||||
|
||||
# %% todo: Model fI
|
||||
# for each model
|
||||
# | (index) | mag | alt | type | F | I |
|
||||
# | 0 | -10 | m | shift | array | array |
|
||||
models = ['RS_pyramidal', 'RS_inhib', 'FS', 'RS_pyramidal_Kv', 'RS_inhib_Kv', 'FS_Kv', 'Cb_stellate', 'Cb_stellate_Kv',
|
||||
'Cb_stellate_Kv_only', 'STN', 'STN_Kv', 'STN_Kv_only']
|
||||
model_names = ['RS pyramidal', 'RS inhibitory', 'FS', 'RS pyramidal +Kv1.1', 'RS inhibitory +Kv1.1', 'FS +Kv1.1',
|
||||
'Cb stellate', 'Cb stellate +Kv1.1', 'Cb stellate $\Delta$Kv1.1', 'STN', 'STN +Kv1.1',
|
||||
'STN $\Delta$Kv1.1']
|
||||
# for each model get csv file with all shifts, scale and g
|
||||
for model_name in models:
|
||||
df = pd.DataFrame(columns=['mag', 'alt', 'type', 'F', 'I'])
|
||||
folder = '../Neuron_models/{}'.format(model_name)
|
||||
fname = os.path.join(folder, "{}.hdf5".format(model_name))
|
||||
# for each alt in model
|
||||
# with h5py.File(fname, "r+") as f:
|
||||
# df.loc[model_name, 'alt'] = f['data'].attrs['alteration']
|
||||
# test = f['data'].attrs['alteration_info'].replace(' ', ',')
|
||||
# alt_info = literal_eval(test)
|
||||
# var = alt_info[0]
|
||||
# alt_type = alt_info[1]
|
||||
# df.loc[model_name, 'mag'] = var
|
||||
# df.loc[model_name, 'type'] = alt_type
|
||||
# df.loc[model_name, 'F'] = f['analysis']['F_inf'][:]
|
||||
# I_mag = np.arange(f['data'].attrs['I_low'], f['data'].attrs['I_high'],
|
||||
# (f['data'].attrs['I_high'] - f['data'].attrs['I_low']) / f['data'].attrs['stim_num']) * 1000
|
||||
# df.loc[model_name, 'I'] = I
|
||||
# df.to_csv('./Model_fI/{}.csv'.format(model_name))
|
||||
# %% todo: rheo/AUC_{}_corr
|
||||
# | (index) | model | corr | p_value | g | color
|
||||
rheo_corr = pd.DataFrame(columns=['model', 'corr', 'p_value', 'g', 'color'])
|
||||
rheo_corr.to_csv('rheo_corr.csv')
|
||||
|
||||
AUC_corr = pd.DataFrame(columns=['model', 'corr', 'p_value', 'g', 'color'])
|
||||
AUC_corr.to_csv('AUC_corr.csv')
|
||||
models = ['RS Pyramidal', 'RS Inhibitory', 'FS', 'RS Pyramidal +$\mathrm{K}_{\mathrm{V}}\mathrm{1.1}$',
|
||||
'RS Inhibitory +$\mathrm{K}_{\mathrm{V}}\mathrm{1.1}$', 'FS +$\mathrm{K}_{\mathrm{V}}\mathrm{1.1}$',
|
||||
'Cb stellate', 'Cb stellate +$\mathrm{K}_{\mathrm{V}}\mathrm{1.1}$',
|
||||
'Cb stellate $\Delta$$\mathrm{K}_{\mathrm{V}}\mathrm{1.1}$', 'STN',
|
||||
'STN +$\mathrm{K}_{\mathrm{V}}\mathrm{1.1}$', 'STN $\Delta$$\mathrm{K}_{\mathrm{V}}\mathrm{1.1}$']
|
||||
|
||||
# %% firing_values.csv,model_spiking.csv, model_F_inf.csv # DONE ####################################################
|
||||
model_save_name = {'RS Pyramidal': 'RS_pyr_posp', 'RS Inhibitory': 'RS_inhib_posp', 'FS': 'FS_posp',
|
||||
'RS Pyramidal +$\mathrm{K}_{\mathrm{V}}\mathrm{1.1}$':'RS_pyr_Kv',
|
||||
'RS Inhibitory +$\mathrm{K}_{\mathrm{V}}\mathrm{1.1}$':'RS_inhib_Kv',
|
||||
'FS +$\mathrm{K}_{\mathrm{V}}\mathrm{1.1}$':'FS_Kv',
|
||||
'Cb stellate': 'Cb_stellate',
|
||||
'Cb stellate +$\mathrm{K}_{\mathrm{V}}\mathrm{1.1}$':'Cb_stellate_Kv',
|
||||
'Cb stellate $\Delta$$\mathrm{K}_{\mathrm{V}}\mathrm{1.1}$':'Cb_stellate_Kv_only',
|
||||
'STN': 'STN',
|
||||
'STN +$\mathrm{K}_{\mathrm{V}}\mathrm{1.1}$': 'STN_Kv',
|
||||
'STN $\Delta$$\mathrm{K}_{\mathrm{V}}\mathrm{1.1}$': 'STN_Kv_only'}
|
||||
top_file_dir = '../Sensitivity_Analysis/Data'
|
||||
data_dir = {'RS Pyramidal': os.path.join(top_file_dir, 'RS_pyramidal_{}_fI.json'),
|
||||
'RS Inhibitory': os.path.join(top_file_dir, 'RS_inhib_{}_fI.json'),
|
||||
'FS': os.path.join(top_file_dir, 'FS_{}_fI.json'),
|
||||
'RS Pyramidal +$\mathrm{K}_{\mathrm{V}}\mathrm{1.1}$': os.path.join(top_file_dir, 'RS_pyramidal_{}_fI.json'),
|
||||
'RS Inhibitory +$\mathrm{K}_{\mathrm{V}}\mathrm{1.1}$': os.path.join(top_file_dir, 'RS_inhib_{}_fI.json'),
|
||||
'FS +$\mathrm{K}_{\mathrm{V}}\mathrm{1.1}$': os.path.join(top_file_dir, 'FS_{}_fI.json'),
|
||||
'Cb stellate': os.path.join(top_file_dir, 'Cb_stellate_{}_fI.json'),
|
||||
'Cb stellate +$\mathrm{K}_{\mathrm{V}}\mathrm{1.1}$': os.path.join(top_file_dir, 'Cb_stellate_Kv_{}_fI.json'),
|
||||
'Cb stellate $\Delta$$\mathrm{K}_{\mathrm{V}}\mathrm{1.1}$': os.path.join(top_file_dir, 'Cb_stellate_Kv_only_{}_fI.json'),
|
||||
'STN': os.path.join(top_file_dir, 'STN_{}_fI.json'),
|
||||
'STN +$\mathrm{K}_{\mathrm{V}}\mathrm{1.1}$': os.path.join(top_file_dir, 'STN_Kv_{}_fI.json'),
|
||||
'STN $\Delta$$\mathrm{K}_{\mathrm{V}}\mathrm{1.1}$': os.path.join(top_file_dir, 'STN_Kv_only_{}_fI.json')}
|
||||
|
||||
I_dir = {'RS Pyramidal': os.path.join(top_file_dir, 'RS_pyramidal_{}_I_mag.json'),
|
||||
'RS Inhibitory': os.path.join(top_file_dir, 'RS_pyramidal_{}_I_mag.json'),
|
||||
'FS': os.path.join(top_file_dir, 'RS_pyramidal_{}_I_mag.json'),
|
||||
'RS Pyramidal +$\mathrm{K}_{\mathrm{V}}\mathrm{1.1}$': os.path.join(top_file_dir, 'RS_pyramidal_{}_I_mag.json'),
|
||||
'RS Inhibitory +$\mathrm{K}_{\mathrm{V}}\mathrm{1.1}$': os.path.join(top_file_dir, 'RS_inhib_{}_I_mag.json'),
|
||||
'FS +$\mathrm{K}_{\mathrm{V}}\mathrm{1.1}$': os.path.join(top_file_dir, 'FS_{}_I_mag.json'),
|
||||
'Cb stellate': os.path.join(top_file_dir, 'Cb_stellate_{}_I_mag.json'),
|
||||
'Cb stellate +$\mathrm{K}_{\mathrm{V}}\mathrm{1.1}$': os.path.join(top_file_dir, 'Cb_stellate_Kv_{}_I_mag.json'),
|
||||
'Cb stellate $\Delta$$\mathrm{K}_{\mathrm{V}}\mathrm{1.1}$': os.path.join(top_file_dir, 'Cb_stellate_Kv_only_{}_I_mag.json'),
|
||||
'STN': os.path.join(top_file_dir, 'STN_{}_I_mag.json'),
|
||||
'STN +$\mathrm{K}_{\mathrm{V}}\mathrm{1.1}$': os.path.join(top_file_dir, 'STN_Kv_{}_I_mag.json'),
|
||||
'STN $\Delta$$\mathrm{K}_{\mathrm{V}}\mathrm{1.1}$': os.path.join(top_file_dir, 'STN_Kv_only_{}_I_mag.json')}
|
||||
|
||||
|
||||
def concat_dfs(df, data_dir, I_dir, type='shift'):
|
||||
with open(data_dir.format(type)) as json_file:
|
||||
data = pd.read_json(json_file, convert_axes=False)
|
||||
with open(I_dir.format(type)) as json_file:
|
||||
I = pd.read_json(json_file, convert_axes=False)
|
||||
for c in data.columns:
|
||||
# print(c)
|
||||
df = df.append(pd.DataFrame(data=(np.array([data.index,['{}'.format(c) for i in range(0, len(data[c]))],
|
||||
[type for i in range(0, len(data[c]))], data[c], I[c]]).T),
|
||||
columns=['mag','alt', 'type', 'F', 'I']))
|
||||
return df
|
||||
|
||||
|
||||
summary_df = pd.DataFrame(columns=['mag','alt', 'type', 'F', 'I'])
|
||||
for m in models:
|
||||
print(m)
|
||||
df = pd.DataFrame(columns=['mag','alt', 'type', 'F', 'I'])
|
||||
df = concat_dfs(df, data_dir[m], I_dir[m], type='shift')
|
||||
df = concat_dfs(df, data_dir[m], I_dir[m], type='slope')
|
||||
df = concat_dfs(df, data_dir[m], I_dir[m], type='g')
|
||||
folder = os.path.join(os.path.dirname(os.path.realpath("__file__")), 'Model_fI')
|
||||
if not os.path.isdir(folder):
|
||||
os.makedirs(folder)
|
||||
df.to_csv(os.path.join(folder, '{}_fI.csv'.format(model_save_name[m])))
|
||||
|
||||
# #%% todo: rheo/AUC_{}_corr - done in SA_collection.py
|
||||
# # | (index) | model | corr | p_value | g | color
|
||||
#
|
||||
# # in rheo_[]_corr.csv and AUC_[]_corr.csv
|
||||
# # columns=['model', 'corr', 'p_value', 'local corr', 'local p_value', 'ratio', '$\Delta V_{1/2}$', 'color']
|
||||
#
|
||||
# rheo_corr = pd.DataFrame(columns=['model', 'corr', 'p_value', 'g', 'color'])
|
||||
# rheo_corr.to_csv('rheo_corr.csv')
|
||||
#
|
||||
# AUC_corr = pd.DataFrame(columns=['model', 'corr', 'p_value', 'g', 'color'])
|
||||
# AUC_corr.to_csv('AUC_corr.csv')
|
||||
|
||||
# %% firing_values.csv,model_spiking.csv, model_F_inf.csv
|
||||
import numpy as np
|
||||
import pandas as pd
|
||||
|
||||
@@ -52,9 +243,6 @@ model_names = ['RS pyramidal', 'RS inhibitory', 'FS', 'RS pyramidal +Kv1.1', 'RS
|
||||
'Cb stellate', 'Cb stellate +Kv1.1', 'Cb stellate $\Delta$Kv1.1', 'STN', 'STN +Kv1.1',
|
||||
'STN $\Delta$Kv1.1']
|
||||
firing_values = pd.DataFrame(columns=models, index=['spike_ind', 'ramp_up', 'ramp_down'])
|
||||
# firing_values.loc['spike_ind', :] = np.array(
|
||||
# [0.3, 0.04375, 0.25, 0.3, 0.0875, 0.25, 0.3, 0.65, 0.375, 0.125, 0.475, 0.4])
|
||||
|
||||
models = ['RS_pyr', 'RS_pyr_Kv', 'RS_inhib', 'RS_inhib_Kv', 'FS', 'FS_Kv',
|
||||
'Cb_stellate', 'Cb_stellate_Kv', 'Cb_stellate_Delta_Kv',
|
||||
'STN', 'STN_Kv', 'STN_Delta_Kv']
|
||||
@@ -65,7 +253,6 @@ col_names = ['t']
|
||||
for mod in models: col_names.append(mod)
|
||||
spiking = pd.DataFrame(columns=col_names)
|
||||
|
||||
|
||||
# index for example trace
|
||||
spike_ind = {'RS_pyramidal': 60, 'RS_inhib':25, 'FS':50, 'RS_pyramidal_Kv':60,
|
||||
'RS_inhib_Kv':50, 'FS_Kv':50, 'Cb_stellate':60, 'Cb_stellate_Kv':130,
|
||||
@@ -88,7 +275,7 @@ for model_name in models:
|
||||
firing_values.to_csv('firing_values.csv')
|
||||
spiking.to_csv('model_spiking.csv')
|
||||
model_F_inf.to_csv('model_F_inf.csv')
|
||||
# %% model_ramp.csv # DONE #########################################################################
|
||||
# %% model_ramp.csv
|
||||
# | (index) | t | models ....
|
||||
import numpy as np
|
||||
import pandas as pd
|
||||
@@ -114,9 +301,9 @@ for model_name in models:
|
||||
|
||||
model_ramp.to_csv('model_ramp.csv')
|
||||
|
||||
#%% sim_mut_AUC.csv, sim_mut_rheo.csv # DONE #########################################################################
|
||||
#%% sim_mut_AUC.csv, sim_mut_rheo.csv #
|
||||
# generate mutation plot data
|
||||
mutations = json.load(open("../mutations_effects_dict.json"))
|
||||
mutations = json.load(open("../KCNA1_mutations/mutations_effects_dict.json"))
|
||||
keys_to_remove = ['V408L', 'T226R', 'R239S', 'R324T']
|
||||
for key in keys_to_remove:
|
||||
del mutations[key]
|
||||
@@ -148,6 +335,3 @@ rheobase = (rheobase - rheobase.loc['WT', :]) /rheobase.loc['WT', :]
|
||||
AUC = (AUC - AUC.loc['WT', :]) /AUC.loc['WT', :]
|
||||
AUC.to_csv(os.path.join(save_folder, 'sim_mut_AUC.csv'))
|
||||
rheobase.to_csv(os.path.join(save_folder, 'sim_mut_rheobase.csv'))
|
||||
|
||||
|
||||
#########################################################################################################################
|
||||
|
||||
@@ -7,12 +7,12 @@ import json
|
||||
import scipy.stats as stats
|
||||
|
||||
# folder
|
||||
top_dir = '../Sensitivity_Analysis'
|
||||
#%% create JSON files for each alt type
|
||||
for dir_name in next(os.walk(top_dir))[1]:
|
||||
top_dir = '../Sensitivity_Analysis/Data'
|
||||
|
||||
#%% create JSON files for each alt type for each model in '../Sensitivity_Analysis/Data/SA_summary_df/file.json'
|
||||
for dir_name in next(os.walk(top_dir))[1]: # for each folder in top_file_dir (each model)
|
||||
folder = os.path.join(top_dir, dir_name)
|
||||
print(folder)
|
||||
|
||||
# for each alt_type create pd df
|
||||
shift_AUC = pd.DataFrame()
|
||||
shift_rheo = pd.DataFrame()
|
||||
@@ -122,12 +122,16 @@ alt_dict['Kv'] = '$K_V1.1$'
|
||||
alt_dict['A'] = 'A'
|
||||
alt_dict['Leak'] = 'Leak'
|
||||
|
||||
# models = directory names in top_file_dir and what json files are named
|
||||
models = ['RS_pyramidal', 'RS_inhib', 'FS', 'RS_pyramidal_Kv', 'RS_inhib_Kv', 'FS_Kv', 'Cb_stellate', 'Cb_stellate_Kv',
|
||||
'Cb_stellate_Kv_only', 'STN', 'STN_Kv', 'STN_Kv_only']
|
||||
# model_names = names of models for json files and ultimately csv files for plotting
|
||||
model_names = ['RS Pyramidal','RS Inhibitory','FS', 'RS Pyramidal +$K_V1.1$','RS Inhibitory +$K_V1.1$', 'FS +$K_V1.1$',
|
||||
'Cb stellate','Cb stellate +$K_V1.1$', 'Cb stellate $\Delta$$K_V1.1$','STN','STN +$K_V1.1$', 'STN $\Delta$$K_V1.1$']
|
||||
|
||||
models =['RS_pyramidal', 'RS_inhib', 'FS', 'IB','Cb_stellate','Cb_stellate_Kv','Cb_stellate_Kv_only','STN','STN_Kv','STN_Kv_only']
|
||||
model_names = ['RS pyramidal', 'RS inhibitory', 'FS', 'IB','Cb stellate','Cb stellate +$K_V1.1$','Cb stellate $\Delta$$K_V1.1$','STN','STN +$K_V1.1$','STN $\Delta$$K_V1.1$']
|
||||
shift_df = pd.DataFrame(columns=['model', 'corr', 'p_value', 'local corr', 'local p_value', 'ratio', '$\Delta V_{1/2}$', 'color']) # for boxplots
|
||||
for mod in range(len(models)):
|
||||
with open('./SA_summary_df/{}_shift_AUC.json'.format(models[mod])) as json_file:
|
||||
with open('../Sensitivity_Analysis/Data/SA_summary_df/{}_shift_AUC.json'.format(models[mod])) as json_file:
|
||||
df = pd.read_json(json_file)
|
||||
df.sort_index(inplace=True)
|
||||
df.replace(0., np.NaN, inplace=True)
|
||||
@@ -142,11 +146,16 @@ for mod in range(len(models)):
|
||||
shift_df = shift_df.append(pd.Series([model_names[mod], tau, p,tau_l, p_l, ratio_tau, alt_dict[c],clr_dict[models[mod]]], index=shift_df.columns), ignore_index=True)
|
||||
|
||||
|
||||
models =['RS_pyramidal', 'RS_inhib', 'FS', 'IB','Cb_stellate','Cb_stellate_Kv','Cb_stellate_Kv_only','STN','STN_Kv','STN_Kv_only']
|
||||
model_names = ['RS pyramidal', 'RS inhibitory', 'FS', 'IB','Cb stellate','Cb stellate +$K_V1.1$','Cb stellate $\Delta$$K_V1.1$','STN','STN +$K_V1.1$','STN $\Delta$$K_V1.1$']
|
||||
# models = directory names in top_file_dir and what json files are named
|
||||
models = ['RS_pyramidal', 'RS_inhib', 'FS', 'RS_pyramidal_Kv', 'RS_inhib_Kv', 'FS_Kv', 'Cb_stellate', 'Cb_stellate_Kv',
|
||||
'Cb_stellate_Kv_only', 'STN', 'STN_Kv', 'STN_Kv_only']
|
||||
# model_names = names of models for json files and ultimately csv files for plotting
|
||||
model_names = ['RS Pyramidal','RS Inhibitory','FS', 'RS Pyramidal +$K_V1.1$','RS Inhibitory +$K_V1.1$', 'FS +$K_V1.1$',
|
||||
'Cb stellate','Cb stellate +$K_V1.1$', 'Cb stellate $\Delta$$K_V1.1$','STN','STN +$K_V1.1$', 'STN $\Delta$$K_V1.1$']
|
||||
|
||||
slope_df = pd.DataFrame(columns=['model', 'corr', 'p_value','local corr', 'local p_value', 'ratio', 'Slope (k)', 'color']) # for boxplots
|
||||
for mod in range(len(models)):
|
||||
with open('./SA_summary_df/{}_slope_AUC.json'.format(models[mod])) as json_file:
|
||||
with open('../Sensitivity_Analysis/Data/SA_summary_df//{}_slope_AUC.json'.format(models[mod])) as json_file:
|
||||
df = pd.read_json(json_file, convert_dates=False, convert_axes=False)
|
||||
df.index = df.index.map(float)
|
||||
df.sort_index(inplace=True)
|
||||
@@ -161,11 +170,16 @@ for mod in range(len(models)):
|
||||
ratio_tau = tau_l/tau
|
||||
slope_df = slope_df.append(pd.Series([model_names[mod], tau, p, tau_l, p_l, ratio_tau, alt_dict[c],clr_dict[models[mod]]], index=slope_df.columns), ignore_index=True)
|
||||
|
||||
models =['RS_pyramidal', 'RS_inhib', 'FS', 'IB','Cb_stellate','Cb_stellate_Kv','Cb_stellate_Kv_only','STN','STN_Kv','STN_Kv_only']
|
||||
model_names = ['RS pyramidal', 'RS inhibitory', 'FS', 'IB','Cb stellate','Cb stellate +$K_V1.1$','Cb stellate $\Delta$$K_V1.1$','STN','STN +$K_V1.1$','STN $\Delta$$K_V1.1$']
|
||||
# models = directory names in top_file_dir and what json files are named
|
||||
models = ['RS_pyramidal', 'RS_inhib', 'FS', 'RS_pyramidal_Kv', 'RS_inhib_Kv', 'FS_Kv', 'Cb_stellate', 'Cb_stellate_Kv',
|
||||
'Cb_stellate_Kv_only', 'STN', 'STN_Kv', 'STN_Kv_only']
|
||||
# model_names = names of models for json files and ultimately csv files for plotting
|
||||
model_names = ['RS Pyramidal','RS Inhibitory','FS', 'RS Pyramidal +$K_V1.1$','RS Inhibitory +$K_V1.1$', 'FS +$K_V1.1$',
|
||||
'Cb stellate','Cb stellate +$K_V1.1$', 'Cb stellate $\Delta$$K_V1.1$','STN','STN +$K_V1.1$', 'STN $\Delta$$K_V1.1$']
|
||||
|
||||
g_df = pd.DataFrame(columns=['model', 'corr', 'p_value', 'local corr', 'local p_value', 'ratio', 'g', 'color']) # for boxplots
|
||||
for mod in range(len(models)):
|
||||
with open('./SA_summary_df/{}_g_AUC.json'.format(models[mod])) as json_file:
|
||||
with open('../Sensitivity_Analysis/Data/SA_summary_df//{}_g_AUC.json'.format(models[mod])) as json_file:
|
||||
df = pd.read_json(json_file, convert_dates=False, convert_axes=False)
|
||||
df.index = df.index.map(float)
|
||||
df.sort_index(inplace=True)
|
||||
@@ -182,16 +196,21 @@ for mod in range(len(models)):
|
||||
|
||||
shift_df.to_json('./Sensitivity_analysis/shift_box_kendall_corr.json')
|
||||
slope_df.to_json('./Sensitivity_analysis/slope_box_kendall_corr.json')
|
||||
g_df.to_json('./Sensitivity_analysis/g_box_kendall_corr.json')
|
||||
g_df.to_json('./Sensitivity_analysis/g_kendall_corr.json')
|
||||
|
||||
|
||||
#%% rheobase correlation analysis
|
||||
|
||||
models =['RS_pyramidal', 'RS_inhib', 'FS', 'IB','Cb_stellate','Cb_stellate_Kv','Cb_stellate_Kv_only','STN','STN_Kv','STN_Kv_only']
|
||||
model_names = ['RS pyramidal', 'RS inhibitory', 'FS', 'IB','Cb stellate','Cb stellate +$K_V1.1$','Cb stellate $\Delta$$K_V1.1$','STN','STN +$K_V1.1$','STN $\Delta$$K_V1.1$']
|
||||
# models = directory names in top_file_dir and what json files are named
|
||||
models = ['RS_pyramidal', 'RS_inhib', 'FS', 'RS_pyramidal_Kv', 'RS_inhib_Kv', 'FS_Kv', 'Cb_stellate', 'Cb_stellate_Kv',
|
||||
'Cb_stellate_Kv_only', 'STN', 'STN_Kv', 'STN_Kv_only']
|
||||
# model_names = names of models for json files and ultimately csv files for plotting
|
||||
model_names = ['RS Pyramidal','RS Inhibitory','FS', 'RS Pyramidal +$K_V1.1$','RS Inhibitory +$K_V1.1$', 'FS +$K_V1.1$',
|
||||
'Cb stellate','Cb stellate +$K_V1.1$', 'Cb stellate $\Delta$$K_V1.1$','STN','STN +$K_V1.1$', 'STN $\Delta$$K_V1.1$']
|
||||
|
||||
shift_df = pd.DataFrame(columns=['model', 'corr', 'p_value', 'local corr', 'local p_value', 'ratio', '$\Delta V_{1/2}$', 'color']) # for boxplots
|
||||
for mod in range(len(models)):
|
||||
with open('./SA_summary_df/{}_shift_rheo.json'.format(models[mod])) as json_file:
|
||||
with open('../Sensitivity_Analysis/Data/SA_summary_df//{}_shift_rheo.json'.format(models[mod])) as json_file:
|
||||
df = pd.read_json(json_file)
|
||||
df.sort_index(inplace=True)
|
||||
df.replace(0., np.NaN, inplace=True)
|
||||
@@ -206,11 +225,16 @@ for mod in range(len(models)):
|
||||
shift_df = shift_df.append(pd.Series([model_names[mod], tau, p,tau_l, p_l, ratio_tau, alt_dict[c],clr_dict[models[mod]]], index=shift_df.columns), ignore_index=True)
|
||||
|
||||
|
||||
models =['RS_pyramidal', 'RS_inhib', 'FS', 'IB','Cb_stellate','Cb_stellate_Kv','Cb_stellate_Kv_only','STN','STN_Kv','STN_Kv_only']
|
||||
model_names = ['RS pyramidal', 'RS inhibitory', 'FS', 'IB','Cb stellate','Cb stellate +$K_V1.1$','Cb stellate $\Delta$$K_V1.1$','STN','STN +$K_V1.1$','STN $\Delta$$K_V1.1$']
|
||||
# models = directory names in top_file_dir and what json files are named
|
||||
models = ['RS_pyramidal', 'RS_inhib', 'FS', 'RS_pyramidal_Kv', 'RS_inhib_Kv', 'FS_Kv', 'Cb_stellate', 'Cb_stellate_Kv',
|
||||
'Cb_stellate_Kv_only', 'STN', 'STN_Kv', 'STN_Kv_only']
|
||||
# model_names = names of models for json files and ultimately csv files for plotting
|
||||
model_names = ['RS Pyramidal','RS Inhibitory','FS', 'RS Pyramidal +$K_V1.1$','RS Inhibitory +$K_V1.1$', 'FS +$K_V1.1$',
|
||||
'Cb stellate','Cb stellate +$K_V1.1$', 'Cb stellate $\Delta$$K_V1.1$','STN','STN +$K_V1.1$', 'STN $\Delta$$K_V1.1$']
|
||||
|
||||
slope_df = pd.DataFrame(columns=['model', 'corr', 'p_value','local corr', 'local p_value', 'ratio', 'Slope (k)', 'color']) # for boxplots
|
||||
for mod in range(len(models)):
|
||||
with open('./SA_summary_df/{}_slope_rheo.json'.format(models[mod])) as json_file:
|
||||
with open('../Sensitivity_Analysis/Data/SA_summary_df//{}_slope_rheo.json'.format(models[mod])) as json_file:
|
||||
df = pd.read_json(json_file, convert_dates=False, convert_axes=False)
|
||||
df.index = df.index.map(float)
|
||||
df.sort_index(inplace=True)
|
||||
@@ -225,11 +249,16 @@ for mod in range(len(models)):
|
||||
ratio_tau = tau_l/tau
|
||||
slope_df = slope_df.append(pd.Series([model_names[mod], tau, p, tau_l, p_l, ratio_tau, alt_dict[c],clr_dict[models[mod]]], index=slope_df.columns), ignore_index=True)
|
||||
|
||||
models =['RS_pyramidal', 'RS_inhib', 'FS', 'IB','Cb_stellate','Cb_stellate_Kv','Cb_stellate_Kv_only','STN','STN_Kv','STN_Kv_only']
|
||||
model_names = ['RS pyramidal', 'RS inhibitory', 'FS', 'IB','Cb stellate','Cb stellate +$K_V1.1$','Cb stellate $\Delta$$K_V1.1$','STN','STN +$K_V1.1$','STN $\Delta$$K_V1.1$']
|
||||
# models = directory names in top_file_dir and what json files are named
|
||||
models = ['RS_pyramidal', 'RS_inhib', 'FS', 'RS_pyramidal_Kv', 'RS_inhib_Kv', 'FS_Kv', 'Cb_stellate', 'Cb_stellate_Kv',
|
||||
'Cb_stellate_Kv_only', 'STN', 'STN_Kv', 'STN_Kv_only']
|
||||
# model_names = names of models for json files and ultimately csv files for plotting
|
||||
model_names = ['RS Pyramidal','RS Inhibitory','FS', 'RS Pyramidal +$K_V1.1$','RS Inhibitory +$K_V1.1$', 'FS +$K_V1.1$',
|
||||
'Cb stellate','Cb stellate +$K_V1.1$', 'Cb stellate $\Delta$$K_V1.1$','STN','STN +$K_V1.1$', 'STN $\Delta$$K_V1.1$']
|
||||
|
||||
g_df = pd.DataFrame(columns=['model', 'corr', 'p_value', 'local corr', 'local p_value', 'ratio', 'g', 'color']) # for boxplots
|
||||
for mod in range(len(models)):
|
||||
with open('./SA_summary_df/{}_g_rheo.json'.format(models[mod])) as json_file:
|
||||
with open('../Sensitivity_Analysis/Data/SA_summary_df//{}_g_rheo.json'.format(models[mod])) as json_file:
|
||||
df = pd.read_json(json_file, convert_dates=False, convert_axes=False)
|
||||
df.index = df.index.map(float)
|
||||
df.sort_index(inplace=True)
|
||||
@@ -246,52 +275,29 @@ for mod in range(len(models)):
|
||||
|
||||
shift_df.to_json('./Sensitivity_analysis/rheo_shift_box_kendall_corr.json')
|
||||
slope_df.to_json('./Sensitivity_analysis/rheo_slope_box_kendall_corr.json')
|
||||
g_df.to_json('./Sensitivity_analysis/rheo_g_box_kendall_corr.json')
|
||||
g_df.to_json('./Sensitivity_analysis/rheo_g_kendall_corr.json')
|
||||
|
||||
|
||||
#%% todo: CREATE CSV FILES ###################################################################################################
|
||||
|
||||
# from ./Code/From_Neuronal_models/tau_analysis/AUC_corr_df_gen.py
|
||||
AUC_shift_df = pd.read_json('./Sensitivity_analysis/shift_box_kendall_corr_rel.json', orient='records')
|
||||
AUC_slope_df = pd.read_json('./Sensitivity_analysis/slope_box_kendall_corr_rel.json', orient='records') #, lines=True)
|
||||
AUC_g_df = pd.read_json('./Sensitivity_analysis/g_box_kendall_corr_rel.json', orient='records')
|
||||
# for i in np.array(['FS', 'IB', 'RS inhibitory', 'RS pyramidal']):
|
||||
# AUC_shift_df.loc[AUC_shift_df['model'] == i, 'model'] = i + ' +$K_V1.1$' # ''+$\mathrm{K}_{\mathrm{V}}\mathrm{1.1}$'
|
||||
# AUC_slope_df.loc[AUC_slope_df['model'] == i, 'model'] = i + ' +$K_V1.1$' #' +$\mathrm{K}_{\mathrm{V}}\mathrm{1.1}$'
|
||||
# AUC_g_df.loc[AUC_g_df['model'] == i, 'model'] = i + ' +$K_V1.1$' #' +$\mathrm{K}_{\mathrm{V}}\mathrm{1.1}$'
|
||||
|
||||
AUC_shift_df_posp = pd.read_json('./Sensitivity_analysis/shift_box_kendall_corr_rel_pospischil.json', orient='records')
|
||||
AUC_slope_df_posp = pd.read_json('./Sensitivity_analysis/slope_box_kendall_corr_rel_pospischil.json', orient='records') #, lines=True)
|
||||
AUC_g_df_posp = pd.read_json('./Sensitivity_analysis/g_box_kendall_corr_rel_pospischil.json', orient='records')
|
||||
|
||||
AUC_shift_df = AUC_shift_df.append(AUC_shift_df_posp)
|
||||
AUC_slope_df = AUC_slope_df.append(AUC_slope_df_posp)
|
||||
AUC_g_df = AUC_g_df.append(AUC_g_df_posp)
|
||||
|
||||
#% AUC
|
||||
AUC_shift_json = pd.read_json('./Sensitivity_analysis/shift_kendall_corr_rel.json', orient='records')
|
||||
AUC_slope_json = pd.read_json('./Sensitivity_analysis/slope_kendall_corr_rel.json', orient='records') #, lines=True)
|
||||
AUC_g_json = pd.read_json('./Sensitivity_analysis/g_kendall_corr_rel.json', orient='records')
|
||||
AUC_shift_df = AUC_shift_json[['model', 'corr', 'p_value', 'g', 'color']]
|
||||
AUC_slope_df = AUC_slope_json[['model', 'corr', 'p_value', 'g', 'color']]
|
||||
AUC_g_df = AUC_g_json[['model', 'corr', 'p_value', 'g', 'color']]
|
||||
AUC_shift_df.to_csv('AUC_shift_corr.csv')
|
||||
AUC_slope_df.to_csv('AUC_scale_corr.csv')
|
||||
AUC_g_df.to_csv('AUC_g_corr.csv')
|
||||
|
||||
|
||||
|
||||
#% rheo
|
||||
rheo_shift_df = pd.read_json('./Sensitivity_analysis/rheo_shift_box_kendall_corr.json', orient='records')
|
||||
rheo_slope_df = pd.read_json('./Sensitivity_analysis/rheo_slope_box_kendall_corr.json', orient='records') #, lines=True)
|
||||
rheo_g_df = pd.read_json('./Sensitivity_analysis/rheo_g_box_kendall_corr.json', orient='records')
|
||||
for i in np.array(['FS', 'IB', 'RS inhibitory', 'RS pyramidal']):
|
||||
rheo_shift_df.loc[rheo_shift_df['model'] == i, 'model'] = i + ' +$K_V1.1$' #' +$\mathrm{K}_{\mathrm{V}}\mathrm{1.1}$'
|
||||
rheo_slope_df.loc[rheo_slope_df['model'] == i, 'model'] = i + ' +$K_V1.1$' #' +$\mathrm{K}_{\mathrm{V}}\mathrm{1.1}$'
|
||||
rheo_g_df.loc[rheo_g_df['model'] == i, 'model'] = i + ' +$K_V1.1$' #' +$\mathrm{K}_{\mathrm{V}}\mathrm{1.1}$'
|
||||
|
||||
rheo_shift_df_posp = pd.read_json('./Sensitivity_analysis/rheo_shift_box_kendall_corr_pospischil.json', orient='records')
|
||||
rheo_slope_df_posp = pd.read_json('./Sensitivity_analysis/rheo_slope_box_kendall_corr_pospischil.json', orient='records') #, lines=True)
|
||||
rheo_g_df_posp = pd.read_json('./Sensitivity_analysis/rheo_g_box_kendall_corr_pospischil.json', orient='records')
|
||||
|
||||
|
||||
rheo_shift_df = rheo_shift_df.append(rheo_shift_df_posp)
|
||||
rheo_slope_df = rheo_slope_df.append(rheo_slope_df_posp)
|
||||
rheo_g_df = rheo_g_df.append(rheo_g_df_posp)
|
||||
|
||||
rheo_shift_json = pd.read_json('./Sensitivity_analysis/rheo_shift_kendall_corr.json', orient='records')
|
||||
rheo_slope_json = pd.read_json('./Sensitivity_analysis/rheo_slope_kendall_corr.json', orient='records') #, lines=True)
|
||||
rheo_g_json = pd.read_json('./Sensitivity_analysis/rheo_g_kendall_corr.json', orient='records')
|
||||
rheo_shift_df = rheo_shift_json[['model', 'corr', 'p_value', 'g', 'color']]
|
||||
rheo_slope_df = rheo_slope_json[['model', 'corr', 'p_value', 'g', 'color']]
|
||||
rheo_g_df = rheo_g_json[['model', 'corr', 'p_value', 'g', 'color']]
|
||||
rheo_shift_df.to_csv('rheo_shift_corr.csv')
|
||||
rheo_slope_df.to_csv('rheo_scale_corr.csv')
|
||||
rheo_g_df.to_csv('rheo_g_corr.csv')
|
||||
rheo_g_df.to_csv('rheo_g_corr.csv')
|
||||
|
||||
Reference in New Issue
Block a user