time | calls | line |
---|
| | 1 | function [x_peak,actual_cutoffs,mostLikelyGaussians] = FindGaussianCutoffs_3(workingDir,saveName, chromosome,segment,copyNum, smoothed_Histogram, MakeFigure);
|
| | 2 |
|
| 12 | 3 | monosomy_peaks = [0, 1]*199+1;
|
| 12 | 4 | disomy_peaks = [0, 1/2, 1]*199+1;
|
| 12 | 5 | trisomy_peaks = [0, 1/3, 2/3, 1]*199+1;
|
| 12 | 6 | tetrasomy_peaks = [0, 1/4, 2/4, 3/4, 1]*199+1;
|
| 12 | 7 | pentasomy_peaks = [0, 1/5, 2/5, 3/5, 4/5, 1]*199+1;
|
| 12 | 8 | hexasomy_peaks = [0, 1/6, 2/6, 3/6, 4/6, 5/6, 1]*199+1;
|
| 12 | 9 | heptasomy_peaks = [0, 1/7, 2/7, 3/7, 4/7, 5/7, 6/7, 1]*199+1;
|
| 12 | 10 | octasomy_peaks = [0, 1/8, 2/8, 3/8, 4/8, 5/8, 6/8, 7/8, 1]*199+1;
|
| 12 | 11 | nonasomy_peaks = [0, 1/9, 2/9, 3/9, 4/9, 5/9, 6/9, 7/9, 8/9, 1]*199+1;
|
| | 12 |
|
| | 13 | %% Calculation of Gaussians against per chromosome data.
|
| | 14 | % Fits Gaussians to real data per chromomsome, then determines equal probability cutoffs between them.
|
| 12 | 15 | sigma = 5;
|
| | 16 | %% FindGaussianCutoffs Finds cutoffs as intersections of Gaussians, fit to the data at each peak location.
|
| 12 | 17 | ErrorType = 'linear';
|
| | 18 | % Define range of fit curves.
|
| 12 | 19 | range = 1:200;
|
| | 20 |
|
| | 21 | % Generate figure.
|
| 12 | 22 | if (MakeFigure == true)
|
| | 23 | fig = figure(1);
|
| | 24 | hold on;
|
| | 25 | end;
|
| 12 | 26 | if (copyNum == 0)
|
| | 27 | G = [];
|
| | 28 | list = [];
|
| | 29 | x_peak = [];
|
| | 30 | actual_cutoffs = [];
|
| | 31 | mostLikelyGaussians = [];
|
| | 32 | fit_curve_tot = range*0;
|
| 12 | 33 | elseif (copyNum == 1)
|
| 1 | 34 | G = [];
|
0.07 | 1 | 35 | [G{1}.a,G{1}.b,G{1}.c, G{2}.a,G{2}.b,G{2}.c] = ...
|
| | 36 | fit_Gaussian_model_monosomy_2(workingDir,saveName, smoothed_Histogram,monosomy_peaks,sigma,ErrorType);
|
0.02 | 1 | 37 | [list] = FindHighestGaussian_2(G);
|
| 1 | 38 | actual_cutoffs = [];
|
| 1 | 39 | mostLikelyGaussians = [];
|
| 1 | 40 | for i = 1:199
|
| 199 | 41 | if (list(i) ~= list(i+1)) % we've found a boundary.
|
| 1 | 42 | actual_cutoffs = [actual_cutoffs (i+0.5)];
|
| | 43 | % actual_cutoffs = [actual_cutoffs FindGaussianCrossover_2(G{list(i)},G{list(i+1)},i)];
|
| 1 | 44 | mostLikelyGaussians = [mostLikelyGaussians list(i)];
|
| 1 | 45 | end;
|
| 199 | 46 | end;
|
| 1 | 47 | mostLikelyGaussians = [mostLikelyGaussians list(200)];
|
| 1 | 48 | x_peak = [];
|
| 1 | 49 | for i = 1:2; x_peak(i) = G{i}.b; end;
|
| | 50 |
|
| | 51 | % Construct curve
|
| 1 | 52 | fit_curve_1 = G{1}.a*exp(-0.5*((range-G{1}.b)./G{1}.c).^2);
|
| 1 | 53 | fit_curve_2 = G{2}.a*exp(-0.5*((range-G{2}.b)./G{2}.c).^2);
|
| 1 | 54 | if (MakeFigure == true)
|
| | 55 | plot(fit_curve_1,'color',[1.00 0.50 0.50],'linestyle','-','linewidth',1);
|
| | 56 | plot(fit_curve_2,'color',[1.00 0.50 0.50],'linestyle','-','linewidth',1);
|
| | 57 | end;
|
| 1 | 58 | fit_curve_tot = fit_curve_1+fit_curve_2;
|
| 11 | 59 | elseif (copyNum == 2)
|
| 9 | 60 | G = [];
|
3.04 | 9 | 61 | [G{1}.a,G{1}.b,G{1}.c, G{2}.a,G{2}.b,G{2}.c, G{3}.a,G{3}.b,G{3}.c] = ...
|
| | 62 | fit_Gaussian_model_disomy_2(workingDir,saveName, smoothed_Histogram,disomy_peaks,sigma,ErrorType);
|
0.18 | 9 | 63 | [list] = FindHighestGaussian_2(G);
|
| 9 | 64 | actual_cutoffs = [];
|
| 9 | 65 | mostLikelyGaussians = [];
|
| 9 | 66 | for i = 1:199
|
| 1791 | 67 | if (list(i) ~= list(i+1)) % we've found a boundary.
|
| 20 | 68 | actual_cutoffs = [actual_cutoffs (i+0.5)];
|
| | 69 | % actual_cutoffs = [actual_cutoffs FindGaussianCrossover_2(G{list(i)},G{list(i+1)},i)];
|
| 20 | 70 | mostLikelyGaussians = [mostLikelyGaussians list(i)];
|
| 20 | 71 | end;
|
0.01 | 1791 | 72 | end;
|
| 9 | 73 | mostLikelyGaussians = [mostLikelyGaussians list(200)];
|
| 9 | 74 | x_peak = [];
|
| 9 | 75 | for i = 1:3; x_peak(i) = G{i}.b; end;
|
| | 76 |
|
| | 77 | % Construct curve
|
| 9 | 78 | fit_curve_1 = G{1}.a*exp(-0.5*((range-G{1}.b)./G{1}.c).^2);
|
| 9 | 79 | fit_curve_2 = G{2}.a*exp(-0.5*((range-G{2}.b)./G{2}.c).^2);
|
| 9 | 80 | fit_curve_3 = G{3}.a*exp(-0.5*((range-G{3}.b)./G{3}.c).^2);
|
| 9 | 81 | if (MakeFigure == true)
|
| | 82 | plot(fit_curve_1,'color',[1.00 0.50 0.50],'linestyle','-','linewidth',1);
|
| | 83 | plot(fit_curve_2,'color',[1.00 0.50 0.50],'linestyle','-','linewidth',1);
|
| | 84 | plot(fit_curve_3,'color',[1.00 0.50 0.50],'linestyle','-','linewidth',1);
|
| | 85 | end;
|
| 9 | 86 | fit_curve_tot = fit_curve_1+fit_curve_2+fit_curve_3;
|
| 2 | 87 | elseif (copyNum == 3)
|
| 2 | 88 | G = [];
|
1.06 | 2 | 89 | [G{1}.a,G{1}.b,G{1}.c, G{2}.a,G{2}.b,G{2}.c, G{3}.a,G{3}.b,G{3}.c, G{4}.a,G{4}.b,G{4}.c] = ...
|
| | 90 | fit_Gaussian_model_trisomy_2(workingDir,saveName, smoothed_Histogram,trisomy_peaks,sigma,ErrorType);
|
0.06 | 2 | 91 | list = FindHighestGaussian_2(G);
|
| 2 | 92 | actual_cutoffs = [];
|
| 2 | 93 | mostLikelyGaussians = [];
|
| 2 | 94 | for i = 1:199
|
| 398 | 95 | if (list(i) ~= list(i+1)) % we've found a boundary.
|
| 4 | 96 | actual_cutoffs = [actual_cutoffs (i+0.5)];
|
| | 97 | % actual_cutoffs = [actual_cutoffs FindGaussianCrossover_2(G{list(i)},G{list(i+1)},i)];
|
| 4 | 98 | mostLikelyGaussians = [mostLikelyGaussians list(i)];
|
| 4 | 99 | end;
|
| 398 | 100 | end;
|
| 2 | 101 | mostLikelyGaussians = [mostLikelyGaussians list(200)];
|
| 2 | 102 | x_peak = [];
|
| 2 | 103 | for i = 1:4; x_peak(i) = G{i}.b; end;
|
| | 104 |
|
| | 105 | % Construct curve
|
| 2 | 106 | fit_curve_1 = G{1}.a*exp(-0.5*((range-G{1}.b)./G{1}.c).^2);
|
| 2 | 107 | fit_curve_2 = G{2}.a*exp(-0.5*((range-G{2}.b)./G{2}.c).^2);
|
| 2 | 108 | fit_curve_3 = G{3}.a*exp(-0.5*((range-G{3}.b)./G{3}.c).^2);
|
| 2 | 109 | fit_curve_4 = G{4}.a*exp(-0.5*((range-G{4}.b)./G{4}.c).^2);
|
| 2 | 110 | if (MakeFigure == true)
|
| | 111 | plot(fit_curve_1,'color',[1.00 0.50 0.50],'linestyle','-','linewidth',1);
|
| | 112 | plot(fit_curve_2,'color',[1.00 0.50 0.50],'linestyle','-','linewidth',1);
|
| | 113 | plot(fit_curve_3,'color',[1.00 0.50 0.50],'linestyle','-','linewidth',1);
|
| | 114 | plot(fit_curve_4,'color',[1.00 0.50 0.50],'linestyle','-','linewidth',1);
|
| | 115 | end;
|
| 2 | 116 | fit_curve_tot = fit_curve_1+fit_curve_2+fit_curve_3+fit_curve_4;
|
| | 117 | elseif (copyNum == 4)
|
| | 118 | G = [];
|
| | 119 | [G{1}.a,G{1}.b,G{1}.c, G{2}.a,G{2}.b,G{2}.c, G{3}.a,G{3}.b,G{3}.c, G{4}.a,G{4}.b,G{4}.c, G{5}.a,G{5}.b,G{5}.c] = ...
|
| | 120 | fit_Gaussian_model_tetrasomy_2(workingDir,saveName, smoothed_Histogram,tetrasomy_peaks,sigma,ErrorType);
|
| | 121 | [list] = FindHighestGaussian_2(G);
|
| | 122 | actual_cutoffs = [];
|
| | 123 | mostLikelyGaussians = [];
|
| | 124 | for i = 1:199
|
| | 125 | if (list(i) ~= list(i+1)) % we've found a boundary.
|
| | 126 | actual_cutoffs = [actual_cutoffs (i+0.5)];
|
| | 127 | % actual_cutoffs = [actual_cutoffs FindGaussianCrossover_2(G{list(i)},G{list(i+1)},i)];
|
| | 128 | mostLikelyGaussians = [mostLikelyGaussians list(i)];
|
| | 129 | end;
|
| | 130 | end;
|
| | 131 | mostLikelyGaussians = [mostLikelyGaussians list(200)];
|
| | 132 | x_peak = [];
|
| | 133 | for i = 1:5; x_peak(i) = G{i}.b; end;
|
| | 134 |
|
| | 135 | % Construct curve
|
| | 136 | fit_curve_1 = G{1}.a*exp(-0.5*((range-G{1}.b)./G{1}.c).^2);
|
| | 137 | fit_curve_2 = G{2}.a*exp(-0.5*((range-G{2}.b)./G{2}.c).^2);
|
| | 138 | fit_curve_3 = G{3}.a*exp(-0.5*((range-G{3}.b)./G{3}.c).^2);
|
| | 139 | fit_curve_4 = G{4}.a*exp(-0.5*((range-G{4}.b)./G{4}.c).^2);
|
| | 140 | fit_curve_5 = G{5}.a*exp(-0.5*((range-G{5}.b)./G{5}.c).^2);
|
| | 141 | if (MakeFigure == true)
|
| | 142 | plot(fit_curve_1,'color',[1.00 0.50 0.50],'linestyle','-','linewidth',1);
|
| | 143 | plot(fit_curve_2,'color',[1.00 0.50 0.50],'linestyle','-','linewidth',1);
|
| | 144 | plot(fit_curve_3,'color',[1.00 0.50 0.50],'linestyle','-','linewidth',1);
|
| | 145 | plot(fit_curve_4,'color',[1.00 0.50 0.50],'linestyle','-','linewidth',1);
|
| | 146 | plot(fit_curve_5,'color',[1.00 0.50 0.50],'linestyle','-','linewidth',1);
|
| | 147 | end;
|
| | 148 | fit_curve_tot = fit_curve_1+fit_curve_2+fit_curve_3+fit_curve_4+fit_curve_5;
|
| | 149 | elseif (copyNum == 5)
|
| | 150 | G = [];
|
| | 151 | [G{1}.a,G{1}.b,G{1}.c, G{2}.a,G{2}.b,G{2}.c, G{3}.a,G{3}.b,G{3}.c, G{4}.a,G{4}.b,G{4}.c, G{5}.a,G{5}.b,G{5}.c, G{6}.a,G{6}.b,G{6}.c] = ...
|
| | 152 | fit_Gaussian_model_pentasomy_2(workingDir,saveName, smoothed_Histogram,pentasomy_peaks,sigma,ErrorType);
|
| | 153 | [list] = FindHighestGaussian_2(G);
|
| | 154 | actual_cutoffs = [];
|
| | 155 | mostLikelyGaussians = [];
|
| | 156 | for i = 1:199
|
| | 157 | if (list(i) ~= list(i+1)) % we've found a boundary.
|
| | 158 | actual_cutoffs = [actual_cutoffs (i+0.5)];
|
| | 159 | % actual_cutoffs = [actual_cutoffs FindGaussianCrossover_2(G{list(i)},G{list(i+1)},i)];
|
| | 160 | mostLikelyGaussians = [mostLikelyGaussians list(i)];
|
| | 161 | end;
|
| | 162 | end;
|
| | 163 | mostLikelyGaussians = [mostLikelyGaussians list(200)];
|
| | 164 | x_peak = [];
|
| | 165 | for i = 1:6; x_peak(i) = G{i}.b; end;
|
| | 166 |
|
| | 167 | % Construct curve
|
| | 168 | fit_curve_1 = G{1}.a*exp(-0.5*((range-G{1}.b)./G{1}.c).^2);
|
| | 169 | fit_curve_2 = G{2}.a*exp(-0.5*((range-G{2}.b)./G{2}.c).^2);
|
| | 170 | fit_curve_3 = G{3}.a*exp(-0.5*((range-G{3}.b)./G{3}.c).^2);
|
| | 171 | fit_curve_4 = G{4}.a*exp(-0.5*((range-G{4}.b)./G{4}.c).^2);
|
| | 172 | fit_curve_5 = G{5}.a*exp(-0.5*((range-G{5}.b)./G{5}.c).^2);
|
| | 173 | fit_curve_6 = G{6}.a*exp(-0.5*((range-G{6}.b)./G{6}.c).^2);
|
| | 174 | if (MakeFigure == true)
|
| | 175 | plot(fit_curve_1,'color',[1.00 0.50 0.50],'linestyle','-','linewidth',1);
|
| | 176 | plot(fit_curve_2,'color',[1.00 0.50 0.50],'linestyle','-','linewidth',1);
|
| | 177 | plot(fit_curve_3,'color',[1.00 0.50 0.50],'linestyle','-','linewidth',1);
|
| | 178 | plot(fit_curve_4,'color',[1.00 0.50 0.50],'linestyle','-','linewidth',1);
|
| | 179 | plot(fit_curve_5,'color',[1.00 0.50 0.50],'linestyle','-','linewidth',1);
|
| | 180 | plot(fit_curve_6,'color',[1.00 0.50 0.50],'linestyle','-','linewidth',1);
|
| | 181 | end;
|
| | 182 | fit_curve_tot = fit_curve_1+fit_curve_2+fit_curve_3+fit_curve_4+fit_curve_5+fit_curve_6;
|
| | 183 | elseif (copyNum == 6)
|
| | 184 | G = [];
|
| | 185 | [G{1}.a,G{1}.b,G{1}.c, G{2}.a,G{2}.b,G{2}.c, G{3}.a,G{3}.b,G{3}.c, G{4}.a,G{4}.b,G{4}.c, G{5}.a,G{5}.b,G{5}.c, G{6}.a,G{6}.b,G{6}.c, G{7}.a,G{7}.b,G{7}.c] = ...
|
| | 186 | fit_Gaussian_model_hexasomy_2(workingDir,saveName, smoothed_Histogram,hexasomy_peaks,sigma,ErrorType);
|
| | 187 | [list] = FindHighestGaussian_2(G);
|
| | 188 | actual_cutoffs = [];
|
| | 189 | mostLikelyGaussians = [];
|
| | 190 | for i = 1:199
|
| | 191 | if (list(i) ~= list(i+1)) % we've found a boundary.
|
| | 192 | actual_cutoffs = [actual_cutoffs (i+0.5)];
|
| | 193 | % actual_cutoffs = [actual_cutoffs FindGaussianCrossover_2(G{list(i)},G{list(i+1)},i)];
|
| | 194 | mostLikelyGaussians = [mostLikelyGaussians list(i)];
|
| | 195 | end;
|
| | 196 | end;
|
| | 197 | mostLikelyGaussians = [mostLikelyGaussians list(200)];
|
| | 198 | x_peak = [];
|
| | 199 | for i = 1:7; x_peak(i) = G{i}.b; end;
|
| | 200 |
|
| | 201 | % Construct curve
|
| | 202 | fit_curve_1 = G{1}.a*exp(-0.5*((range-G{1}.b)./G{1}.c).^2);
|
| | 203 | fit_curve_2 = G{2}.a*exp(-0.5*((range-G{2}.b)./G{2}.c).^2);
|
| | 204 | fit_curve_3 = G{3}.a*exp(-0.5*((range-G{3}.b)./G{3}.c).^2);
|
| | 205 | fit_curve_4 = G{4}.a*exp(-0.5*((range-G{4}.b)./G{4}.c).^2);
|
| | 206 | fit_curve_5 = G{5}.a*exp(-0.5*((range-G{5}.b)./G{5}.c).^2);
|
| | 207 | fit_curve_6 = G{6}.a*exp(-0.5*((range-G{6}.b)./G{6}.c).^2);
|
| | 208 | fit_curve_7 = G{7}.a*exp(-0.5*((range-G{7}.b)./G{7}.c).^2);
|
| | 209 | if (MakeFigure == true)
|
| | 210 | plot(fit_curve_1,'color',[1.00 0.50 0.50],'linestyle','-','linewidth',1);
|
| | 211 | plot(fit_curve_2,'color',[1.00 0.50 0.50],'linestyle','-','linewidth',1);
|
| | 212 | plot(fit_curve_3,'color',[1.00 0.50 0.50],'linestyle','-','linewidth',1);
|
| | 213 | plot(fit_curve_4,'color',[1.00 0.50 0.50],'linestyle','-','linewidth',1);
|
| | 214 | plot(fit_curve_5,'color',[1.00 0.50 0.50],'linestyle','-','linewidth',1);
|
| | 215 | plot(fit_curve_6,'color',[1.00 0.50 0.50],'linestyle','-','linewidth',1);
|
| | 216 | plot(fit_curve_7,'color',[1.00 0.50 0.50],'linestyle','-','linewidth',1);
|
| | 217 | end;
|
| | 218 | fit_curve_tot = fit_curve_1+fit_curve_2+fit_curve_3+fit_curve_4+fit_curve_5+fit_curve_6+fit_curve_7;
|
| | 219 | elseif (copyNum == 7)
|
| | 220 | G = [];
|
| | 221 | [G{1}.a,G{1}.b,G{1}.c, G{2}.a,G{2}.b,G{2}.c, G{3}.a,G{3}.b,G{3}.c, G{4}.a,G{4}.b,G{4}.c, G{5}.a,G{5}.b,G{5}.c, G{6}.a,G{6}.b,G{6}.c, G{7}.a,G{7}.b,G{7}.c, G{8}.a,G{8}.b,G{8}.c] = ...
|
| | 222 | fit_Gaussian_model_heptasomy_2(workingDir,saveName, smoothed_Histogram,heptasomy_peaks,sigma,ErrorType);
|
| | 223 | [list] = FindHighestGaussian_2(G);
|
| | 224 | % fprintf(['||2 list = ' num2str(list) '\n']);
|
| | 225 | actual_cutoffs = [];
|
| | 226 | mostLikelyGaussians = [];
|
| | 227 | for i = 1:199
|
| | 228 | if (list(i) ~= list(i+1)) % we've found a boundary.
|
| | 229 | actual_cutoffs = [actual_cutoffs (i+0.5)];
|
| | 230 | % actual_cutoffs = [actual_cutoffs FindGaussianCrossover_2(G{list(i)},G{list(i+1)},i)];
|
| | 231 | mostLikelyGaussians = [mostLikelyGaussians list(i)];
|
| | 232 | end;
|
| | 233 | end;
|
| | 234 | mostLikelyGaussians = [mostLikelyGaussians list(200)];
|
| | 235 | x_peak = [];
|
| | 236 | for i = 1:8; x_peak(i) = G{i}.b; end;
|
| | 237 |
|
| | 238 | % Construct curve
|
| | 239 | fit_curve_1 = G{1}.a*exp(-0.5*((range-G{1}.b)./G{1}.c).^2);
|
| | 240 | fit_curve_2 = G{2}.a*exp(-0.5*((range-G{2}.b)./G{2}.c).^2);
|
| | 241 | fit_curve_3 = G{3}.a*exp(-0.5*((range-G{3}.b)./G{3}.c).^2);
|
| | 242 | fit_curve_4 = G{4}.a*exp(-0.5*((range-G{4}.b)./G{4}.c).^2);
|
| | 243 | fit_curve_5 = G{5}.a*exp(-0.5*((range-G{5}.b)./G{5}.c).^2);
|
| | 244 | fit_curve_6 = G{6}.a*exp(-0.5*((range-G{6}.b)./G{6}.c).^2);
|
| | 245 | fit_curve_7 = G{7}.a*exp(-0.5*((range-G{7}.b)./G{7}.c).^2);
|
| | 246 | fit_curve_8 = G{8}.a*exp(-0.5*((range-G{8}.b)./G{8}.c).^2);
|
| | 247 | if (MakeFigure == true)
|
| | 248 | plot(fit_curve_1,'color',[1.00 0.50 0.50],'linestyle','-','linewidth',1);
|
| | 249 | plot(fit_curve_2,'color',[1.00 0.50 0.50],'linestyle','-','linewidth',1);
|
| | 250 | plot(fit_curve_3,'color',[1.00 0.50 0.50],'linestyle','-','linewidth',1);
|
| | 251 | plot(fit_curve_4,'color',[1.00 0.50 0.50],'linestyle','-','linewidth',1);
|
| | 252 | plot(fit_curve_5,'color',[1.00 0.50 0.50],'linestyle','-','linewidth',1);
|
| | 253 | plot(fit_curve_6,'color',[1.00 0.50 0.50],'linestyle','-','linewidth',1);
|
| | 254 | plot(fit_curve_7,'color',[1.00 0.50 0.50],'linestyle','-','linewidth',1);
|
| | 255 | plot(fit_curve_8,'color',[1.00 0.50 0.50],'linestyle','-','linewidth',1);
|
| | 256 | end;
|
| | 257 | fit_curve_tot = fit_curve_1+fit_curve_2+fit_curve_3+fit_curve_4+fit_curve_5+fit_curve_6+fit_curve_7+fit_curve_8;
|
| | 258 | elseif (copyNum == 8)
|
| | 259 | G = [];
|
| | 260 | [G{1}.a,G{1}.b,G{1}.c, G{2}.a,G{2}.b,G{2}.c, G{3}.a,G{3}.b,G{3}.c, G{4}.a,G{4}.b,G{4}.c, G{5}.a,G{5}.b,G{5}.c, G{6}.a,G{6}.b,G{6}.c, G{7}.a,G{7}.b,G{7}.c, G{8}.a,G{8}.b,G{8}.c, G{9}.a,G{9}.b,G{9}.c] = ...
|
| | 261 | fit_Gaussian_model_octasomy_2(workingDir,saveName, smoothed_Histogram,octasomy_peaks,sigma,ErrorType);
|
| | 262 | [list] = FindHighestGaussian_2(G);
|
| | 263 | actual_cutoffs = [];
|
| | 264 | mostLikelyGaussians = [];
|
| | 265 | for i = 1:199
|
| | 266 | if (list(i) ~= list(i+1)) % we've found a boundary.
|
| | 267 | actual_cutoffs = [actual_cutoffs (i+0.5)];
|
| | 268 | % actual_cutoffs = [actual_cutoffs FindGaussianCrossover_2(G{list(i)},G{list(i+1)},i)];
|
| | 269 | mostLikelyGaussians = [mostLikelyGaussians list(i)];
|
| | 270 | end;
|
| | 271 | end;
|
| | 272 | mostLikelyGaussians = [mostLikelyGaussians list(200)];
|
| | 273 | x_peak = [];
|
| | 274 | for i = 1:9; x_peak(i) = G{i}.b; end;
|
| | 275 |
|
| | 276 | % Construct curve
|
| | 277 | fit_curve_1 = G{1}.a*exp(-0.5*((range-G{1}.b)./G{1}.c).^2);
|
| | 278 | fit_curve_2 = G{2}.a*exp(-0.5*((range-G{2}.b)./G{2}.c).^2);
|
| | 279 | fit_curve_3 = G{3}.a*exp(-0.5*((range-G{3}.b)./G{3}.c).^2);
|
| | 280 | fit_curve_4 = G{4}.a*exp(-0.5*((range-G{4}.b)./G{4}.c).^2);
|
| | 281 | fit_curve_5 = G{5}.a*exp(-0.5*((range-G{5}.b)./G{5}.c).^2);
|
| | 282 | fit_curve_6 = G{6}.a*exp(-0.5*((range-G{6}.b)./G{6}.c).^2);
|
| | 283 | fit_curve_7 = G{7}.a*exp(-0.5*((range-G{7}.b)./G{7}.c).^2);
|
| | 284 | fit_curve_8 = G{8}.a*exp(-0.5*((range-G{8}.b)./G{8}.c).^2);
|
| | 285 | fit_curve_9 = G{9}.a*exp(-0.5*((range-G{9}.b)./G{9}.c).^2);
|
| | 286 | if (MakeFigure == true)
|
| | 287 | plot(fit_curve_1,'color',[1.00 0.50 0.50],'linestyle','-','linewidth',1);
|
| | 288 | plot(fit_curve_2,'color',[1.00 0.50 0.50],'linestyle','-','linewidth',1);
|
| | 289 | plot(fit_curve_3,'color',[1.00 0.50 0.50],'linestyle','-','linewidth',1);
|
| | 290 | plot(fit_curve_4,'color',[1.00 0.50 0.50],'linestyle','-','linewidth',1);
|
| | 291 | plot(fit_curve_5,'color',[1.00 0.50 0.50],'linestyle','-','linewidth',1);
|
| | 292 | plot(fit_curve_6,'color',[1.00 0.50 0.50],'linestyle','-','linewidth',1);
|
| | 293 | plot(fit_curve_7,'color',[1.00 0.50 0.50],'linestyle','-','linewidth',1);
|
| | 294 | plot(fit_curve_8,'color',[1.00 0.50 0.50],'linestyle','-','linewidth',1);
|
| | 295 | plot(fit_curve_9,'color',[1.00 0.50 0.50],'linestyle','-','linewidth',1);
|
| | 296 | end;
|
| | 297 | fit_curve_tot = fit_curve_1+fit_curve_2+fit_curve_3+fit_curve_4+fit_curve_5+fit_curve_6+fit_curve_7+fit_curve_8+fit_curve_9;
|
| | 298 | else % if (copyNum == 9+)
|
| | 299 | G = [];
|
| | 300 | [G{1}.a,G{1}.b,G{1}.c, G{2}.a,G{2}.b,G{2}.c, G{3}.a,G{3}.b,G{3}.c, G{4}.a,G{4}.b,G{4}.c, G{5}.a,G{5}.b,G{5}.c, G{6}.a,G{6}.b,G{6}.c, G{7}.a,G{7}.b,G{7}.c, G{8}.a,G{8}.b,G{8}.c, G{9}.a,G{9}.b,G{9}.c, G{10}.a,G{10}.b,G{10}.c] = ...
|
| | 301 | fit_Gaussian_model_nonasomy_2(workingDir,saveName, smoothed_Histogram,nonasomy_peaks,sigma,ErrorType);
|
| | 302 | [list] = FindHighestGaussian_2(G);
|
| | 303 | actual_cutoffs = [];
|
| | 304 | mostLikelyGaussians = [];
|
| | 305 | for i = 1:199
|
| | 306 | if (list(i) ~= list(i+1)) % we've found a boundary.
|
| | 307 | actual_cutoffs = [actual_cutoffs (i+0.5)];
|
| | 308 | % actual_cutoffs = [actual_cutoffs FindGaussianCrossover_2(G{list(i)},G{list(i+1)},i)];
|
| | 309 | mostLikelyGaussians = [mostLikelyGaussians list(i)];
|
| | 310 | end;
|
| | 311 | end;
|
| | 312 | mostLikelyGaussians = [mostLikelyGaussians list(200)];
|
| | 313 | x_peak = [];
|
| | 314 | for i = 1:9; x_peak(i) = G{i}.b; end;
|
| | 315 |
|
| | 316 | % Construct curve
|
| | 317 | fit_curve_1 = G{ 1}.a*exp(-0.5*((range-G{ 1}.b)./G{ 1}.c).^2);
|
| | 318 | fit_curve_2 = G{ 2}.a*exp(-0.5*((range-G{ 2}.b)./G{ 2}.c).^2);
|
| | 319 | fit_curve_3 = G{ 3}.a*exp(-0.5*((range-G{ 3}.b)./G{ 3}.c).^2);
|
| | 320 | fit_curve_4 = G{ 4}.a*exp(-0.5*((range-G{ 4}.b)./G{ 4}.c).^2);
|
| | 321 | fit_curve_5 = G{ 5}.a*exp(-0.5*((range-G{ 5}.b)./G{ 5}.c).^2);
|
| | 322 | fit_curve_6 = G{ 6}.a*exp(-0.5*((range-G{ 6}.b)./G{ 6}.c).^2);
|
| | 323 | fit_curve_7 = G{ 7}.a*exp(-0.5*((range-G{ 7}.b)./G{ 7}.c).^2);
|
| | 324 | fit_curve_8 = G{ 8}.a*exp(-0.5*((range-G{ 8}.b)./G{ 8}.c).^2);
|
| | 325 | fit_curve_9 = G{ 9}.a*exp(-0.5*((range-G{ 9}.b)./G{ 9}.c).^2);
|
| | 326 | fit_curve_10 = G{10}.a*exp(-0.5*((range-G{10}.b)./G{10}.c).^2);
|
| | 327 | if (MakeFigure == true)
|
| | 328 | plot(fit_curve_1,'color',[1.00 0.50 0.50],'linestyle','-','linewidth',1);
|
| | 329 | plot(fit_curve_2,'color',[1.00 0.50 0.50],'linestyle','-','linewidth',1);
|
| | 330 | plot(fit_curve_3,'color',[1.00 0.50 0.50],'linestyle','-','linewidth',1);
|
| | 331 | plot(fit_curve_4,'color',[1.00 0.50 0.50],'linestyle','-','linewidth',1);
|
| | 332 | plot(fit_curve_5,'color',[1.00 0.50 0.50],'linestyle','-','linewidth',1);
|
| | 333 | plot(fit_curve_6,'color',[1.00 0.50 0.50],'linestyle','-','linewidth',1);
|
| | 334 | plot(fit_curve_7,'color',[1.00 0.50 0.50],'linestyle','-','linewidth',1);
|
| | 335 | plot(fit_curve_8,'color',[1.00 0.50 0.50],'linestyle','-','linewidth',1);
|
| | 336 | plot(fit_curve_9,'color',[1.00 0.50 0.50],'linestyle','-','linewidth',1);
|
| | 337 | plot(fit_curve_10,'color',[1.00 0.50 0.50],'linestyle','-','linewidth',1);
|
| | 338 | end;
|
| | 339 | fit_curve_tot = fit_curve_1+fit_curve_2+fit_curve_3+fit_curve_4+fit_curve_5+fit_curve_6+fit_curve_7+fit_curve_8+fit_curve_9+fit_curve_10;
|
| | 340 | end;
|
| | 341 |
|
| 12 | 342 | if (MakeFigure == true)
|
| | 343 | plot(smoothed_Histogram,'color',[0.50 0.50 1.00],'linestyle','-','linewidth',1);
|
| | 344 | for cutoffID = 1:length(actual_cutoffs)
|
| | 345 | plot([actual_cutoffs(cutoffID) actual_cutoffs(cutoffID)],[fit_curve_tot(round(actual_cutoffs(cutoffID)))/2 1],'color',[1.00 0.50 0.50],'linestyle','-','linewidth',1);
|
| | 346 | end;
|
| | 347 | plot(fit_curve_tot, 'color',[1.00 0.00 0.00],'linestyle','-','linewidth',2);
|
| | 348 | title(['allelicRatios.chr_' num2str(chromosome) '.segment_' num2str(segment)],'HorizontalAlign','center','VerticalAlign','middle');
|
| | 349 | hold off;
|
| | 350 | xlim([1,200]);
|
| | 351 | % save then delete figures.
|
| | 352 | saveas(fig, [workingDir saveName '.png'], 'png');
|
| | 353 | delete(fig);
|
| | 354 | end;
|
| | 355 |
|
| 12 | 356 | end
|
Other subfunctions in this file are not included in this listing.