| 665 | } |
| 666 | |
| 667 | static void plotScoresAndWeights(const String& output_dir, const String& tmp_path, const String& file_suffix, const String& file_extension, const vector<SIPPeptide>& sip_peptides, double score_plot_yaxis_min, Size debug_level = 0, const QString& executable = QString("R")) |
| 668 | { |
| 669 | String score_filename = String("score_plot") + file_suffix + file_extension; |
| 670 | String script_filename = String("score_plot") + file_suffix + String(".R"); |
| 671 | |
| 672 | for (Size i = 0; i != sip_peptides.size(); ++i) |
| 673 | { |
| 674 | TextFile current_script; |
| 675 | StringList rate_dec_list; |
| 676 | StringList rate_corr_list; |
| 677 | StringList weights_list; |
| 678 | StringList corr_list; |
| 679 | |
| 680 | for (MapRateToScoreType::const_iterator mit = sip_peptides[i].decomposition_map.begin(); mit != sip_peptides[i].decomposition_map.end(); ++mit) |
| 681 | { |
| 682 | rate_dec_list.push_back(String(mit->first)); |
| 683 | weights_list.push_back(String(mit->second)); |
| 684 | } |
| 685 | |
| 686 | for (MapRateToScoreType::const_iterator mit = sip_peptides[i].correlation_map.begin(); mit != sip_peptides[i].correlation_map.end(); ++mit) |
| 687 | { |
| 688 | rate_corr_list.push_back(String(mit->first)); |
| 689 | corr_list.push_back(String(mit->second)); |
| 690 | } |
| 691 | |
| 692 | String rate_dec_list_string; |
| 693 | rate_dec_list_string.concatenate(rate_dec_list.begin(), rate_dec_list.end(), ","); |
| 694 | |
| 695 | String weights_list_string; |
| 696 | weights_list_string.concatenate(weights_list.begin(), weights_list.end(), ","); |
| 697 | |
| 698 | String rate_corr_list_string; |
| 699 | rate_corr_list_string.concatenate(rate_corr_list.begin(), rate_corr_list.end(), ","); |
| 700 | |
| 701 | String corr_list_string; |
| 702 | corr_list_string.concatenate(corr_list.begin(), corr_list.end(), ","); |
| 703 | |
| 704 | current_script.addLine("rate_dec<-c(" + rate_dec_list_string + ")"); |
| 705 | current_script.addLine("dec<-c(" + weights_list_string + ")"); |
| 706 | current_script.addLine("if (max(dec)!=0) {dec<-dec/max(dec)}"); |
| 707 | current_script.addLine("rate_corr<-c(" + rate_corr_list_string + ")"); |
| 708 | current_script.addLine("corr<-c(" + corr_list_string + ")"); |
| 709 | |
| 710 | if (score_plot_yaxis_min >= 0) |
| 711 | { |
| 712 | current_script.addLine("corr[corr<0]=0"); // truncate at 0 for better drawing |
| 713 | } |
| 714 | |
| 715 | current_script.addLine("x0=rate_dec; x1=rate_dec; y0=rep(0, length(x0)); y1=dec"); // create R segments for decomposition score (vertical bars) |
| 716 | if (file_extension == "png") |
| 717 | { |
| 718 | current_script.addLine("png('" + tmp_path + "/" + score_filename + "')"); |
| 719 | } |
| 720 | else if (file_extension == "svg") |
| 721 | { |
| 722 | current_script.addLine("svg('" + tmp_path + "/" + score_filename + "', width=8, height=4.5)"); |
| 723 | } |
| 724 | else if (file_extension == "pdf") |
nothing calls this directly
no test coverage detected