0001 function models2report( varargin )
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022
0023
0024
0025
0026
0027
0028
0029
0030
0031
0032
0033
0034
0035
0036
0037
0038
0039
0040
0041
0042
0043
0044
0045
0046
0047
0048
0049
0050
0051
0052
0053
0054
0055
0056
0057
0058
0059
0060
0061
0062
0063
0064
0065
0066
0067
0068
0069
0070
0071
0072
0073
0074
0075
0076
0077
0078
0079
0080
0081
0082
0083 param = varargin{2};
0084
0085 param = ml_initparam(param,struct('verbose',true,'includenuclear',true,'includecell',true,'includeprot',true));
0086
0087 models = varargin{1};
0088
0089 n=length(models);
0090
0091 try
0092 indvarlabels = varargin{3};
0093 nolabels=false;
0094 legendentry = regexp(indvarlabels, ';', 'split');
0095 catch
0096 nolabels=true;
0097 end
0098
0099 try
0100 indvar = varargin{4};
0101 if nolabels indvarlabels = 'Indepedent variable'; end
0102 for i = 1:length(indvar)
0103 legendentry{i} = num2str(indvar(i));
0104 end
0105 catch
0106 indvar = [1:n];
0107 if nolabels
0108 indvarlabels = 'Model number';
0109 for i = 1:length(indvar)
0110 legendentry{i} = num2str(indvar(i));
0111 end
0112 end
0113 end
0114
0115 colors = jet(length(indvar));
0116
0117 is3D = strcmpi(models{1}.dimensionality, '3D');
0118
0119 if is3D
0120 protfield = 'proteinShape';
0121 else
0122 protfield = 'proteinModel';
0123 end
0124
0125 [ nuclearparams, cellparams, proteinparams ] = getModelReportParams( models{1}, param );
0126
0127
0128
0129
0130
0131 for j = 1:n
0132 if is3D
0133 compartments{j} = eval(['models{j}.' protfield '.cytonuclearflag']);
0134 else
0135 compartments{j} = 'all';
0136 end
0137 end
0138
0139
0140 y = [];
0141 if param.includeprot
0142
0143 for j=1:n
0144
0145
0146
0147 for i=1:length(proteinparams)
0148 y(j,i)=eval(['models{j}.' protfield '.' proteinparams{i}]');
0149 end
0150
0151 if is3D
0152 [positionBeta, fractdist] = beta2posMap(models{j}.proteinShape.position.beta);
0153 else
0154 [positionBeta, fractdist] = beta2posMap(models{j}.proteinModel.positionModel.beta);
0155 end
0156
0157 objpdf = squeeze(sum(sum(positionBeta,1),3));
0158
0159 if strcmpi(compartments{j}, 'cyto')
0160 domain = fractdist >= 0;
0161 objpdf(~domain) = [];
0162 objpdf = [zeros(1,1+sum(~domain)), objpdf ] ;
0163 fractdists{j} = [fractdist(~domain) 0 fractdist(domain)];
0164
0165 elseif strcmpi(compartments{j}, 'nuc')
0166 domain = fractdist <= 0;
0167 objpdf(~domain) = [];
0168 objpdf = [objpdf zeros(1,1+sum(~domain))];
0169 fractdists{j} = [fractdist(domain) 0 fractdist(~domain)];
0170
0171 else
0172 fractdists{j} = fractdist;
0173 end
0174
0175
0176 objpdf = objpdf./sum(objpdf);
0177
0178 objpdfs{j} = objpdf;
0179 end
0180
0181
0182 end
0183
0184
0185
0186 y2 = [];
0187 y3 = []; cellparams = [];
0188 if param.includenuclear | param.includecell
0189 if param.includenuclear
0190
0191 for i=1:length(nuclearparams)
0192 for j=1:n
0193 y2(j,i)=eval(['models{j}.nuclearShapeModel.' nuclearparams{i}]');
0194 end
0195 end
0196
0197 end
0198
0199 tparam = [];
0200 tparam.generatemeanshape = true;
0201 tparam.display = false;
0202 tparam.debug = false;
0203
0204 havealready = length(nuclearparams);
0205 for j=1:n
0206 model = models{j};
0207 tparam.resolution.cell = model.cellShapeModel.resolution;
0208 tparam.resolution.objects = eval(['model.' protfield '.resolution']);
0209
0210
0211 if is3D
0212 instance = tp_genspsurf(model.nuclearShapeModel,tparam);
0213 [nucimg,nucsurf,outres] = tp_gennucshape(instance,tparam);
0214
0215 nucleus.nucimgsize = size(nucimg);
0216 nucleus.nucsurf = nucsurf; clear nucsurf;
0217 nucleus.nucimg = nucimg; clear nucimg;
0218
0219 [cellimg,nucimg] = ml_gencellshape3d( ...
0220 model.cellShapeModel, nucleus,tparam );
0221
0222 if param.includenuclear
0223 stats=rm_get3Dstats(nucimg);
0224 statnames = fieldnames(stats);
0225 for k=1:length(statnames)
0226 y2(j,k+havealready) = eval(['stats.' statnames{k}]);
0227 nuclearparams{k+havealready} = statnames{k};
0228 end
0229
0230 clear nucimg;
0231 end
0232
0233 if param.includecell
0234 stats=rm_get3Dstats(cellimg);
0235 statnames = fieldnames(stats);
0236 for k=1:length(statnames)
0237 y3(j,k) = eval(['stats.' statnames{k}]);
0238 end
0239 cellparams=statnames';
0240
0241 clear cellimg;
0242 end
0243
0244 end
0245 end
0246 end
0247
0248 paramnames = [proteinparams nuclearparams cellparams];
0249 yall = [y y2 y3];
0250
0251
0252
0253
0254
0255
0256
0257
0258
0259
0260 figure
0261 npanel = length(paramnames);
0262 ncolumns = 3; nrows = 5; ntot = ncolumns*nrows;
0263 for iplot=1:ceil(npanel/ntot);
0264 nleft = npanel-(iplot-1)*ntot;
0265 for i=(iplot-1)*ntot+1:(iplot-1)*ntot+min(nleft,ntot)
0266 subplot((ceil(min(nleft,ntot)/ncolumns)),ncolumns,i-(iplot-1)*ntot);
0267 plot(indvar,yall(:,i),'rd-');
0268 xlabel(indvarlabels);
0269 ylabel(paramnames{i});
0270 end
0271 figure
0272 end
0273
0274 normy = yall./repmat(mean(yall),n,1);
0275 cv=std(normy);
0276 [sorted,order]=sort(cv,'descend');
0277
0278 idx = find(sorted>0.5);
0279 mintodisplay = 3;
0280 if length(idx)> mintodisplay
0281 order = order(find(sorted>0.5));
0282
0283 else
0284 order = order(1:mintodisplay);
0285
0286 end
0287
0288 colorstr = {'rd-','g+-','b^-','co-','mv-','yx-'};
0289 for i=1:min(length(colorstr),length(order))
0290 plot(indvar,normy(:,order(i)),colorstr{i});
0291 legends{i}=paramnames{order(i)};
0292 hold on;
0293 end
0294 legend(legends);
0295 xlabel(indvarlabels);
0296 ylabel('Coefficient of variation');
0297 title('Parameters ordered by extent of variation');
0298 hold off;
0299
0300 if param.includeprot
0301 figure,
0302 for i = 1:length(models)
0303
0304
0305 plot(fractdists{i}, objpdfs{i} , 'color', colors(i,:), 'LineWidth',2)
0306 hold on;
0307 end
0308
0309 xlabel('Fractional distance between nuclear and plasma membranes')
0310 ylabel('Relative probability density')
0311 legend(legendentry);
0312 set(gca,...
0313 'YTickLabel','')
0314
0315
0316
0317 if is3D
0318
0319
0320 objmu = y(:,strcmpi(proteinparams, 'frequency.mu'));
0321 objsigma = y(:,strcmpi(proteinparams, 'frequency.sigma'));
0322 xrange = [0 max(exp(objmu+objsigma))];
0323
0324 figure,
0325 for i = 1:length(models)
0326 semilogx(xrange(1):xrange(2), lognpdf(xrange(1):xrange(2), objmu(i), objsigma(i)), 'color', colors(i,:), 'LineWidth',2)
0327 hold on
0328 end
0329 xlabel('Number of objects')
0330 ylabel('Relative probability density')
0331 legend(legendentry);
0332 set(gca,...
0333 'YTickLabel','')
0334 else
0335 objalpha = y(:,strcmpi(proteinparams, 'objectModel.numStatModel.alpha'));
0336 objbeta = y(:,strcmpi(proteinparams, 'objectModel.numStatModel.beta'));
0337
0338 xrange = 0:1000;
0339
0340 for i = 1:length(models)
0341 gamcdfs(i,:) = gamcdf(xrange, objalpha(i), objbeta(i));
0342 gampdfs(i,:) = gampdf(xrange, objalpha(i), objbeta(i));
0343 end
0344
0345 inds = any(gamcdfs < 0.95,1);
0346
0347 figure,
0348
0349 for i = 1:length(models)
0350 plot(xrange(inds), gampdfs(i,inds)','color', colors(i,:))
0351 legendentry{i} = num2str(indvar(i));
0352 hold on
0353 end
0354
0355 xlabel('Number of objects')
0356 ylabel('Relative probability density')
0357 legend(legendentry);
0358 set(gca,...
0359 'YTickLabel','')
0360 end
0361 end
0362
0363 end