This is a static copy of a profile report

Home

fit_Gaussian_model2 (14 calls, 0.262 sec)
Generated 14-Nov-2016 07:47:11 using cpu time.
function in file /home/user/dev/ymap/scripts_seqModules/fit_Gaussian_model2.m
Copy to new window for comparing multiple runs

Parents (calling functions)

Function NameFunction TypeCalls
FindChrSizes_4function14
Lines where the most time was spent

Line NumberCodeCallsTotal Time% TimeTime Plot
39
[Estimates,~,exitflag] = fmins...
140.212 s80.8%
37
options = optimset('Display','...
140.050 s19.2%
61
end
140 s0%
52
G1_c = abs(Estimates(3));
140 s0%
51
G1_b = Estimates(2);
140 s0%
All other lines  0.000 s0.0%
Totals  0.262 s100% 
Children (called functions)

Function NameFunction TypeCallsTotal Time% TimeTime Plot
fminsearchfunction140.202 s76.9%
optimsetfunction140.050 s19.2%
Self time (built-ins, overhead, etc.)  0.010 s3.8%
Totals  0.262 s100% 
Code Analyzer results
Line numberMessage
Coverage results
Show coverage for parent directory
Total lines in function61
Non-code lines (comments, blank lines)29
Code lines (lines that can run)32
Code lines that did run21
Code lines that did not run11
Coverage (did run/can run)65.62 %
Function listing
time 
calls 
 line
   1 
function [G1_a, G1_b, G1_c] = fit_Gaussian_model2(data, location, func_type, show_fitting, ploidy1x)
   2 
	% Attempt to fit a single-gaussian model to data.
   3 
	% Used to help determine copy number estimates for regions.
   4 

     14 
   5 
	time  = 1:length(data); 
     14 
   6 
	G1_a = nan; 
     14 
   7 
	G1_b = nan; 
     14 
   8 
	G1_c = nan; 
   9 
    
     14 
  10 
	if isnan(data) 
  11 
		% fitting variables
  12 
		return
  13 
	end
  14 

  15 
	% find max height in data.
     14 
  16 
	datamax = max(data); 
  17 
	%datamax(data ~= max(datamax)) = [];
  18 
    
  19 
	% if maxdata is final bin, then find next highest p
     14 
  20 
	if (find(data == datamax) == length(data)) 
  21 
		data(data == datamax) = 0;
  22 
		datamax = data;
  23 
		datamax(data ~= max(datamax)) = [];
  24 
	end;
  25 
    
  26 
	% a = height; b = location; c = width.
     14 
  27 
	G1_ai = datamax; 
     14 
  28 
	G1_bi = location; 
  29 
    
  30 
	%find G1_ci; width of G1 at halfmax.
     14 
  31 
	dd = data; 
     14 
  32 
	dd(data < max(data)/2) = 0; 
     14 
  33 
	c1 = find(dd,1,'first'); 
     14 
  34 
	G1_ci = (G1_bi-c1)/sqrt(2*log(2)); 
  35 
    
     14 
  36 
	initial = [G1_ai, G1_bi, G1_ci]; 
  0.05 
     14 
  37 
	options = optimset('Display','off','FunValCheck','on','MaxFunEvals',10000); 
  38 

  0.21 
     14 
  39 
	[Estimates,~,exitflag] = fminsearch(@fiterror, ...    % function to be fitted. 
  40 
	                                    initial, ...      % initial x-value.
  41 
	                                    options, ...      % options for fitting algorithm.
  42 
	                                    time, ...         % problem-specific parameter 1.
  43 
	                                    data, ...         % problem-specific parameter 2.
  44 
	                                    func_type, ...    % problem-specific parameter 3.
  45 
	                                    show_fitting, ... % problem-specific parameter 4.
  46 
	                                    ploidy1x ...      % problem-specific parameter 5.
  47 
	                            );
     14 
  48 
	if (exitflag > 0) 
  49 
		% > 0 : converged to a solution.
     14 
  50 
		G1_a = abs(Estimates(1)); 
     14 
  51 
		G1_b = Estimates(2); 
     14 
  52 
		G1_c = abs(Estimates(3)); 
  53 
	else
  54 
		% = 0 : exceeded maximum iterations allowed.
  55 
		% < 0 : did not converge to a solution.
  56 
		% return last best estimate anyhow.
  57 
		G1_a = abs(Estimates(1));
  58 
		G1_b = Estimates(2);
  59 
		G1_c = abs(Estimates(3));
  60 
	end;
     14 
  61 
end 

Other subfunctions in this file are not included in this listing.