forked from lawrennd/gpsim
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgpsimMapExtractParam.m
102 lines (86 loc) · 2.7 KB
/
gpsimMapExtractParam.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
function [param, names] = gpsimMapExtractParam(model)
% GPSIMMAPEXTRACTPARAM Extract the parameters of a GPSIMMAP model.
% FORMAT
% DESC extracts the model parameters from a structure containing
% the information about a Gaussian process for single input motif
% modelling.
% ARG model : the model structure containing the information about
% the model.
% RETURN params : a vector of parameters from the model.
%
% SEEALSO : gpsimMapCreate, gpsimMapExpandParam, modelExtractParam
%
% COPYRIGHT : Neil D. Lawrence, 2006
%
% MODIFIED : Pei Gao, 2008
% SHEFFIELDML
if nargout>1
[param, names] = kernExtractParam(model.kern);
else
param = kernExtractParam(model.kern);
end
fhandle = str2func([model.Transform 'Transform']);
for i = 1:model.numGenes
if isfield(model,'bTransform') && isempty(model.bTransform);
param = [param model.B(i)];
else
param = [param fhandle(model.B(i), 'xtoa')];
end
param = [param fhandle(model.S(i), 'xtoa') fhandle(model.D(i), ...
'xtoa')];
if isfield(model, 'includeRepression') && model.includeRepression
if isfield(model,'alphaTransform') && isempty(model.alphaTransform);
param = [param model.alpha(i)];
else
param = [param fhandle(model.alpha(i), 'xtoa')];
end
end
if model.ngParam > 0
param = [param (fhandle(model.gParam(:,i), 'xtoa'))'];
end
if nargout >1
names{end+1} = ['Basal' num2str(i)];
names{end+1} = ['Sensitivity' num2str(i)];
names{end+1} = ['Decay' num2str(i)];
if isfield(model, 'isGroupNonlinearity') && model.isGroupNonlinearity
if strcmp(model.nonLinearity{i}, 'repression')
names{end+1} = ['alpha' num2str(i)];
end
else
names{end+1} = ['alpha' num2str(i)];
end
if model.ngParam > 0
ngParamk = model.ngParam/model.numGenes;
names{(end+1):(end+ngParamk)} = ['Parameters for g' num2str(i)];
end
end
end
if isfield(model,'includeNoise') && model.includeNoise
param = [param fhandle(sqrt(model.noiseVar), 'xtoa')];
if nargout > 1
for i=1:model.numGenes
names = {names{:} ['noiseSd' num2str(i)]};
end
end
end
if isfield(model, 'fix')
for i = 1:length(model.fix)
param(model.fix(i).index) = model.fix(i).value;
end
end
param = real(param);
% Check if there is a mean function.
if isfield(model, 'meanFunction') & ~isempty(model.meanFunction)
if nargout>1
[meanFuncParams, meanFuncNames] = modelExtractParam(model.meanFunction);
else
meanFuncParams = modelExtractParam(model.meanFunction);
end
else
meanFuncParams =[];
meanFuncNames = {};
end
param = [param meanFuncParams];
if nargout > 1
names = {names{:} meanFuncNames{:}};
end