modified AUC_correlation, rheobase_correlation, ramp_firing

This commit is contained in:
nkoch1 2022-05-20 00:21:14 -04:00
parent f21c5be832
commit 4497aaf4af
10 changed files with 92 additions and 61 deletions

Binary file not shown.

View File

@ -13,7 +13,7 @@ import matplotlib
import matplotlib.lines as mlines
from matplotlib import ticker
from matplotlib.ticker import NullFormatter
from plotstyle import boxplot_style
from Figures.plotstyle import boxplot_style
def cm2inch(*tupl):
inch = 2.54
@ -99,6 +99,7 @@ Axes.scatter = new_scatter
#%%
def boxplot_with_markers(ax,max_width, alteration='shift', msize=3):
# size =4
hlinewidth = 0.5
# ax.tick_params(axis='x', rotation=90)
model_names = ['RS pyramidal','RS inhibitory','FS',
'RS pyramidal +$K_V1.1$','RS inhibitory +$K_V1.1$',
@ -120,20 +121,6 @@ def boxplot_with_markers(ax,max_width, alteration='shift', msize=3):
'#873770', # magenta
]
# colorslist = ['#40A787', # cyan'#
# '#F0D730', # yellow
# 'C02717', # red
# '#007030', # dark green
# '#AAB71B', # lightgreen
# '#008797', # light blue
# '#F78017', # orange
# '#478010', # green
# '#53379B', # purple
# '#2060A7', # blue
# '#873770', # magenta
# '#D03050' # pink
# ]
hlinewidth =0.5
import matplotlib.colors
colors = [matplotlib.colors.to_rgb(c) for c in colorslist] # sns.color_palette("hls", 14, desat=0.75)#[cm.tab20(i) for i in range(20)]
@ -158,6 +145,8 @@ def boxplot_with_markers(ax,max_width, alteration='shift', msize=3):
# sns.despine(trim=True, bottom=True, ax=ax)
# ax.set(xlabel=None, ylabel=r'Kendall $\it{\tau}$')
ax.set_title("Shift ($\Delta V_{1/2}$)", y=1.05)
ax.set_xticklabels(['Na \nactivation', 'Na \ninactivation', 'K \nactivation', '$K_V1.1$ \nactivation',
'$K_V1.1$ \ninactivation', 'A \nactivation', 'A \ninactivation'])
elif alteration=='slope':
i = 3 # Kv1.1 act
ax.axvspan(i - 0.4, i + 0.4, fill=False, edgecolor='k')
@ -183,6 +172,8 @@ def boxplot_with_markers(ax,max_width, alteration='shift', msize=3):
# ax.set(xlabel=None, ylabel=r'Kendall $\it{\tau}$')
ax.set_title("Slope (k)", y=1.05)
# sns.despine(trim=True, bottom=True, ax=ax)
ax.set_xticklabels(['Na \nactivation', 'Na \ninactivation', 'K \nactivation', '$K_V1.1$ \nactivation',
'$K_V1.1$ \ninactivation', 'A \nactivation', 'A \ninactivation'])
elif alteration=='g':
i = 1 # Kd
ax.axvspan(i - 0.4, i + 0.4, fill=False, edgecolor='k')
@ -203,14 +194,15 @@ def boxplot_with_markers(ax,max_width, alteration='shift', msize=3):
# sns.despine(trim=True, bottom=True, ax=ax)
# ax.set(xlabel=None, ylabel=r'Kendall $\it{\tau}$')
ax.set_title("Conductance (g)", y=1.05)
# ax.set_xticklabels(textwrap.fill(x.get_text(), max_width) for x in ax.get_xticklabels())
ax.set_xticklabels(textwrap.fill(x.get_text(), max_width) for x in ax.get_xticklabels())
else:
print('Please chose "shift", "slope" or "g"')
ax.get_legend().remove()
ax.xaxis.grid(False)
sns.despine(trim=True, bottom=True, ax=ax)
ax.set(xlabel=None, ylabel=r'Kendall $\it{\tau}$')
ax.set_xticklabels(textwrap.fill(x.get_text(), max_width) for x in ax.get_xticklabels())
# ax.set_xticklabels(textwrap.fill(x.get_text(), max_width) for x in ax.get_xticklabels())
# fixlegend(ax, Markers)
def model_legend(ax, marker_s_leg, pos, ncol):
@ -363,7 +355,7 @@ def plot_fI(ax, model='RS Pyramidal', type='shift', alt='m', color1='red', color
c += 1
ax.set_ylabel('Frequency [Hz]')
ax.set_xlabel('Current [nA]')
ax.set_title(model)
ax.set_title(model, x=0.2, y=1.0)
ax.spines["right"].set_visible(False)
ax.spines["top"].set_visible(False)
L = ax.get_ylim()
@ -390,15 +382,15 @@ color_dict = {'Cb stellate': '#40A787', # cyan'#
# plot setup
marker_s_leg = 2
max_width = 20
pad_x = 0.65
pad_y= 0.4
pad_w = 0.85
pad_x = 0.8
pad_y= 0.45
pad_w = 1
pad_h = 0.7
fig = plt.figure()
# fig = plt.figure()
# fig.set_size_inches(cm2inch(17.6,10))
gs = fig.add_gridspec(3, 6, wspace=1., hspace=0.8)
gs = fig.add_gridspec(3, 6, wspace=1.2, hspace=1.)
# plt.subplots_adjust(hspace=0.8) #, wspace=0.6
ax0 = fig.add_subplot(gs[0,2:6])
ax0_ex = fig.add_subplot(gs[0,1])
@ -428,9 +420,9 @@ rec = ax2_fI.add_patch(rec)
rec.set_clip_on(False)
# label subplots with letters
ax0_fI.text(-0.95, 1.12, string.ascii_uppercase[0], transform=ax0_fI.transAxes, size=10, weight='bold') #-0.09
ax1_fI.text(-0.95, 1.12, string.ascii_uppercase[1], transform=ax1_fI.transAxes,size=10, weight='bold')
ax2_fI.text(-0.95, 1.12, string.ascii_uppercase[2], transform=ax2_fI.transAxes,size=10, weight='bold')
ax0_fI.text(-0.825, 1.3, string.ascii_uppercase[0], transform=ax0_fI.transAxes, size=10, weight='bold') #-0.09
ax1_fI.text(-0.825, 1.3, string.ascii_uppercase[1], transform=ax1_fI.transAxes,size=10, weight='bold')
ax2_fI.text(-0.825, 1.3, string.ascii_uppercase[2], transform=ax2_fI.transAxes,size=10, weight='bold')
# plot boxplots
boxplot_with_markers(ax0,max_width, alteration='shift')
@ -438,8 +430,8 @@ boxplot_with_markers(ax1,max_width, alteration='slope')
boxplot_with_markers(ax2,max_width, alteration='g')
# plot legend
pos = (0.25, -0.6)
ncol = 6
pos = (0.15, -0.9)
ncol = 5
model_legend(ax2, marker_s_leg, pos, ncol)
# plot examples
@ -450,7 +442,7 @@ plot_AUC_alt(ax2_ex, model='STN +$\mathrm{K}_{\mathrm{V}}\mathrm{1.1}$', color1=
#save
# plt.tight_layout(pad=0)
print(fig.dpi)
fig.set_size_inches(cm2inch(21,10))
fig.set_size_inches(cm2inch(20.6,12))
fig.savefig('./Figures/AUC_correlation.pdf', dpi=fig.dpi) #bbox_inches='tight', dpi=fig.dpi
plt.show()

View File

@ -299,6 +299,6 @@ ax3.text(0.95, -0.55, 'LOF')
ax3_BR = ax3.inset_axes([0.63, 0.15, 0.3, 0.2])
plot_diff_sqrt(ax3_BR, b2=0.4, c2=75)
ax3_BR.set_ylim(inset_ylim)
fig.set_size_inches(cm2inch(8.17,12))
fig.set_size_inches(cm2inch(8.5,12))
fig.savefig('./Figures/firing_characterization.pdf', dpi=fig.dpi) #bbox_inches='tight', dpi=fig.dpi
plt.show()

Binary file not shown.

View File

@ -28,18 +28,18 @@ def plot_style():
plt.rcParams['figure.dpi'] = 300
def boxplot_style():
plt.rcParams['xtick.direction'] = 'out'
plt.rcParams['ytick.direction'] = 'out'
plt.rcParams['xtick.direction'] = 'in'
plt.rcParams['ytick.direction'] = 'in'
plt.rcParams['lines.linewidth'] = 1
plt.rcParams['lines.markersize'] = 0.5
plt.rcParams['xtick.labelsize'] = 4
plt.rcParams['ytick.labelsize'] = 4
plt.rcParams['xtick.labelsize'] = 7
plt.rcParams['ytick.labelsize'] = 7
plt.rcParams['savefig.bbox'] = 'tight'
plt.rcParams['axes.titlesize'] = 5
plt.rcParams['axes.labelsize'] = 4
plt.rcParams['legend.fontsize']= 4
plt.rcParams['xtick.labelsize'] = 3
plt.rcParams['ytick.labelsize']= 3
plt.rcParams['axes.titlesize'] = 7
plt.rcParams['axes.labelsize'] = 7
plt.rcParams['legend.fontsize']= 6
plt.rcParams['xtick.labelsize'] = 6
plt.rcParams['ytick.labelsize']= 6
plt.rcParams['mathtext.default'] = 'regular'
plt.rcParams['figure.dpi'] = 300

View File

@ -239,11 +239,40 @@ def plot_ramp_V(ax, model='RS Pyramidal'): # , stop=750
ax.axis('off')
ax.set_title(model, fontsize=8)
def plot_I_ramp(ax):
dt = 0.01
I_low = 0
I_high = 0.001
initial_period = 1000
sec = 4
ramp_len = int(4 * 1000 * 1 / dt)
stim_time = ramp_len * 2
I_amp = np.array([0])
I_amp = np.reshape(I_amp, (1, I_amp.shape[0]))
I_ramp = np.zeros((stim_time, 1)) @ I_amp
I_ramp[:, :] = np.ones((stim_time, 1)) @ I_amp
stim_num_step = I_ramp.shape[1]
# start = np.int(initial_period * 1 / dt)
start=0
I_ramp[start:int(start + ramp_len), 0] = np.linspace(0, I_high, ramp_len)
I_ramp[int(start + ramp_len):int(start + ramp_len * 2), 0] = np.linspace(I_high, 0, ramp_len)
t = np.arange(0, 4000 * 2, dt)
ax.plot(t, I_ramp)
# ax.plot(model_ramp['t'], model_ramp[model], 'k', linewidth=0.0025)
ax.set_ylabel('I')
ax.set_xlabel('Time [s]')
# ax.set_ylim(-80, 60)
ax.axis('off')
ax.set_title('Ramp Current', fontsize=8, x=0.5, y=-0.5)
return ax
#% plot setup
fig = plt.figure(figsize=cm2inch(17.6,25))
gs0 = fig.add_gridspec(2, 1, wspace=0.)
gs00 = gs0[:].subgridspec(12, 1, wspace=0.7, hspace=1.0)
gs00 = gs0[:].subgridspec(13, 1, wspace=0.7, hspace=1.0)
# gs01 = gs0[1:].subgridspec(7, 2, wspace=0.6, hspace=1)
ax1_ramp = fig.add_subplot(gs00[0])
@ -258,7 +287,7 @@ ax9_ramp = fig.add_subplot(gs00[8])
ax10_ramp = fig.add_subplot(gs00[9])
ax11_ramp = fig.add_subplot(gs00[10])
ax12_ramp = fig.add_subplot(gs00[11])
ax13_I = fig.add_subplot(gs00[12])
ramp_axs = [ax1_ramp, ax2_ramp, ax3_ramp, ax4_ramp, ax5_ramp,ax6_ramp, ax7_ramp, ax8_ramp,
ax9_ramp, ax10_ramp, ax11_ramp, ax12_ramp]
@ -282,6 +311,10 @@ add_scalebar(ax12_ramp, matchx=False, matchy=False, hidex=True, hidey=True, size
# add_scalebar(ax12_ramp, matchx=False, matchy=False, hidex=True, hidey=True, sizex=1000, sizey=25, labelx='1 s',
# labely='25 mV', loc=3, pad=-2, borderpad=0, barwidth=2, bbox_to_anchor=Bbox.from_bounds(-0.05, 0.1, 1, 1),
# bbox_transform=ax12_ramp.transAxes)
ax13_I = plot_I_ramp(ax13_I)
add_scalebar(ax13_I, matchx=False, matchy=False, hidex=True, hidey=True, sizex=1000, sizey=0.0005, labelx='1 s',
labely='0.5 $I_{max}$', loc=3, pad=-2, borderpad=0, barwidth=1,
bbox_to_anchor=Bbox.from_bounds(0.0, -0.01, 1, 1), bbox_transform=ax13_I.transAxes)
# add subplot labels
for i in range(0,len(models)):
@ -289,7 +322,7 @@ for i in range(0,len(models)):
# fig.savefig('./Figures/ramp_firing.pdf') #, bbox_inches='tight'
print(fig.dpi)
fig.set_size_inches(cm2inch(17.6,20))
fig.set_size_inches(cm2inch(17.6,22))
fig.savefig('./Figures/ramp_firing.pdf', dpi=fig.dpi) #bbox_inches='tight', dpi=fig.dpi
plt.show()

Binary file not shown.

Binary file not shown.

View File

@ -13,7 +13,7 @@ import matplotlib
import matplotlib.lines as mlines
from matplotlib import ticker
from matplotlib.ticker import NullFormatter
from plotstyle import boxplot_style
from Figures.plotstyle import boxplot_style
def cm2inch(*tupl):
@ -132,7 +132,6 @@ def boxplot_with_markers(ax,max_width, alteration='shift', msize=2.2):
i = 3 # Kv1.1 act
ax.axvspan(i - 0.4, i + 0.4, fill=False, edgecolor='k')
df = pd.read_csv('./Figures/Data/rheo_shift_corr.csv')
sns.swarmplot(y="corr", x="$\Delta V_{1/2}$", hue="model", data=df, #dodge=True,
palette=clr_dict, linewidth=0, orient='v', ax=ax, size=msize,
order=['Na activation', 'Na inactivation', 'K activation', '$K_V1.1$ activation',
@ -143,6 +142,8 @@ def boxplot_with_markers(ax,max_width, alteration='shift', msize=2.2):
ax.plot([lim[0], lim[1]], [1, 1], ':k',linewidth=hlinewidth)
ax.plot([lim[0], lim[1]], [-1, -1], ':k',linewidth=hlinewidth)
ax.set_title("Shift ($\Delta V_{1/2}$)", y=1.05)
ax.set_xticklabels(['Na \nactivation', 'Na \ninactivation', 'K \nactivation', '$K_V1.1$ \nactivation',
'$K_V1.1$ \ninactivation', 'A \nactivation', 'A \ninactivation'])
elif alteration=='slope':
i = 4 # Kv1.1 inact
ax.axvspan(i - 0.4, i + 0.4, fill=False, edgecolor='k')
@ -159,6 +160,8 @@ def boxplot_with_markers(ax,max_width, alteration='shift', msize=2.2):
ax.plot([lim[0], lim[1]], [1, 1], ':k',linewidth=hlinewidth)
ax.plot([lim[0], lim[1]], [-1, -1], ':k',linewidth=hlinewidth)
ax.set_title("Slope (k)", y=1.05)
ax.set_xticklabels(['Na \nactivation', 'Na \ninactivation', 'K \nactivation', '$K_V1.1$ \nactivation',
'$K_V1.1$ \ninactivation', 'A \nactivation', 'A \ninactivation'])
elif alteration=='g':
i = 4 # Leak
ax.axvspan(i - 0.4, i + 0.4, fill=False, edgecolor='k')
@ -174,13 +177,14 @@ def boxplot_with_markers(ax,max_width, alteration='shift', msize=2.2):
ax.plot([lim[0], lim[1]], [1, 1], ':k',linewidth=hlinewidth)
ax.plot([lim[0], lim[1]], [-1, -1], ':k',linewidth=hlinewidth)
ax.set_title("Conductance (g)", y=1.05)
ax.set_xticklabels(textwrap.fill(x.get_text(), max_width) for x in ax.get_xticklabels())
else:
print('Please chose "shift", "slope" or "g"')
ax.get_legend().remove()
ax.xaxis.grid(False)
sns.despine(trim=True, bottom=True, ax=ax)
ax.set(xlabel=None, ylabel=r'Kendall $\it{\tau}$')
ax.set_xticklabels(textwrap.fill(x.get_text(), max_width) for x in ax.get_xticklabels())
# ax.set_xticklabels(textwrap.fill(x.get_text(), max_width) for x in ax.get_xticklabels())
def model_legend(ax, marker_s_leg, pos, ncol):
colorslist = [ '#40A787', # cyan'#
@ -298,11 +302,12 @@ def plot_rheo_alt(ax, model='FS', color1='red', color2='dodgerblue', alteration=
else:
ax.plot(df['alteration'], df[mod], color=clr_dict[mod], alpha=1, zorder=1, linewidth=1)
ax.set_ylabel('$\Delta$ Rheobase (nA)')
ax.set_ylabel('$\Delta$ Rheobase (nA)', labelpad=0)
x = df['alteration']
y = df[model_name_dict[model]]
ax.set_xlim(x.min(), x.max())
ax.set_ylim(df[model_names].min().min(), df[model_names].max().max())
return ax
def plot_fI(ax, model='RS Pyramidal', type='shift', alt='m', color1='red', color2='dodgerblue'):
@ -335,7 +340,7 @@ def plot_fI(ax, model='RS Pyramidal', type='shift', alt='m', color1='red', color
c += 1
ax.set_ylabel('Frequency [Hz]')
ax.set_xlabel('Current [nA]')
ax.set_title(model)
ax.set_title(model, x=0.2, y=1.025)
ax.spines["right"].set_visible(False)
ax.spines["top"].set_visible(False)
L = ax.get_ylim()
@ -362,21 +367,22 @@ color_dict = {'Cb stellate': '#40A787', # cyan'#
# plot setup
marker_s_leg = 2
max_width = 20
pad_x = 0.65
pad_x = 0.85
pad_y= 0.4
pad_w = 0.85
pad_w = 1.1
pad_h = 0.7
fig = plt.figure(figsize=cm2inch(17.6,10))
gs = fig.add_gridspec(3, 6, wspace=1., hspace=0.8)
fig = plt.figure()
# fig = plt.figure(figsize=cm2inch(17.6,10))
gs = fig.add_gridspec(3, 7, wspace=1.2, hspace=1.)
# plt.subplots_adjust(hspace=0.8) #, wspace=0.6
ax0 = fig.add_subplot(gs[0,2:6])
ax0 = fig.add_subplot(gs[0,2:7])
ax0_ex = fig.add_subplot(gs[0,1])
ax0_fI = fig.add_subplot(gs[0,0])
ax1 = fig.add_subplot(gs[1,2:6])
ax1 = fig.add_subplot(gs[1,2:7])
ax1_ex = fig.add_subplot(gs[1,1])
ax1_fI = fig.add_subplot(gs[1,0])
ax2 = fig.add_subplot(gs[2,2:6])
ax2 = fig.add_subplot(gs[2,2:7])
ax2_ex = fig.add_subplot(gs[2,1])
ax2_fI = fig.add_subplot(gs[2,0])
@ -398,9 +404,9 @@ rec = ax2_fI.add_patch(rec)
rec.set_clip_on(False)
# label fI subplots with letters
ax0_fI.text(-0.95, 1.12, string.ascii_uppercase[0], transform=ax0_fI.transAxes, size=10, weight='bold') #-0.09
ax1_fI.text(-0.95, 1.12, string.ascii_uppercase[1], transform=ax1_fI.transAxes,size=10, weight='bold')
ax2_fI.text(-0.95, 1.12, string.ascii_uppercase[2], transform=ax2_fI.transAxes,size=10, weight='bold')
ax0_fI.text(-0.875, 1.35, string.ascii_uppercase[0], transform=ax0_fI.transAxes, size=10, weight='bold') #-0.09
ax1_fI.text(-0.875, 1.35, string.ascii_uppercase[1], transform=ax1_fI.transAxes,size=10, weight='bold')
ax2_fI.text(-0.875, 1.35, string.ascii_uppercase[2], transform=ax2_fI.transAxes,size=10, weight='bold')
# plot boxplots
boxplot_with_markers(ax0,max_width, alteration='shift')
@ -408,8 +414,8 @@ boxplot_with_markers(ax1,max_width, alteration='slope')
boxplot_with_markers(ax2,max_width, alteration='g')
# plot legend
pos = (0.25, -0.6)
ncol = 6
pos = (0.225, -0.9)
ncol = 5
model_legend(ax2, marker_s_leg, pos, ncol)
# plot rheo across model for example alteration
@ -420,7 +426,7 @@ plot_rheo_alt(ax2_ex, model='Cb stellate', color1='lightgrey', color2='k', alter
# save
# fig.savefig('./Figures/rheobase_correlation.pdf', bbox_inches='tight')
print(fig.dpi)
fig.set_size_inches(cm2inch(20.3,10))
fig.set_size_inches(cm2inch(20.75,12))
fig.savefig('./Figures/rheobase_correlation.pdf', dpi=fig.dpi) #bbox_inches='tight', dpi=fig.dpi
plt.show()

View File

@ -310,7 +310,7 @@ Qualitative differences can be found, for example, when increasing the conductan
\begin{figure}[tp]
\centering
\includegraphics[width=\linewidth]{Figures/AUC_correlation.pdf}
\\\notejb{tick labels too small!}\notenk{I will fix this tongiht or tomorrow}
\\\notejb{tick labels too small!}\notenk{Is this better?}
\linespread{1.}\selectfont
\caption[]{Effects of altered channel kinetics on AUC in various neuron models. The Kendall rank correlation (Kendall \(\tau\)) coefficients between shifts in \(V_{1/2}\) and AUC, slope factor k and AUC as well as current conductances and AUC for each model are shown on the right in (A), (B) and (C) respectively. The relationships between AUC and \(\Delta V_{1/2}\), slope (k) and conductance (g) for the Kendall \(\tau\) coefficients highlights by the black box are depicted in the middle panel. The fI curves corresponding to one of the models are shown in the left panels.}
\label{fig:AUC_correlation}
@ -456,7 +456,7 @@ Accordingly, for accurate modelling and predictions of the effects of mutations
\centering
\includegraphics[width=\linewidth]{Figures/ramp_firing.pdf}
\linespread{1.}\selectfont
\\\notejb{You should add the ramp stimulus at the bottom. To be able to see the hysteresis one needs to know where the symmetry axis is. (I gues it is in the center, but better is to see that.}
\\\notejb{You should add the ramp stimulus at the bottom. To be able to see the hysteresis one needs to know where the symmetry axis is. (I gues it is in the center, but better is to see that.}\notenk{like this?}
\caption[]{Diversity in Neuronal Model Firing Responses to a Current Ramp. Spike trains for Cb stellate (A), RS inhibitory (B), FS (C), RS pyramidal (D), RS inhibitory +\Kv (E), Cb stellate +\Kv (F), FS +\Kv (G), RS pyramidal +\Kv (H), STN +\Kv (I), Cb stellate \(\Delta\)\Kv (J), STN \(\Delta\)\Kv (K), and STN (L) neuron models in response to a slow ascending current ramp followed by the descending version of the current ramp. The current at which firing begins in response to an ascending current ramp and the current at which firing ceases in response to a descending current ramp are depicted on the frequency current (fI) curves in \Cref{fig:diversity_in_firing} for each model.}
\label{fig:ramp_firing}
\end{figure}