Skip to content

Commit c376126

Browse files
committed
Can work when all chromosomes are Y and X..
1 parent 0376b1e commit c376126

2 files changed

Lines changed: 20 additions & 5 deletions

File tree

src/GenomeCopyNumber.cpp

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -481,8 +481,6 @@ void GenomeCopyNumber::recalculateRatioUsingCG (int degree, bool intercept, floa
481481
vector<ChrCopyNumber>::iterator it;
482482
for ( it=chrCopyNumber_.begin() ; it != chrCopyNumber_.end(); it++ ) {
483483
if (! (it->getChromosome().find("X")!=string::npos || it->getChromosome().find("Y")!=string::npos)) {
484-
485-
486484
//use a threshold, but correct using notN profile
487485
if (it->getMappabilityLength()>0) {
488486
for (int i = 0; i< it->getLength(); i++) {
@@ -551,11 +549,18 @@ int GenomeCopyNumber::calculateRatioUsingCG (bool intercept, float minExpectedGC
551549
vector <float> y; //y ~ ax^2+bx+c
552550
vector <float> x;
553551

554-
//fill x and y:
552+
//check whether there are chromosomes without X and Y:
555553
vector<ChrCopyNumber>::iterator it;
554+
int countAutosomes = 0;
555+
for ( it=chrCopyNumber_.begin() ; it != chrCopyNumber_.end(); it++ ) {
556+
if (! (it->getChromosome().find("X")!=string::npos || it->getChromosome().find("Y")!=string::npos)) {
557+
countAutosomes++;
558+
}
559+
}
560+
//fill x and y:
556561
for ( it=chrCopyNumber_.begin() ; it != chrCopyNumber_.end(); it++ ) {
557562

558-
if (! (it->getChromosome().find("X")!=string::npos || it->getChromosome().find("Y")!=string::npos)) {
563+
if (countAutosomes>0 && !(it->getChromosome().find("X")!=string::npos || it->getChromosome().find("Y")!=string::npos) || countAutosomes==0) {
559564
// if uniqueMatch, do correction to mappability
560565
if (uniqueMatch) {
561566
//use mappabilityProfile_ and correct
@@ -994,8 +999,18 @@ double GenomeCopyNumber::calculateMedianAround (float interval, float around) {
994999

9951000
vector <float> myValuesAround;
9961001
vector<ChrCopyNumber>::iterator it;
1002+
1003+
1004+
int countAutosomes = 0;
1005+
for ( it=chrCopyNumber_.begin() ; it != chrCopyNumber_.end(); it++ ) {
1006+
if (! (it->getChromosome().find("X")!=string::npos || it->getChromosome().find("Y")!=string::npos)) {
1007+
countAutosomes++;
1008+
}
1009+
}
1010+
1011+
9971012
for ( it=chrCopyNumber_.begin() ; it != chrCopyNumber_.end(); it++ ) {
998-
if (! (it->getChromosome().find("X")!=string::npos || it->getChromosome().find("Y")!=string::npos))
1013+
if (countAutosomes>0 && ! (it->getChromosome().find("X")!=string::npos || it->getChromosome().find("Y")!=string::npos) || countAutosomes==0)
9991014
for (int i = 0; i< it->getLength(); i++) {
10001015
if ((it->getCGprofileAt(i)<=maxCG)&&(it->getCGprofileAt(i)>=minCG))
10011016
if (it->getValueAt(i) >0) //non-zero values

src/freec

32.7 KB
Binary file not shown.

0 commit comments

Comments
 (0)