From a0f64fd365a983bba5c8695748756e9ac00a32a4 Mon Sep 17 00:00:00 2001 From: nkoch1 Date: Sat, 11 Jun 2022 20:28:22 -0400 Subject: [PATCH] Changed firing_characterization-jb.py to firing_characterization.py and old firing_characterization file to firing_characterization_old.py also renamed ramp_examples.py as ramp_firing.py; cleaned up comments and code for rheobase_correlation.py, AUC_correlation.py, diversity_in_firing.py, ramp_firing.py, simulation_model_comparison.py --- Figures/AUC_correlation.py | 113 +---- Figures/diversity_in_firing.py | 8 +- Figures/firing_characterization-jb.py | 386 ------------------ Figures/firing_characterization.pdf | Bin 23388 -> 23345 bytes Figures/firing_characterization.py | 408 ++++++++++++++----- Figures/firing_characterization_old.py | 182 +++++++++ Figures/{ramp_examples.py => ramp_firing.py} | 13 +- Figures/rheobase_correlation.py | 87 +--- Figures/simulation_model_comparison.py | 26 +- 9 files changed, 506 insertions(+), 717 deletions(-) delete mode 100644 Figures/firing_characterization-jb.py create mode 100644 Figures/firing_characterization_old.py rename Figures/{ramp_examples.py => ramp_firing.py} (95%) diff --git a/Figures/AUC_correlation.py b/Figures/AUC_correlation.py index 992fc50..ba9ea18 100644 --- a/Figures/AUC_correlation.py +++ b/Figures/AUC_correlation.py @@ -93,14 +93,11 @@ def new_scatter(self, *args, **kwargs): return FinalCollection Axes.scatter = new_scatter ############## End hack. ############## - ######################################################################################################################## #%% 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$', 'FS +$K_V1.1$','Cb stellate','Cb stellate +$K_V1.1$', @@ -123,7 +120,7 @@ def boxplot_with_markers(ax,max_width, alteration='shift', msize=3): 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)] + colors = [matplotlib.colors.to_rgb(c) for c in colorslist] clr_dict = {} for m in range(len(model_names)): clr_dict[model_names[m]] = colors[m] @@ -141,9 +138,6 @@ def boxplot_with_markers(ax,max_width, alteration='shift', msize=3): ax.plot([lim[0], lim[1]], [0, 0], ':r',linewidth=hlinewidth) ax.plot([lim[0], lim[1]], [1, 1], ':k',linewidth=hlinewidth) ax.plot([lim[0], lim[1]], [-1, -1], ':k',linewidth=hlinewidth) - # ax.get_legend().remove() - # 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']) @@ -153,25 +147,16 @@ def boxplot_with_markers(ax,max_width, alteration='shift', msize=3): df = pd.read_csv('./Figures/Data/AUC_scale_corr.csv') # Add in points to show each observation - sns.swarmplot(y="corr", x="Slope (k)", hue="model", data=df, #dodge=True, + sns.swarmplot(y="corr", x="Slope (k)", hue="model", data=df, palette=clr_dict, linewidth=0, orient='v', ax=ax, size=msize, order=['Na activation', 'Na inactivation', 'K activation', '$K_V1.1$ activation', '$K_V1.1$ inactivation', 'A activation', 'A inactivation'], hue_order=model_names, co2mk=Markers) lim = ax.get_xlim() - # ax.plot([lim[0], lim[1]], [0,0], ':k') ax.plot([lim[0], lim[1]], [0, 0], ':r',linewidth=hlinewidth) ax.plot([lim[0], lim[1]], [1, 1], ':k',linewidth=hlinewidth) ax.plot([lim[0], lim[1]], [-1, -1], ':k',linewidth=hlinewidth) - # Markers = ["o","s","v","^","<",">","p","h","P","X","D","*","8","o"] - # ax=fixlegend(ax, Markers) - # Tweak the visual presentation - # ax.get_legend().remove() - # ax.xaxis.grid(False) - # ax.set_xticklabels(textwrap.fill(x.get_text(), max_width) for x in ax.get_xticklabels()) - # 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': @@ -180,7 +165,7 @@ def boxplot_with_markers(ax,max_width, alteration='shift', msize=3): df = pd.read_csv('./Figures/Data/AUC_g_corr.csv') # Add in points to show each observation - sns.swarmplot(y="corr", x="g", hue="model", data=df, #dodge=True, + sns.swarmplot(y="corr", x="g", hue="model", data=df, palette=clr_dict, linewidth=0, orient='v', ax=ax, size=msize, order=['Na', 'K', '$K_V1.1$', 'A', 'Leak'], hue_order=model_names, co2mk=Markers) @@ -190,9 +175,6 @@ def boxplot_with_markers(ax,max_width, alteration='shift', msize=3): ax.plot([lim[0], lim[1]], [1, 1], ':k',linewidth=hlinewidth) ax.plot([lim[0], lim[1]], [-1, -1], ':k',linewidth=hlinewidth) # Tweak the visual presentation - # ax.xaxis.grid(False) - # 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()) else: @@ -202,8 +184,6 @@ 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_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): colorslist = [ '#40A787', # cyan'# @@ -220,15 +200,13 @@ def model_legend(ax, marker_s_leg, pos, ncol): '#D03050' # pink ] 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)] - + colors = [matplotlib.colors.to_rgb(c) for c in colorslist] model_pos = {'Cb stellate':0, 'RS Inhibitory':1, 'FS':2, 'RS Pyramidal':3, 'RS Inhibitory +$\mathrm{K}_{\mathrm{V}}\mathrm{1.1}$':4, 'Cb stellate +$\mathrm{K}_{\mathrm{V}}\mathrm{1.1}$':5, 'FS +$\mathrm{K}_{\mathrm{V}}\mathrm{1.1}$':6, 'RS Pyramidal +$\mathrm{K}_{\mathrm{V}}\mathrm{1.1}$':7, 'STN +$\mathrm{K}_{\mathrm{V}}\mathrm{1.1}$':8, 'Cb stellate $\Delta$$\mathrm{K}_{\mathrm{V}}\mathrm{1.1}$':9, 'STN $\Delta$$\mathrm{K}_{\mathrm{V}}\mathrm{1.1}$':10, 'STN':11} - Markers = ["o", "o", "o", "^", "^", "^", "D", "D", "D", "s", "s", "s"] RS_p = mlines.Line2D([], [], color=colors[model_pos['RS Pyramidal']], marker=Markers[model_pos['RS Pyramidal']], markersize=marker_s_leg, linestyle='None', label='RS pyramidal') @@ -290,8 +268,7 @@ def plot_AUC_alt(ax, model='FS', color1='red', color2='dodgerblue', alteration=' ] 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)] + colors = [matplotlib.colors.to_rgb(c) for c in colorslist] clr_dict = {} for m in range(len(model_names)): clr_dict[model_names[m]] = colors[m] @@ -392,10 +369,7 @@ pad_w = 1.1 pad_h = 0.7 fig = plt.figure() -# fig = plt.figure() -# fig.set_size_inches(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:7]) ax0_ex = fig.add_subplot(gs[0,1]) ax0_fI = fig.add_subplot(gs[0,0]) @@ -423,9 +397,6 @@ rec = plt.Rectangle((-pad_x, -pad_y), 1 + pad_w, 1 + pad_h, fill=False, lw=line rec = ax2_fI.add_patch(rec) rec.set_clip_on(False) - - - # plot boxplots boxplot_with_markers(ax0,max_width, alteration='shift') boxplot_with_markers(ax1,max_width, alteration='slope') @@ -455,78 +426,6 @@ ax2_ex.text(-0.8, 1.35, string.ascii_uppercase[7], transform=ax2_ex.transAxes, s ax2.text(-0.075, 1.35, string.ascii_uppercase[8], transform=ax2.transAxes, size=10, weight='bold') #save -# plt.tight_layout(pad=0) -print(fig.dpi) fig.set_size_inches(cm2inch(20.75,12)) -fig.savefig('./Figures/AUC_correlation.pdf', dpi=fig.dpi) #bbox_inches='tight', dpi=fig.dpi +fig.savefig('./Figures/AUC_correlation.pdf', dpi=fig.dpi) plt.show() - -# #%% alternative layout -# # boxplot_style() -# marker_s_leg = 8 -# max_width = 10 -# pad_x = 0.2 -# pad_y= 0.4 -# pad_w = 0.22 -# pad_h = 0.6 -# -# fig = plt.figure(figsize=(12,20)) -# gs = fig.add_gridspec(3, 1, hspace=0.4, wspace=0.4) -# gs0 = gs[0].subgridspec(2, 4, wspace=0.6, hspace=1.) -# gs1 = gs[1].subgridspec(2, 4, wspace=0.6, hspace=1.) -# gs2 = gs[2].subgridspec(2, 4, wspace=0.6, hspace=1.) -# ax0 = fig.add_subplot(gs0[1,:]) -# ax0_ex = fig.add_subplot(gs0[0,2:]) -# ax0_fI = fig.add_subplot(gs0[0,:2]) -# ax1 = fig.add_subplot(gs1[1,:]) -# ax1_ex = fig.add_subplot(gs1[0,2:]) -# ax1_fI = fig.add_subplot(gs1[0,:2]) -# ax2 = fig.add_subplot(gs2[1,:]) -# ax2_ex = fig.add_subplot(gs2[0,2:]) -# ax2_fI = fig.add_subplot(gs2[0,:2]) -# -# -# ax0_fI = plot_fI(ax0_fI, model='FS +$\mathrm{K}_{\mathrm{V}}\mathrm{1.1}$', type='shift', alt='s', color1='lightgrey', color2='k') -# rec = plt.Rectangle((-pad_x, -pad_y), 1 + pad_w, 1 + pad_h, fill=False, lw=2,transform=ax0_fI.transAxes, color=color_dict['FS +$\mathrm{K}_{\mathrm{V}}\mathrm{1.1}$'], alpha=1, zorder=-1) -# rec = ax0_fI.add_patch(rec) -# rec.set_clip_on(False) -# -# ax1_fI = plot_fI(ax1_fI, model='FS +$\mathrm{K}_{\mathrm{V}}\mathrm{1.1}$', type='slope', alt='u', color1='lightgrey', color2='k') -# rec = plt.Rectangle((-pad_x, -pad_y), 1 + pad_w, 1 + pad_h, fill=False, lw=2,transform=ax1_fI.transAxes, color=color_dict['FS +$\mathrm{K}_{\mathrm{V}}\mathrm{1.1}$'], alpha=1, zorder=-1) -# rec = ax1_fI.add_patch(rec) -# rec.set_clip_on(False) -# -# ax2_fI = plot_fI(ax2_fI, model='STN +$\mathrm{K}_{\mathrm{V}}\mathrm{1.1}$', type='g', alt='Leak', color1='lightgrey', color2='k') -# rec = plt.Rectangle((-pad_x, -pad_y), 1 + pad_w, 1 + pad_h, fill=False, lw=2,transform=ax2_fI.transAxes, color=color_dict['STN +$\mathrm{K}_{\mathrm{V}}\mathrm{1.1}$'], alpha=1, zorder=-1) -# rec = ax2_fI.add_patch(rec) -# rec.set_clip_on(False) -# -# # label subplots with letters -# ax0_fI.text(-0.2, 1.38, string.ascii_uppercase[0], transform=ax0_fI.transAxes, size=16, weight='bold') #-0.09 -# ax1_fI.text(-0.2, 1.38, string.ascii_uppercase[1], transform=ax1_fI.transAxes,size=16, weight='bold') -# ax2_fI.text(-0.2, 1.38, string.ascii_uppercase[2], transform=ax2_fI.transAxes,size=16, weight='bold') -# -# # plot boxplots -# boxplot_with_markers(ax0,max_width, alteration='shift') -# boxplot_with_markers(ax1,max_width, alteration='slope') -# boxplot_with_markers(ax2,max_width, alteration='g') -# # plot legend -# pos = (0.5, -1.) -# ncol = 6 -# model_legend(ax2, marker_s_leg, pos, ncol) -# -# # # plot rheo across model for example alteration -# # plot_rheo_alt(ax0_ex,model='FS +$\mathrm{K}_{\mathrm{V}}\mathrm{1.1}$', color1='red', color2='maroon', alteration='shift') -# # plot_rheo_alt(ax1_ex,model='Cb stellate +$\mathrm{K}_{\mathrm{V}}\mathrm{1.1}$', color1='orchid', color2='purple',alteration='slope') -# # plot_rheo_alt(ax2_ex, model='Cb stellate', color1='darkviolet', color2='indigo', alteration='g') -# # plot_rheo_alt(ax0_ex,model='FS +$\mathrm{K}_{\mathrm{V}}\mathrm{1.1}$', color1='lightgrey', color2='k', alteration='shift') -# # plot_rheo_alt(ax1_ex,model='Cb stellate +$\mathrm{K}_{\mathrm{V}}\mathrm{1.1}$', color1='lightgrey', color2='k',alteration='slope') -# # plot_rheo_alt(ax2_ex, model='Cb stellate', color1='lightgrey', color2='k', alteration='g') -# -# # plot examples -# plot_AUC_alt(ax0_ex,model='FS', color1='lightgrey', color2='k', alteration='shift') -# plot_AUC_alt(ax1_ex,model='FS +$\mathrm{K}_{\mathrm{V}}\mathrm{1.1}$', color1='lightgrey', color2='k',alteration='slope') -# plot_AUC_alt(ax2_ex, model='STN +$\mathrm{K}_{\mathrm{V}}\mathrm{1.1}$', color1='lightgrey', color2='k', alteration='g') -# fig.savefig('AUC_correlation_2.pdf', bbox_inches='tight') # -# # plt.saveas(fig, 'AUC_correlation_2.png') -# plt.show() diff --git a/Figures/diversity_in_firing.py b/Figures/diversity_in_firing.py index 859def3..f48646a 100644 --- a/Figures/diversity_in_firing.py +++ b/Figures/diversity_in_firing.py @@ -4,7 +4,6 @@ import matplotlib.pyplot as plt import matplotlib.gridspec as gridspec from matplotlib.transforms import Bbox import string -# from plotstyle import plot_style def cm2inch(*tupl): @@ -15,6 +14,7 @@ def cm2inch(*tupl): return tuple(i/inch for i in tupl) plt.rcParams['xtick.labelsize'] = 6 plt.rcParams['ytick.labelsize'] = 6 + #### from https://gist.github.com/dmeliza/3251476 ##################################################################### from matplotlib.offsetbox import AnchoredOffsetbox class AnchoredScaleBar(AnchoredOffsetbox): @@ -128,7 +128,7 @@ def plot_fI(ax, model='RS Pyramidal'): #%% # plot layout -fig = plt.figure() #figsize=cm2inch(17.6,17.6) +fig = plt.figure() gs0 = fig.add_gridspec(3, 2, wspace=0.3, hspace=0) gs00 = gs0[:,0].subgridspec(6, 3, wspace=1.5, hspace=1.5) gs01 = gs0[:,1].subgridspec(6, 3, wspace=1.2, hspace=1.3) @@ -187,10 +187,8 @@ for i in range(0,len(models)): spike_axs[i].text(-0.18, 1.08, string.ascii_uppercase[i], transform=spike_axs[i].transAxes, size=10, weight='bold') # save -# fig.savefig('./Figures/diversity_in_firing.pdf', bbox_inches='tight') -print(fig.dpi) fig.set_size_inches(cm2inch(17.6,20)) -fig.savefig('./Figures/diversity_in_firing.pdf', dpi=fig.dpi) #bbox_inches='tight', dpi=fig.dpi +fig.savefig('./Figures/diversity_in_firing.pdf', dpi=fig.dpi) plt.show() diff --git a/Figures/firing_characterization-jb.py b/Figures/firing_characterization-jb.py deleted file mode 100644 index 9a95b6c..0000000 --- a/Figures/firing_characterization-jb.py +++ /dev/null @@ -1,386 +0,0 @@ -import numpy as np -import matplotlib.pyplot as plt -import matplotlib.gridspec as gridspec -import matplotlib.ticker as ticker -from matplotlib.colors import colorConverter as cc -from matplotlib.colors import to_hex -import string -# from plotstyle import plot_style -from plotstyle import scheme_style - -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 - ] - -def cm2inch(*tupl): - inch = 2.54 - if isinstance(tupl[0], tuple): - return tuple(i/inch for i in tupl[0]) - else: - return tuple(i/inch for i in tupl) - - -def show_spines(ax, spines='lrtb'): - """ Show and hide spines. - - From github.com/janscience/plottools.git spines.py - - Parameters - ---------- - ax: matplotlib figure, matplotlib axis, or list of matplotlib axes - Axis on which spine and ticks visibility is manipulated. - If figure, then apply manipulations on all axes of the figure. - If list of axes, apply manipulations on each of the given axes. - spines: string - Specify which spines and ticks should be shown. - All other ones or hidden. - 'l' is the left spine, 'r' the right spine, - 't' the top one and 'b' the bottom one. - E.g. 'lb' shows the left and bottom spine, and hides the top - and and right spines, as well as their tick marks and labels. - '' shows no spines at all. - 'lrtb' shows all spines and tick marks. - - Examples - -------- - ```py - import matplotlib.pyplot as plt - import plottools.spines - - fig, (ax0, ax1, ax2) = plt.subplots(1, 3) - ax0.show_spines('lb') - ax1.show_spines('bt') - ax2.show_spines('tr') - ``` - ![show](figures/spines-show.png) - """ - # collect spine visibility: - xspines = [] - if 't' in spines: - xspines.append('top') - if 'b' in spines: - xspines.append('bottom') - yspines = [] - if 'l' in spines: - yspines.append('left') - if 'r' in spines: - yspines.append('right') - # collect axes: - if isinstance(ax, (list, tuple, np.ndarray)): - axs = ax - elif hasattr(ax, 'get_axes'): - # ax is figure: - axs = ax.get_axes() - else: - axs = [ax] - if not isinstance(axs, (list, tuple)): - axs = [axs] - for ax in axs: - # hide spines: - ax.spines['top'].set_visible('top' in xspines) - ax.spines['bottom'].set_visible('bottom' in xspines) - ax.spines['left'].set_visible('left' in yspines) - ax.spines['right'].set_visible('right' in yspines) - # ticks: - if len(xspines) == 0: - ax.xaxis.set_ticks_position('none') - ax.xaxis.label.set_visible(False) - ax.xaxis._orig_major_locator = ax.xaxis.get_major_locator() - ax.xaxis.set_major_locator(ticker.NullLocator()) - else: - if hasattr(ax.xaxis, '_orig_major_locator'): - ax.xaxis.set_major_locator(ax.xaxis._orig_major_locator) - delattr(ax.xaxis, '_orig_major_locator') - elif isinstance(ax.xaxis.get_major_locator(), ticker.NullLocator): - ax.xaxis.set_major_locator(ticker.AutoLocator()) - if len(xspines) == 1: - ax.xaxis.set_ticks_position(xspines[0]) - ax.xaxis.set_label_position(xspines[0]) - else: - ax.xaxis.set_ticks_position('both') - ax.xaxis.set_label_position('bottom') - if len(yspines) == 0: - ax.yaxis.set_ticks_position('none') - ax.yaxis.label.set_visible(False) - ax.yaxis._orig_major_locator = ax.yaxis.get_major_locator() - ax.yaxis.set_major_locator(ticker.NullLocator()) - else: - if hasattr(ax.yaxis, '_orig_major_locator'): - ax.yaxis.set_major_locator(ax.yaxis._orig_major_locator) - delattr(ax.yaxis, '_orig_major_locator') - elif isinstance(ax.yaxis.get_major_locator(), ticker.NullLocator): - ax.yaxis.set_major_locator(ticker.AutoLocator()) - if len(yspines) == 1: - ax.yaxis.set_ticks_position(yspines[0]) - ax.yaxis.set_label_position(yspines[0]) - else: - ax.yaxis.set_ticks_position('both') - ax.yaxis.set_label_position('left') - - - -def lighter(color, lightness): - """ Make a color lighter. - - From github.com/janscience/plottools.git colors.py - - ![lighter](figures/colors-lighter.png) - - Parameters - ---------- - color: dict or matplotlib color spec - A matplotlib color (hex string, name color string, rgb tuple) - or a dictionary with an 'color' or 'facecolor' key. - lightness: float - The smaller the lightness, the lighter the returned color. - A lightness of 0 returns white. - A lightness of 1 leaves the color untouched. - A lightness of 2 returns black. - - Returns - ------- - color: string or dict - The lighter color as a hexadecimal RGB string (e.g. '#rrggbb'). - If `color` is a dictionary, a copy of the dictionary is returned - with the value of 'color' or 'facecolor' set to the lighter color. - - Examples - -------- - For 40% lightness of blue do - ```py - import plottools.colors as c - colors = c.palettes['muted'] - lightblue = c.lighter(colors['blue'], 0.4) - ``` - """ - try: - c = color['color'] - cd = dict(**color) - cd['color'] = lighter(c, lightness) - return cd - except (KeyError, TypeError): - try: - c = color['facecolor'] - cd = dict(**color) - cd['facecolor'] = lighter(c, lightness) - return cd - except (KeyError, TypeError): - if lightness > 2: - lightness = 2 - if lightness > 1: - return darker(color, 2.0-lightness) - if lightness < 0: - lightness = 0 - r, g, b = cc.to_rgb(color) - rl = r + (1.0-lightness)*(1.0 - r) - gl = g + (1.0-lightness)*(1.0 - g) - bl = b + (1.0-lightness)*(1.0 - b) - return to_hex((rl, gl, bl)).upper() - - -def plot_sqrt(ax, a=1, b=0.2, c=100, d=0): - x = np.linspace(0, 1, 10000) - y = c*np.sqrt(a*(x - b)) + d - ax.plot(x, y) - ax.set_xlabel('Current [nA]') - ax.set_ylabel('Frequency [Hz]') - ax.set_xlim(0,1) - ax.set_ylim(0, ax.get_ylim()[1]) - -def plot_AUC(ax, a=1, b=0.2, c=180, d=0, width=0.2): - x = np.linspace(0, 1, 1000) - y = c*np.sqrt(a*(x - b)) + d - ax.plot(x, y, colorslist[9]) - ax.set_xlabel('Current [nA]') - ax.set_ylabel('Frequency [Hz]') - ax.fill_between(x, y, where=(x<=b+width), color=lighter(colorslist[9], 0.3)) - ax.text(0.3, 15, 'AUC', ha='center') - ax.annotate('', (0.2, 10), (0, 10), arrowprops=dict(arrowstyle="<->")) - ax.text(0.1, 20, 'rheobase', ha='center') - ax.set_xlim(0, 0.5) - ax.set_ylim(0, 100) - ax.yaxis.set_major_locator(ticker.MultipleLocator(50)) - -def plot_diff_sqrt(ax, a=1, b=0.2, c=100, d=0, a2=1, b2=0.2, c2=100, d2=0): - show_spines(ax, 'lb') - x = np.linspace(0, 1, 10000) - y = c*np.sqrt(a*(x - b)) + d - y2 = c2 * np.sqrt(a2 * (x - b2)) + d2 - ax.plot(x, y, colorslist[9]) - ax.plot(x, y2, colorslist[2]) - ax.set_xlim(0,1) - ax.set_ylim(0, ax.get_ylim()[1]) - ax.set_xticks([]) - ax.set_yticks([]) - - -def plot_quadrant(ax): - ax.spines['left'].set_position('zero') - ax.spines['bottom'].set_position('zero') - ax.text(1.2, -0.15, '$\\Delta$ rheobase', ha='right') - ax.text(-0.03, 0.7, '$\\Delta$ AUC', ha='right', rotation=90) - ax.tick_params(length=0) - ax.set_xlim(-1, 1) - ax.set_ylim(-1, 1) - ax.annotate('', (1, 0), (-1, 0), arrowprops=dict(arrowstyle="->")) - ax.annotate('', (0, 1), (0, -1), arrowprops=dict(arrowstyle="->")) - ax.set_xticks([-0.5, 0.5]) - a = ax.get_xticks().tolist() - a[0] = '\u2212' - a[1] = '+' - ax.set_xticklabels(a) - ax.set_yticks([-0.5, 0.5]) - b = ax.get_xticks().tolist() - b[0] = '\u2212' - b[1] = '+' - ax.set_yticklabels(b) - - # ax.tick_params(labelsize=16) - # ax.set_yticks([0]) - # ax.axis('off') - - -scheme_style() -#%% with legend -fig = plt.figure(figsize=cm2inch(7, 12)) -gs = gridspec.GridSpec(3,6, top=0.95, bottom=0.1, left=0.15, right = 0.95, hspace=0.8, wspace=0.6) -ax1 = fig.add_subplot(gs[0,1:]) -show_spines(ax1, 'lb') -plot_AUC(ax1, width=0.2) -ax3 = fig.add_subplot(gs[1:, :]) - -# add panel letter labels -# ax_list = fig.axes -# i =0 -# for a in ax_list: -# a.text(-0.25, 1.08, string.ascii_uppercase[i], transform=a.transAxes,size=16, weight='bold') -# i += 1 -ax1.text(-0.4, 1.2, string.ascii_uppercase[0], transform=ax1.transAxes, size=16, weight='bold') -ax3.text(-0.15, 1.05, string.ascii_uppercase[1], transform=ax3.transAxes, size=16, weight='bold') - -show_spines(ax3, '') -#ax3.set_ylabel('$\\Delta$ AUC', rotation='vertical') -#ax3.set_xlabel('$\\Delta$ rheobase') -plot_quadrant(ax3) # plot delineation into quadrants - - -inset_ylim = (0, 100) -# top left -lfsize = 8 -ax3.text(x=-0.9, y=0.7, s='$\\uparrow$ AUC\n$\\downarrow$ rheobase', fontsize=lfsize) -ax3.text(-0.95, 0.35, 'GOF', ha='right') -ax3_TL = ax3.inset_axes([0.07, 0.6, 0.3, 0.2]) -plot_diff_sqrt(ax3_TL, b2=0.1, c2=200) -ax3_TL.set_ylim(inset_ylim) - -# top right -ax3.text(x=0.22, y=0.7, s='$\\uparrow$ AUC\n$\\uparrow$ rheobase', fontsize=lfsize) -ax3.text(0.95, 0.35, 'LOF/\nGOF?') -ax3_TR = ax3.inset_axes([0.63, 0.6, 0.3, 0.2]) -plot_diff_sqrt(ax3_TR, b2=0.4, c2=200) -ax3_TR.set_ylim(inset_ylim) - -# bottom left -ax3.text(x=-0.9, y=-0.95, s='$\\downarrow$ AUC\n$\downarrow$ rheobase', fontsize=lfsize) -ax3.text(-0.95, -0.55, 'GOF/\nLOF?', ha='right') -ax3_BL = ax3.inset_axes([0.07, 0.15, 0.3, 0.2]) -plot_diff_sqrt(ax3_BL, b2=0.07, c2=65) -ax3_BL.set_ylim(inset_ylim) - -# bottom right -ax3.text(x=0.22, y=-0.95, s='$\\downarrow$ AUC\n$\\uparrow$ rheobase', fontsize=lfsize) -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=60) -ax3_BR.set_ylim(inset_ylim) - - - -import matplotlib.lines as mlines -wt = mlines.Line2D([], [], color=colorslist[9], linestyle='-',label='WT') -mut = mlines.Line2D([], [], color=colorslist[2], linestyle='-',label='Altered') -pos = (0.575, 0.05) -ncol = 2 -fig.legend(handles=[wt, mut], loc='center', bbox_to_anchor=pos, ncol=ncol, frameon=False, fontsize=8) - -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() - - - -#%% with arrows -fig = plt.figure(figsize=cm2inch(7, 12)) -gs = gridspec.GridSpec(3,6, top=0.95, bottom=0.1, left=0.15, right = 0.95, hspace=0.8, wspace=0.6) -ax1 = fig.add_subplot(gs[0,1:]) -show_spines(ax1, 'lb') -plot_AUC(ax1, width=0.2) -ax3 = fig.add_subplot(gs[1:, :]) - -# add panel letter labels -# ax_list = fig.axes -# i =0 -# for a in ax_list: -# a.text(-0.25, 1.08, string.ascii_uppercase[i], transform=a.transAxes,size=16, weight='bold') -# i += 1 -ax1.text(-0.4, 1.2, string.ascii_uppercase[0], transform=ax1.transAxes, size=16, weight='bold') -ax3.text(-0.15, 1.05, string.ascii_uppercase[1], transform=ax3.transAxes, size=16, weight='bold') - -show_spines(ax3, '') -#ax3.set_ylabel('$\\Delta$ AUC', rotation='vertical') -#ax3.set_xlabel('$\\Delta$ rheobase') -plot_quadrant(ax3) # plot delineation into quadrants - - -inset_ylim = (0, 100) -# top left -lfsize = 8 -ax3.text(x=-0.9, y=0.7, s='$\\uparrow$ AUC\n$\\downarrow$ rheobase', fontsize=lfsize) -ax3.text(-0.95, 0.35, 'GOF', ha='right') -ax3_TL = ax3.inset_axes([0.07, 0.6, 0.3, 0.2]) -plot_diff_sqrt(ax3_TL, b2=0.09, c2=200) -ax3_TL.set_ylim(inset_ylim) -ax3_TL.annotate('', (0.25, 7), (0.085, 7), arrowprops=dict(arrowstyle="<|-", color=colorslist[2],lw=0.5, mutation_scale=5), zorder=-10) # -ax3_TL.annotate('', (0.55, 55), (0.3, 90), arrowprops=dict(arrowstyle="<|-", color=colorslist[2],lw=0.5, mutation_scale=5), zorder=-10) # -# top right -ax3.text(x=0.22, y=0.7, s='$\\uparrow$ AUC\n$\\uparrow$ rheobase', fontsize=lfsize) -ax3.text(0.95, 0.35, 'LOF/\nGOF?') -ax3_TR = ax3.inset_axes([0.63, 0.6, 0.3, 0.2]) -plot_diff_sqrt(ax3_TR, b2=0.4, c2=200) -ax3_TR.set_ylim(inset_ylim) -ax3_TR.annotate('', (0.17, 7), (0.41, 7), arrowprops=dict(arrowstyle="<|-", color=colorslist[2],lw=0.5, mutation_scale=5), zorder=-10) # -ax3_TR.annotate('', (0.8, 70), (0.6, 90), arrowprops=dict(arrowstyle="<|-", color=colorslist[2],lw=0.5, mutation_scale=5), zorder=-10) # - -# bottom left -ax3.text(x=-0.9, y=-0.95, s='$\\downarrow$ AUC\n$\downarrow$ rheobase', fontsize=lfsize) -ax3.text(-0.95, -0.55, 'GOF/\nLOF?', ha='right') -ax3_BL = ax3.inset_axes([0.07, 0.15, 0.3, 0.2]) -plot_diff_sqrt(ax3_BL, b2=0.06, c2=65) -ax3_BL.set_ylim(inset_ylim) -ax3_BL.annotate('', (0.25, 7), (0.07, 7), arrowprops=dict(arrowstyle="<|-", color=colorslist[2],lw=0.5, mutation_scale=5), zorder=-10) # -ax3_BL.annotate('', (0.8, 80), (0.85, 55), arrowprops=dict(arrowstyle="<|-", color=colorslist[2],lw=0.5, mutation_scale=5), zorder=-10) # - -# bottom right -ax3.text(x=0.22, y=-0.95, s='$\\downarrow$ AUC\n$\\uparrow$ rheobase', fontsize=lfsize) -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=60) -ax3_BR.set_ylim(inset_ylim) -ax3_BR.annotate('', (0.18, 7), (0.42, 7), arrowprops=dict(arrowstyle="<|-", color=colorslist[2],lw=0.5, mutation_scale=5), zorder=-10) # -ax3_BR.annotate('', (0.7, 75), (0.8, 37.5), arrowprops=dict(arrowstyle="<|-", color=colorslist[2],lw=0.5, mutation_scale=5), zorder=-10) # - - - -fig.set_size_inches(cm2inch(8.5,12)) -fig.savefig('./Figures/firing_characterization_arrows.pdf', dpi=fig.dpi) #bbox_inches='tight', dpi=fig.dpi -plt.show() diff --git a/Figures/firing_characterization.pdf b/Figures/firing_characterization.pdf index 757d8ca51bd35168f99c9e8a1e2b97ca3054653b..c8372693523f0276da6bda04ec7f0eea4a557b31 100644 GIT binary patch delta 7857 zcmZvBc{r5O`+h1}%R1IU)-YriV`d~m$i8KleJf%ZX>7gOWzS9_WXUdjBs2CUOR_{{ z?Adn;_4EDy)=z%#bv@Vhp8LG#-1l=o&w2kj-)qS#Yso5<$v7mTH!+fuXfzCs#-Ohw z&W11~N)io4z!I#7h;P@Gf#1VODqz4#i?FgTO!J$aN*HpAUFRz zWJh25CN7ZRt14P`|4X5@Mk@`Kf#sCl4ucGXK+u@0wzk*tL&T*1$?=n_NyU@npLSc5 zy9qRl=8D4Yq%p_2a&EbaR7EnWVK=!fE#USP@LXYfMv+dt0C4Fi%-BA`b-(6%<{>tb zgnNhi1)p)`Kj_bTT-YtJl^aLZoAPnux21aJ!V!mARq3;;%GV1LVknpH4E3nmx2euk z7C&5o2@97)9`x5kyZ&#Etcpmdtp?*rIy)u^@UH!6Ww2*`Uwb*H;OKDGYyDEe&r5(G zexFb?KiusD05_>d_VoeH@ma+oC9l+dl8ZVmCMXOMp_;wx^m+!b)v=UQjkX=6yP1b8 z!l)3oUHlJT2E82U=HyA(p;siL8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nCo6uU=Kx H*I@jA_2W2J diff --git a/Figures/firing_characterization.py b/Figures/firing_characterization.py index f6d4617..cf5a33e 100644 --- a/Figures/firing_characterization.py +++ b/Figures/firing_characterization.py @@ -1,10 +1,26 @@ import numpy as np import matplotlib.pyplot as plt import matplotlib.gridspec as gridspec +import matplotlib.ticker as ticker +from matplotlib.colors import colorConverter as cc +from matplotlib.colors import to_hex import string -# from plotstyle import plot_style from plotstyle import scheme_style +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 + ] + def cm2inch(*tupl): inch = 2.54 if isinstance(tupl[0], tuple): @@ -12,6 +28,165 @@ def cm2inch(*tupl): else: return tuple(i/inch for i in tupl) + +def show_spines(ax, spines='lrtb'): + """ Show and hide spines. + + From github.com/janscience/plottools.git spines.py + + Parameters + ---------- + ax: matplotlib figure, matplotlib axis, or list of matplotlib axes + Axis on which spine and ticks visibility is manipulated. + If figure, then apply manipulations on all axes of the figure. + If list of axes, apply manipulations on each of the given axes. + spines: string + Specify which spines and ticks should be shown. + All other ones or hidden. + 'l' is the left spine, 'r' the right spine, + 't' the top one and 'b' the bottom one. + E.g. 'lb' shows the left and bottom spine, and hides the top + and and right spines, as well as their tick marks and labels. + '' shows no spines at all. + 'lrtb' shows all spines and tick marks. + + Examples + -------- + ```py + import matplotlib.pyplot as plt + import plottools.spines + + fig, (ax0, ax1, ax2) = plt.subplots(1, 3) + ax0.show_spines('lb') + ax1.show_spines('bt') + ax2.show_spines('tr') + ``` + ![show](figures/spines-show.png) + """ + # collect spine visibility: + xspines = [] + if 't' in spines: + xspines.append('top') + if 'b' in spines: + xspines.append('bottom') + yspines = [] + if 'l' in spines: + yspines.append('left') + if 'r' in spines: + yspines.append('right') + # collect axes: + if isinstance(ax, (list, tuple, np.ndarray)): + axs = ax + elif hasattr(ax, 'get_axes'): + # ax is figure: + axs = ax.get_axes() + else: + axs = [ax] + if not isinstance(axs, (list, tuple)): + axs = [axs] + for ax in axs: + # hide spines: + ax.spines['top'].set_visible('top' in xspines) + ax.spines['bottom'].set_visible('bottom' in xspines) + ax.spines['left'].set_visible('left' in yspines) + ax.spines['right'].set_visible('right' in yspines) + # ticks: + if len(xspines) == 0: + ax.xaxis.set_ticks_position('none') + ax.xaxis.label.set_visible(False) + ax.xaxis._orig_major_locator = ax.xaxis.get_major_locator() + ax.xaxis.set_major_locator(ticker.NullLocator()) + else: + if hasattr(ax.xaxis, '_orig_major_locator'): + ax.xaxis.set_major_locator(ax.xaxis._orig_major_locator) + delattr(ax.xaxis, '_orig_major_locator') + elif isinstance(ax.xaxis.get_major_locator(), ticker.NullLocator): + ax.xaxis.set_major_locator(ticker.AutoLocator()) + if len(xspines) == 1: + ax.xaxis.set_ticks_position(xspines[0]) + ax.xaxis.set_label_position(xspines[0]) + else: + ax.xaxis.set_ticks_position('both') + ax.xaxis.set_label_position('bottom') + if len(yspines) == 0: + ax.yaxis.set_ticks_position('none') + ax.yaxis.label.set_visible(False) + ax.yaxis._orig_major_locator = ax.yaxis.get_major_locator() + ax.yaxis.set_major_locator(ticker.NullLocator()) + else: + if hasattr(ax.yaxis, '_orig_major_locator'): + ax.yaxis.set_major_locator(ax.yaxis._orig_major_locator) + delattr(ax.yaxis, '_orig_major_locator') + elif isinstance(ax.yaxis.get_major_locator(), ticker.NullLocator): + ax.yaxis.set_major_locator(ticker.AutoLocator()) + if len(yspines) == 1: + ax.yaxis.set_ticks_position(yspines[0]) + ax.yaxis.set_label_position(yspines[0]) + else: + ax.yaxis.set_ticks_position('both') + ax.yaxis.set_label_position('left') + + + +def lighter(color, lightness): + """ Make a color lighter. + + From github.com/janscience/plottools.git colors.py + + ![lighter](figures/colors-lighter.png) + + Parameters + ---------- + color: dict or matplotlib color spec + A matplotlib color (hex string, name color string, rgb tuple) + or a dictionary with an 'color' or 'facecolor' key. + lightness: float + The smaller the lightness, the lighter the returned color. + A lightness of 0 returns white. + A lightness of 1 leaves the color untouched. + A lightness of 2 returns black. + + Returns + ------- + color: string or dict + The lighter color as a hexadecimal RGB string (e.g. '#rrggbb'). + If `color` is a dictionary, a copy of the dictionary is returned + with the value of 'color' or 'facecolor' set to the lighter color. + + Examples + -------- + For 40% lightness of blue do + ```py + import plottools.colors as c + colors = c.palettes['muted'] + lightblue = c.lighter(colors['blue'], 0.4) + ``` + """ + try: + c = color['color'] + cd = dict(**color) + cd['color'] = lighter(c, lightness) + return cd + except (KeyError, TypeError): + try: + c = color['facecolor'] + cd = dict(**color) + cd['facecolor'] = lighter(c, lightness) + return cd + except (KeyError, TypeError): + if lightness > 2: + lightness = 2 + if lightness > 1: + return darker(color, 2.0-lightness) + if lightness < 0: + lightness = 0 + r, g, b = cc.to_rgb(color) + rl = r + (1.0-lightness)*(1.0 - r) + gl = g + (1.0-lightness)*(1.0 - g) + bl = b + (1.0-lightness)*(1.0 - b) + return to_hex((rl, gl, bl)).upper() + + def plot_sqrt(ax, a=1, b=0.2, c=100, d=0): x = np.linspace(0, 1, 10000) y = c*np.sqrt(a*(x - b)) + d @@ -21,162 +196,173 @@ def plot_sqrt(ax, a=1, b=0.2, c=100, d=0): ax.set_xlim(0,1) ax.set_ylim(0, ax.get_ylim()[1]) -def plot_AUC(ax, a=1, b=0.2, c=100, d=0, width=0.2): - x = np.linspace(0, 1, 10000) +def plot_AUC(ax, a=1, b=0.2, c=180, d=0, width=0.2): + x = np.linspace(0, 1, 1000) y = c*np.sqrt(a*(x - b)) + d - ax.plot(x, y, 'k') + ax.plot(x, y, colorslist[9]) ax.set_xlabel('Current [nA]') ax.set_ylabel('Frequency [Hz]') - ax.fill_between(x,y, where=(x<=b+width), color='c') - ax.set_xlim(0,1) + ax.fill_between(x, y, where=(x<=b+width), color=lighter(colorslist[9], 0.3)) + ax.text(0.3, 15, 'AUC', ha='center') + ax.annotate('', (0.2, 10), (0, 10), arrowprops=dict(arrowstyle="<->")) + ax.text(0.1, 20, 'rheobase', ha='center') + ax.set_xlim(0, 0.5) ax.set_ylim(0, 100) ax.yaxis.set_major_locator(ticker.MultipleLocator(50)) def plot_diff_sqrt(ax, a=1, b=0.2, c=100, d=0, a2=1, b2=0.2, c2=100, d2=0): + show_spines(ax, 'lb') x = np.linspace(0, 1, 10000) y = c*np.sqrt(a*(x - b)) + d y2 = c2 * np.sqrt(a2 * (x - b2)) + d2 - ax.plot(x, y, 'k') - ax.plot(x, y2, 'b') + ax.plot(x, y, colorslist[9]) + ax.plot(x, y2, colorslist[2]) ax.set_xlim(0,1) ax.set_ylim(0, ax.get_ylim()[1]) ax.set_xticks([]) ax.set_yticks([]) + def plot_quadrant(ax): - ax.plot(ax.get_xlim(),[0,0], '--k', linewidth=1.25) - ax.plot([0,0],ax.get_ylim(), '--k', linewidth=1.25) - ax.tick_params(axis=u'both', which=u'both', length=0) - ax.set_xticks([-0.55, 0, 0.55]) + ax.spines['left'].set_position('zero') + ax.spines['bottom'].set_position('zero') + ax.text(1.2, -0.15, '$\\Delta$ rheobase', ha='right') + ax.text(-0.03, 0.7, '$\\Delta$ AUC', ha='right', rotation=90) + ax.tick_params(length=0) + ax.set_xlim(-1, 1) + ax.set_ylim(-1, 1) + ax.annotate('', (1, 0), (-1, 0), arrowprops=dict(arrowstyle="->")) + ax.annotate('', (0, 1), (0, -1), arrowprops=dict(arrowstyle="->")) + ax.set_xticks([-0.5, 0.5]) a = ax.get_xticks().tolist() a[0] = '\u2212' - a[1] = 0 - a[2] = '+' + a[1] = '+' ax.set_xticklabels(a) - ax.set_yticks([-0.55, 0, 0.55]) + ax.set_yticks([-0.5, 0.5]) b = ax.get_xticks().tolist() b[0] = '\u2212' - b[1] = 0 - b[2] = '+' + b[1] = '+' ax.set_yticklabels(b) - # ax.tick_params(labelsize=16) - # ax.set_yticks([0]) - # ax.axis('off') - -# plot_style() -scheme_style() +# scheme_style() +#%% with legend fig = plt.figure(figsize=cm2inch(7, 12)) -gs = gridspec.GridSpec(3,2, top=0.95, bottom=0.1, left=0.15, right = 0.95, hspace=0.8, wspace=0.6) -ax1 = fig.add_subplot(gs[0,:]) +gs = gridspec.GridSpec(3,6, top=0.95, bottom=0.1, left=0.15, right = 0.95, hspace=0.8, wspace=0.6) +ax1 = fig.add_subplot(gs[0,1:]) +show_spines(ax1, 'lb') plot_AUC(ax1, width=0.2) ax3 = fig.add_subplot(gs[1:, :]) # add panel letter labels -ax_list = fig.axes -i =0 -for a in ax_list: - a.text(-0.18, 1.08, string.ascii_uppercase[i], transform=a.transAxes,size=16, weight='bold') - i += 1 - -ax3.set_ylabel('$\Delta$ AUC') -ax3.set_xlabel('$\Delta$ rheobase') -ax3.set_xlim(-1, 1) -ax3.set_ylim(-1, 1) +ax1.text(-0.4, 1.2, string.ascii_uppercase[0], transform=ax1.transAxes, size=16, weight='bold') +ax3.text(-0.15, 1.05, string.ascii_uppercase[1], transform=ax3.transAxes, size=16, weight='bold') + +show_spines(ax3, '') plot_quadrant(ax3) # plot delineation into quadrants inset_ylim = (0, 100) # top left lfsize = 8 -ax3.text(x=-0.75, y=0.25, s=r'''$\uparrow$ AUC -$\downarrow$ rheobase''', fontsize=lfsize) -ax3_TL = ax3.inset_axes([0, 0.8, 0.3, 0.2]) +ax3.text(x=-0.9, y=0.7, s='$\\uparrow$ AUC\n$\\downarrow$ rheobase', fontsize=lfsize) +ax3.text(-0.95, 0.35, 'GOF', ha='right') +ax3_TL = ax3.inset_axes([0.07, 0.6, 0.3, 0.2]) plot_diff_sqrt(ax3_TL, b2=0.1, c2=200) ax3_TL.set_ylim(inset_ylim) + # top right -ax3.text(x=0.25, y=0.25, s=r'''$\uparrow$ AUC -$\uparrow$ rheobase''', fontsize=lfsize) -ax3_TR = ax3.inset_axes([0.7, 0.8, 0.3, 0.2]) +ax3.text(x=0.22, y=0.7, s='$\\uparrow$ AUC\n$\\uparrow$ rheobase', fontsize=lfsize) +ax3.text(0.95, 0.35, 'LOF/\nGOF?') +ax3_TR = ax3.inset_axes([0.63, 0.6, 0.3, 0.2]) plot_diff_sqrt(ax3_TR, b2=0.4, c2=200) ax3_TR.set_ylim(inset_ylim) + # bottom left -ax3.text(x=-0.75, y=-0.35, s=r'''$\downarrow$ AUC -$\downarrow$ rheobase''', fontsize=lfsize) -ax3_BL = ax3.inset_axes([0, 0, 0.3, 0.2]) -plot_diff_sqrt(ax3_BL, b2=0.1, c2=75) +ax3.text(x=-0.9, y=-0.95, s='$\\downarrow$ AUC\n$\downarrow$ rheobase', fontsize=lfsize) +ax3.text(-0.95, -0.55, 'GOF/\nLOF?', ha='right') +ax3_BL = ax3.inset_axes([0.07, 0.15, 0.3, 0.2]) +plot_diff_sqrt(ax3_BL, b2=0.07, c2=65) ax3_BL.set_ylim(inset_ylim) + # bottom right -ax3.text(x=0.25, y=-0.35, s=r'''$\downarrow$ AUC -$\uparrow$ rheobase''', fontsize=lfsize) -ax3_BR = ax3.inset_axes([0.7, 0, 0.3, 0.2]) -plot_diff_sqrt(ax3_BR, b2=0.4, c2=75) +ax3.text(x=0.22, y=-0.95, s='$\\downarrow$ AUC\n$\\uparrow$ rheobase', fontsize=lfsize) +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=60) ax3_BR.set_ylim(inset_ylim) -# fig.savefig('./Figures/firing_characterization.pdf', bbox_inches='tight') -print(fig.dpi) -fig.set_size_inches(cm2inch(8.17,15)) -fig.savefig('./Figures/firing_characterization.pdf', dpi=fig.dpi) #bbox_inches='tight', dpi=fig.dpi + + + +import matplotlib.lines as mlines +wt = mlines.Line2D([], [], color=colorslist[9], linestyle='-',label='WT') +mut = mlines.Line2D([], [], color=colorslist[2], linestyle='-',label='Altered') +pos = (0.575, 0.05) +ncol = 2 +fig.legend(handles=[wt, mut], loc='center', bbox_to_anchor=pos, ncol=ncol, frameon=False, fontsize=8) + +fig.set_size_inches(cm2inch(8.5,12)) +fig.savefig('./Figures/firing_characterization.pdf', dpi=fig.dpi) plt.show() -#%% OLD -# fig = plt.figure() -# # fig, axs = plt.subplots(2, 3, figsize=(6, 4)) -# # fig.subplots_adjust(top=0.95, bottom=0.1, left=0.1, right=0.95, hspace=0.6, wspace=0.6) -# gs = gridspec.GridSpec(2,3, top=0.95, bottom=0.1, left=0.1, right = 0.95, hspace=0.6, wspace=0.6) -# ax1 = fig.add_subplot(gs[0,0]) -# plot_AUC(ax1, width=0.2) -# ax2 = fig.add_subplot(gs[1, 0]) -# ax3 = fig.add_subplot(gs[:, 1:]) -# # ax_list = fig.axes -# # import string -# # i =0 -# # for a in ax_list: -# # a.text(-0.13, 1.05, string.ascii_uppercase[i], transform=a.transAxes,size=12, weight='bold') -# # i += 1 -# ax3.set_ylabel('$\Delta$ AUC') -# ax3.set_xlabel('$\Delta$ rheobase') -# ax3.set_xlim(-1,1) -# ax3.set_ylim(-1,1) -# plot_quadrant(ax3) -# -# # top left -# ax3.text(x=-0.75, y=0.25, s=r'''$\uparrow$ AUC -# $\downarrow$ rheobase''') -# ax3_TL = ax3.inset_axes([0,0.8,0.3,0.2]) -# plot_diff_sqrt(ax3_TL, b2=0.1, c2=200) -# -# # top right -# ax3.text(x=0.25, y=0.25, s=r'''$\uparrow$ AUC -# $\uparrow$ rheobase''') -# ax3_TR = ax3.inset_axes([0.7, 0.8, 0.3, 0.2]) -# plot_diff_sqrt(ax3_TR, b2=0.4, c2=200) -# -# # bottom left -# ax3.text(x=-0.75, y=-0.35, s=r'''$\downarrow$ AUC -# $\downarrow$ rheobase''') -# ax3_BL = ax3.inset_axes([0, 0, 0.3, 0.2]) -# plot_diff_sqrt(ax3_BL, b2=0.1, c2=75) -# -# # bottom right -# ax3.text(x=0.25, y=-0.35, s=r'''$\downarrow$ AUC -# $\uparrow$ rheobase''') -# ax3_BR = ax3.inset_axes([0.7, 0, 0.3, 0.2]) -# plot_diff_sqrt(ax3_BR, b2=0.4, c2=75) -# -# # ax3_TL.sharey(ax3_TR) -# -# # ax3_TL.get_shared_x_axes().join(ax3_TL, ax3_TR, ax3_BL, ax3_BR) -# # ax3_TL.get_shared_y_axes().join(ax3_TL, ax3_TR, ax3_BL, ax3_BR) -# ax_list = [ax3_TL, ax3_TR, ax3_BL, ax3_BR] #< your axes objects -# ax_list[0].get_shared_x_axes().join(*ax_list) -# plt.show() -# -# # plot_sqrt(axs[0,0]) -# # plot_temperature(axs[0,1]) -# # plot_signal_n_power(axs[1,0], axs[1,1]) -# # fig.savefig('coolresult.pdf') -# +#%% with arrows +fig = plt.figure(figsize=cm2inch(7, 12)) +gs = gridspec.GridSpec(3,6, top=0.95, bottom=0.1, left=0.15, right = 0.95, hspace=0.8, wspace=0.6) +ax1 = fig.add_subplot(gs[0,1:]) +show_spines(ax1, 'lb') +plot_AUC(ax1, width=0.2) +ax3 = fig.add_subplot(gs[1:, :]) + +# add panel letter labels +ax1.text(-0.4, 1.2, string.ascii_uppercase[0], transform=ax1.transAxes, size=16, weight='bold') +ax3.text(-0.15, 1.05, string.ascii_uppercase[1], transform=ax3.transAxes, size=16, weight='bold') + +show_spines(ax3, '') +plot_quadrant(ax3) # plot delineation into quadrants + + +inset_ylim = (0, 100) +# top left +lfsize = 8 +ax3.text(x=-0.9, y=0.7, s='$\\uparrow$ AUC\n$\\downarrow$ rheobase', fontsize=lfsize) +ax3.text(-0.95, 0.35, 'GOF', ha='right') +ax3_TL = ax3.inset_axes([0.07, 0.6, 0.3, 0.2]) +plot_diff_sqrt(ax3_TL, b2=0.09, c2=200) +ax3_TL.set_ylim(inset_ylim) +ax3_TL.annotate('', (0.25, 7), (0.085, 7), arrowprops=dict(arrowstyle="<|-", color=colorslist[2],lw=0.5, mutation_scale=5), zorder=-10) # +ax3_TL.annotate('', (0.55, 55), (0.3, 90), arrowprops=dict(arrowstyle="<|-", color=colorslist[2],lw=0.5, mutation_scale=5), zorder=-10) # +# top right +ax3.text(x=0.22, y=0.7, s='$\\uparrow$ AUC\n$\\uparrow$ rheobase', fontsize=lfsize) +ax3.text(0.95, 0.35, 'LOF/\nGOF?') +ax3_TR = ax3.inset_axes([0.63, 0.6, 0.3, 0.2]) +plot_diff_sqrt(ax3_TR, b2=0.4, c2=200) +ax3_TR.set_ylim(inset_ylim) +ax3_TR.annotate('', (0.17, 7), (0.41, 7), arrowprops=dict(arrowstyle="<|-", color=colorslist[2],lw=0.5, mutation_scale=5), zorder=-10) # +ax3_TR.annotate('', (0.8, 70), (0.6, 90), arrowprops=dict(arrowstyle="<|-", color=colorslist[2],lw=0.5, mutation_scale=5), zorder=-10) # + +# bottom left +ax3.text(x=-0.9, y=-0.95, s='$\\downarrow$ AUC\n$\downarrow$ rheobase', fontsize=lfsize) +ax3.text(-0.95, -0.55, 'GOF/\nLOF?', ha='right') +ax3_BL = ax3.inset_axes([0.07, 0.15, 0.3, 0.2]) +plot_diff_sqrt(ax3_BL, b2=0.06, c2=65) +ax3_BL.set_ylim(inset_ylim) +ax3_BL.annotate('', (0.25, 7), (0.07, 7), arrowprops=dict(arrowstyle="<|-", color=colorslist[2],lw=0.5, mutation_scale=5), zorder=-10) # +ax3_BL.annotate('', (0.8, 80), (0.85, 55), arrowprops=dict(arrowstyle="<|-", color=colorslist[2],lw=0.5, mutation_scale=5), zorder=-10) # + +# bottom right +ax3.text(x=0.22, y=-0.95, s='$\\downarrow$ AUC\n$\\uparrow$ rheobase', fontsize=lfsize) +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=60) +ax3_BR.set_ylim(inset_ylim) +ax3_BR.annotate('', (0.18, 7), (0.42, 7), arrowprops=dict(arrowstyle="<|-", color=colorslist[2],lw=0.5, mutation_scale=5), zorder=-10) # +ax3_BR.annotate('', (0.7, 75), (0.8, 37.5), arrowprops=dict(arrowstyle="<|-", color=colorslist[2],lw=0.5, mutation_scale=5), zorder=-10) # + + + +fig.set_size_inches(cm2inch(8.5,12)) +fig.savefig('./Figures/firing_characterization_arrows.pdf', dpi=fig.dpi) #bbox_inches='tight', dpi=fig.dpi +plt.show() diff --git a/Figures/firing_characterization_old.py b/Figures/firing_characterization_old.py new file mode 100644 index 0000000..0d92f70 --- /dev/null +++ b/Figures/firing_characterization_old.py @@ -0,0 +1,182 @@ +import numpy as np +import matplotlib.pyplot as plt +import matplotlib.gridspec as gridspec +import string +# from plotstyle import plot_style +from plotstyle import scheme_style + +def cm2inch(*tupl): + inch = 2.54 + if isinstance(tupl[0], tuple): + return tuple(i/inch for i in tupl[0]) + else: + return tuple(i/inch for i in tupl) + +def plot_sqrt(ax, a=1, b=0.2, c=100, d=0): + x = np.linspace(0, 1, 10000) + y = c*np.sqrt(a*(x - b)) + d + ax.plot(x, y) + ax.set_xlabel('Current [nA]') + ax.set_ylabel('Frequency [Hz]') + ax.set_xlim(0,1) + ax.set_ylim(0, ax.get_ylim()[1]) + +def plot_AUC(ax, a=1, b=0.2, c=100, d=0, width=0.2): + x = np.linspace(0, 1, 10000) + y = c*np.sqrt(a*(x - b)) + d + ax.plot(x, y, 'k') + ax.set_xlabel('Current [nA]') + ax.set_ylabel('Frequency [Hz]') + ax.fill_between(x,y, where=(x<=b+width), color='c') + ax.set_xlim(0,1) + ax.set_ylim(0, 100) + ax.yaxis.set_major_locator(ticker.MultipleLocator(50)) + +def plot_diff_sqrt(ax, a=1, b=0.2, c=100, d=0, a2=1, b2=0.2, c2=100, d2=0): + x = np.linspace(0, 1, 10000) + y = c*np.sqrt(a*(x - b)) + d + y2 = c2 * np.sqrt(a2 * (x - b2)) + d2 + ax.plot(x, y, 'k') + ax.plot(x, y2, 'b') + ax.set_xlim(0,1) + ax.set_ylim(0, ax.get_ylim()[1]) + ax.set_xticks([]) + ax.set_yticks([]) + +def plot_quadrant(ax): + ax.plot(ax.get_xlim(),[0,0], '--k', linewidth=1.25) + ax.plot([0,0],ax.get_ylim(), '--k', linewidth=1.25) + ax.tick_params(axis=u'both', which=u'both', length=0) + ax.set_xticks([-0.55, 0, 0.55]) + a = ax.get_xticks().tolist() + a[0] = '\u2212' + a[1] = 0 + a[2] = '+' + ax.set_xticklabels(a) + ax.set_yticks([-0.55, 0, 0.55]) + b = ax.get_xticks().tolist() + b[0] = '\u2212' + b[1] = 0 + b[2] = '+' + ax.set_yticklabels(b) + + # ax.tick_params(labelsize=16) + # ax.set_yticks([0]) + # ax.axis('off') + + +# plot_style() +scheme_style() + +fig = plt.figure(figsize=cm2inch(7, 12)) +gs = gridspec.GridSpec(3,2, top=0.95, bottom=0.1, left=0.15, right = 0.95, hspace=0.8, wspace=0.6) +ax1 = fig.add_subplot(gs[0,:]) +plot_AUC(ax1, width=0.2) +ax3 = fig.add_subplot(gs[1:, :]) + +# add panel letter labels +ax_list = fig.axes +i =0 +for a in ax_list: + a.text(-0.18, 1.08, string.ascii_uppercase[i], transform=a.transAxes,size=16, weight='bold') + i += 1 + +ax3.set_ylabel('$\Delta$ AUC') +ax3.set_xlabel('$\Delta$ rheobase') +ax3.set_xlim(-1, 1) +ax3.set_ylim(-1, 1) +plot_quadrant(ax3) # plot delineation into quadrants + + +inset_ylim = (0, 100) +# top left +lfsize = 8 +ax3.text(x=-0.75, y=0.25, s=r'''$\uparrow$ AUC +$\downarrow$ rheobase''', fontsize=lfsize) +ax3_TL = ax3.inset_axes([0, 0.8, 0.3, 0.2]) +plot_diff_sqrt(ax3_TL, b2=0.1, c2=200) +ax3_TL.set_ylim(inset_ylim) +# top right +ax3.text(x=0.25, y=0.25, s=r'''$\uparrow$ AUC +$\uparrow$ rheobase''', fontsize=lfsize) +ax3_TR = ax3.inset_axes([0.7, 0.8, 0.3, 0.2]) +plot_diff_sqrt(ax3_TR, b2=0.4, c2=200) +ax3_TR.set_ylim(inset_ylim) +# bottom left +ax3.text(x=-0.75, y=-0.35, s=r'''$\downarrow$ AUC +$\downarrow$ rheobase''', fontsize=lfsize) +ax3_BL = ax3.inset_axes([0, 0, 0.3, 0.2]) +plot_diff_sqrt(ax3_BL, b2=0.1, c2=75) +ax3_BL.set_ylim(inset_ylim) +# bottom right +ax3.text(x=0.25, y=-0.35, s=r'''$\downarrow$ AUC +$\uparrow$ rheobase''', fontsize=lfsize) +ax3_BR = ax3.inset_axes([0.7, 0, 0.3, 0.2]) +plot_diff_sqrt(ax3_BR, b2=0.4, c2=75) +ax3_BR.set_ylim(inset_ylim) +# fig.savefig('./Figures/firing_characterization.pdf', bbox_inches='tight') +print(fig.dpi) +fig.set_size_inches(cm2inch(8.17,15)) +fig.savefig('./Figures/firing_characterization_old.pdf', dpi=fig.dpi) #bbox_inches='tight', dpi=fig.dpi +plt.show() + + + +#%% OLD +# fig = plt.figure() +# # fig, axs = plt.subplots(2, 3, figsize=(6, 4)) +# # fig.subplots_adjust(top=0.95, bottom=0.1, left=0.1, right=0.95, hspace=0.6, wspace=0.6) +# gs = gridspec.GridSpec(2,3, top=0.95, bottom=0.1, left=0.1, right = 0.95, hspace=0.6, wspace=0.6) +# ax1 = fig.add_subplot(gs[0,0]) +# plot_AUC(ax1, width=0.2) +# ax2 = fig.add_subplot(gs[1, 0]) +# ax3 = fig.add_subplot(gs[:, 1:]) +# # ax_list = fig.axes +# # import string +# # i =0 +# # for a in ax_list: +# # a.text(-0.13, 1.05, string.ascii_uppercase[i], transform=a.transAxes,size=12, weight='bold') +# # i += 1 +# ax3.set_ylabel('$\Delta$ AUC') +# ax3.set_xlabel('$\Delta$ rheobase') +# ax3.set_xlim(-1,1) +# ax3.set_ylim(-1,1) +# plot_quadrant(ax3) +# +# # top left +# ax3.text(x=-0.75, y=0.25, s=r'''$\uparrow$ AUC +# $\downarrow$ rheobase''') +# ax3_TL = ax3.inset_axes([0,0.8,0.3,0.2]) +# plot_diff_sqrt(ax3_TL, b2=0.1, c2=200) +# +# # top right +# ax3.text(x=0.25, y=0.25, s=r'''$\uparrow$ AUC +# $\uparrow$ rheobase''') +# ax3_TR = ax3.inset_axes([0.7, 0.8, 0.3, 0.2]) +# plot_diff_sqrt(ax3_TR, b2=0.4, c2=200) +# +# # bottom left +# ax3.text(x=-0.75, y=-0.35, s=r'''$\downarrow$ AUC +# $\downarrow$ rheobase''') +# ax3_BL = ax3.inset_axes([0, 0, 0.3, 0.2]) +# plot_diff_sqrt(ax3_BL, b2=0.1, c2=75) +# +# # bottom right +# ax3.text(x=0.25, y=-0.35, s=r'''$\downarrow$ AUC +# $\uparrow$ rheobase''') +# ax3_BR = ax3.inset_axes([0.7, 0, 0.3, 0.2]) +# plot_diff_sqrt(ax3_BR, b2=0.4, c2=75) +# +# # ax3_TL.sharey(ax3_TR) +# +# # ax3_TL.get_shared_x_axes().join(ax3_TL, ax3_TR, ax3_BL, ax3_BR) +# # ax3_TL.get_shared_y_axes().join(ax3_TL, ax3_TR, ax3_BL, ax3_BR) +# ax_list = [ax3_TL, ax3_TR, ax3_BL, ax3_BR] #< your axes objects +# ax_list[0].get_shared_x_axes().join(*ax_list) +# plt.show() +# +# # plot_sqrt(axs[0,0]) +# # plot_temperature(axs[0,1]) +# # plot_signal_n_power(axs[1,0], axs[1,1]) +# # fig.savefig('coolresult.pdf') +# diff --git a/Figures/ramp_examples.py b/Figures/ramp_firing.py similarity index 95% rename from Figures/ramp_examples.py rename to Figures/ramp_firing.py index 72e245a..1812b05 100644 --- a/Figures/ramp_examples.py +++ b/Figures/ramp_firing.py @@ -253,17 +253,14 @@ def plot_I_ramp(ax): 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 @@ -273,7 +270,6 @@ fig = plt.figure(figsize=cm2inch(17.6,25)) gs0 = fig.add_gridspec(2, 1, wspace=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]) ax2_ramp = fig.add_subplot(gs00[1]) @@ -308,9 +304,7 @@ plt.rcParams.update({'font.size': 6}) add_scalebar(ax12_ramp, matchx=False, matchy=False, hidex=True, hidey=True, sizex=1000, sizey=50, labelx='1 s', labely='50 mV', loc=3, pad=-2, borderpad=0, barwidth=1, bbox_to_anchor=Bbox.from_bounds(0.01, 0.05, 1, 1), bbox_transform=ax12_ramp.transAxes) -# 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, @@ -320,9 +314,8 @@ add_scalebar(ax13_I, matchx=False, matchy=False, hidex=True, hidey=True, sizex=1 for i in range(0,len(models)): ramp_axs[i].text(-0.01, 1.1, string.ascii_uppercase[i], transform=ramp_axs[i].transAxes, size=10, weight='bold') -# fig.savefig('./Figures/ramp_firing.pdf') #, bbox_inches='tight' -print(fig.dpi) +#save fig.set_size_inches(cm2inch(17.6,22)) -fig.savefig('./Figures/ramp_firing.pdf', dpi=fig.dpi) #bbox_inches='tight', dpi=fig.dpi +fig.savefig('./Figures/ramp_firing.pdf', dpi=fig.dpi) plt.show() diff --git a/Figures/rheobase_correlation.py b/Figures/rheobase_correlation.py index 99bb848..c22ec7d 100644 --- a/Figures/rheobase_correlation.py +++ b/Figures/rheobase_correlation.py @@ -94,14 +94,11 @@ def new_scatter(self, *args, **kwargs): return FinalCollection Axes.scatter = new_scatter ############## End hack. ############## - ######################################################################################################################## #%% def boxplot_with_markers(ax,max_width, alteration='shift', msize=2.2): - # 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$', 'FS +$K_V1.1$','Cb stellate','Cb stellate +$K_V1.1$', @@ -123,7 +120,7 @@ def boxplot_with_markers(ax,max_width, alteration='shift', msize=2.2): ] 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)] + colors = [matplotlib.colors.to_rgb(c) for c in colorslist] clr_dict = {} for m in range(len(model_names)): clr_dict[model_names[m]] = colors[m] @@ -132,7 +129,7 @@ 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, + sns.swarmplot(y="corr", x="$\Delta V_{1/2}$", hue="model", data=df, palette=clr_dict, linewidth=0, orient='v', ax=ax, size=msize, order=['Na activation', 'Na inactivation', 'K activation', '$K_V1.1$ activation', '$K_V1.1$ inactivation', 'A activation', 'A inactivation'], @@ -150,7 +147,7 @@ def boxplot_with_markers(ax,max_width, alteration='shift', msize=2.2): df = pd.read_csv('./Figures/Data/rheo_scale_corr.csv') # Add in points to show each observation - sns.swarmplot(y="corr", x="Slope (k)", hue="model", data=df, #dodge=True, + sns.swarmplot(y="corr", x="Slope (k)", hue="model", data=df, palette=clr_dict, linewidth=0, orient='v', ax=ax, size=msize, order=['Na activation', 'Na inactivation', 'K activation', '$K_V1.1$ activation', '$K_V1.1$ inactivation', 'A activation', 'A inactivation'], @@ -168,7 +165,7 @@ def boxplot_with_markers(ax,max_width, alteration='shift', msize=2.2): df = pd.read_csv('./Figures/Data/rheo_g_corr.csv') # Add in points to show each observation - sns.swarmplot(y="corr", x="g", hue="model", data=df, #dodge=True, + sns.swarmplot(y="corr", x="g", hue="model", data=df, palette=clr_dict, linewidth=0, orient='v', ax=ax, size=msize, order=['Na', 'K', '$K_V1.1$', 'A', 'Leak'], hue_order=model_names, co2mk=Markers) @@ -184,7 +181,7 @@ def boxplot_with_markers(ax,max_width, alteration='shift', msize=2.2): 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()) + def model_legend(ax, marker_s_leg, pos, ncol): colorslist = [ '#40A787', # cyan'# @@ -201,16 +198,13 @@ def model_legend(ax, marker_s_leg, pos, ncol): '#D03050' # pink ] 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)] + colors = [matplotlib.colors.to_rgb(c) for c in colorslist] model_pos = {'Cb stellate':0, 'RS Inhibitory':1, 'FS':2, 'RS Pyramidal':3, 'RS Inhibitory +$\mathrm{K}_{\mathrm{V}}\mathrm{1.1}$':4, 'Cb stellate +$\mathrm{K}_{\mathrm{V}}\mathrm{1.1}$':5, 'FS +$\mathrm{K}_{\mathrm{V}}\mathrm{1.1}$':6, 'RS Pyramidal +$\mathrm{K}_{\mathrm{V}}\mathrm{1.1}$':7, 'STN +$\mathrm{K}_{\mathrm{V}}\mathrm{1.1}$':8, 'Cb stellate $\Delta$$\mathrm{K}_{\mathrm{V}}\mathrm{1.1}$':9, 'STN $\Delta$$\mathrm{K}_{\mathrm{V}}\mathrm{1.1}$':10, 'STN':11} - - - Markers = ["o", "o", "o", "^", "^", "^", "D", "D", "D", "s", "s", "s"] RS_p = mlines.Line2D([], [], color=colors[model_pos['RS Pyramidal']], marker=Markers[model_pos['RS Pyramidal']], markersize=marker_s_leg, linestyle='None', label='RS pyramidal') @@ -236,7 +230,6 @@ def model_legend(ax, marker_s_leg, pos, ncol): ax.legend(handles=[RS_p, RS_i, FS, RS_p_Kv, RS_i_Kv, FS_Kv, Cb, Cb_pl, Cb_sw, STN, STN_pl, STN_sw], loc='center', bbox_to_anchor=pos, ncol=ncol, frameon=False) - def plot_rheo_alt(ax, model='FS', color1='red', color2='dodgerblue', alteration='shift'): ax.spines["right"].set_visible(False) ax.spines["top"].set_visible(False) @@ -273,8 +266,7 @@ def plot_rheo_alt(ax, model='FS', color1='red', color2='dodgerblue', alteration= '#873770', # magenta ] 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)] + colors = [matplotlib.colors.to_rgb(c) for c in colorslist] clr_dict = {} for m in range(len(model_names)): clr_dict[model_names[m]] = colors[m] @@ -373,9 +365,7 @@ pad_w = 1.1 pad_h = 0.7 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:7]) ax0_ex = fig.add_subplot(gs[0,1]) ax0_fI = fig.add_subplot(gs[0,0]) @@ -433,69 +423,6 @@ ax2_ex.text(-0.8, 1.35, string.ascii_uppercase[7], transform=ax2_ex.transAxes, s ax2.text(-0.075, 1.35, string.ascii_uppercase[8], transform=ax2.transAxes, size=10, weight='bold') # save -# fig.savefig('./Figures/rheobase_correlation.pdf', bbox_inches='tight') -print(fig.dpi) 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() - -# #%% alternative layout -# marker_s_leg = 8 -# max_width = 10 -# pad_x = 0.2 -# pad_y= 0.4 -# pad_w = 0.22 -# pad_h = 0.6 -# -# fig = plt.figure(figsize=(12,20)) -# gs = fig.add_gridspec(3, 1, hspace=0.4, wspace=0.4) -# gs0 = gs[0].subgridspec(2, 4, wspace=0.6, hspace=1.) -# gs1 = gs[1].subgridspec(2, 4, wspace=0.6, hspace=1.) -# gs2 = gs[2].subgridspec(2, 4, wspace=0.6, hspace=1.) -# ax0 = fig.add_subplot(gs0[1,:]) -# ax0_ex = fig.add_subplot(gs0[0,2:]) -# ax0_fI = fig.add_subplot(gs0[0,:2]) -# ax1 = fig.add_subplot(gs1[1,:]) -# ax1_ex = fig.add_subplot(gs1[0,2:]) -# ax1_fI = fig.add_subplot(gs1[0,:2]) -# ax2 = fig.add_subplot(gs2[1,:]) -# ax2_ex = fig.add_subplot(gs2[0,2:]) -# ax2_fI = fig.add_subplot(gs2[0,:2]) -# -# -# ax0_fI = plot_fI(ax0_fI, model='FS +$\mathrm{K}_{\mathrm{V}}\mathrm{1.1}$', type='shift', alt='s', color1='lightgrey', color2='k') -# rec = plt.Rectangle((-pad_x, -pad_y), 1 + pad_w, 1 + pad_h, fill=False, lw=2,transform=ax0_fI.transAxes, color=color_dict['FS +$\mathrm{K}_{\mathrm{V}}\mathrm{1.1}$'], alpha=1, zorder=-1) -# rec = ax0_fI.add_patch(rec) -# rec.set_clip_on(False) -# -# ax1_fI = plot_fI(ax1_fI, model='Cb stellate +$\mathrm{K}_{\mathrm{V}}\mathrm{1.1}$', type='slope', alt='u', color1='lightgrey', color2='k') -# rec = plt.Rectangle((-pad_x, -pad_y), 1 + pad_w, 1 + pad_h, fill=False, lw=2,transform=ax1_fI.transAxes, color=color_dict['Cb stellate +$\mathrm{K}_{\mathrm{V}}\mathrm{1.1}$'], alpha=1, zorder=-1) -# rec = ax1_fI.add_patch(rec) -# rec.set_clip_on(False) -# -# ax2_fI = plot_fI(ax2_fI, model='Cb stellate', type='g', alt='Leak', color1='lightgrey', color2='k') -# rec = plt.Rectangle((-pad_x, -pad_y), 1 + pad_w, 1 + pad_h, fill=False, lw=2,transform=ax2_fI.transAxes, color=color_dict['Cb stellate'], alpha=1, zorder=-1) -# rec = ax2_fI.add_patch(rec) -# rec.set_clip_on(False) -# -# # label subplots with letters -# ax0_fI.text(-0.2, 1.38, string.ascii_uppercase[0], transform=ax0_fI.transAxes, size=16, weight='bold') #-0.09 -# ax1_fI.text(-0.2, 1.38, string.ascii_uppercase[1], transform=ax1_fI.transAxes,size=16, weight='bold') -# ax2_fI.text(-0.2, 1.38, string.ascii_uppercase[2], transform=ax2_fI.transAxes,size=16, weight='bold') -# -# # plot boxplots -# boxplot_with_markers(ax0,max_width, alteration='shift') -# boxplot_with_markers(ax1,max_width, alteration='slope') -# boxplot_with_markers(ax2,max_width, alteration='g') -# # plot legend -# pos = (0.5, -1.) -# ncol = 6 -# model_legend(ax2, marker_s_leg, pos, ncol) -# -# # # plot rheo across model for example alteration -# plot_rheo_alt(ax0_ex,model='FS +$\mathrm{K}_{\mathrm{V}}\mathrm{1.1}$', color1='lightgrey', color2='k', alteration='shift') -# plot_rheo_alt(ax1_ex,model='Cb stellate +$\mathrm{K}_{\mathrm{V}}\mathrm{1.1}$', color1='lightgrey', color2='k',alteration='slope') -# plot_rheo_alt(ax2_ex, model='Cb stellate', color1='lightgrey', color2='k', alteration='g') -# -# fig.savefig('rheobase_correlation_2.pdf', bbox_inches='tight') -# plt.show() diff --git a/Figures/simulation_model_comparison.py b/Figures/simulation_model_comparison.py index 416d238..78449b7 100644 --- a/Figures/simulation_model_comparison.py +++ b/Figures/simulation_model_comparison.py @@ -3,7 +3,6 @@ import matplotlib.pyplot as plt import pandas as pd import os import string -# from plotstyle import plot_style from Figures.plotstyle import sim_style import seaborn as sns import scipy.stats as stats @@ -21,20 +20,17 @@ def Kendall_tau(df): p = pd.DataFrame(columns=df.columns, index=df.columns) for col in range((df.columns).shape[0]): for col2 in range((df.columns).shape[0]): - # print(col, col2) if col != col2: _, p.loc[df.columns[col], df.columns[col2]] = stats.kendalltau( df[df.columns[col]], df[df.columns[col2]], nan_policy='omit') return tau, p def correlation_plot(ax, df='AUC', title='', cbar=False): - # cbar_ax = fig.add_axes([0.94, .25, .03, .4]) cbar_ax = fig.add_axes([0.685, 0.44, .15, .01]) cbar_ax.spines['left'].set_visible(False) cbar_ax.spines['bottom'].set_visible(False) cbar_ax.spines['right'].set_visible(False) cbar_ax.spines['top'].set_visible(False) - # cbar_ax.axis('off') cbar_ax.set_xticks([]) cbar_ax.set_yticks([]) if df == 'AUC': @@ -102,7 +98,7 @@ def correlation_plot(ax, df='AUC', title='', cbar=False): def mutation_plot(ax, model='RS_pramidal'): models = ['RS_pyramidal', 'RS_inhib', 'FS', 'Cb_stellate', 'Cb_stellate_Kv', 'Cb_stellate_Kv_only', 'STN', 'STN_Kv', 'STN_Kv_only'] - model_names = ['RS pyramidal', 'RS inhibitory', 'FS', #'RS pyramidal', 'RS inhibitory', 'FS', 'IB', + model_names = ['RS pyramidal', 'RS inhibitory', 'FS', '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}$'] model_display_names = ['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', @@ -117,7 +113,6 @@ def mutation_plot(ax, model='RS_pramidal'): ax_dict['RS_pyramidal'] = (0, 0) ax_dict['RS_inhib'] = (0, 1) ax_dict['FS'] = (1, 0) - # ax_dict['IB'] = (1, 1) ax_dict['Cb_stellate'] = (2, 0) ax_dict['Cb_stellate_Kv'] = (2, 1) ax_dict['Cb_stellate_Kv_only'] = (3, 0) @@ -129,7 +124,6 @@ def mutation_plot(ax, model='RS_pramidal'): ylim_dict['RS_pyramidal'] = (-0.1, 0.3) ylim_dict['RS_inhib'] = (-0.6, 0.6) ylim_dict['FS'] = (-0.06, 0.08) - # ylim_dict['IB'] = (-0.2, 0.2) ylim_dict['Cb_stellate'] = (-0.1, 0.4) ylim_dict['Cb_stellate_Kv'] = (-0.1, 0.5) ylim_dict['Cb_stellate_Kv_only'] = (-1, 0.8) @@ -152,7 +146,7 @@ def mutation_plot(ax, model='RS_pramidal'): mut_names = AUC.index ax.plot(rheo.loc[mut_names, model_names[mod]]*1000, AUC.loc[mut_names, model_names[mod]], linestyle='', markeredgecolor='grey', markerfacecolor='grey', marker=Marker_dict[model_display_names[mod]], - markersize=2) # markeredgecolor=clr_dict[model_names[mod]],markerfacecolor=clr_dict[model_names[mod]], + markersize=2) ax.plot(rheo.loc['wt', model_names[mod]], AUC.loc['wt', model_names[mod]], 'sk') @@ -165,13 +159,12 @@ def mutation_plot(ax, model='RS_pramidal'): markeredgecolor=mut_col[2], markerfacecolor=mut_col[2], marker=Marker_dict[model_display_names[mod]],markersize=4) ax.plot(rheo.loc['V404I', model_names[mod]]*1000, AUC.loc['V404I', model_names[mod]], linestyle='', markeredgecolor=mut_col[3], markerfacecolor=mut_col[5], marker=Marker_dict[model_display_names[mod]],markersize=4) - ax.set_title(model_display_names[mod], pad=14)#, color=clr_dict[models[mod]]) , fontsize=14 - ax.set_xlabel('$\Delta$ Rheobase (pA)')#, fontsize=6) - ax.set_ylabel('Normalized $\Delta$AUC')#, fontsize=6) + ax.set_title(model_display_names[mod], pad=14) + ax.set_xlabel('$\Delta$ Rheobase (pA)') + ax.set_ylabel('Normalized $\Delta$AUC') ax.spines['right'].set_visible(False) ax.spines['top'].set_visible(False) - # ax.ticklabel_format(style='scientific', useMathText=True, useOffset=False) - ax.ticklabel_format(axis="y", style="sci", scilimits=(0, 0),useMathText=True) #,useOffset=False + ax.ticklabel_format(axis="y", style="sci", scilimits=(0, 0),useMathText=True) xmin, xmax = ax.get_xlim() ymin, ymax = ax.get_ylim() @@ -196,10 +189,9 @@ def mutation_legend(ax, marker_s_leg, pos, ncol): -# plot_style() sim_style() # plot setup -fig = plt.figure() #figsize=cm2inch(17.6,15) +fig = plt.figure() gs0 = fig.add_gridspec(1, 6, wspace=-0.2) gsl = gs0[0:3].subgridspec(3, 3, wspace=0.9, hspace=0.8) gsr = gs0[4:6].subgridspec(6, 1, wspace=0.6, hspace=1) @@ -247,9 +239,7 @@ axr0.text(-0.77, 1.1, string.ascii_uppercase[j], transform=axr0.transAxes, size= axr1.text(-0.77, 1.1, string.ascii_uppercase[j+1], transform=axr1.transAxes, size=10, weight='bold') # save -# fig.savefig('./Figures/simulation_model_comparison.pdf') #, bbox_inches='tight' -print(fig.dpi) fig.set_size_inches(cm2inch(22.2,15)) -fig.savefig('./Figures/simulation_model_comparison.pdf', dpi=fig.dpi) #bbox_inches='tight', dpi=fig.dpi +fig.savefig('./Figures/simulation_model_comparison.pdf', dpi=fig.dpi) plt.show()