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

Function get_iqr

src/myFunc.cpp:226–265  ·  view source on GitHub ↗

Calculate inter quartile range across individuals ---------------------------------------------------------------------------

Source from the content-addressed store, hash-verified

224// Calculate inter quartile range across individuals
225// ---------------------------------------------------------------------------
226float get_iqr(const std::vector<float>& myvector) {
227 vector<float> data (myvector);
228 int ndatapoints = data.size();
229 if (ndatapoints==0) {
230 cerr << "Error: zero values to calculate medians..\n";
231 exit(-1);
232 }
233 sort(data.begin(),data.end());
234 // Get IQR
235 float lower_quartile, upper_quartile;
236
237 if( ndatapoints % 2 == 1){
238 float fl = (ndatapoints-1)/float(4.0);
239 float fu = 3*(ndatapoints-1)/float(4.0);
240
241 if( fmod(fl,float(1.0)) == 0 ){
242 lower_quartile = data[ (int) fl ];
243 upper_quartile = data[ (int) fu ];
244 }
245 else{
246 lower_quartile = (data[ (int) fl ] + data[ (int) fl + 1 ])/float(2.0);
247 upper_quartile = (data[ (int) fu ] + data[ (int) fu + 1 ])/float(2.0);
248 }
249 }
250 else{
251 double fl = (ndatapoints)/float(4.0);
252 double fu = 3*(ndatapoints)/float(4.0);
253
254 if( fmod(fl,1.0) == 0 ){
255 lower_quartile = data[ (int) fl ];
256 upper_quartile = data[ (int) fu ];
257 }
258 else{
259 lower_quartile = (data[ (int) fl ] + data[ (int) fl + 1 ])/float(2);
260 upper_quartile = (data[ (int) fu ] + data[ (int) fu + 1 ])/float(2);
261 }
262 }
263
264 return upper_quartile - lower_quartile;
265}
266
267void readChrNamesInBed(const std::string &targetBed, std::vector<std::string>&names_bed){
268 ifstream file(targetBed.c_str());

Callers 2

GenomeDensityMethod · 0.85
removeLargeExonsMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected