123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876 |
- % EZvInitLoad
- global Exp
- global Expaa
- global Expbb
- global userPars
- global scansDir
- global matFile
- global zonePB
- global mpdmFile
- global ghandles
- % Initialize some variables from matlab
- ezPath=which(mfilename);
- [ezDir,ezFileName]=fileparts(ezPath);
- ezDir=fullfile(easyDir);
- [parentDir, ~]=fileparts(ezDir);
- parentDir=fullfile(parentDir);
- debug=1;
- if debug
- disp('Running in debug mode');
- disp('Initialized variables:');
- whos;
- end
- fprintf('This script name: %s\n', ezFileName);
- % Set scansDir (project scans directory) intelligently
- if exist('PROJECT_SCANS_DIR', 'var') && ~isempty(getenv('PROJECT_SCANS_DIR'))
- scansDir=fullfile(getenv('PROJECT_SCANS_DIR'));
- if exist(scansDir, 'dir')
- fprintf('Using scans directory: %s from environment variable PROJECT_SCANS_DIR\n', scansDir);
- disp('This usually indicates that we are in module mode');
- if ~exist('PROJECT', 'var') || isempty(getenv('PROJECT'))
- dirInfo=fileparts(scansDir);
- project=dirInfo.name;
- end
- else
- disp('WARNING: PROJECT_SCANS_DIR does not exist');
- end
- elseif exist('PROJECT', 'var') && ~isempty(getenv('PROJECT')) % for standalone mode
- % scansDir=fullfile(parentDir, '..', '..', 'scans', getenv('PROJECT') 'out', 'easy', getenv('PROJECT'));
- scansDir=fullfile(parentDir, '..', '..', 'scans', getenv('PROJECT'));
- project=getenv('PROJECT');
- fprintf('Using project path: %s from environment variable PROJECT\n', scansDir);
- disp('This usually indicates that we are in standalone mode');
- else
- % TODO Lots of this is hardcoded logic, this TODO is just a reminder to change this block
- % when changing EASY/EZdir and other variables in the parent script
- fprintf('WARNING: Running in standalone mode without PROJECT or PROJECT_SCANS_DIR environment variables (not recommended)\n');
- fprintf('Beginning parent scans directory search\n');
- dirsToScan={
- fullfile(parentDir, '..', '..', 'scans')
- fullfile(parentDir, '..', '..', 'ExpJobs')
- fullfile('mnt','data','scans')
- fullfile('mnt','data', 'ExpJobs')
- fullfile(parentDir, '..', '..', 'templates', 'scans-demo')
- };
- for i=1:length(dirsToScan)
- d=dirsToScan(i);
- d=char(d);
- if exist(d, 'dir')
- subDirs=dir(d);
- pattern='^\d{6}_.*_.*';
- matchedDirs={dirs(regexp(subDirs.name, pattern)).name};
- if ~isempty(matchedDirs)
- fprintf('Found a non-empty scans directory in our list: %s\n', char(d));
- fprintf('Setting scansDir to %s\n', char(d));
- scansDir=fullfile(d);
- end
- fprintf('Scanning inside %s for a project directory\n', char(d));
- sortedMatchedDirs=sortrows(matchedDirs);
- project=sortedMatchedDirs{1}; % select the latest dir (by date prefix)
- fprintf('Selected latest project directory %s\n', char(project));
- end
- end
- end
- % User sanity check and warning
- if exist('PROJECT_USER', 'var') && ~isempty(getenv('PROJECT_USER'))
- if ~equal(getenv('PROJECT_USER'), userName)
- disp("WARNING: PROJECT_USER does not match the current namespace");
- end
- end
- % Allow module to override hardcoded default EZview directory
- if exist('EZVIEW_DIR','var') && ~isempty(getenv('EZVIEW_DIR'))
- EZVIEW_DIR=fullfile(getenv('EZVIEW_DIR'));
- if ~strcmp(ezDir, EZVIEW_DIR) % sanity check
- disp("WARNING: EZVIEW_DIR does not match this script's hardcoded EZview location");
- disp("This is probably OK but if strange beahvior arises, we'll need to fix it in code");
- ezDir=EZVIEW_DIR;
- end
- fprintf('Using EZview script directory: %s from environment variable EZVIEW_DIR\n', ezDir);
- else
- fprintf('Using EZview script directory: %s from hardcoded default\n', ezDir);
- end
- % Allow module to override hardcoded default EASY directory
- if exist('EASY_DIR','var') && ~isempty(getenv('EASY_DIR'))
- EASY_DIR=fullfile(getenv('EASY_DIR'));
- if ~strcmp(easyDir, EASY_DIR) % sanity check
- disp("WARNING: EASY_DIR does not match this script's hardcoded EASY location");
- disp("This is probably OK but if strange beahvior arises, we'll need to fix it in code");
- easyDir=EASY_DIR;
- end
- fprintf('Using EASY script directory: %s from environment variable EASY_DIR\n', easyDir);
- else
- fprintf('Using EASY script directory: %s from hardcoded default\n', easyDir);
- end
- userPars.BPdefault={'on','on','0.3','8','45','1000'};
- userPars.boxplotFlg=1;
- userPars.BPoutliers='On';
- userPars.BPnotch='On';
- userPars.BPlblShft=0.3;
- userPars.BPfontSz=8;
- userPars.BProt=45;
- userPars.Trenddefault={'1000'};
- userPars.kfiltLim=str2double(userPars.BPdefault(6));
- try
- % Generate the Exp arrays
- numExps=3;
- for i=1:numExps
- Exp(i).cTraceN=0;
- Exp(i).cTraceIndx(1)=1;
- end
- Exp(1).CompositPlot=0;Exp(2).CompositPlot=0;Exp(3).CompositPlot=0;
- for i=1:numExps
- Exp(i).DexpType='single';
- Exp(i).DexpN=1;
- Exp(i).DexpLength=1;
- eval(['set(handles.DN' num2str(i) ', ''value'', 1);']); % MATLAB level unlocked
- end
- set(handles.GeneOrfTog,'value',0)
- try
- load('EZsgdInfo');
- catch
- disp('Fail to load EZsgdInfo file from code directory');
- end
- Exp(numExps+1).SGDnum=SGDnum;
- Exp(numExps+1).SGDtext=SGDtext;
- Exp(numExps+1).SGDraw=SGDraw;
- Exp(numExps+1).interacPBsel=0;
- % Big outer loop try catch to ln844 end ln868
- % try to use user selected 'ExpJobs' folder otherwise use a default
- % directory in the uigetfile to load the experiment .mat file.
- try
- [matFile,scansDir]=uigetfile('.mat','Open Experiment folder and data storage .mat file name','MultiSelect','off')
- load (fullfile(Exp(1).Dexp(1).ExpFoldr,'MasterPlateFiles','MPDMmat.mat'))
- for i=1:numExps
- Exp(i).Dexp(1).DM=DM;
- Exp(i).Dexp(1).MP=MP;
- Exp(i).Dexp(1).scan=scan;
- Exp(i).cTraceIndx(1)=1;
- end
-
- load(fullfile(resDir,'PTmats','NImParameters'))
- Exp(1).Dexp(1).ImParMat=ImParMat;
- Exp(2).Dexp(1).ImParMat=ImParMat;
- Exp(3).Dexp(1).ImParMat=ImParMat;
- try
- load(fullfile(resDir,'Fotos','Coordinates'))
- load(fullfile(resDir,'Fotos','anlZones'))
- load(fullfile(resDir,'Fotos','BGatTpts'))
- for i=1:numExps
- Exp(i).Dexp(1).FexpScanSpots=FexpScanSpots;
- Exp(i).Dexp(1).FexpScanBMtp=FexpScanBMtp;
- Exp(i).Dexp(1).anlZoneRefs=anlZoneRefs;
- Exp(i).cTraceIndx(1)=1;
- end
- catch
- end
- for i=1:numExps
- Exp(i).traceN=0; % ZoneRelated
- Exp(i).traceN=0;
- Exp(i).hOL=[];
- Exp(i).hOLb=[];
- Exp(i).hOLname={};
- Exp(i).hOLexpNm={};
- Exp(i).hOLresDir={}
- Exp(i).hOLplateNum=[];
- Exp(i).hOLresDir={};
- Exp(i).RFmd1indx=[];
- Exp(i).RFmd1pltN=[];
- Exp(i).RFmd2indx=[];
- Exp(i).RFmd2pltN=[];
- end
- % default values for EZvFigPrint that meet JLH preferences
- Exp(4).plotPars={'4','36','10','5'};
- expN=1;
-
- % Test for Bad MP cell array (usually 384 [NaN}'s)
- % replaced length(Exp(expN).Dexp(1).MP) with MPnum
- for mx=1:length(Exp(expN).Dexp(1).MP)
- try
- char((Exp(1).Dexp(1).MP(mx).genename{1}(384)))
- MPnum=mx;
- catch
- break
- end
- end
- % MPnum=length(Exp(expN).Dexp(1).MP);
- set(handles.MPsldr1,'min',1,'max',MPnum)
- set(handles.MPsldr2,'min',1,'max',MPnum)
- set(handles.MPsldr3,'min',1,'max',MPnum)
- DMnum=length(Exp(expN).Dexp(1).DM.drug);
- set(handles.DMsldr1,'min',1,'max',DMnum) %DMnum,'value',1.01) %100,'value',1.01)
- set(handles.DMsldr2,'min',1,'max',DMnum)
- set(handles.DMsldr3,'min',1,'max',DMnum)
- tPtsSize=size(Exp(expN).Dexp(1).FexpScanBMtp{1,1},(3));
- set(handles.Tptsldr1,'min',1,'max',tPtsSize)
- set(handles.Tptsldr2,'min',1,'max',tPtsSize)
- set(handles.Tptsldr3,'min',1,'max',tPtsSize)
- set(handles.MPsldr1,'SliderStep',[1/MPnum 1/MPnum]); %[1/length(MP) 1/length(MP)])
- set(handles.DMsldr1,'SliderStep',[1/length(DM.drug) 1/length(DM.drug)]);
- set(handles.Tptsldr1,'SliderStep',[1/tPtsSize 1/tPtsSize]);
- set(handles.MPsldr2,'SliderStep',[1/MPnum 1/MPnum]);
- set(handles.DMsldr2,'SliderStep',[1/length(DM.drug) 1/length(DM.drug)]);
- set(handles.Tptsldr2,'SliderStep',[1/tPtsSize 1/tPtsSize]);
- set(handles.MPsldr3,'SliderStep',[1/MPnum 1/MPnum]);
- set(handles.DMsldr3,'SliderStep',[1/length(DM.drug) 1/length(DM.drug)]);
- set(handles.Tptsldr3,'SliderStep',[1/tPtsSize 1/tPtsSize]);
- try
- xp=char(Exp(expN).Dexp(1).resDir);
- if ispc
- slashPos=strfind(char(Exp(expN).Dexp(1).resDir),'\');
- else
- slashPos=strfind(char(Exp(expN).Dexp(1).resDir),'/');
- end
- startPos=slashPos(length(slashPos)-1) +1;
- endPos=slashPos(length(slashPos)) -1;
- expStr=xp(startPos:endPos);
- set(handles.expName1,'string',expStr);
- set(handles.expName2,'string',expStr);
- set(handles.expName3,'string',expStr);
- catch
- cd(w)
- end %internal try xp=char(Exp(expN).Dexp(1).resDir); if ispc,...
- catch
- cd(w)
- msg='LOADing or Setup issue'
- % if no load, then Message try SelExp PB to reload or try and different experiment
- end
- try
- DNLaxes1=handles.DNLaxes1; DNLaxes2=handles.DNLaxes2; DNLaxes3=handles.DNLaxes3;
- zeroCLn=zeros(1,DMnum);
- %Exp(expN).expLoadCnt(1)=1; %ZoneRelated
- Exp(1).hzeroCLn(1)=plot(DNLaxes1,zeroCLn,1:DMnum,'y'); try set(Exp(1).hzeroCLn,'visible','off'); catch ME, end
- Exp(2).hzeroCLn(1)=plot(DNLaxes2,zeroCLn,1:DMnum,'y'); try set(Exp(2).hzeroCLn,'visible','off'); catch ME, end
- Exp(3).hzeroCLn(1)=plot(DNLaxes3,zeroCLn,1:DMnum,'y'); try set(Exp(3).hzeroCLn,'visible','off'); catch ME, end
- Exp(1).expLoadCnt=1;
- Exp(2).expLoadCnt=1;
- Exp(3).expLoadCnt=1;
- catch ME
- ME.message,
- end
- % Compile GeneList and OrfList
- % Sort and add the medians of Ref Plates if RF1,RF2 exist
- set(handles.listboxGnOrf,'string',{('Loading')})
- lstindx=0;
- lstindxOrf=0;
- spN=0;
- rfcnt=0;
- dRF1indx=0;
- RF1mp=[];
- RF2mp=[];
- for mp=1:MPnum %length(Exp(expN).Dexp(1).MP)
- RF1fullPlate=0;
- try RF1fullPlate=sum(ismember((Exp(expN).Dexp(1).MP(mp).genename{1}),'RF1'))==384; catch, mp, msg=strcat(num2str(mp),' genename ERROR'), end
- RF2fullPlate=0;
- try RF2fullPlate=sum(ismember((Exp(expN).Dexp(1).MP(mp).genename{1}),'RF2'))==384; catch, mp, msg=strcat(num2str(mp),' genename ERROR'), end
- for ind384=1:384
- spN=spN+1;
- try % temp find data error
- r=ceil(ind384/24);
- if rem(ind384,24)==0, c=24; else c=rem(ind384,24); end
- % Insert test for numeric in genename and orf if isnumeric
- % Correct common EXCEL problem of converting OCT1 into a date numeric
- if cell2mat(Exp(expN).Dexp(1).MP(mp).genename{1}(ind384))==38991,
- Exp(expN).Dexp(1).MP(mp).genename{1}(ind384)={'OCT1_'};
- % genename{1}(ind384) replace numeric with a space ' ' or something
- elseif isnumeric(cell2mat(Exp(expN).Dexp(1).MP(mp).genename{1}(ind384)))
- Exp(expN).Dexp(1).MP(mp).genename{1}(ind384)={' '};
- end
- % Check for full(384spot) Reference Plates (RF1 or/and RF2)
- RF1fullPlate=0;
- try RF1fullPlate=sum(ismember((Exp(expN).Dexp(1).MP(mp).genename{1}),'RF1'))==384; catch, mp, msg=strcat(num2str(mp),' genename ERROR'), end
- RF2fullPlate=0;
- try RF2fullPlate=sum(ismember((Exp(expN).Dexp(1).MP(mp).genename{1}),'RF2'))==384; catch, mp, msg=strcat(num2str(mp),' genename ERROR'), end
- if isempty(regexpi(char((Exp(expN).Dexp(1).MP(mp).orf{1}(ind384))),'blank'))... %,'\<blank\>'
- && ~isnumeric(Exp(expN).Dexp(1).MP(mp).orf{1}(ind384))...
- && ~strcmpi((Exp(expN).Dexp(1).MP(mp).orf{1}(ind384)),' ')...
- && ~strcmpi((Exp(expN).Dexp(1).MP(mp).orf{1}(ind384)),' ')...
- && ~strcmpi((Exp(expN).Dexp(1).MP(mp).orf{1}(ind384)),'')...
- && ~isempty((Exp(expN).Dexp(1).MP(mp).orf{1}(ind384)))...
- && ~strcmpi((Exp(expN).Dexp(1).MP(mp).orf{1}(ind384)),'RF1')...
- && ~strcmpi((Exp(expN).Dexp(1).MP(mp).orf{1}(ind384)),'RF2')...
- && iscellstr((Exp(expN).Dexp(1).MP(mp).orf{1}(ind384))) % .genename{1}(ind384)))
- lstindxOrf=lstindxOrf+1;
- bb(lstindxOrf,1)=(Exp(expN).Dexp(1).MP(mp).orf{1}(ind384));
- bb(lstindxOrf,2)={strcat(':',num2str(mp),':',num2str(r),':',num2str(c))};
- bb(lstindxOrf,3)={mp};
- bb(lstindxOrf,4)={r};
- bb(lstindxOrf,5)={c};
- mutorfs(lstindxOrf)=spN; %16_0318 added for Interaction EZinteract
- end
- if isempty(regexpi(char((Exp(expN).Dexp(1).MP(mp).genename{1}(ind384))),'blank'))... %,'\<blank\>'
- && ~isnumeric(Exp(expN).Dexp(1).MP(mp).genename{1}(ind384))...
- && ~strcmpi((Exp(expN).Dexp(1).MP(mp).genename{1}(ind384)),' ')...
- && ~strcmpi((Exp(expN).Dexp(1).MP(mp).genename{1}(ind384)),' ')...
- && ~strcmpi((Exp(expN).Dexp(1).MP(mp).genename{1}(ind384)),'')...
- && ~isempty((Exp(expN).Dexp(1).MP(mp).genename{1}(ind384)))...
- && ~strcmpi((Exp(expN).Dexp(1).MP(mp).genename{1}(ind384)),'RF1')...
- && ~strcmpi((Exp(expN).Dexp(1).MP(mp).genename{1}(ind384)),'RF2')...
- && iscellstr((Exp(expN).Dexp(1).MP(mp).genename{1}(ind384)))
- lstindx=lstindx+1;
- aa(lstindx,1)=(Exp(expN).Dexp(1).MP(mp).genename{1}(ind384));
- aa(lstindx,2)={strcat(':',num2str(mp),':',num2str(r),':',num2str(c))};
- aa(lstindx,3)={mp};
- aa(lstindx,4)={r};
- aa(lstindx,5)={c};
- mutgenes(lstindx)=spN;
- % Exp(expN).Dexp(1).mutSpotIndx.woRFs(lstindx)=spN;
- elseif (RF1fullPlate==1 ... % sum(ismember((Exp(expN).Dexp(1).MP(mp).genename{1}),'RF1'))==384 || ...
- || (length(unique(Exp(expN).Dexp(1).MP(mp).genename{1}(1:384))))==1 && mp==1 ) ... %(isequal((Exp(expN).Dexp(1).MP(mp).genename{1}(1:384)), (Exp(expN).Dexp(1).MP(mp).genename{1}(384:-1:1)))&& mp==1 )) && ...
- && ~exist('RF1scanN','var')
- RF1mp=mp
- RF1scanN=(mp*DMnum)-(DMnum-1); %mp;
- rfcnt=rfcnt+1;
- RFs(spN:spN+383)=spN:spN+383;
- elseif (RF2fullPlate==1 ... %sum(ismember((Exp(expN).Dexp(1).MP(mp).genename{1}(ind384)),'RF2'))==384 ||...
- || (length(unique(Exp(expN).Dexp(1).MP(mp).genename{1}(1:384))))==1 && mp==MPnum ) && ~exist('RF2scanN','var')
- rfcnt=rfcnt+1;
- RFs(spN:spN+383)=spN:spN+383;
- asdf=sparse(RFs);
- asd=find(asdf);
- RFs=asd;
- RF2mp=mp
- RF2scanN=(mp*DMnum)-(DMnum-1); %mp;
- elseif strcmpi((Exp(expN).Dexp(1).MP(mp).genename{1}(ind384)),'RF1') && (RF1fullPlate~=1)
- dRF1indx=dRF1indx+1;
- Exp(expN).Dexp(1).MP(mp).genename{1}(ind384)=strrep((Exp(expN).Dexp(1).MP(mp).genename{1}(ind384)),':',' ');
- drf(dRF1indx,1)=(Exp(expN).Dexp(1).MP(mp).genename{1}(ind384));
- drf(dRF1indx,2)={strcat(':',num2str(mp),':',num2str(r),':',num2str(c))};
- drf(dRF1indx,3)={mp}; drfMP(dRF1indx,mp)=mp;
- drf(dRF1indx,4)={r}; drfr(dRF1indx,mp)=r;
- drf(dRF1indx,5)={c}; drfc(dRF1indx,mp)=c;
- drf(dRF1indx,6)={ind384}; drfPindx(dRF1indx,mp)=ind384;
- end % if isempty(regexpi(char((Exp(expN).Dexp(1).MP(mp).genename{1}(ind384))),'blank'))...
- catch
- mp
- ind384
- msgBadGeneName=strcat('check genename at mp=',num2str(mp),' indx=',num2str(ind384))
- end
- end
- mp
- end
- % Cover case if mutorfs RFs are labeled RF1 or RF2
- try
- Exp(1).Dexp(1).mutSpotIndx.wRFs=union(RFs, mutorfs);
- catch
- msg='No RFs Found in Exp! wRFs'
- Exp(1).Dexp(1).mutSpotIndx.wRFs=mutorfs;
- end
- try
- Exp(1).Dexp(1).mutSpotIndx.woRFs=setdiff(mutorfs,RFs);
- catch
- Exp(expN).Dexp(1).mutSpotIndx.woRFs=mutorfs;
- msg='No RFs Found in Exp! woRFs'
- end
- Exp(2).Dexp(1).mutSpotIndx.wRFs=Exp(1).Dexp(1).mutSpotIndx.wRFs;
- Exp(2).Dexp(1).mutSpotIndx.woRFs=Exp(1).Dexp(1).mutSpotIndx.woRFs;
- Exp(3).Dexp(1).mutSpotIndx.wRFs=Exp(1).Dexp(1).mutSpotIndx.wRFs;
- Exp(3).Dexp(1).mutSpotIndx.woRFs=Exp(1).Dexp(1).mutSpotIndx.woRFs;
- Exp(1).Dexp(1).RFmd1indx=[]; Exp(2).Dexp(1).RFmd1indx=[]; Exp(3).Dexp(1).RFmd1indx=[];
- Exp(1).Dexp(1).RFmd1pltN=[]; Exp(2).Dexp(1).RFmd1pltN=[]; Exp(3).Dexp(1).RFmd1pltN=[];
- Exp(1).Dexp(1).RFmean=[]; Exp(2).Dexp(1).RFmean=[]; Exp(3).Dexp(1).RFmean=[];
- Exp(1).Dexp(1).RFmeanG=[]; Exp(2).Dexp(1).RFmeanG=[]; Exp(3).Dexp(1).RFmeanG=[];
- if exist('RF1scanN','var')
- for d=0:(DMnum-1)
- medianIndx=[];
- nonZeroIndx=[];
- medValList=[];
- rf1scN=RF1scanN+d;
- try %if RF1scanN doesn't exist this addition to list will be skipped
- nonZeroIndx=find(Exp(expN).Dexp(1).scan(rf1scN).plate(1).CFout(1:384,5));
- if isempty(nonZeroIndx)
- nonZeroCnt=0
- medianIndx=nonZeroIndx;
- else
- nonZeroCnt=length(nonZeroIndx);
- end
- if ~isempty(nonZeroIndx) && mod(nonZeroCnt,2)==0, medianIndx=nonZeroIndx(1:nonZeroCnt-1); end
- if ~isempty(nonZeroIndx) && mod(nonZeroCnt,2)~=0, medianIndx=nonZeroIndx; end
- clear medValLst
- clear kValLst
- clear rValLst
- if ~isempty(nonZeroIndx) && length(medianIndx) > (.15*384) % To calc. a median, more than 15% of spots must be nonZero
- medValLst=Exp(expN).Dexp(1).scan(rf1scN).plate(1).CFout(medianIndx,5);
- medValList1{d+1}=medValLst;
- min1=min(medValLst);
- max1=max(medValLst);
- std1=std(medValLst);
- mean1=mean(medValLst)
- kValLst=Exp(expN).Dexp(1).scan(rf1scN).plate(1).CFout(medianIndx,3); % For Ref Composite 17_1009
- rValLst=Exp(expN).Dexp(1).scan(rf1scN).plate(1).CFout(medianIndx,4); % For Ref Composite 17_1009
- mval1=median(medValLst); % (Exp(expN).Dexp(1).scan(RF1scanN).plate(1).CFout(383,5));
- RFmd1pos=find(mval1==(Exp(expN).Dexp(1).scan(rf1scN).plate(1).CFout(1:384,5)))
- RFmd1loc(1)=ceil(RFmd1pos/24); %calc r value
- RFmd1loc(2)=RFmd1pos - ((RFmd1loc(1)-1)*24); %calc c value
- lstindx=lstindx+1;
- lstindxOrf=lstindxOrf+1;
- aa(lstindx,1)={strcat('RF1md(',num2str(d+1),')')};
- aa(lstindx,2)={strcat(':',num2str(RF1mp),':',num2str(RFmd1loc(1)),':',num2str(RFmd1loc(2)))}; %,' std',num2str(std1))};
- bb(lstindxOrf,1)={strcat('RF1md(',num2str(d+1),')')};
- bb(lstindxOrf,2)={strcat(':',num2str(RF1mp),':',num2str(RFmd1loc(1)),':',num2str(RFmd1loc(2)))}; %,' std',num2str(std1))};
- % Composite Reference Amalgum Plot
- lstindx=lstindx+1;
- lstindxOrf=lstindxOrf+1;
- aa(lstindx,1)={strcat('RF1cmp(',num2str(d+1),')')};
- aa(lstindx,2)={''};
- bb(lstindxOrf,1)={strcat('RF1cmp(',num2str(d+1),')')};
- bb(lstindxOrf,2)={''};
- Exp(1).Dexp(1).RFmd1LB(d+1)=strcat(aa(lstindx,1),aa(lstindx,2)); Exp(2).Dexp(1).RFmd1LB(d+1)=strcat(aa(lstindx,1),aa(lstindx,2)); Exp(3).Dexp(1).RFmd1LB(d+1)=strcat(aa(lstindx,1),aa(lstindx,2));
- Exp(1).Dexp(1).RFmd1indx(d+1)=RFmd1pos; Exp(2).Dexp(1).RFmd1indx(d+1)=RFmd1pos; Exp(3).Dexp(1).RFmd1indx(d+1)=RFmd1pos;
- Exp(1).Dexp(1).RFmd1pltN=RF1mp; Exp(2).Dexp(1).RFmd1pltN=RF1mp; Exp(3).Dexp(1).RFmd1pltN=RF1mp;
- Exp(1).Dexp(1).RFmd1val(d+1)=mval1; Exp(2).Dexp(1).RFmd1val(d+1)=mval1; Exp(3).Dexp(1).RFmd1val(d+1)=mval1;
- Exp(1).Dexp(1).mean1(d+1)=mean1; Exp(2).Dexp(1).mean1(d+1)=mean1; Exp(3).Dexp(1).mean1(d+1)=mean1;
- Exp(1).Dexp(1).std1(d+1)=std1; Exp(2).Dexp(1).std1(d+1)=std1; Exp(3).Dexp(1).std1(d+1)=std1;
- Exp(1).Dexp(1).min1(d+1)=min1; Exp(2).Dexp(1).min1(d+1)=min1; Exp(3).Dexp(1).min1(d+1)=min1;
- Exp(1).Dexp(1).max1(d+1)=max1; Exp(2).Dexp(1).max1(d+1)=max1; Exp(3).Dexp(1).max1(d+1)=max1;
- for ic=1:3
- Exp(ic).Dexp(1).RFcmpL(1).dm(d+1).Lvals=medValLst; %17_1201 TrendOL
- Exp(ic).Dexp(1).RFcmpL(1).dm(d+1).med=median(medValLst); %For Ref Composite 17_1009
- Exp(ic).Dexp(1).RFcmpL(1).dm(d+1).mean=mean(medValLst); %For Ref Composite 17_1009
- Exp(ic).Dexp(1).RFcmpL(1).dm(d+1).std=std(medValLst); %For Ref Composite 17_1009
- Exp(ic).Dexp(1).RFcmpL(1).dm(d+1).min=min(medValLst); %For Ref Composite 17_1009
- Exp(ic).Dexp(1).RFcmpL(1).dm(d+1).max=max(medValLst); %For Ref Composite 17_1009
- Exp(ic).Dexp(1).RFcmpK(1).dm(d+1).Kvals=kValLst; %17_1201 TrendOL
- Exp(ic).Dexp(1).RFcmpK(1).dm(d+1).mean=mean(kValLst); %For Ref Composite 17_1009
- Exp(ic).Dexp(1).RFcmpK(1).dm(d+1).med=median(kValLst); %For Ref Composite 17_1009
- Exp(ic).Dexp(1).RFcmpK(1).dm(d+1).std=std(kValLst); %For Ref Composite 17_1009
- Exp(ic).Dexp(1).RFcmpK(1).dm(d+1).min=min(kValLst); %For Ref Composite 17_1009
- Exp(ic).Dexp(1).RFcmpK(1).dm(d+1).max=max(kValLst); %For Ref Composite 17_1009
- Exp(ic).Dexp(1).RFcmpr(1).dm(d+1).rvals=rValLst; %17_1201 TrendOL
- Exp(ic).Dexp(1).RFcmpr(1).dm(d+1).med=median(rValLst); %For Ref Composite 17_1009
- Exp(ic).Dexp(1).RFcmpr(1).dm(d+1).mean=mean(rValLst); %For Ref Composite 17_1009
- Exp(ic).Dexp(1).RFcmpr(1).dm(d+1).std=std(rValLst); %For Ref Composite 17_1009
- Exp(ic).Dexp(1).RFcmpr(1).dm(d+1).min=min(rValLst); %For Ref Composite 17_1009
- Exp(ic).Dexp(1).RFcmpr(1).dm(d+1).mean=max(rValLst); %For Ref Composite 17_1009
- end
- else
- % Pick the first spot with zeros
- medianCalcFailed='To Few nonZero spots for valid median RF1 selection'
- firstZero=find(((Exp(expN).Dexp(1).scan(rf1scN).plate(1).CFout(1:384,5))==0),1,'first')
- Exp(1).Dexp(1).RFmd1indx(d+1)=firstZero; Exp(2).Dexp(1).RFmd1indx(d+1)=firstZero; Exp(3).Dexp(1).RFmd1indx(d+1)=firstZero;
- Exp(1).Dexp(1).RFmd1pltN=RF1mp; Exp(2).Dexp(1).RFmd1pltN=RF1mp; Exp(3).Dexp(1).RFmd1pltN=RF1mp; %EZdestComp uses the masterplate number to get all the destPlates scanNumbers
- try, medValList1{d+1}=Exp(expN).Dexp(1).scan(rf1scN).plate(1).CFout(medianIndx,5); nonZeroCnt; catch end
- end
- catch
- medianCalcTryFailed1='Failed! Failed! But process continued with bogus P1ind384 spot value!'
- try
- firstZero=find(((Exp(expN).Dexp(1).scan(rf1scN).plate(1).CFout(1:384,5))==0),1,'first')
- Exp(1).Dexp(1).RFmd1indx(d+1)=firstZero; Exp(2).Dexp(1).RFmd1indx(d+1)=firstZero; Exp(3).Dexp(1).RFmd1indx(d+1)=firstZero;
- catch
- Exp(1).Dexp(1).RFmd1indx(d+1)=384; Exp(2).Dexp(1).RFmd1indx(d+1)=384; Exp(3).Dexp(1).RFmd1indx(d+1)=384; %if crapout,Then use spot384 as default to keep going
- end
- try
- Exp(1).Dexp(1).RFmd1pltN=RF1mp; Exp(2).Dexp(1).RFmd1pltN=RF1mp; Exp(3).Dexp(1).RFmd1pltN=RF1mp;
- catch
- catchissue='Ln334'
- Exp(1).Dexp(1).RFmd1pltN=1; Exp(2).Dexp(1).RFmd1pltN=1; Exp(3).Dexp(1).RFmd1pltN=1;
- end
- end
- end
- end
- Exp(1).Dexp(1).RFmd2indx=[]; Exp(2).Dexp(1).RFmd2indx=[]; Exp(3).Dexp(1).RFmd2indx=[];
- Exp(1).Dexp(1).RFmd2pltN=[]; Exp(2).Dexp(1).RFmd2pltN=[]; Exp(3).Dexp(1).RFmd2pltN=[];
- if exist('RF2scanN','var')
- for d=0:(DMnum-1);
- medianIndx2=[];
- nonZeroIndx2=[];
- medValList2=[];
- rf2scN=RF2scanN+d;
- try % if RF2scanN doesn't exist this addition to list will be skipped
- nonZeroIndx2=find(Exp(expN).Dexp(1).scan(rf2scN).plate(1).CFout(1:384,5));
- if isempty(nonZeroIndx2)
- nonZeroCnt2=0
- medianIndx2=nonZeroIndx2;
- else
- nonZeroCnt2=length(nonZeroIndx2);
- end
- if ~isempty(nonZeroIndx2) && mod(nonZeroCnt2,2)==0, medianIndx2=nonZeroIndx2(1:nonZeroCnt2-1); end
- if ~isempty(nonZeroIndx2) && mod(nonZeroCnt2,2)~=0, medianIndx2=nonZeroIndx2; end
- clear medValLst2
- clear kValLst2
- clear rValLst2
- if ~isempty(nonZeroIndx2) && length(medianIndx2) > (.15*384) % to calc. a median, more than 15% of spots must be nonZero
- medValLst2=Exp(expN).Dexp(1).scan(rf2scN).plate(1).CFout(medianIndx2,5);
- medValList2{d+1}=medValLst2;
- min2=min(medValLst2);
- max2=max(medValLst2);
- std2=std(medValLst2)
- mean2=mean(medValLst2);
- kValLst2=Exp(expN).Dexp(1).scan(rf2scN).plate(1).CFout(medianIndx2,3); %For Ref Composite 17_1009
- rValLst2=Exp(expN).Dexp(1).scan(rf2scN).plate(1).CFout(medianIndx2,4); %For Ref Composite 17_1009
- mval2=median(medValLst2); %(Exp(expN).Dexp(1).scan(RF2scanN).plate(1).CFout(1:383,5));
- RFmd2pos=find(mval2==(Exp(expN).Dexp(1).scan(rf2scN).plate(1).CFout(1:384,5)));
- RFmd2loc(1)=ceil(RFmd2pos/24); %calc r value
- RFmd2loc(2)=RFmd2pos - ((RFmd2loc(1)-1)*24); %calc c value
- lstindx=lstindx+1;
- lstindxOrf=lstindxOrf+1;
- aa(lstindx,1)={strcat('RF2md(',num2str(d+1),')')}; %{'RF2md'};
- aa(lstindx,2)={strcat(':',num2str(RF2mp),':',num2str(RFmd2loc(1)),':',num2str(RFmd2loc(2)))}; %,' std~',num2str(std2))};
- bb(lstindxOrf,1)={strcat('RF2md(',num2str(d+1),')')}; %{'RF2md'};
- bb(lstindxOrf,2)={strcat(':',num2str(RF2mp),':',num2str(RFmd2loc(1)),':',num2str(RFmd2loc(2)))}; %,' std~',num2str(std2))};
- %Composite Reference Amalgum Plot (CRAP)
- lstindx=lstindx+1;
- lstindxOrf=lstindxOrf+1;
- aa(lstindx,1)={strcat('RF2cmp(',num2str(d+1),')')};
- aa(lstindx,2)={''};
- bb(lstindxOrf,1)={strcat('RF2cmp(',num2str(d+1),')')};
- bb(lstindxOrf,2)={''};
- Exp(1).Dexp(1).RFmd2LB(d+1)=strcat(aa(lstindx,1),aa(lstindx,2)); Exp(2).Dexp(1).RFmd2LB(d+1)=strcat(aa(lstindx,1),aa(lstindx,2)); Exp(3).Dexp(1).RFmd2LB(d+1)=strcat(aa(lstindx,1),aa(lstindx,2));
- Exp(1).Dexp(1).RFmd2indx(d+1)=RFmd2pos; Exp(2).Dexp(1).RFmd2indx(d+1)=RFmd2pos; Exp(3).Dexp(1).RFmd2indx(d+1)=RFmd2pos;
- Exp(1).Dexp(1).RFmd2pltN=RF2mp; Exp(2).Dexp(1).RFmd2pltN=RF2mp; Exp(3).Dexp(1).RFmd2pltN=RF2mp;
- Exp(1).Dexp(1).RFmd2val(d+1)=mval2; Exp(2).Dexp(1).RFmd2val(d+1)=mval2; Exp(3).Dexp(1).RFmd2val(d+1)=mval2;
- Exp(1).Dexp(1).mean2(d+1)=mean2; Exp(2).Dexp(1).mean2(d+1)=mean2; Exp(3).Dexp(1).mean2(d+1)=mean2;
- Exp(1).Dexp(1).std2(d+1)=std2; Exp(2).Dexp(1).std2(d+1)=std2; Exp(3).Dexp(1).std2(d+1)=std2;
- Exp(1).Dexp(1).min2(d+1)=min2; Exp(2).Dexp(1).min2(d+1)=min2; Exp(3).Dexp(1).min2(d+1)=min2;
- Exp(1).Dexp(1).max2(d+1)=max2; Exp(2).Dexp(1).max2(d+1)=max2; Exp(3).Dexp(1).max2(d+1)=max2;
- for ic=1:3
- Exp(ic).Dexp(1).RFcmpL(2).dm(d+1).Lvals=medValLst2; %17_1201 TrendOL
- Exp(ic).Dexp(1).RFcmpL(2).dm(d+1).med=median(medValLst2); %For Ref Composite 17_1009
- Exp(ic).Dexp(1).RFcmpL(2).dm(d+1).mean=mean(medValLst2); %For Ref Composite 17_1009
- Exp(ic).Dexp(1).RFcmpL(2).dm(d+1).std=std(medValLst2); %For Ref Composite 17_1009
- Exp(ic).Dexp(1).RFcmpL(2).dm(d+1).min=min(medValLst2); %For Ref Composite 17_1009
- Exp(ic).Dexp(1).RFcmpL(2).dm(d+1).max=max(medValLst2); %For Ref Composite 17_1009
- Exp(ic).Dexp(1).RFcmpK(2).dm(d+1).Kvals=kValLst2; %17_1201 TrendOL
- Exp(ic).Dexp(1).RFcmpK(2).dm(d+1).med=median(kValLst2); %For Ref Composite 17_1009
- Exp(ic).Dexp(1).RFcmpK(2).dm(d+1).mean=mean(kValLst2); %For Ref Composite 17_1009
- Exp(ic).Dexp(1).RFcmpK(2).dm(d+1).std=std(kValLst2); %For Ref Composite 17_1009
- Exp(ic).Dexp(1).RFcmpK(2).dm(d+1).min=min(kValLst2); %For Ref Composite 17_1009
- Exp(ic).Dexp(1).RFcmpK(2).dm(d+1).max=max(kValLst2); %For Ref Composite 17_1009
- Exp(ic).Dexp(1).RFcmpr(2).dm(d+1).rvals=rValLst2; %17_1201 TrendOL
- Exp(ic).Dexp(1).RFcmpr(2).dm(d+1).med=median(rValLst2); %For Ref Composite 17_1009
- Exp(ic).Dexp(1).RFcmpr(2).dm(d+1).mean=mean(rValLst2); %For Ref Composite 17_1009
- Exp(ic).Dexp(1).RFcmpr(2).dm(d+1).std=std(rValLst2); %For Ref Composite 17_1009
- Exp(ic).Dexp(1).RFcmpr(2).dm(d+1).min=min(rValLst2); %For Ref Composite 17_1009
- Exp(ic).Dexp(1).RFcmpr(2).dm(d+1).max=max(rValLst); %For Ref Composite 17_1009
- end
- else
- % Pick the first spot with zeros
- % Use that position to satisfy and keep process OK
- medianCalcFailed2='To Few nonZero spots for valid median RF2 selection'
- firstZero2=find(((Exp(expN).Dexp(1).scan(rf2scN).plate(1).CFout(1:384,5))==0),1,'first')
- Exp(1).Dexp(1).RFmd2indx(d+1)=firstZero2; Exp(2).Dexp(1).RFmd2indx(d+1)=firstZero2; Exp(3).Dexp(1).RFmd2indx(d+1)=firstZero2;
- Exp(1).Dexp(1).RFmd2pltN=RF2mp; Exp(2).Dexp(1).RFmd2pltN=RF2mp; Exp(3).Dexp(1).RFmd2pltN=RF2mp;
- try
- medValList2{d+1}=Exp(expN).Dexp(1).scan(rf2scN).plate(1).CFout(medianIndx2,5);
- nonZeroCnt2;
- catch
- end
- end
- catch
- medianCalcTryFailed2='Failed! Failed! No RF1median But process continued with bogus P1ind384 spot value!'
- try
- firstZero2=find(((Exp(expN).Dexp(1).scan(rf2scN).plate(1).CFout(1:384,5))==0),1,'first')
- Exp(1).Dexp(1).RFmd2indx(d+1)=firstZero2; Exp(2).Dexp(1).RFmd2indx(d+1)=firstZero2; Exp(3).Dexp(1).RFmd2indx(d+1)=firstZero2;
- catch
- Exp(1).Dexp(1).RFmd2indx(d+1)=384; Exp(2).Dexp(1).RFmd2indx(d+1)=384; Exp(3).Dexp(1).RFmd2indx(d+1)=384; %if crapout,Then use spot384 as default to keep going
- end
- try
- Exp(1).Dexp(1).RFmd2pltN=RF2mp; Exp(2).Dexp(1).RFmd2pltN=RF2mp; Exp(3).Dexp(1).RFmd2pltN=RF2mp;
- catch
- Exp(1).Dexp(1).RFmd2pltN=1; Exp(2).Dexp(1).RFmd2pltN=1; Exp(3).Dexp(1).RFmd2pltN=1;
- end
- end % if RF2scanN doesn't exist this addition to list will be skipped
- RFcombValList=cat(1,medValList1{d+1},medValList2{d+1});
- Exp(1).Dexp(1).RFmean(d+1)=mean(RFcombValList);Exp(2).Dexp(1).RFmean(d+1)=mean(RFcombValList);Exp(3).Dexp(1).RFmean(d+1)=mean(RFcombValList);
- Exp(1).Dexp(1).RFstd(d+1)=std(RFcombValList);Exp(2).Dexp(1).RFstd(d+1)=std(RFcombValList);Exp(3).Dexp(1).RFstd(d+1)=std(RFcombValList);
- Exp(1).Dexp(1).RFmin(d+1)=min(RFcombValList);Exp(2).Dexp(1).RFmin(d+1)=min(RFcombValList);Exp(3).Dexp(1).RFmin(d+1)=min(RFcombValList);
- Exp(1).Dexp(1).RFmax(d+1)=max(RFcombValList);Exp(2).Dexp(1).RFmax(d+1)=max(RFcombValList);Exp(3).Dexp(1).RFmax(d+1)=max(RFcombValList);
- % TODO can delete the following redundant line of code
- Exp(2).Dexp(1).RFmean(d+1)=Exp(1).Dexp(1).RFmean(d+1); Exp(3).Dexp(1).RFmean(d+1)=Exp(1).Dexp(1).RFmean(d+1);
- end
- elseif exist('RF1scanN','var')
- Exp(1).Dexp(1).RFmean=Exp(1).Dexp(1).mean1; Exp(2).Dexp(1).RFmean=Exp(2).Dexp(1).mean1; Exp(3).Dexp(1).RFmean=Exp(3).Dexp(1).mean1;
- Exp(1).Dexp(1).RFstd=Exp(1).Dexp(1).std1; Exp(2).Dexp(1).RFstd=Exp(2).Dexp(1).std1; Exp(3).Dexp(1).RFstd=Exp(3).Dexp(1).std1;
- Exp(1).Dexp(1).RFmin=Exp(1).Dexp(1).min1; Exp(2).Dexp(1).RFmin=Exp(2).Dexp(1).min1; Exp(3).Dexp(1).RFmin=Exp(3).Dexp(1).min1;
- Exp(1).Dexp(1).RFmax=Exp(1).Dexp(1).max1; Exp(2).Dexp(1).RFmax=Exp(2).Dexp(1).max1; Exp(3).Dexp(1).RFmax=Exp(3).Dexp(1).max1;
- end
- % DISPERSE REFERENCE PLATES
- Exp(expN).Dexp(1).RFmdPindx=[];
- Exp(expN).Dexp(1).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:length(dMPs)
- 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));
- vv(chgIndx(mm):(chgIndx(mm+1)-1),d)=Exp(expN).Dexp(1).scan(rf1scNdisp).plate(1).CFout(NZrefIndxP,5);
- % For Global Ref Composite 17_1009
- vvK(chgIndx(mm):(chgIndx(mm+1)-1),d)=Exp(expN).Dexp(1).scan(rf1scNdisp).plate(1).CFout(NZrefIndxP,3);
- vvr(chgIndx(mm):(chgIndx(mm+1)-1),d)=Exp(expN).Dexp(1).scan(rf1scNdisp).plate(1).CFout(NZrefIndxP,4);
- nonZeroValsP=nonzeros(Exp(expN).Dexp(1).scan(rf1scNdisp).plate(1).CFout(NZrefIndxP,5));
- minDisp=min(nonZeroValsP);
- maxDisp=max(nonZeroValsP);
- std1Disp=std(nonZeroValsP);
- mean1Disp=mean(nonZeroValsP);
- drfVals=Exp(expN).Dexp(1).scan(rf1scNdisp).plate(1).CFout(NZrefIndxP,5);
- %MEDIAN Determination for PLATES with Dispersed RFs
- 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(1).scan(rf1scNdisp).plate(1).CFout(medianIndxDisp,5);
- mval1Disp=median(medValLstDisp);
- nonZeroMedPosIndx=find(mval1Disp==nonZeroValsP);
- RFmd1posD=NZrefIndxP(nonZeroMedPosIndx);
- 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),')')}; %{'RF1md'};
- aa(lstindx,2)={strcat(':',num2str(dMPs(mm)),':',num2str(RFmd1locD(1)),':',num2str(RFmd1locD(2)))}; %,'std_',num2str(std1))};
- bb(lstindxOrf,1)={strcat('RF1mdP(',num2str(d),')')}; %{'RF1md'};
- bb(lstindxOrf,2)={strcat(':',num2str(dMPs(mm)),':',num2str(RFmd1locD(1)),':',num2str(RFmd1locD(2)))}; %,'std_',num2str(std1))};
- Exp(1).Dexp(1).RFmdPLB(d,dMPs(mm))=strcat(aa(lstindx,1),aa(lstindx,2)); Exp(2).Dexp(1).RFmdPLB(d,dMPs(mm))=strcat(aa(lstindx,1),aa(lstindx,2)); Exp(3).Dexp(1).RFmdPLB(d,dMPs(mm))=strcat(aa(lstindx,1),aa(lstindx,2));
- Exp(1).Dexp(1).RFmdPindx(d,dMPs(mm))=RFmd1posD; Exp(2).Dexp(1).RFmdPindx(d,dMPs(mm))=RFmd1posD; Exp(3).Dexp(1).RFmdPindx(d,dMPs(mm))=RFmd1posD;
- Exp(1).Dexp(1).RFmdPpltN(d,dMPs(mm))=dMPs(mm); Exp(2).Dexp(1).RFmdPpltN(d,dMPs(mm))=dMPs(mm); Exp(3).Dexp(1).RFmdPpltN(d,dMPs(mm))=dMPs(mm);
- Exp(1).Dexp(1).RFmedianP(d,dMPs(mm))=mval1Disp; Exp(2).Dexp(1).RFmedianP(d,dMPs(mm))=mval1Disp; Exp(3).Dexp(1).RFmedianP(d,dMPs(mm))=mval1Disp;
- Exp(1).Dexp(1).meanP(d,dMPs(mm))=mean1Disp; Exp(2).Dexp(1).meanP(d,dMPs(mm))=mean1Disp; Exp(3).Dexp(1).meanP(d,dMPs(mm))=mean1Disp;
- Exp(1).Dexp(1).stdP(d,dMPs(mm))=std1Disp; Exp(2).Dexp(1).stdP(d,dMPs(mm))=std1Disp; Exp(3).Dexp(1).stdP(d,dMPs(mm))=std1Disp;
- Exp(1).Dexp(1).minP(d,dMPs(mm))=minDisp; Exp(2).Dexp(1).minP(d,dMPs(mm))=minDisp; Exp(3).Dexp(1).minP(d,dMPs(mm))=minDisp;
- Exp(1).Dexp(1).maxP(d,dMPs(mm))=maxDisp; Exp(2).Dexp(1).maxP(d,dMPs(mm))=maxDisp; Exp(3).Dexp(1).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(1).scan(rf1scNdisp).plate(1).CFout(NZrefIndxP,5))==0),1,'first');
- firstZeroD=drfPindx((firstZeroDindx),dMPs(mm));
- Exp(expN).Dexp(1).RFmdPindx(d,dMPs(mm))=firstZeroD;
- Exp(expN).Dexp(1).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(1).RFmdPpltN(d,dMPs(mm))=dMPs(mm);
- Exp(expN).Dexp(1).RFmdPindx(d,dMPs(mm))=firstZeroPindx;
- catch
- catchissue='try at Ln565'
- Exp(expN).Dexp(1).RFmdPpltN(d,dMPs(mm))=dMPs(mm);
- Exp(expN).Dexp(1).RFmdPindx(d,dMPs(mm))=384; % if crapout,Then use spot384 as default to keep going
- end
- try
- Exp(expN).Dexp(1).RFmdPpltN=dMPs(mm);
- catch
- catchissue='Ln'
- Exp(expN).Dexp(1).RFmdPpltN=1; %This might keep from breaking BUT ???
- end
- end
- end
- end
- % Calc. Global Mean, Std, And Median For Distributed References
- uu=horzcat(uu,vv);
- for d=1:DMnum
- medianIndxD=[];
- NZrfIndxG=[];
- minG=min(nonzeros(vv(:,d)));
- maxG=max(nonzeros(vv(:,d)));
- RFmeanG=mean(nonzeros(vv(:,d)));
- RFstdG=std(nonzeros(vv(:,d)));
- NZrfIndxG=find(vv(:,d)); % find(nonzeros(vv(:,d))); WWRONG FOR A WHILE! find(nonzeros(vv(:,d)));
- if isempty(RFmeanG)
- nonZeroCntD=0;
- 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))};
- % Composite Reference Amalgum Plot
- lstindx=lstindx+1;
- lstindxOrf=lstindxOrf+1;
- aa(lstindx,1)={strcat('RFcmpG(',num2str(d),')')};
- aa(lstindx,2)={''};
- bb(lstindxOrf,1)={strcat('RFcmpG(',num2str(d),')')};
- bb(lstindxOrf,2)={''};
- Exp(1).Dexp(1).RFmdGLB(d)=strcat(aa(lstindx,1),aa(lstindx,2)); Exp(2).Dexp(1).RFmdGLB(d)=strcat(aa(lstindx,1),aa(lstindx,2)); Exp(3).Dexp(1).RFmdGLB(d)=strcat(aa(lstindx,1),aa(lstindx,2));
- Exp(1).Dexp(1).RFmdGindx(d)=nzPosIndxDG; Exp(2).Dexp(1).RFmdGindx(d)=nzPosIndxDG; Exp(3).Dexp(1).RFmdGindx(d)=nzPosIndxDG;
- Exp(1).Dexp(1).RFmdGpltN(d)=RFmdDGloc(d,1); Exp(2).Dexp(1).RFmdGpltN(d)=RFmdDGloc(d,1); Exp(3).Dexp(1).RFmdGpltN(d)=RFmdDGloc(d,1);
- Exp(1).Dexp(1).RFmdGscanN(d)=uu(nzPosIndxDG,4); Exp(2).Dexp(1).RFmdGscanN(d)=uu(nzPosIndxDG,4); Exp(3).Dexp(1).RFmdGscanN(d)=uu(nzPosIndxDG,4);
- Exp(1).Dexp(1).RFmedianG(d)=mvalsDG; Exp(2).Dexp(1).RFmedianG(d)=mvalsDG; Exp(3).Dexp(1).RFmedianG(d)=mvalsDG;
- Exp(1).Dexp(1).RFmeanG(d)=RFmeanG; Exp(2).Dexp(1).RFmeanG(d)=RFmeanG; Exp(3).Dexp(1).RFmeanG(d)=RFmeanG;
- Exp(1).Dexp(1).RFstdG(d)=RFstdG; Exp(2).Dexp(1).RFstdG(d)=RFstdG; Exp(3).Dexp(1).RFstdG(d)=RFstdG;
- Exp(1).Dexp(1).RFminG(d)=minG; Exp(2).Dexp(1).RFminG(d)=minG; Exp(3).Dexp(1).RFminG(d)=minG;
- Exp(1).Dexp(1).RFmaxG(d)=maxG; Exp(2).Dexp(1).RFmaxG(d)=maxG; Exp(3).Dexp(1).RFmaxG(d)=maxG;
- for ic=1:3
- Exp(ic).Dexp(1).RFcmpGL.dm(d).Lvals=vv(medianIndxD,d); %17_1201 TrendOL
- Exp(ic).Dexp(1).RFcmpGL.dm(d).med=median(vv(medianIndxD,d)); %For Ref Composite 17_1009
- Exp(ic).Dexp(1).RFcmpGL.dm(d).mean=mean(vv(medianIndxD,d)); %For Ref Composite 17_1009
- Exp(ic).Dexp(1).RFcmpGL.dm(d).std=std(vv(medianIndxD,d)); %For Ref Composite 17_1009
- Exp(ic).Dexp(1).RFcmpGL.dm(d).min=min(vv(medianIndxD,d)); %For Ref Composite 17_1009
- Exp(ic).Dexp(1).RFcmpGL.dm(d).max=max(vv(medianIndxD,d)); %For Ref Composite 17_1009
- Exp(ic).Dexp(1).RFcmpGK.dm(d).Kvals=vvK(medianIndxD,d); %17_1201 TrendOL
- Exp(ic).Dexp(1).RFcmpGK.dm(d).med=median(vvK(medianIndxD,d)); %For Ref Composite 17_1009
- Exp(ic).Dexp(1).RFcmpGK.dm(d).mean=mean(vvK(medianIndxD,d)); %For Ref Composite 17_1009
- Exp(ic).Dexp(1).RFcmpGK.dm(d).std=std(vvK(medianIndxD,d)); %For Ref Composite 17_1009
- Exp(ic).Dexp(1).RFcmpGK.dm(d).min=min(vvK(medianIndxD,d)); %For Ref Composite 17_1009
- Exp(ic).Dexp(1).RFcmpGK.dm(d).max=max(vvK(medianIndxD,d)); %For Ref Composite 17_1009
- Exp(ic).Dexp(1).RFcmpGr.dm(d).rvals=vvr(medianIndxD,d); %17_1201 TrendOL
- Exp(ic).Dexp(1).RFcmpGr.dm(d).med=median(vvr(medianIndxD,d)); %For Ref Composite 17_1009
- Exp(ic).Dexp(1).RFcmpGr.dm(d).mean=mean(vvr(medianIndxD,d)); %For Ref Composite 17_1009
- Exp(ic).Dexp(1).RFcmpGr.dm(d).std=std(vvr(medianIndxD,d)); %For Ref Composite 17_1009
- Exp(ic).Dexp(1).RFcmpGr.dm(d).min=min(vvr(medianIndxD,d)); %For Ref Composite 17_1009
- Exp(ic).Dexp(1).RFcmpGr.dm(d).max=max(vvr(medianIndxD,d)); %For Ref Composite 17_1009
- end
- end
- end
- end
- % End Of Disperse Reference Plataes Calculations And List Additions
- % Sort And Build Genelist
- Exp(1).Dexp(1).srtGnLst={('CheckMP/MPDMfile')};
- gnLstRaw=strcat(aa(:,1),aa(:,2));
- Exp(1).Dexp(1).srtGnLst=sort(gnLstRaw);
- Exp(2).Dexp(1).srtGnLst=Exp(1).Dexp(1).srtGnLst;
- Exp(3).Dexp(1).srtGnLst=Exp(1).Dexp(1).srtGnLst;
- orfLstRaw=strcat(bb(:,1),bb(:,2));
- Exp(1).Dexp(1).srtOrfLst=sort(orfLstRaw);
- Exp(2).Dexp(1).srtOrfLst=Exp(1).Dexp(1).srtOrfLst;
- Exp(3).Dexp(1).srtOrfLst=Exp(1).Dexp(1).srtOrfLst;
- set(handles.listboxGnOrf,'string',Exp(1).Dexp(1).srtGnLst)
- catch ME %Outer loop try around entire code subroutine
- cd(w)
- set(handles.listboxGnOrf,'string',cellstr([{'Failed To Load'}; {'Check MPDMmat file'};{'Check .xls files'};{'Check \Fotos .mat files'};{'Check \matResults file'}]))
- %Exp(expN).Dexp(1).srtGnLst={('Failed To Load')};
- Exp(1).Dexp(1).srtGnLst=cellstr([{'Failed To Load'}; {' '}]);
- Exp(2).Dexp(1).srtGnLst=cellstr([{'Failed To Load'}; {' '}]);
- Exp(3).Dexp(1).srtGnLst=cellstr([{'Failed To Load'}; {' '}]);
- %Exp(expN).srtOrfLst={('Failed To Load')};
- Exp(1).Dexp(1).srtOrfLst=cellstr([{'Failed To Load'}; {' '}]);
- Exp(2).Dexp(1).srtOrfLst=cellstr([{'Failed To Load'}; {' '}]);
- Exp(3).Dexp(1).srtOrfLst=cellstr([{'Failed To Load'}; {' '}]);
- if ~contains(matFile,'.mat')
- ExpOutImFile=fullfile(matFile);
- EZvImagesOnly
- end
- end
- expN=1; % Fix 170424
- DexpN=1;
- EZdiagRFsSheet
- Exp(1).Dexp(1).RFrnames=rnames; Exp(2).Dexp(1).RFrnames=rnames; Exp(3).Dexp(1).RFrnames=rnames;
- Exp(1).Dexp(1).RFdata=data; Exp(2).Dexp(1).RFdata=data; Exp(3).Dexp(1).RFdata=data;
- RFconfig=0;
- if sum(ismember(fieldnames(Exp(expN).Dexp(1)),'RFmean')) ...
- && ~isempty(Exp(expN).Dexp(1).RFmean) ...
- && sum(ismember(fieldnames(Exp(expN).Dexp(1)),'RFmeanG')) ...
- && isempty(Exp(expN).Dexp(1).RFmeanG)
- RFconfig=1;
- end
- if sum(ismember(fieldnames(Exp(expN).Dexp(1)),'RFmean'))==0 ...
- || isempty(Exp(expN).Dexp(1).RFmean) ...
- && sum(ismember(fieldnames(Exp(expN).Dexp(1)),'RFmeanG')) ...
- && ~isempty(Exp(expN).Dexp(1).RFmeanG)
- RFconfig=2;
- end
- if sum(ismember(fieldnames(Exp(expN).Dexp(1)),'RFmean')) ...
- && ~isempty(Exp(expN).Dexp(1).RFmean) ...
- && sum(ismember(fieldnames(Exp(expN).Dexp(1)),'RFmeanG')) ...
- && ~isempty(Exp(expN).Dexp(1).RFmeanG)
- RFconfig=3;
- end
- Exp(1).RFconfig=RFconfig; Exp(2).RFconfig=RFconfig; Exp(3).RFconfig=RFconfig; % ZoneRelated
- try
- msgBadGeneName
- catch
- end
- try
- Exp(1).Dexp(1).resetHtmpTg=3; Exp(2).Dexp(1).resetHtmpTg=3; Exp(3).Dexp(1).resetHtmpTg=3; % ZoneRelated
- if RFconfig==0
- RFconfigMsg='No RF1 references in this Experiment Job'
- Exp(1).resetHtmpTg=3; Exp(2).resetHtmpTg=3; Exp(3).resetHtmpTg=3; % ZoneRelated
- end
- catch
- end
- prntHt=0;
- % HtMapTog 'string', 'Current user HL/HN' selection'
- try
- Exp(1).htmapPBsel=0;
- set(handles.HtMapTog1,'string','L')
- Exp(2).htmapPBsel=0; %ZoneRelated
- set(handles.HtMapTog2,'string','L')
- Exp(3).htmapPBsel=0;
- set(handles.HtMapTog3,'string','L')
- catch
- % expN=1;
- end
- for ic=1:3
- Expaa{ic,1}=aa;
- Expbb{ic,1}=bb;
- end
- htMapTogPBfg=0;
- Exp(1).htmapRFanswer={'G','L'}; % ZoneRelated
- Exp(2).htmapRFanswer={'G','L'};
- Exp(3).htmapRFanswer={'G','L'};
- zonePB=expN; % added 230828 to fix migration
- ghandles=handles;
- ghandles.guiFig=gcf;
- Exp(4).guiFig=gcf;
|