rbbt-dm 1.1.37 → 1.1.38

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: 71fdaa734ed3b4e8184825c24afac4892c4c59f4
4
- data.tar.gz: e592516363b8af1c1dcf10fc44ac7536d2f2befc
3
+ metadata.gz: fc3a1528624e0026f2caa9b351aa87767c3601f1
4
+ data.tar.gz: 9e4d4133a3b4fe32d46ba1fb61bdaa92c6b43c73
5
5
  SHA512:
6
- metadata.gz: ed5bfa1e2425957a311e3df4302717a3b56201c94f6dbb0d04dc8534f45336f29e8054b4ed9c63751bf381069b4dfcc0640612cc151e95c69064986e45eece13
7
- data.tar.gz: 65f9824324f40e3e34fa7b34c8db8db27c979359a601f397490d75dc6857e91760eccb53ddcd82141c625cf0a6ed0c407f82fc84d3607634558a49072464fd3b
6
+ metadata.gz: 337c1d68795c09299636d9b55a3bca970f64bdbfcfe6140e729300bf12c53d646f886d3a4f3790371a8f584c55cff8d0b73a90386369184c6f3b6cb86d5ffd07
7
+ data.tar.gz: a82b72caaeb5d429c20c19d8a7c60113abbdd52edf4ed094bd44f801b37567e763e5a7f9dec85cea536f0463e286cce2e0c7d49b03fb30518571c36fb76d8536
@@ -104,7 +104,7 @@ double hypergeometric_c(double total, double support, double list, double found)
104
104
 
105
105
  def self.hypergeometric(count, positive, negative, total)
106
106
  #RSRuby.instance.phyper(count - 1, positive, negative, total, false).to_f
107
- R.eval("phyper(#{ count } - 1, #{ positive }, #{ negative }, #{ total }, FALSE)").to_f
107
+ R.eval("phyper(#{ count } - 1, #{ positive }, #{ negative }, #{ total }, lower.tail=FALSE)").to_f
108
108
  end
109
109
  end
110
110
 
@@ -114,10 +114,11 @@ module TSV
114
114
  fields ||= self.fields
115
115
  fields = [fields] if String === fields or Symbol === fields
116
116
  rename = options.delete :rename
117
+ background = options.delete :background
117
118
 
118
119
  field_pos = fields.collect{|f| self.fields.index f}.compact
119
120
  persistence_path = self.respond_to?(:persistence_path)? self.persistence_path : nil
120
- Persist.persist(filename, :yaml, :fields => fields, :persist => persistence, :prefix => "Hyp.Geo.Counts", :other => {:rename => rename, :persistence_path => persistence_path}) do
121
+ Persist.persist(filename, :yaml, :fields => fields, :persist => persistence, :prefix => "Hyp.Geo.Counts", :other => {:background => background, :rename => rename, :persistence_path => persistence_path}) do
121
122
  data ||= {}
122
123
 
123
124
  with_unnamed do
@@ -125,22 +126,26 @@ module TSV
125
126
  case type
126
127
  when :single
127
128
  through :key, field_pos do |key, value|
129
+ next if background and not background.include?(key)
128
130
  next if value.nil?
129
131
  data[value] ||= []
130
132
  data[value] << key
131
133
  end
132
134
  when :double
133
135
  through :key, field_pos do |key, values|
136
+ next if background and not background.include?(key)
134
137
  values.flatten.compact.uniq.each{|value| data[value] ||= []; data[value] << key}
135
138
  end
136
139
  when :list
137
140
  through :key, field_pos do |key, values|
138
141
  next if values.nil?
142
+ next if background and not background.include?(key)
139
143
  values.compact.uniq.each{|value| data[value] ||= []; data[value] << key}
140
144
  end
141
145
  when :flat
142
146
  through :key, field_pos do |key, values|
143
147
  next if values.nil?
148
+ next if background and not background.include?(key)
144
149
  values.compact.uniq.each{|value| data[value] ||= []; data[value] << key}
145
150
  end
146
151
  end
@@ -182,7 +187,6 @@ module TSV
182
187
 
183
188
  selected = select :key => list.uniq
184
189
 
185
- tsv_size = keys.length
186
190
  found = selected.keys.length
187
191
  Log.debug "Found #{found} of #{list.length} entities"
188
192
 
@@ -194,7 +198,14 @@ module TSV
194
198
  Log.debug "Using #{ list.length } as sample size"
195
199
  end
196
200
 
197
- counts = annotation_counts fields, options[:persist], :rename => rename, :masked => masked
201
+ if background
202
+ tsv_size = background.length
203
+ counts = annotation_counts fields, options[:persist], :rename => rename, :masked => masked, :background => background
204
+ else
205
+ tsv_size = keys.length
206
+ counts = annotation_counts fields, options[:persist], :rename => rename, :masked => masked
207
+ end
208
+
198
209
 
199
210
  annotation_keys = Hash.new
200
211
  selected.with_unnamed do
@@ -248,8 +259,8 @@ module TSV
248
259
  elems = elems.collect{|elem| rename.include?(elem)? rename[elem] : elem }.compact.uniq if rename
249
260
  count = elems.length
250
261
  next if count < options[:min_support] or not counts.include? annotation
251
- #pvalues[annotation] = RSRuby.instance.phyper(count - 1, counts[annotation], tsv_size - counts[annotation], total, false).to_f
252
262
  pvalues[annotation] = Hypergeometric.hypergeometric(count, counts[annotation], tsv_size - counts[annotation], total)
263
+ iii [annotation, elems, total, counts[annotation], tsv_size, pvalues[annotation]]
253
264
  end
254
265
 
255
266
  pvalues = FDR.adjust_hash! pvalues if options[:fdr]
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.37
4
+ version: 1.1.38
5
5
  platform: ruby
6
6
  authors:
7
7
  - Miguel Vazquez
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-09-21 00:00:00.000000000 Z
11
+ date: 2017-12-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rbbt-util