forked from lawrennd/gpsim
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgpsimCandidateExpandParam.m
59 lines (52 loc) · 2.14 KB
/
gpsimCandidateExpandParam.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
function model = gpsimCandidateExpandParam(model, params)
% GPSIMCANDIDATEEXPANDPARAM Expand the given parameters for a candidate gene.
% FORMAT
% DESC takes the given vector of parameters for a new candidate gene and places them in the
% model structure, it then updates any stored representations that
% are dependent on those parameters, for example kernel matrices
% etc..
% ARG model : the model structure for which parameters are to be
% updated.
% ARG params : a vector of parameters for placing in the model
% structure.
% RETURN model : a returned model structure containing the updated
% parameters.
%
% SEEALSO : gpsimExpandParam, gpsimCandidateExtractParam, modelExtractParam
%
% COPYRIGHT : Neil D. Lawrence, 2007
% SHEFFIELDML
params = real(params);
if isfield(model, 'fix')
for i = 1:length(model.candidate.fix)
params(model.candidate.fix(i).index) = model.candidate.fix(i).value;
end
end
if length(params) ~= model.candidate.numParams
error('Parameter vector is incorrect length');
end
baseKernParam = kernExtractParam(model.kern);
startVal = 1;
endVal = model.candidate.kern.nParams-model.kern.nParams;
% pad out parameters for candidate kernel with those from true kernel.
model.candidate.kern = kernExpandParam(model.candidate.kern, [baseKernParam ...
params(startVal:endVal)]);
fhandle = str2func([model.candidate.bTransform 'Transform']);
model.candidate.B = fhandle(params(endVal+1:end), 'atox');
% The decays and sensitivities are actually stored in the kernel.
% We'll put them here as well for convenience.
% Only take ones associated with candidate kernel.
counter = 0;
for i = model.kern.numBlocks+1:model.candidate.kern.numBlocks
counter = counter + 1;
model.candidate.D(counter) = model.candidate.kern.comp{i}.decay;
model.candidate.S(counter) = sqrt(model.candidate.kern.comp{i}.variance);
end
model.candidate.mu = model.candidate.B./model.candidate.D;
model = gpsimCandidateUpdateKernels(model);
lengthObs = size(model.candidate.t, 1);
ind = 1:lengthObs;
for i = 1:model.candidate.numGenes
model.candidate.m(ind) = model.candidate.y(ind) - model.candidate.mu(i)*ones(lengthObs, 1);
ind = ind + lengthObs;
end