Skip to content

Commit ad1af70

Browse files
Merge pull request #39 from sysbiolux/v1.3_Refactor
V1.3 refactor
2 parents c966d53 + 9680e7d commit ad1af70

26 files changed

+1681
-2595
lines changed

FALCON/DriverFalcon.m

Lines changed: 44 additions & 115 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,9 @@
99
% |/ |/ \|(_______/(_______/(_______)|/ )_) %
1010
% %
1111
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
12-
% Current version: v1.2 %
13-
% (July 2019) %
14-
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
12+
% Current version: v1.3 %
13+
% (July 2020) %
14+
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1515
% CONTEXTUALIZATION OF DBN MODELS OF BIOLOGICAL NETWORKS %
1616
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1717
% Sébastien De Landtsheer: sebastien.delandtsheer@uni.lu %
@@ -22,161 +22,90 @@
2222
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2323
% cite: De Landtsheer et al., 2017, Bioinformatics, 33, 3431–6 %
2424
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
25+
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2526

2627
clc, clear all % clear screen and workspace
2728

28-
29-
% ===========================
30-
% Define optimization options
31-
% ===========================
32-
optRound = 4; % Number of optimisation round
33-
MaxFunEvals = 3000; % Number of maximal function being evaluated (3000 = default)
34-
MaxIter = 3000; % Number of maximal iteration being evaluated (3000 = default)
35-
Parallelisation = 1; % Use multiple cores for optimisation? (0=no, 1=yes)
36-
HLbound = 0.5; % Qualitative threshold between high and low inputs
37-
InitIC = 2; % Initialise parameters' distribution (1=uniform, 2=normal, 3=zeros)
38-
ObjFunction = 'weighted'; % Either 'unweighted' or 'weighted'
39-
40-
% Define plotting and saving (0=no, 1=yes)
41-
PlotFitEvolution = 1; % Graph of optimise fitting cost over iteration
42-
PlotFitSummary = 1; % Graph of state values at steady-state versus measurements (all in 1)
43-
PlotFitIndividual = 0; % Graph of state values at steady-state versus measurements (individual)
44-
PlotHeatmapCost = 1; % Heatmaps of optimal costs for each output for each condition absolute cost
45-
PlotStateSummary = 1; % Graph of only state values at steady-sate (all in 1)
46-
PlotStateEvolution = 1; % Graph of state values evolution over the course of the simulation (two graphs)
47-
PlotBiograph = 0; % Graph of network topology, nodes activities, and optimised parameters
48-
PlotAllBiographs = 0; % (Only for machines with strong GPUs) Plot all Biographs above
49-
50-
% Additional analyses after the optimisation with the default setting (0=no, 1=yes)
51-
Resampling_Analysis = 1; % Resampling of experimental data and re-optimise
52-
NDatasets = 50;% Number of artificial datasets from which to resample.
53-
54-
LPSA_Analysis = 1; % Local parameter sensitivity analysis
55-
Fast_Option = 0; % Performing faster LPSA by stopping if fitting costs go over a set threshold value
56-
optRound_LPSA = 5; % Number of optimizations for each perturbed datapoint
57-
LPSA_Increments = 3; % Number of increments for LPSA. Increase for finer resolution
58-
59-
KO_Analysis = 1; % Parameter knock-out analysis
60-
KO_Nodes_Analysis = 1; % Node knock-out analysis
61-
optRound_KO = 5; % Number of optimizations for each KO datapoint.
62-
KO_Nodes_fast = 1; %
63-
64-
KO_Nodes_Analysis_eff = 1; % test different KO efficencies on each node and analyse the entire network based on this information
65-
efficiency_range = 0:0.1:1; % indicate the different KO efficencies you want to test (vector from 0 to 1)
66-
6729
% Model and measurement files
6830
InputFile = 'PDGF_model.xlsx'; %for xls
69-
% InputFile='PDGF_model.sif'; %for sif
7031
MeasFile = 'PDGF_meas.xlsx'; %for xls
71-
% MeasFile={'PDGF_meas_in.csv';'PDGF_meas_out.csv';'PDGF_meas_err.csv'}; %for csv
7232

