iroki 0.0.31 → 0.0.32

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: b751c71c6569e45169248b4590d971589f6b0547
4
- data.tar.gz: f484b255f98acf4608afd6193ea201de8841039d
3
+ metadata.gz: 571e5fc652dc40cb60edcb05f06a2a7665b63174
4
+ data.tar.gz: 814c6974bead105ac50b176706af90360ed236b7
5
5
  SHA512:
6
- metadata.gz: 6075a849a8b9af0c9faab51b47e7661116376171699dd143560659b9eb52bfd0b130c3cb48573bdc79a6075d311333447235796a9b06718db65c2b393897d89a
7
- data.tar.gz: be579ec3a076408d1aaad3ae2edff537f1019ef72ebfed5db601cbe3c5badab93d6214fafc42daf37faf645b8bf09f079051c414387ec7ccb2a76406337e6070
6
+ metadata.gz: d8ef3ec139f50d020f063d9f226661a4684c5310a4997e223c45d771b330ea3d1e8131ca452f9aa0ffff9861d49f6c1dfc7e6b419bd41eaf9b2c4672cdc2f3bf
7
+ data.tar.gz: 57e478c4e164883104019233a5ec179f8e2c58df6890a03d95cb0e8120edef80ad3c4aa5a136da156bbe4f3579761243a9dcd12ffce5655fb47d62e1fba3fadc
data/exe/iroki CHANGED
@@ -59,8 +59,7 @@ opts = Trollop.options do
59
59
  type: :string)
60
60
 
61
61
  opt(:single_color,
62
- "Use single color gradient for single group biom files",
63
- type: :string)
62
+ "Use single color gradient for single group biom files")
64
63
 
65
64
  opt(:name_map,
66
65
  "File with name mappings",
@@ -85,6 +84,17 @@ opts = Trollop.options do
85
84
  "Default color",
86
85
  type: :string,
87
86
  default: "black")
87
+
88
+ opt(:min_lumin,
89
+ "Min luminosity (only used for gradients)",
90
+ type: :int,
91
+ default: 35)
92
+
93
+ opt(:max_lumin,
94
+ "Max luminosity (only used for gradients)",
95
+ type: :int,
96
+ default: 70)
97
+
88
98
  end
89
99
 
