EZmDayPlotUcomposite.m 29 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590
  1. % User find and build composite of Selected Gene Composite and
  2. % Plot it on OLay Plot and Trend plot DNLaxles
  3. % For Chonological Studies (multi Day Studies)
  4. % Called when Composite_ toggle button is clicked.
  5. % Data stored for printable Trend Plot production (click [L] in DNLaxes )
  6. global ghandles
  7. global Exp
  8. global exDlst
  9. global exFolder
  10. tracN=Exp(expN).traceN;
  11. n=Exp(expN).DexpN; % Temp input for development
  12. % UmDayaa=cell(3,n); UmDaybb=cell(3,n);
  13. patrnN=strfind(selGnOrf{1},':'); % Extract Gene-Orf Name
  14. selStrNm=char(selGnOrf)
  15. usrGene=selStrNm(1:(patrnN(1)-1))
  16. prompt={'Enter Specifics Term if used to futher specify selection '}
  17. dlg_title='User Specifics Term for Refinement Composite';
  18. num_lines=1;
  19. def={'None'};
  20. answer=inputdlg(prompt,dlg_title,num_lines,def);
  21. % usrGene=cell2mat(answer(1));
  22. usrSpec=answer(1);
  23. usrGnSp=strcat(usrGene,usrSpec);
  24. if strcmpi(usrSpec,'None'), usrGnSp={strcat(usrGene,'-')}; end
  25. % if strfind(Exp(expN).UgeneSpLst,usrGnSp), break; end
  26. Exp(expN).Dexp(n).UsrmdPLB={[]};
  27. Exp(expN).Dexp(n).UsrMedianG=[];
  28. Exp(expN).Dexp(n).UsrminG=[];
  29. Exp(expN).Dexp(n).UsrmaxG=[];
  30. Exp(expN).Dexp(n).UsrstdG=[];
  31. Exp(expN).Dexp(n).UsrmeanG=[];
  32. Exp(expN).Dexp(n).UsrCmpGL=[]; % For Ref Composite 17_1026
  33. Exp(expN).Dexp(n).UsrCmpGK=[]; % For Ref Composite 17_1026
  34. Exp(expN).Dexp(n).UsrCmpGr=[]; % For Ref Composite 17_1026
  35. Exp(expN).Dexp(n).UsrGLB={};
  36. for n=1:Exp(expN).DexpLength % Loop Thru Dayexps
  37. MPnum=length(Exp(expN).Dexp(n).MP);
  38. DMnum=length(Exp(expN).Dexp(n).DM.drug);
  39. tPtsSize=size(Exp(expN).Dexp(n).FexpScanBMtp{1,1},(3));
  40. % lstindx=size(aa,1);
  41. % lstindxOrf=size(bb,1);
  42. spN=0;
  43. rfcnt=0;
  44. dRF1indx=0;
  45. % usrGene=cell2mat(usrGene); %user entry of Specifics for Ref selection
  46. usrSp=cell2mat(usrSpec); %user entry of Specifics for Ref selection
  47. for mp=1:length(Exp(expN).Dexp(n).MP)
  48. % RF1fullPlate=0;
  49. for ind384=1:384
  50. spN=spN+1;
  51. try
  52. r=ceil(ind384/24);
  53. if rem(ind384,24)==0, c=24; else c=rem(ind384,24); end
  54. % Insert test for numeric in genename and orf if isnumeric
  55. % Correct common EXCEL problem of converting OCT1 into a date numeric
  56. if cell2mat(Exp(expN).Dexp(n).MP(mp).genename{1}(ind384))==38991
  57. Exp(expN).Dexp(n).MP(mp).genename{1}(ind384)={'OCT1_'};
  58. elseif isnumeric(cell2mat(Exp(expN).Dexp(n).MP(mp).genename{1}(ind384)))
  59. Exp(expN).Dexp(n).MP(mp).genename{1}(ind384)={' '};
  60. end
  61. % DISPersed REFerence capture and find Medians
  62. if ( ((strcmpi((Exp(expN).Dexp(n).MP(mp).genename{1}(ind384)),usrGene) ...
  63. && strcmpi((Exp(expN).Dexp(n).MP(mp).specifics{1}(ind384)),usrSp))) ...
  64. || ((strcmpi((Exp(expN).Dexp(n).MP(mp).genename{1}(ind384)),usrGene) ...
  65. && strcmpi(usrSp,'None'))) )
  66. dRF1indx=dRF1indx+1;
  67. Exp(expN).Dexp(n).MP(mp).genename{1}(ind384)=strrep((Exp(expN).Dexp(n).MP(mp).genename{1}(ind384)),':',' ');
  68. drf(dRF1indx,1)=(Exp(expN).Dexp(n).MP(mp).genename{1}(ind384));
  69. drf(dRF1indx,2)={strcat(':',num2str(mp),':',num2str(r),':',num2str(c))};
  70. drf(dRF1indx,3)={mp}; drfMP(dRF1indx,mp)=mp;
  71. drf(dRF1indx,4)={r}; drfr(dRF1indx,mp)=r;
  72. drf(dRF1indx,5)={c}; drfc(dRF1indx,mp)=c;
  73. drf(dRF1indx,6)={ind384}; drfPindx(dRF1indx,mp)=ind384;
  74. %drf(dRF1indx,7)=(Exp(expN).Dexp(n).MP(mp).specifics{1}(ind384));
  75. end
  76. catch
  77. error='EZexpSel lineAfter 24 EZmultiGeneLst.m'
  78. mp %Disable in future to prevent a bomb out OR put into a nested TryCatch
  79. ind384 %Disable in future to prevent a bomb out OR put into a nested TryCatch
  80. msgBadGeneName=strcat('check genename at mp=',num2str(mp),' indx=',num2str(ind384))
  81. end
  82. end
  83. mp
  84. end
  85. % Exp(expN).Dexp(n).UsrmdPindx=[];
  86. % Exp(expN).Dexp(n).UsrmdPpltN=[];
  87. if exist('drf','var')
  88. % Det. index of change from one MP to the next
  89. i=2;
  90. clear chgIndx
  91. chgIndx(1)=1;
  92. for j=1:length(drf(:,3))
  93. if j>1
  94. if cell2mat(drf(j,3))~=cell2mat(drf((j-1),3)), chgIndx(i)=j; i=i+1; end
  95. end
  96. end
  97. chgIndx(length(chgIndx)+1)=length(drf)+1;
  98. uu=zeros(size(drf,1),4);
  99. uu(:,1:4)=cell2mat(drf(:,3:6));
  100. vv=zeros(length(drf),1 ); % DMnum);
  101. dMPs=unique(cell2mat(drf(:,3)));
  102. for mm=1:length(dMPs) % length(chgIndx)
  103. usrScNdisp=((dMPs(mm)-1)*DMnum)+(dmSel);
  104. NZrefIndxP=drfPindx((find(drfPindx(:,dMPs(mm)))),dMPs(mm)); medianIndxDisp=NZrefIndxP;
  105. vv(chgIndx(mm):(chgIndx(mm+1)-1),dmSel)=Exp(expN).Dexp(n).scan(usrScNdisp).plate(1).CFout(NZrefIndxP,5);
  106. % For Global Ref Composite 17_1009
  107. vvK(chgIndx(mm):(chgIndx(mm+1)-1),dmSel)=Exp(expN).Dexp(n).scan(usrScNdisp).plate(1).CFout(NZrefIndxP,3);
  108. vvr(chgIndx(mm):(chgIndx(mm+1)-1),dmSel)=Exp(expN).Dexp(n).scan(usrScNdisp).plate(1).CFout(NZrefIndxP,4);
  109. end % for mm=1:length(dMPs)
  110. % Calc. Global Mean, Std, And Median For Distributed References
  111. uu=horzcat(uu,vv);
  112. for d=dmSel:dmSel
  113. medianIndxG=[];
  114. NZusrIndxG=[];
  115. minG=min(nonzeros(vv(:,d)));
  116. maxG=max(nonzeros(vv(:,d)));
  117. usrmeanG=mean(nonzeros(vv(:,d)));
  118. usrStdG=std(nonzeros(vv(:,d)));
  119. NZusrIndxG=find(vv(:,d));
  120. if isempty(usrmeanG)
  121. nonZeroCntD=0 % medianIndxDisp=RFmeanG(d);
  122. else
  123. nonZeroCntD=length(nonzeros(vv(:,d)));
  124. end
  125. % Calc. of median value for composite doesn't require and odd number of Indx items
  126. medianIndxG=NZusrIndxG(:);
  127. if ~isempty(NZusrIndxG) && length(medianIndxG) > 0 %(.15*size(drf,1)) %To calc. a median, more than 15% of spots must be nonZero
  128. Exp(expN).Dexp(n).UsrGLB(d)=usrGnSp; % strcat(aa(lstindx,1),aa(lstindx,2));
  129. Exp(expN).Dexp(n).UsrLvals=vv(medianIndxG);
  130. Exp(expN).Dexp(n).UsrKvals=vvK(medianIndxG);
  131. Exp(expN).Dexp(n).Usrrvals=vvr(medianIndxG);
  132. end
  133. end
  134. end
  135. end
  136. Exp(expN).UgeneCnt=Exp(expN).UgeneCnt +1;
  137. Exp(expN).UgeneSpLst(Exp(expN).UgeneCnt)=usrGnSp;
  138. % PLOT Values Selected Gene-Specifics Composite
  139. smpSz=size(medianIndxG,1);
  140. K=median(vvK(medianIndxG,dmSel)); Ks=num2str(K); Kstd=std(vvK(medianIndxG,dmSel)); KstdStr=num2str(Kstd);
  141. r=median(vvr(medianIndxG,dmSel)); rs=num2str(r); rstd=std(vvr(medianIndxG,dmSel)); rstdStr=num2str(rstd);
  142. l=median(vv(medianIndxG,dmSel)); Ls=num2str(l); Lstd=std(vv(medianIndxG,dmSel)); LstdStr=num2str(Lstd);
  143. Kl=K - std(vvK(medianIndxG,dmSel)); %K - Exp(expN).Dexp(DexpN).RFcmpK(RFnum).dm(inDM).std;
  144. Ku=K + std(vvK(medianIndxG,dmSel)); %K + Exp(expN).Dexp(DexpN).RFcmpK(RFnum).dm(inDM).std;
  145. rl=r - std(vvr(medianIndxG,dmSel)); %r - Exp(expN).Dexp(DexpN).RFcmpr(RFnum).dm(inDM).std;
  146. ru=r + std(vvr(medianIndxG,dmSel)); %r + Exp(expN).Dexp(DexpN).RFcmpr(RFnum).dm(inDM).std;
  147. lfast=l - std(vv(medianIndxG,dmSel)); %l - Exp(expN).Dexp(DexpN).RFcmpL(RFnum).dm(inDM).std;
  148. lslow=l + std(vv(medianIndxG,dmSel)); %l + Exp(expN).Dexp(DexpN).RFcmpL(RFnum).dm(inDM).std;
  149. try Kstr=Ks(1:5); catch, Kstr=Ks(1:length(Ks)); end
  150. try rstr=rs(1:5); catch, rstr=rs(1:length(rs)); end
  151. try Lstr=Ls(1:5); catch, Lstr=Ls(1:length(Ls)); end
  152. pertSel=Exp(zoneSel).Dexp(DexpN).pertSel; %floor(get(handles.DMsldr1,'value'));
  153. plateNum=(LBmp-1)*destPerMP + pertSel;
  154. indx=((LBr-1)*24) +LBc
  155. MP=Exp(zoneSel).Dexp(DexpN).MP;
  156. try
  157. t=1:200;
  158. clear g;
  159. try
  160. g=K ./ (1 + exp(-r.* (t - l )));
  161. gSlow=Kl ./ (1 + exp(-rl.* (t - lslow )));
  162. gFast=Ku ./ (1 + exp(-ru.* (t - lfast )));
  163. if K==0||r==0||l==0, g(1:200)=1;gSlow(1:200)=1;gFast(1:200)=1;end
  164. if zoneSel==1, plotAxes=ghandles.Paxes1; OLaxes=ghandles.OLaxes1;
  165. Dlaxes=ghandles.Dlaxes1;Dkaxes=ghandles.Dkaxes1;Draxes=ghandles.Draxes1;
  166. Exp(1).traceN=Exp(1).traceN+1;
  167. traceN=Exp(1).traceN;
  168. end
  169. if zoneSel==2, plotAxes=ghandles.Paxes2; OLaxes=ghandles.OLaxes2;Daxes=ghandles.Daxes2;
  170. Dlaxes=ghandles.Dlaxes2;Dkaxes=ghandles.Dkaxes2;Draxes=ghandles.Draxes2;
  171. Exp(2).traceN=Exp(2).traceN+1;
  172. traceN=Exp(2).traceN;
  173. end
  174. if zoneSel==3, plotAxes=ghandles.Paxes3; OLaxes=ghandles.OLaxes3;Daxes=ghandles.Daxes3;
  175. Dlaxes=ghandles.Dlaxes3;Dkaxes=ghandles.Dkaxes3;Draxes=ghandles.Draxes3;
  176. Exp(3).traceN=Exp(3).traceN+1;
  177. traceN=Exp(3).traceN;
  178. end
  179. plot(plotAxes,t,g);hold (plotAxes,'on');
  180. plot(plotAxes,t,gSlow,'y');plot(plotAxes,t,gFast,'r');hold (plotAxes,'off');
  181. % Store L R and K valves for Composite [C] plots
  182. Exp(expN).ll(traceN)=l; Exp(expN).rr(traceN)=r; Exp(expN).kk(traceN)=K;
  183. Exp(expN).lslow(traceN)=lslow; Exp(expN).lfast(traceN)=lfast;
  184. try
  185. for i=1:length(Exp(zoneSel).hOL(:))
  186. set(Exp(zoneSel).hOL(i),'color',[0 0 1]);
  187. end
  188. catch
  189. end
  190. Exp(zoneSel).hOL(traceN)=plot(OLaxes,t,g);hold on;
  191. set(Exp(zoneSel).hOL(traceN),'color',[1 0 0])
  192. catch
  193. catchissue='Ln100 EZlstBoxExt'
  194. end
  195. % Get the DM agar description
  196. if expN==1,DMstr=char(get(handles.DM1,'string'));end
  197. if expN==2,DMstr=char(get(handles.DM2,'string'));end
  198. if expN==3,DMstr=char(get(handles.DM3,'string'));end
  199. gene=usrGnSp; orf='' % MP(1,LBmp).orf{1,1}(indx);
  200. geneOrfstr=strcat(gene,'_',orf,'_');
  201. grfgenestr=strcat(gene,'_',orf,'_');
  202. % spec=MP(1,LBmp).specifics{1,1}(indx); %orfrep=MP(1,plateNum).orfRep{1,1}(indx);
  203. % tPtStr=strcat('T=', num2str(scan(1,plateNum).plate(1).t0Series(tPtSel)));
  204. % graphStr=strcat(grfgenestr,'_','L=',Lstr,'_','r=',rstr,'_','K=',Kstr);
  205. graphStr=strcat(usrGnSp,'_','L=',Lstr,'_','Ls=',LstdStr,'_','r=',rstr,'_','rs=',rstdStr,'_','K=',Kstr,'Ks=',KstdStr);
  206. spotDescrip=strcat(graphStr,'->',DMstr);
  207. xp=char(Exp(zoneSel).Dexp(DexpN).resDir);
  208. if ispc,
  209. slashPos=strfind(char(Exp(zoneSel).Dexp(DexpN).resDir),'\');
  210. else
  211. slashPos=strfind(char(Exp(zoneSel).Dexp(DexpN).resDir),'/');
  212. end
  213. startPos=slashPos(length(slashPos)-1) +1;
  214. endPos=slashPos(length(slashPos)) -1
  215. expStr={xp(startPos:endPos)}
  216. Exp(zoneSel).hOLname(traceN)=spotDescrip; %graphStr; %ghandles.Exp(zoneSel).hOLname(traceN)=graphStr;
  217. Exp(zoneSel).hOLexpNm(traceN)=expStr; %ghandles.Exp(expN).hOLexpNm(traceN)=expStr;
  218. Exp(zoneSel).hOLresDir(traceN)={Exp(zoneSel).Dexp(DexpN).resDir};
  219. Exp(zoneSel).hOLplateNum(traceN)=plateNum;
  220. % traceData=vertcat(get(Exp(OLay).hOL(traceN),'XData'),get(ghandles.Exp(OLay).hOL(traceN),'YData'));
  221. if zoneSel==1,set(ghandles.GeneOrfLoc1,'string',geneOrfstr);end % Displays the value.
  222. if zoneSel==2,set(ghandles.GeneOrfLoc2,'string',geneOrfstr);end
  223. if zoneSel==3,set(ghandles.GeneOrfLoc3,'string',geneOrfstr);end
  224. if zoneSel==1,set(ghandles.graphStrLoc1,'string',spotDescrip);end %graphStr);end % Displays the value.
  225. if zoneSel==2,set(ghandles.graphStrLoc2,'string',spotDescrip);end %graphStr);end
  226. if zoneSel==3,set(ghandles.graphStrLoc3,'string',spotDescrip);end %graphStr);end
  227. catch ME
  228. msg='ME.message';
  229. end % trycatch zoneSel<4 datatip selection from Image (not from an OverLay Plot)
  230. % Deprecated functions
  231. %{
  232. % If a specific spot median is ever needed
  233. %Calc. of EXACT median specific culture requires an odd number of indx items
  234. if ~isempty(NZusrIndxG) && mod(nonZeroCntD,2)==0, medianIndxOdd= NZusrIndxG(1:(size(NZusrIndxG,1)-1)); end
  235. if ~isempty(NZusrIndxG) && mod(nonZeroCntD,2)~=0, medianIndxOdd=NZusrIndxG(:); end
  236. mvalsDG=median(vv(medianIndxOdd,d)); %(nonzeros(vv(:,d)));
  237. nzPosIndxDG=find(mvalsDG==vv(:,d));
  238. Exp(expN).Dexp(n).UsrMedianG(d)=mvalsDG;
  239. Exp(expN).Dexp(n).UsrminG(d)=minG;
  240. Exp(expN).Dexp(n).UsrmaxG(d)=maxG;
  241. Exp(expN).Dexp(n).UsrstdG(d)=usrStdG;
  242. Exp(expN).Dexp(n).UsrmeanG(d)=usrmeanG;
  243. %}
  244. %{
  245. Exp(expN).Dexp(n).UsrCmpGL.dm(d).med=median(vv(medianIndxP,d)); %For Ref Composite 17_1026
  246. Exp(expN).Dexp(n).UsrCmpGL.dm(d).mean=mean(vv(medianIndxP,d)); %For Ref Composite 17_1026
  247. Exp(expN).Dexp(n).UsrCmpGL.dm(d).std=std(vv(medianIndxP,d)); %For Ref Composite 17_1026
  248. Exp(expN).Dexp(n).UsrCmpGL.dm(d).min=min(vv(medianIndxP,d)); %For Ref Composite 17_1026
  249. Exp(expN).Dexp(n).UsrCmpGL.dm(d).max=max(vv(medianIndxP,d)); %For Ref Composite 17_1026
  250. Exp(expN).Dexp(n).UsrCmpGK.dm(d).med=median(vvK(medianIndxP,d)); %For Ref Composite 17_1026
  251. Exp(expN).Dexp(n).UsrCmpGK.dm(d).mean=mean(vvK(medianIndxP,d)); %For Ref Composite 17_1026
  252. Exp(expN).Dexp(n).UsrCmpGK.dm(d).std=std(vvK(medianIndxP,d)); %For Ref Composite 17_1026
  253. Exp(expN).Dexp(n).UsrCmpGK.dm(d).min=min(vvK(medianIndxP,d)); %For Ref Composite 17_1026
  254. Exp(expN).Dexp(n).UsrCmpGK.dm(d).max=max(vvK(medianIndxP,d)); %For Ref Composite 17_1026
  255. Exp(expN).Dexp(n).UsrCmpGr.dm(d).med=median(vvr(medianIndxP,d)); %For Ref Composite 17_1026
  256. Exp(expN).Dexp(n).UsrCmpGr.dm(d).mean=mean(vvr(medianIndxP,d)); %For Ref Composite 17_1026
  257. Exp(expN).Dexp(n).UsrCmpGr.dm(d).std=std(vvr(medianIndxP,d)); %For Ref Composite 17_1026
  258. Exp(expN).Dexp(n).UsrCmpGr.dm(d).min=min(vvr(medianIndxP,d)); %For Ref Composite 17_1026
  259. Exp(expN).Dexp(n).UsrCmpGr.dm(d).max=max(vvr(medianIndxP,d)); %For Ref Composite 17_1026
  260. %}
  261. %{
  262. for mm=1:length(dMPs) % length(chgIndx)
  263. for d=selDM:selDM %1:(DMnum)
  264. medianIndxDisp=[];
  265. NZrefIndxP=[];
  266. nonZeroValsP=[];
  267. medValLstDisp=[];
  268. usrScNdisp=((dMPs(mm)-1)*DMnum)+(d);
  269. try % Determine the dispersed User Gene median mean and std if such exist
  270. NZrefIndxP=drfPindx((find(drfPindx(:,dMPs(mm)))),dMPs(mm)); medianIndxDisp=NZrefIndxP
  271. vv(chgIndx(mm):(chgIndx(mm+1)-1),d)=Exp(expN).Dexp(n).scan(usrScNdisp).plate(1).CFout(NZrefIndxP,5);
  272. %For Global Ref Composite 17_1009 %**************************************************************************
  273. vvK(chgIndx(mm):(chgIndx(mm+1)-1),d)=Exp(expN).Dexp(n).scan(usrScNdisp).plate(1).CFout(NZrefIndxP,3);
  274. vvr(chgIndx(mm):(chgIndx(mm+1)-1),d)=Exp(expN).Dexp(n).scan(usrScNdisp).plate(1).CFout(NZrefIndxP,4);
  275. %*****************************************************************************************************
  276. %{
  277. nonZeroValsP=nonzeros(Exp(expN).Dexp(n).scan(usrScNdisp).plate(1).CFout(NZrefIndxP,5));
  278. std1Disp=std(nonZeroValsP);
  279. mean1Disp=mean(nonZeroValsP);
  280. minDisp=min(nonZeroValsP);
  281. maxDisp=max(nonZeroValsP);
  282. drfVals=Exp(expN).Dexp(n).scan(usrScNdisp).plate(1).CFout(NZrefIndxP,5);
  283. %nzValsAcc(mm).DM(d,:)=nonZeroValsP;
  284. %MEDIAN Determination for PLATES with Dispersed RFs
  285. %NZrefIndxP=NZrefIndxP %find(Exp(expN).Dexp(n).scan(usrScNdisp).plate(1).CFout(NZrefIndxP,5));
  286. if isempty(NZrefIndxP), nonZeroCntDisp=0, medianIndxDisp=NZrefIndxP;
  287. else nonZeroCntDisp=length(NZrefIndxP);
  288. end
  289. if ~isempty(NZrefIndxP) && mod(nonZeroCntDisp,2)==0, medianIndxDisp= NZrefIndxP(1:nonZeroCntDisp-1); end
  290. if ~isempty(NZrefIndxP) && mod(nonZeroCntDisp,2)~=0, medianIndxDisp=NZrefIndxP; end
  291. %}
  292. if ~isempty(NZrefIndxP) && length(medianIndxDisp) > 0 %(.15*384) %To calc. a median, more than 15% of spots must be nonZero
  293. medValLstDisp=Exp(expN).Dexp(n).scan(usrScNdisp).plate(1).CFout(medianIndxDisp,5);
  294. mval1Disp=median(medValLstDisp);
  295. nzMedPosIndx=find(mval1Disp==nonZeroValsP);
  296. medianIndxP=NZrefIndxP(nzMedPosIndx);
  297. %UsrmdlocP(1)=ceil(medianIndxP/24); %calc r value
  298. %UsrmdlocP(2)=medianIndxP - ((UsrmdlocP(1)-1)*24); %calc c value
  299. meanKval=mean(nonzeros((Exp(expN).Dexp(n).scan(usrScNdisp).plate(1).CFout(NZrefIndxP,3))));
  300. meanrval=mean(nonzeros((Exp(expN).Dexp(n).scan(usrScNdisp).plate(1).CFout(NZrefIndxP,4))));
  301. else
  302. % Need to set L r K values to zeros or pick the first spot with zeros
  303. %Spot 1 could be other than zero as the median isn't calculated if fewer than some percent are nonzero
  304. medianCalcFailedD='To Few nonZero spots for valid median RF1 selection'
  305. firstZeroDindx=find(((Exp(expN).Dexp(n).scan(usrScNdisp).plate(1).CFout(NZrefIndxP,5))==0),1,'first');
  306. firstZeroD=drfPindx((firstZeroDindx),dMPs(mm));
  307. %Exp(expN).Dexp(n).UsrmdPindx(d,dMPs(mm))=firstZeroD;
  308. %Exp(expN).Dexp(n).UsrmdPpltN(d,dMPs(mm))=dMPs(mm); %RF1mp; %Is this supposed to be the MP number or the ScanPlate number???
  309. end %~isempty(NZrefIndxP) && length(medianIndxPisp) > 3 ln584
  310. catch %try ln565
  311. medianCalcTryFailed1D='Failed! Failed! {Dispersed RF1s}'
  312. try
  313. firstZeroindxD=find(vv((chgIndx(d):chgIndx(d+1)-1),5)==0,1,'first');
  314. firstZeroPindx=uu(firstZeroindxD,4);
  315. catch
  316. end
  317. end %try ~ln565
  318. end %for d=0:DMnum
  319. end %for mm=1:length(dMPs)
  320. %}
  321. %{
  322. %Code Template taken from EZlstBoxCmpExt.m
  323. try
  324. %if RFcmpGFlg==0
  325. smpSz=size(medianIndxP,1);
  326. K=median(vvK(medianIndxP,dmSel)); Ks=num2str(K); Kstd=std(vvK(medianIndxP,dmSel)); KstdStr=num2str(Kstd);
  327. r=median(vvr(medianIndxP,dmSel)); rs=num2str(r); rstd=std(vvr(medianIndxP,dmSel)); rstdStr=num2str(rstd);
  328. l=median(vv(medianIndxP,dmSel)); Ls=num2str(l); Lstd=std(vv(medianIndxP,dmSel)); LstdStr=num2str(Lstd);
  329. Kl=K - std(vvK(medianIndxP,dmSel)); %K - Exp(expN).Dexp(DexpN).RFcmpK(RFnum).dm(inDM).std;
  330. Ku=K + std(vvK(medianIndxP,dmSel)); %K + Exp(expN).Dexp(DexpN).RFcmpK(RFnum).dm(inDM).std;
  331. rl=r - std(vvr(medianIndxP,dmSel)); %r - Exp(expN).Dexp(DexpN).RFcmpr(RFnum).dm(inDM).std;
  332. ru=r + std(vvr(medianIndxP,dmSel)); %r + Exp(expN).Dexp(DexpN).RFcmpr(RFnum).dm(inDM).std;
  333. lfast=l - std(vv(medianIndxP,dmSel)); %l - Exp(expN).Dexp(DexpN).RFcmpL(RFnum).dm(inDM).std;
  334. lslow=l + std(vv(medianIndxP,dmSel)); %l + Exp(expN).Dexp(DexpN).RFcmpL(RFnum).dm(inDM).std;
  335. try Kstr=Ks(1:5); catch, Kstr=Ks(1:length(Ks)); end
  336. try rstr=rs(1:5); catch, rstr=rs(1:length(rs)); end
  337. try Lstr=Ls(1:5); catch, Lstr=Ls(1:length(Ls)); end
  338. t=1:200;
  339. clear g;
  340. try
  341. g=K ./ (1 + exp(-r.* (t - l )));
  342. gSlow=Kl ./ (1 + exp(-rl.* (t - lslow )));
  343. gFast=Ku ./ (1 + exp(-ru.* (t - lfast )));
  344. if K==0||r==0||l==0, g(1:200)=1;gSlow(1:200)=1;gFast(1:200)=1;end
  345. %tser=(scan(1,plateNum).plate(1).t0Series(:));
  346. %rawData=scan(1,plateNum).plate(1).intens(indx,:)/scan(1,plateNum).plate(1).Ag(indx);
  347. if zoneSel==1, plotAxes=ghandles.Paxes1; OLaxes=ghandles.OLaxes1;
  348. Dlaxes=ghandles.Dlaxes1;Dkaxes=ghandles.Dkaxes1;Draxes=ghandles.Draxes1;
  349. Exp(1).traceN=Exp(1).traceN+1;
  350. traceN=Exp(1).traceN;
  351. end
  352. if zoneSel==2, plotAxes=ghandles.Paxes2; OLaxes=ghandles.OLaxes2;Daxes=ghandles.Daxes2;
  353. Dlaxes=ghandles.Dlaxes2;Dkaxes=ghandles.Dkaxes2;Draxes=ghandles.Draxes2;
  354. Exp(2).traceN=Exp(2).traceN+1;
  355. traceN=Exp(2).traceN;
  356. end
  357. if zoneSel==3, plotAxes=ghandles.Paxes3; OLaxes=ghandles.OLaxes3;Daxes=ghandles.Daxes3;
  358. Dlaxes=ghandles.Dlaxes3;Dkaxes=ghandles.Dkaxes3;Draxes=ghandles.Draxes3;
  359. Exp(3).traceN=Exp(3).traceN+1;
  360. traceN=Exp(3).traceN;
  361. end
  362. plot(plotAxes,t,g);hold (plotAxes,'on'); %plot(plotAxes,tser,rawData,'g*');
  363. plot(plotAxes,t,gSlow,'y'); plot(plotAxes,t,gFast,'r');hold (plotAxes,'off');
  364. %************CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC**************************************
  365. %Store L R and K valves for Composite [C] plots
  366. Exp(expN).ll(traceN)=l; Exp(expN).rr(traceN)=r; Exp(expN).kk(traceN)=K;
  367. Exp(expN).lstd(traceN)=std(vv(medianIndxP,dmSel)); %Exp(expN).Dexp(DexpN).RFcmpL(RFnum).dm(inDM).std;
  368. Exp(expN).kstd(traceN)=std(vvK(medianIndxP,dmSel)); %Exp(expN).Dexp(DexpN).RFcmpK(RFnum).dm(inDM).std;
  369. Exp(expN).rstd(traceN)=std(vvr(medianIndxP,dmSel)); %Exp(expN).Dexp(DexpN).RFcmpr(RFnum).dm(inDM).std;
  370. Exp(expN).lslow(traceN)=lslow; Exp(expN).lfast(traceN)=lfast;
  371. Exp(expN).lKl(traceN)=Kl; Exp(expN).Ku(traceN)=Ku;
  372. Exp(expN).lrl(traceN)=rl; Exp(expN).Ku(traceN)=ru;
  373. %************************************************************************
  374. try for i=1:length(Exp(zoneSel).hOL(:)),set(Exp(zoneSel).hOL(i),'color',[0 0 1]); end, catch; end
  375. Exp(zoneSel).hOL(traceN)=plot(OLaxes,t,g);hold on;
  376. set(Exp(zoneSel).hOL(traceN),'color',[1 0 0])
  377. %Exp(zoneSel).hOLb(traceN)=plot(OLaxes,tser,rawData,'g*'); %No Raw Data, Ref Composite 17_1009
  378. catch
  379. catchissue='Ln68 EZlstBoxCmpExt'
  380. end %trycatch
  381. %Get the DM agar description
  382. %if expN==1,DMstr=char(get(handles.DM1,'string'));end
  383. %if expN==2,DMstr=char(get(handles.DM2,'string'));end
  384. %if expN==3,DMstr=char(get(handles.DM3,'string'));end
  385. DMstr=num2str(dmSel);
  386. %spec=MP(1,LBmp).specifics{1,1}(indx); %orfrep=MP(1,plateNum).orfRep{1,1}(indx);
  387. %tPtStr=strcat('T=', num2str(scan(1,plateNum).plate(1).t0Series(tPtSel)));
  388. %graphStr=strcat(usrGnSp,'_','L=',Lstr,'_','Lstd=',LstdStr,'_','r=',rstr,'_','rstd=',rstdStr,'_','K=',Kstr,'Kstd=',KstdStr);
  389. graphStr=strcat(usrGnSp,'_','L=',Lstr,'_','Lstd=',LstdStr,'_','r=',rstr,'_','rstd=',rstdStr,'_','K=',Kstr,'Kstd=',KstdStr);
  390. spotDescrip=strcat(graphStr,'DMS->',DMstr);
  391. xp=char(Exp(zoneSel).Dexp(DexpN).resDir);
  392. if ispc,
  393. slashPos=strfind(char(Exp(zoneSel).Dexp(DexpN).resDir),'\');
  394. else
  395. slashPos=strfind(char(Exp(zoneSel).Dexp(DexpN).resDir),'/');
  396. end
  397. startPos=slashPos(length(slashPos)-1) +1;
  398. endPos=slashPos(length(slashPos)) -1
  399. expStr={xp(startPos:endPos)}
  400. Exp(zoneSel).hOLname(traceN)=usrGnSp; %spotDescrip; %graphStr; %ghandles.Exp(zoneSel).hOLname(traceN)=graphStr;
  401. Exp(zoneSel).hOLexpNm(traceN)=expStr; %ghandles.Exp(expN).hOLexpNm(traceN)=expStr;
  402. Exp(zoneSel).hOLresDir(traceN)={Exp(zoneSel).Dexp(DexpN).resDir};
  403. %Exp(zoneSel).hOLplateNum(traceN)=plateNum;
  404. %traceData=vertcat(get(Exp(OLay).hOL(traceN),'XData'),get(ghandles.Exp(OLay).hOL(traceN),'YData'));
  405. %if zoneSel==1,set(ghandles.GeneOrfLoc1,'string',geneOrfstr);end % Displays the value.
  406. %if zoneSel==2,set(ghandles.GeneOrfLoc2,'string',geneOrfstr);end
  407. %if zoneSel==3,set(ghandles.GeneOrfLoc3,'string',geneOrfstr);end
  408. %if zoneSel==1,set(ghandles.graphStrLoc1,'string',spotDescrip);end %graphStr);end % Displays the value.
  409. %if zoneSel==2,set(ghandles.graphStrLoc2,'string',spotDescrip);end %graphStr);end
  410. %if zoneSel==3,set(ghandles.graphStrLoc3,'string',spotDescrip);end %graphStr);end
  411. catch
  412. catchissue='Ln33 EZlstBoxCmpExt'
  413. msg='Error'
  414. end % trycatch zoneSel<4 datatip selection from Image (not from an OverLay Plot)
  415. %**************Write Spot and Exp Info to OLay title areas****************************************************************************
  416. if zoneSel==1, %&& get(ghandles.rotPB1,'value')~=1
  417. if length(char(Exp(zoneSel).hOLname(traceN)))>40,set(ghandles.OLay1,'FontSize',8);end
  418. set(ghandles.OLay1,'string', Exp(zoneSel).hOLname(traceN));
  419. if length(char(Exp(zoneSel).hOLexpNm(traceN)))>40,set(ghandles.OLexp1,'FontSize',8);end
  420. set(ghandles.OLexp1,'string',Exp(zoneSel).hOLexpNm(traceN));
  421. end
  422. if zoneSel==2 %&& get(ghandles.rotPB2,'value') ~=1
  423. if length(char(Exp(zoneSel).hOLname(traceN)))>40,set(ghandles.OLay2,'FontSize',8);end
  424. set(ghandles.OLay2,'string', Exp(zoneSel).hOLname(traceN));
  425. if length(char(Exp(zoneSel).hOLexpNm(traceN)))>40,set(ghandles.OLexp2,'FontSize',8);end
  426. set(ghandles.OLexp2,'string',Exp(zoneSel).hOLexpNm(traceN));
  427. end
  428. if zoneSel==3 %&& get(ghandles.rotPB3,'value') ~=1
  429. if length(char(Exp(zoneSel).hOLname(traceN)))>40,set(ghandles.OLay3,'FontSize',8);end
  430. set(ghandles.OLay3,'string', Exp(OLay).hOLname(traceN));
  431. if length(char(Exp(zoneSel).hOLexpNm(traceN)))>40,set(ghandles.OLexp3,'FontSize',8);end
  432. set(ghandles.OLexp3,'string',Exp(OLay).hOLexpNm(traceN));
  433. end
  434. %}
  435. %**********************************************************************
  436. %{
  437. %elseif RFcmpGFlg==1
  438. K=Exp(expN).Dexp(DexpN).RFcmpGK.dm(inDM).med; Ks=num2str(K);
  439. r=Exp(expN).Dexp(DexpN).RFcmpGr.dm(inDM).med; rs=num2str(r);
  440. l=Exp(expN).Dexp(DexpN).RFcmpGL.dm(inDM).med; Ls=num2str(l);
  441. Kl=K - Exp(expN).Dexp(DexpN).RFcmpGK.dm(inDM).std;
  442. Ku=K + Exp(expN).Dexp(DexpN).RFcmpGK.dm(inDM).std;
  443. rl=r - Exp(expN).Dexp(DexpN).RFcmpGr.dm(inDM).std;
  444. ru=r + Exp(expN).Dexp(DexpN).RFcmpGr.dm(inDM).std;
  445. lfast=l - Exp(expN).Dexp(DexpN).RFcmpGL.dm(inDM).std;
  446. lslow=l + Exp(expN).Dexp(DexpN).RFcmpGL.dm(inDM).std;
  447. end
  448. %}
  449. %Exp(expN).Dexp(n).UsrmdPindx=[];
  450. %Exp(expN).Dexp(n).UsrmdPpltN=[];
  451. %Exp(expN).Dexp(n).UsrmdPscanN=[];
  452. %Exp(expN).Dexp(n).UsrMedianP=[];
  453. %Exp(expN).Dexp(n).stdP=[];
  454. %Exp(expN).Dexp(n).meanP=[];
  455. %Exp(expN).Dexp(n).minP=[];
  456. %Exp(expN).Dexp(n).maxP=[];
  457. %Exp(expN).Dexp(n).RFmdGLB={[]};
  458. %Exp(expN).Dexp(n).RFmdGindx=[];
  459. %Exp(expN).Dexp(n).RFmdGpltN=[];
  460. %Exp(expN).Dexp(n).RFmdGscanN=[];
  461. %UsrmdDGloc(d,1)=uu(nzPosIndxDG,1); %MP of distributedGlobal Median value
  462. %UsrmdDGloc(d,2)=uu(nzPosIndxDG,2); %calc r value
  463. %UsrmdDGloc(d,3)=uu(nzPosIndxDG,3); %calc c value
  464. %lstindx=lstindx+1;
  465. %lstindxOrf=lstindxOrf+1;
  466. %{
  467. usrGLbl=strcat(usrGnSp,'UmdG('); %accomodate User Ref Selection
  468. aa(lstindx,1)=strcat(usrGLbl,num2str(d),')'); %remove string2cell brackets {...}
  469. aa(lstindx,2)={strcat(':',num2str(UsrmdDGloc(d,1)),':',num2str(UsrmdDGloc(d,2)),':',num2str(UsrmdDGloc(d,3)))}; %,'std_',num2str(std2))};
  470. bb(lstindxOrf,1)=strcat(usrGLbl,num2str(d),')'); %remove string2cell brackets {...}
  471. bb(lstindxOrf,2)={strcat(':',num2str(UsrmdDGloc(d,1)),':',num2str(UsrmdDGloc(d,2)),':',num2str(UsrmdDGloc(d,3)))}; %,'std_',num2str(std2))};
  472. %Composite Reference Amalgum Plot ******************
  473. lstindx=lstindx+1;
  474. lstindxOrf=lstindxOrf+1;
  475. aa(lstindx,1)=strcat(usrGnSp,'UcmpG(',num2str(d),')');
  476. aa(lstindx,2)={''};
  477. bb(lstindxOrf,1)=strcat(usrGnSp,'UcmpG(',num2str(d),')');
  478. bb(lstindxOrf,2)={''};
  479. %*****************************************************
  480. %}
  481. %{
  482. lstindx=lstindx+1;
  483. lstindxOrf=lstindxOrf+1;
  484. usrPLbl=strcat(usrGnSp,'UmdP('); %accomodate User Ref Selection
  485. aa(lstindx,1)=strcat(usrPLbl,num2str(d),')');
  486. aa(lstindx,2)={strcat(':',num2str(dMPs(mm)),':',num2str(UsrmdlocP(1)),':',num2str(UsrmdlocP(2)))};
  487. bb(lstindxOrf,1)=strcat(usrPLbl,num2str(d),')'); %remove string2cell brackets {...}
  488. bb(lstindxOrf,2)={strcat(':',num2str(dMPs(mm)),':',num2str(UsrmdlocP(1)),':',num2str(UsrmdlocP(2)))};
  489. Exp(expN).Dexp(n).UsrmdPLB(d,dMPs(mm))=strcat(aa(lstindx,1),aa(lstindx,2));
  490. Exp(expN).Dexp(n).UsrmdPindx(d,dMPs(mm))=medianIndxP;
  491. Exp(expN).Dexp(n).UsrmdPpltN(d,dMPs(mm))=dMPs(mm); %This is a storage of the MasterPlate used NOT the ScanPlate? WeMight wish to store the ScanPlateNumber also???
  492. Exp(expN).Dexp(n).UsrmdPscanN(d,dMPs(mm))=usrScNdisp;
  493. Exp(expN).Dexp(n).UsrMedianP(d,dMPs(mm))=mval1Disp;
  494. Exp(expN).Dexp(n).stdP(d,dMPs(mm))=std1Disp;
  495. Exp(expN).Dexp(n).meanP(d,dMPs(mm))=mean1Disp;
  496. Exp(expN).Dexp(n).minP(d,dMPs(mm))=minDisp;
  497. Exp(expN).Dexp(n).maxP(d,dMPs(mm))=maxDisp;
  498. Exp(expN).Dexp(n).UsrCmpPL.dm(d).med=mval1Disp; %For Ref Composite 17_1026
  499. Exp(expN).Dexp(n).UsrCmpPL.dm(d).mean=mean1Disp; %For Ref Composite 17_1026
  500. Exp(expN).Dexp(n).UsrCmpPL.dm(d).std=std1Disp; %For Ref Composite 17_1026
  501. Exp(expN).Dexp(n).UsrCmpPL.dm(d).min=minDisp; %For Ref Composite 17_1026
  502. Exp(expN).Dexp(n).UsrCmpPL.dm(d).max=maxDisp; %For Ref Composite 17_1026
  503. Exp(expN).Dexp(n).UsrCmpPK.dm(d).med=median(nonzeros((Exp(expN).Dexp(n).scan(usrScNdisp).plate(1).CFout(NZrefIndxP,3)))); %For Ref Composite 17_1026
  504. Exp(expN).Dexp(n).UsrCmpPK.dm(d).mean=mean(nonzeros((Exp(expN).Dexp(n).scan(usrScNdisp).plate(1).CFout(NZrefIndxP,3)))); %For Ref Composite 17_1026
  505. Exp(expN).Dexp(n).UsrCmpPK.dm(d).std=std(nonzeros((Exp(expN).Dexp(n).scan(usrScNdisp).plate(1).CFout(NZrefIndxP,3)))); %For Ref Composite 17_1026
  506. Exp(expN).Dexp(n).UsrCmpPK.dm(d).min=min(nonzeros((Exp(expN).Dexp(n).scan(usrScNdisp).plate(1).CFout(NZrefIndxP,3)))); %For Ref Composite 17_1026
  507. Exp(expN).Dexp(n).UsrCmpPK.dm(d).max=max(nonzeros((Exp(expN).Dexp(n).scan(usrScNdisp).plate(1).CFout(NZrefIndxP,3)))); %For Ref Composite 17_1026
  508. Exp(expN).Dexp(n).UsrCmpPr.dm(d).med=median(nonzeros((Exp(expN).Dexp(n).scan(usrScNdisp).plate(1).CFout(NZrefIndxP,4)))); %For Ref Composite 17_1026
  509. Exp(expN).Dexp(n).UsrCmpPr.dm(d).mean=mean(nonzeros((Exp(expN).Dexp(n).scan(usrScNdisp).plate(1).CFout(NZrefIndxP,4)))); %For Ref Composite 17_1026
  510. Exp(expN).Dexp(n).UsrCmpPr.dm(d).std=std(nonzeros((Exp(expN).Dexp(n).scan(usrScNdisp).plate(1).CFout(NZrefIndxP,4)))); %For Ref Composite 17_1026
  511. Exp(expN).Dexp(n).UsrCmpPr.dm(d).min=min(nonzeros((Exp(expN).Dexp(n).scan(usrScNdisp).plate(1).CFout(NZrefIndxP,4)))); %For Ref Composite 17_1026
  512. Exp(expN).Dexp(n).UsrCmpPr.dm(d).max=max(nonzeros((Exp(expN).Dexp(n).scan(usrScNdisp).plate(1).CFout(NZrefIndxP,4)))); %For Ref Composite 17_1026
  513. %}
  514. %Exp(expN).Dexp(n).UsrmdGindx(d)=nzPosIndxDG;
  515. %Exp(expN).Dexp(n).UsrmdGpltN(d)=UsrmdDGloc(d,1);
  516. %Exp(expN).Dexp(n).UsrmdGscanN(d)=uu(nzPosIndxDG,4);
  517. %{
  518. try
  519. firstZeroindxD=find(vv((chgIndx(d):chgIndx(d+1)-1),5)==0,1,'first');
  520. firstZeroPindx=uu(firstZeroindxD,4);
  521. %Exp(expN).Dexp(n).UsrmdPpltN(d,dMPs(mm))=dMPs(mm);
  522. %Exp(expN).Dexp(n).UsrmdPindx(d,dMPs(mm))=firstZeroPindx;
  523. catch
  524. catchissue='try at Ln565'
  525. %Exp(expN).Dexp(n).UsrmdPpltN(d,dMPs(mm))=dMPs(mm);
  526. %Exp(expN).Dexp(n).UsrmdPindx(d,dMPs(mm))=384; %if crapout,Then use spot384 as default to keep going
  527. end
  528. try
  529. % Exp(expN).Dexp(n).UsrmdPpltN=dMPs(mm);
  530. catch
  531. catchissue='Ln619'
  532. %Exp(expN).Dexp(n).UsrmdPpltN=1; %This might keep from breaking BUT ???
  533. end
  534. error='EZexpSel lineAfter 565'
  535. end %try ~ln565
  536. %}