function populationSunitinibFits plotSunitinibData groupColors = [0 0 0; 0 0 255; 255 0 0;0 206 209;255 165 0 ; 0 0 255; 199 21 133]/255; colTIME = [unique(G1(:,2));unique(G3(:,2))]; %% Calculate with Means % colG1 = nanmean(G1ind(:,:,3),1)'; % colG3 = nanmean(G3ind(:,:,3),1)'; %% Calculate with Medians colG1 = nanmedian(G1ind(:,:,3),1)'; colG3 = nanmedian(G3ind(:,:,3),1)'; varG1 = nanstd(G1ind(:,:,3),1)'; varG3 = nanstd(G3ind(:,:,3),1)'; D0 = 1.76; K0 = 7.43; lambda0 = 1.02; bb0 = 0.00168; ps = 2.12; betas = 0.0237; b0 = [D0 K0 lambda0 bb0 ps betas]; Y = [colG1;colG3]; yhat = runModelSutent(b0,colTIME); close all hFig = figure; % Set Figure Properties hold all fontSize = 26; set(gcf,'defaultlinelinewidth',1,'DefaultAxesFontSize', fontSize,'DefaultAxesFontName', 'Times') set(gca,'fontsize',fontSize,'fontname','times') set(hFig, 'Position', [10 800 1000 560]) set(gca,'XTick',[0:20:100]) set(gca,'yTick',[0:2:16]) subplot(2,4,[1 2 5 6]) hold all h(1) = plot(colTIME(1:19),yhat(1:19),'-','color',groupColors(1,:),'LineWidth',4); h(2) = plot(colTIME(1:19),colG1,'ko','LineWidth',2,... 'Color','k','MarkerEdgeColor','k','MarkerFaceColor','k','MarkerSize',8); h(3) = plot(colTIME(20:46),yhat(20:46),'--','color',groupColors(2,:),'LineWidth',4); h(4) = plot(colTIME(20:46),colG3,'ko','LineWidth',2,... 'Color',groupColors(2,:),'MarkerEdgeColor','k','MarkerFaceColor',groupColors(2,:),'MarkerSize',8); legend([h(1) h(3)], {'G1 : Control','G2 : Sunitinib'},'location','northwest'); axis square xlabel('Time (days)') ylabel('Mean Tumor Diameter (mm)') ylim([0 16]) xa = [41 37]; % X-CooFrdinates in data space ya = [6.5 7.8]; % Y-Coordinates in data space [xaf,yaf] = ds2nfu(xa,ya); %Convert to normalized figure units annotation('textarrow',xaf,yaf,'string','Day 0 ','fontweight','bold',... 'fontsize',fontSize,'headwidth',14,'headlength',14,'fontName','times') % Run VPC code cd('./SunitinibVPC/code') generateVPCs end function yhat = runModelSutent(beta,x) V0 = beta(1); K0 = beta(2); lambda = beta(3); b = beta(4); ps = beta(5); betas = beta(6); treattime = 37; x1 = x(1:19,1); % Time values G1 x3 = x(20:46,1); % Time values G3 S0 = [0 V0 K0]; param = [lambda;... b;... ps;... betas]; tspan = [0 treattime]; options_ode15s=odeset('Vectorized','{on,on}'); G = deval(ode15s(@modelSutent,tspan,S0,options_ode15s,param)',x1(x1<=tspan(end))); GSPAN = deval(ode15s(@modelSutent,tspan,S0,options_ode15s,param)',tspan(end)); YY1 = G(1,:); Y1end = GSPAN(1,end); YY2 = G(2,:); Y2end = GSPAN(2,end); YY3 = G(3,:); Y3end = GSPAN(3,end); ttime = treattime; % For group 1 tspan = [ttime ceil(x1(end))]; if tspan(1) ~= tspan(2) S0 = [Y1end ; Y2end ; Y3end]; H = deval(ode15s(@modelSutent,tspan,S0,options_ode15s,param)',x1(x1>tspan(1))); Y1 = cat(2,YY1,H(1,1:end)); Y2 = cat(2,YY2,H(2,1:end)); Y3 = cat(2,YY3,H(3,1:end)); end yhat = Y2'; % For group 3 S0 = [0 V0 K0]; tspan = [0 treattime]; G = deval(ode15s(@modelSutent,tspan,S0,options_ode15s,param)',x3(x3<=tspan(end))); GSPAN = deval(ode15s(@modelSutent,tspan,S0,options_ode15s,param)',tspan(end)); YY1 = G(1,:); Y1end = GSPAN(1,end); YY2 = G(2,:); Y2end = GSPAN(2,end); YY3 = G(3,:); Y3end = GSPAN(3,end); ttime = treattime; nbcures = 12; for j=1:nbcures-1 ttime = treattime-1+j; tspan = [treattime-1+j treattime+j]; S0 = [Y1end+1 ; Y2end ; Y3end]; time1 = x3(x3>tspan(1)); time2 = x3(x3<=tspan(end)); timei = intersect(time1,time2); if ~isempty(timei) H = deval(ode15s(@modelSutent,tspan,S0,options_ode15s,param)',timei); HSPAN = deval(ode15s(@modelSutent,tspan,S0,options_ode15s,param)',tspan(end)); Y1 = cat(2,YY1,H(1,:)); Y1end = HSPAN(1,end); Y2 = cat(2,YY2,H(2,:)); Y2end = HSPAN(2,end); Y3 = cat(2,YY3,H(3,:)); Y3end = HSPAN(3,end); YY1 = Y1; YY2 = Y2; YY3 = Y3; end HSPAN = deval(ode15s(@modelSutent,tspan,S0,options_ode15s,param)',tspan(end)); Y1end = HSPAN(1,end); Y2end = HSPAN(2,end); Y3end = HSPAN(3,end); end ttime = 48; tspan = [48 ceil(x3(end))]; if tspan(1) ~= tspan(2) S0 = [Y1end+1 ; Y2end ; Y3end]; H = deval(ode15s(@modelSutent,tspan,S0,options_ode15s,param)',x3(x3>tspan(1))); Y1 = cat(2,YY1,H(1,1:end)); Y2 = cat(2,YY2,H(2,1:end)); Y3 = cat(2,YY3,H(3,1:end)); end yhat = cat(1,yhat,Y2'); end function dSdt = modelSutent(t,S,param) lambda = param(1); b = param(2); kde = param(3); beta = param(4); C = S(1); V = S(2); K = S(3); alfa = 0.1; dCdt = -kde*C; dVdt = lambda*V*(1-((V/K)^alfa)); dKdt = b*(V^2) - beta*kde*C*K; dSdt = [dCdt; dVdt; dKdt]; end function [varargout] = nlinfitsome(fixed,x,y,fun,beta0,varargin) % This function was downloaded from MATHWORKS (www.mathworks.com) % "fixed" indicates which values of beta0 should not change % Get separate arrays of coefficients to fix and to estimate bfixed = beta0(fixed); beta0 = beta0(~fixed); % Estimate only the non-fixed ones [varargout{1:max(1,nargout)}] = nlinfit(x,y,@localfit,beta0,varargin{:}); % Re-create array combining fixed and estimated coefficients b(~fixed) = varargout{1}; b(fixed) = bfixed; varargout{1} = b; % Nested function takes just the parameters to be estimated as inputs % It inherits the following from the outer function: % fixed = logical index for fixed elements % bfixed = fixed values for these elements function y=localfit(beta,x) b(fixed) = bfixed; b(~fixed) = beta; y = fun(b,x); end end