Class: FDRTest

Inherits:
Test::Unit::TestCase
  • Object
show all
Defined in:
lib/MARQ/fdr.rb

Instance Method Summary collapse

Instance Method Details

#clean(values) ⇒ Object



139
140
141
142
143
144
145
# File 'lib/MARQ/fdr.rb', line 139

def clean(values)
  if Array === values
    values.collect{|v| (v * 10000).to_i.to_f / 10000}
  else
    (values * 10000).to_i.to_f / 10000
  end
end

#copy(values) ⇒ Object



147
148
149
# File 'lib/MARQ/fdr.rb', line 147

def copy(values)
  values.collect{|v| v + 0.0}
end

#setupObject



151
152
153
154
155
156
157
# File 'lib/MARQ/fdr.rb', line 151

def setup
  @r = RSRuby.instance
  @values = [0.001, 0.002, 0.003, 0.003, 0.003, 0.004, 0.006, 0.07, 0.09]
  @threshold = 0.01
  @r_adj = @r.p_adjust(@values,'BH')

end

#test_adjustObject



165
166
167
168
169
170
# File 'lib/MARQ/fdr.rb', line 165

def test_adjust
  assert_equal(clean(@r_adj), clean(FDR.adjust_native(@values)))
  assert_equal(clean(FDR.adjust_fast(@values)), clean(FDR.adjust_native(@values)))

  assert_equal(clean(@r_adj), clean(FDR.adjust_fast_self(copy(@values))))
end

#test_step_upObject



159
160
161
162
163
# File 'lib/MARQ/fdr.rb', line 159

def test_step_up
  assert_equal(0.006, clean(FDR.step_up(@values, @threshold)))
  assert_equal(clean(FDR.step_up_native(@values, @threshold)), clean(FDR.step_up_fast(@values,@threshold)))
  assert_equal(@r_adj.select{|v| v <= @threshold}.length, @values.select{|v| v <= FDR.step_up(@values, @threshold)}.length)
end