rbbt-dm 1.1.4 → 1.1.5

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 412564d1fb5e11cd74d9d5f5831d3169c3b41bfc
4
- data.tar.gz: b8015384a48dd97d9aaacc87f409d4a003b6a25e
3
+ metadata.gz: 8e5a9283f6f9108886ee24aeea8b589e6499833f
4
+ data.tar.gz: 171269f201ce1e0f6d068e0002096cd94884150a
5
5
  SHA512:
6
- metadata.gz: 4c27963bc45ac247de676b90f64748a6c8e6108a27e5c493620156a758db8c0709c9666e3c9d016b273ec754c8063d6636e2887680ce7aef51db8f34ae69112c
7
- data.tar.gz: 65da093976bce048ab5572f904e831628178eb01dba43888bdebb7c2f2e9150070905610cebe52a8c59ea1503505d57fe4c4a3d179f358e617a15dde6150f65f
6
+ metadata.gz: f7b061d03710e3e570e39dc907d9220c19dfdee0809c469fe92d1eb01a62d34c938cc9274c906b2a5d078bc2ffe2c42af2c1f7ab142e5a9bf172f0559203c173
7
+ data.tar.gz: c7e7e6bf19b44a2ba0638df98d515e7239da9e1933f77cf7ed93552caae60dde9b66b53056d2eacd692ec51b2023c0894cfb435a7eaec92954fda4963dadc71c
@@ -135,36 +135,48 @@ module FDR
135
135
  alias :step_up :step_up_fast
136
136
  end
137
137
 
138
- # This will change the values of the floats in-situ
139
138
  def self.adjust_hash!(data, field = nil)
140
- keys = []
141
- values = []
142
-
143
- if data.respond_to? :unnamed
144
- unnamed = data.unnamed
145
- data.unnamed = true
146
- end
147
-
148
- data.collect{|key, value| [key, Array === ( v = field.nil? ? value : value[field] ) ? v.first : v] }.sort{|a,b|
149
- a[1] <=> b[1]
150
- }.each{|p|
151
- keys << p[0]
152
- values << p[1]
153
- }
139
+ begin
140
+ if data.respond_to? :unnamed
141
+ unnamed = data.unnamed
142
+ data.unnamed = true
143
+ end
154
144
 
155
- if data.respond_to? :unnamed
156
- data.unnamed = unnamed
157
- end
145
+ values = []
146
+ keys = []
147
+ data.collect{|k,vs|
148
+ v = field.nil? ? vs : vs[field]
149
+ v = v.first if Array === v
150
+ [k, v]
151
+ }.sort{|a,b|
152
+ a[1] <=> b[1]
153
+ }.each{|p|
154
+ keys << p[0]
155
+ values << p[1]
156
+ }
157
+
158
+ if RUBY_VERSION[0] == "2"
159
+ values = FDR.adjust(values)
160
+ keys.zip(values).each do |k,v|
161
+ vs = data[k]
162
+ if field
163
+ vs[field] = v
164
+ else
165
+ if Array === vs
166
+ vs[0] = v
167
+ else
168
+ data[k] = vs
169
+ end
170
+ end
171
+ end
172
+ else
173
+ FDR.adjust!(values)
174
+ end
158
175
 
159
- if RUBY_VERSION[0] == "2"
160
- # I don't know why the RFLOAT_VALUE_SET for Ruby 2.1.0 does not work
161
- values = FDR.adjust(values)
162
- data = Hash[*keys.zip(values).flatten]
163
- else
164
- FDR.adjust!(values)
176
+ data
177
+ ensure
178
+ data.unnamed = unnamed if unnamed
165
179
  end
166
-
167
- data
168
180
  end
169
181
 
170
182
  end
@@ -101,8 +101,9 @@ double hypergeometric_c(double total, double support, double list, double found)
101
101
  EOC
102
102
  end
103
103
 
104
- def self.hypergeometric(total, support, list, found)
105
- RSRuby.instance.phyper(found, support, total - support, list, false).to_f
104
+ def self.hypergeometric(count, positive, negative, total)
105
+ #RSRuby.instance.phyper(count - 1, positive, negative, total, false).to_f
106
+ R.eval("phyper(#{ count } - 1, #{ positive }, #{ negative }, #{ total }, FALSE)").to_f
106
107
  end
107
108
  end
108
109
 
@@ -246,7 +247,8 @@ module TSV
246
247
  elems = elems.collect{|elem| rename.include?(elem)? rename[elem] : elem }.compact.uniq if rename
247
248
  count = elems.length
248
249
  next if count < options[:min_support] or not counts.include? annotation
249
- pvalues[annotation] = RSRuby.instance.phyper(count - 1, counts[annotation], tsv_size - counts[annotation], total, false).to_f
250
+ #pvalues[annotation] = RSRuby.instance.phyper(count - 1, counts[annotation], tsv_size - counts[annotation], total, false).to_f
251
+ pvalues[annotation] = Hypergeometric.hypergeometric(count, counts[annotation], tsv_size - counts[annotation], total)
250
252
  end
251
253
 
252
254
  pvalues = FDR.adjust_hash! pvalues if options[:fdr]
@@ -1,7 +1,7 @@
1
1
  require File.expand_path(File.dirname(__FILE__) + '/../../test_helper')
2
2
  require 'rbbt/statistics/fdr'
3
3
  require 'test/unit'
4
- require 'rsruby'
4
+ require 'rbbt/util/R'
5
5
 
6
6
  class TestFDR < Test::Unit::TestCase
7
7
  def clean(values)
@@ -17,11 +17,9 @@ class TestFDR < Test::Unit::TestCase
17
17
  end
18
18
 
19
19
  def setup
20
- @r = RSRuby.instance
21
20
  @values = [0.001, 0.002, 0.003, 0.003, 0.003, 0.004, 0.006, 0.07, 0.09]
22
21
  @threshold = 0.01
23
- @r_adj = @r.p_adjust(@values,'BH')
24
-
22
+ @r_adj = R.eval_a "p.adjust(#{R.ruby2R(@values)},'BH')"
25
23
  end
26
24
 
27
25
  def test_step_up
@@ -34,8 +32,9 @@ class TestFDR < Test::Unit::TestCase
34
32
  assert_equal(clean(@r_adj), clean(FDR.adjust_native(@values)))
35
33
  assert_equal(clean(FDR.adjust_fast(@values)), clean(FDR.adjust_native(@values)))
36
34
 
37
- assert_equal(clean(@r_adj), clean(FDR.adjust_fast_self(copy(@values))))
35
+ assert_equal(clean(@r_adj), clean(FDR.adjust_fast_self(copy(@values)))) if RUBY_VERSION[0] != "2"
38
36
  end
37
+
39
38
  end
40
39
 
41
40
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rbbt-dm
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.4
4
+ version: 1.1.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Miguel Vazquez
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-03-25 00:00:00.000000000 Z
11
+ date: 2014-05-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rbbt-util