Skip to content

Commit

Permalink
Add model updates for Eric's project.
Browse files Browse the repository at this point in the history
  • Loading branch information
Munsky committed Jul 3, 2024
1 parent 6052113 commit e28c71c
Show file tree
Hide file tree
Showing 45 changed files with 254,579 additions and 10,645 deletions.
10,184 changes: 10,184 additions & 0 deletions WorkSpace/EricModel/EricData/DUSP1_fit_filtered_data_100nM_031224.csv

Large diffs are not rendered by default.

5,650 changes: 5,650 additions & 0 deletions WorkSpace/EricModel/EricData/DUSP1_predict_data_DUSP1_TPL_031224.csv

Large diffs are not rendered by default.

10,878 changes: 10,878 additions & 0 deletions WorkSpace/EricModel/EricData/DUSP1_predict_filtered_data_03nM_1nM_10nM_031224.csv

Large diffs are not rendered by default.

Large diffs are not rendered by default.

43,179 changes: 43,179 additions & 0 deletions WorkSpace/EricModel/EricData/Data010224_Gated_On_Nuc.csv

Large diffs are not rendered by default.

7,722 changes: 7,722 additions & 0 deletions WorkSpace/EricModel/EricData/Gated_dataframe_Ron_020224_NormalizedGR_bins.csv

Large diffs are not rendered by default.

8,592 changes: 8,592 additions & 0 deletions WorkSpace/EricModel/EricData/NormalizedGR_fit_filtered_data_050124.csv

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,13 @@
TMP.Nuc_DUSP1_avg_int_tot = TMP.Nuc_DUSP1_avg_int.*(TMP.Nuc_Area.^p);
TMP.Nuc_DUSP1_avg_int_tot = TMP.Nuc_DUSP1_avg_int_tot/maxVal;
TMP.Nuc_DUSP1_avg_int_tot = round(400*TMP.Nuc_DUSP1_avg_int_tot);

totNucRNA = TMP.RNA_DUSP1_nuc;
totNucRNA(~isnan(TMP.DUSP1_ts_size_0)) = totNucRNA(~isnan(TMP.DUSP1_ts_size_0)) + TMP.DUSP1_ts_size_0(~isnan(TMP.DUSP1_ts_size_0));
totNucRNA(~isnan(TMP.DUSP1_ts_size_1)) = totNucRNA(~isnan(TMP.DUSP1_ts_size_1)) + TMP.DUSP1_ts_size_1(~isnan(TMP.DUSP1_ts_size_1));
totNucRNA(~isnan(TMP.DUSP1_ts_size_2)) = totNucRNA(~isnan(TMP.DUSP1_ts_size_2)) + TMP.DUSP1_ts_size_2(~isnan(TMP.DUSP1_ts_size_2));
totNucRNA(~isnan(TMP.DUSP1_ts_size_3)) = totNucRNA(~isnan(TMP.DUSP1_ts_size_3)) + TMP.DUSP1_ts_size_3(~isnan(TMP.DUSP1_ts_size_3));
TMP.totalNucRNA = totNucRNA;
writetable(TMP,'pdoCalibrationData_EricIntensity_DexSweeps.csv')

%%
Expand All @@ -38,6 +45,14 @@
TMP.Nuc_DUSP1_avg_int_tot = TMP.Nuc_DUSP1_avg_int.*(TMP.Nuc_Area.^p);
TMP.Nuc_DUSP1_avg_int_tot = TMP.Nuc_DUSP1_avg_int_tot/maxVal;
TMP.Nuc_DUSP1_avg_int_tot = round(400*TMP.Nuc_DUSP1_avg_int_tot);