73-
74-
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
75-
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
76-
77-
78-
% Creates a save folder
79-
SaveFolderName = ['Results_' datestr(now)]; FinalFolderName=strrep(SaveFolderName, ':', '.');
80-
mkdir(FinalFolderName) % Automatically generate a folder for saving
33+
% InputFile='PDGF_model.sif'; %for sif
34+
% MeasFile={'PDGF_meas_in.csv';'PDGF_meas_out.csv';'PDGF_meas_err.csv'}; %for csv
8135

8236
% Builds a FALCON model for optimisation
83-
estim = FalconMakeModel(InputFile, MeasFile, HLbound); %make the model
37+
estim = FalconMakeModel(InputFile, MeasFile); %make the model
8438

85-
% Defines optimisation options
86-
estim.options = optimoptions('fmincon', 'TolCon', 1e-6, 'TolFun', 1e-6, 'TolX', 1e-10, 'MaxFunEvals', MaxFunEvals, 'MaxIter', MaxIter); % Default setting
87-
estim.SSthresh = eps*100 ; estim.ObjFunction = ObjFunction;
88-
if InitIC == 1, IC_Dist = 'uniform'; elseif InitIC == 2, IC_Dist = 'normal'; elseif InitIC == 3, IC_Dist = 'scratch'; else, error('Please choose the initial parameter distribution'), end
39+
%%%%
40+
% modify optimization parameters here
41+
%%%%
8942

9043
% Optimization
91-
toc_all = []; x_all = []; fval_all = [];
92-
93-
if Parallelisation
94-
parfor counter = 1:optRound %'parfor' will run the parallel computing toolbox
95-
tic, k = FalconIC(estim, IC_Dist); %initial conditions
96-
[xval, fval] = FalconObjFun(estim, k); %objective function
97-
toc_all = [toc_all; toc]; x_all = [x_all; xval]; fval_all = [fval_all; fval];
98-
end
99-
100-
else
101-
for counter = 1:optRound %'parfor' will run the parallel computing toolbox
102-
tic, k = FalconIC(estim, IC_Dist); %initial conditions
103-
[xval, fval] = FalconObjFun(estim, k); %objective function
104-
toc_all = [toc_all; toc]; x_all = [x_all; xval]; fval_all = [fval_all; fval];
105-
end
106-
close(h);
107-
end
108-
109-
fxt_all = [fval_all x_all toc_all];
110-
beep; pause(0.5); beep;
111-
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
112-
%Retrieving the results
113-
114-
[bestx, meanx, stdx, estim] = FalconResults(estim, fxt_all, estim.param_vector, FinalFolderName);
44+
estim = FalconOptimize(estim);
11545

11646
%%% Re-simulate results based on the best optimised parameter set
117-
[MeanStateValueAll, StdStateValueAll, MeanCostAll, StdCostAll, estim] = FalconSimul(estim, bestx, [PlotFitSummary PlotFitIndividual PlotHeatmapCost PlotStateSummary PlotStateEvolution], FinalFolderName);
47+
[estim, StateValues, MSE] = FalconSimul(estim);
11848

119-
save([FinalFolderName filesep 'OptimizedModel'])
49+
save([estim.FinalFolderName filesep 'OptimizedModel'])
12050

12151
%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
12252
%%% Analyzing the evolution of fitting cost
123-
if PlotFitEvolution
124-
estim = FalconFitEvol(estim, IC_Dist, FinalFolderName);
53+
if estim.PlotFitEvolution
54+
estim = FalconFitEvol(estim);
12555
end
12656

12757
%%% Displayed optimised network with weights
128-
if PlotBiograph
129-
FalconShowNetwork(estim, PlotAllBiographs, FinalFolderName)
58+
if estim.PlotBiograph
59+
FalconShowNetwork(estim)
13060
end
13161

13262
%%% Obtaining robust estimates for the parameters by resampling
133-
if Resampling_Analysis
134-
optRound_Sampling = optRound;
135-
CV_cutoff = 10; % Percent cut-off for large coefficient of variation
136-
[~,~,estim] = FalconResample(estim, bestx, NDatasets, 3, CV_cutoff, FinalFolderName);
63+
if estim.Resampling_Analysis
64+
estim = FalconResample(estim);
13765
end
13866

