Fig2AB_BarChart.m 2.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. %% Fig. 2AB BarChart
  2. clear all
  3. close all
  4. % ==========================================================================
  5. %% k-means cluster barchart
  6. % ==========================================================================
  7. %Prepare variables
  8. load('Fig2AB_BarChart.mat');
  9. %Prepare variables
  10. NofMouse = 6;
  11. NofCluster = 6;
  12. catNames = {'Others', 'Stable1', 'Stable2', 'Up', 'Down', 'Ramp-up', 'Ramp-down'};
  13. %% Plot barchart
  14. for iLearning = 1:2
  15. CellRatio = [];
  16. switch iLearning
  17. case 1
  18. fig1 = figure;
  19. CellRatio = CellRatio4Cluster(:, :, 1);
  20. title('Proportion of cells for clusters - Go - Ini');
  21. hold on;
  22. case 2
  23. fig2 = figure;
  24. CellRatio = CellRatio4Cluster(:, :, 2);
  25. title('Proportion of cells for clusters - Go - Rev');
  26. hold on;
  27. end%iLearning
  28. Mean4Bar = mean(CellRatio,1);
  29. SEM4Bar = std(CellRatio,1)/sqrt(NofMouse);
  30. bar(1:size(catNames,2), Mean4Bar, 'FaceColor', 'none', 'EdgeColor', 'k');
  31. hold on;
  32. er = errorbar(1:size(catNames,2), Mean4Bar, SEM4Bar);
  33. er.Color = [0 0 0];
  34. er.LineStyle = 'none';
  35. er.MarkerEdgeColor = 'none';
  36. xticks([1 2 3 4 5 6 7]);
  37. xticklabels(catNames);
  38. box off
  39. ylim([0 0.55]);
  40. yticks([0 0.1 0.2 0.3 0.4 0.5]);
  41. ylabel('Proportion of cells')
  42. %Add scatter plot--------------------------------------------------------------------------
  43. if iLearning == 1 %First 4 mice are auditory reward group. The last 2 mice are visual reward group.
  44. Group1Color = [1 0 0];
  45. Group2Color = [0 1 0];
  46. disp('DotColor: Group1(Aud-1st) is Red, Group2(Vis-1st) is Green')
  47. elseif iLearning == 2 %First 4 mice are visual reward group. The last 2 mice are auditory reward group.
  48. Group1Color = [0 1 0];
  49. Group2Color = [1 0 0];
  50. disp('DotColor: Group1(Aud-1st) is Green, Group2(Vis-1st) is Red')
  51. end
  52. %Group1 - Aud-reward 1st
  53. Group1Cluster = [];
  54. Group1Cluster = CellRatio(1:4, :);
  55. sz = 20;
  56. ScatterID = repmat(1:NofCluster+1, size(Group1Cluster,1),1);
  57. scatter(ScatterID(:),Group1Cluster(:), [], Group1Color, 'filled','MarkerFaceAlpha',0.5','jitter','on','jitterAmount',0.15);
  58. %Group2 - Vis-reward 1st
  59. Group2Cluster = [];
  60. Group2Cluster = CellRatio(5:6, :);
  61. ScatterID = repmat(1:NofCluster+1, size(Group2Cluster,1),1);
  62. scatter(ScatterID(:),Group2Cluster(:), [], Group2Color, 'filled','MarkerFaceAlpha',0.5','jitter','on','jitterAmount',0.15);
  63. end %for iLearning