totNucRNA = TMP.RNA_DUSP1_nuc;
totNucRNA(~isnan(TMP.DUSP1_ts_size_0)) = totNucRNA(~isnan(TMP.DUSP1_ts_size_0)) + TMP.DUSP1_ts_size_0(~isnan(TMP.DUSP1_ts_size_0));
totNucRNA(~isnan(TMP.DUSP1_ts_size_1)) = totNucRNA(~isnan(TMP.DUSP1_ts_size_1)) + TMP.DUSP1_ts_size_1(~isnan(TMP.DUSP1_ts_size_1));
totNucRNA(~isnan(TMP.DUSP1_ts_size_2)) = totNucRNA(~isnan(TMP.DUSP1_ts_size_2)) + TMP.DUSP1_ts_size_2(~isnan(TMP.DUSP1_ts_size_2));
totNucRNA(~isnan(TMP.DUSP1_ts_size_3)) = totNucRNA(~isnan(TMP.DUSP1_ts_size_3)) + TMP.DUSP1_ts_size_3(~isnan(TMP.DUSP1_ts_size_3));
TMP.totalNucRNA = totNucRNA;

writetable(TMP,'pdoCalibrationData_EricIntensity_ConcSweeps.csv')

%%
Expand All @@ -47,4 +62,12 @@
TMP.Nuc_DUSP1_avg_int_tot = TMP.Nuc_DUSP1_avg_int.*(TMP.Nuc_Area.^p);
TMP.Nuc_DUSP1_avg_int_tot = TMP.Nuc_DUSP1_avg_int_tot/maxVal;
TMP.Nuc_DUSP1_avg_int_tot = round(400*TMP.Nuc_DUSP1_avg_int_tot);

totNucRNA = TMP.RNA_DUSP1_nuc;
totNucRNA(~isnan(TMP.DUSP1_ts_size_0)) = totNucRNA(~isnan(TMP.DUSP1_ts_size_0)) + TMP.DUSP1_ts_size_0(~isnan(TMP.DUSP1_ts_size_0));
totNucRNA(~isnan(TMP.DUSP1_ts_size_1)) = totNucRNA(~isnan(TMP.DUSP1_ts_size_1)) + TMP.DUSP1_ts_size_1(~isnan(TMP.DUSP1_ts_size_1));
totNucRNA(~isnan(TMP.DUSP1_ts_size_2)) = totNucRNA(~isnan(TMP.DUSP1_ts_size_2)) + TMP.DUSP1_ts_size_2(~isnan(TMP.DUSP1_ts_size_2));
totNucRNA(~isnan(TMP.DUSP1_ts_size_3)) = totNucRNA(~isnan(TMP.DUSP1_ts_size_3)) + TMP.DUSP1_ts_size_3(~isnan(TMP.DUSP1_ts_size_3));
TMP.totalNucRNA = totNucRNA;

writetable(TMP,'pdoCalibrationData_EricIntensity_ConcHigh.csv')

Large diffs are not rendered by default.

43,179 changes: 43,179 additions & 0 deletions WorkSpace/EricModel/EricData/oldProbablyTrash/Data010224_Gated_On_Nuc.csv

Large diffs are not rendered by default.

26,922 changes: 26,922 additions & 0 deletions WorkSpace/EricModel/EricData/oldProbablyTrash/pdoCalibrationData_EricIntensity.csv

Large diffs are not rendered by default.

Large diffs are not rendered by default.

26,922 changes: 26,922 additions & 0 deletions WorkSpace/EricModel/EricData/pdoCalibrationData_EricIntensity.csv

Large diffs are not rendered by default.

Large diffs are not rendered by default.

10,505 changes: 10,505 additions & 0 deletions WorkSpace/EricModel/EricData/pdoCalibrationData_EricIntensity_ConcSweeps.csv

Large diffs are not rendered by default.

26,922 changes: 26,922 additions & 0 deletions WorkSpace/EricModel/EricData/pdoCalibrationData_EricIntensity_DexSweeps.csv

Large diffs are not rendered by default.

10,602 changes: 0 additions & 10,602 deletions WorkSpace/EricModel/EricDataJan23_2024/DUSP1_fit_flitered_data_100nM_030624.csv

