Module: BioVcf::Variant
- Defined in:
- lib/bio-vcf/variant.rb
Class Method Summary collapse
- .apply_threshold(t, normal, tumor) ⇒ Object
- .diff(normal, tumor) ⇒ Object
- .index(normal, tumor) ⇒ Object
- .relative_diff(normal, tumor) ⇒ Object
- .relative_threshold_diff(t, normal, tumor) ⇒ Object
- .threshold_diff(t, normal, tumor) ⇒ Object
Class Method Details
.apply_threshold(t, normal, tumor) ⇒ Object
31 32 33 34 35 |
# File 'lib/bio-vcf/variant.rb', line 31 def Variant.apply_threshold t,normal,tumor normal2 = normal.map{|v| (v>t ? 0 : v) } tumor2 = tumor.each_with_index.map{|v,i| (normal2[i]==0 ? 0 : v) } return normal2,tumor2 end |
.diff(normal, tumor) ⇒ Object
5 6 7 |
# File 'lib/bio-vcf/variant.rb', line 5 def Variant.diff normal,tumor tumor.each_with_index.map {|t,i| t-normal[i]} end |
.index(normal, tumor) ⇒ Object
25 26 27 28 29 |
# File 'lib/bio-vcf/variant.rb', line 25 def Variant.index normal,tumor rd = relative_diff(normal,tumor) max = rd.reduce(0){|mem,v| (v>mem ? v : mem) } rd.index(max) end |
.relative_diff(normal, tumor) ⇒ Object
14 15 16 17 18 |
# File 'lib/bio-vcf/variant.rb', line 14 def Variant.relative_diff normal,tumor d = diff(normal,tumor) total = tumor.each_with_index.map {|t,i| t+normal[i]} total.each_with_index.map {|t,i| (t==0 ? 0 : ((d[i].to_f/t)*100.0).round/100.0)} end |
.relative_threshold_diff(t, normal, tumor) ⇒ Object
20 21 22 23 |
# File 'lib/bio-vcf/variant.rb', line 20 def Variant.relative_threshold_diff t,normal,tumor normal2,tumor2 = apply_threshold(t,normal,tumor) relative_diff(normal2,tumor2) end |
.threshold_diff(t, normal, tumor) ⇒ Object
9 10 11 12 |
# File 'lib/bio-vcf/variant.rb', line 9 def Variant.threshold_diff t,normal,tumor normal2,tumor2 = apply_threshold(t,normal,tumor) diff(normal2,tumor2) end |