|
411 | 411 | %ModelGRDusp100nM.fspOptions.bounds = [0;0;0;2;2;400];
|
412 | 412 | ModelGRDusp100nM.fittingOptions.modelVarsToFit = 10:13;
|
413 | 413 | ModelGRDusp100nM = ModelGRDusp100nM.formPropensitiesGeneral('EricModDusp1_1');
|
414 |
| - log10PriorMean = [-2 -5 -6 -5 0.5 -3 -3 -2 -1 -1 0 -2 -2 -5]; |
| 414 | + log10PriorMean = [-2 -5 -6 -5 0.5 -3 -3 -2 2 -1 -1 0 -2 -2 -5]; |
415 | 415 | log10PriorStd = 2*ones(1,15);
|
416 | 416 | duspLogPrior = @(x)-sum((log10(x(:))'-log10PriorMean(9:12)).^2./(2*log10PriorStd(9:12).^2));
|
417 | 417 | ModelGRDusp100nM.fittingOptions.logPrior = duspLogPrior;
|
|
429 | 429 | ModelDusp1Fit{i}.inputExpressions = {'IDex','Dex0*exp(-gDex*t)'};
|
430 | 430 | ModelDusp1parameterMap{i} = (1:4);
|
431 | 431 | % Set Dex concentration.
|
432 |
| - ModelDusp1Fit{i}.parameters{13,2} = str2num(Dusp1FitCases{i,1}); |
| 432 | + ModelDusp1Fit{i}.parameters{9,2} = str2num(Dusp1FitCases{i,1}); |
433 | 433 | ModelDusp1Fit{i} = ModelDusp1Fit{i}.formPropensitiesGeneral(['EricModDusp1_',num2str(i),'_FSP']);
|
434 | 434 | end
|
435 | 435 | DUSP1pars = [ModelDusp1Fit{i}.parameters{ModelGRDusp100nM.fittingOptions.modelVarsToFit,2}];
|
|
453 | 453 | save('EricModelDusp1_MMDex','GRpars_a','GRpars_b','DUSP1pars')
|
454 | 454 | end
|
455 | 455 |
|
456 |
| - %% STEP 2.C. -- Plot predictions for other Dex concentrations. |
457 |
| - showCases = [1,1,1,1]; |
458 |
| - makePlotsDUSP1({ModelGRDusp100nM},ModelGRDusp100nM,DUSP1pars,Dusp1FitCases,showCases) |
| 456 | + %% Plot predictions for other Dex concentrations. |
| 457 | + %showCases = [1,1,1,1]; |
| 458 | + %makePlotsDUSP1({ModelGRDusp100nM},ModelGRDusp100nM,DUSP1pars,Dusp1FitCases,showCases) |
459 | 459 |
|
460 |
| - %% STEP 2.D. -- Sample uncertainty for Dusp1 Parameters |
461 |
| - % STEP 2.D.1. -- Compute sensitivity of the FSP solution |
| 460 | + %% Sample uncertainty for Dusp1 Parameters |
| 461 | + % Compute sensitivity of the FSP solution |
462 | 462 | ModelGRDusp100nM.solutionScheme = 'fspSens';
|
463 | 463 | sensSoln = ModelGRDusp100nM.solve();
|
464 | 464 | ModelGRDusp100nM.solutionScheme = 'FSP';
|
465 |
| - % STEP 2.D.2. -- Compute FIM |
| 465 | + % Compute FIM |
466 | 466 | % define which species in model are not observed.
|
467 | 467 | ModelGRDusp100nM.pdoOptions.unobservedSpecies = {'offGene';'onGene'};
|
468 | 468 | % compute the FIM
|
469 | 469 | fimResults = ModelGRDusp100nM.computeFIM(sensSoln.sens,'log');
|
470 | 470 | % In the following, the log-prior is used as a prior co-variance matrix.
|
471 | 471 | % This will be used in the FIM calculation as an FIM without new evidence
|
472 | 472 | % being set equal to the inverse of this covariance matrix. More rigorous
|
473 |
| - % justification is needed to support this heuristic. |
| 473 | + %% justification is needed to support this heuristic. |
474 | 474 | fimTotal = ModelGRDusp100nM.evaluateExperiment(fimResults,ModelGRDusp100nM.dataSet.nCells,...
|
475 |
| - diag(log10PriorStd(1:13).^2)); |
| 475 | + diag(log10PriorStd(1:15).^2)); |
476 | 476 | FIMfree = fimTotal{1}(1:4,1:4);
|
477 | 477 | if min(eig(FIMfree))<1
|
478 | 478 | disp('Warning -- FIM has one or more small eigenvalues. Reducing proposal width to 10x in those directions. MH Convergence may be slow.')
|
|
499 | 499 | ModelGRDusp100nM.parameters(1:4,2) = num2cell(DUSP1pars);
|
500 | 500 | end
|
501 | 501 |
|
502 |
| - save('workspace_Feb4_2024.mat','ModelGRDusp100nM','DUSP1pars','fimTotal','sensSoln','combinedGRModel','MHResultsDusp1') |
| 502 | + save('workspace_Feb4_2024.mat','ModelGRDusp100nM','DUSP1pars','fimTotal','sensSoln','combinedGRModel_a','MHResultsDusp1') |
503 | 503 |
|
504 | 504 | %% Plot the MH results
|
505 | 505 | figNew = figure;
|
|
514 | 514 | end
|
515 | 515 | end
|
516 | 516 |
|
517 |
| - % |
518 |
| - % %% Switch solver to ODE and generate model codes |
519 |
| - % ModelGRDusp100nM_a.solutionScheme = 'fsp'; |
520 |
| - % ModelGRDusp100nM_b.solutionScheme = 'fsp'; |
521 |
| - % ModelGRDusp100nM_a.useHybrid = false; |
522 |
| - % ModelGRDusp100nM_b.useHybrid = false; |
523 |
| - % ModelGRDusp100nM_a = ModelGRDusp100nM_a.formPropensitiesGeneral('fspDUSP1_a'); |
524 |
| - % ModelGRDusp100nM_a = ModelGRDusp100nM_a.formPropensitiesGeneral('fspDUSP1_b'); |
525 |
| - % %% Change parameters manually, solve, and make plots |
| 517 | + %% Switch solver to ODE |
| 518 | + ModelGRDusp100nM.solutionScheme = 'fsp'; |
| 519 | + ModelGRDusp100nM.useHybrid = false; |
| 520 | + ModelGRDusp100nM = ModelGRDusp100nM.formPropensitiesGeneral('fspDUSP1_a'); |
| 521 | + %% Change parameters manually, solve, and make plots |
526 | 522 | % [Dusp_soln_a,ModelGRDusp100nM_a.fspOptions.bounds] = ModelGRDusp100nM_a.solve;
|
527 | 523 | % [Dusp_soln_b,ModelGRDusp100nM_b.fspOptions.bounds] = ModelGRDusp100nM_b.solve;
|
528 | 524 | % %plotODEresults(ModelGRDusp100nM_a,Dusp_soln_a,ModelGRfit_a{3})
|
|
619 | 615 | save('EricModelDusp1_MMDex','GRpars_a','GRpars_b','DUSP1pars')
|
620 | 616 | end
|
621 | 617 |
|
622 |
| - %% STEP 2.C. -- Plot predictions for other Dex concentrations. |
623 |
| - showCases = [1,1,1,1]; |
624 |
| - makePlotsDUSP1({ModelGRDusp100nM},ModelGRDusp100nM,DUSP1pars,Dusp1FitCases,showCases) |
| 618 | + %% Plot predictions for other Dex concentrations. |
| 619 | + %showCases = [1,1,1,1]; |
| 620 | + %makePlotsDUSP1({ModelGRDusp100nM},ModelGRDusp100nM,DUSP1pars,Dusp1FitCases,showCases) |
625 | 621 |
|
626 |
| - %% STEP 2.D. -- Sample uncertainty for Dusp1 Parameters |
627 |
| - % STEP 2.D.1. -- Compute sensitivity of the FSP solution |
| 622 | + %% Sample uncertainty for Dusp1 Parameters |
| 623 | + % Compute sensitivity of the FSP solution |
628 | 624 | ModelGRDusp100nM.solutionScheme = 'fspSens';
|
629 | 625 | sensSoln = ModelGRDusp100nM.solve();
|
630 | 626 | ModelGRDusp100nM.solutionScheme = 'FSP';
|
631 |
| - % STEP 2.D.2. -- Compute FIM |
| 627 | + % Compute FIM |
632 | 628 | % define which species in model are not observed.
|
633 | 629 | ModelGRDusp100nM.pdoOptions.unobservedSpecies = {'offGene';'onGene'};
|
634 | 630 | % compute the FIM
|
635 | 631 | fimResults = ModelGRDusp100nM.computeFIM(sensSoln.sens,'log');
|
636 | 632 | % In the following, the log-prior is used as a prior co-variance matrix.
|
637 | 633 | % This will be used in the FIM calculation as an FIM without new evidence
|
638 | 634 | % being set equal to the inverse of this covariance matrix. More rigorous
|
639 |
| - % justification is needed to support this heuristic. |
| 635 | + %% justification is needed to support this heuristic. |
640 | 636 | fimTotal = ModelGRDusp100nM.evaluateExperiment(fimResults,ModelGRDusp100nM.dataSet.nCells,...
|
641 |
| - diag(log10PriorStd(1:13).^2)); |
642 |
| - FIMfree = fimTotal{1}(1:4,1:4); |
| 637 | + diag(log10PriorStd(1:12).^2)); |
| 638 | + FIMfree = fimTotal{1}(10:13,10:13); |
643 | 639 | if min(eig(FIMfree))<1
|
644 | 640 | disp('Warning -- FIM has one or more small eigenvalues. Reducing proposal width to 10x in those directions. MH Convergence may be slow.')
|
645 | 641 | FIMfree = FIMfree + 1*eye(length(FIMfree));
|
|
649 | 645 |
|
650 | 646 | %% STEP 2.D.3. -- Run Metropolis Hastings Search
|
651 | 647 | if loadPrevious
|
652 |
| - MHDusp1File = 'MHDusp1_Dec92024'; |
| 648 | + MHDusp1File = 'MHDusp1_Feb_2025'; |
653 | 649 | load(MHDusp1File)
|
654 | 650 | else
|
655 | 651 | MHFitOptions.proposalDistribution=@(x)mvnrnd(x,covFree);
|
|
662 | 658 | [DUSP1pars,~,MHResultsDusp1] = ModelGRDusp100nM.maximizeLikelihood(...
|
663 | 659 | [], MHFitOptions, 'MetropolisHastings');
|
664 | 660 | delete('TMPEricMHDusp1.mat')
|
665 |
| - ModelGRDusp100nM.parameters(1:4,2) = num2cell(DUSP1pars); |
| 661 | + ModelGRDusp100nM.parameters(10:13,2) = num2cell(DUSP1pars); |
666 | 662 | end
|
667 | 663 |
|
668 | 664 | save('workspace_Feb4_2024.mat','ModelGRDusp100nM','DUSP1pars','fimTotal','sensSoln','combinedGRModel','MHResultsDusp1')
|
669 | 665 |
|
670 |
| - %% STEP 2.D.4. -- Plot the MH results |
| 666 | + %% Plot the MH results |
671 | 667 | figNew = figure;
|
672 | 668 | ModelGRDusp100nM.plotMHResults(MHResultsDusp1,[],'log',[],figNew)
|
673 | 669 | for j = 1:3
|
|
681 | 677 | end
|
682 | 678 |
|
683 | 679 | %% Save results
|
684 |
| - varNames = unique({'ModelGR' |
| 680 | + varNames = unique({'ModelGR_a' |
| 681 | + 'ModelGR_b' |
685 | 682 | 'GRfitCases'
|
686 | 683 | 'log10PriorMean'
|
687 | 684 | 'log10PriorStd'
|
688 |
| - 'GRpars' |
689 |
| - 'MHResultsGR' |
| 685 | + 'GRpars_a' |
| 686 | + 'GRpars_b' |
690 | 687 | 'ModelGRparameterMap'
|
691 |
| - 'ModelGRfit' |
692 |
| - 'boundGuesses' |
| 688 | + 'combinedGR_a' |
693 | 689 | 'ModelGRDusp100nM'
|
694 |
| - 'GRfitCases' |
695 |
| - 'log10PriorMean' |
696 |
| - 'log10PriorStd' |
697 | 690 | 'duspLogPrior'
|
698 | 691 | 'DUSP1pars'
|
699 |
| - 'ModelGRfit' |
| 692 | + 'ModelGRfit_a' |
| 693 | + 'ModelGRfit_b' |
700 | 694 | 'fimResults'
|
701 | 695 | 'MHResultsDusp1'
|
702 |
| - 'sensSoln' |
| 696 | + 'ModelGRDusp100nM' |
703 | 697 | });
|
704 | 698 |
|
705 |
| - save('workspaceDec9_2024',varNames{:}) % WARNING: THIS OVERWRITE THE PREVIOUSLY SAVED WORKSPACE - TODO: FIX |
| 699 | + save('workspace_Feb_2025',varNames{:}) % WARNING: THIS OVERWRITE THE PREVIOUSLY SAVED WORKSPACE - TODO: FIX |
706 | 700 | end
|
707 | 701 |
|
708 | 702 | save('conv2solnTensor_postData','GRpars_a','combinedGRModel_a', 'ModelGRfit_a','ModelGRfit_b','GRpars_b','GR_b_fspSoln', 'fspSolnsSMM',...
|
709 | 703 | 'fimGR_a_withPrior','fimGR_b_withPrior','ModelGR_b_fimResults','fimGR_a_covFree','fimGR_b_covFree','MHResultsGR_a','MHFitOptions','ModelGRfit');
|
710 |
| - |
| 704 | + |
| 705 | + %% Create new objective function combining all of the previous ones. |
| 706 | + % Remove all priors from individual models. |
| 707 | + for i=1:3 |
| 708 | + ModelGRfit_a{i}.fittingOptions.logPrior = []; |
| 709 | + ModelGRfit_a{i}.tSpan = ModelGRfit_a{i}.dataSet.times; |
| 710 | + end |
| 711 | + ModelGRfit_b{1}.fittingOptions.logPrior = []; |
| 712 | + ModelGRfit_b{1}.tSpan = ModelGRfit_b{1}.dataSet.times; |
| 713 | + ModelGRDusp100nM.fittingOptions.logPrior = []; |
| 714 | + fullPars = [ModelGRDusp100nM.parameters{1:15,2}]; |
| 715 | + |
| 716 | + %% Fit all objective functions at once. |
| 717 | + log10PriorMean = [-2 -5 -6 ... % GR pars |
| 718 | + -5 0.5 -3 -3 -2 ... % GR-alpha pars |
| 719 | + 2 ... % Dex |
| 720 | + -1 -1 0 -2 ... % Dusp1 pars |
| 721 | + -2 -5]; % GR-beta pars |
| 722 | + log10PriorStd = 2*ones(1,15); |
| 723 | + %duspLogPrior = @(x)-sum((log10(x(:))'-log10PriorMean(9:12)).^2./(2*log10PriorStd(9:12).^2)); |
| 724 | + logPriorAll = @(x)-sum((log10(x)-log10PriorMean(1:15)).^2./(2*log10PriorStd(1:15).^2)); |
| 725 | + |
| 726 | + % extendedMod.fittingOptions.modelVarsToFit = [1:12,14,15]; |
| 727 | + Organization = {ModelGRfit_a{3},[1:8],[1:8],'computeLikelihood',1;... |
| 728 | + ModelGRfit_b{1},[1:5],[1:5],'computeLikelihood',1;... |
| 729 | + ModelGRDusp100nM,[1:8,10:15],[1:8,10:15],'computeLikelihood',1}; |
| 730 | + %extendedMod,[1:12,14:15],[1:14],'computeLikelihoodODE',0.01}; |
| 731 | + Organization = getTotalFitErr(Organization,fullPars,true); |
| 732 | + getTotalFitErr(Organization,fullPars,false) |
| 733 | + objAll = @(x)-getTotalFitErr(Organization,exp(x),false)-logPriorAll(exp(x)); |
| 734 | + for jj = 1:fitIters |
| 735 | + fullParsLog = log(fullPars); |
| 736 | + fullPars = exp(fminsearch(objAll,fullParsLog,fitOptions)); |
| 737 | + end |
711 | 738 |
|
712 | 739 | %% compute likelihood
|
713 | 740 | % logLikelihood = sum(log(conv2solnTensor{f}(PAs>0)).*PAs((PAs>0)),"all");
|
714 | 741 | %logLikelihood = sum(log(conv2solnTensor_postData{t}(fspsoln_sptensor_a_postData{t}>0)).*fspsoln_sptensor_a_postData{t}((fspsoln_sptensor_a_postData{t}>0)),"all");
|
715 | 742 |
|
716 | 743 | case 2
|
717 | 744 |
|
718 |
| - %% STEP 3.A.1 -- Extend model to include nuclear and cytoplasmic RNA |
| 745 | + %% Extend model to include nuclear and cytoplasmic RNA |
719 | 746 | extendedMod = ModelGRDusp100nM;
|
720 | 747 | extendedMod = extendedMod.addSpecies({'rCyt'},0);
|
721 | 748 | % Adjust the final reaction to be nuc -> cyt transport.
|
|
0 commit comments