MCPcopy Create free account
hub / github.com/BoevaLab/FREEC / calculateSomaticCNVs

Method calculateSomaticCNVs

src/GenomeCopyNumber.cpp:2946–2985  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2944
2945
2946void GenomeCopyNumber::calculateSomaticCNVs (std::vector <EntryCNV> controlCNVs, int controlPloidy) {
2947 ifUsedControl_=true;
2948
2949 int overlapPrecision = 3; //+-3 windows => the same CNA
2950
2951 std::cout << "..Calculate somatic CNVs" << std::endl;
2952 for (int i = 0; i < (int)CNVs_.size(); i++) {
2953 string type = "somatic";
2954 vector <int>lefts;
2955 vector <int> rights;
2956 for (int unsigned j = 0; j < controlCNVs.size(); j++) {
2957 int left, right;
2958 float overlap;
2959 if (sex_.compare("XY")==0 && (CNVs_[i].getChr().find("X")!=string::npos || CNVs_[i].getChr().find("Y")!=string::npos)) {
2960 overlap=CNVs_[i].compare(controlCNVs[j], overlapPrecision, left, right,ploidy_*0.5,controlPloidy*0.5);
2961 } else {
2962 overlap=CNVs_[i].compare(controlCNVs[j], overlapPrecision, left, right,ploidy_,controlPloidy);
2963 }
2964 if (overlap==1) {
2965 type = "germline";
2966 CNVs_[i].setGermlinePercent(overlap);
2967 break;
2968 } else if (overlap>0) {
2969 lefts.push_back(left);
2970 rights.push_back(right);
2971 }
2972 }
2973 CNVs_[i].setType(type);
2974 if (type == "somatic" && lefts.size()>0) {
2975 //we will devide this CNV into peaces..
2976 int germlineLength = calculateTotalLength(lefts,rights);
2977 CNVs_[i].setGermlinePercent(germlineLength*1./(CNVs_[i].getEnd()-CNVs_[i].getStart()+1));
2978 lefts.clear();
2979 rights.clear();
2980 } else if (type == "somatic") {
2981 CNVs_[i].setGermlinePercent(0);
2982 }
2983 }
2984
2985}
2986void GenomeCopyNumber::printRatioBedGraph(std::string const& chr, std::ofstream & file, std::string const& typeCNA) {
2987 string::size_type pos = 0;
2988 float value;

Callers 1

mainFunction · 0.80

Calls 7

calculateTotalLengthFunction · 0.85
compareMethod · 0.80
getChrMethod · 0.80
setGermlinePercentMethod · 0.80
setTypeMethod · 0.80
getEndMethod · 0.80
getStartMethod · 0.80

Tested by

no test coverage detected