figS5.m 7.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189
  1. clear % clear workspace
  2. close all; % close all open figures
  3. % load chR2V1_uInfo (Ntsr1 photoactivation)
  4. load('/Users/busse/code/work/CTfeedbackSize/to_publish/data/chr2V1.mat')
  5. %% plot parameters
  6. mean_color = [218 165 35]/255; % color for mean
  7. pinkEx = [255 20 147]/255; % color for example neurons
  8. % percentage of layer thickness based on: Heumann D, Rabinowicz T (1977) Postnatal development of mouse cerebral neocortex. II Quantitative cytoarchitectonics of visual and auditory areas. J Hirnforsch 18: 483-500
  9. % Layers I II/III IV V VI Total
  10. % Relative thickness (%) 13 26 13 24 24 100
  11. % assumptions: thickness of V1 of 1 mm
  12. % 0: base of layer 4
  13. rel_layerDepth = [-520 -390 -130 0 240 480];
  14. rel_layerCenters = [-455 -260 -65 120 360]; % add half of each layer thickness
  15. %% S5b: example tuning curves
  16. %% S5c: Ntsr1+ photoactivation across layers
  17. rng(1);
  18. layer_names = {'1', '2/3', '4', '5', '6'};
  19. n_layers = numel(layer_names);
  20. % compute means, CIs, SEMs across layers
  21. layer_mean = nan(1, n_layers);
  22. layer_sem = nan(1, n_layers);
  23. layer_ci = nan(2, n_layers);
  24. for ilayer = 1 : n_layers
  25. % find neurons in layer
  26. layer_log = strcmp({chr2V1_uInfo.layer}, layer_names(ilayer));
  27. % add 0.0001 to numerator and denominator to make log2 work for 0 firing rates
  28. layer_mean(ilayer) = mean(log2(([chr2V1_uInfo(layer_log).frL]+0.0001) ./ ...
  29. ([chr2V1_uInfo(layer_log).frC]+0.0001)));
  30. % compute confidence intervals via bootstrapping
  31. temp = bootstrp(100, @(x) {mean(log2(x))}, ...
  32. ([chr2V1_uInfo(layer_log).frL]+0.0001) ./([chr2V1_uInfo(layer_log).frC]+0.0001));
  33. layer_ci(:, ilayer) = prctile([temp{:}], [2.5, 97.5]);
  34. layer_sem(ilayer) = var([temp{:}]);
  35. fprintf('Layer %s: mean %3.2f (%3.2f, %3.2f)\n', ...
  36. layer_names{ilayer}, layer_mean(ilayer), ...
  37. layer_ci(1, ilayer), layer_ci(2, ilayer));
  38. end
  39. fprintf('\n');
  40. % make plot
  41. xLim = 9;
  42. layerY = [rel_layerDepth' rel_layerDepth']'/1000;
  43. layerX = [repmat(-xLim,6,1) repmat(xLim,6,1)]';
  44. modRats = log2(([chr2V1_uInfo.frL]+0.001) ./ ([chr2V1_uInfo.frC]+0.001));
  45. modRats(modRats < -8) = -8.5;
  46. figure('Name', 'Born et al. (2021), Fig. S5c'); hold on;
  47. plot(modRats, [chr2V1_uInfo.relative_depth], 'ko', 'MarkerSize', 4);
  48. plot(layer_mean, rel_layerCenters/1000, 'o', 'Color', mean_color, 'MarkerSize', 4);
  49. line(layer_ci, [rel_layerCenters; rel_layerCenters]/1000, 'Color', mean_color)
  50. % add layer boundaries
  51. line(layerX, layerY, 'Color', 'k')
  52. line([0 0], [-0.4 0.4], 'Color', 'k')
  53. set(gca, 'YDir', 'reverse', 'XLim', [-xLim xLim], ...
  54. 'YLim', [rel_layerDepth(1)/1000 rel_layerDepth(end)/1000])
  55. xlabel('Fold change')
  56. ylabel('Relative depth (mm)')
  57. %% load uInfo for dLGN recordings
  58. load('/Users/busse/code/work/CTfeedbackSize/to_publish/data/chr2LGN.mat');
  59. %% 2e: example raster plots
  60. %sponEx(1,1) = struct('mouse_id', 'Ntsr1-Cre_0039', 'mouse_counter', 91, 'series_num', 7, 'unit_id', 21);
  61. %sponEx(1,2) = struct('mouse_id', 'Ntsr1-Cre_0039', 'mouse_counter', 91, 'series_num', 7, 'unit_id', 29);
  62. exIdx = [43 48];
  63. timelims{1} = [-0.5, 0.75];
  64. timelims{2} = [-0.5, 1.325];
  65. figure('Name', 'Born et al. (2021), Fig. S5e'); hold on;
  66. % (1:31) trials for one particular experiment with 0.25 s light dur
  67. plotRaster_pub(chr2LGN_uInfo(exIdx(1)).spikeTimes(1:31)', timelims{1});
  68. line([0 0.25], [1 1], 'Color', 'k'); % light duration
  69. set(gca, 'YColor', 'w')
  70. ylabel('')
  71. figure('Name', 'Born et al. (2021), Fig. S5f'); hold on;
  72. % (32:100) trials for experiments with 0.5 s light dur
  73. plotRaster_pub(chr2LGN_uInfo(exIdx(2)).spikeTimes(32:100)', timelims{2});
  74. line([0 0.5], [1 1], 'Color', 'k');
  75. set(gca, 'YColor', 'w')
  76. ylabel('')
  77. %% 2f: firing rate during spontaneous visual activity (corresponding to size 0)
  78. % mean rate before onset of V1 Ntsr1+ stimulation and during V1 Ntsr1+ stimulation
  79. chr2_meanBefore = arrayfun(@(u) nanmean(u.rateBefore), chr2LGN_uInfo);
  80. chr2_meanDuring = arrayfun(@(u) nanmean(u.rateDuring), chr2LGN_uInfo);
  81. % statistics: signrank treats nan as missing value (i.e. ignores it)
  82. p_rates = signrank(chr2_meanBefore, chr2_meanDuring);
  83. % change in rate, n
  84. n_rates = nnz(~isnan(chr2_meanBefore) & ~isnan(chr2_meanDuring));
  85. fprintf('dLGN mean rate before %3.1f sp/s, during %3.1f sp/s V1 Ntsr1+ stimulation\n', ...
  86. mean(chr2_meanBefore), mean(chr2_meanDuring));
  87. fprintf('\tp(signrank) = %0.2g (N = %d)\n', p_rates, n_rates);
  88. % prepare for plotting
  89. scale_out = 1.2; % outliers will be plotted at max+10%
  90. ymin_r = 0;
  91. ymaxVal_r = 20;
  92. ymax_r = ymin_r + (ymaxVal_r-ymin_r)*scale_out;
  93. chr2_meanBefore(chr2_meanBefore > ymaxVal_r) = ymax_r;
  94. chr2_meanDuring(chr2_meanDuring > ymaxVal_r) = ymax_r;
  95. % make the plot
  96. figure('Name', 'Born et al. (2021), Fig. 3g'); hold on;
  97. plot(chr2_meanBefore, chr2_meanDuring, 'ko', 'MarkerSize', 4);
  98. hold on;
  99. plot(chr2_meanBefore(exIdx), chr2_meanDuring(exIdx), 'ko', 'MarkerSize', 4, ...
  100. 'MarkerEdgeColor', pinkEx, 'MarkerFaceColor', pinkEx);
  101. plot(mean(chr2_meanBefore), mean(chr2_meanDuring), 'ko', 'MarkerSize', 4, ...
  102. 'MarkerEdgeColor', mean_color, 'MarkerFaceColor', mean_color);
  103. hline = refline(1,0); % line of unity slope
  104. set(hline, 'color', 0.6*ones(1,3));
  105. axis equal; axis square
  106. set(gca, 'XLim', [0 ymax_r], 'YLim', [0 ymax_r], ...
  107. 'XTick', [0:10:ymaxVal_r ymax_r], 'YTick', [0:10:ymaxVal_r ymax_r]);
  108. xlabel('Control');
  109. ylabel('L6 activation');
  110. title('Firing rate (sp/s)');
  111. %% 2g: burst ratios
  112. % compute burst data
  113. % compute burst tonic ratio before vs. during V1 Ntsr1+ stimulation
  114. chr2_btBefore = arrayfun(@(u) nanmean(u.btRatioBefore), chr2LGN_uInfo);
  115. chr2_btDuring = arrayfun(@(u) nanmean(u.btRatioDuring), chr2LGN_uInfo);
  116. n_bts = nnz(~isnan(chr2_btBefore) & ~isnan(chr2_btDuring));
  117. pburst_pv = signrank(chr2_btBefore, chr2_btDuring); % treats nan as missign values
  118. fprintf('\ndLGN burst ratio before and during V1 Ntsr1+ stimulation\n')
  119. fprintf('\tmean before: %3.2f%%\n\tmean during: %3.2f%%\n\tsignrank p = %02g\n\tN = %d\n', ...
  120. nanmean(chr2_btBefore)*100, nanmean(chr2_btDuring)*100, ...
  121. pburst_pv, n_bts);
  122. % compute burst lengths before vs. during Ntsr1+ photoactivation
  123. chr2blenBefore = cell2mat(arrayfun(@(bt) cat(1, bt.blengthBefore{:}), ...
  124. chr2LGN_uInfo, 'uniformoutput', 0)');
  125. chr2blenBefore(chr2blenBefore < 1) = []; % 0 burst length: tonic spikes
  126. chr2blenDuring = cell2mat(arrayfun(@(bt) cat(1, bt.blengthDuring{:}), ...
  127. chr2LGN_uInfo, 'uniformoutput', 0)');
  128. chr2blenDuring(chr2blenDuring < 1) = [];
  129. [~,p_blen] = kstest2(chr2blenBefore, chr2blenDuring);
  130. p_med_blen = ranksum(chr2blenBefore, chr2blenDuring);
  131. fprintf('\ndLGN burst lengths before / during V1 Ntsr1+ stimulation\n')
  132. fprintf('\tkstest: p = %0.2g\n\tranksum: p = %02g\n\tN = %d/%d\n', ...
  133. p_blen, p_med_blen, numel(chr2blenBefore), numel(chr2blenDuring));
  134. % prepare for plotting
  135. btTicks = [10^-2 10^-1 10^0];
  136. btTickLabels = [0.01 0.1 1];
  137. % adjust for plotting
  138. chr2_btBefore(chr2_btBefore == 0) = 10^-2.5;
  139. chr2_btDuring(chr2_btDuring == 0) = 10^-2.5;
  140. figure('Name', 'Born et al. (2021), Fig. S5h');
  141. loglog(chr2_btBefore, chr2_btDuring, 'ko', 'MarkerSize', 4);
  142. hold on;
  143. loglog(chr2_btBefore(exIdx), chr2_btDuring(exIdx), 'ko', 'MarkerSize', 4, ...
  144. 'MarkerEdgeColor', pinkEx, 'MarkerFaceColor', pinkEx);
  145. loglog(nanmean(chr2_btBefore), nanmean(chr2_btDuring), 'ko', 'MarkerSize', 4, ...
  146. 'MarkerEdgeColor', mean_color, 'MarkerFaceColor', mean_color);
  147. hline = refline(1,0);
  148. set(hline, 'color', 0.6*ones(1,3));
  149. axis equal; axis square
  150. set(gca, 'XLim', [10^-2.5 10^0], 'YLim', [10^-2.5 10^0], ...
  151. 'XTick', btTicks, 'YTick', btTicks, ...
  152. 'XTickLabel', btTickLabels, 'YTickLabel', btTickLabels, ...
  153. 'XMinorTick','off', 'YMinorTick','off');
  154. xlabel('Control');
  155. ylabel('L6 activation');
  156. % inset for distribution of burst lengths
  157. figure('Name', 'Born et al. (2021), Fig. S5h inset'); hold on;
  158. ecdf(chr2blenBefore)
  159. ecdf(chr2blenDuring)
  160. sh = get(gca, 'Children'); % to set the color of the individual ecdfs
  161. set(sh(1), 'Color', [0 143 210]/255);
  162. set(sh(2), 'Color', 'k');
  163. ylabel('CDF')
  164. set(gca, 'XLim', [2 inf], 'YTick', [0 1])
  165. xlabel('sp/burst')