forked from ICRC-Models/HHCoM
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsimVaxWane.m
267 lines (249 loc) · 11 KB
/
simVaxWane.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
% Accepts end year of analysis, number of tests, and population vector from
% calibrated model as inputs
close all;clear all;clc
% function simVaxCEA2(endYear, vaxCover , vaxEff, vaxAge , waning , varargin)
% p = inputParser;
% addRequired(p , 'endYear');
% addRequired(p , 'vaxCover');
% addRequired(p , 'vaxEff');
% addRequired(p , 'vaxAge');
% addRequired(p , 'waning');
% addOptional(p , 'origEffVec' , []);
% addOptional(p , 't_wane' , 0);
% parse(p , endYear, vaxCover , vaxEff, vaxAge , varargin{:})
% close all; clear all; clc
lastYear = 2040; %endYear;
% if nargin
% origEffVec = varargin{1};
% t_wane = varargin{2};
% end
disp('Start up')
% load variables
paramDir = [pwd , '\Params\'];
load([paramDir, 'general'])
load([paramDir,'mixInfectIndices'])
load([paramDir,'vlAdvancer'])
load([paramDir,'deathMat'])
load([paramDir,'circMat'])
load([paramDir,'vaxer'])
load([paramDir,'mixInfectParams'])
load([paramDir,'popData'])
load([paramDir,'HIVParams'])
load([paramDir,'hivIndices'])
load([paramDir,'hpvIndices'])
load([paramDir,'ager'])
load([paramDir,'hpvTreatIndices'])
load([paramDir,'calibParams'])
load([paramDir,'vaxInds'])
% load([paramDir,'settings'])
load([paramDir,'hpvData'])
load([paramDir ,'cost_weights'])
load([paramDir,'fertMat'])
load([paramDir,'hivFertMats'])
load([paramDir,'fertMat2'])
load([paramDir,'hivFertMats2'])
load([paramDir , 'ageRiskInds'])
load([paramDir,'vlBeta'])
% load population
popIn = load([pwd , '\HHCoM_Results\toNow']);
currPop = popIn.popLast;
artDist = popIn.artDist;
artDistList = popIn.artDistList;
%%%%%%%
fImm(1 : age) = 1; % all infected individuals who clear HPV get natural immunity
%%%%%
%% Use calibrated parameters
load([paramDir , 'popData'])
load([paramDir , 'General'])
load([paramDir , 'calibratedParams'])
vaxCover = [0.4 , 0.6 , 0.8];
vaxEff = [0.8 * 0.9 , 0.85 * 0.9];
vaxAge = 3;
waning = 1;
maxRateM_vec = [0.4 , 0.4];% as of 2013. Scales up from this value in hiv2a.
maxRateF_vec = [0.5 , 0.5];% as of 2013. Scales up from this value in hiv2a.
%
maxRateM1 = maxRateM_vec(1);
maxRateM2 = maxRateM_vec(2);
maxRateF1 = maxRateF_vec(1);
maxRateF2 = maxRateF_vec(2);
c = fix(clock);
currYear = c(1); % get the current year
% 90% efficacy against 70% of CC types, 100% efficacy against 70% of types, ...
% 100% efficacy against 90% of types
% vaxEff = [0.9 * 0.7 , 0.7 , 0.9];
% vaxCover = [0 , 0.7 , 0.9];
testParams = allcomb(vaxCover , vaxEff); % test scenarios consist of all combinations of vaccine coverage and efficacy
testParams = [testParams ; [0 , 0]]; % Append no vaccine scenario to test scenarios
nTests = size(testParams , 1); % counts number of scenarios to test
%%%%%%%
dim = [disease , viral , hpvTypes , hpvStates , periods , gender , age ,risk];
% run analyses
stepsPerYear = 6;
c = fix(clock);
currYear = c(1); % get the current year
% Initialize vectors
timeStep = 1 / stepsPerYear;
years = lastYear - currYear;
s = 1 : timeStep : years + 1;
hivOn = 1;
hpvOn = 1;
% Intervention start years
circStartYear = 1990;
vaxStartYear = currYear;
lambdaMultVaxMat = zeros(age , nTests - 1);
% waning = 0;
vaxEffInd = repmat(1 : length(vaxEff) , 1 , (nTests - 1) /length(vaxEff));
for n = 1 : nTests - 1
% No waning
lambdaMultVaxMat(3 : age , n) = vaxEff(vaxEffInd(n));
if waning
% Following a period (in years) where original efficacy is retained,
% specified by 'effPeriod' , linearly scale down vaccine efficacy
% to 0% over time period specificed by 'wanePeriod'
lambdaMultVaxMat(round(effPeriod / 5) + vaxAge : age , n) = ...
linspace(vaxEff(vaxEffInd(n)) , ...
max(0 , vaxEff(vaxEffInd(n)) ./ wanePeriod) ,...
age + 1 - (round(effPeriod / 5) + vaxAge))';
end
end
lambdaMultVaxMat = [lambdaMultVaxMat , zeros(age , 1)]; % append 0 vaccine protection for no vaccine scenario
disp(['Simulating period from ' num2str(currYear) ' to ' num2str(lastYear) ...
' with ' num2str(stepsPerYear), ' steps per year.'])
fromNonV = toInd(allcomb(1 : disease , 1 : viral , 1 , 1 , 1 , ...
2 , vaxAge , 1 : risk));
toV = toInd(allcomb(1 : disease , 1 : viral , 1 , 9 , 1 , ...
2 , vaxAge , 1 : risk));
import java.util.LinkedList
% artDistList = LinkedList();
artDistList = popIn.artDistList;
%%
parfor n = 1 : nTests
simNum = n;
vaxEff = testParams(n , 2);
lambdaMultVax = 1 - lambdaMultVaxMat(: , n);
vaxRate = testParams(n , 1);
popVec = spalloc(years / timeStep , prod(dim) , 10 ^ 8);
popIn = currPop; % initial population to "seed" model
newHiv = zeros(length(s) - 1 , gender , age , risk);
newHpv = zeros(length(s) - 1 , gender , disease , age , risk);
newImmHpv = newHpv;
newVaxHpv = newHpv;
newCC = zeros(length(s) - 1 , disease , hpvTypes , age);
ccDeath = newCC;
ccTreated = zeros(length(s) - 1 , disease , hpvTypes , age , 3); % 3 cancer stages: local, regional, distant
hivDeaths = zeros(length(s) - 1 , gender , age);
deaths = zeros(size(popVec));
vaxd = zeros(length(s) - 1 , 1);
artTreatTracker = zeros(length(s) - 1 , disease , viral , gender , age , risk);
popVec(1 , :) = popIn;
tVec = linspace(currYear , lastYear , size(popVec , 1));
k = cumprod([disease , viral , hpvTypes , hpvStates , periods , gender , age]);
artDist = zeros(disease , viral , gender , age , risk); % initial distribution of inidividuals on ART = 0
%%
for i = 2 : length(s) - 1
year = currYear + s(i) - 1;
currStep = round(s(i) * stepsPerYear);
tspan = [s(i) , s(i + 1)]; % evaluate diff eqs over one time interval
popIn = popVec(i - 1 , :);
if hpvOn
hystOption = 'on';
% Progression/regression from initial HPV infection to
% precancer stages and cervical cancer. Differential CC
% detection by CC stage and HIV status/CD4 count.
[~ , pop , newCC(i , : , : , :) , ccDeath(i , : , : , :) , ...
ccTreated(i , : , : , : , :)] ...
= ode4xtra(@(t , pop) ...
hpvCCdet(t , pop , immuneInds , infInds , cin1Inds , ...
cin2Inds , cin3Inds , normalInds , ccInds , ccRegInds , ccDistInds , ...
ccTreatedInds , ccLocDetInds , ccRegDetInds , ccDistDetInds , ...
kInf_Cin1 , kCin1_Cin2 , kCin2_Cin3 , ...
kCin2_Cin1 , kCin3_Cin2 , kCC_Cin3 , kCin1_Inf ,...
rNormal_Inf , hpv_hivClear , c3c2Mults , ...
c2c1Mults , fImm , kRL , kDR , muCC , muCC_det , kCCDet , ...
disease , viral , age , hpvTypes , ...
rImmuneHiv , vaccinated , hystOption) , tspan , popIn);
popIn = pop(end , :);
if any(pop(end , :) < 0)
disp('After hpv')
break
end
end
% HIV and HPV mixing and infection module. Protective effects of condom
% coverage, circumcision, ART, PrEP (not currently used) are accounted for.
[~ , pop , newHpv(i , : , : , : , :) , newImmHpv(i , : , : , : , :) , ...
newVaxHpv(i , : , : , : , :) , newHiv(i , : , : , :)] = ...
ode4xtra(@(t , pop) mixInfect(t , pop , currStep , ...
gar , perPartnerHpv , perPartnerHpv_lr , perPartnerHpv_nonV , ...
lambdaMultImm , lambdaMultVax , artHpvMult , epsA_vec , epsR_vec , yr , modelYr1 , ...
circProtect , condProtect , condUse , actsPer , partnersM , partnersF , ...
hpv_hivMult , hpvSus , hpvImm , toHpv_Imm , hpvVaxd , hpvVaxd2 , toHpv , toHpv_ImmVax , ...
toHpv_ImmVaxNonV , hivSus , toHiv , mCurr , fCurr , mCurrArt , fCurrArt , ...
betaHIVF2M , betaHIVM2F , disease , viral , gender , age , risk , hpvStates , hpvTypes , ...
hrInds , lrInds , hrlrInds , periods , startYear , stepsPerYear , year) , tspan , popIn);
popIn = pop(end , :); % for next mixing and infection module
if any(pop(end , :) < 0)
disp('After mixInfect')
break
end
% HIV module, CD4 Progression, VL progression, ART initiation/dropout,
% excess HIV mortality
if hivOn
[~ , pop , hivDeaths(i , : , :) , artTreat] =...
ode4xtra(@(t , pop) hiv2a(t , pop , vlAdvancer , artDist , muHIV , ...
kCD4 , maxRateM1 , maxRateM2 , maxRateF1 , maxRateF2 , disease , ...
viral , gender , age , risk , k , hivInds , ...
stepsPerYear , year) , tspan , pop(end , :));
artTreatTracker(i , : , : , : , : ,:) = artTreat;
artDistList.add(artTreat);
if artDistList.size() >= stepsPerYear * 2
artDistList.remove(); % remove CD4 and VL distribution info for people initiating ART more than 2 years ago
end
artDist = calcDist(artDistList , disease , viral , gender , age , ...
risk); % 2 year average CD4 and VL distribution at time of ART initiation. Details where ART dropouts return to.
if any(pop(end , :) < 0)
disp('After hiv')
break
end
end
% birth, aging, risk redistribution module
[~ , pop , deaths(i , :)] = ode4xtra(@(t , pop) ...
bornAgeDieRisk(t , pop , year , currStep ,...
gender , age , risk , fertility , fertMat , fertMat2 ,...
hivFertPosBirth , hivFertNegBirth , hivFertPosBirth2 , ...
hivFertNegBirth2 , deathMat , circMat , ...
MTCTRate , circStartYear , ageInd , riskInd , riskDist ,...
startYear , endYear, stepsPerYear) , tspan , pop(end , :));
if any(pop(end , :) < 0)
disp('After bornAgeDieRisk')
break
end
popSize = sum(pop(end , :) , 2);
fracVaxd = sum(pop(end , toV) , 2) / ... % find proportion of population that is currently vaccinated
(sum(pop(end , fromNonV) , 2) + sum(pop(end , toV) , 2));
if vaxRate - fracVaxd > 10 ^ -6 % when proportion vaccinated is below target vaccination level
vaxCover = max(0 , (vaxRate - fracVaxd) ./ (1 - fracVaxd)); % vaccinate enough people in age group to reach target
vaxdGroup = vaxCover .* pop(end , fromNonV);
dPop = zeros(size(pop(end , :)));
dPop(fromNonV) = -vaxdGroup;
dPop(toV) = vaxdGroup;
pop(end , :) = dPop + pop(end , :);
vaxd(i , :) = sumall(vaxdGroup); % count number of people vaccinated at current time step
end
% add results to population vector
popVec(i , :) = pop(end , :);
end
popLast = popVec(end , :);
popVec = sparse(popVec); % compress population vectors
filename = ['vaxSimResult' , num2str(simNum)];
if waning
filename = ['vaxWaneSimResult' , num2str(simNum)];
end
parsave(filename , tVec , popVec , newHiv ,...
newImmHpv , newVaxHpv , newHpv , deaths , hivDeaths , ccDeath , ...
newCC , artTreatTracker , vaxd , ccTreated , ...
currYear , lastYear , vaxRate , vaxEff , popLast);
end
disp('Done')
%%
vaxCEA