-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathloopingCEAOverScenarios_v2.m
275 lines (255 loc) · 17 KB
/
loopingCEAOverScenarios_v2.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
268
269
270
271
272
273
274
275
% DESCRIPTION: Looping vaxCEA_multSims_SACEA.m over all the scenario
% numbers, cleaning the output, turning into an array, and exporting to CSV for
% processing in R.
function loopingCEAOverScenarios_v2(username)
clear;
% Initialize variables
[stepsPerYear , timeStep , startYear , currYear , endYear , ...
years , disease , viral , hpvVaxStates , hpvNonVaxStates , endpoints , ...
intervens , gender , age , risk , hpvTypeGroups , dim , k , toInd , ...
annlz , ...
ageSexDebut , mInit , fInit , partnersM , partnersF , maleActs , ...
femaleActs , riskDist , fertility , fertility2 , fertility3 , fertility4 , ...
mue , mue2 , mue3 , mue4 , epsA_vec , epsR_vec , ...
yr , ...
hivOn , betaHIV_mod , muHIV , kCD4 , ...
hpvOn , beta_hpvVax_mod , beta_hpvNonVax_mod , fImm , rImmune , ...
kCin1_Inf , kCin2_Cin1 , kCin3_Cin2 , kCC_Cin3 , rNormal_Inf , kInf_Cin1 , ...
kCin1_Cin2 , kCin2_Cin3 , lambdaMultImm , hpv_hivClear , rImmuneHiv , ...
c3c2Mults , c2c1Mults , c2c3Mults , c1c2Mults , muCC , muCC_ud , muCC_d , kRL , kDR , artHpvMult , ...
hpv_hivMult , maleHpvClearMult , ...
condUse , screenYrs , hpvScreenStartYear , ...
artYr , maxRateM , maxRateF , ...
artYr_vec , artM_vec , artF_vec , minLim , maxLim , ...
circ_aVec , vmmcYr_vec , vmmc_vec , vmmcYr , vmmcRate , ...
hivStartYear , circStartYear , circNatStartYear , vaxStartYear , ...
baseline , who , spCyto , spHpvDna , spGentyp , spAve , spHpvAve , ...
circProtect , condProtect , MTCTRate , hyst , ...
OMEGA , ...
ccInc2012_dObs , ccInc2018_dObs , cc_dist_dObs , cin3_dist_dObs , ...
cin1_dist_dObs , hpv_dist_dObs , cinPos2002_dObs , cinNeg2002_dObs , ...
cinPos2015_dObs , cinNeg2015_dObs , hpv_hiv_dObs , hpv_hivNeg_dObs , ...
hpv_hivM2008_dObs , hpv_hivMNeg2008_dObs , hivPrevM_dObs , hivPrevF_dObs , ...
popAgeDist_dObs , totPopSize_dObs , ...
stageDist_1997_dObs , ...
hivCurr , ...
gar , hivSus , hpvVaxSus , hpvVaxImm , hpvNonVaxSus , hpvNonVaxImm , ...
toHiv , vaxInds , nonVInds , hpvVaxInf , hpvNonVaxInf , ...
hivInds , ...
cin3hpvVaxIndsFrom , ccLochpvVaxIndsTo , ccLochpvVaxIndsFrom , ...
ccReghpvVaxInds , ccDisthpvVaxInds , cin3hpvNonVaxIndsFrom , ...
ccLochpvNonVaxIndsTo , ccLochpvNonVaxIndsFrom , ccReghpvNonVaxInds , ...
ccDisthpvNonVaxInds , cin1hpvVaxInds , cin2hpvVaxInds , cin3hpvVaxInds , ...
cin1hpvNonVaxInds , cin2hpvNonVaxInds , cin3hpvNonVaxInds , normalhpvVaxInds , ...
immunehpvVaxInds , infhpvVaxInds , normalhpvNonVaxInds , immunehpvNonVaxInds , ...
infhpvNonVaxInds , fromVaxNoScrnInds , fromVaxScrnInds , toNonVaxNoScrnInds , ...
toNonVaxScrnInds , ageInd , riskInd , ...
kSymp , hystMult , ...
hivNegNonVMMCinds , hivNegVMMCinds , ...
vlAdvancer , ...
fertMat , hivFertPosBirth , hivFertNegBirth , fertMat2 , ...
hivFertPosBirth2 , hivFertNegBirth2 , fertMat3 , hivFertPosBirth3 , hivFertNegBirth3 , ...
fertMat4 , hivFertPosBirth4 , hivFertNegBirth4 , ...
dFertPos1 , dFertNeg1 , dFertMat1 , dFertPos2 , dFertNeg2 , dFertMat2 , ...
dFertPos3 , dFertNeg3 , dFertMat3 , deathMat , deathMat2 , deathMat3 , deathMat4 , ...
dDeathMat , dDeathMat2 , dDeathMat3 , dMue , ...
ccLochpvVaxIndsFrom_treat , ...
ccReghpvVaxInds_treat , ccDisthpvVaxInds_treat , vaxEff] = loadUp2(1 , 0 , [] , [] , [] , 1 , 1);
% Indices of calib runs to plot
% Temporarily commenting out to only run one scenario first to test out
% code
fileInds = {'6_1' , '6_2' , '6_3' , '6_6' , '6_8' , '6_9' , '6_11' , ...
'6_12' , '6_13' , '6_15' , '6_20' , '6_21' , '6_22' , '6_26' , ...
'6_27' , '6_32' , '6_34' , '6_35' , '6_38' , '6_39' , '6_40' , ...
'6_41' , '6_42' , '6_45' , '6_47'}; % 22Apr20Ph2V11 ***************SET ME****************
% fileInds = {'6_1'}; % FORTESTING
nRuns = length(fileInds);
lastYear = 2123; % manually set in futureSim
monthlyTimespan = [startYear : timeStep : lastYear]; % list all the timespans in a vector
monthlyTimespan = monthlyTimespan(1 : end-1); % remove the very last date
monthlyTimespanFut = [endYear : timeStep : lastYear]; % screening time span starts at 2021
monthlyTimespanFut = monthlyTimespanFut(1 : end-1);
nTimepoints = length(monthlyTimespan);
nTimepointsFut = length(monthlyTimespanFut);
% parallelizing the for loop
loopSegments = {0 , round(2/2) , 2}; % ********SET ME*********: how many scenarios are you running
loopSegmentsLength = length(loopSegments);
scenarios = {'8', '9'}; % *********SET ME***********: what are the scenarios you are running
for k = 1 : loopSegmentsLength-1
parfor j = loopSegments{k}+1 : loopSegments{k+1}
% for j = [1] % FORTESTING
sceNum = j - 1;
sceString = scenarios{j}; % turn sceNum into string sceString
sce = sceNum + 1; % add one since indices start at 1 (so scenarios will be 1-10 in this case)
% Initialize result matrices
deaths = zeros(nTimepoints, age+1, 4, nRuns); % time, age (1:17), 3 death data elements, number of parameters, 10 scenarios
screenTreat = zeros(nTimepointsFut, age+1, 5, nRuns); % time, age (1:16), 5 screen/treat data elements, number of parameters, 10 scenarios
hpvHealthState = zeros(nTimepoints, age+1, 7, nRuns); % time, age (1:16), 10 HPV/CC health states, number of parameters, 10 scenarios
ccHealthState = zeros(nTimepoints, age+1, endpoints, nRuns);
hivHealthState = zeros(nTimepoints, age+1, 7, nRuns); % time, age (1:16), 7 HIV health states, number of parameters , 10 scenarios
totalPerAge = zeros(nTimepoints, age+1, nRuns); % to pull the N per age group at each time point , 10 scenarios
vax = zeros(nTimepoints, age+1, nRuns); % number of vaccinations is not stratified by age. only time and parameter. , 10 scenarios
nonDisabHealthState = zeros(nTimepoints, age+1, nRuns);
scen0CinTx = zeros(nTimepointsFut, endpoints, 2, nRuns); % 2 because only LEEP and cryo (for the 3rd dimension, 1 is LEEP 2 is cryo)
newCC = zeros(nTimepoints, age+1, nRuns);
screenSympCCTreat = zeros(nTimepoints, 3, age+1, 3, 2, nRuns);
% Feeding in the zeroed result matrix, spitting out the same matrix but with all the counts added in for that scenario
[deaths, screenTreat, hpvHealthState, ccHealthState, hivHealthState, totalPerAge, vax, nonDisabHealthState, scen0CinTx, newCC, screenSympCCTreat] = ...
vaxCEA_multSims_SACEA_CH(1 , sceString , {'0'}, fileInds, deaths, screenTreat, hpvHealthState, ccHealthState, hivHealthState, totalPerAge, vax, nonDisabHealthState, scen0CinTx, newCC, screenSympCCTreat);
% turn all the result matrices into 2D
for param = 1 : nRuns
for a = 1 : age + 1
% turning deaths into 2D
for var = 1 : 4
if (param == 1 && a ==1 && var == 1)
deathsReshape = [transpose(monthlyTimespan), a.*ones(nTimepoints,1), var.*ones(nTimepoints,1), ...
param.*ones(nTimepoints,1), sce.*ones(nTimepoints,1), deaths(:, a, var, param)];
else
deathsReshape = [deathsReshape; ...
transpose(monthlyTimespan), a.*ones(nTimepoints,1), var.*ones(nTimepoints,1), ...
param.*ones(nTimepoints,1), sce.*ones(nTimepoints,1), deaths(:, a, var, param)];
end
end
% turning screening/treatment matrix into 2D
for var = 1 : 5
if (param == 1 && a ==1 && var == 1)
screenTreatReshape = [transpose(monthlyTimespanFut), a.*ones(nTimepointsFut,1), var.*ones(nTimepointsFut,1), ...
param.*ones(nTimepointsFut,1), sce.*ones(nTimepointsFut,1), screenTreat(:, a, var, param)];
else
screenTreatReshape = [screenTreatReshape; ...
transpose(monthlyTimespanFut), a.*ones(nTimepointsFut,1), var.*ones(nTimepointsFut,1), ...
param.*ones(nTimepointsFut,1), sce.*ones(nTimepointsFut,1), screenTreat(:, a, var, param)];
end
end
% turning hpv health states matrix into 2D
for var = 1 : 7
if (param == 1 && a ==1 && var == 1)
hpvHealthStateReshape = [transpose(monthlyTimespan), a.*ones(nTimepoints,1), var.*ones(nTimepoints,1), ...
param.*ones(nTimepoints,1), sce.*ones(nTimepoints,1), hpvHealthState(:, a, var, param)];
else
hpvHealthStateReshape = [hpvHealthStateReshape;
transpose(monthlyTimespan), a.*ones(nTimepoints,1), var.*ones(nTimepoints,1), ...
param.*ones(nTimepoints,1), sce.*ones(nTimepoints,1), hpvHealthState(:, a, var, param)];
end
end
% turning cc health states matrix into 2D
for var = 1 : 10
if (param == 1 && a ==1 && var == 1)
ccHealthStateReshape = [transpose(monthlyTimespan), a.*ones(nTimepoints,1), var.*ones(nTimepoints,1), ...
param.*ones(nTimepoints,1), sce.*ones(nTimepoints,1), ccHealthState(:, a, var, param)];
else
ccHealthStateReshape = [ccHealthStateReshape;
transpose(monthlyTimespan), a.*ones(nTimepoints,1), var.*ones(nTimepoints,1), ...
param.*ones(nTimepoints,1), sce.*ones(nTimepoints,1), ccHealthState(:, a, var, param)];
end
end
% turning hiv health states matrix into 2D
for var = 1 : 7
if (param == 1 && a ==1 && var == 1)
hivHealthStateReshape = [transpose(monthlyTimespan), a.*ones(nTimepoints,1), var.*ones(nTimepoints,1), ...
param.*ones(nTimepoints,1), sce.*ones(nTimepoints,1), hivHealthState(:, a, var, param)];
else
hivHealthStateReshape = [hivHealthStateReshape;
transpose(monthlyTimespan), a.*ones(nTimepoints,1), var.*ones(nTimepoints,1), ...
param.*ones(nTimepoints,1), sce.*ones(nTimepoints,1), hivHealthState(:, a, var, param)];
end
end
% turning non disability health states matrix into 2D
if (param == 1 && a == 1)
nonDisabHealthStateReshape = [transpose(monthlyTimespan), a.*ones(nTimepoints,1), param.*ones(nTimepoints,1), ...
sce.*ones(nTimepoints,1), nonDisabHealthState(:, a, param)];
else
nonDisabHealthStateReshape = [nonDisabHealthStateReshape; ...
transpose(monthlyTimespan), a.*ones(nTimepoints,1), param.*ones(nTimepoints,1), ...
sce.*ones(nTimepoints,1), nonDisabHealthState(:, a, param)];
end
% turning total per age matrix into 2D
if (param == 1 && a == 1)
totalPerAgeReshape = [transpose(monthlyTimespan), a.*ones(nTimepoints,1), param.*ones(nTimepoints,1), ...
sce.*ones(nTimepoints,1), totalPerAge(:, a, param)];
vaxReshape = [transpose(monthlyTimespan), a.*ones(nTimepoints,1), param.*ones(nTimepoints,1), ...
sce.*ones(nTimepoints,1), vax(:, a, param)];
newCCReshape = [transpose(monthlyTimespan), a.*ones(nTimepoints,1), param.*ones(nTimepoints,1), sce.*ones(nTimepoints,1), ...
newCC(:, a, param)];
else
totalPerAgeReshape = [totalPerAgeReshape;
transpose(monthlyTimespan), a.*ones(nTimepoints,1), param.*ones(nTimepoints,1), ...
sce.*ones(nTimepoints,1), totalPerAge(:, a, param)];
vaxReshape = [vaxReshape;
transpose(monthlyTimespan), a.*ones(nTimepoints,1), param.*ones(nTimepoints,1), ...
sce.*ones(nTimepoints,1), vax(:, a, param)];
newCCReshape = [newCCReshape;
transpose(monthlyTimespan), a.*ones(nTimepoints,1), param.*ones(nTimepoints,1), sce.*ones(nTimepoints,1), ...
newCC(:, a, param)];
end
% turning screen symp into 2D
for x = 1 : 3
for index = 1 : 2
for treat = 1 : 3
if (param==1 && a==1 && x==1)
screenSympCCTreatReshape = [transpose(monthlyTimespan), x.*ones(nTimepoints,1), a.*ones(nTimepoints,1), treat.*ones(nTimepoints,1), index.*ones(nTimepoints,1) , param.*ones(nTimepoints,1), ...
sce.*ones(nTimepoints,1), screenSympCCTreat(:, x, a, treat, index, param)];
else
screenSympCCTreatReshape = [screenSympCCTreatReshape;
transpose(monthlyTimespan), x.*ones(nTimepoints,1), a.*ones(nTimepoints,1), treat.*ones(nTimepoints,1), index.*ones(nTimepoints,1) , param.*ones(nTimepoints,1), ...
sce.*ones(nTimepoints,1), screenSympCCTreat(:, x, a, treat, index, param)];
end
end
end
end
end
disp(['Complete Scenario ', num2str(sce), ', Parameter ', num2str(param)])
end
% turn result matrices for scenario 0 cin analysis into 2D
for param = 1 : nRuns
for h = 1 : hpvVaxStates
% turning the cin treatment scenario 0 analysis into 2D
for var = 1 : 2
if (param == 1 && h ==1 && var == 1)
scen0CinTxReshape = [transpose(monthlyTimespanFut), h.*ones(nTimepointsFut,1), var.*ones(nTimepointsFut,1), ...
param.*ones(nTimepointsFut,1), sce.*ones(nTimepointsFut,1), scen0CinTx(:, h, var, param)];
else
scen0CinTxReshape = [scen0CinTxReshape;
transpose(monthlyTimespanFut), h.*ones(nTimepointsFut,1), var.*ones(nTimepointsFut,1), ...
param.*ones(nTimepointsFut,1), sce.*ones(nTimepointsFut,1), scen0CinTx(:, h, var, param)];
end
end
end
end
% turn into arrays
deathsReshape1 = array2table(deathsReshape, 'VariableNames', {'year', 'age', 'categ', 'paramNum', ...
'sceNum', 'count'});
screenTreatReshape1 = array2table(screenTreatReshape, 'VariableNames', {'year', 'age', 'categ', 'paramNum', ...
'sceNum', 'count'});
hpvHealthStateReshape1 = array2table(hpvHealthStateReshape, 'VariableNames', {'year', 'age', 'categ', 'paramNum', ...
'sceNum', 'count'});
ccHealthStateReshape1 = array2table(ccHealthStateReshape, 'VariableNames', {'year', 'age', 'categ', 'paramNum', ...
'sceNum', 'count'});
hivHealthStateReshape1 = array2table(hivHealthStateReshape, 'VariableNames', {'year', 'age', 'categ', 'paramNum', ...
'sceNum', 'count'});
totalPerAgeReshape1 = array2table(totalPerAgeReshape, 'VariableNames', {'year', 'age', 'paramNum', ...
'sceNum', 'count'});
vaxReshape1 = array2table(vaxReshape, 'VariableNames', {'year', 'age', 'paramNum', ...
'sceNum', 'count'});
nonDisabHealthStateReshape1 = array2table(nonDisabHealthStateReshape, 'VariableNames', {'year', 'age', 'paramNum', ...
'sceNum', 'count'});
scen0CinTxReshape1 = array2table(scen0CinTxReshape, 'VariableNames', {'year', 'hpvState', 'categ', 'paramNum', 'sceNum', 'count'});
newCCReshape1 = array2table(newCCReshape, 'VariableNames', {'year', 'age', 'paramNum', 'sceNum', 'count'});
screenSympCCTreatReshape1 = array2table(screenSympCCTreatReshape, 'VariableNames', {'year', 'endpoint', 'age', 'treat', 'index', 'paramNum', 'sceNum', 'count'});
% spit out into CSV
writetable(deathsReshape1,[pwd '/SACEA/deaths_S' sceString '.csv']);
writetable(screenTreatReshape1, [pwd '/SACEA/screenTreat_S' sceString '.csv']);
writetable(hpvHealthStateReshape1, [pwd '/SACEA/hpvHealthState_S' sceString '.csv']);
writetable(ccHealthStateReshape1, [pwd '/SACEA/ccHealthState_S' sceString '.csv']);
writetable(hivHealthStateReshape1, [pwd '/SACEA/hivHealthState_S' sceString '.csv']);
writetable(totalPerAgeReshape1, [pwd '/SACEA/totalPerAge_S' sceString '.csv']);
writetable(vaxReshape1, [pwd '/SACEA/vax_S' sceString '.csv']);
writetable(nonDisabHealthStateReshape1, [pwd '/SACEA/nonDisabHealthState_S' sceString '.csv']);
writetable(newCCReshape1, [pwd '/SACEA/newCC_S' sceString '.csv']);
writetable(screenSympCCTreatReshape1, [pwd '/SACEA/screenSympCCTreat_S' sceString '.csv']);
if sceNum == 0 % only write the cin / treatment file if in scenario 0
writetable(scen0CinTxReshape1, [pwd '/SACEA/scen0CinTx_S0.csv']);
end
end
end
end