Commit 067d60d4 authored by Antonio Politi's avatar Antonio Politi

Modeling variants equations

* Alternative production
* Multistep and distributed delay model
parent 26cede72
function [dist, distI, distM] = afitround(MO, par, ifit, nrfits, parfile)
denfile = fullfile(MO.outdir,[parfile '_den.txt']);
prodratefile = fullfile(MO.outdir, [parfile '_prodrate.txt']);
fractionMaturefile = fullfile(MO.outdir, [parfile '_fracM.txt']);
parfile = [parfile '.txt'];
MO.runFit(par, ifit, nrfits, 0.5, parfile)
MO.plotBestfit(fullfile(MO.outdir, parfile), 1, 1);
parf = MO.getBestfit(fullfile(MO.outdir, parfile));
[dist, distI, distM] = MO.distMO(parf(ifit), ifit, parf);
dist = sum(dist.^2);
distI = sum(distI.^2);
distM = [sum(distM.^2) sum(distM(1:12).^2) sum(distM(13:24).^2)];
MO.writeDensities(parf,denfile);
MO.writeProdRate(parf, prodratefile);
MO.writeFractionMatureIP(parf, fractionMaturefile);
%%
[soli, solo] = MO.solve(parf, [parf(1) 1200]);
timPM = [180:1:1200];
yi = deval(soli, timPM);
yo = deval(solo, timPM);
A = MO.getSurf(timPM);
mean(yi(3,:)./A*0.68 + yo(3,:)./A*0.32)
std(yi(3,:)./A*0.68 + yo(3,:)./A*0.32)
mean((yi(1,:)+yi(2,:))./A*0.68 + (yi(1,:)+yi(2,:))./A*0.32)
std((yi(1,:)+yi(2,:))./A*0.68 + (yi(1,:)+yi(2,:))./A*0.32)
end
\ No newline at end of file
%%
% dealyedMaturation model with production proportional to free area
% V = v*A
% par(1): ts, start of interphase assembly
% par(2): v, maximal rate of interphase assembly
% par(3): kM, initiation of maturation
% par(4): tauM, maturation time
% par(5): kd, decay of Mature pore
% par(6): number of minipores at ts inner core
% par(7): number of mature pores at ts inner core
% par(7): number of minipores at ts outer core
% par(8): number of mature pores at ts outer core
classdef delayedMaturation < absDelayedMaturation
methods
function MO = delayedMaturation(surf, useSpline, force)
MO@absDelayedMaturation(surf, useSpline, force)
MO.dataF = MO.dataA;
for i =1:2
MO.dataF(i).noncore = MO.dataF(i).d_noncore;
MO.dataF(i).core_i = MO.dataF(i).d_core_i;
MO.dataF(i).core_o = MO.dataF(i).d_core_o;
end
MO.parnames = 'ts v kM tauM kd P01 M01 P02 M02';
MO.LB = [0, 0, 0.01, 10, 0, 0, 0,0,0]; %Low boundary values
MO.HB = [15, 1, 10, 70, 1, 10000, 10000, 10000, 10000]; %High boundary values
MO.name = mfilename('class')
MO.N = 3;
end
%%
% solve equations for one set of parameters and provide the
function [soli, solo] = solve(MO, par, timeint)
soli = dde23(@MO.dde,[par(4)],@MO.ddehist1, timeint, ddeset, par);
solo = dde23(@MO.dde,[par(4)],@MO.ddehist2, timeint, ddeset, par);
end
%%
% get production rate of minipores and mature pores coming from PM
% only
function [prodRate, maturePM] = getProdRate(MO, par, timeint)
A = MO.getSurf(timeint);
prodRate = [par(2)*(timeint>=par(1)) par(2)*(timeint>=par(1))];
maturePM = [par(7)*exp(-par(5)*(timeint - par(1)))./A par(9)*exp(-par(5)*(timeint - par(1)))./A];
end
function obs = getObservable(MO,sol)
obs(:,1) = sol(1,:)'+ sol(2,:)';
obs(:,2) = sol(3,:)';
end
function s = ddehist1(MO,t,par)
% Constant history function for DDEX1.
s = [0, 0, par(7)];
if t == par(1)
s = [par(6), 0, par(7)];
end
end
function s = ddehist2(MO,t,par)
% Constant history function for DDEX1.
s = [0, 0, par(9)];
if t == par(1)
s = [par(8), 0, par(9)];
end
end
function dydt = dde(MO, t, y, Z, par)
% par(1): ts, start of interphase assembly
% par(2): v, maximal rate of interphase assembly
% par(3): kM, initiation of maturation
% par(4): tauM, maturation time
% par(5): kd, decay of Mature pore
% par(6): number of minipores at ts
% par(7): number of mature pores at 0
% Delay Differential equations function for DDEX1.
ylag = Z(:,1);
if t > par(1)
v = par(2);
else
v = 0;
end
A = MO.getSurf(t);
dydt = [ v*A - par(3)*y(1)
par(3)*y(1) - par(3)*ylag(1)
par(3)*ylag(1) - par(5)*y(3)];
end
function [par, norm] = testFit(MO)
ts = 10;
At0 = MO.getSurf(ts);
P01 = 4.493*At0;
M01 = 4.79*At0;
P02 = 3.935*At0;
M02 = 9.048*At0;
if nargin < 2
par = [ts, 0.014, 1.136, 40, 4.2e-04, P01, M01, P02, M02];
end
ifit = [2:4 6:9];
[parf, norm] = MO.fitModel(ifit, par)
par(ifit) = parf;
MO.plotResult(par)
end
end
end
\ No newline at end of file
%%
% dealyedMaturation model with production proportional to free area
% V = v*A.
% delay is uniform distributed along tauM1 and tauM2
% par(1): ts, start of interphase assembly
% par(2): v, maximal rate of interphase assembly
% par(3): kM, initiation of maturation
% par(4): tauM1, lowest maturation time
% par(5): DtauM, tauM1 + DtauM gives the highest maturation time tauM2
% par(6): kd, decay of Mature pore
% par(7): number of minipores at ts inner core
% par(8): number of mature pores at ts inner core
% par(9): number of minipores at ts outer core
% par(10): number of mature pores at ts outer core
classdef delayedMaturationDistributedDelay < absDelayedMaturation
methods
function MO = delayedMaturationDistributedDelay(surf, useSpline, force)
MO@absDelayedMaturation(surf, useSpline, force)
MO.dataF = MO.dataA;
for i =1:2
MO.dataF(i).noncore = MO.dataF(i).d_noncore;
MO.dataF(i).core_i = MO.dataF(i).d_core_i;
MO.dataF(i).core_o = MO.dataF(i).d_core_o;
end
MO.parnames = 'ts v kM tauM dtauM kd P01 M01 P02 M02';
MO.LB = [0, 0, 0.1, 12, 0.1, 0, 0, 0, 0, 0]; %Low boundary values
MO.HB = [15, 1, 10, 70, 30, 1, 5000, 5000, 5000, 5000]; %High boundary values
MO.N = 3;
MO.name = mfilename('class')
end
function obs = getObservable(MO,sol)
obs(:,1) = sol(1,:)'+ sol(2,:)';
obs(:,2) = sol(3,:)';
end
%%
% solve equations for one set of parameters and provide the
function [soli, solo] = solve(MO, par, timeint)
prei = ode15s(@MO.prec, timeint, par(7),odeset, par);
soli = ode15s(@MO.mat, timeint, [par(7) 0 par(8)], odeset, par, prei);
preo = ode15s(@MO.prec,timeint, par(9), odeset, par);
solo = ode15s(@MO.mat, timeint, [par(9) 0 par(10)], odeset, par, preo);
end
%%
% get production rate of minipores and mature pores coming from PM
% only
function [prodRate, maturePM] = getProdRate(MO, par, timeint)
A = MO.getSurf(timeint);
prodRate = [par(2)*(timeint>=par(1)) par(2)*(timeint>=par(1))];
maturePM = [par(8)*exp(-par(6)*(timeint - par(1)))./A par(10)*exp(-par(6)*(timeint - par(1)))./A];
end
function dydt = prec(MO,t,y, par)
if t >= par(1)
v = par(2);
else
v = 0;
end
A = MO.getSurf(t);
dydt = [v*A - par(3)*y(1)];
end
function p = precA(MO, t, par)
p = par(2)/par(3)-(par(2)/par(3)-par(7))*exp(-par(3)*(t-par(1)));
end
function dydt = mat(MO,t,y, par, pre)
if t >= par(1)
v = par(2);
else
v = 0;
end
if t < par(4) + par(1)
dPre = 0;
end
%% Analytical solution of simplest integral without area effect
% if t >= par(4) + par(1) && t < par(5) + par(4) + par(1)
% dPre= 1/par(5)*(par(2)*(t-par(4)-par(1))+par(7) - MO.precA(t-par(4), par));
% end
% if t >= par(5) + par(4) + par(1)
% dPre= 1/par(5)*(par(2)*par(5) + MO.precA(t-par(4)-par(5),par)- MO.precA(t-par(4), par));
% end
A = MO.getSurf(t);
tauM2 = par(4) + par(5)/2;
tauM1 = par(4) - par(5)/2;
if t >= tauM1 + par(1) && t < tauM2 + par(1)
pre4 = deval(pre, t - tauM1 );
pre5 = deval(pre, par(1));
%compute difference of integrals in surface
dPre = 1/par(5)*(pre5-pre4 + v*integral(@MO.getSurf, par(1), t-tauM1));
end
if t >= tauM2 + par(1)
pre4 = deval(pre, t-tauM1);
pre5 = deval(pre, t-tauM2);
dPre = 1/par(5)*(pre5 - pre4 + v*integral(@MO.getSurf, t-tauM2, t-tauM1));
end
dydt = [v*A - par(3)*y(1)
par(3)*deval(pre,t) - dPre
dPre - par(6)*y(3)];
end
function [par, norm] = testFit(MO)
ts = 10;
At0 = MO.getSurf(ts);
P01 = 4.493*At0;
M01 = 4.79*At0;
P02 = 3.935*At0;
M02 = 9.048*At0;
if nargin < 2
par = [ts, 0.014, 1.136, 40, 4.2e-04, P01, M01, P02, M02];
end
ifit = [3:4 6:9];
[parf, norm] = MO.fitModel(ifit, par)
par(ifit) = parf;
MO.plotResult(par)
end
end
end
\ No newline at end of file
%%
% dealyedMaturation model with production proportional to free area
% V = A*(vmax*exp(-k(t-ts))+v0)
% par(1): ts, start of interphase assembly
% par(2): vmax, maximal rate of interphase assembly
% par(3): kv, rate of decay
% par(4): v0, basal production rate
% par(5): kM, initiation of maturation
% par(6): tauM, maturation time
% par(7): kd, decay of Mature pore
% par(8): number of minipores at ts inner core
% par(9): number of mature pores at ts inner core
% par(10): number of minipores at ts outer core
% par(11): number of mature pores at ts outer core
classdef delayedMaturationExponentialV < absDelayedMaturation
methods
function MO = delayedMaturationExponentialV(surf, useSpline, force)
MO@absDelayedMaturation(surf, useSpline, force)
MO.dataF = MO.dataA;
for i =1:2
MO.dataF(i).noncore = MO.dataF(i).d_noncore;
MO.dataF(i).core_i = MO.dataF(i).d_core_i;
MO.dataF(i).core_o = MO.dataF(i).d_core_o;
end
MO.parnames = 'ts vmax kv v0 kM tauM kd P01 M01 P02 M02';
MO.name = mfilename('class')
% ts, vmax, kv, v0, kM, tauM, kd, P01, M01, P02, M02
MO.LB = [0, 0, 0.001, 0, 0, 0, 0, 0, 0, 0, 0]; %Low boundary values
MO.HB = [15, 100, 100, 1, 10, 70, 1, 5000, 5000, 5000, 5000]; %High boundary values
end
function obs = getObservable(MO,sol)
obs(:,1) = sol(1,:)'+ sol(2,:)';
obs(:,2) = sol(3,:)';
end
%%
% solve equations for one set of parameters and provide the
function [soli, solo] = solve(MO, par, timeint)
soli = dde23(@MO.dde,[par(6)],@MO.ddehist1,timeint, ddeset, par);
solo = dde23(@MO.dde,[par(6)],@MO.ddehist2,timeint, ddeset, par);
end
function [prodRate, maturePM] = getProdRate(MO, par, timeint)
A = MO.getSurf(timeint);
prodRate = [(par(2)*exp(-par(3)*(timeint - par(1)))+par(4)).*(timeint>=par(1)) (par(2)*exp(-par(3)*(timeint-par(1)))+par(4)).*(timeint>=par(1))];
maturePM = [par(9)*exp(-par(7)*(timeint - par(1)))./A par(11)*exp(-par(7)*(timeint - par(1)))./A];
end
function s = ddehist1(MO,t,par)
% Constant history function for DDEX1.
s = [0, 0, par(9)];
if t == par(1)
s = [par(8), 0, par(9)];
end
end
function s = ddehist2(MO,t,par)
% Constant history function for DDEX1.
s = [0, 0, par(11)];
if t == par(1)
s = [par(10), 0, par(11)];
end
end
function dydt = dde(MO, t, y, Z, par)
% par(1): ts, start of interphase assembly
% par(2): vmax, maximal rate of interphase assembly
% par(3): kv, rate of decay
% par(4): basal production rate
% par(5): kM, initiation of maturation
% par(6): tauM, maturation time
% par(7): kd, decay of Mature pore
% Delay Differential equations function for DDEX1.
ylag = Z(:,1);
if t > par(1)
v = par(2)*exp(-par(3)*(t-par(1)))+par(4);
else
v = 0;
end
A = MO.getSurf(t);
dydt = [ v*A - par(5)*y(1)
par(5)*y(1) - par(5)*ylag(1)
par(5)*ylag(1) - par(7)*y(3)];
end
function [par, norm] = testFit(MO)
ts = 15;
At0 = MO.getSurf(ts);
P01 = 0.0*4.493*At0;
M01 = 4.79*At0;
P02 = 0*3.935*At0;
M02 = 9.048*At0;
if nargin < 2
par = [ts, 2, 0.1, 0.014, 0.1, 40, 4.2e-04, P01, M01, P02, M02];
end
ifit = [2:4 5 6 9 11];
[parf, norm] = MO.fitModel(ifit, par)
par(ifit) = parf;
MO.plotResult(par)
end
end
end
\ No newline at end of file
%%
% dealyedMaturation model with production proportional to free area
% V = k*(A(t)*rho0-Total_number_pores)
% par(1): ts, start of interphase assembly
% par(2): k, maximal rate of interphase assembly
% par(3): rho0, steady state interphase density
% par(4): kM, initiation of maturation
% par(5): tauM, maturation time
% par(6): kd, decay of Mature pore
% par(7): number of minipores at ts
% par(8): number of mature pores at 0
classdef delayedMaturationSteadyRho < absDelayedMaturation
properties
end
methods
function MO = delayedMaturationSteadyRho(surf, useSpline, force)
MO@absDelayedMaturation(surf, useSpline, force)
MO.dataF = MO.dataA;
for i =1:2
MO.dataF(i).noncore = MO.dataF(i).d_noncore;
MO.dataF(i).core_i = MO.dataF(i).d_core_i;
MO.dataF(i).core_o = MO.dataF(i).d_core_o;
end
MO.N = 3;
MO.parnames = 'ts k rho0 kM tauM kd P01 M01 P02 M02';
MO.name = mfilename('class')
MO.LB = [0, 0, 8, 0.1, 10, 0, 0, 0,0,0]; %Low boundary values
MO.HB = [15, 1, 15, 10, 70, 1, 5000, 5000, 5000, 5000]; %High boundary values
end
function obs = getObservable(MO,sol)
obs(:,1) = sol(1,:)'+ sol(2,:)';
obs(:,2) = sol(3,:)';
end
%%
% solve equations for one set of parameters and provide the
function [soli, solo] = solve(MO, par, timeint)
soli = dde23(@MO.dde,[par(5)],@MO.ddehist1,timeint, ddeset, par);
solo = dde23(@MO.dde,[par(5)],@MO.ddehist2,timeint, ddeset, par);
end
%%
% get production rate of minipores and mature pores coming from PM
% only
function [prodRate, maturePM] = getProdRate(MO, par, timeint)
[soli, solo] = solve(MO, par, [par(1) timeint(end)]);
A = MO.getSurf(timeint);
yi = deval(soli, timeint);
yo = deval(solo, timeint);
obsi = MO.getObservable(yi);
obso = MO.getObservable(yo);
k = par(2)*(timeint >= par(1));
prodRate = [(k.*(A*par(3) - obsi(:,1)-obsi(:,2)))./A (k.*(A*par(3) - obso(:,1)-obso(:,2)))./A];
maturePM = [par(8)*exp(-par(6)*(timeint - par(1)))./A par(10)*exp(-par(6)*(timeint - par(1)))./A];
end
function s = ddehist1(MO,t,par)
% Constant history function for DDEX1.
s = [0, 0, par(8)];
if t == par(1)
s = [par(7), 0, par(8)];
end
end
function s = ddehist2(MO,t,par)
% Constant history function for DDEX1.
s = [0, 0, par(10)];
if t == par(1)
s = [par(9), 0, par(10)];
end
end
function dydt = dde(MO, t, y, Z, par)
% par(1): ts, start of interphase assembly
% par(2): k, maximal rate of interphase assembly
% par(3): rho0, steady state interphase density
% par(4): kM, initiation of maturation
% par(5): tauM, maturation time
% par(6): kd, decay of Mature pore
% par(7): number of minipores at ts
% par(8): number of mature pores at 0
% Delay Differential equations function for DDEX1.
ylag = Z(:,1);
if t > par(1)
k = par(2);
else
k = 0;
end
A = MO.getSurf(t);
dydt = [ k*(A*par(3) - y(1) - y(2) -y(3)) - par(4)*y(1)
par(4)*y(1) - par(4)*ylag(1)
par(4)*ylag(1) - par(6)*y(3)];
end
function [par, norm] = testFit(MO)
ts = 10;
At0 = MO.getSurf(ts);
P01 = 4.493*At0;
M01 = 4.79*At0;
P02 = 3.935*At0;
M02 = 9.048*At0;
if nargin < 2
par = [ts, 0.014, 12, 1.136, 40, 4.2e-04, P01, M01, P02, M02];
end
ifit = [2:5 7:10];
%ifit = [2:5 8 10];
[parf, norm] = MO.fitModel(ifit, par)
par(ifit) = parf;
MO.plotResult(par)
end
end
end
\ No newline at end of file
%%
% linearChainApproximation model with production proportional to free area
% linear steps
% V = v*A
% par(1): ts, start of interphase assembly
% par(2): v, maximal rate of interphase assembly
% par(3): mean rate constant
% par(4): std of rate constants
% par(5): kd, degradation rate constant of mature pores
% par(5): number of minipores at ts inner core
% par(6): number of mature pores at ts inner core
% par(7): number of minipores at ts outer core
% par(8): number of mature pores at ts outer core
classdef linearChainApproximation < absDelayedMaturation
methods
function MO = linearChainApproximation( surf, useSpline, force, N)
MO@absDelayedMaturation(surf, useSpline, force)
MO.dataF = MO.dataA;
for i =1:2
MO.dataF(i).noncore = MO.dataF(i).d_noncore;
MO.dataF(i).core_i = MO.dataF(i).d_core_i;
MO.dataF(i).core_o = MO.dataF(i).d_core_o;
end
MO.parnames = 'ts v k stdk kd P01 M01 P02 M02';
MO.LB = [0, 0, 0.01, 0, 0, 0, 0, 0, 0]; %Low boundary values
MO.HB = [15, 1, 10, 10, 1, 5000, 5000, 5000, 5000]; %High boundary values
MO.N = N;
end
function obs = getObservable(MO, sol)
obs(:,1) = sum(sol(1:end-1,:),1);
obs(:,2) = sol(end,:);
end
%%
% get production rate of minipores and mature pores coming from PM
% only
function [prodRate, maturePM] = getProdRate(MO, par, timeint)
A = MO.getSurf(timeint);
prodRate = [par(2)*(timeint>=par(1)) par(2)*(timeint>=par(1))];
maturePM = [par(7)*exp(-par(5)*(timeint - par(1)))./A par(9)*exp(-par(5)*(timeint - par(1)))./A];
end
function [soli, solo] = solve(MO, par, timeint)
m = par(3);
v = par(4);
mu = log((m^2)/sqrt(v+m^2));
sigma = sqrt(log(v/(m^2)+1));
pval = [par(2) lognrnd(mu,sigma,1,MO.N-1) par(5)];
soli = ode45(@MO.odeFun, timeint, [par(6) zeros(1,MO.N-2) par(7)], odeset, pval);
solo = ode45(@MO.odeFun, timeint, [par(8) zeros(1,MO.N-2) par(9)], odeset, pval);
end
function dydt = odeFun(MO, t, y, par)
A = MO.getSurf(t);
M1 = diag(-1*ones(1,MO.N));
M2 = diag(ones(1,MO.N),-1);
M = M1*diag(par(2:end)) + M2(1:end-1, 1:end-1)*diag(par(2:end));
dydt = M*y + [par(1)*A zeros(1,MO.N-1)]';
end
end
end
\ No newline at end of file
%%
% linearChainApproximation model with production proportional to free area
% linear steps
% V = v*A
% par(1): ts, start of interphase assembly
% par(2): v, maximal rate of interphase assembly
% par(3): mean rate constant
% par(4): std of rate constants
% par(5): kd, degradation rate constant of mature pores
% par(5): number of minipores at ts inner core
% par(6): number of mature pores at ts inner core
</