This is a static copy of a profile report

Home

FindChrSizes_4 (1 call, 0.464 sec)
Generated 14-Nov-2016 07:47:08 using cpu time.
function in file /home/user/dev/ymap/scripts_seqModules/FindChrSizes_4.m
Copy to new window for comparing multiple runs

Parents (calling functions)

Function NameFunction TypeCalls
LOH_hapmap_v4function1
Lines where the most time was spent

Line NumberCodeCallsTotal Time% TimeTime Plot
74
[CGHsegment_height, CGHsegment...
140.262 s56.5%
42
segment_CGHdata = [segment_CGH...
31460.050 s10.9%
39
if (i <= length(CNVplot{use...
49940.050 s10.9%
41
val = CNVplot{usedChr}(i);
31460.030 s6.5%
58
smoothed        = smooth_gauss...
140.020 s4.3%
All other lines  0.050 s10.9%
Totals  0.464 s100% 
Children (called functions)

Function NameFunction TypeCallsTotal Time% TimeTime Plot
fit_Gaussian_model2function140.262 s56.5%
histfunction280.030 s6.5%
modefunction10.010 s2.2%
num2strfunction160.010 s2.2%
smooth_gaussianfunction280 s0%
Self time (built-ins, overhead, etc.)  0.151 s32.6%
Totals  0.464 s100% 
Code Analyzer results
Line numberMessage
8The value assigned to variable 'chrCopyNum1' might be unused.
15The variable 'chr_breaks' appears to change size on every loop iteration. Consider preallocating for speed.
18Using ISEMPTY is usually faster than comparing LENGTH to 0.
23The value assigned to variable 'chr_broken' might be unused.
28The variable 'chr_breaks' appears to change size on every loop iteration. Consider preallocating for speed.
32The value assigned to variable 'smoothed' might be unused.
33The value assigned to variable 'smoothed2' might be unused.
42The variable 'segment_CGHdata' appears to change size on every loop iteration. Consider preallocating for speed.
74The value assigned here to 'CGHsegment_height' appears to be unused. Consider replacing it by ~.
74The value assigned here to 'CGHsegment_width' appears to be unused. Consider replacing it by ~.
76The variable 'chrCopyNum' appears to change size on every loop iteration. Consider preallocating for speed.
78The variable 'chrCopyNum' appears to change size on every loop iteration. Consider preallocating for speed.
80The variable 'chrCopyNum_vector' appears to change size on every loop iteration. Consider preallocating for speed.
95The variable 'chrCopyNum2' appears to change size on every loop iteration. Consider preallocating for speed.
97The variable 'chrCopyNum2' appears to change size on every loop iteration. Consider preallocating for speed.
101The value assigned to variable 'chrCopyNum1' might be unused.
Coverage results
Show coverage for parent directory
Total lines in function110
Non-code lines (comments, blank lines)30
Code lines (lines that can run)80
Code lines that did run70
Code lines that did not run10
Coverage (did run/can run)87.50 %
Function listing
time 
calls 
 line
   1 
function [chr_breaks, chrCopyNum, ploidyAdjust] = FindChrSizes_4(Aneuploidy,CNVplot,Ploidy,num_chrs,chr_in_use)
   2 

   3 
% FindChrSizes determines chromosome sizes from
   4 
%    initial ploidy estimate and CGH data.
      1 
   5 
maxY              = 10; 
      1 
   6 
chr_breaks        = []; 
      1 
   7 
chrCopyNum        = []; 
      1 
   8 
chrCopyNum1       = []; 
      1 
   9 
chrCopyNum2       = []; 
      1 
  10 
chrCopyNum_vector = []; 
  11 
% precalculation of chromosome copy numbers.
      1 
  12 
for usedChr = 1:num_chrs 
      9 
  13 
	if (chr_in_use(usedChr) == 1) 
  14 
		% determine where the endpoints of ploidy segments are.
      8 
  15 
		chr_breaks{usedChr}(1) = 0.0; 
      8 
  16 
		break_count = 1; 
  17 

      8 
  18 
		if (length(Aneuploidy) > 0) 
      8 
  19 
			for i = 1:length(Aneuploidy) 
  20 
				%if (Aneuploidy(i).dataset == dataset) && (Aneuploidy(i).chr == usedChr)
     48 
  21 
				if (Aneuploidy(i).chr == usedChr) 
      6 
  22 
					break_count = break_count+1; 
      6 
  23 
					chr_broken = true; 
      6 
  24 
					chr_breaks{usedChr}(break_count) = Aneuploidy(i).break; 
      6 
  25 
				end; 
     48 
  26 
			end; 
      8 
  27 
		end; 
      8 
  28 
		chr_breaks{usedChr}(length(chr_breaks{usedChr})+1) = 1; 
  29 
    
  0.01 
      8 
  30 
		fprintf(['chr' num2str(usedChr) ' : ' num2str(length(chr_breaks{usedChr})) '\n']); 
      8 
  31 
		for segment = 1:length(chr_breaks{usedChr})-1 
     14 
  32 
			smoothed = []; 
     14 
  33 
			smoothed2 = []; 
     14 
  34 
			segment_CGHdata = []; 
     14 
  35 
			segment_CGHdata2  = []; 
  36 
			% find set of CGH data for this segment of this chromosome.
     14 
  37 
			for i = 1:length(CNVplot{usedChr}) 
  38 
				% val = ploidy estimate adjusted copy number for each CGH probe.
  0.05 
   4994 
  39 
				if (i <= length(CNVplot{usedChr})*chr_breaks{usedChr}(segment+1)) && ... 
  40 
				   (i >= length(CNVplot{usedChr})*chr_breaks{usedChr}(segment))
  0.03 
   3146 
  41 
					val = CNVplot{usedChr}(i); 
  0.05 
   3146 
  42 
					segment_CGHdata = [segment_CGHdata val]; 
  0.01 
   3146 
  43 
				end; 
  0.01 
   4994 
  44 
			end; 
     14 
  45 
			if (Ploidy == 0) 
  46 
				segment_CGHdata = segment_CGHdata*2;
     14 
  47 
			else 
     14 
  48 
				segment_CGHdata = segment_CGHdata*Ploidy; 
     14 
  49 
			end; 
  50 
			% make smoothed histogram of CGH data for this segment.
     14 
  51 
			segment_CGHdata(segment_CGHdata==0) = []; 
     14 
  52 
			segment_CGHdata(length(segment_CGHdata)+1) = 0;   % endpoints added to ensure histogram bounds. 
     14 
  53 
			segment_CGHdata(length(segment_CGHdata)+1) = maxY; 
  54 
			% clearing 
     14 
  55 
			segment_CGHdata(segment_CGHdata<0) = []; 
     14 
  56 
			segment_CGHdata(segment_CGHdata>maxY) = []; 
     14 
  57 
			histogram_width = 200; 
  0.02 
     14 
  58 
			smoothed        = smooth_gaussian(hist(segment_CGHdata,histogram_width),5,20); 
  59 
			
  60 
			% make a smoothed version of just the endpoints used to ensure histogram bounds.
     14 
  61 
			segment_CGHdata2(1) = 0; 
     14 
  62 
			segment_CGHdata2(2) = maxY; 
  0.01 
     14 
  63 
			smoothed2 = smooth_gaussian(hist(segment_CGHdata2,histogram_width),5,20); 
  64 

  65 
			% subtract the smoothed endpoints from the histogram to remove the influence of the added endpoints.
     14 
  66 
			smoothed = smoothed - smoothed2; 
     14 
  67 
			smoothed = smoothed/max(smoothed); 
  68 
            
  69 
			% find initial estimage of peak location from smoothed segment CGH data.
     14 
  70 
			peakLocation = find(smoothed==max(smoothed)); 
  71 
			% fit Gaussian to segment CGH data.
     14 
  72 
			show_fitting = 0; 
     14 
  73 
			if (peakLocation > 1) 
  0.26 
     14 
  74 
				[CGHsegment_height, CGHsegment_location, CGHsegment_width] = fit_Gaussian_model2(smoothed, peakLocation, 'cubic',show_fitting,20); 
  75 
				% calculate copy number from Gaussian location.
     14 
  76 
				chrCopyNum{usedChr}(segment) = round(CGHsegment_location/(histogram_width/maxY)*10)/10; 
  77 
			else
  78 
				chrCopyNum{usedChr}(segment) = 0;
  79 
			end;
     14 
  80 
			chrCopyNum_vector = [chrCopyNum_vector chrCopyNum{usedChr}(segment)]; 
     14 
  81 
		end; 
      8 
  82 
	end; 
      9 
  83 
end; 
  84 

  85 
% Adjustment of ploidy estimate.
  86 
% assumes most common copy number to really be a whole number. (2.1 -> 2, etc.)
  87 
% zero data indicate erroneous copy number estimates and are first excluded.
      1 
  88 
chrCopyNum_vector(chrCopyNum_vector == 0) = []; 
  0.01 
      1 
  89 
common_copyNum = mode(chrCopyNum_vector); 
      1 
  90 
for chr = 1:length(chrCopyNum) 
      9 
  91 
	for segment = 1:length(chrCopyNum{chr}) 
  92 
		% avoid avoid dividing by Nan if common_copyNum is NaN (since the whole copy vector can be empty)
     14 
  93 
		if (~isnan(common_copyNum)) 
  94 
			% rounds to 1 decimal place.
     14 
  95 
			chrCopyNum2{chr}(segment) = round(chrCopyNum{chr}(segment)/common_copyNum*round(common_copyNum)*10)/10; 
  96 
		else
  97 
			chrCopyNum2{chr}(segment) = 0;
  98 
		end;
     14 
  99 
	end; 
      9 
 100 
end; 
      1 
 101 
chrCopyNum1  = chrCopyNum; 
      1 
 102 
chrCopyNum   = chrCopyNum2; 
 103 
% set ploidy adjust according to copy num, avoid dividing by Nan if common_copyNum is NaN (since the whole copy vector can be empty)
      1 
 104 
if (~isnan(common_copyNum)) 
      1 
 105 
    ploidyAdjust = round(common_copyNum)/common_copyNum; 
 106 
else
 107 
    ploidyAdjust = Ploidy;
 108 
end;
 109 

      1 
 110 
end 

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