% 2022-10-06
% BBB #13 results

% BBB#13 data (hard-coded here)
rXes13 = {'24E','24C','48E','48C','72E','72C'};
bright13 = [0,0,2,3,10,7];
total13 = [34,29,47,48,46,50];
dim13 = total13-bright13;
bright_frac13 = bright13./total13;

% Per https://www.sciencedirect.com/topics/mathematics/binomial-situation
errorEst13 = sqrt((bright_frac13.*(1-bright_frac13))./total13);

% BBB#12 data (hard-coded here)
rXes12 = {'96C','96E'};
bright12 = [5,41+20];
total12 = [50,48+34];
dim12 = total12-bright12;
bright_frac12 = bright12./total12;

% Per https://www.sciencedirect.com/topics/mathematics/binomial-situation
errorEst12 = sqrt((bright_frac12.*(1-bright_frac12))./total12);

% Actual time since exposure
injTime = [24-7,48-7,72-7,96-2];
scoreTime = [injTime+4];
% assumes exposure happened at ZT16 on Day 0
% For BBB#13, day 1, 2 and 3 day flies were injected at ZT9
% For BBB#12, day 4 flies were injected at ZT14

% Make scatter plot
figure;
hold on;

% Plot entrained lighting
shadeArea = ones(1,13);
    
for k=-16:24:120
    daySpan = k:1:k+12;
    nightSpan = k+12:1:k+24;
    area(nightSpan,shadeArea,'FaceColor','k','FaceAlpha',0.1,'EdgeColor','none','HandleVisibility','off');   
    area(daySpan,shadeArea,'FaceColor','y','FaceAlpha',0.2,'EdgeColor','none','HandleVisibility','off'); 
end

% Plot exposed data and error
scatter(scoreTime,[bright_frac13(1),bright_frac13(3),bright_frac13(5),bright_frac12(2)],'MarkerFaceColor','r','MarkerEdgeColor','none');
errorbar(scoreTime,[bright_frac13(1),bright_frac13(3),bright_frac13(5),bright_frac12(2)],[errorEst13(1),errorEst13(3),errorEst13(5),errorEst12(2)],'LineStyle','none','Color',[0.1 0.1 0.1],'HandleVisibility','off');

% Plot control data and error
scatter(scoreTime,[bright_frac13(2),bright_frac13(4),bright_frac13(6),bright_frac12(1)],'MarkerFaceColor','k','MarkerEdgeColor','none');
errorbar(scoreTime,[bright_frac13(2),bright_frac13(4),bright_frac13(6),bright_frac12(1)],[errorEst13(2),errorEst13(4),errorEst13(6),errorEst12(1)],'LineStyle','none','Color',[0.1 0.1 0.1],'HandleVisibility','off');

ylim([0 1]);
xlim([0 100]);
%set(gca,'xtick',1:4,'xticklabel',24:24:96)
set(gca,'TickLength',[0 0]);
legend({'Exposed','Control'})

xlabel('Time since exposure (hours)');
ylabel('Fraction of bright-eyed flies');
title('BBB #12 & 13 - Combined Results');

%outDir = "D:\Harvard\";
outDir = "D:\Harvard\Manuscripts\Summit paper\Figures\Fig 6 Supp\";
print(strcat(outDir,'BBB_supp.png'),'-dpng');
print(strcat(outDir,'BBB_supp.pdf'),'-dpdf');
close();