Squashed initial commit
This commit is contained in:
199
qhtcp-workflow/apps/matlab/ezview/EZusrSelRefx.m
Executable file
199
qhtcp-workflow/apps/matlab/ezview/EZusrSelRefx.m
Executable file
@@ -0,0 +1,199 @@
|
||||
%EZusrSelRef
|
||||
|
||||
% User Select Reference Diaglog Box
|
||||
try
|
||||
if n==1 && ~exist('RF1scanN','var') && ~exist('RF2scanN','var') %change || &&
|
||||
%{
|
||||
prompt={'Enter Masterplate Number(s) of Your Reference GeneName spots:',...
|
||||
'Enter GeneName of Your Reference:'};
|
||||
rfMPstr=cell2mat(answer(1));
|
||||
rfMPcomas=strfind((cell2mat(answer(1))),',');
|
||||
n=0;
|
||||
if isempty(rfMPcomas)|| max(rfMPcomas)==length(rfMPstr)
|
||||
usrMPs=rfMPstr
|
||||
else
|
||||
for i=rfMPcomas,
|
||||
n=n+1
|
||||
usrMPs(n)=str2double(rfMPstr(i-1:i))
|
||||
if i==max(rfMPcomas)
|
||||
usrMPs(n+1)=str2double(rfMPstr(i:end))
|
||||
end
|
||||
end
|
||||
end
|
||||
usrMPs=answer(1);
|
||||
refGene=answer(2);
|
||||
%}
|
||||
prompt={'Enter GeneName to use as Reference:',...
|
||||
'Enter Specifics Term if used to futher specify Reference '}
|
||||
dlg_title='User Reference Input';
|
||||
num_lines=1;
|
||||
def={'None','Specifics Term'};
|
||||
answer=inputdlg(prompt,dlg_title,num_lines,def);
|
||||
rfGenestr=cell2mat(answer(1));
|
||||
rfSpec=cell2mat(answer(2));
|
||||
end
|
||||
|
||||
%try
|
||||
for mp=1:length(Exp(expN).Dexp(DexpN).MP)
|
||||
for ind384=1:384
|
||||
spN=spN+1;
|
||||
end
|
||||
%catch
|
||||
%end %try for user selected Reference routine
|
||||
end
|
||||
|
||||
% Disperse Reference Plates
|
||||
Exp(expN).Dexp(DexpN).RFmdPindx=[];
|
||||
Exp(expN).Dexp(DexpN).RFmdPpltN=[];
|
||||
if exist('drf','var') % ('RF1scanN','var')
|
||||
%Det. index of change from one MP to the next
|
||||
i=2;
|
||||
chgIndx(1)=1;
|
||||
for j=1:length(drf(:,3))
|
||||
if j>1
|
||||
if cell2mat(drf(j,3))~=cell2mat(drf((j-1),3)), chgIndx(i)=j; i=i+1; end
|
||||
end
|
||||
end
|
||||
chgIndx(length(chgIndx)+1)=length(drf)+1;
|
||||
uu=zeros(size(drf,1),4);
|
||||
uu(:,1:4)=cell2mat(drf(:,3:6))
|
||||
vv=zeros(length(drf),DMnum);
|
||||
dMPs=unique(cell2mat(drf(:,3)));
|
||||
%{
|
||||
for mm=1:MPnum
|
||||
nonZrfIndx.mp{mm,:}=drfPindx((find(drfPindx(:,mm))),mm);
|
||||
end
|
||||
|
||||
%}
|
||||
% nzValsG=zeros(DMnum,size(drf,1));
|
||||
% nzValsAcc=zeros(DMnum,384);
|
||||
for mm=1:length(dMPs) % length(chgIndx)
|
||||
for d=1:(DMnum)
|
||||
medianIndxDisp=[];
|
||||
NZrefIndxP=[];
|
||||
nonZeroValsP=[];
|
||||
medValLstDisp=[];
|
||||
rf1scNdisp=((dMPs(mm)-1)*DMnum)+(d);
|
||||
try % Determine the dispersed RFs median mean and std if such exist
|
||||
NZrefIndxP=drfPindx((find(drfPindx(:,dMPs(mm)))),dMPs(mm)); %find(Exp(expN).Dexp(DexpN).scan(rf1scNdisp).plate(1).CFout(drf(chgIndx(cI):chgIndx(cI+1)),5));
|
||||
% vv=Exp(expN).Dexp(DexpN).scan(rf1scNdisp).plate(1).CFout(NZrefIndxP,5);
|
||||
vv(chgIndx(mm):(chgIndx(mm+1)-1),d)=Exp(expN).Dexp(DexpN).scan(rf1scNdisp).plate(1).CFout(NZrefIndxP,5);
|
||||
nonZeroValsP=nonzeros(Exp(expN).Dexp(DexpN).scan(rf1scNdisp).plate(1).CFout(NZrefIndxP,5));
|
||||
std1Disp=std(nonZeroValsP);
|
||||
mean1Disp=mean(nonZeroValsP);
|
||||
minDisp=min(nonZeroValsP);
|
||||
maxDisp=max(nonZeroValsP);
|
||||
drfVals=Exp(expN).Dexp(DexpN).scan(rf1scNdisp).plate(1).CFout(NZrefIndxP,5);
|
||||
%nzValsAcc(mm).DM(d,:)=nonZeroValsP;
|
||||
%MEDIAN Determination for PLATES with Dispersed RFs
|
||||
%NZrefIndxP=NZrefIndxP %find(Exp(expN).Dexp(DexpN).scan(rf1scNdisp).plate(1).CFout(NZrefIndxP,5));
|
||||
if isempty(NZrefIndxP)
|
||||
nonZeroCntDisp=0
|
||||
medianIndxDisp=NZrefIndxP;
|
||||
else
|
||||
nonZeroCntDisp=length(NZrefIndxP);
|
||||
end
|
||||
if ~isempty(NZrefIndxP) && mod(nonZeroCntDisp,2)==0, medianIndxDisp=NZrefIndxP(1:nonZeroCntDisp-1); end
|
||||
if ~isempty(NZrefIndxP) && mod(nonZeroCntDisp,2)~=0, medianIndxDisp=NZrefIndxP; end
|
||||
if ~isempty(NZrefIndxP) && length(medianIndxDisp) > 3 %(.15*384) %To calc. a median, more than 15% of spots must be nonZero
|
||||
medValLstDisp=Exp(expN).Dexp(DexpN).scan(rf1scNdisp).plate(1).CFout(medianIndxDisp,5);
|
||||
%medValList1Disp{d}=medValLstDisp;
|
||||
mval1Disp=median(medValLstDisp); %mval1=median(Exp(expN).Dexp(DexpN).scan(RF1mps).plate(1).CFout(1:384,5)); %CFout(1:383,5));
|
||||
nonZeroMedPosIndx=find(mval1Disp==nonZeroValsP); %(Exp(expN).Dexp(DexpN).scan(rf1scNdisp).plate(1).CFout(NZrefIndxP,5))); %(nonZeroIndxDisp,5))); %((nonZrfIndx.mp{dMPs(mm),:}),5)));
|
||||
RFmd1posD=NZrefIndxP(nonZeroMedPosIndx); %drfPindx((RFmd1posIndx),dMPs(mm));
|
||||
RFmd1locD(1)=ceil(RFmd1posD/24); %calc r value
|
||||
RFmd1locD(2)=RFmd1posD - ((RFmd1locD(1)-1)*24); %calc c value
|
||||
lstindx=lstindx+1;
|
||||
lstindxOrf=lstindxOrf+1;
|
||||
aa(lstindx,1)={strcat('RF1mdP(',num2str(d),')')};
|
||||
aa(lstindx,2)={strcat(':',num2str(dMPs(mm)),':',num2str(RFmd1locD(1)),':',num2str(RFmd1locD(2)))};
|
||||
bb(lstindxOrf,1)={strcat('RF1mdP(',num2str(d),')')};
|
||||
bb(lstindxOrf,2)={strcat(':',num2str(dMPs(mm)),':',num2str(RFmd1locD(1)),':',num2str(RFmd1locD(2)))};
|
||||
Exp(expN).Dexp(DexpN).RFmdPLB(d,dMPs(mm))=strcat(aa(lstindx,1),aa(lstindx,2));
|
||||
Exp(expN).Dexp(DexpN).RFmdPindx(d,dMPs(mm))=RFmd1posD;
|
||||
Exp(expN).Dexp(DexpN).RFmdPpltN(d,dMPs(mm))=dMPs(mm); %This is a storage of the MasterPlate used NOT the ScanPlate? WeMight wish to store the ScanPlateNumber also???
|
||||
Exp(expN).Dexp(DexpN).RFmdPscanN(d,dMPs(mm))=rf1scNdisp;
|
||||
Exp(expN).Dexp(DexpN).RFmedianP(d,dMPs(mm))=mval1Disp;
|
||||
Exp(expN).Dexp(DexpN).stdP(d,dMPs(mm))=std1Disp;
|
||||
Exp(expN).Dexp(DexpN).meanP(d,dMPs(mm))=mean1Disp;
|
||||
Exp(expN).Dexp(DexpN).minP(d,dMPs(mm))=minDisp;
|
||||
Exp(expN).Dexp(DexpN).maxP(d,dMPs(mm))=maxDisp;
|
||||
else
|
||||
% Need to set L r K values to zeros or pick the first spot with zeros
|
||||
% Spot 1 could be other than zero as the median isn't calculated if fewer than some percent are nonzero
|
||||
medianCalcFailedD='To Few nonZero spots for valid median RF1 selection'
|
||||
firstZeroDindx=find(((Exp(expN).Dexp(DexpN).scan(rf1scNdisp).plate(1).CFout(NZrefIndxP,5))==0),1,'first');
|
||||
firstZeroD=drfPindx((firstZeroDindx),dMPs(mm));
|
||||
Exp(expN).Dexp(DexpN).RFmdPindx(d,dMPs(mm))=firstZeroD;
|
||||
Exp(expN).Dexp(DexpN).RFmdPpltN(d,dMPs(mm))=dMPs(mm); %RF1mp; %Is this supposed to be the MP number or the ScanPlate number???
|
||||
end
|
||||
catch
|
||||
medianCalcTryFailed1D='Failed! Failed! Ln565 {Dispersed RF1s} "try" But process continued with bogus Plate spot value!'
|
||||
try
|
||||
firstZeroindxD=find(vv((chgIndx(d):chgIndx(d+1)-1),5)==0,1,'first');
|
||||
firstZeroPindx=uu(firstZeroindxD,4);
|
||||
Exp(expN).Dexp(DexpN).RFmdPpltN(d,dMPs(mm))=dMPs(mm);
|
||||
Exp(expN).Dexp(DexpN).RFmdPindx(d,dMPs(mm))=firstZeroPindx;
|
||||
catch
|
||||
Exp(expN).Dexp(DexpN).RFmdPpltN(d,dMPs(mm))=dMPs(mm);
|
||||
Exp(expN).Dexp(DexpN).RFmdPindx(d,dMPs(mm))=384; %if crapout,Then use spot384 as default to keep going
|
||||
end
|
||||
try
|
||||
Exp(expN).Dexp(DexpN).RFmdPpltN=dMPs(mm);
|
||||
catch
|
||||
Exp(expN).Dexp(DexpN).RFmdPpltN=1; %This might keep from breaking BUT ???
|
||||
end
|
||||
end
|
||||
end % for d=0:DMnum
|
||||
end % for mm=1:length(dMPs)
|
||||
|
||||
% Calc. Global Mean, Std, And Median For Distributed References
|
||||
uu=horzcat(uu,vv);
|
||||
for d=1:DMnum
|
||||
medianIndxG=[];
|
||||
NZrfIndxG=[];
|
||||
minG=min(nonzeros(vv(:,d)));
|
||||
maxG=max(nonzeros(vv(:,d)));
|
||||
RFmeanG=mean(nonzeros(vv(:,d)));
|
||||
RFstdG=std(nonzeros(vv(:,d)));
|
||||
NZrfIndxG=find(nonzeros(vv(:,d)));
|
||||
|
||||
if isempty(RFmeanG)
|
||||
nonZeroCntD=0
|
||||
% medianIndxDisp=RFmeanG(d);
|
||||
else
|
||||
nonZeroCntD=length(nonzeros(vv(:,d)));
|
||||
end
|
||||
|
||||
% Calc. of median requires an odd number of indx items
|
||||
if ~isempty(NZrfIndxG) && mod(nonZeroCntD,2)==0, medianIndxD=NZrfIndxG(1:(size(NZrfIndxG,1)-1)); end
|
||||
if ~isempty(NZrfIndxG) && mod(nonZeroCntD,2)~=0, medianIndxD=NZrfIndxG(:); end
|
||||
if ~isempty(NZrfIndxG) && length(medianIndxD) > (.15*size(drf,1)) % To calc. a median, more than 15% of spots must be nonZero
|
||||
mvalsDG=median(vv(medianIndxD,d)); % (nonzeros(vv(:,d)));
|
||||
nzPosIndxDG=find(mvalsDG==vv(:,d));
|
||||
RFmdDGloc(d,1)=uu(nzPosIndxDG,1); % MP of distributedGlobal Median value
|
||||
RFmdDGloc(d,2)=uu(nzPosIndxDG,2); % calc r value
|
||||
RFmdDGloc(d,3)=uu(nzPosIndxDG,3); % calc c value
|
||||
lstindx=lstindx+1;
|
||||
lstindxOrf=lstindxOrf+1;
|
||||
aa(lstindx,1)={strcat('RF1mdG(',num2str(d),')')};
|
||||
aa(lstindx,2)={strcat(':',num2str(RFmdDGloc(d,1)),':',num2str(RFmdDGloc(d,2)),':',num2str(RFmdDGloc(d,3)))}; %,'std_',num2str(std2))};
|
||||
bb(lstindxOrf,1)={strcat('RF1mdG(',num2str(d),')')};
|
||||
bb(lstindxOrf,2)={strcat(':',num2str(RFmdDGloc(d,1)),':',num2str(RFmdDGloc(d,2)),':',num2str(RFmdDGloc(d,3)))}; %,'std_',num2str(std2))};
|
||||
|
||||
Exp(expN).Dexp(DexpN).RFmdGLB(d)=strcat(aa(lstindx,1),aa(lstindx,2));
|
||||
Exp(expN).Dexp(DexpN).RFmdGindx(d)=nzPosIndxDG;
|
||||
Exp(expN).Dexp(DexpN).RFmdGpltN(d)=RFmdDGloc(d,1);
|
||||
Exp(expN).Dexp(DexpN).RFmdGscanN(d)=uu(nzPosIndxDG,4);
|
||||
Exp(expN).Dexp(DexpN).RFmedianG(d)=mvalsDG;
|
||||
Exp(expN).Dexp(DexpN).RFminG(d)=minG;
|
||||
Exp(expN).Dexp(DexpN).RFmaxG(d)=maxG;
|
||||
Exp(expN).Dexp(DexpN).RFstdG(d)=RFstdG;
|
||||
Exp(expN).Dexp(DexpN).RFmeanG(d)=RFmeanG;
|
||||
end
|
||||
end
|
||||
end
|
||||
catch
|
||||
msg='Failed attempt to apply User Selected Reference'
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user