#!/usr/bin/ruby -w ## The yeast Scal db mean background is: 0.00984 ## The yeast Cysteine background freq is: 0.0131986582396467 pep_seq_re = / pep_cnts, 'probs' => probs, 'prob_fprs' => prob_fprs, 'prob_tps' => prob_tps, 'cys_fprs' => cys_fprs, 'cys_tps' => cys_tps, 'fpr_diff' => fpr_diff, } real_base = file.sub(/\.xml/,'') ## TPS vs FPR base = real_base.dup base << "." << "tps_vs_fpr" base_toplot = base + '.to_plot' title = "Peptide Prophet FPR Estimation (bg: #{background_freq})" xaxis = "TPs" yaxis = "FPR" cats = [['prob_tps', 'prob_fprs'],['cys_tps', 'cys_fprs']] plot(base_toplot, base, title, xaxis, yaxis, hash, cats) ## PEPHITS vs FPR base = real_base.dup base << "." << "num_pep_hits_vs_fpr" base_toplot = base + '.to_plot' title = "Peptide Prophet FPR Estimation (bg: #{background_freq})" xaxis = "num peptide hits" yaxis = "FPR" cats = [['pep_cnts', 'prob_fprs'],['pep_cnts', 'cys_fprs']] plot(base_toplot, base, title, xaxis, yaxis, hash, cats) ## PEPHITS VS FPR DIFF base = real_base.dup base << "." << "num_pep_hits_vs_fpr_diff" base_toplot = base + '.to_plot' title = "num_pep_hits vs fpr_diff (prob - cysteine) (bg: #{background_freq})" xaxis = "num peptide hits" yaxis = "FPR diff (prob - cysteine)" cats = [['pep_cnts', 'fpr_diff']] plot(base_toplot, base, title, xaxis, yaxis, hash, cats) ## PROB VS FPR DIFF base = real_base.dup base << "." << "prob_vs_fpr_diff" base_toplot = base + '.to_plot' title = "peptide prob vs fpr_diff (prob - cysteine) (bg: #{background_freq})" xaxis = "peptide probability" yaxis = "FPR diff (prob - cysteine)" cats = [['probs', 'fpr_diff']] plot(base_toplot, base, title, xaxis, yaxis, hash, cats) =begin returns [number_of_prots, actual_fpr] def num_prots_above_fpr(prots, desired_fpr) current_fpr_rate_percent = 0.0 previous_fpr_rate_percent = 0.0 current_sum_one_minus_prob = 0.0 proteins_within_fpr = 0 actual_fpr = nil already_found = false prot_cnt = 0 prots.each do |prot| prot_cnt += 1 # SUM(1-probX)/#prots current_sum_one_minus_prob += 1.0 - prot._probability.to_f current_fpr_rate_percent = (current_sum_one_minus_prob / prot_cnt) * 100 if current_fpr_rate_percent > desired_fpr && !already_found actual_fpr = previous_fpr_rate_percent proteins_within_fpr = prot_cnt already_found = true end previous_fpr_rate_percent = current_fpr_rate_percent end [proteins_within_fpr, actual_fpr] end =end