forked from lawrennd/gpsim
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgpsimXGradient.m
52 lines (40 loc) · 1.26 KB
/
gpsimXGradient.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
function [dxdB dxdD dxdS dxdalpha dxdgParam] = gpsimXGradient(model, i, j)
% GPSIMXGRADIENT ...
%
% COPYRIGHT : Pei Gao, 2008
% SHEFFIELDML
% i: ti
% j: jth gene
dxdB = 1./model.D(j);
endPoint = model.times_index(i);
dxdD = 0;
dxdS = 0;
dxdalpha = [];
dxdgParam = [];
if model.ngParam > 0
ngParamk = model.ngParam/model.numGenes;
dxdgParam = zeros(1, ngParamk);
gInd = j;
else
gInd = 1;
end
for m = 1:endPoint
arg = model.t(i)-model.mapt(m);
if arg >= 0
dxdD = dxdD+model.g(m,gInd)*arg*exp(-model.D(j)*arg+log(model.step)+log(model.S(j)));
dxdS = dxdS+exp(-model.D(j)*arg+log(model.step))*model.g(m,gInd); % g=Sf
if model.ngParam > 0
for gParamInd = 1:ngParamk
dxdgParam(gParamInd) = dxdgParam(gParamInd) + exp(- ...
model.D(j)*arg+log(model.step)+log(model.S(j)))*model.dg(m,gInd);
end
end
end
end
dxdD = -model.B(j)/(model.D(j)*model.D(j))-dxdD;
% check if g(f) is different for each gene.
if isfield(model, 'isGroupNonlinearity') && strcmp(model.nonLinearity{j}, ...
'repression')
dxdalpha = exp(-model.D(j)*model.t(i));
dxdD = -model.t(i)*model.alpha(j)*exp(-model.D(j)*model.t(i))+dxdD;
end