Code covered by the BSD License  

Highlights from
FRETSCAL

image thumbnail

FRETSCAL

by

 

For the FRET analysis of images of yeast cells labeled with YFP and CFP.

fdistribution2( flag )
function fdistribution2( flag )
%Version 4/3/09 Called to display a distribution and by writefinal to
%display on the command line the min, max and average values and throw the averages to parms file.
global  accepted darkgreen fontpics histfig
global CFPspill YFPspill
global dirsep inspectedfile inputdirectory outputdirectory
global gminimum gmaximum gaverage gstddev
global cminimum cmaximum caverage cstddev
global fminimum fmaximum faverage fstddev
global yminimum ymaximum yaverage ystddev
global AOI line1 line2 ExptType

dir = strcat( inputdirectory, dirsep, outputdirectory );
fin = fopen( strcat( dir, dirsep, inspectedfile ), 'r' );
line1 = fgetl(fin);%skip first  header line
start1 = ftell(fin);
line2 = fgetl(fin);
fseek(fin,start1,-1);
line2a = textscan(fin,'%s%s%s%f%s%f%s%d%s%f%s%f%s%f%s%f%s%f%s%f%s%f%s%f%s%f%s%f%s%f%s%f%s%f%s%f%s%f%s%f%s%f%s%f%s%f%s%f%s%f',1);
ExptType = line2a{2}(1);
CFPspill = line2a{4}(1);
YFPspill = line2a{6}(1);
AOI = textscan(fin,'%s%s%s%s%d%f%f%f%f%f%f%f%f%f%f%f%f%f%f%d%d%f%f%f%d%d%f%f%f%d%d');%cell array
fclose(fin);
accepted = length(AOI{1});
adjustYFP = AOI{12}(:);
yminimum = min(adjustYFP);
ymaximum = max(adjustYFP);
yaverage = mean (adjustYFP);
ystddev = std(adjustYFP);
adjustFRET = AOI{13}(:);
fminimum = min(adjustFRET);
fmaximum = max(adjustFRET);
faverage = mean(adjustFRET);
fstddev = std(adjustFRET);
adjustCFP = AOI{14}(:);
cminimum = min(adjustCFP);
cmaximum = max(adjustCFP);
caverage = mean (adjustCFP);
cstddev = std(adjustCFP);
Totspillover = zeros(accepted,1);
for i = 1:accepted
    Totspillover(i) = (CFPspill*AOI{14}(i)) + YFPspill*AOI{12}(i);
end
adjustg = zeros(accepted,1);
for i = 1:accepted
    adjustg(i) = AOI{13}(i)/Totspillover(i);
    %In a [C,Y]FP spillover expt: [C,Y]FPspill = 1, [Y,C]FPspill = 0;
    %Thus adjustg = FRETr, CFP or YFP spillover factor depending on experiment type
