123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101 |
- %% PLOTTING SCATTERS AND DISTRIBUTIONS COMPARISONS
- function plot_residuals_comparison_scatter(Zstruct_trwise,save_folder_path,filename_suffix)
- addpath(genpath('../../../../my-tools'));
- if nargin<6
- filename_suffix='';
- end
- Z_b1_LL_trwise=Zstruct_trwise.Z_b1_LL_trwise;
- Z_b1_LR_trwise=Zstruct_trwise.Z_b1_LR_trwise;
- Z_b2_LL_trwise=Zstruct_trwise.Z_b2_LL_trwise;
- Z_b2_LR_trwise=Zstruct_trwise.Z_b2_LR_trwise;
- ZZ=squeeze(nanmean(Z_b1_LL_trwise,[1 3])); Z_b1_LL=[ZZ(:,1)' ZZ(:,2)'; ZZ(:,3)' ZZ(:,4)'];
- ZZ=squeeze(nanmean(Z_b1_LR_trwise,[1 3])); Z_b1_LR=[ZZ(:,1)' ZZ(:,2)'; ZZ(:,3)' ZZ(:,4)'];
- ZZ=squeeze(nanmean(Z_b2_LL_trwise,[1 3])); Z_b2_LL=[ZZ(:,1)' ZZ(:,2)'; ZZ(:,3)' ZZ(:,4)'];
- ZZ=squeeze(nanmean(Z_b2_LR_trwise,[1 3])); Z_b2_LR=[ZZ(:,1)' ZZ(:,2)'; ZZ(:,3)' ZZ(:,4)'];
- hf=fullfig([0 0 .5 1]);
- subplot(2,2,1); hold on; title('SV_L delay2 LookL');
- plotscatteredmedian(Z_b1_LL,'auto','right',[-1 1]*1.5e-3,...
- {'\beta_{1}>0,ch=L; \beta_{1}<0,ch=R','\beta_{1}<0,ch=L; \beta_{1}>0,ch=R'},'residuals');
- %text(min(get(gca,'XLim'))*.9,max(get(gca,'YLim')*.9),sprintf('md1: %.3i',nanmedian(Z_b1_LL(1,:))));
- %text(min(get(gca,'XLim'))*.9,max(get(gca,'YLim')*.8),sprintf('md2: %.3i',nanmedian(Z_b1_LL(2,:))));
- %[~,p]=ttest(rmnans(Z_b1_LL(1,:))-rmnans(Z_b1_LL(2,:)),0,'tail','right');
- %text(min(get(gca,'XLim'))*.9,max(get(gca,'YLim')*.7),sprintf('t-test right p:%.3i%s',p,getpstars(p)));
- xlabel('preferred non-preferred');
- subplot(2,2,2); hold on; title('SV_L delay2 LookR');
- plotscatteredmedian(Z_b1_LR,'auto','right',[-1 1]*1.5e-3,...
- {'\beta_{1}>0,ch=L; \beta_{1}<0,ch=R','\beta_{1}<0,ch=L; \beta_{1}>0,ch=R'},'residuals');
- %text(min(get(gca,'XLim'))*.9,max(get(gca,'YLim')*.9),sprintf('md1: %.3i',nanmedian(Z_b1_LR(1,:))));
- %text(min(get(gca,'XLim'))*.9,max(get(gca,'YLim')*.8),sprintf('md2: %.3i',nanmedian(Z_b1_LR(2,:))));
- %[~,p]=ttest(rmnans(Z_b1_LR(1,:))-rmnans(Z_b1_LR(2,:)),0,'tail','right');
- %text(min(get(gca,'XLim'))*.9,max(get(gca,'YLim')*.7),sprintf('t-test right p:%.3i%s',p,getpstars(p)));
- xlabel('preferred non-preferred');
- subplot(2,2,3); hold on; title('SV_R delay2 LookL');
- plotscatteredmedian(Z_b2_LL,'auto','left',[-1 1]*1.5e-3,...
- {'\beta_{2}>0,ch=L; \beta_{2}<0,ch=R','\beta_{2}<0,ch=L; \beta_{2}>0,ch=R'},'residuals');
- %text(min(get(gca,'XLim'))*.9,max(get(gca,'YLim')*.9),sprintf('md1: %.3i',nanmedian(Z_b2_LL(1,:))));
- %text(min(get(gca,'XLim'))*.9,max(get(gca,'YLim')*.8),sprintf('md2: %.3i',nanmedian(Z_b2_LL(2,:))));
- %[~,p]=ttest(rmnans(Z_b2_LL(1,:))-rmnans(Z_b2_LL(2,:)),0,'tail','left');
- %text(min(get(gca,'XLim'))*.9,max(get(gca,'YLim')*.7),sprintf('t-test left p:%.3i%s',p,getpstars(p)));
- xlabel('non-preferred preferred');
- subplot(2,2,4); hold on; title('SV_R delay2 LookR');
- plotscatteredmedian(Z_b2_LR,'auto','left',[-1 1]*1.5e-3,...
- {'\beta_{2}>0,ch=L; \beta_{2}<0,ch=R','\beta_{2}<0,ch=L; \beta_{2}>0,ch=R'},'residuals');
- %text(min(get(gca,'XLim'))*.9,max(get(gca,'YLim')*.9),sprintf('md1: %.3i',nanmedian(Z_b2_LR(1,:))));
- %text(min(get(gca,'XLim'))*.9,max(get(gca,'YLim')*.8),sprintf('md2: %.3i',nanmedian(Z_b2_LR(2,:))));
- %[~,p]=ttest(rmnans(Z_b2_LR(1,:))-rmnans(Z_b2_LR(2,:)),0,'tail','left');
- %text(min(get(gca,'XLim'))*.9,max(get(gca,'YLim')*.7),sprintf('t-test left p:%.3i%s',p,getpstars(p)));
- xlabel('non-preferred preferred');
- saveas(hf,[save_folder_path 'zetas_tr_time_avg_scatter_comparisons' filename_suffix '.png']);
- saveas(hf,[save_folder_path 'zetas_tr_time_avg_scatter_comparisons' filename_suffix '.svg']);
- saveas(hf,[save_folder_path 'zetas_tr_time_avg_scatter_comparisons' filename_suffix '.fig']);
- %print(hf,[save_folder_path 'zetas_tr_time_avg_scatter_comparisons' filename_suffix '.pdf'],'-dpdf','-fillpage');
- zbins=-1.6e-3:.25e-4:1.6e-3; ylims=[0 60];
- hf=fullfig([.5 0 .5 .5]);
- subplot(2,2,1);
- histogram(Z_b1_LL(1,:),zbins,'edgecolor','none'); hold on; ylim(ylims);
- histogram(Z_b1_LL(2,:),zbins,'edgecolor','none'); plotvline(0,'k-'); box off; gch=gca;
- plot(nanmedian(Z_b1_LL(1,:)-Z_b1_LL(2,:)),max(gch.YLim).*.85,'rv');
- pv=signrank(Z_b1_LL(1,:),Z_b1_LL(2,:),'tail','right');
- text(0,max(gch.YLim).*.9,sprintf('diff pvalue: %.2i %s',pv,getpstars(pv)),'color','r');
- text(0,max(gch.YLim).*.95,sprintf('diff median: %.3i',nanmedian(Z_b1_LL(1,:)-Z_b1_LL(2,:))),'color','r');
- title('SV_L delay2 LookL'); legend('pref.','non-pref.','location','southeast','box','off'); ylabel('cell count');
- subplot(2,2,3);
- histogram(Z_b1_LR(1,:),zbins,'edgecolor','none'); hold on; ylim(ylims);
- histogram(Z_b1_LR(2,:),zbins,'edgecolor','none'); plotvline(0,'k-'); box off; gch=gca;
- plot(nanmedian(Z_b1_LR(1,:)-Z_b1_LR(2,:)),max(gch.YLim).*.85,'kv'); plotvline(0,'k-'); box off
- pv=signrank(Z_b1_LR(1,:),Z_b1_LR(2,:),'tail','right');
- text(0,max(gch.YLim).*.9,sprintf('diff pvalue: %.2i %s',pv,getpstars(pv)));
- text(0,max(gch.YLim).*.95,sprintf('diff median: %.3i',nanmedian(Z_b1_LR(1,:)-Z_b1_LR(2,:))));
- title('SV_L delay2 LookR'); legend('pref.','non-pref.','location','southeast','box','off'); xlabel('residual');
- subplot(2,2,2);
- histogram(Z_b2_LL(1,:),zbins,'edgecolor','none'); hold on; ylim(ylims);
- histogram(Z_b2_LL(2,:),zbins,'edgecolor','none'); plotvline(0,'k-'); box off; gch=gca;
- plot(nanmedian(Z_b2_LL(1,:)-Z_b2_LL(2,:)),max(gch.YLim).*.85,'kv');
- pv=signrank(Z_b2_LL(1,:),Z_b2_LL(2,:),'tail','left');
- text(0,max(gch.YLim).*.9,sprintf('diff pvalue: %.2i %s',pv,getpstars(pv)),'color','k');
- text(0,max(gch.YLim).*.95,sprintf('diff median: %.3i',nanmedian(Z_b2_LL(1,:)-Z_b2_LL(2,:))));
- title('SV_R delay2 LookL'); legend('non-pref.','pref.','location','southeast','box','off'); ylabel('cell count');
- subplot(2,2,4);
- histogram(Z_b2_LR(1,:),zbins,'edgecolor','none'); hold on; ylim(ylims);
- histogram(Z_b2_LR(2,:),zbins,'edgecolor','none'); plotvline(0,'k-'); box off; gch=gca;
- plot(nanmedian(Z_b2_LR(1,:)-Z_b2_LR(2,:)),max(gch.YLim).*.85,'rv'); plotvline(0,'k-'); box off
- pv=signrank(Z_b2_LR(1,:),Z_b2_LR(2,:),'tail','left');
- text(0,max(gch.YLim).*.9,sprintf('diff pvalue: %.2i %s',pv,getpstars(pv)),'color','r');
- text(0,max(gch.YLim).*.95,sprintf('diff median: %.3i',nanmedian(Z_b2_LR(1,:)-Z_b2_LR(2,:))),'color','r');
- title('SV_R delay2 LookR'); legend('non-pref.','pref.','location','southeast','box','off'); xlabel('residual');
- saveas(hf,[save_folder_path 'zetas_tr_time_avg_distrib_comparisons' filename_suffix '.png']);
- saveas(hf,[save_folder_path 'zetas_tr_time_avg_distrib_comparisons' filename_suffix '.svg']);
- saveas(hf,[save_folder_path 'zetas_tr_time_avg_distrib_comparisons' filename_suffix '.fig']);
- %print(hf,[save_folder_path 'zetas_tr_time_avg_distrib_comparisons' filename_suffix '.pdf'],'-dpdf','-fillpage');
- end
|