Class: Bioinform::MotifModel::PCM
- Inherits:
-
Object
- Object
- Bioinform::MotifModel::PCM
- Defined in:
- lib/sequence_logo/ppm_support.rb
Instance Method Summary collapse
Instance Method Details
#get_logo(icd_mode) ⇒ Object
54 55 56 57 58 59 60 61 |
# File 'lib/sequence_logo/ppm_support.rb', line 54 def get_logo(icd_mode) case icd_mode.to_s when 'weblogo' get_logo_weblogo when 'discrete' get_logo_discrete end end |
#get_logo_discrete ⇒ Object
73 74 75 76 77 78 79 80 |
# File 'lib/sequence_logo/ppm_support.rb', line 73 def get_logo_discrete each_position.map{|position| word_count = position.inject(0.0, &:+) icd4of4 = icd4of4(word_count) inf_content = (icd4of4 == 0) ? 1.0 : scale(position_infocod(position), relative_to: icd4of4) position.map{|el| (el / word_count) * inf_content } } end |
#get_logo_weblogo ⇒ Object
63 64 65 66 67 68 69 70 71 |
# File 'lib/sequence_logo/ppm_support.rb', line 63 def get_logo_weblogo each_position.map{|position| word_count = position.inject(0.0, &:+) inf_content = position.map{|el| (el == 0) ? 0 : (el / word_count) * Math.log2(el / word_count) }.inject(0.0, :+) + 2 position.map{|el| (el / word_count) * inf_content / 2 } } end |