end
gminimum = min(adjustg);
gmaximum = max(adjustg);
gaverage = mean (adjustg);
gstddev = std(adjustg);
YFPFWHM = AOI{17}(:);
YFPFWHMmin = min(YFPFWHM);
YFPFWHMmax = max(YFPFWHM);
YFPFWHMavg = mean (YFPFWHM);
YFPFWHMstd = std(YFPFWHM);
YFPsig2bac = AOI{18}(:);
YFPsig2bacmin = min(YFPsig2bac);
YFPsig2bacmax = max(YFPsig2bac);
YFPsig2bacavg = mean (YFPsig2bac);
YFPsig2bacstd = std(YFPsig2bac);
YFPmon = AOI{19}(:);
YFPmonmin = min(YFPmon);
YFPmonmax = max(YFPmon);
YFPmonavg = mean (YFPmon);
YFPmonstd = std(YFPmon);
FRETFWHM = AOI{22}(:);
FRETFWHMmin = min(FRETFWHM);
FRETFWHMmax = max(FRETFWHM);
FRETFWHMavg = mean (FRETFWHM);
FRETFWHMstd = std(FRETFWHM);
FRETsig2bac = AOI{23}(:);
FRETsig2bacmin = min(FRETsig2bac);
FRETsig2bacmax = max(FRETsig2bac);
FRETsig2bacavg = mean (FRETsig2bac);
FRETsig2bacstd = std(FRETsig2bac);
FRETmon = AOI{24}(:);
FRETmonmin = min(FRETmon);
FRETmonmax = max(FRETmon);
FRETmonavg = mean (FRETmon);
FRETmonstd = std(FRETmon);
CFPFWHM = AOI{27}(:);
CFPFWHMmin = min(CFPFWHM);
CFPFWHMmax = max(CFPFWHM);
CFPFWHMavg = mean (CFPFWHM);
CFPFWHMstd = std(CFPFWHM);
CFPsig2bac = AOI{28}(:);
CFPsig2bacmin = min(CFPsig2bac);
CFPsig2bacmax = max(CFPsig2bac);
CFPsig2bacavg = mean (CFPsig2bac);
CFPsig2bacstd = std(CFPsig2bac);
CFPmon = AOI{29}(:);
CFPmonmin = min(CFPmon);
CFPmonmax = max(CFPmon);
CFPmonavg = mean (CFPmon);
CFPmonstd = std(CFPmon);
if flag > 0
    if flag == 1
        plottitle = 'YFP Signal/Bkg (avg. observed intensity/bkg)';
        plotme = YFPsig2bac;
        plotmemax = YFPsig2bacmax;
        plotmemin = YFPsig2bacmin;
        plotmeavg = YFPsig2bacavg;
        plotmestd = YFPsig2bacstd;
    elseif flag == 2
        plottitle = 'Distribution of YFP FWHM';
        plotme = YFPFWHM;
        plotmemax = YFPFWHMmax;
        plotmemin = YFPFWHMmin;
        plotmeavg = YFPFWHMavg;
        plotmestd = YFPFWHMstd;
    elseif flag == 3
        plottitle = 'FRET Signal/Bkg (avg. observed intensity/bkg)';
        plotme = FRETsig2bac;
        plotmemax = FRETsig2bacmax;
        plotmemin = FRETsig2bacmin;
        plotmeavg = FRETsig2bacavg;
        plotmestd = FRETsig2bacstd;
    elseif flag == 4
        plottitle = 'Distribution of FRET FWHM';
        plotme = FRETFWHM;
        plotmemax = FRETFWHMmax;
        plotmemin = FRETFWHMmin;
        plotmeavg = FRETFWHMavg;
        plotmestd = FRETFWHMstd;
    elseif flag == 5
        plottitle = 'CFP Signal/Bkg(avg. observed intensity/bkg)';
        plotme = CFPsig2bac;
        plotmemax = CFPsig2bacmax;
        plotmemin = CFPsig2bacmin;
        plotmeavg = CFPsig2bacavg;
        plotmestd = CFPsig2bacstd;
    elseif flag == 6
        plottitle = 'Distribution of CFP FWHM';
        plotme = CFPFWHM;
        plotmemax = CFPFWHMmax;
        plotmemin = CFPFWHMmin;
        plotmeavg = CFPFWHMavg;
        plotmestd = CFPFWHMstd;
    elseif flag == 7
        plottitle = 'Distribution YFP spillover';
        plotme = adjustg;
        plotmemax = gmaximum;
        plotmemin = gminimum;
        plotmeavg = gaverage;
        plotmestd = gstddev;
    elseif flag == 8
        plottitle = 'Distribution of CFP spillover';
        plotme = adjustg;
        plotmemax = gmaximum;
        plotmemin = gminimum;
        plotmeavg = gaverage;
        plotmestd = gstddev;
    elseif flag == 9
        plottitle = 'Distribution of FRETR';
        plotme = adjustg;
        plotmemax = gmaximum;
        plotmemin = gminimum;
        plotmeavg = gaverage;
        plotmestd = gstddev;
    elseif flag == 10
        plottitle = 'Distribution of YFP monotonic values';
        plotme = YFPmon;
        plotmemax = YFPmonmax;
        plotmemin = YFPmonmin;
        plotmeavg = YFPmonavg;
        plotmestd = YFPmonstd;
    elseif flag == 11
        plottitle = 'Distribution of FRET monotonic values';
        plotme = FRETmon;
        plotmemax = FRETmonmax;
        plotmemin = FRETmonmin;
        plotmeavg = FRETmonavg;
        plotmestd = FRETmonstd;
    elseif flag == 12
        plottitle = 'Distribution of CFP monotonic values';
        plotme = CFPmon;
        plotmemax = CFPmonmax;
        plotmemin = CFPmonmin;
        plotmeavg = CFPmonavg;
        plotmestd = CFPmonstd;
    end
    if plotmemin == plotmemax
        plotmemax = plotmemax*1.1;
        plotmemin = plotmemin - plotmemin*.1;
    end
    if accepted >= 500
        incr = (plotmemax-plotmemin)/(accepted/30);
    elseif accepted >= 300 && accepted < 500
        incr = (plotmemax-plotmemin)/20;
    elseif accepted >= 70 && accepted < 300
        incr = (plotmemax-plotmemin)/10;
    elseif accepted >= 50 && accepted < 70
        incr = (plotmemax-plotmemin)/7;
    elseif accepted >= 40 && accepted < 50
        incr = (plotmemax-plotmemin)/5;
    elseif accepted >= 30 && accepted < 40
        incr = (plotmemax-plotmemin)/4;
    elseif accepted < 30
        incr = (plotmemax-plotmemin)/4;
    end
    if flag == 7 && strcmp(ExptType,'calcYFPspill') ~= 1
        fprintf(1,'No values to plot since experiment did not calculate YFP spillover factor!\n');
    elseif flag == 8 && strcmp(ExptType,'calcCFPspill') ~= 1
        fprintf(1,'No values to plot since experiment did not calculate CFP spillover factor!\n');
    elseif flag == 9 && strcmp(ExptType,'FRET') ~= 1
        fprintf(1,'No values to plot since experiment did not calculate FRETR!\n');
    elseif plotmeavg == 0 || isnan(plotmeavg) == 1
        fprintf(1,'No values to plot!\n');
    else
        n = histc( plotme(:), plotmemin:incr:plotmemax );
        binc = plotmemin:incr:plotmemax;
        histfig = figure('Color', darkgreen,'units','normalized','Color','white','Name', plottitle,'menubar','figure','pos',[ .25 .10 .5 .5 ]);
        hold on;
        %   titlestring = sprintf( 'Total number of data values = %d', accepted );
        title( plottitle,'Fontsize',16 );
        favgstring = sprintf( 'Total number of data values = %d\nAverage value is %5.3f +/- %5.3f ', accepted,plotmeavg,plotmestd );
        xlabel( favgstring,'Fontsize',14 );
        ylabel('Counts','Fontsize',14);
        g = bar( binc, n,'style','histc');
        set(g,'EdgeColor','w','FaceColor','k')
        xy = get(gcf,'CurrentAxes');
        set(xy,'FontSize',12,'LineWidth',1,'Layer','top')
        uicontrol( 'style','pushbutton', 'units', 'normalized',  'string','Close',...
            'position',[ .9 .9 .1 .1 ], 'fontsize', fontpics,'background','r','fore','w','callback',@closehistogram);
    end
else
    fprintf(1,'YFP background subtracted average intensity = %f\n',yaverage);
    fprintf(1,'YFP monotonic average = %f\n',YFPmonavg);
    fprintf(1,'YFP FWHM average = %f\n\n',YFPFWHMavg);
    fprintf(1,'FRET background subtracted average intensity = %f\n',faverage);
    fprintf(1,'FRET monotonic average = %f\n',FRETmonavg);
    fprintf(1,'FRET FWHM average = %f\n\n',FRETFWHMavg);
    fprintf(1,'CFP background subtracted average intensity = %f\n',caverage);
    fprintf(1,'CFP monotonic average = %f\n',CFPmonavg);
    fprintf(1,'CFP FWHM average = %f\n',CFPFWHMavg);
end;
end

function closehistogram( gcf, eventdata, handles )
global histfig
close(histfig);
end

Contact us