diff --git a/Legacy Code/plotter_model_5.m b/Legacy Code/plotter_model_5.m deleted file mode 100644 index a6e5f8c..0000000 --- a/Legacy Code/plotter_model_5.m +++ /dev/null @@ -1,260 +0,0 @@ -%% -% /--------------------------------------------------------------\ -% | Date: 04/04/2019 | -% | Author: Jonathan Cody | -% | Affiliation: Purdue University | -% | Weldon School of Biomedical Engineering | -% | Pienaar Computational Systems Pharmacology Lab | -% \--------------------------------------------------------------/ - -close all -clear all %#ok - -%% ======================================================================== -% INPUT -% ======================================================================== - -%% ------------------------------------------------------------------------ -% General Inputs -% ------------------------------------------------------------------------ - -D = load('DATA') ;% N803 project data file - -xconv = 1/7 ;% x-axis tick conversion -xunits = 'Weeks Post-Treatment' ;% x-axis labels -Yunits = D.Yu ;% y-axis labels for main outputs - -suffix = 't1_all' ;% suffix for output filenames -ext = 'jpg' ;% file extension for figure files - -extra = 1 ;% 1 = plot extended outputs - % 0 = plot calibrated outputs only -legspace = 21 ;% extra xunits to append to figures - % (allows space for legend) - -manualpars = 1 ;% 1 = enter pars manually (see section) - % 0 = retrieve pars from calibrator.m file - -% Docking all plotted figures -set(0,'DefaultFigureWindowStyle','docked') % comment out to undock figures - -%% ------------------------------------------------------------------------ -% calibrator.m Parameter Inputs -% ------------------------------------------------------------------------ - -PlotRanks = 1:2 ;% run(s) in data file to plot (as ranked in C) -tend = 315 ;% ending time point for plotting results - -COLORS = {[1 0 0]*0.8,[1 1 0]*0.8,[0 1 0]*0.8,... - [0 1 1]*0.8,[0 0 1]*0.8,[1 0 1]*0.8,}; - -% I use this line when plotting pairs of parameter sets from calibrator.m -% COLORS = {COLORS{PlotRanks(1)},COLORS{PlotRanks(2)}} ; - -%% ------------------------------------------------------------------------ -% Manual Parameter Inputs (arbitrary) -% ------------------------------------------------------------------------ - -monkey = 2 ;% monkey -for n = 1:4 - X{n} = D.X_ellis3{n}(monkey) ; %#ok<*SAGROW> - Y{n} = D.Y_ellis3{n}(monkey) ; - IC(n,1) = mean(Y{n}{1}(1:5)) ; -end - -tt = -28:0.1:105 ;% model x-values (before conversion) - -% model handle -plotmodel = @(P) HIV_model_5(tt,D.td,P,[],[]) ; - -P = zeros(43,4) ;% percolating parameter matrix - -% Initial Conditions -P([01:03 39],:) = [IC(1:4) IC(1:4) IC(1:4) IC(1:4)] ;% V,(R+A+E),K,T i.c. - -% Pharmacokinetic Parameters -P(04,:) = P(04,:) + 877 ;% injection site i.c. [pmol/kg] -P(05,:) = P(05,:) + 0.75 ;% absorption rate const. [/d] -P(06,:) = P(05,:) / 1.64 ;% P(05)*'bioavail.'/'vol. of dist.' [kg/L-d] -P(07,:) = P(07,:) + 2.1 ;% elimination rate const. [/d] - -% Pharmacodynamic Parameters -P(08,:) = [1 1 1 1]*3.5 ;% drug half saturation [pM] -P(09,:) = [1 1 1 1]*0.7 ;% Rc 1/(delay time constant) [/d] -P(10,:) = [1.5 1.5 2 2] ;% Sc " -P(11,:) = [10 10 10 10] ;% Rc number of delay chambers [] -P(12,:) = [1 1 1 1] ;% Sc " -P(13,:) = [1 1 1 1]*0.95 ;% R receptor effect modifier [] -P(14,:) = [1 1 1 1]*1.2 ;% E " -P(15,:) = [1 1 1 1]*1.4 ;% K " - -% Parameters governing R,K proliferation and death -P(16,:) = [1 1 1 1]*18e-3 ;% R death rate constant [/d] -P(17,:) = [1 1 1 1]*66e-3 ;% K " -P(18,:) = [1 1 1 1]*870 ;% R max proliferating concentration [/µL] -P(19,:) = [1 1 1 1]*370 ;% K " -P(20,:) = [1 1 1 1]*1.3 ;% R drug-induced proliferation factor [/d] -P(21,:) = [1 1 1 1]*1.95 ;% K " -P(22,:) = [1 2 1 2]*0.34 ;% R population suppression factor [/d] -P(23,:) = [1 2 1 2]*0.205 ;% K " - -% Parameters governing R activation & E,K killing -P(24,:) = [1 1 1 1]*1e-7 ;% R activation rate constant [/d] -P(25,:) = [1 1 1 1]*0 ;% E initial killing rate (a_E * E_0) [/d] -P(26,:) = [1 1 1 1]*0 ;% K " -P(27,:) = [1 1 1 1]*1e-7 ;% R drug-induced activation factor [/d] -P(28,:) = [1 1 1 1]*0 ;% E drug-induced killing factor [µL/d] -P(29,:) = [1 1 1 1]*0 ;% K " -P(30,:) = [1 1 1 1]*0 ;% R activation suppression factor [] -P(31,:) = [1 1 1 1]*0 ;% E killing suppression factor [] -P(32,:) = [1 1 1 1]*0 ;% K " -P(33,:) = [1 1 1 1]*0 ;% R half-activation virus conc. [/µL] - -% Parameters governing CD8+ T cell clonal expansion and retraction -P(34,:) = [1 1 1 1]*0.1 ;% A death rate constant [/d] -P(35,:) = [1 1 1 1]*2.9 ;% A division rate constant [/d] -P(36,:) = [1 1 1 1]*8 ;% A number of divisions [] -P(37,:) = [1 1 1 1]*0.33 ;% E death rate constant [/d] -P(38,:) = [1 1 1 1]*0 ;% E deactivation rate constant [/d] - -% Parameters governing CD4+ T cells -P(40,:) = [0 0 0 0] ;% T death rate constant [/d] -P(41,:) = [1 1 1 1] ;% T max proliferating concentration [/µL] -P(42,:) = [0 0 0 0] ;% T infection rate constant [/µL-d] -P(43,:) = [0 0 0 0] ;% infected T decay rate constant [*(P(40)] - -% Declare parameter table labels and values -ParLabels = strsplit(num2str(1:size(P,1))) ; -ParMatrix = P ; -RowLabels = {'red';'yellow';'green';'cyan';'blue';'magenta'} ; - -%% ======================================================================== -% BODY -% ======================================================================== - -%% ------------------------------------------------------------------------ -% Setup -% ------------------------------------------------------------------------ - -% If calibrator output file parameters are used... -if manualpars == 0 - - % Load structure file to structure variable 'C' - load(['C_' suffix],'C') ; - - % Define time points to evaluate model - tt = [C(1).setup.Xeval ; ((C(1).setup.Xeval(end)+1):tend)'] ; - plotmodel = @(P) C(1).setup.modelfun(tt,P) ; - - % Load parameter sets into cell array 'P' - P = ones(length(C(1).Parameters),length(PlotRanks)) ; - for n = 1:length(PlotRanks) - P(:,n) = (C(PlotRanks(n)).Parameters)' ; - end - - % Define data to plot against - X = C(1).setup.X ; - Y = C(1).setup.Y ; -end - -% Load model outputs (see model file) into cell arrays 'YM' and 'YE' -YM = cell(1,size(P,2)) ; -YE = cell(1,size(P,2)) ; -for n = 1:size(P,2) - [YM{n},YE{n}] = plotmodel(P(:,n)) ;% model solution -end - -%% ------------------------------------------------------------------------ -% Plotter -% ------------------------------------------------------------------------ - -tt = tt*xconv ;% converting x-axis - -% Plot main outputs -gap = 0.02 ;% gap between subplots -margs = [0.02 0.07 0.07 0.02] ;% top, bottom, left, right margins -axheight = (1-sum(margs(1:2))-3*gap)/4 ;% axis height -ypos = 1 - margs(1) - axheight ;% axis y position - -name = ['Fullplot ' suffix ' part 1'] ; -F = figure('Name',name,'Color',[1 1 1]) ; -for n = 1:3 - axes('Units','normalized','Position',... - [margs(3) ypos 1-sum(margs(3:4)) axheight]) - ypos = ypos - axheight - gap ; - hold on - for m = 1:length(Y{n}) - plot(X{n}{m}*xconv,Y{n}{m},':o',... - 'MarkerSize',4,'MarkerFaceColor','k','MarkerEdgeColor','k') - end - for m = 1:length(YM) - plot(tt,YM{m}(:,n),'Color',COLORS{m},'LineWidth',1.5) - end - axis([tt(1) tt(end) 0+(n==1) inf]) - ylabel(Yunits{n}) - set(gca,'FontSize',10,'FontName','Arial','LineWidth',1) - set(gca,'XTickLabel',[],'XTick',tt(1):1:tt(end)) - grid on -end -set(gca,'XTickLabel',tt(1):2:tt(end),'XTick',tt(1):2:tt(end)) -xlabel(xunits) - -% Plotting table of parameters for manual calibration -if manualpars == 1 - uitable('Data',num2cell(ParMatrix'),'ColumnName',ParLabels,... - 'Units','normalized','FontSize',10,'RowName',RowLabels,... - 'Position',[margs(3) ypos 1-sum(margs(3:4)) axheight-0.04]) ; -else - -end - -saveas(F,name,ext) - -if extra == 1 -% Plot extended outputs -gap = 0.02 ;% gap between subplots -margs = [0.02 0.07 0.07 0.02] ;% top, bottom, left, right margins -axheight = (1-sum(margs(1:2))-4*gap)/5 ;% axis height -ypos = 1 - margs(1) - axheight ;% axis y position - -i = 1 ;% index -j = 0 ;% index -for n = 1:length(YE{1}) - j = j + 1 ; - if j == 1 - i = i + 1 ; - name = ['Fullplot ' suffix ' part ' num2str(i)] ; - if manualpars == 0 - name = [name ' rank ' num2str(PlotRanks)]; %#ok - end - F = figure('Name',name,'Color',[1 1 1]) ; - end - leg = cell(1,size(YE{1}{n},1)) ; - axes('Units','normalized','Position',... - [margs(3) ypos 1-sum(margs(3:4)) axheight]) - ypos = ypos - axheight - gap ; - hold on - for m = 1:length(YE) - for o = 1:size(YE{1}{n},1) - plot(tt,YE{m}{n}{o,1},'Color',COLORS{m},... - 'LineStyle',YE{m}{n}{o,2},'LineWidth',1.5) - leg{o} = YE{m}{n}{o,3} ; - end - end - axis([-1 tt(end)+legspace*xconv -inf inf]) - ylabel(YE{1}{n}{1,4}) - legend(leg,'Location','east','FontSize',9) - set(gca,'XTickLabel',[],'XTick',tt(1):1:tt(end)) - set(gca,'FontSize',11,'FontName','Arial','LineWidth',1) - grid on - if j == 5 - j = 0 ; - ypos = 1 - margs(1) - axheight ; - xlabel(xunits) - set(gca,'XTickLabel',tt(1):1:tt(end)) - saveas(F,name,ext) - end -end -saveas(F,name,ext) -end -disp('Done!')