iroki 0.0.10 → 0.0.11
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +1 -0
- data/README.md +6 -0
- data/assets/images/iroki_logo2.idraw +0 -0
- data/assets/images/iroki_logo2.png +0 -0
- data/assets/images/iroki_logo2.svg +70 -0
- data/exe/iroki +13 -3
- data/lib/iroki.rb +2 -1
- data/lib/iroki/biom.rb +11 -22
- data/lib/iroki/color/color.rb +53 -56
- data/lib/iroki/color/gradient.rb +18 -4
- data/lib/iroki/color/{single_sample_gradient.rb → single_group_gradient.rb} +5 -21
- data/lib/iroki/color/two_group_gradient.rb +81 -0
- data/lib/iroki/main/main.rb +9 -2
- data/lib/iroki/version.rb +1 -1
- metadata +7 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9cd2b03674248b38f06bd033f032732d7fecea1f
|
4
|
+
data.tar.gz: 3fde1b8f6245ad4d80bf161d4277fa456e357d97
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f0c670f88f3781a56dae69be7a8e5d995185148358f1d6ed3013741d8201647ef59362629379ab6da925344384789912dc920f0b8471b74f9b350c972f76f130
|
7
|
+
data.tar.gz: 5290570c30e36ea2af296a6c0cfb44bde9baed4dd28b50b468ba7b66e81096fbe150a8eb95458b9c438b9de6a68b661906e41e8ded237d1fb24b97d5da9d0fbb
|
data/.gitignore
CHANGED
data/README.md
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
[![Iroki](https://github.com/mooreryan/iroki/blob/master/assets/images/iroki_logo2.png)](https://github.com/mooreryan/iroki/blob/master/assets/images/iroki_logo2.png)
|
2
|
+
|
1
3
|
# Iroki #
|
2
4
|
|
3
5
|
[![Gem Version](https://badge.fury.io/rb/iroki.svg)](https://badge.fury.io/rb/iroki) [![Build Status](https://travis-ci.org/mooreryan/iroki.svg?branch=master)](https://travis-ci.org/mooreryan/iroki) [![Coverage Status](https://coveralls.io/repos/github/mooreryan/iroki/badge.svg?branch=master)](https://coveralls.io/github/mooreryan/iroki?branch=master)
|
@@ -117,3 +119,7 @@ Add `reorder_nodes` script.
|
|
117
119
|
### 0.0.10 ###
|
118
120
|
|
119
121
|
- Fix Jess's bug
|
122
|
+
|
123
|
+
### 0.0.11 ###
|
124
|
+
|
125
|
+
- Add two color, two group color gradients from biom files
|
Binary file
|
Binary file
|
@@ -0,0 +1,70 @@
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
2
|
+
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
|
3
|
+
<svg version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0" y="0" width="1503" height="1030" viewBox="0, 0, 1503, 1030">
|
4
|
+
<defs>
|
5
|
+
<clipPath id="Clip_1">
|
6
|
+
<path d="M1503,1030 L1503,0 L0,0 L0,1030 L1503,1030 z"/>
|
7
|
+
</clipPath>
|
8
|
+
</defs>
|
9
|
+
<g id="Layer_1">
|
10
|
+
<g clip-path="url(#Clip_1)">
|
11
|
+
<path d="M0,0 L1503,0 L1503,1030 L0,1030 L0,0 z" fill="#FFFFFF"/>
|
12
|
+
<path d="M628.34,877.53 L604.41,862.97" fill-opacity="0" stroke="#000000" stroke-width="9"/>
|
13
|
+
<path d="M563.57,824.83 L547.41,801.95" fill-opacity="0" stroke="#000000" stroke-width="9"/>
|
14
|
+
<path d="M209.45,695.32 L517.54,695.32" fill-opacity="0" stroke="#F9B400" stroke-width="9"/>
|
15
|
+
<path d="M604.41,527.67 L628.34,513.12" fill-opacity="0" stroke="#000000" stroke-width="9"/>
|
16
|
+
<path d="M457.21,976.02 L547.41,801.95" fill-opacity="0" stroke="#79572D" stroke-width="9"/>
|
17
|
+
<path d="M249.76,798.83 L519.45,723.27" fill-opacity="0" stroke="#C25B7F" stroke-width="9"/>
|
18
|
+
<path d="M266.89,327 L534.53,613.57" fill-opacity="0" stroke="#007CB4" stroke-width="9"/>
|
19
|
+
<path d="M472.39,127.06 L563.57,565.82" fill-opacity="0" stroke="#009769" stroke-width="9"/>
|
20
|
+
<path d="M195.82,576.7 L519.45,667.38" fill-opacity="0" stroke="#7464A8" stroke-width="9"/>
|
21
|
+
<path d="M1319.18,406.69 L708.74,490.59" fill-opacity="0" stroke="#9A6DA3" stroke-width="9"/>
|
22
|
+
<path d="M935.22,78.37 L628.34,513.12" fill-opacity="0" stroke="#CC1E41" stroke-width="9"/>
|
23
|
+
<path d="M706.69,907.4 L681,896.24" fill-opacity="0" stroke="#000000" stroke-width="9"/>
|
24
|
+
<path d="M654.03,888.69 L628.34,877.53" fill-opacity="0" stroke="#000000" stroke-width="9"/>
|
25
|
+
<path d="M641.93,968.54 L604.41,862.97" fill-opacity="0" stroke="#F6CC00" stroke-width="9"/>
|
26
|
+
<path d="M615.17,70.32 L582.68,545.35" fill-opacity="0" stroke="#969694" stroke-width="9"/>
|
27
|
+
<path d="M697.48,924.04 L654.03,888.69" fill-opacity="0" stroke="#000000" stroke-width="9"/>
|
28
|
+
<path d="M525.15,639.96 L534.53,613.57" fill-opacity="0" stroke="#000000" stroke-width="9"/>
|
29
|
+
<path d="M534.53,613.57 L547.41,588.7" fill-opacity="0" stroke="#000000" stroke-width="9"/>
|
30
|
+
<path d="M519.45,667.38 L525.15,639.96" fill-opacity="0" stroke="#000000" stroke-width="9"/>
|
31
|
+
<path d="M547.41,588.7 L563.57,565.82" fill-opacity="0" stroke="#000000" stroke-width="9"/>
|
32
|
+
<path d="M525.15,750.69 L519.45,723.27" fill-opacity="0" stroke="#000000" stroke-width="9"/>
|
33
|
+
<path d="M681,494.41 L708.74,490.59" fill-opacity="0" stroke="#000000" stroke-width="9"/>
|
34
|
+
<path d="M354.13,215.68 L547.41,588.7" fill-opacity="0" stroke="#ECA3BA" stroke-width="9"/>
|
35
|
+
<path d="M563.57,565.82 L582.68,545.35" fill-opacity="0" stroke="#000000" stroke-width="9"/>
|
36
|
+
<path d="M534.53,777.08 L525.15,750.69" fill-opacity="0" stroke="#000000" stroke-width="9"/>
|
37
|
+
<path d="M1088.55,148.45 L654.03,501.96" fill-opacity="0" stroke="#B0D4F4" stroke-width="9"/>
|
38
|
+
<path d="M708.74,900.06 L681,896.24" fill-opacity="0" stroke="#000000" stroke-width="9"/>
|
39
|
+
<path d="M582.68,845.3 L563.57,824.83" fill-opacity="0" stroke="#000000" stroke-width="9"/>
|
40
|
+
<path d="M547.41,801.95 L534.53,777.08" fill-opacity="0" stroke="#000000" stroke-width="9"/>
|
41
|
+
<path d="M604.41,862.97 L582.68,845.3" fill-opacity="0" stroke="#000000" stroke-width="9"/>
|
42
|
+
<path d="M628.34,513.12 L654.03,501.96" fill-opacity="0" stroke="#000000" stroke-width="9"/>
|
43
|
+
<path d="M654.03,501.96 L681,494.41" fill-opacity="0" stroke="#000000" stroke-width="9"/>
|
44
|
+
<path d="M517.54,695.32 L519.45,667.38" fill-opacity="0" stroke="#000000" stroke-width="9"/>
|
45
|
+
<path d="M582.68,545.35 L604.41,527.67" fill-opacity="0" stroke="#000000" stroke-width="9"/>
|
46
|
+
<path d="M676.79,946.17 L628.34,877.53" fill-opacity="0" stroke="#000000" stroke-width="9"/>
|
47
|
+
<path d="M381.59,940.83 L534.53,777.08" fill-opacity="0" stroke="#9DBF00" stroke-width="9"/>
|
48
|
+
<path d="M214.05,450.78 L525.15,639.96" fill-opacity="0" stroke="#FCA68B" stroke-width="9"/>
|
49
|
+
<path d="M529.37,989.36 L563.57,824.83" fill-opacity="0" stroke="#EA6E2C" stroke-width="9"/>
|
50
|
+
<path d="M592.24,985.01 L582.68,845.3" fill-opacity="0" stroke="#384D32" stroke-width="9"/>
|
51
|
+
<path d="M519.45,723.27 L517.54,695.32" fill-opacity="0" stroke="#000000" stroke-width="9"/>
|
52
|
+
<path d="M1220.47,260.08 L681,494.41" fill-opacity="0" stroke="#F79700" stroke-width="9"/>
|
53
|
+
<path d="M681,896.24 L654.03,888.69" fill-opacity="0" stroke="#000000" stroke-width="9"/>
|
54
|
+
<path d="M773.24,52.64 L604.41,527.67" fill-opacity="0" stroke="#CDBE92" stroke-width="9"/>
|
55
|
+
<path d="M309.77,881.66 L525.15,750.69" fill-opacity="0" stroke="#9B3E1D" stroke-width="9"/>
|
56
|
+
</g>
|
57
|
+
</g>
|
58
|
+
<g id="since_2015">
|
59
|
+
<g>
|
60
|
+
<text transform="matrix(1, 0, -0, 1, 709, 732.145)">
|
61
|
+
<tspan x="-54.78" y="-5.5" font-family="HelveticaNeue-Thin" font-size="15" fill="#000000">Phylogenetic Tree </tspan>
|
62
|
+
<tspan x="-34.912" y="12.5" font-family="HelveticaNeue-Thin" font-size="15" fill="#000000">Customizer</tspan>
|
63
|
+
</text>
|
64
|
+
<path d="M634,703 L784,703" fill-opacity="0" stroke="#000000" stroke-width="1.5"/>
|
65
|
+
<text transform="matrix(1, 0, 0, 1, 709, 672.5)">
|
66
|
+
<tspan x="-35.52" y="16.5" font-family="HelveticaNeue-UltraLight" font-size="48" fill="#000000">Iroki</tspan>
|
67
|
+
</text>
|
68
|
+
</g>
|
69
|
+
</g>
|
70
|
+
</svg>
|
data/exe/iroki
CHANGED
@@ -44,14 +44,22 @@ opts = Trollop.options do
|
|
44
44
|
opt(:exact,
|
45
45
|
"Exact pattern matching")
|
46
46
|
|
47
|
-
opt(:remove_bootstraps_below,
|
48
|
-
|
49
|
-
|
47
|
+
# opt(:remove_bootstraps_below,
|
48
|
+
# "Remove bootstrap values below given value",
|
49
|
+
# type: :float)
|
50
50
|
|
51
51
|
opt(:color_map,
|
52
52
|
"File with color mappings",
|
53
53
|
type: :string)
|
54
54
|
|
55
|
+
opt(:biom,
|
56
|
+
"Biom file to make color gradient",
|
57
|
+
type: :string)
|
58
|
+
|
59
|
+
opt(:single_color,
|
60
|
+
"Use single color gradient for single group biom files",
|
61
|
+
type: :string)
|
62
|
+
|
55
63
|
opt(:name_map,
|
56
64
|
"File with name mappings",
|
57
65
|
type: :string)
|
@@ -78,6 +86,8 @@ Iroki::Main.main(
|
|
78
86
|
exact: opts[:exact],
|
79
87
|
remove_bootstraps_below: opts[:remove_bootstraps_below],
|
80
88
|
color_map_f: opts[:color_map],
|
89
|
+
biom_f: opts[:biom],
|
90
|
+
single_color: opts[:single_color],
|
81
91
|
name_map_f: opts[:name_map],
|
82
92
|
auto_color: opts[:auto_color],
|
83
93
|
display_auto_color_options: opts[:display_auto_color_options],
|
data/lib/iroki.rb
CHANGED
@@ -25,7 +25,8 @@ require "iroki/const/const"
|
|
25
25
|
|
26
26
|
require "iroki/color/color"
|
27
27
|
require "iroki/color/gradient"
|
28
|
-
require "iroki/color/
|
28
|
+
require "iroki/color/single_group_gradient"
|
29
|
+
require "iroki/color/two_group_gradient"
|
29
30
|
require "iroki/color/palette/palette"
|
30
31
|
|
31
32
|
require "iroki/core_ext/hash/hash"
|
data/lib/iroki/biom.rb
CHANGED
@@ -18,39 +18,28 @@
|
|
18
18
|
|
19
19
|
module Iroki
|
20
20
|
class Biom < File
|
21
|
-
|
21
|
+
attr_accessor :single_group
|
22
|
+
|
23
|
+
def parse
|
22
24
|
samples = []
|
23
25
|
counts = []
|
24
26
|
|
25
27
|
self.each_line do |line|
|
26
28
|
unless line.start_with? "#"
|
27
|
-
sample,
|
29
|
+
sample, *the_counts = line.chomp.split "\t"
|
28
30
|
|
29
31
|
samples << sample
|
30
|
-
counts << count.to_f
|
31
|
-
end
|
32
|
-
end
|
33
|
-
|
34
|
-
[samples, counts]
|
35
|
-
end
|
36
|
-
|
37
32
|
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
unless line.start_with? "#"
|
45
|
-
sample, count1, count2 = line.chomp.split "\t"
|
46
|
-
|
47
|
-
samples << sample
|
48
|
-
counts_group1 << count1.to_f
|
49
|
-
counts_group2 << count2.to_f
|
33
|
+
if the_counts.length == 1
|
34
|
+
counts << the_counts.first.to_f
|
35
|
+
@single_group = true
|
36
|
+
else
|
37
|
+
counts << the_counts.map(&:to_f)
|
38
|
+
end
|
50
39
|
end
|
51
40
|
end
|
52
41
|
|
53
|
-
[samples,
|
42
|
+
[samples, counts, @single_group]
|
54
43
|
end
|
55
44
|
end
|
56
45
|
end
|
data/lib/iroki/color/color.rb
CHANGED
@@ -20,61 +20,6 @@ require "color"
|
|
20
20
|
|
21
21
|
module Iroki
|
22
22
|
module Color
|
23
|
-
GREEN_HUE = 1 / 3.0
|
24
|
-
BLUE_HUE = 2 / 3.0
|
25
|
-
WHITE_HUE = 1.0
|
26
|
-
FULLY_SATURATED = 1
|
27
|
-
PURE_COLOR = 0.5
|
28
|
-
PURE_LIGHT = 1.0
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
GREEN = Object::Color::HSL.from_fraction GREEN_HUE,
|
33
|
-
FULLY_SATURATED,
|
34
|
-
PURE_COLOR
|
35
|
-
|
36
|
-
BLUE = Object::Color::HSL.from_fraction BLUE_HUE,
|
37
|
-
FULLY_SATURATED,
|
38
|
-
PURE_COLOR
|
39
|
-
|
40
|
-
WHITE = Object::Color::HSL.from_fraction WHITE_HUE,
|
41
|
-
FULLY_SATURATED,
|
42
|
-
PURE_LIGHT
|
43
|
-
|
44
|
-
def self.get_tag str, palette=nil
|
45
|
-
if str.hex?
|
46
|
-
self.tag_from_hex str
|
47
|
-
else
|
48
|
-
self.tag_from_color str, palette
|
49
|
-
end
|
50
|
-
end
|
51
|
-
|
52
|
-
def self.tag_from_hex hex
|
53
|
-
assert hex.hex?, "'#{hex}' was not a valid hex code"
|
54
|
-
|
55
|
-
%Q{[&!color="#{hex.upcase}"]}
|
56
|
-
end
|
57
|
-
|
58
|
-
def self.tag_from_color color, palette=nil
|
59
|
-
col = color.downcase.strip
|
60
|
-
|
61
|
-
if palette
|
62
|
-
hash =
|
63
|
-
Hash[palette.keys.zip palette.map(&:last).map{|h| h[:hex]}]
|
64
|
-
colors = COLORS.merge hash
|
65
|
-
else
|
66
|
-
colors = COLORS
|
67
|
-
end
|
68
|
-
|
69
|
-
if colors.has_key? col
|
70
|
-
hex = colors[col]
|
71
|
-
else
|
72
|
-
# if passed color other than one defined, return black
|
73
|
-
hex = colors["black"]
|
74
|
-
end
|
75
|
-
|
76
|
-
%Q{[&!color="#{hex.upcase}"]}
|
77
|
-
end
|
78
23
|
|
79
24
|
COLORS = {
|
80
25
|
"white" => "#FFFFFF",
|
@@ -736,6 +681,58 @@ module Iroki
|
|
736
681
|
"yellowgreen" => "#9ACD32",
|
737
682
|
}
|
738
683
|
|
739
|
-
|
684
|
+
# TOP
|
685
|
+
|
686
|
+
GREEN_HUE = 1 / 3.0
|
687
|
+
BLUE_HUE = 2 / 3.0
|
688
|
+
WHITE_HUE = 1.0
|
689
|
+
FULLY_SATURATED = 1
|
690
|
+
PURE_COLOR = 0.5
|
691
|
+
PURE_LIGHT = 1.0
|
692
|
+
|
693
|
+
HSL = Object::Color::HSL
|
694
|
+
RGB = Object::Color::RGB
|
695
|
+
|
696
|
+
GREEN = HSL.from_fraction GREEN_HUE, FULLY_SATURATED, PURE_COLOR
|
697
|
+
BLUE = HSL.from_fraction BLUE_HUE, FULLY_SATURATED, PURE_COLOR
|
698
|
+
WHITE = HSL.from_fraction WHITE_HUE, FULLY_SATURATED, PURE_LIGHT
|
699
|
+
|
700
|
+
DARK_GREEN = RGB.by_hex(COLORS["darkgreen"])
|
701
|
+
GRAY = RGB.by_hex(COLORS["gray"])
|
702
|
+
|
703
|
+
def self.get_tag str, palette=nil
|
704
|
+
if str.hex?
|
705
|
+
self.tag_from_hex str
|
706
|
+
else
|
707
|
+
self.tag_from_color str, palette
|
708
|
+
end
|
709
|
+
end
|
710
|
+
|
711
|
+
def self.tag_from_hex hex
|
712
|
+
assert hex.hex?, "'#{hex}' was not a valid hex code"
|
713
|
+
|
714
|
+
%Q{[&!color="#{hex.upcase}"]}
|
715
|
+
end
|
716
|
+
|
717
|
+
def self.tag_from_color color, palette=nil
|
718
|
+
col = color.downcase.strip
|
719
|
+
|
720
|
+
if palette
|
721
|
+
hash =
|
722
|
+
Hash[palette.keys.zip palette.map(&:last).map{|h| h[:hex]}]
|
723
|
+
colors = COLORS.merge hash
|
724
|
+
else
|
725
|
+
colors = COLORS
|
726
|
+
end
|
727
|
+
|
728
|
+
if colors.has_key? col
|
729
|
+
hex = colors[col]
|
730
|
+
else
|
731
|
+
# if passed color other than one defined, return black
|
732
|
+
hex = colors["black"]
|
733
|
+
end
|
734
|
+
|
735
|
+
%Q{[&!color="#{hex.upcase}"]}
|
736
|
+
end
|
740
737
|
end
|
741
738
|
end
|
data/lib/iroki/color/gradient.rb
CHANGED
@@ -19,15 +19,15 @@
|
|
19
19
|
module Iroki
|
20
20
|
module Color
|
21
21
|
class Gradient
|
22
|
-
attr_accessor :samples, :color_hex_codes, :lumins
|
22
|
+
attr_accessor :samples, :color_hex_codes, :lumins, :single_color
|
23
23
|
|
24
|
-
# scales [
|
25
|
-
def
|
24
|
+
# 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
|
26
26
|
((((new_max - new_min) * (x - old_min.to_f)) / (old_max - old_min)) + new_min)
|
27
27
|
end
|
28
28
|
|
29
29
|
# scales [old_min, old_max] to [new_max, new_min]
|
30
|
-
def
|
30
|
+
def scale_reverse x, new_min=0.0, new_max=0.0, old_min=0.0, old_max=1.0
|
31
31
|
(new_max - ((((new_max - new_min) * (x - old_min.to_f)) / (old_max - old_min)) + new_min)) + new_min
|
32
32
|
end
|
33
33
|
|
@@ -40,6 +40,20 @@ module Iroki
|
|
40
40
|
|
41
41
|
hash
|
42
42
|
end
|
43
|
+
|
44
|
+
def counts_to_rabunds counts
|
45
|
+
max_count = counts.max.to_f
|
46
|
+
|
47
|
+
counts.map do |count|
|
48
|
+
count / max_count
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
def rabunds_to_lumins rabunds
|
53
|
+
rabunds.map do |count|
|
54
|
+
scale_reverse count, new_min=50, new_max=97
|
55
|
+
end
|
56
|
+
end
|
43
57
|
end
|
44
58
|
end
|
45
59
|
end
|
@@ -18,15 +18,15 @@
|
|
18
18
|
|
19
19
|
module Iroki
|
20
20
|
module Color
|
21
|
-
class
|
22
|
-
attr_accessor :counts, :rel_abunds
|
21
|
+
class SingleGroupGradient < Gradient
|
22
|
+
attr_accessor :counts, :rel_abunds
|
23
23
|
|
24
24
|
def initialize samples, counts, single_color=false
|
25
25
|
@single_color = single_color
|
26
26
|
@samples = samples
|
27
27
|
@counts = counts
|
28
|
-
@rel_abunds =
|
29
|
-
@lumins =
|
28
|
+
@rel_abunds = counts_to_rabunds counts
|
29
|
+
@lumins = rabunds_to_lumins @rel_abunds
|
30
30
|
|
31
31
|
if @single_color
|
32
32
|
@color_hex_codes = single_color_gradient_hex_codes
|
@@ -35,22 +35,6 @@ module Iroki
|
|
35
35
|
end
|
36
36
|
end
|
37
37
|
|
38
|
-
private
|
39
|
-
|
40
|
-
def counts_to_rel_abunds
|
41
|
-
max_count = @counts.max.to_f
|
42
|
-
|
43
|
-
@counts.map do |count|
|
44
|
-
count / max_count
|
45
|
-
end
|
46
|
-
end
|
47
|
-
|
48
|
-
def rel_abunds_to_lumins
|
49
|
-
@rel_abunds.map do |count|
|
50
|
-
Gradient.scale_reverse count, new_min=50, new_max=97
|
51
|
-
end
|
52
|
-
end
|
53
|
-
|
54
38
|
def two_color_gradient_hex_codes
|
55
39
|
@rel_abunds.map.with_index do |rel_abund, idx|
|
56
40
|
lumin = @lumins[idx]
|
@@ -67,7 +51,7 @@ module Iroki
|
|
67
51
|
def single_color_gradient_hex_codes
|
68
52
|
@rel_abunds.zip(@lumins).map do |rel_abund, lumin|
|
69
53
|
amt_of_orig_color =
|
70
|
-
|
54
|
+
scale rel_abund, new_min=10, new_max=95
|
71
55
|
|
72
56
|
col =
|
73
57
|
Iroki::Color::DARK_GREEN.lighten_by amt_of_orig_color
|
@@ -0,0 +1,81 @@
|
|
1
|
+
# Copyright 2016 Ryan Moore
|
2
|
+
# Contact: moorer@udel.edu
|
3
|
+
#
|
4
|
+
# This file is part of Iroki.
|
5
|
+
#
|
6
|
+
# Iroki is free software: you can redistribute it and/or modify it
|
7
|
+
# under the terms of the GNU General Public License as published by
|
8
|
+
# the Free Software Foundation, either version 3 of the License, or
|
9
|
+
# (at your option) any later version.
|
10
|
+
#
|
11
|
+
# Iroki is distributed in the hope that it will be useful, but
|
12
|
+
# WITHOUT ANY WARRANTY; without even the implied warranty of
|
13
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
14
|
+
# General Public License for more details.
|
15
|
+
#
|
16
|
+
# You should have received a copy of the GNU General Public License
|
17
|
+
# along with Iroki. If not, see <http://www.gnu.org/licenses/>.
|
18
|
+
|
19
|
+
module Iroki
|
20
|
+
module Color
|
21
|
+
class TwoGroupGradient < Gradient
|
22
|
+
attr_accessor :g1_counts, :g2_counts, :g1_rabunds, :g2_rabunds
|
23
|
+
|
24
|
+
def initialize samples, g1_counts, g2_counts
|
25
|
+
assert(samples.count == g1_counts.count &&
|
26
|
+
g1_counts.count == g2_counts.count,
|
27
|
+
"Samples and counts are different lengths. " +
|
28
|
+
"Check your biom file.")
|
29
|
+
|
30
|
+
@samples = samples
|
31
|
+
@g1_counts = g1_counts
|
32
|
+
@g2_counts = g2_counts
|
33
|
+
@g1_rabunds = counts_to_rabunds g1_counts
|
34
|
+
@g2_rabunds = counts_to_rabunds g2_counts
|
35
|
+
@color_hex_codes = calc_hex_codes @g1_rabunds, @g2_rabunds
|
36
|
+
end
|
37
|
+
|
38
|
+
def percent_of_group1_color ra1, ra2
|
39
|
+
if ra1 > ra2
|
40
|
+
1 - scale(ra2 / ra1, new_min=0.0, new_max=0.5, old_min=0.0, old_max=1.0)
|
41
|
+
elsif ra1 < ra2
|
42
|
+
scale(ra1 / ra2, new_min=0.0, new_max=0.5, old_min=0.0, old_max=1.0)
|
43
|
+
else
|
44
|
+
0.5
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
def mix_percent ra1, ra2
|
49
|
+
1 - percent_of_group1_color(ra1, ra2)
|
50
|
+
end
|
51
|
+
|
52
|
+
def lumin_level ra1, ra2
|
53
|
+
if ra1 > ra2
|
54
|
+
scale_reverse ra1, new_min=50, new_max=90, old_min=0.0, old_max=1.0
|
55
|
+
else
|
56
|
+
scale_reverse ra2, new_min=50, new_max=90, old_min=0.0, old_max=1.0
|
57
|
+
end
|
58
|
+
end
|
59
|
+
|
60
|
+
def hex_code ra1, ra2
|
61
|
+
perc = mix_percent ra1, ra2
|
62
|
+
|
63
|
+
col = Iroki::Color::GREEN.mix_with Iroki::Color::BLUE, perc
|
64
|
+
|
65
|
+
col.luminosity = lumin_level ra1, ra2
|
66
|
+
|
67
|
+
col.html
|
68
|
+
end
|
69
|
+
|
70
|
+
def calc_hex_codes g1_rabunds, g2_rabunds
|
71
|
+
g1_rabunds.zip(g2_rabunds).map do |ra1, ra2|
|
72
|
+
if ra1.zero? && ra2.zero?
|
73
|
+
Iroki::Color::GRAY.html
|
74
|
+
else
|
75
|
+
hex_code ra1, ra2
|
76
|
+
end
|
77
|
+
end
|
78
|
+
end
|
79
|
+
end
|
80
|
+
end
|
81
|
+
end
|
data/lib/iroki/main/main.rb
CHANGED
@@ -77,8 +77,15 @@ module Iroki
|
|
77
77
|
exact_matching: exact,
|
78
78
|
auto_color: auto_color_hash
|
79
79
|
else
|
80
|
-
samples, counts = Biom.open(biom_f).
|
81
|
-
|
80
|
+
samples, counts, is_single_group = Biom.open(biom_f).parse
|
81
|
+
|
82
|
+
if is_single_group
|
83
|
+
patterns = SingleGroupGradient.new(samples, counts, single_color).patterns
|
84
|
+
else
|
85
|
+
g1_counts = counts.map(&:first)
|
86
|
+
g2_counts = counts.map(&:last)
|
87
|
+
patterns = TwoGroupGradient.new(samples, g1_counts, g2_counts).patterns
|
88
|
+
end
|
82
89
|
end
|
83
90
|
|
84
91
|
treeio = Bio::FlatFile.open(Bio::Newick, newick)
|
data/lib/iroki/version.rb
CHANGED
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.
|
4
|
+
version: 0.0.11
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ryan Moore
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-07-
|
11
|
+
date: 2016-07-29 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -185,6 +185,9 @@ files:
|
|
185
185
|
- Guardfile
|
186
186
|
- README.md
|
187
187
|
- Rakefile
|
188
|
+
- assets/images/iroki_logo2.idraw
|
189
|
+
- assets/images/iroki_logo2.png
|
190
|
+
- assets/images/iroki_logo2.svg
|
188
191
|
- bin/console
|
189
192
|
- bin/iroki_docker
|
190
193
|
- bin/setup
|
@@ -198,7 +201,8 @@ files:
|
|
198
201
|
- lib/iroki/color/color.rb
|
199
202
|
- lib/iroki/color/gradient.rb
|
200
203
|
- lib/iroki/color/palette/palette.rb
|
201
|
-
- lib/iroki/color/
|
204
|
+
- lib/iroki/color/single_group_gradient.rb
|
205
|
+
- lib/iroki/color/two_group_gradient.rb
|
202
206
|
- lib/iroki/const/const.rb
|
203
207
|
- lib/iroki/core_ext/file/file.rb
|
204
208
|
- lib/iroki/core_ext/hash/hash.rb
|