class Bio::KEGG::EXPRESSION
Attributes
max_intensity[R]
orf2ratio[R]
orf2rgb[R]
orf2val[R]
Public Class Methods
new(entry)
click to toggle source
# File lib/bio/db/kegg/expression.rb 19 def initialize(entry) 20 @orf2val = Hash.new('') 21 @orf2rgb = Hash.new('') 22 @orf2ratio = Hash.new('') 23 @max_intensity = 10000 24 entry.split("\n").each do |line| 25 unless /^#/ =~ line 26 ary = line.split("\t") 27 orf = ary.shift 28 val = ary[2, 4].collect {|x| x.to_f} 29 @orf2val[orf] = val 30 end 31 end 32 end
Public Instance Methods
control_avg()
click to toggle source
# File lib/bio/db/kegg/expression.rb 38 def control_avg 39 sum = 0.0 40 @orf2val.values.each do |v| 41 sum += v[0] - v[1] 42 end 43 sum/orf2val.size 44 end
control_sd()
click to toggle source
# File lib/bio/db/kegg/expression.rb 74 def control_sd 75 var = self.control_var 76 Math.sqrt(var) 77 end
control_var()
click to toggle source
# File lib/bio/db/kegg/expression.rb 54 def control_var 55 sum = 0.0 56 avg = self.control_avg 57 @orf2val.values.each do |v| 58 tmp = v[0] - v[1] 59 sum += (tmp - avg)*(tmp - avg) 60 end 61 sum/orf2val.size 62 end
down_regulated(num=20, threshold=nil)
click to toggle source
# File lib/bio/db/kegg/expression.rb 98 def down_regulated(num=20, threshold=nil) 99 logy_minus_logx 100 ary = @orf2ratio.to_a.sort{|a, b| a[1] <=> b[1]} 101 if threshold != nil 102 i = 0 103 while ary[i][1] < threshold 104 i += 1 105 end 106 return ary[0..i] 107 else 108 return ary[0..num-1] 109 end 110 end
logy_minus_logx()
click to toggle source
# File lib/bio/db/kegg/expression.rb 126 def logy_minus_logx 127 @orf2val.each do |k, v| 128 @orf2ratio[k] = (1.0/Math.log10(2))*(Math.log10(v[2]-v[3]) - Math.log10(v[0]-v[1])) 129 end 130 end
regulated(num=20, threshold=nil)
click to toggle source
# File lib/bio/db/kegg/expression.rb 112 def regulated(num=20, threshold=nil) 113 logy_minus_logx 114 ary = @orf2ratio.to_a.sort{|a, b| b[1].abs <=> a[1].abs} 115 if threshold != nil 116 i = 0 117 while ary[i][1].abs > threshold 118 i += 1 119 end 120 return ary[0..i] 121 else 122 return ary[0..num-1] 123 end 124 end
target_avg()
click to toggle source
# File lib/bio/db/kegg/expression.rb 46 def target_avg 47 sum = 0.0 48 @orf2val.values.each do |v| 49 sum += v[2] - v[3] 50 end 51 sum/orf2val.size 52 end
target_sd()
click to toggle source
# File lib/bio/db/kegg/expression.rb 79 def target_sd 80 var = self.target_var 81 Math.sqrt(var) 82 end
target_var()
click to toggle source
# File lib/bio/db/kegg/expression.rb 64 def target_var 65 sum = 0.0 66 avg = self.target_avg 67 @orf2val.values.each do |v| 68 tmp = v[2] - v[3] 69 sum += (tmp - avg)*(tmp - avg) 70 end 71 sum/orf2val.size 72 end
up_regulated(num=20, threshold=nil)
click to toggle source
# File lib/bio/db/kegg/expression.rb 84 def up_regulated(num=20, threshold=nil) 85 logy_minus_logx 86 ary = @orf2ratio.to_a.sort{|a, b| b[1] <=> a[1]} 87 if threshold != nil 88 i = 0 89 while ary[i][1] > threshold 90 i += 1 91 end 92 return ary[0..i] 93 else 94 return ary[0..num-1] 95 end 96 end
val2rgb()
click to toggle source
# File lib/bio/db/kegg/expression.rb 132 def val2rgb 133 col_unit = @max_intensity/255 134 @orf2val.each do |k, v| 135 tmp_val = ((v[0] - v[1])/col_unit).to_i 136 if tmp_val > 255 137 g = "ff" 138 else 139 g = format("%02x", tmp_val) 140 end 141 tmp_val = ((v[2] - v[3])/col_unit).to_i 142 if tmp_val > 255 143 r = "ff" 144 else 145 r = format("%02x", tmp_val) 146 end 147 @orf2rgb[k] = r + g + "00" 148 end 149 150 end