EZplotUcmp.m 10.0 KB

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