This file was deleted.

Binary file modified WorkSpace/EricModel/EricModelDusp1_MMDex.mat
Binary file not shown.
32 changes: 17 additions & 15 deletions WorkSpace/EricModel/RonModelPipelineJune16_2024.m
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@
ModelGRfit = cell(1,size(GRfitCases,1));
ModelGRODEfit = cell(1,size(GRfitCases,1));
for i=1:3
ModelGRfit{i} = ModelGR.loadData("EricDataJan23_2024/Gated_dataframe_Ron_030624_NormalizedGR_bins.csv",...
ModelGRfit{i} = ModelGR.loadData("EricData/Gated_dataframe_Ron_020224_NormalizedGR_bins.csv",...
{'nucGR','normgrnuc';'cytGR','normgrcyt'},...
{'Condition','GR_timesweep';'Dex_Conc',GRfitCases{i,2}});
ModelGRfit{i}.parameters{13,2} = str2num(GRfitCases{i,1});
Expand Down Expand Up @@ -136,8 +136,8 @@
ModelDusp1parameterMap = cell(1,size(GRfitCases,1));
for i = 1:size(Dusp1FitCases,1)
% TODo - Adjust for newly processed data.
ModelDusp1Fit{i} = ModelGRDusp.loadData('EricDataJan23_2024/pdoCalibrationData_EricIntensity_DexSweeps.csv',...
{'rna','RNA_DUSP1_nuc'},...
ModelDusp1Fit{i} = ModelGRDusp.loadData('EricData/pdoCalibrationData_EricIntensity_DexSweeps.csv',...
{'rna','totalNucRNA'},...
{'Dex_Conc','100'});
ModelDusp1Fit{i}.inputExpressions = {'IDex','Dex0*exp(-gDex*t)'};

Expand All @@ -148,8 +148,8 @@
end
DUSP1pars = [ModelDusp1Fit{i}.parameters{ModelGRDusp.fittingOptions.modelVarsToFit,2}];

ModelGRDusp100nM = ModelGRDusp.loadData('EricDataJan23_2024/pdoCalibrationData_EricIntensity_DexSweeps.csv',...
{'rna','RNA_DUSP1_nuc'},{'Dex_Conc','100'});
ModelGRDusp100nM = ModelGRDusp.loadData('EricData/pdoCalibrationData_EricIntensity_DexSweeps.csv',...
{'rna','totalNucRNA'},{'Dex_Conc','100'});
%% Fit DUSP1 model(s) with single parameter set.
% Specify prior on parameters.
for i = 1:5
Expand All @@ -162,7 +162,7 @@
end

%% Plot predictions for other Dex concentrations.
showCases = [1,0,0,0];
showCases = [0,0,1,0];
makePlotsDUSP1(ModelDusp1Fit,ModelGRDusp,DUSP1pars,Dusp1FitCases,showCases)
%% Sample uncertainty for Dusp1 Parameters
%% Compute sensitivity of the FSP solution
Expand Down Expand Up @@ -277,7 +277,7 @@

%% Calibrate PDO from Eric's DUSP1 Intensity Data.
ModelPDOIntensEric = ModelGRDusp100nM;
ModelPDOIntensEric = ModelPDOIntensEric.calibratePDO('EricDataJan23_2024/pdoCalibrationData_EricIntensity_ConcHigh.csv',...
ModelPDOIntensEric = ModelPDOIntensEric.calibratePDO('EricData/pdoCalibrationData_EricIntensity_ConcHigh.csv',...
{'rna'},{'RNA_DUSP1_nuc'},{'Nuc_DUSP1_avg_int_tot'},'AffinePoiss',true,[1,230,0.5]);

%% With PDO for MCP/smFISH
Expand Down Expand Up @@ -381,7 +381,7 @@
% attempt to identify the model from just that data and at just the times
% selected by the FIM.
ModelPDOIntensEric.dataSet = [];
ModelPDOIntensEric = ModelPDOIntensEric.loadData('EricDataJan23_2024/pdoCalibrationData_EricIntensity_DexSweeps.csv',...
ModelPDOIntensEric = ModelPDOIntensEric.loadData('EricData/pdoCalibrationData_EricIntensity_DexSweeps.csv',...
{'rna','Nuc_DUSP1_avg_int_tot'},...
{'Dex_Conc','100'});
load('EricModelDusp1_MMDex','DUSP1parsIntensity')
Expand All @@ -401,7 +401,7 @@
% selected by the FIM.
ModelPDOIntensEricFIM = ModelPDOIntensEric;
ModelPDOIntensEricFIM.dataSet = [];
ModelPDOIntensEricFIM = ModelPDOIntensEricFIM.loadData('EricDataJan23_2024/pdoCalibrationData_EricIntensity_DexSweeps.csv',...
ModelPDOIntensEricFIM = ModelPDOIntensEricFIM.loadData('EricData/pdoCalibrationData_EricIntensity_DexSweeps.csv',...
{'rna','Nuc_DUSP1_avg_int_tot'},...
{'Dex_Conc','100'});
% Set fitting routine only to consider the time points selected by the FIM.
Expand Down Expand Up @@ -473,15 +473,17 @@

%% Extend model to include cytoplasmic mRNA
SSAModelCytoDusp1 = SSAModel;
SSAModelCytoDusp1.ssaOptions.nSimsPerExpt = 20;
SSAModelCytoDusp1.species = {'offGene';'onGene';'cytGR';'nucGR';'rna';'rCyt'};
SSAModelCytoDusp1.initialCondition = [2;0;24;1;5;50];
SSAModelCytoDusp1.propensityFunctions = {'kon*offGene*nucGR';'koff*onGene';
'(kcn0 + (t>0)*kcn1*IDex/(MDex+IDex)) * cytGR';'knc*nucGR';'kg1';'gg1*cytGR';'gg2*nucGR';...
'kr*onGene';'gnuc*rna';...
'kr*onGene';'gnuc*rna/(1+(rna/50)^3)';...
'ktr*rna';'gcyt*rCyt'};
SSAModelCytoDusp1.parameters(4,:) = {'gnuc',0.01}; % add parameter for cytoplasmic decay
SSAModelCytoDusp1.parameters(14,:) = {'gcyt',0.005}; % add parameter for cytoplasmic decay
SSAModelCytoDusp1.parameters(15,:) = {'ktr',0.01896}; % add parameter for cytoplasmic decay
gnuc = 0.00;
SSAModelCytoDusp1.parameters(4,:) = {'gnuc',gnuc}; % add parameter for cytoplasmic decay
SSAModelCytoDusp1.parameters(14,:) = {'gcyt',0.01}; % add parameter for cytoplasmic decay
SSAModelCytoDusp1.parameters(15,:) = {'ktr',DUSP1pars(4)}; % add parameter for cytoplasmic decay
SSAModelCytoDusp1.stoichiometry = [-1,1,0,0,0,0,0,0,0,0,0;...
1,-1,0,0,0,0,0,0,0,0,0;...
0,0,-1,1,1,-1,0,0,0,0,0;...
Expand All @@ -491,12 +493,12 @@

SSAModelCytoDusp1 = SSAModelCytoDusp1.formPropensitiesGeneral('SSAEricCyt');
ssaSolnCyt = SSAModelCytoDusp1.solve;

%
SSAModelCytoDusp1.makePlot(ssaSolnCyt,'meansAndDevs')

%% Make plots of cytoplasmic RNA.
tempCytModel = ModelGRDusp100nM;
tempCytModel = tempCytModel.loadData('EricDataJan23_2024/pdoCalibrationData_EricIntensity_DexSweeps.csv',...
tempCytModel = tempCytModel.loadData('EricData/pdoCalibrationData_EricIntensity_DexSweeps.csv',...
{'rna','RNA_DUSP1_cyto'},...
{'Dex_Conc','100'});
tempCytModel.makeFitPlot
Expand Down
63 changes: 46 additions & 17 deletions WorkSpace/EricModel/RonModelPipelineMar11.m
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@
'gg1',1e-5;'gg2',1e-6;'MDex',5;'Dex0',100});

log10PriorMean = [-1 -1 0 -2,...
-1 -3 -2 -1 -2 -2 -2 0.5];
log10PriorStd = ones(1,12);
-1 -3 -2 -1 -2 -2 -2 0.5, 2];
log10PriorStd = ones(1,13);

ModelGR.fspOptions.initApproxSS = true;

Expand Down Expand Up @@ -168,28 +168,57 @@
end
DUSP1pars = [ModelDusp1Fit{i}.parameters{ModelGRDusp.fittingOptions.modelVarsToFit,2}];

%%
ModelGRDusp100nM = ModelGRDusp.loadData('EricDataJan23_2024/DUSP1_fit_flitered_data_100nM_030624.csv',...
{'rna','RNA_DUSP1_nuc'});
%% Fit DUSP1 model(s) with single parameter set.
for i = 1:5
fitOptions = optimset('Display','iter','MaxIter',50);
duspLogPrior = @(x)-sum((log10(x(:))'-log10PriorMean(1:4)).^2./(2*log10PriorStd(1:4).^2));
ModelGRDusp100nM.fittingOptions.logPrior = duspLogPrior;
for i = 1%:5
fitOptions = optimset('Display','iter','MaxIter',100);
fitOptions.suppressFSPExpansion = true;
combinedDusp1Model = SSITMultiModel(ModelDusp1Fit,ModelDusp1parameterMap);
combinedDusp1Model = combinedDusp1Model.initializeStateSpaces({[0;0;0;2;2;400]});
DUSP1pars = combinedDusp1Model.maximizeLikelihood(...
% combinedDusp1Model = SSITMultiModel(ModelDusp1Fit,ModelDusp1parameterMap,duspLogPrior);
% combinedDusp1Model = combinedDusp1Model.initializeStateSpaces({[0;0;0;2;2;400]});
DUSP1pars = ModelGRDusp100nM.maximizeLikelihood(...
DUSP1pars, fitOptions);
ModelGRDusp100nM.parameters(1:4,2) = num2cell(DUSP1pars);
ModelGRDusp.parameters(1:4,2) = num2cell(DUSP1pars);
save('EricModelDusp1_MMDex','DUSP1pars')
% save('EricModelDusp1_MMDex','DUSP1pars')
end

%% Sample uncertainty for Dusp1 Parameters
% MHFitOptions.thin=1;
% MHFitOptions.numberOfSamples=100;
% MHFitOptions.burnIn=0;
% MHFitOptions.progress=true;
% MHFitOptions.proposalDistribution=@(x)x+0.01*randn(size(x));
% MHFitOptions.numChains = 1;
% MHFitOptions.saveFile = 'TMPEricMHDusp1.mat';
% [~,~,MHResultsDusp1] = combinedDusp1Model.maximizeLikelihood(...
% DUSP1pars, MHFitOptions, 'MetropolisHastings');
% specify prior on parameter values

% Compute FIM
% fignums = [211,221,201,231];
% combinedDusp1Model = combinedDusp1Model.updateModels(DUSP1pars,false,fignums);
fimResults = ModelGRDusp100nM.computeFIM([],'log');
fimTotal = ModelGRDusp100nM.evaluateExperiment(fimResults,ModelGRDusp100nM.dataSet.nCells,...
diag(log10PriorStd))

% Run Metropolis Hastings Search
FIMfree = fimTotal{1}(1:4,1:4);
if min(eig(FIMfree))<1
disp('Warning -- FIM has one or more small eigenvalues. Reducing proposal width to 10x in those directions. MH Convergence may be slow.')
FIMfree = FIMfree + 1*eye(length(FIMfree));
end
covFree = FIMfree^-1;
covFree = 0.5*(covFree+covFree');
%%
MHFitOptions.proposalDistribution=@(x)mvnrnd(x,covFree);
MHFitOptions.thin=1;
MHFitOptions.numberOfSamples=100;
MHFitOptions.burnIn=0;
MHFitOptions.progress=true;
MHFitOptions.numChains = 1;
MHFitOptions.saveFile = 'TMPEricMHDusp1.mat';
[DUSP1pars,~,MHResultsDusp1] = ModelGRDusp100nM.maximizeLikelihood(...
[], MHFitOptions, 'MetropolisHastings');
delete('TMPEricMHDusp1.mat')
%
ModelGRDusp100nM.parameters(1:4,2) = num2cell(DUSP1pars);
figNew = figure;
ModelGRDusp100nM.plotMHResults(MHResultsDusp1,[FIMfree],'log',[],figNew)

%% Make Plots of DUSP1 FIT Results
fignums = [211,221,201,231];
Expand Down
12 changes: 6 additions & 6 deletions WorkSpace/EricModel/makePlotsDUSP1.m
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ function makePlotsDUSP1(ModelDusp1Fit,ModelGRDusp,DUSP1pars,Dusp1FitCases,showCa
313,323,303,333];
ModelPred = cell(size(Dusp1FitCases,1),1);
for i=1:size(PredictionCases,1)
ModelPred{i} = ModelGRDusp.loadData('EricDataJan23_2024/pdoCalibrationData_EricIntensity_DexSweeps.csv',...
{'rna','RNA_DUSP1_nuc'},...
ModelPred{i} = ModelGRDusp.loadData('EricData/pdoCalibrationData_EricIntensity_DexSweeps.csv',...
{'rna','totalNucRNA'},...
{'Dex_Conc',PredictionCases{i,2}});

ModelPred{i}.tSpan = sort(unique([ModelPred{i}.tSpan,linspace(0,180,30)]));
Expand Down Expand Up @@ -57,8 +57,8 @@ function makePlotsDUSP1(ModelDusp1Fit,ModelGRDusp,DUSP1pars,Dusp1FitCases,showCa
for i=1:length(DexConc)
ModelPredDexTtr = ModelGRDusp;
ModelPredDexTtr.dataSet = [];
ModelPredDexTtr = ModelPredDexTtr.loadData('EricDataJan23_2024/pdoCalibrationData_EricIntensity_ConcSweeps.csv',...
{'rna','RNA_DUSP1_nuc'},...
ModelPredDexTtr = ModelPredDexTtr.loadData('EricData/pdoCalibrationData_EricIntensity_ConcSweeps.csv',...
{'rna','totalNucRNA'},...
{'Dex_Conc',DecConcStr{i}});

% Set model parameters to those supplied
Expand Down Expand Up @@ -117,8 +117,8 @@ function makePlotsDUSP1(ModelDusp1Fit,ModelGRDusp,DUSP1pars,Dusp1FitCases,showCa
ModelPredDexTplSoln = cell(size(PredictionCases,1),1);
for i=1:size(PredictionCases,1)
ModelPredDexTpl{i}.dataSet = [];
ModelPredDexTpl{i} = ModelGRDusp.loadData('EricDataJan23_2024/DUSP1_predict_data_TPL_SSIT.csv',...
{'rna','RNA_DUSP1_nuc'},...
ModelPredDexTpl{i} = ModelGRDusp.loadData('EricData/DUSP1_predict_data_TPL_SSIT.csv',...
{'rna','totalNucRNA'},...
{['tryptCond',num2str(i)],num2str(i)});

% Set model parameters to those supplied
Expand Down
Loading

0 comments on commit e28c71c

Please sign in to comment.