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 +4 -4
- data/lib/rbbt/statistics/fdr.rb +38 -26
- data/lib/rbbt/statistics/hypergeometric.rb +5 -3
- data/test/rbbt/statistics/test_fdr.rb +4 -5
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8e5a9283f6f9108886ee24aeea8b589e6499833f
|
4
|
+
data.tar.gz: 171269f201ce1e0f6d068e0002096cd94884150a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f7b061d03710e3e570e39dc907d9220c19dfdee0809c469fe92d1eb01a62d34c938cc9274c906b2a5d078bc2ffe2c42af2c1f7ab142e5a9bf172f0559203c173
|
7
|
+
data.tar.gz: c7e7e6bf19b44a2ba0638df98d515e7239da9e1933f77cf7ed93552caae60dde9b66b53056d2eacd692ec51b2023c0894cfb435a7eaec92954fda4963dadc71c
|
data/lib/rbbt/statistics/fdr.rb
CHANGED
@@ -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
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
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
|
-
|
156
|
-
|
157
|
-
|
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
|
-
|
160
|
-
|
161
|
-
|
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(
|
105
|
-
RSRuby.instance.phyper(
|
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 '
|
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 =
|
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
|
+
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-
|
11
|
+
date: 2014-05-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rbbt-util
|