90
100
  Iroki::Main.main(
@@ -100,5 +110,7 @@ Iroki::Main.main(
100
110
  display_auto_color_options: opts[:display_auto_color_options],
101
111
  newick_f: opts[:infile],
102
112
  out_f: opts[:outfile],
103
- default_color: opts[:default_color]
113
+ default_color: opts[:default_color],
114
+ min_lumin: opts[:min_lumin],
115
+ max_lumin: opts[:max_lumin]
104
116
  )
@@ -19,16 +19,43 @@
19
19
  module Iroki
20
20
  module Color
21
21
  class Gradient
22
- attr_accessor :samples, :color_hex_codes, :lumins, :single_color
22
+ attr_accessor :samples,
23
+ :color_hex_codes,
24
+ :lumins,
25
+ :single_color,
26
+ :min_lumin,
27
+ :max_lumin
23
28
 
24
29
  # scales [old_min, old_max] to [new_min, new_max]
25
- def scale x, new_min=0.05, new_max=0.9, old_min=0.0, old_max=1.0
30
+ def scale x,
31
+ new_min=0.05,
32
+ new_max=0.9,
33
+ old_min=0.0,
34
+ old_max=1.0
35
+
36
+ x = x.to_f
37
+ new_min = new_min.to_f
38
+ new_max = new_max.to_f
39
+ old_min = old_min.to_f
40
+ old_max = old_max.to_f
41
+
26
42
  ((((new_max - new_min) * (x - old_min.to_f)) / (old_max - old_min)) + new_min)
27
43
  end
28
44
 
29
45
  # scales [old_min, old_max] to [new_max, new_min]
30
- def scale_reverse x, new_min=0.0, new_max=0.0, old_min=0.0, old_max=1.0
31
- (new_max - ((((new_max - new_min) * (x - old_min.to_f)) / (old_max - old_min)) + new_min)) + new_min
46
+ def scale_reverse x,
47
+ new_min=0.0,
48
+ new_max=0.0,
49
+ old_min=0.0,
50
+ old_max=1.0
51
+
52
+ x = x.to_f
53
+ new_min = new_min.to_f
54
+ new_max = new_max.to_f
55
+ old_min = old_min.to_f
56
+ old_max = old_max.to_f
57
+
58
+ (new_max - ((((new_max - new_min) * (x - old_min.to_f)) / (old_max - old_min)) + new_min)) + new_min
32
59
  end
33
60
 
34
61
  def patterns
@@ -51,7 +78,10 @@ module Iroki
51
78
 
52
79
  def rabunds_to_lumins rabunds
53
80
  rabunds.map do |count|
54
- scale_reverse count, new_min=50, new_max=97
81
+ # scale_reverse count, new_min=50, new_max=97
82
+ # scale_reverse count, new_min=35, new_max=85
83
+ scale_reverse count, new_min=@min_lumin, new_max=@max_lumin
84
+ # scale_reverse count, 0.0, 50.0
55
85
  end
56
86
  end
57
87
  end
@@ -21,11 +21,19 @@ module Iroki
21
21
  class SingleGroupGradient < Gradient
22
22
  attr_accessor :counts, :rel_abunds
23
23
 
24
- def initialize samples, counts, single_color=false
24
+ def initialize samples,
25
+ counts,
26
+ single_color=false,
27
+ min_lumin,
28
+ max_lumin
29
+
25
30
  abort_unless samples.count == counts.count,
26
31
  "Samples (#{samples.count}) and counts " +
27
32
  "#{counts.count} are different size."
28
33
 
34
+ @min_lumin = min_lumin
35
+ @max_lumin = max_lumin
36
+
29
37
  @single_color = single_color
30
38
  @samples = samples
31
39
  @counts = counts
@@ -45,6 +53,8 @@ module Iroki
45
53
 
46
54
  col =
47
55
  Iroki::Color::GREEN.mix_with Iroki::Color::BLUE, rel_abund
56
+ # col =
57
+ # Iroki::Color::BLUE.mix_with Iroki::Color::GREEN, rel_abund
48
58
 
49
59
  col.luminosity = lumin
50
60
 
@@ -55,7 +65,8 @@ module Iroki
55
65
  def single_color_gradient_hex_codes
56
66
  @rel_abunds.zip(@lumins).map do |rel_abund, lumin|
57
67
  amt_of_orig_color =
58
- scale rel_abund, new_min=10, new_max=95
68
+ # scale rel_abund, new_min=10, new_max=95
69
+ scale rel_abund, new_min=@min_lumin, new_max=@max_lumin
59
70
 
60
71
  col =
61
72
  Iroki::Color::DARK_GREEN.lighten_by amt_of_orig_color
@@ -21,12 +21,20 @@ module Iroki
21
21
  class TwoGroupGradient < Gradient
22
22
  attr_accessor :g1_counts, :g2_counts, :g1_rabunds, :g2_rabunds
23
23
 
24
- def initialize samples, g1_counts, g2_counts
24
+ def initialize samples,
25
+ g1_counts,
26
+ g2_counts,
27
+ min_lumin,
28
+ max_lumin
29
+
25
30
  assert(samples.count == g1_counts.count &&
26
31
  g1_counts.count == g2_counts.count,
27
32
  "Samples and counts are different lengths. " +
28
33
  "Check your biom file.")
29
34
 
35
+ @min_lumin = min_lumin
36
+ @max_lumin = max_lumin
37
+
30
38
  @samples = samples
31
39
  @g1_counts = g1_counts
32
40
  @g2_counts = g2_counts
@@ -37,9 +45,17 @@ module Iroki
37
45
 
38
46
  def percent_of_group1_color ra1, ra2
39
47
  if ra1 > ra2
40
- 1 - scale(ra2 / ra1, new_min=0.0, new_max=0.5, old_min=0.0, old_max=1.0)
48
+ 1 - scale(ra2 / ra1,
49
+ new_min=0.0,
50
+ new_max=0.5,
51
+ old_min=0.0,
52
+ old_max=1.0)
41
53
  elsif ra1 < ra2
42
- scale(ra1 / ra2, new_min=0.0, new_max=0.5, old_min=0.0, old_max=1.0)
54
+ scale(ra1 / ra2,
55
+ new_min=0.0,
56
+ new_max=0.5,
57
+ old_min=0.0,
58
+ old_max=1.0)
43
59
  else
44
60
  0.5
45
61
  end
@@ -51,9 +67,17 @@ module Iroki
51
67
 
52
68
  def lumin_level ra1, ra2
53
69
  if ra1 > ra2
54
- scale_reverse ra1, new_min=50, new_max=90, old_min=0.0, old_max=1.0
70
+ scale_reverse ra1,
71
+ new_min=@min_lumin,
72
+ new_max=@max_lumin,
73
+ old_min=0.0,
74
+ old_max=1.0
55
75
  else
56
- scale_reverse ra2, new_min=50, new_max=90, old_min=0.0, old_max=1.0
76
+ scale_reverse ra2,
77
+ new_min=@min_lumin,
78
+ new_max=@max_lumin,
79
+ old_min=0.0,
80
+ old_max=1.0
57
81
  end
58
82
  end
59
83
 
@@ -184,7 +184,9 @@ module Iroki
184
184
  display_auto_color_options: nil,
185
185
  newick_f: nil,
186
186
  out_f: nil,
187
- default_color: "black")
187
+ default_color: "black",
188
+ min_lumin: 35,
189
+ max_lumin: 70)
188
190
 