13967
%%% Sensitivity analysis
140-
if LPSA_Analysis
141-
if Fast_Option, IsFast = 'fast'; else, IsFast = 'slow'; end
142-
Estimated_Time_LPSA = mean(fxt_all(:, end)) * optRound_LPSA * LPSA_Increments * 3 * length(estim.param_vector);
143-
disp(['Estimated Time for LPSA analysis (fast): ' num2str(Estimated_Time_LPSA) ' seconds']); beep; pause(3); beep;
144-
[~, estim] = FalconLPSA(estim, bestx, MeasFile, HLbound, optRound_LPSA, LPSA_Increments, IsFast, Parallelisation, FinalFolderName);
68+
if estim.LPSA_Analysis
69+
estim = FalconLPSA(estim);
14570
end
14671

14772
%%% Knock-out analysis
148-
if KO_Analysis
149-
Estimated_Time_KO = mean(fxt_all(:, end)) * optRound_KO * length(estim.param_vector);
150-
disp(['Estimated Time for KO analysis: ' num2str(Estimated_Time_KO) ' seconds']); beep; pause(3); beep;
151-
estim = FalconKO(estim, fxt_all, HLbound, optRound_KO, Parallelisation, FinalFolderName);
73+
if estim.KO_Analysis
74+
estim = FalconKO(estim);
15275
end
15376

15477
%%% Nodes Knock-out analysis
155-
if KO_Nodes_Analysis
156-
Estimated_Time_KO = mean(fxt_all(:, end)) * optRound_KO * (length(estim.state_names) - length(estim.Input_idx(1,:)));
157-
disp(['Estimated Time for KO analysis: ' num2str(Estimated_Time_KO) ' seconds']); beep; pause(3); beep;
158-
estim = FalconKONodes(estim, fxt_all, HLbound, optRound_KO, Parallelisation, FinalFolderName);
159-
end
160-
161-
%%% Nodes Knock-out efficency analysis
162-
if KO_Nodes_Analysis_eff
163-
Estimated_Time_KO = mean(fxt_all(:,end)) * numel(efficiency_range) * optRound_KO * (length(estim.state_names)-length(estim.Input_idx(1,:)));
164-
disp(['Estimated Time for KO analysis: ' num2str(Estimated_Time_KO) ' seconds']); beep; pause(3); beep;
165-
estim=FalconKONodes_eff(estim, fxt_all, efficiency_range, HLbound, optRound_KO, FinalFolderName);
166-
78+
if estim.KO_Nodes_Analysis
79+
estim = FalconKONodes(estim);
16780
end
16881

16982
%%% Fast KO
170-
if KO_Nodes_fast
171-
estim = FalconKONodes_fast(estim, fxt_all, HLbound, optRound_KO, Parallelisation, FinalFolderName);
83+
if estim.KO_Nodes_fast
84+
estim = FalconKONodes_fast(estim);
17285
end
86+
%
87+
% %%% Nodes Knock-out efficency analysis
88+
% if estim.KO_Nodes_Analysis_eff
89+
% estim=FalconKONodes_eff(estim, fxt_all, efficiency_range, HLbound, optRound_KO, FinalFolderName);
90+
%
91+
% end
17392

17493
%%% Discriminate fast effects from long-term effects
17594
X = estim.Results.KnockOutNodes.BIC_values;
17695
Y = estim.Results.KnockOutNodesFast.BIC_values;
177-
M1 = min(X,Y); M2 = min(X,Y);
17896
figure, plot(X,Y,'.k', 'MarkerSize', 15), hold on
97+
M1 = min(X,Y); M2 = min(X,Y);
17998
plot([M1, M2], [M1, M2], '-k');
99+
Nodes = estim.state_names;
100+
Nodes(estim.Input_idx(1, :)) = [];
101+
text(X(1), Y(1), 'base')
102+
for tx = 1:length(X)-1
103+
text(X(tx+1), Y(tx+1), Nodes(tx))
104+
end
105+
xlabel('BIC for re-optimized model')
106+
ylabel('BIC for non-adapted model')
107+
108+
180109

181110

182111
% === End of the script === %

0 commit comments

Comments
 (0)