| 1222 | |
| 1223 | |
| 1224 | int runWithDefinedPloidy(int ploidy, GenomeCopyNumber & sampleCopyNumber, GenomeCopyNumber & controlCopyNumber, bool isControlIsPresent, int forceGC, |
| 1225 | bool has_BAF,bool ifTargeted,bool WESanalysis, |
| 1226 | int degree,int intercept,bool logLogNorm,float minExpectedGC,float maxExpectedGC,float knownContamination,float breakPointThreshold,int breakPointType,int minCNAlength, |
| 1227 | int teloCentroFlanks, vector<double> & RSS, vector<double> &percentage_GenExpl,bool contaminationAdjustment,vector<double> &contamination, ThreadPool * thrPool, |
| 1228 | ThreadPoolManager * thrPoolManager, string makePileup, float seekSubclones, std::string myName, vector<int> &unexplainedChromosomes, bool CompleteGenomicsData, |
| 1229 | bool normalization) { |
| 1230 | //NORMALIZE READ COUNT: |
| 1231 | sampleCopyNumber.setPloidy(ploidy); |
| 1232 | sampleCopyNumber.setNormalContamination(knownContamination); |
| 1233 | |
| 1234 | int successfulFit = 1; |
| 1235 | |
| 1236 | if (normalization) { |
| 1237 | if (isControlIsPresent) { |
| 1238 | if (((!forceGC) && (!has_BAF)) || (ifTargeted&&forceGC!=1) || (WESanalysis == true &&forceGC==0)) { //normalize sample density with control density |
| 1239 | successfulFit = sampleCopyNumber.calculateRatio(controlCopyNumber, degree,intercept); |
| 1240 | } else { //forceGC != 0 |
| 1241 | if (forceGC==1) { //normalize first Sample and Control, and then calculate the ratio |
| 1242 | if (degree==NA) { |
| 1243 | successfulFit = sampleCopyNumber.calculateRatioUsingCG( intercept,minExpectedGC,maxExpectedGC); |
| 1244 | if (controlCopyNumber.calculateRatioUsingCG( intercept,minExpectedGC,maxExpectedGC)==0) |
| 1245 | successfulFit = 0; |
| 1246 | } |
| 1247 | else { |
| 1248 | successfulFit = sampleCopyNumber.calculateRatioUsingCG(degree, intercept,minExpectedGC,maxExpectedGC); |
| 1249 | if (controlCopyNumber.calculateRatioUsingCG(degree, intercept,minExpectedGC,maxExpectedGC)==0) |
| 1250 | successfulFit = 0; |
| 1251 | } |
| 1252 | sampleCopyNumber.calculateRatioUsingCG(controlCopyNumber); |
| 1253 | //sampleCopyNumber.calculateRatioUsingCG_Regression(controlCopyNumber); |
| 1254 | } else if (forceGC==2) { //calculate the ratio , normalize for GC |
| 1255 | successfulFit = sampleCopyNumber.calculateRatio(controlCopyNumber, degree,intercept); |
| 1256 | sampleCopyNumber.recalculateRatioUsingCG(8, 1,minExpectedGC,maxExpectedGC); //try higher values of polynomial's degree |
| 1257 | } |
| 1258 | } |
| 1259 | if(has_BAF && forceGC!=1 && !ifTargeted && WESanalysis == false) { //calculateRatioUsingCG |
| 1260 | if (intercept != 1) cerr << "Warning: Again, I would advise using 'intercept = 1' with your parameters\n"; |
| 1261 | |
| 1262 | if (forceGC==0) { //otherwise, already calculated for the Sample |
| 1263 | if (degree==NA) { |
| 1264 | successfulFit = sampleCopyNumber.calculateRatioUsingCG( intercept,minExpectedGC,maxExpectedGC); |
| 1265 | } |
| 1266 | else { |
| 1267 | successfulFit = sampleCopyNumber.calculateRatioUsingCG(degree, intercept,minExpectedGC,maxExpectedGC); |
| 1268 | } |
| 1269 | } |
| 1270 | |
| 1271 | if (degree==NA) { |
| 1272 | if(controlCopyNumber.calculateRatioUsingCG(intercept,minExpectedGC,maxExpectedGC)==0) |
| 1273 | successfulFit = 0; |
| 1274 | } |
| 1275 | else { |
| 1276 | if(controlCopyNumber.calculateRatioUsingCG(degree, intercept,minExpectedGC,maxExpectedGC)==0) |
| 1277 | successfulFit = 0; |
| 1278 | } |
| 1279 | |
| 1280 | } |
| 1281 | if (ifTargeted && (has_BAF) && forceGC!=1) { |
no test coverage detected