1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495 |
- %% fig. S3B - BarChart
- clear all
- close all
- % ==========================================================================
- %% Sensory responsive cell barchart
- % ==========================================================================
- %Prepare variables
- load('figS3B_BarChart.mat');
- NofMouse = 8;
- % ============================================================================================
- %% 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}(:,:),1); mean(RatioData{1,iLearning+1}(:,:),1)];
- SEM4Bar = [std(RatioData{1,iLearning}(:,:),0,1)/sqrt(NofMouse); std(RatioData{1,iLearning+1}(:,:),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}(:,:),1); mean(RatioData{1,iLearning}(:,:),1)];
- SEM4Bar = [std(RatioData{1,iLearning-1}(:,:),0,1)/sqrt(NofMouse); std(RatioData{1,iLearning}(:,:),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')
-
- %Add scatter plot--------------------------------------------------------------------------
- if iLearning == 1 %First 4 mice are auditory reward group. The last 2 mice are visual reward group.
- Group1Color = [1 0 0];
- Group2Color = [0 1 0];
- disp('DotColor: Group1(Aud-1st) is Red, Group2(Vis-1st) is Green')
-
- elseif iLearning == 2 %First 4 mice are visual reward group. The last 2 mice are auditory reward group.
- Group1Color = [0 1 0];
- Group2Color = [1 0 0];
- disp('DotColor: Group1(Aud-1st) is Green, Group2(Vis-1st) is Red')
- end
-
- for ii = 1:2 %1 = Naive, 2 = Expert
- %Group1 - Aud-reward 1st
- Group1Cluster = [];
- Group1Cluster = RatioData{1,ii}(1:4, :);
- sz = 20;
- ScatterID = repmat(x(ii,:), size(Group1Cluster,1),1);
- scatter(ScatterID(:),Group1Cluster(:), [], Group1Color, 'filled','MarkerFaceAlpha',0.5','jitter','on','jitterAmount',0.075);
-
- %Group2 - Vis-reward 1st
- Group2Cluster = [];
- Group2Cluster = RatioData{1,ii}(5:8, :);
- ScatterID = repmat(x(ii,:), size(Group2Cluster,1),1);
- scatter(ScatterID(:),Group2Cluster(:), [], Group2Color, 'filled','MarkerFaceAlpha',0.5','jitter','on','jitterAmount',0.075);
- end% ii
- end %for iLearning
|