123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687 |
- %% fig. S3CD - BarChart
- clear all
- close all
- % ==========================================================================
- %% Sensory responsive cell barchart
- % ==========================================================================
- %Prepare variables
- load('figS3B_BarChart.mat');
- NofMouse = 4;
- Aud = 0; %For fig. S3C
- Vis = 1; %For fig. S3D
- if Aud
- MouseID = 1:4;
- elseif Vis
- MouseID = 5:8;
- end
- % ============================================================================================
- %% Proportion of cells from each mouse for each cluster - Bar chart (mean)+ SEM - For figures
- % ============================================================================================
- for iLearning = 1:2 %Initial or Reversal
- RatioData = [];
- Mean4Bar = [];
- SEM4Bar = [];
-
- switch iLearning
- case 1 %Initial Learning
- fig1 = figure('Name', 'InitialLearning-GoNogoCellRatio');
- RatioData = CellRatio_Initial;
- title('Proportion of cell types - Go - Ini');
- hold on;
-
- Mean4Bar = [mean(RatioData{1,iLearning}(MouseID,:),1); mean(RatioData{1,iLearning+1}(MouseID,:),1)];
- SEM4Bar = [std(RatioData{1,iLearning}(MouseID,:),0,1)/sqrt(NofMouse); std(RatioData{1,iLearning+1}(MouseID,:),0,1)];
-
- case 2 %Reversal Learning
- fig2 = figure('Name', 'ReversalLearning-GoNogoCellRatio');
- RatioData = CellRatio_Reversal;
- title('Proportion of cell types - Go - Rev');
- hold on;
-
- Mean4Bar = [mean(RatioData{1,iLearning-1}(MouseID,:),1); mean(RatioData{1,iLearning}(MouseID,:),1)];
- SEM4Bar = [std(RatioData{1,iLearning-1}(MouseID,:),0,1)/sqrt(NofMouse); std(RatioData{1,iLearning}(MouseID,:),0,1)];
- end %switch
-
- %Plot bar chart
- b = bar(1:size(Mean4Bar,2), Mean4Bar, 'grouped','FaceColor', 'none', 'EdgeColor', 'k');
- hold on;
-
- % Calculate the number of groups and number of bars in each group
- [nbars,ngroups] = size(Mean4Bar);
-
- % Get the x coordinate of the bars
- x = nan(nbars, ngroups);
- for i = 1:nbars
- x(i,:) = b(i).XEndPoints;
- end
-
- %Plot error bar
- er = errorbar(x, Mean4Bar, SEM4Bar);
- %er is 1x4 struct structure
- for e=1:size(Mean4Bar,2)
- er(1,e).Color = [0 0 0];
- er(1,e).LineStyle = 'none';
- er(1,e).MarkerEdgeColor = 'none';
- end
- xticks([1 2 3 4]);
- xticklabels({'Go', 'Nogo', 'Both', 'Non'});
- box off
-
- ylim([0 0.8]);
- yticks([0 0.2 0.4 0.6 0.8 1.0]);
- ylabel('Proportion of cells')
-
- %Dot color
- Group1Color = [0.75 0.75 0.75];
-
- for ii = 1:2 %1 = Naive, 2 = Expert
- Group1Cluster = [];
- Group1Cluster = RatioData{1,ii}(MouseID, :);
- sz = 20;
- ScatterID = repmat(x(ii,:), size(Group1Cluster,1),1);
- scatter(ScatterID(:),Group1Cluster(:), [], Group1Color, 'filled','MarkerFaceAlpha',0.5','jitter','on','jitterAmount',0.075);
- end% ii
- end %for iLearning
|