| 566 | } |
| 567 | |
| 568 | int GenomeCopyNumber::calculateRatioUsingCG (bool intercept, float minExpectedGC, float maxExpectedGC) { //returns 1 if the number of iteration is less than max; otherwise 0 |
| 569 | |
| 570 | //try degree 3 and 4, SELECT THE ONE WITH LESS ITTERATIONS: |
| 571 | int minDegreeToTest = 3; |
| 572 | int maxDegreeToTest = 4; |
| 573 | int selectedDegree=minDegreeToTest; |
| 574 | int maximalNumberOfIterations = 300; |
| 575 | int bestNumberOfIterations=maximalNumberOfIterations; |
| 576 | // int bestSqareError=INFINITY; |
| 577 | int valueToReturn = 0; |
| 578 | |
| 579 | |
| 580 | vector <float> y; //y ~ ax^2+bx+c |
| 581 | vector <float> x; |
| 582 | |
| 583 | //check whether there are chromosomes without X and Y: |
| 584 | vector<ChrCopyNumber>::iterator it; |
| 585 | int countAutosomes = 0; |
| 586 | for ( it=chrCopyNumber_.begin() ; it != chrCopyNumber_.end(); it++ ) { |
| 587 | if (! (it->getChromosome().find("X")!=string::npos || it->getChromosome().find("Y")!=string::npos)) { |
| 588 | countAutosomes++; |
| 589 | } |
| 590 | } |
| 591 | //fill x and y: |
| 592 | for ( it=chrCopyNumber_.begin() ; it != chrCopyNumber_.end(); it++ ) { |
| 593 | |
| 594 | if (countAutosomes>0 && !(it->getChromosome().find("X")!=string::npos || it->getChromosome().find("Y")!=string::npos) || countAutosomes==0) { |
| 595 | // if uniqueMatch, do correction to mappability |
| 596 | if (uniqueMatch) { |
| 597 | //use mappabilityProfile_ and correct |
| 598 | for (int i = 0; i< it->getLength(); i++) { |
| 599 | if ((it->getValueAt(i)>0)&&(it->getMappabilityProfileAt(i)>minMappabilityPerWindow)) { |
| 600 | x.push_back(it->getCGprofileAt(i)); |
| 601 | y.push_back(it->getValueAt(i)/it->getMappabilityProfileAt(i)); |
| 602 | } |
| 603 | } |
| 604 | } else { |
| 605 | //use a threshold, but correct using notN profile |
| 606 | if (it->getMappabilityLength()>0) { |
| 607 | for (int i = 0; i< it->getLength(); i++) { |
| 608 | if ((it->getValueAt(i)>0)&&(it->getMappabilityProfileAt(i)>minMappabilityPerWindow)) { |
| 609 | x.push_back(it->getCGprofileAt(i)); |
| 610 | y.push_back(it->getValueAt(i)/it->getNotNprofileAt(i)); |
| 611 | } |
| 612 | } |
| 613 | } else { |
| 614 | for (int i = 0; i< it->getLength(); i++) { |
| 615 | if ((it->getValueAt(i)>0)&&(it->getNotNprofileAt(i)>minMappabilityPerWindow)) { |
| 616 | x.push_back(it->getCGprofileAt(i)); |
| 617 | y.push_back(it->getValueAt(i)/it->getNotNprofileAt(i)); |
| 618 | } |
| 619 | } |
| 620 | } |
| 621 | } |
| 622 | } |
| 623 | } |
| 624 | |
| 625 | for (int degree=minDegreeToTest;degree<=maxDegreeToTest; degree++) { |
no test coverage detected