% The script was written by Natalia Maksymchuk for the article
% Maksymchuk N, Sakurai A, Cox DN, Cymbalyuk GS.
% Cold-Temperature Coding with Bursting and Spiking
% Based on TRP Channel Dynamics in Drosophila Larva Sensory Neurons.
% International Journal of Molecular Sciences. 2023; 24(19):14638.
% https://doi.org/10.3390/ijms241914638
load('N.mat');
load('Data.mat');
% Create labels for heat maps
% Create text files for correspondence of GLTRP and Temperature to j and i
% Temperature
[fidTemp,message]= fopen('T.txt', 'w');
for i=1:NC2 %T
fprintf(fidTemp,'%f ',i,Tv(i));% file for correspondence
fprintf(fidTemp,'\n');
Tvalues(i) = {num2str(Tv(i))};% label values for heat map
end
fclose(fidTemp);
% GLTRP
[fidGleakTest,message]= fopen('GleakTest.txt', 'w');
for j=1:NC1%GleakTest
fprintf(fidGleakTest,'%f ',j,GLTestv(j));
fprintf(fidGleakTest,'\n');
GLTestValues(j) = {num2str(GLTestv(j))};%label values for heat map
end
fclose(fidGleakTest);
%% Heat maps
pp1range=GLTestv; %x values
pp2range=Tv; %y values
pp1='G_{LTRP} (nS)';
pp2='Temp ({}^oC)';
ptsize=72; % size of squares on stationary heat map
cirklesize=65.; % size of circles on GTRP trajectory
%% Frequency ********************************************
% Mean Frequency
HeatMapValues=MeanFreq;
titleString='MF (Hz)';
colorbarString='MF (Hz)';
figure;
for ii=1:length(pp2range)
hm=scatter(pp1range,ones(1,length(pp1range))*pp2range(ii),ptsize,HeatMapValues(ii,:),'s','filled',...
'MarkerFaceAlpha',.6, 'MarkerEdgeAlpha',1);
hold on
end
colormap(jet);
set(gca, 'FontSize', 14,'FontWeight', 'bold');
xlabel(pp1);ylabel(pp2);
title(titleString);
c=colorbar;
c.Label.FontSize=14;
set(gca,'box','off');
axis([0. 1. 4. 24.])
% Get the current axis size
currentSize = get(gca, 'Position');
clim=get(c, 'limits'); %get current limits
hold on
ax = axes;
plot(ax,G_LTest,TK-273.15,'-','color',[0.4 0.4 0.4],'LineWidth',2);%[0.4 0.4 0.4],'LineWidth',3)
axis([0. 1. 4. 24.]);
set(gca, 'FontSize', 14,'FontWeight', 'bold');
ax.Color = 'none';
ax.XTick = [];
ax.YTick = [];
%set(gca,'box','off');
axis off;
% Adjust axes position after colorbar rescale
set(gca, 'Position', currentSize);
hold on
hc=scatter(G_LTestInt(2:end),TCint(2:end),cirklesize,Frequency,'filled');
set(hc,'MarkerEdgeColor',[0 0 0]);
set(hc,'LineWidth',0.2, 'MarkerEdgeAlpha', 0.5);
colormap(jet);
%colorbar;
axis([0. 1. 4. 24.])
set(gca, 'Position', currentSize);
caxis(clim);