forked from theinmozhiarulraj/QSP-mets
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy patharch_analyze.m
144 lines (96 loc) · 3.87 KB
/
arch_analyze.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
%thein: modified script to analyze results from ARCH
% some functions might not work in the QSP model with mets but are not
% required
clear
close all
sbioreset
load('model_workspace_w60.mat')
%npatients_subset=3; % comment later
growth_rates=NaN(n_PSA,length(organs));
%simDataPSA=struct;
% number of tasks
ntasks=n_PSA/npatients_subset;
for i=1:ntasks
% concatenate output of all tasks
disp(i)
tic
loaded_ws=load(['PSA_output' num2str(i) '.mat']);
start_patient=npatients_subset*(i-1)+1;
end_patient=start_patient+npatients_subset-1;
growth_rates(start_patient:end_patient,:)=loaded_ws.growth_rates(start_patient:end_patient,:);
% growth_rates=[growth_rates,growth_rates_temp];
% put together simDataPSA
% if(i==1)
% simDataPSA.simData=load(['PSA_output' num2str(i) '.mat']).simDataPSA.simData;
% else
% simDataPSA.simData=[load(['PSA_output' num2str(i) '.mat']).simDataPSA.simData];
%
% end
for k=start_patient:end_patient
simDataPSA(k).simData=loaded_ws.simDataPSA(k).simData;
end
% put together params.out
params_out.patient(start_patient:end_patient)=loaded_ws.params_out.patient(start_patient:end_patient);
params_out.ICs(1,start_patient:end_patient)=loaded_ws.params_out.ICs(1,start_patient:end_patient);
% if(i==1)
%
% params_out.iPatient(start_patient:end_patient)=load(['PSA_output' num2str(i) '.mat']).params_out.iPatient(start_patient:end_patient);
% else
%
% params_out.iPatient(start_patient:end_patient)=load(['PSA_output' num2str(i) '.mat']).params_out.iPatient(start_patient:end_patient);
%
% end
tic
end
ncount_patient=1;
ncount_healthy=1;
params_out.iPatient=[];
params_out.iHealthy=[];
for j=1:n_PSA
if(params_out.patient(j)==1) % patient
params_out.iPatient(ncount_patient)=j;
ncount_patient=ncount_patient+1;
else % healthy if 0
params_out.iHealthy(ncount_healthy)=j;
ncount_healthy=ncount_healthy+1;
end
end
%% Postprocess
growth_rates = array2table(growth_rates,'VariableNames',organs);
% thein: write growth rates in a file
writetable(growth_rates,'growth_rates.csv');
% Postprocess Data -> Calculate Clonality, Percentages and ...
simDataPSApost = PSA_post(simDataPSA,params_in,params_out,TumorArray);
% Add pre-treatment observables to the params_in
params_in = PSA_preObs(simDataPSA,simDataPSApost,params_in,params_out);
% Prepare the data for the rest of the analysis
params_out = PSA_prep(simDataPSA,simDataPSApost,params_out);
% Save and print data of interest (by assigning a unique code name for the trial)
%sprint_data(simDataPSA, simDataPSApost, params_in, params_out, 'test_thein')
%sprint_data(simDataPSA, simDataPSApost, params_in, params_out, 'thein')
%% Perform and plot different types of analysis
% Partial Rank Correlation Coefficients
% PSA_PRCC(params_in,params_out,'plausible')
% PSA_PRCC(params_in,params_out)
% t-SNE Analysis
% PSA_tSNE(params_in,params_out,'plausible')
% PSA_tSNE(params_in,params_out,'patient')
% eFAST
% Principle Component Analysis
%% Plot Results
% close all
% Plot percent change in size and RECIST
% PSA_plot_RECIST(simDataPSA,simDataPSApost,params_out)
% Tumor Size
% PSA_plot_TumSize(simDataPSA,simDataPSApost,params_out)
% Kaplan-Meier Progression-free survival (PFS)
% PSA_plot_KaplanMeier(simDataPSA,simDataPSApost,params_out)
%% Waterfall plots
% Plot percent change in size using waterfall plots for a parameter.
% Waterfall plots can be plotted using either end tumor sizes or best overall responses.
%
% PSA_plot_Waterfall(simDataPSApost,model,params_in,params_out,'n_T1_clones')
% PSA_plot_Waterfall(simDataPSApost,model,params_in,params_out,'k_P1_d1')
PSA_plot_Waterfall(simDataPSApost,model,params_in,params_out,'k_C1_growth')
PSA_plot_Waterfall_mets(simDataPSApost,model,params_in,params_out,'k_C1_growth',TumorArray)
save('analyzed_results_w60.mat')