EZmDayPlotUcmp.m 10.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251
  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. traceN=Exp(expN).traceN;
  11. DexpN=Exp(expN).DexpN; % Temp input for development
  12. patrnN=strfind(selGnOrf{1},':'); %Extract Gene-Orf Name
  13. patrndash=strfind(selGnOrf{1},'-');
  14. selStrNm=char(selGnOrf)
  15. if strcmpi(selStrNm(1:3),'RF-')
  16. usrGene=selStrNm(4:(patrndash(2)-1));
  17. else
  18. usrGene=selStrNm(1:(patrnN(1)-1));
  19. end
  20. prompt={'Enter Specifics Term if used to futher specify selection '}
  21. dlg_title='User Specifics Term for Refinement Composite';
  22. num_lines=1;
  23. def={'None'};
  24. answer=inputdlg(prompt,dlg_title,num_lines,def);
  25. usrSpec=cell2mat(answer(1));
  26. if strcmpi(usrSpec,'None')
  27. usrGnSp={strcat(usrGene,'-')};
  28. elseif length(usrSpec)> 8,
  29. trimUspec=usrSpec(1:8);
  30. usrGnSp=strcat(usrGene,',',{trimUspec});
  31. else
  32. trimUspec=usrSpec;
  33. usrGnSp=strcat(usrGene,',',{trimUspec});
  34. end
  35. for n=1:Exp(expN).DexpLength % LOOP Thru DayExps
  36. MPnum=length(Exp(expN).Dexp(n).MP);
  37. DMnum=length(Exp(expN).Dexp(n).DM.drug);
  38. %Extract expDay from ExpName string
  39. dayNpos=max(strfind(Exp(expN).Dexp(n).ExpFoldr, '_D'))
  40. dayLbl=Exp(expN).Dexp(n).ExpFoldr(dayNpos+1:end);
  41. dRF1indx=0;
  42. usrSp=usrSpec; %user entry of Specifics for Ref selection
  43. for mp=1:length(Exp(expN).Dexp(n).MP)
  44. for ind384=1:384
  45. try
  46. % Insert test for numeric in genename and orf if isnumeric
  47. % Correct common EXCEL problem of converting OCT1 into a date numeric
  48. if cell2mat(Exp(expN).Dexp(n).MP(mp).genename{1}(ind384))==38991,
  49. Exp(expN).Dexp(n).MP(mp).genename{1}(ind384)={'OCT1_'};
  50. elseif isnumeric(cell2mat(Exp(expN).Dexp(n).MP(mp).genename{1}(ind384)))
  51. Exp(expN).Dexp(n).MP(mp).genename{1}(ind384)={' '};
  52. end
  53. % DISPersed REFerence capture and find Medians
  54. if ( ((strcmpi((Exp(expN).Dexp(n).MP(mp).genename{1}(ind384)),usrGene) ...
  55. && strcmpi((Exp(expN).Dexp(n).MP(mp).specifics{1}(ind384)),usrSp))) ...
  56. || ((strcmpi((Exp(expN).Dexp(n).MP(mp).genename{1}(ind384)),usrGene) ...
  57. && strcmpi(usrSp,'None'))) )
  58. dRF1indx=dRF1indx+1;
  59. Exp(expN).Dexp(n).MP(mp).genename{1}(ind384)=strrep((Exp(expN).Dexp(n).MP(mp).genename{1}(ind384)),':',' ');
  60. drf(dRF1indx,1)=(Exp(expN).Dexp(n).MP(mp).genename{1}(ind384));
  61. drf(dRF1indx,2)={mp}; drfMP(dRF1indx,mp)=mp;
  62. drf(dRF1indx,3)={ind384}; drfPindx(dRF1indx,mp)=ind384;
  63. %drf(dRF1indx,7)=(Exp(expN).Dexp(n).MP(mp).specifics{1}(ind384));
  64. end
  65. catch
  66. msgBadGeneName=strcat('check genename at mp=',num2str(mp),' indx=',num2str(ind384))
  67. end
  68. end % end associated with for ind384=1:384
  69. mp
  70. end
  71. vvL=[]; %Initialize to cover case where all spot are Zero NoGrowth See NIGrowthflg==0
  72. if exist('drf','var')
  73. % Det. index of change from one MP to the next
  74. i=2;
  75. clear chgIndx
  76. chgIndx(1)=1;
  77. for j=1:length(drf(:,3))
  78. if j>1
  79. if cell2mat(drf(j,2))~=cell2mat(drf((j-1),2)), chgIndx(i)=j; i=i+1; end
  80. end
  81. end
  82. chgIndx(length(chgIndx)+1)=size(drf,1) +1; %length(drf)+1;
  83. vvL=zeros(size(drf,1),1 ); %length(drf)+1;
  84. dMPs=unique(cell2mat(drf(:,2)));
  85. for mm=1:length(dMPs) % length(chgIndx)
  86. usrScNdisp=((dMPs(mm)-1)*DMnum)+(dmSel);
  87. NZusrIndx=drfPindx((find(drfPindx(:,dMPs(mm)))),dMPs(mm)); medianIndxDisp=NZusrIndx;
  88. vvL(chgIndx(mm):(chgIndx(mm+1)-1))=Exp(expN).Dexp(n).scan(usrScNdisp).plate(1).CFout(NZusrIndx,5);
  89. % For Global Ref Composite 17_1009
  90. vvK(chgIndx(mm):(chgIndx(mm+1)-1))=Exp(expN).Dexp(n).scan(usrScNdisp).plate(1).CFout(NZusrIndx,3);
  91. vvr(chgIndx(mm):(chgIndx(mm+1)-1))=Exp(expN).Dexp(n).scan(usrScNdisp).plate(1).CFout(NZusrIndx,4);
  92. end
  93. % Calc. Global Mean, Std, And Median For Distributed References
  94. for d=dmSel:dmSel
  95. NZusrIndxG=[];
  96. NZusrIndxG=find(vvL);
  97. if isempty(nonzeros(vvL))
  98. nonZeroCntD=0;
  99. else
  100. nonZeroCntD=length(nonzeros(vvL));
  101. end
  102. % Calc. of median value for composite doesn't require and odd number of Indx items
  103. NZusrIndxG=NZusrIndxG(:);
  104. if ~isempty(NZusrIndxG) && length(NZusrIndxG) > 0 %(.15*size(drf,1)) %To calc. a median, more than 15% of spots must be nonZero
  105. UsrLvals{n}=vvL(NZusrIndxG);
  106. UsrKvals{n}=vvK(NZusrIndxG);
  107. Usrrvals{n}=vvr(NZusrIndxG);
  108. end
  109. end
  110. end
  111. end
  112. if ~exist('drf','var'),
  113. errordlg('Gene-Specifics combination not found. Check spelling of Specifics entry.','Entry Warning');
  114. break;
  115. end
  116. NoGrowthflg=0;
  117. if isempty(vvL),
  118. warndlg('No Growth condition found for Gene-Specifics combination. . ','No Growth warning');
  119. NoGrowthflg=1;
  120. end
  121. %Exp(expN).UgeneCnt=Exp(expN).UgeneCnt +1;
  122. %Exp(expN).UgeneSpLst(Exp(expN).UgeneCnt)=usrGnSp;
  123. % Plot Values Selected Gene-Specifics Composite
  124. if NoGrowthflg==0
  125. smpSz=size(NZusrIndxG,1);
  126. K=median(cell2mat((UsrKvals(DexpN)))); Ks=num2str(K); Kstd=std(cell2mat((UsrKvals(DexpN)))); KstdStr=num2str(Kstd);
  127. r=median(cell2mat((Usrrvals(DexpN)))); rs=num2str(r); rstd=std(cell2mat((Usrrvals(DexpN)))); rstdStr=num2str(rstd);
  128. l=median(cell2mat((UsrLvals(DexpN)))); Ls=num2str(l); Lstd=std(cell2mat((UsrLvals(DexpN)))); LstdStr=num2str(Lstd);
  129. Kl=K - Kstd; %std(UsrKvals(DexpN));
  130. Ku=K + Kstd; %std(UsrKvals(DexpN));
  131. rl=r - rstd; %std(Usrrvals(DexpN));
  132. ru=r + rstd; %std(UsrKvals(DexpN));
  133. lfast=l - Lstd;
  134. lslow=l + Lstd;
  135. elseif NoGrowth==1 %if all data is zero (NoGrowth)
  136. smpSz=size(NZusrIndxG,1);
  137. K=0; Ks=num2str(K); Kstd=0; KstdStr=num2str(0);
  138. r=0; rs=num2str(r); rstd=0; rstdStr=num2str(0);
  139. l=0; Ls=num2str(l); Lstd=0; LstdStr=num2str(0);
  140. Kl=K - Kstd;
  141. Ku=K + Kstd;
  142. rl=r - rstd;
  143. ru=r + rstd;
  144. lfast=l - Lstd;
  145. lslow=l + Lstd;
  146. end
  147. try Kstr=Ks(1:5); catch, Kstr=Ks(1:length(Ks)); end
  148. try rstr=rs(1:5); catch, rstr=rs(1:length(rs)); end
  149. try Lstr=Ls(1:5); catch, Lstr=Ls(1:length(Ls)); end
  150. pertSel=Exp(zoneSel).Dexp(DexpN).pertSel; %floor(get(handles.DMsldr1,'value'));
  151. plateNum=(LBmp-1)*destPerMP + pertSel;
  152. MP=Exp(zoneSel).Dexp(DexpN).MP;
  153. try
  154. t=1:200;
  155. clear g;
  156. try
  157. g=K ./ (1 + exp(-r.* (t - l )));
  158. gSlow=Kl ./ (1 + exp(-rl.* (t - lslow )));
  159. gFast=Ku ./ (1 + exp(-ru.* (t - lfast )));
  160. if K==0||r==0||l==0, g(1:200)=1;gSlow(1:200)=1;gFast(1:200)=1;end
  161. if zoneSel==1, plotAxes=ghandles.Paxes1; OLaxes=ghandles.OLaxes1;
  162. Dlaxes=ghandles.Dlaxes1;Dkaxes=ghandles.Dkaxes1;Draxes=ghandles.Draxes1;
  163. Exp(1).traceN=Exp(1).traceN+1;
  164. traceN=Exp(1).traceN;
  165. end
  166. if zoneSel==2
  167. plotAxes=ghandles.Paxes2; OLaxes=ghandles.OLaxes2;Daxes=ghandles.Daxes2;
  168. Dlaxes=ghandles.Dlaxes2;Dkaxes=ghandles.Dkaxes2;Draxes=ghandles.Draxes2;
  169. Exp(2).traceN=Exp(2).traceN+1;
  170. traceN=Exp(2).traceN;
  171. end
  172. if zoneSel==3
  173. plotAxes=ghandles.Paxes3; OLaxes=ghandles.OLaxes3;Daxes=ghandles.Daxes3;
  174. Dlaxes=ghandles.Dlaxes3;Dkaxes=ghandles.Dkaxes3;Draxes=ghandles.Draxes3;
  175. Exp(3).traceN=Exp(3).traceN+1;
  176. traceN=Exp(3).traceN;
  177. end
  178. plot(plotAxes,t,g);hold (plotAxes,'on');
  179. plot(plotAxes,t,gSlow,'y');plot(plotAxes,t,gFast,'r');hold (plotAxes,'off');
  180. Exp(expN).Trace(traceN).UsrGLB=usrGnSp;
  181. Exp(expN).Trace(traceN).dmSel=dmSel;
  182. for n=1:Exp(expN).DexpLength % Loop Thru DayExps
  183. Exp(expN).Trace(traceN).Dexp(n).DM(dmSel).UsrLvals=UsrLvals(n);
  184. Exp(expN).Trace(traceN).Dexp(n).DM(dmSel).UsrKvals=UsrKvals(n);
  185. Exp(expN).Trace(traceN).Dexp(n).DM(dmSel).Usrrvals=Usrrvals(n);
  186. end
  187. % Store L R and K valves for manual selected Composite [C] plots
  188. Exp(expN).ll(traceN)=l; Exp(expN).rr(traceN)=r; Exp(expN).kk(traceN)=K;
  189. Exp(expN).lslow(traceN)=lslow; Exp(expN).lfast(traceN)=lfast;
  190. try for i=1:length(Exp(zoneSel).hOL(:)),set(Exp(zoneSel).hOL(i),'color',[0 0 1]); end, catch; end
  191. Exp(zoneSel).hOL(traceN)=plot(OLaxes,t,g);hold on;
  192. set(Exp(zoneSel).hOL(traceN),'color',[1 0 0])
  193. catch
  194. catchissue='Ln100 EZlstBoxExt'
  195. end
  196. %Get the DM agar description
  197. if expN==1,DMstr=char(get(handles.DM1,'string'));end
  198. if expN==2,DMstr=char(get(handles.DM2,'string'));end
  199. if expN==3,DMstr=char(get(handles.DM3,'string'));end
  200. gene=usrGnSp; orf='' %MP(1,LBmp).orf{1,1}(indx);
  201. geneOrfstr=strcat(gene,'_',orf,'_');
  202. grfgenestr=strcat(gene,'_',orf,'_');
  203. graphStr=strcat(usrGnSp,'_','L=',Lstr,'_','Ls=',LstdStr,'_','r=',rstr,'_','rs=',rstdStr,'_','K=',Kstr,'Ks=',KstdStr);
  204. spotDescrip=strcat(graphStr,'->',DMstr);
  205. xp=char(Exp(zoneSel).Dexp(DexpN).resDir);
  206. if ispc,
  207. slashPos=strfind(char(Exp(zoneSel).Dexp(DexpN).resDir),'\');
  208. else
  209. slashPos=strfind(char(Exp(zoneSel).Dexp(DexpN).resDir),'/');
  210. end
  211. startPos=slashPos(length(slashPos)-1) +1;
  212. endPos=slashPos(length(slashPos)) -1;
  213. expStr={xp(startPos:endPos)};
  214. Exp(zoneSel).hOLname(traceN)=spotDescrip;
  215. Exp(zoneSel).hOLexpNm(traceN)=expStr;
  216. Exp(zoneSel).hOLresDir(traceN)={Exp(zoneSel).Dexp(DexpN).resDir};
  217. Exp(zoneSel).hOLplateNum(traceN)=plateNum;
  218. if zoneSel==1,set(ghandles.GeneOrfLoc1,'string',geneOrfstr);end % Displays the value.
  219. if zoneSel==2,set(ghandles.GeneOrfLoc2,'string',geneOrfstr);end
  220. if zoneSel==3,set(ghandles.GeneOrfLoc3,'string',geneOrfstr);end
  221. if zoneSel==1,set(ghandles.graphStrLoc1,'string',spotDescrip);end %graphStr);end % Displays the value.
  222. if zoneSel==2,set(ghandles.graphStrLoc2,'string',spotDescrip);end %graphStr);end
  223. if zoneSel==3,set(ghandles.graphStrLoc3,'string',spotDescrip);end %graphStr);end
  224. catch
  225. msg='Error'
  226. end