forked from lawrennd/gpsim
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgpnddisimPredictRNAConditional.m
149 lines (130 loc) · 4.27 KB
/
gpnddisimPredictRNAConditional.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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
function [priormeans,posteriormeans,covmatrix] = gpnddisimPredictRNAConditional(model,predtimes);
% GPASIMPREDICT Compute predictions (means and a covariance matrix)
% of RNA values for the GPASIM model, conditional on the existing
% POL values in the model but not on any existing RNA values.
%
% FORMAT
%---------------------------------
% DESC computes predictions for the asynchronous Gaussian
% process single input motif model.
%
% ARG model : the model for which the gradient is computed.
%
% ARG pol2times : the time points where predictions for POL2 are needed
%
% ARG rnatime : the time points where predictions for RNA are needed
%
% RETURN means : the predicted mean values, first the POL2
% predictions and then the RNA predictions.
%
% RETURN covmatrix : the covariance matrix between the
% predictions; for example, the diagonal values are the variances
% of each prediction.
%---------------------------------
%
% SEEALSO : gpnddisimCreate
%
% COPYRIGHT : Jaakko Peltonen, 2011
% GPASIMPREDICT
numGenes=model.numGenes;
if numGenes==0,
error('gpnddisimPredictRNAConditional requires a model that has parameters for RNA modeling\n');
end;
% compute prior means
%pol2priormeans=[1:size(predtimes,1)]'*0;
if iscell(predtimes)==0,
pol2priormeans=ones(size(predtimes,1),1)*model.simMean;
else
pol2priormeans=ones(size(predtimes{1},1),1)*model.simMean;
end;
% Mean for the mRNA is nonconstant over time and depends on the
% B,D,S parameters and on the POL2 mean
if numGenes>0,
Bj=model.B(1);
Dj=model.D(1);
Sj=model.S(1);
if model.use_disimstartmean==1,
disimStartMean=model.disimStartMean(1);
end;
end;
% compute the RNA mean curve
if numGenes>0,
rnapriormeans=[];
tempind1=1;
for k=1:numGenes,
if iscell(predtimes)==0,
nt=length(predtimes);
else
nt=length(predtimes{k+1});
end;
rnapriormeans=[rnapriormeans;nan*ones(nt,1)];
if (model.use_disimstartmean==1),
if iscell(predtimes)==0,
tempt=predtimes;
else
tempt=predtimes{k+1};
end;
delayedt=tempt-model.delay(k);
I=find(delayedt<0);
delayedt(I)=0;
if length(delayedt)>0,
rnapriormeans(tempind1:tempind1+nt-1)=...
model.disimStartMean(k)*exp(model.D(k)*(-tempt)) ...
+(model.B(k)/model.D(k))*(1-exp(-model.D(k)*tempt)) ...
+(model.simMean*model.S(k)/model.D(k))*(1-exp(-model.D(k)*delayedt));
end;
else
if iscell(predtimes)==0,
tempt=predtimes;
else
tempt=predtimes{k+1};
end;
delayedt=tempt-model.delay(k);
I=find(delayedt<0);
delayedt(I)=0;
if length(delayedt)>0,
rnapriormeans(tempind1:tempind1+nt-1)=...
((model.B(k)+model.simMean*model.S(k))/model.D(k))*exp(model.D(k)*(-tempt))...
+((model.B(k)+model.simMean*model.S(k))/model.D(k))*(1-exp(-model.D(k)*delayedt));
end;
end;
tempind1=tempind1+nt;
end;
end;
%if model.use_disimstartmean==1,
% rnapriormeans=(Bj+model.simMean*Sj)/Dj+(disimStartMean-(Bj+model.simMean*Sj)/Dj)*exp(Dj*(-predtimes));
%else
% rnapriormeans=(Bj+model.simMean*Sj)/Dj*ones(size(predtimes));
%end;
if 1,
K_new=kernCompute(model.kern, predtimes);
K_new_old=kernCompute(model.kern, predtimes, model.t);
if iscell(predtimes)==0,
K_new=K_new(length(predtimes)+1:2*length(predtimes),length(predtimes)+1:2*length(predtimes));
K_new_old=K_new_old(length(predtimes)+1:2*length(predtimes),1:length(model.t));
else
K_new=K_new(length(predtimes{1})+1:length(predtimes{1})+length(predtimes{2}),length(predtimes{1})+1:length(predtimes{1})+length(predtimes{2}));
K_new_old=K_new_old(length(predtimes{1})+1:length(predtimes{1})+length(predtimes{2}),1:length(model.t{1}));
end;
if iscell(model.t)==0,
K_old=model.K(1:length(model.t),1:length(model.t));
else
K_old=model.K(1:length(model.t{1}),1:length(model.t{1}));
end;
K_old_new=K_new_old';
end;
if iscell(model.t)==0,
tempm=model.m(1:length(model.t));
else
tempm=model.m(1:length(model.t{1}));
end;
priormeans=rnapriormeans;
size(tempm)
size(K_new_old)
size(K_old)
size(priormeans)
posteriormeans=priormeans+K_new_old*(K_old\tempm);
%covmatrix=K_new-K_new_old*inv(K_old)*K_old_new;
covmatrix=K_new-K_new_old*(K_old\K_old_new);
%posteriormeans=real(posteriormeans);
%covmatrix=real(covmatrix);