00001
00002
00004
00005 #include "EGFRTraffickingCHOMinimizableDirector.h"
00006
00008
00010
00011 CEGFRTraffickingCHOMinimizableDirector::CEGFRTraffickingCHOMinimizableDirector()
00012 {
00013
00014 double maxSimTime = 241.0;
00015 double stepSize = 0.0001;
00016 double frequency = 1.0;
00017 int nCells = 1;
00018 double moveTol = 1.0e-06;
00019
00020 m_dGammaSquared = 1.0e-07;
00021
00022
00023 bool rateFlag = true;
00024 bool chemFlag = false;
00025 bool logsFlag = false;
00026 double timeWeight = 1.0;
00027 double rateWeight = 0.0;
00028 double chemWeight = 0.0;
00029
00030
00031
00032
00033
00034 _networkList.push_back(new CEGFRTraffickingNetwork());
00035 _experimentList.push_back(new Experiment(_networkList[0],"EGF at 5 ng/ml, Bao 2000"));
00036
00037 _experimentList[0]->AddDataFileToList("../DataFiles/TimeSeries/InternalizedEGFREGFYarden.dat");
00038 _experimentList[0]->AddForcingFileToList("../DataFiles/TimeSeries/TwoHourEGF.dat");
00039
00040
00041 _moverList.push_back(new CStiffBulirschStoerMover(frequency,stepSize,moveTol));
00042
00043 _minimizableList.push_back(new SingleNetworkMinimizable());
00044
00045 _minimizableList[0]->Initialize(_experimentList[0],_moverList[0],nCells,rateFlag,chemFlag,logsFlag,timeWeight,rateWeight,chemWeight);
00046 _minimizableList[0]->SetRateConstantsWeight(0.0);
00047
00048
00049 _plotterList.push_back(new GnuPlotterTimeSeriesObserver());
00050 _plotterList[0]->SetTitle("EGFR Trafficking Network:EGF at 5 ng/ml (Bao 2000):ODE");
00051 _minimizableList[0]->Attach(_plotterList[0]);
00052
00053
00054
00055
00056 _networkList.push_back(new CEGFRTraffickingNetwork());
00057 _experimentList.push_back(new Experiment(_networkList[1],"EGF at 100 nM, Davis 1992"));
00058
00059 _experimentList[1]->AddDataFileToList("../DataFiles/TimeSeries/SurfaceEGFREGFDavis100nM.dat");
00060 _experimentList[1]->AddForcingFileToList("../DataFiles/TimeSeries/TwoHourEGF.dat");
00061
00062
00063 _moverList.push_back(new CStiffBulirschStoerMover(frequency,stepSize,moveTol));
00064
00065 _minimizableList.push_back(new SingleNetworkMinimizable());
00066
00067 _minimizableList[1]->Initialize(_experimentList[1],_moverList[1],nCells,rateFlag,chemFlag,logsFlag,timeWeight,rateWeight,chemWeight);
00068 _minimizableList[1]->GetConversionFactor(59)->SetFactorFixed(true);
00069 _minimizableList[1]->GetConversionFactor(59)->SetFactorValue(100.0/82000.0);
00070 _minimizableList[1]->SetRateConstantsWeight(0.0);
00071
00072
00073 _plotterList.push_back(new GnuPlotterTimeSeriesObserver());
00074 _plotterList[1]->SetTitle("EGFR Trafficking Network:EGF at 100 nM (Davis 1992):ODE");
00075 _minimizableList[1]->Attach(_plotterList[1]);
00076
00077
00078
00079
00080 _networkList.push_back(new CEGFRTraffickingNetwork());
00081 _experimentList.push_back(new Experiment(_networkList[2],"EGF at 10 nM, Davis 1992"));
00082
00083 _experimentList[2]->AddDataFileToList("../DataFiles/TimeSeries/SurfaceEGFREGFDavis10nM.dat");
00084 _experimentList[2]->AddForcingFileToList("../DataFiles/TimeSeries/TwoHourEGF.dat");
00085
00086
00087 _moverList.push_back(new CStiffBulirschStoerMover(frequency,stepSize,moveTol));
00088
00089 _minimizableList.push_back(new SingleNetworkMinimizable());
00090
00091 _minimizableList[2]->Initialize(_experimentList[2],_moverList[2],nCells,rateFlag,chemFlag,logsFlag,timeWeight,rateWeight,chemWeight);
00092 _minimizableList[2]->GetConversionFactor(59)->SetFactorFixed(true);
00093 _minimizableList[2]->GetConversionFactor(59)->SetFactorValue(100.0/82000.0);
00094 _minimizableList[2]->SetRateConstantsWeight(0.0);
00095
00096
00097 _plotterList.push_back(new GnuPlotterTimeSeriesObserver());
00098 _plotterList[2]->SetTitle("EGFR Trafficking Network:EGF at 10 nM (Davis 1992):ODE");
00099 _minimizableList[2]->Attach(_plotterList[2]);
00100
00101
00102
00103
00104 _networkList.push_back(new CEGFRTraffickingNetwork());
00105 _experimentList.push_back(new Experiment(_networkList[3],"EGF at 1 nM, Davis 1992"));
00106
00107 _experimentList[3]->AddDataFileToList("../DataFiles/TimeSeries/SurfaceEGFREGFDavis1nM.dat");
00108 _experimentList[3]->AddForcingFileToList("../DataFiles/TimeSeries/TwoHourEGF.dat");
00109
00110
00111 _moverList.push_back(new CStiffBulirschStoerMover(frequency,stepSize,moveTol));
00112
00113 _minimizableList.push_back(new SingleNetworkMinimizable());
00114
00115 _minimizableList[3]->Initialize(_experimentList[3],_moverList[3],nCells,rateFlag,chemFlag,logsFlag,timeWeight,rateWeight,chemWeight);
00116 _minimizableList[3]->GetConversionFactor(59)->SetFactorFixed(true);
00117 _minimizableList[3]->GetConversionFactor(59)->SetFactorValue(100.0/82000.0);
00118 _minimizableList[3]->SetRateConstantsWeight(0.0);
00119
00120
00121 _plotterList.push_back(new GnuPlotterTimeSeriesObserver());
00122 _plotterList[3]->SetTitle("EGFR Trafficking Network:EGF at 1 nM (Davis 1992):ODE");
00123 _minimizableList[3]->Attach(_plotterList[3]);
00124
00125
00126
00127
00128
00129
00130
00131
00132
00133
00134
00135
00136
00137
00138
00139
00140
00141
00142
00143
00144
00145
00146
00147
00148
00149
00150
00151
00152
00153
00154
00155
00156
00157
00158
00159
00160
00161
00162
00163
00164
00165
00166
00167
00168
00169
00170
00171
00172
00173
00174
00175
00176
00177
00178
00179
00180
00181
00182
00183
00184
00185
00186
00187
00188
00189
00190
00191
00192
00193
00194
00195
00196
00197 int masterResidualsSize = 0;
00198 for(int i = 0; i < _minimizableList.size(); i++)
00199 {
00200 int subRes = _minimizableList[i]->GetNResiduals();
00201 masterResidualsSize += subRes;
00202 cout << subRes << " residuals in minimizable " << i << endl;
00203 }
00204
00205 masterResidualsSize += m_iPriorList.size();
00206 cout << m_iPriorList.size() << " parameters are constrained by a prior " << endl;
00207 if(m_dGammaSquared > 0.0)
00208 {
00209 masterResidualsSize += 1;
00210 }
00211 Allocate(masterResidualsSize);
00212
00213 cout << "Master Residuals size : " << this->GetNResiduals() << endl;
00214
00215
00216 DefineExperiments();
00217
00218 }
00219
00220 CEGFRTraffickingCHOMinimizableDirector::~CEGFRTraffickingCHOMinimizableDirector()
00221 {
00222 for(int i = 0; i < _plotterList.size(); i++)
00223 {
00224 _minimizableList[i]->Detach(_plotterList[i]);
00225 delete _plotterList[i];
00226 }
00227 }
00228
00229 void CEGFRTraffickingCHOMinimizableDirector::DefineExperiments()
00230 {
00231
00232
00233
00234 _minimizableList[0]->GetExperiment()->GetReactionNetwork()->RemoveReaction(98);
00235 _minimizableList[0]->GetExperiment()->GetReactionNetwork()->GetChemical(0)->SetInitialAmount(600000.0);
00236 _minimizableList[0]->GetExperiment()->GetReactionNetwork()->GetChemical(3)->SetInitialAmount(10000.0);
00237 _minimizableList[0]->GetExperiment()->GetReactionNetwork()->GetChemical(4)->SetInitialAmount(70000.0);
00238 _minimizableList[0]->GetExperiment()->GetReactionNetwork()->ChemicalReset();
00239
00240
00241 _minimizableList[1]->GetExperiment()->GetReactionNetwork()->RemoveReaction(98);
00242 _minimizableList[1]->GetExperiment()->GetReactionNetwork()->GetChemical(0)->SetInitialAmount(7.2e+007);
00243 _minimizableList[1]->GetExperiment()->GetReactionNetwork()->GetChemical(3)->SetInitialAmount(10000);
00244 _minimizableList[1]->GetExperiment()->GetReactionNetwork()->GetChemical(4)->SetInitialAmount(72000.0);
00245 _minimizableList[1]->GetExperiment()->GetReactionNetwork()->ChemicalReset();
00246
00247
00248 _minimizableList[2]->GetExperiment()->GetReactionNetwork()->RemoveReaction(98);
00249 _minimizableList[2]->GetExperiment()->GetReactionNetwork()->GetChemical(0)->SetInitialAmount(7.2e+006);
00250 _minimizableList[2]->GetExperiment()->GetReactionNetwork()->GetChemical(3)->SetInitialAmount(10000);
00251 _minimizableList[2]->GetExperiment()->GetReactionNetwork()->GetChemical(4)->SetInitialAmount(72000);
00252 _minimizableList[2]->GetExperiment()->GetReactionNetwork()->ChemicalReset();
00253
00254
00255 _minimizableList[3]->GetExperiment()->GetReactionNetwork()->RemoveReaction(98);
00256 _minimizableList[3]->GetExperiment()->GetReactionNetwork()->GetChemical(0)->SetInitialAmount(7.2e+005);
00257 _minimizableList[3]->GetExperiment()->GetReactionNetwork()->GetChemical(3)->SetInitialAmount(10000);
00258 _minimizableList[3]->GetExperiment()->GetReactionNetwork()->GetChemical(4)->SetInitialAmount(72000);
00259 _minimizableList[3]->GetExperiment()->GetReactionNetwork()->ChemicalReset();
00260
00261
00262
00263
00264
00265
00266
00267
00268
00269
00270
00271
00272
00273
00274
00275
00276
00277
00278
00279
00280
00281
00282
00283
00284
00285
00286
00287
00288
00289
00290
00291 }
00292
00293 double CEGFRTraffickingCHOMinimizableDirector::GetParameter(int parIndex)
00294 {
00295
00296
00297 return _minimizableList[0]->GetParameter(parIndex);
00298 }
00299
00300 int CEGFRTraffickingCHOMinimizableDirector::GetNParameters()
00301 {
00302
00303
00304 return _minimizableList[0]->GetNParameters() + 8;
00305 }
00306
00307 double CEGFRTraffickingCHOMinimizableDirector::ComputeResiduals(double *parameters)
00308 {
00309 int lastrc = _minimizableList[0]->GetNParameters();
00310
00311 for(int i = 0; i < 4; i++)
00312 {
00313 _minimizableList[i]->GetExperiment()->GetReactionNetwork()->GetChemical(46)->SetInitialAmount(parameters[lastrc]);
00314 _minimizableList[i]->GetExperiment()->GetReactionNetwork()->GetChemical(47)->SetInitialAmount(parameters[lastrc+1]);
00315 _minimizableList[i]->GetExperiment()->GetReactionNetwork()->GetChemical(49)->SetInitialAmount(parameters[lastrc+2]);
00316 _minimizableList[i]->GetExperiment()->GetReactionNetwork()->GetChemical(53)->SetInitialAmount(parameters[lastrc+3]);
00317 _minimizableList[i]->GetExperiment()->GetReactionNetwork()->GetChemical(54)->SetInitialAmount(parameters[lastrc+4]);
00318 _minimizableList[i]->GetExperiment()->GetReactionNetwork()->GetChemical(55)->SetInitialAmount(parameters[lastrc+5]);
00319 _minimizableList[i]->GetExperiment()->GetReactionNetwork()->GetChemical(71)->SetInitialAmount(parameters[lastrc+6]);
00320 _minimizableList[i]->GetExperiment()->GetReactionNetwork()->ChemicalReset();
00321
00322 }
00323
00324
00325
00326 double summedCost = 0.0;
00327 double timeCost = 0.0;
00328 double pcost = 0.0;
00329
00330
00331 for(i = 0; i < _minimizableList.size(); i++)
00332 {
00333 summedCost += _minimizableList[i]->ObjectiveFunction(parameters);
00334 }
00335
00336
00337 int nextResidual = 0;
00338 for(i = 0; i < _minimizableList.size(); i++)
00339 {
00340 int nRes = _minimizableList[i]->GetNResiduals();
00341 for(int j = 0; j < nRes; j++)
00342 {
00343 residuals[nextResidual+j] = (_minimizableList[i]->GetResiduals())[j];
00344 }
00345 nextResidual += nRes;
00346 }
00347
00348
00349 for(i = 0; i < m_iPriorList.size(); i++)
00350 {
00351 int which = m_iPriorList[i];
00352
00353 double presid = _networkList[0]->GetRateConstant(which)->GetValue() - _networkList[0]->GetRateConstant(which)->GetInitialValue();
00354 presid = presid/(sqrt(2.0)*_networkList[0]->GetRateConstant(which)->GetErrorInInitialValue());
00355 residuals[nextResidual + i] = presid;
00356 pcost += presid*presid;
00357 }
00358 nextResidual += m_iPriorList.size();
00359
00360
00361
00362 if(m_dGammaSquared > 0.0)
00363 {
00364 double totalSteps = 0.0;
00365 for(int l = 0; l < _moverList.size(); l++)
00366 {
00367 totalSteps += _moverList[l]->GetTotalStepsTaken();
00368 }
00369 residuals[nResiduals - 1] = sqrt(m_dGammaSquared/2.0)*totalSteps;
00370 timeCost = residuals[nResiduals - 1]*residuals[nResiduals - 1];
00371 }
00372 return summedCost + pcost + timeCost;
00373 }