Class: Validator::DigestionBased
- Defined in:
- lib/validator/digestion_based.rb
Overview
objects of this class can calculate pephit_precision given an array of SpecID::Pep objects using the pephit_precision method.
Direct Known Subclasses
Constant Summary collapse
- DEFAULTS =
{ #:false_to_total_ratio => 1.0, # disable because this needs to be set # explicitly :background => 0.0, }
Instance Attribute Summary collapse
-
#background ⇒ Object
For a sample with no false hits in it, (under defaults) this is the fraction of peptides with the constraint over the total number of peptides from which these hits are derived.
-
#calculated_background ⇒ Object
readonly
the false_to_total_ratio calculated (but not applied).
-
#false_to_total_ratio ⇒ Object
the ratio of false hits to total peptides in the fasta file.
-
#increment_fps ⇒ Object
the number of fps.
-
#increment_total_submitted ⇒ Object
the total peptides submitted to the validator (regardless of tp, fp, or nil).
-
#increment_tps ⇒ Object
the number of tps.
Instance Method Summary collapse
-
#calc_precision_prep(num_tps, num_fps) ⇒ Object
returns [num_tps, num_fps].
-
#pephit_precision(peps) ⇒ Object
expects that classes define a partition method, and a @background.
-
#set_false_to_total_ratio(peps) ⇒ Object
returns self assumes partition returns (tps, fps).
Instance Attribute Details
#background ⇒ Object
For a sample with no false hits in it, (under defaults) this is the fraction of peptides with the constraint over the total number of peptides from which these hits are derived.
32 33 34 |
# File 'lib/validator/digestion_based.rb', line 32 def background @background end |
#calculated_background ⇒ Object (readonly)
the false_to_total_ratio calculated (but not applied)
27 28 29 |
# File 'lib/validator/digestion_based.rb', line 27 def calculated_background @calculated_background end |
#false_to_total_ratio ⇒ Object
the ratio of false hits to total peptides in the fasta file
24 25 26 |
# File 'lib/validator/digestion_based.rb', line 24 def false_to_total_ratio @false_to_total_ratio end |
#increment_fps ⇒ Object
the number of fps
17 18 19 |
# File 'lib/validator/digestion_based.rb', line 17 def increment_fps @increment_fps end |
#increment_total_submitted ⇒ Object
the total peptides submitted to the validator (regardless of tp, fp, or nil)
21 22 23 |
# File 'lib/validator/digestion_based.rb', line 21 def increment_total_submitted @increment_total_submitted end |
#increment_tps ⇒ Object
the number of tps
15 16 17 |
# File 'lib/validator/digestion_based.rb', line 15 def increment_tps @increment_tps end |
Instance Method Details
#calc_precision_prep(num_tps, num_fps) ⇒ Object
returns [num_tps, num_fps]
44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 |
# File 'lib/validator/digestion_based.rb', line 44 def calc_precision_prep(num_tps, num_fps) total_peps_passing_partition = num_tps + num_fps num_fps = adjust_fps_for_background(num_tps, num_fps, background) ## we must use the false_to_total_ratio to estimate how many are really ## incorrect! # FALSE/TOTAL = FALSE(found)/TOTAL(found) # TOTAL(found) = FALSE(found) * TOTAL/FALSE # = FALSE(found) / (FALSE/TOTAL) total_false = num_fps / false_to_total_ratio # NOTE: the partition algorithm drops peptides that are transmembrane # under certain options. Thus, the total false estimate must be tempered # by this lower number of total peptides. adjusted_tps = total_peps_passing_partition.to_f - total_false [adjusted_tps, total_false] end |
#pephit_precision(peps) ⇒ Object
expects that classes define a partition method, and a @background
36 37 38 39 40 41 |
# File 'lib/validator/digestion_based.rb', line 36 def pephit_precision(peps) ## this gives us the fraction that are transmembrane (under defaults): (tps, fps) = partition(peps) (num_tps, num_fps) = calc_precision_prep(tps.size, fps.size) calc_precision(num_tps, num_fps) end |
#set_false_to_total_ratio(peps) ⇒ Object
returns self assumes partition returns (tps, fps)
62 63 64 65 66 |
# File 'lib/validator/digestion_based.rb', line 62 def set_false_to_total_ratio(peps) (tps, fps) = partition(peps) self.false_to_total_ratio = fps.size.to_f / (tps.size + fps.size) self end |