189
191
  args = method(__method__).parameters.map { |arg| arg[1] }
190
192
  AbortIf::logger.info "Args " + args.map { |arg| "#{arg} = #{eval(arg.to_s).inspect}" }.join(', ')
@@ -287,11 +289,19 @@ module Iroki
287
289
  samples, counts, is_single_group = Biom.open(biom_f, "rt").parse
288
290
 
289
291
  if is_single_group
290
- biom_patterns = SingleGroupGradient.new(samples, counts, single_color).patterns
292
+ biom_patterns = SingleGroupGradient.new(samples,
293
+ counts,
294
+ single_color,
295
+ min_lumin,
296
+ max_lumin).patterns
291
297
  else
292
298
  g1_counts = counts.map(&:first)
293
299
  g2_counts = counts.map(&:last)
294
- biom_patterns = TwoGroupGradient.new(samples, g1_counts, g2_counts).patterns
300
+ biom_patterns = TwoGroupGradient.new(samples,
301
+ g1_counts,
302
+ g2_counts,
303
+ min_lumin,
304
+ max_lumin).patterns
295
305
  end
296
306
 
297
307
  # these patterns have the original name for the key, so change
@@ -326,11 +336,19 @@ module Iroki
326
336
  samples, counts, is_single_group = Biom.open(biom_f, "rt").parse
327
337
 
328
338
  if is_single_group
329
- patterns = SingleGroupGradient.new(samples, counts, single_color).patterns
339
+ patterns = SingleGroupGradient.new(samples,
340
+ counts,
341
+ single_color,
342
+ min_lumin,
343
+ max_lumin).patterns
330
344
  else
331
345
  g1_counts = counts.map(&:first)
332
346
  g2_counts = counts.map(&:last)
333
- patterns = TwoGroupGradient.new(samples, g1_counts, g2_counts).patterns
347
+ patterns = TwoGroupGradient.new(samples,
348
+ g1_counts,
349
+ g2_counts,
350
+ min_lumin,
351
+ max_lumin).patterns
334
352
  end
335
353
 
336
354
  # these patterns have the original name for the key, so change
@@ -18,7 +18,7 @@
18
18
 
19
19
  # Library metadata
20
20
  module Iroki
21
- VERSION = "0.0.31"
21
+ VERSION = "0.0.32"
22
22
  COPYRIGHT = "2015 - 2017 Ryan Moore"
23
23
  CONTACT = "moorer@udel.edu"
24
24
  WEBSITE = "https://github.com/mooreryan/iroki"
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: iroki
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.31
4
+ version: 0.0.32
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ryan Moore
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2017-03-16 00:00:00.000000000 Z
11
+ date: 2017-04-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler