MCPcopy Create free account
hub / github.com/OpenMS/OpenMS / plotHeatMap

Method plotHeatMap

src/topp/MetaProSIP.cpp:365–466  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

363{
364public:
365 static void plotHeatMap(const String& output_dir, const String& tmp_path, const String& file_suffix, const String& file_extension, const vector<vector<double> >& binned_ria, vector<String> class_labels, Size debug_level = 0, const QString& executable = QString("R"))
366 {
367 String filename = String("heatmap") + file_suffix + "." + file_extension;
368 String script_filename = String("heatmap") + file_suffix + String(".R");
369
370 TextFile current_script;
371 StringList ria_list, col_labels;
372
373 for (Size i = 0; i != binned_ria[0].size(); ++i)
374 {
375 String label = String(i * (100 / binned_ria[0].size())) + "%-" + String((i + 1) * (100 / binned_ria[0].size())) + "%";
376 col_labels.push_back(label);
377 }
378
379 for (vector<vector<double> >::const_iterator pit = binned_ria.begin(); pit != binned_ria.end(); ++pit)
380 {
381 for (vector<double>::const_iterator rit = pit->begin(); rit != pit->end(); ++rit)
382 {
383 ria_list.push_back(String(*rit));
384 }
385 }
386
387 // row labels
388 StringList row_labels;
389 if (!class_labels.empty())
390 {
391 for (Size i = 0; i != class_labels.size(); ++i)
392 {
393 row_labels.push_back(class_labels[i]);
394 }
395 }
396
397 // plot heatmap
398 current_script.addLine("library(gplots)");
399 String ria_list_string;
400 ria_list_string.concatenate(ria_list.begin(), ria_list.end(), ",");
401 current_script.addLine("mdat <- matrix(c(" + ria_list_string + "), ncol=" + String(binned_ria[0].size()) + ", byrow=TRUE)");
402
403 if (file_extension == "png")
404 {
405 current_script.addLine("png('" + tmp_path + "/" + filename + "', width=1000, height=" + String(10 * binned_ria.size()) + ")");
406 }
407 else if (file_extension == "svg")
408 {
409 current_script.addLine("svg('" + tmp_path + "/" + filename + "', width=8, height=4.5)");
410 }
411 else if (file_extension == "pdf")
412 {
413 current_script.addLine("pdf('" + tmp_path + "/" + filename + "', width=8, height=4.5)");
414 }
415
416 String labRowString;
417 if (row_labels.empty())
418 {
419 labRowString = "FALSE";
420 }
421 else
422 {

Callers

nothing calls this directly

Calls 13

concatenateMethod · 0.80
QStringClass · 0.50
StringClass · 0.50
sizeMethod · 0.45
push_backMethod · 0.45
beginMethod · 0.45
endMethod · 0.45
emptyMethod · 0.45
storeMethod · 0.45
toQStringMethod · 0.45
startMethod · 0.45
copyMethod · 0.45

Tested by

no test coverage detected