EZfigTrendOL.m 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549
  1. %EZfigTrendOL.m called from EZviewGui.m LKrTog__ Callback
  2. %Uses data stored from OLay ; Clearing OLay clears data used by this
  3. %Trending Utility
  4. global Exp
  5. global userPars
  6. %try
  7. kfiltLim=userPars.kfiltLim;
  8. %catch
  9. %kfiltLim=str2double(userPars.BPdefault(6));
  10. %end
  11. if get(handles.CompositeTog1, 'Value')
  12. cmpTogFlg=1;
  13. else
  14. cmpTogFlg=0;
  15. end
  16. DexpN=Exp(expN).DexpN;
  17. if strcmp(Exp(expN).DexpType, 'chrono')
  18. maxRows=1; Lmax=1; bpInd=0;
  19. for n=1:length(Exp(expN).Dexp) %LOOP Thru DayExps
  20. for trc=1:Exp(expN).traceN %length(Exp(expN).Trace)
  21. try
  22. if isequal(get(Exp(expN).hOL(trc),'Visible'),'on')
  23. dmSel=Exp(expN).Trace(trc).dmSel;
  24. if iscell(Exp(expN).Trace(trc).Dexp(n).DM(dmSel).UsrLvals)
  25. rows=length(cell2mat(Exp(expN).Trace(trc).Dexp(n).DM(dmSel).UsrLvals));
  26. else
  27. rows=1;
  28. end
  29. if iscell(Exp(expN).Trace(trc).Dexp(n).DM(dmSel).UsrLvals)
  30. if rows> maxRows, maxRows=rows; end
  31. LsmpMax=max(cell2mat(Exp(expN).Trace(trc).Dexp(n).DM(dmSel).UsrLvals));
  32. else
  33. LsmpMax=max(Exp(expN).Trace(trc).Dexp(n).DM(dmSel).UsrLvals);
  34. end
  35. if LsmpMax> Lmax, Lmax=LsmpMax; end
  36. bpInd=bpInd+1;
  37. end % if isequal(get(Exp(1).hOL(trc),'Visible'),'on')
  38. catch
  39. end
  40. end
  41. end
  42. maxCols=bpInd; % length(Exp(expN).Dexp) * length(Exp(expN).Trace)
  43. BPvals(1:maxRows,1:maxCols)=nan; % BoxPlot requires a matrix with uniform length even if data is not of the same length
  44. bpInd=0;
  45. for n=1:length(Exp(expN).Dexp) %LOOP Thru DayExps
  46. for trc=1:Exp(expN).traceN %length(Exp(expN).Trace)
  47. try
  48. if isequal(get(Exp(expN).hOL(trc),'Visible'),'on')
  49. dmSel=Exp(expN).Trace(trc).dmSel;
  50. bpInd=bpInd+1;
  51. if iscell(Exp(expN).Trace(trc).Dexp(n).DM(dmSel).UsrLvals)
  52. kFiltrIndx=find((cell2mat(Exp(expN).Trace(trc).Dexp(n).DM(dmSel).UsrKvals))<=kfiltLim);
  53. tmp=cell2mat(Exp(expN).Trace(trc).Dexp(n).DM(dmSel).UsrLvals);
  54. BPvals(1:length(kFiltrIndx),bpInd)=tmp(kFiltrIndx);
  55. % BPvals(1:length(cell2mat(Exp(expN).Trace(trc).Dexp(n).DM(dmSel).UsrLvals)),bpInd)=cell2mat(Exp(expN).Trace(trc).Dexp(n).DM(dmSel).UsrLvals);
  56. cnt=length(kFiltrIndx); %length(cell2mat(Exp(expN).Trace(trc).Dexp(n).DM(dmSel).UsrLvals));
  57. else
  58. if length(Exp(expN).Trace(trc).Dexp(n).DM(dmSel).UsrLvals)> 1 %>=1
  59. kFiltrIndx=find(((Exp(expN).Trace(trc).Dexp(n).DM(dmSel).UsrKvals))<=kfiltLim);
  60. tmp=Exp(expN).Trace(trc).Dexp(n).DM(dmSel).UsrLvals;
  61. BPvals(1:length(kFiltrIndx),bpInd)=tmp(kFiltrIndx);
  62. cnt=length(kFiltrIndx);
  63. % BPvals(1:length((Exp(expN).Trace(trc).Dexp(n).DM(dmSel).UsrLvals)),bpInd)=Exp(expN).Trace(trc).Dexp(n).DM(dmSel).UsrLvals;
  64. % cnt=length((Exp(expN).Trace(trc).Dexp(n).DM(dmSel).UsrLvals));
  65. else
  66. BPvals(1,bpInd)=Exp(expN).Trace(trc).Dexp(n).DM(dmSel).UsrLvals;
  67. cnt=length(Exp(expN).Trace(trc).Dexp(n).DM(dmSel).UsrLvals);
  68. end
  69. end
  70. % scnt(bpInd)=strcat('[',num2str(cnt),']');
  71. scnt=strcat('[',num2str(cnt),']');
  72. % Get Agar DrugMedia
  73. drug=Exp(expN).Dexp(n).DM.drug{dmSel};
  74. conc=Exp(expN).Dexp(n).DM.conc{dmSel};
  75. media=Exp(expN).Dexp(n).DM.media{dmSel};
  76. mod1=Exp(expN).Dexp(n).DM.mod1{dmSel}; if isnan(cell2mat(mod1)), mod1='';end
  77. conc1=Exp(expN).Dexp(n).DM.conc1{dmSel}; if isnan(cell2mat(conc1)), conc1='';end
  78. mod2=Exp(expN).Dexp(n).DM.mod2{dmSel}; if isnan(cell2mat(mod2)), mod2='';end
  79. conc2=Exp(expN).Dexp(n).DM.conc2{dmSel}; if isnan(cell2mat(conc2)), conc2='';end
  80. dmStr=strcat(drug,conc,'_',media,'_',mod1,conc1,mod2,conc2);
  81. % Extract expDay from ExpName string
  82. dayNpos=max(strfind(Exp(expN).Dexp(n).ExpFoldr, '_D'));
  83. dayLbl=Exp(expN).Dexp(n).ExpFoldr(dayNpos+1:end);
  84. label=strcat(dayLbl,'-', Exp(expN).Trace(trc).UsrGLB, dmStr,scnt); %scnt(bpInd));
  85. tickLabelStr{bpInd}=label;
  86. end
  87. catch
  88. end
  89. end
  90. end
  91. else % if 'single' or 'multi' experiment setup for DM trends
  92. maxRows=1; Lmax=1; bpInd=0;
  93. % for n=1:length(Exp(expN).Dexp) % Loop Thru Multi Experiments
  94. DexpN=Exp(expN).DexpN;
  95. for dm=1:length(Exp(expN).Dexp(DexpN).DM.drug) % LOOP Thru DM perturbations
  96. for trc=1:Exp(expN).traceN %length(Exp(expN).Trace)
  97. % tempLB=Exp(expN).Trace(trc).UsrGLB;
  98. try
  99. if isequal(get(Exp(expN).hOL(trc),'Visible'),'on')
  100. DexpN=Exp(expN).Trace(trc).DexpN;
  101. if iscell(Exp(expN).Trace(trc).Dexp(DexpN).DM(dm).UsrLvals)
  102. rows=length(cell2mat(Exp(expN).Trace(trc).Dexp(DexpN).DM(dm).UsrLvals));
  103. else
  104. rows=1;
  105. end
  106. if iscell(Exp(expN).Trace(trc).Dexp(DexpN).DM(dm).UsrLvals)
  107. if rows> maxRows, maxRows=rows; end
  108. LsmpMax=max(cell2mat(Exp(expN).Trace(trc).Dexp(DexpN).DM(dm).UsrLvals));
  109. else
  110. LsmpMax=max(Exp(expN).Trace(trc).Dexp(DexpN).DM(dm).UsrLvals);
  111. end
  112. if LsmpMax> Lmax, Lmax=LsmpMax; end
  113. bpInd=bpInd+1;
  114. end
  115. catch
  116. end
  117. end
  118. end
  119. % end <- to stop here
  120. maxCols=bpInd; % length(Exp(expN).Dexp) * length(Exp(expN).Trace)
  121. BPvals(1:maxRows,1:maxCols)=nan; % BoxPlot requires a matrix with uniform length even if data is not of the same length
  122. bpInd=0;
  123. for dm=1:length(Exp(expN).Dexp(DexpN).DM.drug) %LOOP Thru DM perturbations
  124. for trc=1:Exp(expN).traceN % length(Exp(expN).Trace)
  125. try
  126. if isequal(get(Exp(expN).hOL(trc),'Visible'),'on')
  127. DexpN=Exp(expN).Trace(trc).DexpN;
  128. bpInd=bpInd+1;
  129. if iscell(Exp(expN).Trace(trc).Dexp(DexpN).DM(dm).UsrLvals)
  130. kFiltrIndx=find((cell2mat(Exp(expN).Trace(trc).Dexp(DexpN).DM(dm).UsrKvals))<=kfiltLim);
  131. tmp=cell2mat(Exp(expN).Trace(trc).Dexp(DexpN).DM(dm).UsrLvals);
  132. BPvals(1:length(kFiltrIndx),bpInd)=tmp(kFiltrIndx);
  133. cnt=length(kFiltrIndx);
  134. %BPvals(1:length(cell2mat(Exp(expN).Trace(trc).Dexp(DexpN).DM(dm).UsrLvals)),bpInd)=cell2mat(Exp(expN).Trace(trc).Dexp(DexpN).DM(dm).UsrLvals);
  135. %cnt=length(cell2mat(Exp(expN).Trace(trc).Dexp(DexpN).DM(dm).UsrLvals));
  136. else
  137. if length(Exp(expN).Trace(trc).Dexp(DexpN).DM(dm).UsrLvals)> 1
  138. kFiltrIndx=find(((Exp(expN).Trace(trc).Dexp(DexpN).DM(dm).UsrKvals))<=kfiltLim);
  139. tmp=Exp(expN).Trace(trc).Dexp(DexpN).DM(dm).UsrLvals;
  140. BPvals(1:length(kFiltrIndx),bpInd)=tmp(kFiltrIndx);
  141. cnt=length(kFiltrIndx);
  142. else
  143. BPvals(1,bpInd)=Exp(expN).Trace(trc).Dexp(DexpN).DM(dm).UsrLvals;
  144. cnt=length(Exp(expN).Trace(trc).Dexp(DexpN).DM(dm).UsrLvals);
  145. end
  146. end
  147. % scnt(bpInd)={strcat('[',num2str(cnt),']')};
  148. scnt={strcat('[',num2str(cnt),']')};
  149. % Get Agar DrugMedia
  150. drug=Exp(expN).Dexp(DexpN).DM.drug{dm};
  151. conc=Exp(expN).Dexp(DexpN).DM.conc{dm};
  152. media=Exp(expN).Dexp(DexpN).DM.media{dm};
  153. mod1=Exp(expN).Dexp(DexpN).DM.mod1{dm}; if isnan(cell2mat(mod1)), mod1='';end
  154. conc1=Exp(expN).Dexp(DexpN).DM.conc1{dm}; if isnan(cell2mat(conc1)), conc1='';end
  155. mod2=Exp(expN).Dexp(DexpN).DM.mod2{dm}; if isnan(cell2mat(mod2)), mod2='';end
  156. conc2=Exp(expN).Dexp(DexpN).DM.conc2{dm}; if isnan(cell2mat(conc2)), conc2='';end
  157. dmStr=strcat(drug,'_',conc,'_',media,'_',mod1,conc1,mod2,conc2);
  158. % Extract expDay from ExpName string
  159. dayNpos=max(strfind(Exp(expN).Dexp(DexpN).ExpFoldr, '_D'));
  160. dayLbl=Exp(expN).Dexp(DexpN).ExpFoldr(dayNpos+1:end);
  161. if ~isempty(dayLbl), dayLbl=strcat(dayLbl,'_'); end
  162. label=strcat(dayLbl,Exp(expN).Trace(trc).UsrGLB, dmStr,scnt);
  163. tickLabelStr{bpInd}=label;
  164. end %if isequal(get(Exp(1).hOL(trc),'Visible'),'on')
  165. catch
  166. end
  167. end
  168. end
  169. %{
  170. if isequal(tempLB(4:6),'cmp')||isequal(tempLB(3:6),'cmpG'),
  171. RFcmpFlg=1;
  172. else
  173. RFcmpFlg=0;
  174. end
  175. %}
  176. end
  177. % Box Plot Plotting section
  178. if userPars.boxplotFlg==1
  179. BPoutliers=userPars.BPoutliers;
  180. BPnotch=userPars.BPnotch;
  181. sh=userPars.BPlblShft;
  182. fontSize=userPars.BPfontSz;
  183. rotation=userPars.BProt;
  184. % fontSize=8;
  185. % tickLabelStr={'Label alpha','Label beta','Label chi','Label delta',...
  186. %'Label epsilon','Label fish','Label gamma','Label hallo','Label ingo'}
  187. % generate data
  188. if size(BPvals,1)==1, BPvals(2,1:maxCols)=nan; end
  189. final_res=BPvals; %10*randn(300,9)+10;
  190. % group boxes
  191. % sh=0.3; %sh is shift value
  192. width=.5*sh;
  193. % pos=[1+sh 2-sh 3+sh 4-sh 5+sh 6-sh 7+sh 8-sh 9+sh];
  194. bpn=1;
  195. if strcmp(Exp(expN).DexpType, 'chrono')
  196. ticDim=length(Exp(expN).Dexp);
  197. else
  198. ticDim=length(Exp(expN).Dexp(DexpN).DM.drug);
  199. end
  200. for dim=1:ticDim % LOOP Thru DM perturbations
  201. shn=0;
  202. for trc=1:Exp(expN).traceN % length(Exp(expN).Trace)
  203. if isequal(get(Exp(expN).hOL(trc),'Visible'),'on')
  204. pos(bpn)=dim + (shn*sh);
  205. shn=shn+1;
  206. bpn=bpn+1;
  207. end
  208. end
  209. end
  210. wid=width * ones(1,length(pos));
  211. % boxplot
  212. figure
  213. set(gcf,'OuterPosition',(get(0,'screensize')))
  214. if strcmpi(BPnotch,'on')
  215. boxplot(final_res, ...
  216. 'notch', 'on', ...
  217. 'positions', pos,...
  218. 'widths', wid)
  219. elseif strcmpi(BPnotch,'off'),
  220. boxplot(final_res, ...
  221. 'notch', 'off', ...
  222. 'positions', pos,...
  223. 'widths', wid)
  224. end
  225. % label, change fontsize
  226. % y-axis
  227. set(gca, 'FontSize', fontSize)
  228. ylim([-.5 (Lmax+10)])
  229. ylabel('L in Hours', 'FontSize', fontSize)
  230. % x-labels
  231. text_h=findobj(gca, 'Type', 'text');
  232. % rotation=45;
  233. for cnt=1:length(text_h)
  234. set(text_h(cnt), ...
  235. 'FontSize', fontSize,...
  236. 'Rotation', rotation, ...
  237. 'String', tickLabelStr{length(tickLabelStr)-cnt+1}, ...
  238. 'HorizontalAlignment', 'right')
  239. end
  240. % 'VerticalAlignment', 'cap', ...
  241. % Smaller box for axes, in order to un-hide the labels
  242. squeeze=0.2;
  243. left=0.02;
  244. right=1;
  245. bottom=squeeze;
  246. top=1-squeeze;
  247. set(gca, 'OuterPosition', [left bottom right top])
  248. % Remove outliers
  249. hout=findobj(gca,'tag','Outliers');
  250. for out_cnt=1 : length(hout)
  251. if strcmpi(BPoutliers,'on'),
  252. set(hout(out_cnt), 'Visible', 'on')
  253. elseif strcmpi(BPnotch,'off'),
  254. set(hout(out_cnt), 'Visible', 'off')
  255. end
  256. end
  257. end
  258. % Plot Overlay Code
  259. % Plot Overlay Of Trends For Chrono Or Drug-Media Permutations
  260. try
  261. lnwidth=str2num(Exp(4).plotPars{1});
  262. axisFontSz=str2num(Exp(4).plotPars{2});
  263. legFontSz=str2num(Exp(4).plotPars{3});
  264. markerSz=str2num(Exp(4).plotPars{4});
  265. catch
  266. lnwidth=4;
  267. axisFontSz=36;
  268. legFontSz=10;
  269. markerSz=5;
  270. end
  271. if userPars.boxplotFlg~=1 % PLOT OVERLAY OF TRENDS
  272. figure
  273. set(gcf,'OuterPosition',(get(0,'screensize')))
  274. if strcmp(Exp(expN).DexpType, 'chrono') % Chrono
  275. % Plot median values for each DAY of the selected Trace
  276. % (Gene-Specifics)using single DM of trace
  277. range=0;
  278. for trc=1:Exp(expN).traceN % length(Exp(expN).Trace)
  279. % trcInd=0;
  280. scnt='['; % Init for Sample Count String
  281. if isequal(get(Exp(expN).hOL(trc),'Visible'),'on')
  282. for n=1:length(Exp(expN).Dexp) % LOOP Thru DayExps
  283. tmp=[];
  284. try
  285. %if isequal(get(Exp(expN).hOL(trc),'Visible'),'on')
  286. dmSel=Exp(expN).Trace(trc).dmSel;
  287. if iscell(Exp(expN).Trace(trc).Dexp(n).DM(dmSel).UsrLvals)
  288. kFiltrIndx=find((cell2mat(Exp(expN).Trace(trc).Dexp(n).DM(dmSel).UsrKvals))<=kfiltLim);
  289. tmp=cell2mat(Exp(expN).Trace(trc).Dexp(n).DM(dmSel).UsrLvals);
  290. dayMed(trc,n)=median(tmp(kFiltrIndx)); % median(cell2mat(Exp(expN).Trace(trc).Dexp(n).DM(dmSel).UsrLvals));
  291. dayStd(trc,n)=std(tmp(kFiltrIndx)); % std(cell2mat(Exp(expN).Trace(trc).Dexp(n).DM(dmSel).UsrLvals));
  292. cnt=length(kFiltrIndx); % length(cell2mat(Exp(expN).Trace(trc).Dexp(n).DM(dmSel).UsrLvals));
  293. else
  294. kFiltrIndx=find(((Exp(expN).Trace(trc).Dexp(n).DM(dmSel).UsrKvals))<=kfiltLim);
  295. tmp=(Exp(expN).Trace(trc).Dexp(n).DM(dmSel).UsrLvals);
  296. dayMed(trc,n)=median(tmp(kFiltrIndx)); %median(Exp(expN).Trace(trc).Dexp(n).DM(dmSel).UsrLvals);
  297. dayStd(trc,n)=std(tmp(kFiltrIndx)); %std(Exp(expN).Trace(trc).Dexp(n).DM(dmSel).UsrLvals);
  298. cnt=length(kFiltrIndx); %length(Exp(expN).Trace(trc).Dexp(n).DM(dmSel).UsrLvals);
  299. end
  300. % Make LEGEND list
  301. % Make Sample Count Label item;
  302. if n~=length(Exp(expN).Dexp)
  303. scnt=strcat(scnt,num2str(cnt),',');
  304. else
  305. scnt=strcat(scnt,num2str(cnt),']');
  306. end
  307. %Get Agar DrugMedia;
  308. dm=Exp(expN).Trace(trc).dmSel;
  309. drug=Exp(expN).Dexp(n).DM.drug{dm};
  310. conc=Exp(expN).Dexp(n).DM.conc{dm};
  311. media=Exp(expN).Dexp(n).DM.media{dm};
  312. mod1=Exp(expN).Dexp(n).DM.mod1{dm};
  313. conc1=Exp(expN).Dexp(n).DM.conc1{dm};
  314. mod2=Exp(expN).Dexp(n).DM.mod2{dm};
  315. conc2=Exp(expN).Dexp(n).DM.conc2{dm};
  316. dmStr=strcat(drug,'_',conc,'_',media,'_',mod1,conc1,mod2,conc2);
  317. NmLst(trc)=strcat(Exp(expN).Trace(trc).UsrGLB, dmStr,scnt);
  318. %Determine Actual Exp Day from the ExpDay folder
  319. loc=strfind(Exp(expN).Dexp(n).ExpFoldr,'_D');
  320. daystr=Exp(expN).Dexp(n).ExpFoldr((loc+2):end);
  321. dayNums(n)=str2num(daystr);
  322. %trcInd=trcInd+1;
  323. catch
  324. end
  325. try
  326. upperStd(trc,n)=dayMed(trc,n) + dayStd(trc,n);
  327. lowerStd(trc,n)=dayMed(trc,n) - dayStd(trc,n);
  328. catch
  329. end
  330. end
  331. % end
  332. % Plot Trend Data
  333. % if isequal(get(Exp(expN).hOL(trc),'Visible'),'on')
  334. try
  335. if iscell(Exp(expN).Trace(trc).Dexp(n).DM(dmSel).UsrLvals)
  336. hTrendFig=plot(dayNums,dayMed(trc,1:n),'lineWidth',2); hold on
  337. linecolor(trc)={get(hTrendFig,'color')};
  338. else
  339. clear NmLstStr
  340. if iscell(NmLst(trc)),NmLstStr=cell2mat(NmLst(trc)); else NmLstStr=NmLstStr(trc); end
  341. if isequal(NmLstStr(4:6),'cmp') ||
  342. || isequal(NmLstStr(3:6),'cmpG') ...
  343. || isequal(NmLstStr(3:6),'cmpP')
  344. hTrendFig=plot(dayNums,dayMed(trc,1:n),'lineWidth',2); hold on
  345. linecolor(trc)={get(hTrendFig,'color')};
  346. else
  347. hTrendFig=plot(dayNums,dayMed(trc,1:n),'marker','^','lineWidth',2); hold on
  348. linecolor(trc)={get(hTrendFig,'color')};
  349. end
  350. % yTicks=get(gca,'yTickLabel'); Ydelta=max(max(yTicks))-min(min(yTicks));
  351. % spacing=Ydelta* 0.0034; %line spacing for STD marker
  352. end
  353. catch
  354. hTrendFig=plot(1:n,dayMed(trc,1:n),'lineWidth',2); hold on
  355. linecolor(trc)={get(hTrendFig,'color')};
  356. ylabel('Experiment Day Index')
  357. end
  358. end
  359. grid on
  360. % set(gca,'linewidth',4) %0.5 then 1.5 now 6
  361. % set(gca,'fontsize',axisFontSz) % 8 to 15 to 21
  362. hold all
  363. try % if isequal(get(Exp(expN).hOL(trc),'Visible'),'on')
  364. tmpRange=ceil(max(upperStd(trc,1:end))) - floor(min(lowerStd(trc,1:end)));
  365. range=max(range,tmpRange);
  366. catch, end
  367. end
  368. % Standard Deviation range bars
  369. % range=ceil(max(upperStd(trc,1:end))) - floor(min(lowerStd(trc,1:end)));
  370. spacing=range*0.0034; %marker splacing for building range bars
  371. for trc=1:Exp(expN).traceN %length(Exp(expN).Trace)
  372. if isequal(get(Exp(expN).hOL(trc),'Visible'),'on')
  373. for n=1:length(Exp(expN).Dexp) %LOOP Thru DayExps
  374. if isequal(get(Exp(expN).hOL(trc),'Visible'),'on')
  375. try
  376. line(dayNums(n),lowerStd(trc,n):spacing:(dayMed(trc,n)-.05),'marker','^','LineWidth',1,'markerEdgeColor',cell2mat(linecolor(trc))); hold on
  377. line(dayNums(n),(dayMed(trc,n)+0.05):spacing:upperStd(trc,n),'marker','v','LineWidth',1,'markerEdgeColor',cell2mat(linecolor(trc))); hold on
  378. catch
  379. % line(n,lowerStd(trc,n):0.05:(dayMed(trc,n)-.1),'marker','^','LineWidth',1,'markerEdgeColor',cell2mat(linecolor(trc))); hold on
  380. % line(n,(dayMed(trc,n)+0.1):0.05:upperStd(trc,n),'marker','v','LineWidth',1,'markerEdgeColor',cell2mat(linecolor(trc))); hold on
  381. end
  382. end
  383. end
  384. end
  385. end
  386. % legName=strrep(NmLst,'_','-');
  387. mm=1;
  388. for nn=1:length(NmLst)
  389. if iscellstr(NmLst(nn))
  390. legName(mm)=strrep(NmLst(nn),'_','-');
  391. mm=mm+1;
  392. end
  393. end
  394. legName=strrep(legName,'/','-');
  395. hleg=legend((legName),'location','NEO');
  396. set(hleg,'fontsize',legFontSz)
  397. end
  398. xlabel('Days')
  399. ylabel('L in Hours')
  400. title('Chronological Trend Plot with Standard Deviations')
  401. hold off
  402. % Single or Multi Experiment
  403. if ~strcmp(Exp(expN).DexpType, 'chrono') %Single or Multi-Experiment
  404. % Plot median values for each DM of the selected Trace (Gene-DM)
  405. % (Gene-Specifics)using single DAY of trace
  406. for trc=1:Exp(expN).traceN %length(Exp(expN).Trace)
  407. trcInd=0;
  408. DexpN=Exp(expN).Trace(trc).DexpN;
  409. expFolder=Exp(expN).Dexp(DexpN).ExpFoldr;
  410. if ispc
  411. lastSlash=max(strfind(Exp(expN).Dexp(DexpN).ExpFoldr, '\'));
  412. else
  413. lastSlash=max(strfind(Exp(expN).Dexp(DexpN).ExpFoldr, '/'));
  414. end
  415. expName=expFolder(lastSlash+1:end);
  416. if length(expName)>18
  417. expNm=strcat('-',expName(1:18));
  418. else
  419. expNm=strcat('-',expName);
  420. end
  421. scnt='['; %Init for Sample Count String
  422. for n=1:length(Exp(expN).Dexp(DexpN).DM.drug) %LOOP Thru Drug-Media perturbations
  423. tmp=[];
  424. if isequal(get(Exp(expN).hOL(trc),'Visible'),'on')
  425. if iscell(Exp(expN).Trace(trc).Dexp(DexpN).DM(n).UsrLvals)
  426. kFiltrIndx=find((cell2mat(Exp(expN).Trace(trc).Dexp(DexpN).DM(n).UsrKvals))<=kfiltLim);
  427. tmp=(cell2mat(Exp(expN).Trace(trc).Dexp(DexpN).DM(n).UsrLvals));
  428. dmMed(trc,n)=median(tmp(kFiltrIndx)); %median(cell2mat(Exp(expN).Trace(trc).Dexp(DexpN).DM(n).UsrLvals));
  429. dmStd(trc,n)=std(tmp(kFiltrIndx)); %std(cell2mat(Exp(expN).Trace(trc).Dexp(DexpN).DM(n).UsrLvals));
  430. cnt=length(kFiltrIndx); %length(cell2mat(Exp(expN).Trace(trc).Dexp(DexpN).DM(n).UsrLvals));
  431. else
  432. kFiltrIndx=find(((Exp(expN).Trace(trc).Dexp(DexpN).DM(n).UsrKvals))<=kfiltLim);
  433. tmp=((Exp(expN).Trace(trc).Dexp(DexpN).DM(n).UsrLvals));
  434. dmMed(trc,n)=median(tmp(kFiltrIndx)); %median(Exp(expN).Trace(trc).Dexp(DexpN).DM(n).UsrLvals);
  435. dmStd(trc,n)=std(tmp(kFiltrIndx)); %std(Exp(expN).Trace(trc).Dexp(DexpN).DM(n).UsrLvals);
  436. cnt=length(kFiltrIndx); %length(Exp(expN).Trace(trc).Dexp(DexpN).DM(n).UsrLvals);
  437. end
  438. % Make Legend list
  439. % Make Sample Count Label item
  440. if n~=length(Exp(expN).Dexp(DexpN).DM.drug)
  441. scnt=strcat(scnt,num2str(cnt),',');
  442. else
  443. scnt=strcat(scnt,num2str(cnt),']');
  444. end
  445. % Get Agar DrugMedia
  446. drug=Exp(expN).Dexp(DexpN).DM.drug{n};
  447. conc=Exp(expN).Dexp(DexpN).DM.conc{n};
  448. media=Exp(expN).Dexp(DexpN).DM.media{n};
  449. mod1=Exp(expN).Dexp(DexpN).DM.mod1{n};
  450. conc1=Exp(expN).Dexp(DexpN).DM.conc1{n};
  451. mod2=Exp(expN).Dexp(DexpN).DM.mod2{n};
  452. conc2=Exp(expN).Dexp(DexpN).DM.conc2{n};
  453. dmStr=strcat(drug,'_',conc,'_',media,'_',mod1,conc1,mod2,conc2);
  454. NmLst(trc)=strcat(Exp(expN).Trace(trc).UsrGLB, expNm,scnt);
  455. trcInd=trcInd+1;
  456. upperStd(trc,n)=dmMed(trc,n) + dmStd(trc,n);
  457. lowerStd(trc,n)=dmMed(trc,n) - dmStd(trc,n);
  458. end
  459. end
  460. % Plot Trend Data
  461. if isequal(get(Exp(expN).hOL(trc),'Visible'),'on')
  462. if iscell(Exp(expN).Trace(trc).Dexp(DexpN).DM(n).UsrLvals)
  463. hTrendFig=plot(1:n,dmMed(trc,1:n),'lineWidth',2); hold on
  464. linecolor(trc)={get(hTrendFig,'color')};
  465. else
  466. clear NmLstStr
  467. if iscell(NmLst(trc)),NmLstStr=cell2mat(NmLst(trc)); else NmLstStr=NmLst(trc); end
  468. if isequal(NmLstStr(4:6),'cmp'), ...
  469. || isequal(NmLstStr(3:6),'cmpG'), ...
  470. || isequal(NmLstStr(3:6),'cmpP')
  471. hTrendFig=plot(1:n,dmMed(trc,1:n),'lineWidth',2); hold on
  472. linecolor(trc)={get(hTrendFig,'color')};
  473. else
  474. hTrendFig=plot(1:n,dmMed(trc,1:n),'marker','^','lineWidth',2); hold on
  475. linecolor(trc)={get(hTrendFig,'color')};
  476. end
  477. end
  478. % yTicks=get(gca,'yTickLabel'); Ydelta=max(max(yTicks))-min(min(yTicks));
  479. % spacing=Ydelta* 0.0034; %line spacing for STD marker
  480. end
  481. grid on
  482. % set(gca,'linewidth',4) %0.5 then 1.5 now 6
  483. % set(gca,'fontsize',axisFontSz) % 8 to 15 to 21
  484. hold all
  485. end
  486. % Standard Deviation range bars
  487. % range=ceil(max(max(upperStd))) - floor(min(min(lowerStd)));
  488. range=ceil(max(upperStd(trc,1:end))) - floor(min(lowerStd(trc,1:end)));
  489. spacing=range*0.0034;
  490. for trc=1:Exp(expN).traceN %length(Exp(expN).Trace)
  491. for n=1:length(Exp(expN).Dexp(DexpN).DM.drug) %LOOP Thru Drug-Media perturbations
  492. if isequal(get(Exp(expN).hOL(trc),'Visible'),'on')
  493. try
  494. line(n,lowerStd(trc,n):spacing:(dmMed(trc,n)-.05),'marker','^','LineWidth',1,'markerEdgeColor',cell2mat(linecolor(trc))); hold on
  495. line(n,(dmMed(trc,n)+0.05):spacing:upperStd(trc,n),'marker','v','LineWidth',1,'markerEdgeColor',cell2mat(linecolor(trc))); hold on
  496. catch
  497. end
  498. end
  499. end
  500. end
  501. mm=1;
  502. for nn=1:length(NmLst)
  503. if iscellstr(NmLst(nn))
  504. legName(mm)=strrep(NmLst(nn),'_','-');
  505. mm=mm+1;
  506. end
  507. end
  508. legName=strrep(legName,'/','-');
  509. hleg=legend((legName),'location','NEO');
  510. set(hleg,'fontsize',legFontSz)
  511. xlabel('Drug-Media Index')
  512. ylabel('L in Hours')
  513. title('Drug-Media Trend Plot with Standard Deviations')
  514. hold off
  515. end
  516. hold off
  517. end %if userPars.boxplotFlg~=1 %PLOT OVERLAY OF TRENDS 266