MakeFigures.m
—
Objective-C source code,
6 KB (6971 bytes)
File contents
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % Generates figures for previously computed patterns % April 2016 % Author: L. Muresan, lam94@cam.ac.uk %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % Parameters to be modified by the user CorP = 1; % if 1 all the plots are CenterToPeriphery,otherwise - PeripheryToCenter saveim = 1; % if 1 all images are automatically saved sep = '/'; % for Mac / %% if CorP ~= 1 CorP =2; end option{1} = 'CtoP'; %CenterToPeriphery option{2} = 'PtoC'; %PeripheryToCenter % Read computed patterns pt = uigetdir(); fls = dir(strcat(pt,'/*',option{CorP},'.csv')); if exist('R') clear R end if length(fls) == 0 msgbox('No result csv files found! Run ComputePatterns first.') else for k = 1:length(fls) R{k}= csvread(strcat(pt,sep, fls(k).name)); end %% all profiles clear tG tR tC h = figure; x = 0:0.01:1; for k = 1:length(R) vG{k} = interp1(R{k}(:,1)/max(R{k}(:,1)), R{k}(:,2)/sum(R{k}(:,2)), x); if CorP ==1 tG(k,:) = vG{k}; else tG(k,:) = fliplr(vG{k})/sum(vG{k}); end plot(x, tG(k,:), 'g'); hold on end for k = 1:length(R) vR{k} = interp1(R{k}(:,1)/max(R{k}(:,1)), R{k}(:,3)/sum(R{k}(:,3)), x); if CorP ==1 tR(k,:) = vR{k}; else tR(k,:) = fliplr(vR{k})/sum(vR{k}); end plot(x, tR(k,:), 'r'); hold on end for k = 1:length(R) vC{k} = interp1(R{k}(:,1)/max(R{k}(:,1)), R{k}(:,4)/sum(R{k}(:,4)), x); if CorP ==1 tC(k,:) = vC{k}; else tC(k,:) = fliplr(vC{k})/sum(vC{k}); end plot(x, tC(k,:), 'c'); hold on end title (['All samples profiles. ', ' ', option{CorP}]), if CorP ==1 xlabel('Normalised distance from centre to periphery'); else xlabel('Normalised distance from periphery to centre'); end ylabel('Normalised fluorescence intensity'); if saveim print(h, strcat(pt,sep,'Fig','All samples_profiles_', option{CorP},'.pdf'),'-dpdf'); savefig(h, strcat(pt,sep,'Fig','All samples_profiles_', option{CorP},'.fig')); end %% Single profile figures. Uncomment below if you want each profile figure saved separately. % for k = 1:size(tR,1) % h = figure; % plot(x, tR(k,:), 'r', 'LineWidth',2); hold on % plot(x, tG(k,:), 'g', 'LineWidth',2); % plot(x, tC(k,:), 'c', 'LineWidth',2); % % if CorP ==1 % xlabel('Normalised distance from centre to periphery'); % else % xlabel('Normalised distance from periphery to centre'); % end % ylabel('Normalised fluorescence intensity'); % title(strcat(strtok(fls(k).name, '.') )); % if saveim % print(h, strcat(pt,sep,'Fig',strtok(fls(k).name, '.'), '.pdf'),'-dpdf'); % savefig(h, strcat(pt,sep,'Fig',strtok(fls(k).name, '.'), '.fig')); % end % end %% mG = mean(tG); sG = std(tG); mR = mean(tR); sR = std(tR); mC = mean(tC); sC = std(tC); %% ecdf single profiles. Uncomment below if you want each ecdf figure saved separately. % for k = 1:size(tR,1) % h = figure; % plot(cumsum(tR(k,:)), 'r', 'LineWidth',2); hold on % plot(cumsum(tG(k,:)),'g', 'LineWidth',2) % plot(cumsum(tC(k,:)),'c', 'LineWidth',2) % line([0 length(tR(k,:))], [1 1 ], 'Color', 'k', 'LineStyle',':') % ylim([0 1.05]) % xlabel('Radius (ru)') % ylabel('ecdf') % title(strcat(strtok(fls(k).name, '.'), option{CorP} ,' ecdf')); % if saveim % print(h, strcat(pt,sep,'Fig',strtok(fls(k).name, '.'), '_ecdf.pdf'),'-dpdf'); % savefig(h, strcat(pt,sep,'Fig',strtok(fls(k).name, '.'), '_ecdf.fig')); % end % end %% ecdf all profiles if size(tR,1)>1 h = figure; shadedErrorBar(x, mG, sG, 'g', 0.8); hold on shadedErrorBar(x, mR, sR, 'r', 0.8); shadedErrorBar(x, mC, sC, 'c', 0.8); plot(x,mG, 'g', 'LineWidth',3); hold on plot(x,mR, 'r', 'LineWidth',3) plot(x,mC, 'c', 'LineWidth', 3) axis tight title (['All samples profiles ', option{CorP}, ' with error']); if CorP ==1 xlabel('Normalised distance from centre to periphery'); else xlabel('Normalised distance from periphery to centre'); end ylabel('Normalised fluorescence intensity'); if saveim print(h, strcat(pt,sep,'Fig','All samples_profiles_', option{CorP},'_with_error.pdf'),'-dpdf'); savefig(h, strcat(pt,sep,'Fig','All samples_profiles_', option{CorP},'_with_error.fig')); end end %% area measurements for k = 1:size(tR,1) areaR = trapz(cumsum(tR(k,:))); areaC = trapz(cumsum(tC(k,:))); areaG = trapz(cumsum(tG(k,:))); areaDiff = areaC - areaG; area(k,1) = areaR; area(k,2) = areaC; area(k,3) = areaG; area(k,4) = areaDiff; end hdr={'AUC RFP (au)','AUC CFP (au)','AUC GFP (au)','AUC CFP - AUC GFP (au)'}; txt=sprintf('%s,',hdr{:}); txt(end)=''; dlmwrite(strcat(pt,sep,'Area_measurements.csv'),txt, ''); dlmwrite(strcat(pt,sep,'Area_measurements.csv'),area, '-append'); save(strcat(pt,sep,'Area_measurements.mat'),'area'); %% all ecdf for k = 1:size(tR,1) cumR(k,:) = cumsum(tR(k,:)); cumR(k,:) = cumR(k,:)./cumR(k,101); cumG(k,:) = cumsum(tG(k,:)); cumG(k,:) = cumG(k,:)./cumG(k,101); cumC(k,:) = cumsum(tC(k,:)); cumC(k,:) = cumC(k,:)./cumC(k,101); end mG = mean(cumG); sG = std(cumG); mR = mean(cumR); sR = std(cumR); mC = mean(cumC); sC = std(cumC); if size(tR,1)>1 h = figure; shadedErrorBar(x, mG, sG, 'g', 0.8); hold on % 'Marker', '*','MarkerSize',6 shadedErrorBar(x, mC, sC, 'c', 0.8); plot(x,mG, 'g', 'LineWidth',3); hold on plot(x,mC, 'c', 'LineWidth',3) % commentout next two lines if you want ecdf for RFP % plot(x,mR, 'r', 'LineWidth',3) % shadedErrorBar(x, mR, sR, 'r', 0.8); xlabel('Radius (ru)') ylabel('ecdf') axis tight line([0 1], [0 1], 'LineStyle', ':', 'Color','k') title (['All samples ecdfs ', ' ', option{CorP}, ' with error']); if saveim print(h, strcat(pt,sep,'Fig','All samples_ecdf_', option{CorP} ,'ecdf.pdf'),'-dpdf'); savefig(h, strcat(pt,sep,'Fig','All samples_ecdf_', option{CorP} ,'ecdf.fig')) end end end