From 88e9c183fd41b05808e214517e54a267d61c5ebb Mon Sep 17 00:00:00 2001 From: "Cody, Jonathan William" Date: Sun, 25 Dec 2022 09:00:22 -0600 Subject: [PATCH] Delete HIV_stats.m --- Legacy Code/HIV_stats.m | 186 ---------------------------------------- 1 file changed, 186 deletions(-) delete mode 100644 Legacy Code/HIV_stats.m diff --git a/Legacy Code/HIV_stats.m b/Legacy Code/HIV_stats.m deleted file mode 100644 index 6f86bbb..0000000 --- a/Legacy Code/HIV_stats.m +++ /dev/null @@ -1,186 +0,0 @@ -% -% /-------------------------------------------------------\ -% | Date: 5/25/2018 | -% | Author: Jonathan Cody | -% | Institution: Purdue University | -% | Weldon School of Biomedical Engineering | -% | Pienaar Lab | -% \-------------------------------------------------------/ -% -% Plots statistics and results from 'calibrator.m' -% -% NOTE: Lines flagged are data specific. Comment out for general use! -% -% INPUTS ================================================================== -% -% suf = suffix for C file containing results of 'calibrator' -% (should be same 'suf' used in 'calibrator') -% Ns = parameter sets to summarize -% (i.e. Ns = 1:50 to summarize top 50) -% out = output selector (see OUTPUTS) -% ext = save file extension for figures -% (i.e. 'fig','jpg', etc. -% -% OUTPUTS ================================================================= -% -% out = [1 0 0 0] = plots of model against calibration data -% [0 1 0 0] = plots of model bias w.r.t. calibration data -% [0 0 1 0] = histograms of model cost and parameters -% [0 0 0 1] = RCC table of model cost and parameters -% [X X X X] = any combination of the above outputs -% -% CALCULATIONS ============================================================ - -function HIV_stats(suf,Ns,out,ext) - -warning('off') -C = load(['C' suf]) ;% output data structure -D = C.D ;% calibration data structure -load('EllisConnell2018F3.mat') % -S = size(D,2) ;% number of species -warning('on') - -for n = 1:S - ts(n) = D(n).t(1) ;% start time for each species - te(n) = D(n).t(end) ;% end time for each species -end -tt = min(ts):1:max(te) ;% time points to evaluate model -td = D(1).td ;% time points for doses - -for n = Ns - [Ym,~,Pa] = C.mod(tt,td,C.P(n,:)) ;% all parameters for run 'n' - for m = 1:S - y = interp1(tt,Ym(:,m),D(m).t) ; - Yo{m}(n,:) = Ym(:,m) ;% model output - Yb{m}(n,:) = mean(y - D(m).Y) ;% model bias - Yc(n,m) = C.cf{m}(y,D(m).Y)... - *C.W(m)/sum(C.W) ;% model species cost contribution - end - for m = 1:size(Pa,1) - lPa(n,m) = log10(Pa{m,2}) ;% all parameters (log-scale) - end -end - -set(0,'DefaultFigureWindowStyle','docked') - -if out(1) % plots of model against calibration data ----------------------- - -F = figure('Name',['Plots' suf],'Color',[1 1 1]) ; -mark = { ':o' ':^' ':s' ':d' ':p' ':h' ':+' ':x' ':*' } ; -for m = 1:S - subplot(S,1,m) - hold on - for n = Ns - plot(tt,Yo{m}(n,:),'Color',D(m).color,'LineWidth',1) - end - for o = 1:size(D(m).Y,1) - plot(D(m).t,D(m).Y(o,:),mark{o},'Color','k','MarkerSize',5) - end - line([td;td],[0*td+D(m).range(1);0*td+D(m).range(2)],... - 'Color',[1 1 1]/2,'LineStyle','--') - axis([tt(1) tt(end) D(m).range(1) D(m).range(2)]) - ylabel(D(m).Yu) - xlabel(D(m).tu) - set(gca,'FontSize',11,'FontName','Arial','LineWidth',1.5) - set(gca,'XTickLabel',tt(1):14:tt(end),'XTick',tt(1):14:tt(end),'XTickLabelRotation',45) % - grid on -end -saveas(F,['Plots' suf],ext) - -end -if out(2) % plots of model bias w.r.t. calibration data ------------------- - -F = figure('Name',['Bias' suf],'Color',[1 1 1]) ; -for m = 1:S - subplot(S,1,m) - hold on - for n = Ns - plot(D(m).t,Yb{m}(n,:),'o','MarkerSize',5,... - 'Color',D(m).color,'MarkerFaceColor',D(m).color) - end - line([td;td],[0*td+min(min(Yb{m}));0*td+max(max(Yb{m}))],... - 'Color',[0.5 0.5 0.5],'LineStyle','--') - axis([tt(1) tt(end) -inf inf]) - ylabel(D(m).Yu) - xlabel(D(m).tu) - set(gca,'FontSize',11,'FontName','Arial','LineWidth',1.5) - set(gca,'XTickLabel',tt(1):14:tt(end),'XTick',tt(1):14:tt(end),'XTickLabelRotation',45) % - grid on -end -saveas(F,['Bias' suf],ext) - -end -if out(3) % histograms of model cost and parameters ---------------------- - -F = figure('Name',['Histogram' suf '_cost'],'Color',[1 1 1]) ; -i = 1 ;% index -for n = 2:S*2+2 - subplot(S+1,2,n) - if n == 2*i+1 - histogram(C.cost(Ns,1+i),'NumBins',10,'FaceColor',[1 1 1]/2) - title(['Mean Abs. Error in ' D(i).Yu]) - elseif n == 2*i+2 - histogram(Yc(:,i),'NumBins',10,'FaceColor',[1 1 1]/2) - title([func2str(C.cf{1}) ' X ' num2str(C.W(i))]) - i = i + 1 ; - else - histogram(C.cost(Ns,1),'NumBins',10,'FaceColor',[1 1 1]/2) - title('Total Cost') - end - set(gca,'FontSize',11,'FontName','Arial','LineWidth',1.5) -end -saveas(F,['Histogram' suf '_cost'],ext) - -i = 0 ;% index -j = 0 ;% index -for n = 1:size(lPa,2) - j = j + 1 ; - if j == 1 - i = i + 1 ; - F = figure('Name',['Histogram' suf '_par' num2str(i)],... - 'Color',[1 1 1]) ; - end - subplot(5,3,j) - histogram(lPa(:,n),'NumBins',10,'FaceColor',[1 1 1]/2) - title([Pa{n,1} ' [log(' Pa{n,3} ')]']) - set(gca,'FontSize',11,'FontName','Arial','LineWidth',1.5) - if j == 15 - j = 0 ; - saveas(F,['Histogram' suf '_par' num2str(i)],ext) - end -end -saveas(F,['Histogram' suf '_par' num2str(i)],ext) - -end -if out(4) % table of model cost and parameter RCC ------------------------ - -[rho,pval] = partialcorr([C.cost(Ns,1) lPa],'Type','Spearman') ;% RCC -i = 0 ;% index -for n = 1:size(rho,1) - for m = n+1:size(rho,1) - i = i + 1 ; - RCC(i,:) = [rho(n,m) pval(n,m)] ;% RCC in vector form - if n == 1 - Var1{i} = 'cost' ;% 1st variable labels - else - Var1{i} = Pa{n-1,1} ;% 1st variable labels - end - Var2{i} = Pa{m-1,1} ;% 2nd variable labels - end -end - -[~,o] = sort(abs(RCC(:,1)),'descend') ;% descending order by rank -for n = 1:length(Var1) - RCCtab{n,1} = Var1{o(n)} ;% top ranked 1st variable labels - RCCtab{n,2} = Var2{o(n)} ;% top ranked 2nd variable labels - RCCtab{n,3} = RCC(o(n),1) ;% top ranked pair coefficients - RCCtab{n,4} = RCC(o(n),2) ;% top ranked pair p-values -end -F = figure('Name',['RCCs' suf],'Color',[1 1 1]) ; -uitable('Data',RCCtab,'ColumnName',{'Var1','Var2','RCC','P_value'},... - 'Position',[20 20 400 400]) ; -saveas(F,['RCCs' suf],'fig') - -end -disp('Done!') -end %#ok<*AGROW>