In [1]:
require 'nyaplot'
require 'bionya'
Out[1]:
Out[1]:
Out[1]:
true
In [2]:
arr = []
10.times do |i|
  arr.push({group: 'group' + i.to_s ,df: Nyaplot::DataFrame.new({axis: ['a', 'b', 'c'], val: [2, 3, 4]})})
end
df = Nyaplot::DataFrame.new(arr)
Out[2]:
groupdf
group0
axisval
a2
b3
c4
group1
axisval
a2
b3
c4
group2
axisval
a2
b3
c4
group3
axisval
a2
b3
c4
group4
axisval
a2
b3
c4
group5
axisval
a2
b3
c4
group6
axisval
a2
b3
c4
group7
axisval
a2
b3
c4
group8
axisval
a2
b3
c4
group9
axisval
a2
b3
c4
In [3]:
plot = Nyaplot::CircularPlot.new(df, :group, :df)
plot.to_json
Out[3]:
"{\"diagrams\":[],\"options\":{\"zoom\":true,\"width\":800,\"height\":800,\"axis_extra_options\":{\"group_by\":\"group\",\"color\":[\"#253494\"],\"inner_num\":0,\"outer_num\":1,\"df_id\":\"b342f92a-4cb7-44aa-8aa8-1105e96109ed\"}},\"axis_extra_options\":{\"group_by\":\"group\",\"color\":[\"#253494\"],\"inner_num\":0,\"outer_num\":1,\"df_id\":\"b342f92a-4cb7-44aa-8aa8-1105e96109ed\"},\"extension\":\"Bionya\"}"
In [4]:
plot.add(1, :arc, :axis, :val)
Out[4]:
#<Nyaplot::Diagram:0x3548c58 @properties={:type=>:arc, :options=>{:x=>:axis, :y=>:val, :range=>[0, 4], :layer=>1}, :data=>"b342f92a-4cb7-44aa-8aa8-1105e96109ed"}>
In [5]:
plot.show
Out[5]:
In [6]:
df = Nyaplot::DataFrame.from_csv('./data/circular/category.csv')
Out[6]:
namesize
chr1249250621
chr2243199373
chr3198022430
chr4191154276
chr5180915260
chr6171115067
chr7159138663
chr8146364022
chr9141213431
chr10135534747
chr11135006516
chr12133851895
chr13115169878
chr14107349540
chr15102531392
chr1690354753
......
chry59373566
In [7]:
df2 = Nyaplot::DataFrame.from_csv('./data/circular/hgmd.tsv', {col_sep: "\t"})
Out[7]:
gene_namestartendnum1num2
hs11825545571875545570.012.0
hs12232845282282845280.015.0
hs143804340488043400.01.0
hs120972111259721110.02.0
hs1165084566508450.021.0
hs12232844442282844440.01.0
hs112252955172529550.010.0
hs145797505507975050.03.0
hs12265553022315553020.09.0
hs120977000259770000.014.0
hs11825513371875513370.017.0
hs18030994130309940.01.0
hs155638075606380750.020.0
hs12232852002282852000.03.0
hs12232845992282845990.07.0
hs1072195439771954390.010.0
...............
hsX1532841921582841920.012.0
In [8]:
df4 = Nyaplot::DataFrame.from_csv('./data/circular/cosmic_plot1_final.csv')
Out[8]:
gene_namestartendnonecount
hs101022958361072958360.01.0
hs101266782211316782210.01.0
hs1012708745177087450.01.0
hs1014944426199444260.01.0
hs1026385314313853140.01.0
hs1050682263556822630.01.0
hs1052912943579129430.01.0
hs105541181105411810.01.0
hs1064927823699278230.01.0
hs1075238352802383520.02.0
hs108111457131114570.02.0
hs1090770295957702950.01.0
hs111081418741131418740.01.0
hs111174032351224032350.01.0
hs111183906851233906850.01.0
hs11452816561502816560.01.0
...............
hs977365639823656390.01.0
In [9]:
df3 = Nyaplot::DataFrame.from_csv('./data/circular/genes_hgmd.tsv', {col_sep: "\t"})
Out[9]:
gene_namestartendname
hs1182554557182555057RNASEL
hs1223284528223285028TLR5
hs14380434043804840MPL
hs12097211120972611PINK1
hs116508451651345CDK11A
hs1223284444223284944TLR5
hs11225295512253455TNFRSF1B
hs14579750545798005MUTYH
hs1226555302226555802PARP1
hs12097700020977500PINK1
hs1182551337182551837RNASEL
hs180309948031494PARK7
hs15563807555638575USP24
hs1223285200223285700TLR5
hs1223284599223285099TLR5
hs107219543972195939NODAL
............
hsX153284192153284692IRAK1
In [10]:
hash2 = {}
df3.each_row do |row|
  chr_name = "chr" + row[:gene_name].match(/hs(.+)/)[1]
  hash2[chr_name] ||= []
  hash2[chr_name].push({locale: row[:start], name: row[:name]})
end
""
Out[10]:
""
In [36]:
hash = {}
df2.each_row do |row|
  chr_name = "chr" + row[:gene_name].match(/hs(.+)/)[1]
  hash[chr_name] ||= []
  hash[chr_name].push({start: row[:start], val: row[:num2]})
end
Out[36]:
[{:gene_name=>"hs1", :start=>182554557, :end=>187554557, :num1=>0.0, :num2=>12.0}, {:gene_name=>"hs1", :start=>223284528, :end=>228284528, :num1=>0.0, :num2=>15.0}, {:gene_name=>"hs1", :start=>43804340, :end=>48804340, :num1=>0.0, :num2=>1.0}, {:gene_name=>"hs1", :start=>20972111, :end=>25972111, :num1=>0.0, :num2=>2.0}, {:gene_name=>"hs1", :start=>1650845, :end=>6650845, :num1=>0.0, :num2=>21.0}, {:gene_name=>"hs1", :start=>223284444, :end=>228284444, :num1=>0.0, :num2=>1.0}, {:gene_name=>"hs1", :start=>12252955, :end=>17252955, :num1=>0.0, :num2=>10.0}, {:gene_name=>"hs1", :start=>45797505, :end=>50797505, :num1=>0.0, :num2=>3.0}, {:gene_name=>"hs1", :start=>226555302, :end=>231555302, :num1=>0.0, :num2=>9.0}, {:gene_name=>"hs1", :start=>20977000, :end=>25977000, :num1=>0.0, :num2=>14.0}, {:gene_name=>"hs1", :start=>182551337, :end=>187551337, :num1=>0.0, :num2=>17.0}, {:gene_name=>"hs1", :start=>8030994, :end=>13030994, :num1=>0.0, :num2=>1.0}, {:gene_name=>"hs1", :start=>55638075, :end=>60638075, :num1=>0.0, :num2=>20.0}, {:gene_name=>"hs1", :start=>223285200, :end=>228285200, :num1=>0.0, :num2=>3.0}, {:gene_name=>"hs1", :start=>223284599, :end=>228284599, :num1=>0.0, :num2=>7.0}, {:gene_name=>"hs10", :start=>72195439, :end=>77195439, :num1=>0.0, :num2=>10.0}, {:gene_name=>"hs10", :start=>16919052, :end=>21919052, :num1=>0.0, :num2=>2.0}, {:gene_name=>"hs10", :start=>123310871, :end=>128310871, :num1=>0.0, :num2=>1.0}, {:gene_name=>"hs10", :start=>131506283, :end=>136506283, :num1=>0.0, :num2=>3.0}, {:gene_name=>"hs10", :start=>43620335, :end=>48620335, :num1=>0.0, :num2=>2.0}, {:gene_name=>"hs10", :start=>102295836, :end=>107295836, :num1=>0.0, :num2=>4.0}, {:gene_name=>"hs10", :start=>22839628, :end=>27839628, :num1=>0.0, :num2=>10.0}, {:gene_name=>"hs10", :start=>131565064, :end=>136565064, :num1=>0.0, :num2=>8.0}, {:gene_name=>"hs10", :start=>121086097, :end=>126086097, :num1=>0.0, :num2=>1.0}, {:gene_name=>"hs10", :start=>90762801, :end=>95762801, :num1=>0.0, :num2=>1.0}, {:gene_name=>"hs10", :start=>43610119, :end=>48610119, :num1=>0.0, :num2=>11.0}, {:gene_name=>"hs10", :start=>131565170, :end=>136565170, :num1=>0.0, :num2=>5.0}, {:gene_name=>"hs10", :start=>68040325, :end=>73040325, :num1=>0.0, :num2=>10.0}, {:gene_name=>"hs10", :start=>97174352, :end=>102174352, :num1=>0.0, :num2=>1.0}, {:gene_name=>"hs11", :start=>108175462, :end=>113175462, :num1=>0.0, :num2=>2.0}, {:gene_name=>"hs11", :start=>67353579, :end=>72353579, :num1=>0.0, :num2=>2.0}, {:gene_name=>"hs11", :start=>67250676, :end=>72250676, :num1=>0.0, :num2=>1.0}, {:gene_name=>"hs11", :start=>67202156, :end=>72202156, :num1=>0.0, :num2=>3.0}, {:gene_name=>"hs11", :start=>68201295, :end=>73201295, :num1=>0.0, :num2=>1.0}, {:gene_name=>"hs11", :start=>67352689, :end=>72352689, :num1=>0.0, :num2=>13.0}, {:gene_name=>"hs11", :start=>48146622, :end=>53146622, :num1=>0.0, :num2=>5.0}, {:gene_name=>"hs11", :start=>113270828, :end=>118270828, :num1=>0.0, :num2=>3.0}, {:gene_name=>"hs11", :start=>113270160, :end=>118270160, :num1=>0.0, :num2=>14.0}, {:gene_name=>"hs11", :start=>68174189, :end=>73174189, :num1=>0.0, :num2=>1.0}, {:gene_name=>"hs11", :start=>111635566, :end=>116635566, :num1=>0.0, :num2=>1.0}, {:gene_name=>"hs11", :start=>108160350, :end=>113160350, :num1=>0.0, :num2=>1.0}, {:gene_name=>"hs11", :start=>48145375, :end=>53145375, :num1=>0.0, :num2=>5.0}, {:gene_name=>"hs12", :start=>4479549, :end=>9479549, :num1=>0.0, :num2=>1.0}, {:gene_name=>"hs12", :start=>121712077, :end=>126712077, :num1=>0.0, :num2=>3.0}, {:gene_name=>"hs12", :start=>121592689, :end=>126592689, :num1=>0.0, :num2=>4.0}, {:gene_name=>"hs12", :start=>121622196, :end=>126622196, :num1=>0.0, :num2=>3.0}, {:gene_name=>"hs12", :start=>121432117, :end=>126432117, :num1=>0.0, :num2=>6.0}, {:gene_name=>"hs12", :start=>12871099, :end=>17871099, :num1=>0.0, :num2=>5.0}, {:gene_name=>"hs12", :start=>121615103, :end=>126615103, :num1=>0.0, :num2=>11.0}, {:gene_name=>"hs12", :start=>40702911, :end=>45702911, :num1=>0.0, :num2=>1.0}, {:gene_name=>"hs12", :start=>121622304, :end=>126622304, :num1=>0.0, :num2=>4.0}, {:gene_name=>"hs12", :start=>44180295, :end=>49180295, :num1=>0.0, :num2=>3.0}, {:gene_name=>"hs12", :start=>40713901, :end=>45713901, :num1=>0.0, :num2=>5.0}, {:gene_name=>"hs12", :start=>57865821, :end=>62865821, :num1=>0.0, :num2=>17.0}, {:gene_name=>"hs12", :start=>40657700, :end=>45657700, :num1=>0.0, :num2=>1.0}, {:gene_name=>"hs12", :start=>121435427, :end=>126435427, :num1=>0.0, :num2=>5.0}, {:gene_name=>"hs12", :start=>18435452, :end=>23435452, :num1=>0.0, :num2=>13.0}, {:gene_name=>"hs12", :start=>121416650, :end=>126416650, :num1=>0.0, :num2=>2.0}, {:gene_name=>"hs12", :start=>51208122, :end=>56208122, :num1=>0.0, :num2=>1.0}, {:gene_name=>"hs13", :start=>32914839, :end=>37914839, :num1=>0.0, :num2=>1.0}, {:gene_name=>"hs13", :start=>32906480, :end=>37906480, :num1=>0.0, :num2=>3.0}, {:gene_name=>"hs13", :start=>110818598, :end=>115818598, :num1=>0.0, :num2=>12.0}, {:gene_name=>"hs13", :start=>32911463, :end=>37911463, :num1=>0.0, :num2=>4.0}, {:gene_name=>"hs13", :start=>32907407, :end=>37907407, :num1=>0.0, :num2=>1.0}, {:gene_name=>"hs13", :start=>32906729, :end=>37906729, :num1=>0.0, :num2=>7.0}, {:gene_name=>"hs13", :start=>32907129, :end=>37907129, :num1=>0.0, :num2=>1.0}, {:gene_name=>"hs13", :start=>32953550, :end=>37953550, :num1=>0.0, :num2=>1.0}, {:gene_name=>"hs13", :start=>50050620, :end=>55050620, :num1=>0.0, :num2=>15.0}, {:gene_name=>"hs14", :start=>61924239, :end=>66924239, :num1=>0.0, :num2=>1.0}, {:gene_name=>"hs14", :start=>21790040, :end=>26790040, :num1=>0.0, :num2=>8.0}, {:gene_name=>"hs14", :start=>73673178, :end=>78673178, :num1=>0.0, :num2=>1.0}, {:gene_name=>"hs14", :start=>81422178, :end=>86422178, :num1=>0.0, :num2=>1.0}, {:gene_name=>"hs14", :start=>62207575, :end=>67207575, :num1=>0.0, :num2=>1.0}, {:gene_name=>"hs14", :start=>81609994, :end=>86609994, :num1=>0.0, :num2=>1.0}, {:gene_name=>"hs14", :start=>54417522, :end=>59417522, :num1=>0.0, :num2=>12.0}, {:gene_name=>"hs14", :start=>75514489, :end=>80514489, :num1=>0.0, :num2=>1.0}, {:gene_name=>"hs14", :start=>62207557, :end=>67207557, :num1=>0.0, :num2=>5.0}, {:gene_name=>"hs14", :start=>21792781, :end=>26792781, :num1=>0.0, :num2=>1.0}, {:gene_name=>"hs15", :start=>50878630, :end=>55878630, :num1=>0.0, :num2=>5.0}, {:gene_name=>"hs15", :start=>43767774, :end=>48767774, :num1=>0.0, :num2=>11.0}, {:gene_name=>"hs15", :start=>43724646, :end=>48724646, :num1=>0.0, :num2=>13.0}, {:gene_name=>"hs15", :start=>43762196, :end=>48762196, :num1=>0.0, :num2=>6.0}, {:gene_name=>"hs15", :start=>39882178, :end=>44882178, :num1=>0.0, :num2=>3.0}, {:gene_name=>"hs15", :start=>91326099, :end=>96326099, :num1=>0.0, :num2=>2.0}, {:gene_name=>"hs15", :start=>84706461, :end=>89706461, :num1=>0.0, :num2=>11.0}, {:gene_name=>"hs16", :start=>84209609, :end=>89209609, :num1=>0.0, :num2=>1.0}, {:gene_name=>"hs16", :start=>53682949, :end=>58682949, :num1=>0.0, :num2=>1.0}, {:gene_name=>"hs16", :start=>14028081, :end=>19028081, :num1=>0.0, :num2=>1.0}, {:gene_name=>"hs16", :start=>2096239, :end=>7096239, :num1=>0.0, :num2=>1.0}, {:gene_name=>"hs16", :start=>2161150, :end=>7161150, :num1=>0.0, :num2=>1.0}, {:gene_name=>"hs16", :start=>23641461, :end=>28641461, :num1=>0.0, :num2=>4.0}, {:gene_name=>"hs16", :start=>23634293, :end=>28634293, :num1=>0.0, :num2=>3.0}, {:gene_name=>"hs16", :start=>2133798, :end=>7133798, :num1=>0.0, :num2=>1.0}, {:gene_name=>"hs17", :start=>41223094, :end=>46223094, :num1=>0.0, :num2=>14.0}, {:gene_name=>"hs17", :start=>44061036, :end=>49061036, :num1=>0.0, :num2=>5.0}, {:gene_name=>"hs17", :start=>44061023, :end=>49061023, :num1=>0.0, :num2=>5.0}, {:gene_name=>"hs17", :start=>41245090, :end=>46245090, :num1=>0.0, :num2=>1.0}, {:gene_name=>"hs17", :start=>26096597, :end=>31096597, :num1=>0.0, :num2=>11.0}, {:gene_name=>"hs17", :start=>3632836, :end=>8632836, :num1=>0.0, :num2=>11.0}, {:gene_name=>"hs17", :start=>41244000, :end=>46244000, :num1=>0.0, :num2=>13.0}, {:gene_name=>"hs17", :start=>41244936, :end=>46244936, :num1=>0.0, :num2=>14.0}, {:gene_name=>"hs17", :start=>44067400, :end=>49067400, :num1=>0.0, :num2=>6.0}, {:gene_name=>"hs17", :start=>41246481, :end=>46246481, :num1=>0.0, :num2=>1.0}, {:gene_name=>"hs17", :start=>41245471, :end=>46245471, :num1=>0.0, :num2=>1.0}, {:gene_name=>"hs17", :start=>80042792, :end=>85042792, :num1=>0.0, :num2=>1.0}, {:gene_name=>"hs17", :start=>3775848, :end=>8775848, :num1=>0.0, :num2=>10.0}, {:gene_name=>"hs17", :start=>41244435, :end=>46244435, :num1=>0.0, :num2=>12.0}, {:gene_name=>"hs17", :start=>41246061, :end=>46246061, :num1=>0.0, :num2=>1.0}, {:gene_name=>"hs17", :start=>7915912, :end=>12915912, :num1=>0.0, :num2=>4.0}, {:gene_name=>"hs17", :start=>11651057, :end=>16651057, :num1=>0.0, :num2=>5.0}, {:gene_name=>"hs17", :start=>38457151, :end=>43457151, :num1=>0.0, :num2=>3.0}, {:gene_name=>"hs17", :start=>7917279, :end=>12917279, :num1=>0.0, :num2=>3.0}, {:gene_name=>"hs17", :start=>44061278, :end=>49061278, :num1=>0.0, :num2=>2.0}, {:gene_name=>"hs17", :start=>41222975, :end=>46222975, :num1=>0.0, :num2=>1.0}, {:gene_name=>"hs18", :start=>50432602, :end=>55432602, :num1=>0.0, :num2=>15.0}, {:gene_name=>"hs18", :start=>55373793, :end=>60373793, :num1=>0.0, :num2=>1.0}, {:gene_name=>"hs19", :start=>18180413, :end=>23180413, :num1=>0.0, :num2=>7.0}, {:gene_name=>"hs19", :start=>45854919, :end=>50854919, :num1=>0.0, :num2=>10.0}, {:gene_name=>"hs19", :start=>10475652, :end=>15475652, :num1=>0.0, :num2=>3.0}, {:gene_name=>"hs19", :start=>44057574, :end=>49057574, :num1=>0.0, :num2=>5.0}, {:gene_name=>"hs19", :start=>18180451, :end=>23180451, :num1=>0.0, :num2=>9.0}, {:gene_name=>"hs19", :start=>18188408, :end=>23188408, :num1=>0.0, :num2=>3.0}, {:gene_name=>"hs19", :start=>10475649, :end=>15475649, :num1=>0.0, :num2=>1.0}, {:gene_name=>"hs19", :start=>18186618, :end=>23186618, :num1=>0.0, :num2=>10.0}, {:gene_name=>"hs19", :start=>10395683, :end=>15395683, :num1=>0.0, :num2=>9.0}, {:gene_name=>"hs19", :start=>10394792, :end=>15394792, :num1=>0.0, :num2=>3.0}, {:gene_name=>"hs19", :start=>10463118, :end=>15463118, :num1=>0.0, :num2=>1.0}, {:gene_name=>"hs19", :start=>10469975, :end=>15469975, :num1=>0.0, :num2=>2.0}, {:gene_name=>"hs2", :start=>202074207, :end=>207074207, :num1=>0.0, :num2=>3.0}, {:gene_name=>"hs2", :start=>162904013, :end=>167904013, :num1=>0.0, :num2=>1.0}, {:gene_name=>"hs2", :start=>227660544, :end=>232660544, :num1=>0.0, :num2=>5.0}, {:gene_name=>"hs2", :start=>170129547, :end=>175129547, :num1=>0.0, :num2=>1.0}, {:gene_name=>"hs2", :start=>215645464, :end=>220645464, :num1=>0.0, :num2=>18.0}, {:gene_name=>"hs2", :start=>170354138, :end=>175354138, :num1=>0.0, :num2=>1.0}, {:gene_name=>"hs2", :start=>121748048, :end=>126748048, :num1=>0.0, :num2=>1.0}, {:gene_name=>"hs2", :start=>227915847, :end=>232915847, :num1=>0.0, :num2=>1.0}, {:gene_name=>"hs2", :start=>183703336, :end=>188703336, :num1=>0.0, :num2=>2.0}, {:gene_name=>"hs2", :start=>203420712, :end=>208420712, :num1=>0.0, :num2=>3.0}, {:gene_name=>"hs2", :start=>215632255, :end=>220632255, :num1=>0.0, :num2=>11.0}, {:gene_name=>"hs2", :start=>242371101, :end=>247371101, :num1=>0.0, :num2=>3.0}, {:gene_name=>"hs2", :start=>48025764, :end=>53025764, :num1=>0.0, :num2=>4.0}, {:gene_name=>"hs2", :start=>99172244, :end=>104172244, :num1=>0.0, :num2=>11.0}, {:gene_name=>"hs2", :start=>183699584, :end=>188699584, :num1=>0.0, :num2=>4.0}, {:gene_name=>"hs2", :start=>227661921, :end=>232661921, :num1=>0.0, :num2=>2.0}, {:gene_name=>"hs2", :start=>209108301, :end=>214108301, :num1=>0.0, :num2=>1.0}, {:gene_name=>"hs2", :start=>202074098, :end=>207074098, :num1=>0.0, :num2=>1.0}, {:gene_name=>"hs2", :start=>219747116, :end=>224747116, :num1=>0.0, :num2=>1.0}, {:gene_name=>"hs2", :start=>48033750, :end=>53033750, :num1=>0.0, :num2=>1.0}, {:gene_name=>"hs2", :start=>11359120, :end=>16359120, :num1=>0.0, :num2=>11.0}, {:gene_name=>"hs2", :start=>202149589, :end=>207149589, :num1=>0.0, :num2=>6.0}, {:gene_name=>"hs20", :start=>54961541, :end=>59961541, :num1=>0.0, :num2=>7.0}, {:gene_name=>"hs20", :start=>44639692, :end=>49639692, :num1=>0.0, :num2=>4.0}, {:gene_name=>"hs20", :start=>56138621, :end=>61138621, :num1=>0.0, :num2=>1.0}, {:gene_name=>"hs20", :start=>44642406, :end=>49642406, :num1=>0.0, :num2=>16.0}, {:gene_name=>"hs20", :start=>9547018, :end=>14547018, :num1=>0.0, :num2=>2.0}, {:gene_name=>"hs22", :start=>26231312, :end=>31231312, :num1=>0.0, :num2=>2.0}, {:gene_name=>"hs22", :start=>26159289, :end=>31159289, :num1=>0.0, :num2=>13.0}, {:gene_name=>"hs22", :start=>23627369, :end=>28627369, :num1=>0.0, :num2=>12.0}, {:gene_name=>"hs3", :start=>37053568, :end=>42053568, :num1=>0.0, :num2=>8.0}, {:gene_name=>"hs3", :start=>133371471, :end=>138371471, :num1=>0.0, :num2=>3.0}, {:gene_name=>"hs3", :start=>49721532, :end=>54721532, :num1=>0.0, :num2=>11.0}, {:gene_name=>"hs3", :start=>37089131, :end=>42089131, :num1=>0.0, :num2=>1.0}, {:gene_name=>"hs3", :start=>14199908, :end=>19199908, :num1=>0.0, :num2=>2.0}, {:gene_name=>"hs3", :start=>37089130, :end=>42089130, :num1=>0.0, :num2=>1.0}, {:gene_name=>"hs3", :start=>123457893, :end=>128457893, :num1=>0.0, :num2=>18.0}, {:gene_name=>"hs3", :start=>121507231, :end=>126507231, :num1=>0.0, :num2=>7.0}, {:gene_name=>"hs3", :start=>12393125, :end=>17393125, :num1=>0.0, :num2=>4.0}, {:gene_name=>"hs3", :start=>14199887, :end=>19199887, :num1=>0.0, :num2=>5.0}, {:gene_name=>"hs3", :start=>10089689, :end=>15089689, :num1=>0.0, :num2=>1.0}, {:gene_name=>"hs4", :start=>38799710, :end=>43799710, :num1=>0.0, :num2=>8.0}, {:gene_name=>"hs4", :start=>3039150, :end=>8039150, :num1=>0.0, :num2=>17.0}, {:gene_name=>"hs4", :start=>79786856, :end=>84786856, :num1=>0.0, :num2=>2.0}, {:gene_name=>"hs4", :start=>55979558, :end=>60979558, :num1=>0.0, :num2=>3.0}, {:gene_name=>"hs4", :start=>185553098, :end=>190553098, :num1=>0.0, :num2=>21.0}, {:gene_name=>"hs4", :start=>23815662, :end=>28815662, :num1=>0.0, :num2=>11.0}, {:gene_name=>"hs4", :start=>114278277, :end=>119278277, :num1=>0.0, :num2=>3.0}, {:gene_name=>"hs4", :start=>23814707, :end=>28814707, :num1=>0.0, :num2=>4.0}, {:gene_name=>"hs4", :start=>110902111, :end=>115902111, :num1=>0.0, :num2=>1.0}, {:gene_name=>"hs4", :start=>107845794, :end=>112845794, :num1=>0.0, :num2=>5.0}, {:gene_name=>"hs4", :start=>87690998, :end=>92690998, :num1=>0.0, :num2=>7.0}, {:gene_name=>"hs4", :start=>55593464, :end=>60593464, :num1=>0.0, :num2=>5.0}, {:gene_name=>"hs4", :start=>55129831, :end=>60129831, :num1=>0.0, :num2=>3.0}, {:gene_name=>"hs4", :start=>55972946, :end=>60972946, :num1=>0.0, :num2=>2.0}, {:gene_name=>"hs4", :start=>88989089, :end=>93989089, :num1=>0.0, :num2=>1.0}, {:gene_name=>"hs4", :start=>75673363, :end=>80673363, :num1=>0.0, :num2=>10.0}, {:gene_name=>"hs4", :start=>38800214, :end=>43800214, :num1=>0.0, :num2=>2.0}, {:gene_name=>"hs4", :start=>187004074, :end=>192004074, :num1=>0.0, :num2=>12.0}, {:gene_name=>"hs4", :start=>87692393, :end=>92692393, :num1=>0.0, :num2=>3.0}, {:gene_name=>"hs4", :start=>154626317, :end=>159626317, :num1=>0.0, :num2=>4.0}, {:gene_name=>"hs5", :start=>67588148, :end=>72588148, :num1=>0.0, :num2=>8.0}, {:gene_name=>"hs5", :start=>13794057, :end=>18794057, :num1=>0.0, :num2=>1.0}, {:gene_name=>"hs5", :start=>79361265, :end=>84361265, :num1=>0.0, :num2=>10.0}, {:gene_name=>"hs5", :start=>52358757, :end=>57358757, :num1=>0.0, :num2=>4.0}, {:gene_name=>"hs6", :start=>31860337, :end=>36860337, :num1=>0.0, :num2=>19.0}, {:gene_name=>"hs6", :start=>32188383, :end=>37188383, :num1=>0.0, :num2=>11.0}, {:gene_name=>"hs6", :start=>169635010, :end=>174635010, :num1=>0.0, :num2=>2.0}, {:gene_name=>"hs6", :start=>129635800, :end=>134635800, :num1=>0.0, :num2=>1.0}, {:gene_name=>"hs6", :start=>129722453, :end=>134722453, :num1=>0.0, :num2=>1.0}, {:gene_name=>"hs6", :start=>162622197, :end=>167622197, :num1=>0.0, :num2=>2.0}, {:gene_name=>"hs6", :start=>51893107, :end=>56893107, :num1=>0.0, :num2=>1.0}, {:gene_name=>"hs6", :start=>160448324, :end=>165448324, :num1=>0.0, :num2=>5.0}, {:gene_name=>"hs6", :start=>150346532, :end=>155346532, :num1=>0.0, :num2=>11.0}, {:gene_name=>"hs6", :start=>94120219, :end=>99120219, :num1=>0.0, :num2=>1.0}, {:gene_name=>"hs6", :start=>51612626, :end=>56612626, :num1=>0.0, :num2=>1.0}, {:gene_name=>"hs6", :start=>51612999, :end=>56612999, :num1=>0.0, :num2=>1.0}, {:gene_name=>"hs6", :start=>154414446, :end=>159414446, :num1=>0.0, :num2=>21.0}, {:gene_name=>"hs6", :start=>44198362, :end=>49198362, :num1=>0.0, :num2=>1.0}, {:gene_name=>"hs6", :start=>161807855, :end=>166807855, :num1=>0.0, :num2=>7.0}, {:gene_name=>"hs6", :start=>161781225, :end=>166781225, :num1=>0.0, :num2=>1.0}, {:gene_name=>"hs6", :start=>51524705, :end=>56524705, :num1=>0.0, :num2=>1.0}, {:gene_name=>"hs7", :start=>120979089, :end=>125979089, :num1=>0.0, :num2=>15.0}, {:gene_name=>"hs7", :start=>113518434, :end=>118518434, :num1=>0.0, :num2=>6.0}, {:gene_name=>"hs7", :start=>1976457, :end=>6976457, :num1=>0.0, :num2=>1.0}, {:gene_name=>"hs7", :start=>42007446, :end=>47007446, :num1=>0.0, :num2=>2.0}, {:gene_name=>"hs7", :start=>55229255, :end=>60229255, :num1=>0.0, :num2=>11.0}, {:gene_name=>"hs7", :start=>120969769, :end=>125969769, :num1=>0.0, :num2=>12.0}, {:gene_name=>"hs7", :start=>45932669, :end=>50932669, :num1=>0.0, :num2=>11.0}, {:gene_name=>"hs8", :start=>30921935, :end=>35921935, :num1=>0.0, :num2=>3.0}, {:gene_name=>"hs8", :start=>11405576, :end=>16405576, :num1=>0.0, :num2=>1.0}, {:gene_name=>"hs8", :start=>23058220, :end=>28058220, :num1=>0.0, :num2=>7.0}, {:gene_name=>"hs8", :start=>94768004, :end=>99768004, :num1=>0.0, :num2=>2.0}, {:gene_name=>"hs8", :start=>90990479, :end=>95990479, :num1=>0.0, :num2=>14.0}, {:gene_name=>"hs8", :start=>128750540, :end=>133750540, :num1=>0.0, :num2=>1.0}, {:gene_name=>"hs8", :start=>104337548, :end=>109337548, :num1=>0.0, :num2=>1.0}, {:gene_name=>"hs8", :start=>31024654, :end=>36024654, :num1=>0.0, :num2=>8.0}, {:gene_name=>"hs9", :start=>107579632, :end=>112579632, :num1=>0.0, :num2=>3.0}, {:gene_name=>"hs9", :start=>139266496, :end=>144266496, :num1=>0.0, :num2=>7.0}, {:gene_name=>"hs9", :start=>6984236, :end=>11984236, :num1=>0.0, :num2=>9.0}, {:gene_name=>"hs9", :start=>14722616, :end=>19722616, :num1=>0.0, :num2=>5.0}, {:gene_name=>"hs9", :start=>107586753, :end=>112586753, :num1=>0.0, :num2=>3.0}, {:gene_name=>"hs9", :start=>107578620, :end=>112578620, :num1=>0.0, :num2=>1.0}, {:gene_name=>"hs9", :start=>135786904, :end=>140786904, :num1=>0.0, :num2=>5.0}, {:gene_name=>"hs9", :start=>14722477, :end=>19722477, :num1=>0.0, :num2=>13.0}, {:gene_name=>"hs9", :start=>107586800, :end=>112586800, :num1=>0.0, :num2=>1.0}, {:gene_name=>"hsX", :start=>153278829, :end=>158278829, :num1=>0.0, :num2=>5.0}, {:gene_name=>"hsX", :start=>153284192, :end=>158284192, :num1=>0.0, :num2=>12.0}]
In [12]:
hash4 = {}
df4.each_row do |row|
  chr_name = "chr" + row[:gene_name].match(/hs(.+)/)[1]
  hash4[chr_name] ||= []
  hash4[chr_name].push({start: row[:start], val: row[:count]})
end
Out[12]:
[{:gene_name=>"hs10", :start=>102295836, :end=>107295836, :none=>0.0, :count=>1.0}, {:gene_name=>"hs10", :start=>126678221, :end=>131678221, :none=>0.0, :count=>1.0}, {:gene_name=>"hs10", :start=>12708745, :end=>17708745, :none=>0.0, :count=>1.0}, {:gene_name=>"hs10", :start=>14944426, :end=>19944426, :none=>0.0, :count=>1.0}, {:gene_name=>"hs10", :start=>26385314, :end=>31385314, :none=>0.0, :count=>1.0}, {:gene_name=>"hs10", :start=>50682263, :end=>55682263, :none=>0.0, :count=>1.0}, {:gene_name=>"hs10", :start=>52912943, :end=>57912943, :none=>0.0, :count=>1.0}, {:gene_name=>"hs10", :start=>5541181, :end=>10541181, :none=>0.0, :count=>1.0}, {:gene_name=>"hs10", :start=>64927823, :end=>69927823, :none=>0.0, :count=>1.0}, {:gene_name=>"hs10", :start=>75238352, :end=>80238352, :none=>0.0, :count=>2.0}, {:gene_name=>"hs10", :start=>8111457, :end=>13111457, :none=>0.0, :count=>2.0}, {:gene_name=>"hs10", :start=>90770295, :end=>95770295, :none=>0.0, :count=>1.0}, {:gene_name=>"hs11", :start=>108141874, :end=>113141874, :none=>0.0, :count=>1.0}, {:gene_name=>"hs11", :start=>117403235, :end=>122403235, :none=>0.0, :count=>1.0}, {:gene_name=>"hs11", :start=>118390685, :end=>123390685, :none=>0.0, :count=>1.0}, {:gene_name=>"hs1", :start=>145281656, :end=>150281656, :none=>0.0, :count=>1.0}, {:gene_name=>"hs11", :start=>48145375, :end=>53145375, :none=>0.0, :count=>1.0}, {:gene_name=>"hs1", :start=>156756577, :end=>161756577, :none=>0.0, :count=>2.0}, {:gene_name=>"hs11", :start=>64694297, :end=>69694297, :none=>0.0, :count=>1.0}, {:gene_name=>"hs1", :start=>172628574, :end=>177628574, :none=>0.0, :count=>1.0}, {:gene_name=>"hs1", :start=>174976282, :end=>179976282, :none=>0.0, :count=>1.0}, {:gene_name=>"hs1", :start=>176050418, :end=>181050418, :none=>0.0, :count=>1.0}, {:gene_name=>"hs1", :start=>202718090, :end=>207718090, :none=>0.0, :count=>1.0}, {:gene_name=>"hs1", :start=>206669465, :end=>211669465, :none=>0.0, :count=>1.0}, {:gene_name=>"hs12", :start=>104341410, :end=>109341410, :none=>0.0, :count=>1.0}, {:gene_name=>"hs12", :start=>115115428, :end=>120115428, :none=>0.0, :count=>1.0}, {:gene_name=>"hs12", :start=>121416650, :end=>126416650, :none=>0.0, :count=>2.0}, {:gene_name=>"hs12", :start=>121437143, :end=>126437143, :none=>0.0, :count=>1.0}, {:gene_name=>"hs12", :start=>122763691, :end=>127763691, :none=>0.0, :count=>1.0}, {:gene_name=>"hs12", :start=>130833931, :end=>135833931, :none=>0.0, :count=>1.0}, {:gene_name=>"hs1", :start=>228468458, :end=>233468458, :none=>0.0, :count=>1.0}, {:gene_name=>"hs1", :start=>228486404, :end=>233486404, :none=>0.0, :count=>1.0}, {:gene_name=>"hs1", :start=>228525008, :end=>233525008, :none=>0.0, :count=>1.0}, {:gene_name=>"hs1", :start=>228559994, :end=>233559994, :none=>0.0, :count=>1.0}, {:gene_name=>"hs12", :start=>40716270, :end=>45716270, :none=>0.0, :count=>1.0}, {:gene_name=>"hs1", :start=>242035438, :end=>247035438, :none=>0.0, :count=>1.0}, {:gene_name=>"hs12", :start=>57910758, :end=>62910758, :none=>0.0, :count=>2.0}, {:gene_name=>"hs12", :start=>57910759, :end=>62910759, :none=>0.0, :count=>1.0}, {:gene_name=>"hs1", :start=>27107092, :end=>32107092, :none=>0.0, :count=>1.0}, {:gene_name=>"hs13", :start=>111156500, :end=>116156500, :none=>0.0, :count=>1.0}, {:gene_name=>"hs13", :start=>114762162, :end=>119762162, :none=>0.0, :count=>1.0}, {:gene_name=>"hs13", :start=>32906729, :end=>37906729, :none=>0.0, :count=>1.0}, {:gene_name=>"hs13", :start=>42733400, :end=>47733400, :none=>0.0, :count=>2.0}, {:gene_name=>"hs13", :start=>48953730, :end=>53953730, :none=>0.0, :count=>1.0}, {:gene_name=>"hs13", :start=>48955383, :end=>53955383, :none=>0.0, :count=>1.0}, {:gene_name=>"hs13", :start=>52649961, :end=>57649961, :none=>0.0, :count=>1.0}, {:gene_name=>"hs1", :start=>36807481, :end=>41807481, :none=>0.0, :count=>2.0}, {:gene_name=>"hs1", :start=>38173986, :end=>43173986, :none=>0.0, :count=>1.0}, {:gene_name=>"hs1", :start=>38186189, :end=>43186189, :none=>0.0, :count=>1.0}, {:gene_name=>"hs14", :start=>21861692, :end=>26861692, :none=>0.0, :count=>1.0}, {:gene_name=>"hs14", :start=>35182459, :end=>40182459, :none=>0.0, :count=>1.0}, {:gene_name=>"hs1", :start=>44086156, :end=>49086156, :none=>0.0, :count=>1.0}, {:gene_name=>"hs1", :start=>44154632, :end=>49154632, :none=>0.0, :count=>1.0}, {:gene_name=>"hs14", :start=>50901768, :end=>55901768, :none=>0.0, :count=>1.0}, {:gene_name=>"hs14", :start=>61952245, :end=>66952245, :none=>0.0, :count=>1.0}, {:gene_name=>"hs15", :start=>55841196, :end=>60841196, :none=>0.0, :count=>1.0}, {:gene_name=>"hs15", :start=>84651026, :end=>89651026, :none=>0.0, :count=>2.0}, {:gene_name=>"hs16", :start=>2096235, :end=>7096235, :none=>0.0, :count=>1.0}, {:gene_name=>"hs16", :start=>29998970, :end=>34998970, :none=>0.0, :count=>1.0}, {:gene_name=>"hs16", :start=>3827658, :end=>8827658, :none=>0.0, :count=>1.0}, {:gene_name=>"hs16", :start=>53495699, :end=>58495699, :none=>0.0, :count=>2.0}, {:gene_name=>"hs16", :start=>68225270, :end=>73225270, :none=>0.0, :count=>1.0}, {:gene_name=>"hs16", :start=>84203612, :end=>89203612, :none=>0.0, :count=>1.0}, {:gene_name=>"hs16", :start=>84209864, :end=>89209864, :none=>0.0, :count=>1.0}, {:gene_name=>"hs17", :start=>19744860, :end=>24744860, :none=>0.0, :count=>1.0}, {:gene_name=>"hs17", :start=>3657171, :end=>8657171, :none=>0.0, :count=>1.0}, {:gene_name=>"hs17", :start=>41244000, :end=>46244000, :none=>0.0, :count=>1.0}, {:gene_name=>"hs17", :start=>41244936, :end=>46244936, :none=>0.0, :count=>1.0}, {:gene_name=>"hs17", :start=>42458283, :end=>47458283, :none=>0.0, :count=>1.0}, {:gene_name=>"hs17", :start=>45214519, :end=>50214519, :none=>0.0, :count=>1.0}, {:gene_name=>"hs17", :start=>45216149, :end=>50216149, :none=>0.0, :count=>1.0}, {:gene_name=>"hs17", :start=>45219364, :end=>50219364, :none=>0.0, :count=>1.0}, {:gene_name=>"hs17", :start=>45221286, :end=>50221286, :none=>0.0, :count=>1.0}, {:gene_name=>"hs17", :start=>45234726, :end=>50234726, :none=>0.0, :count=>1.0}, {:gene_name=>"hs17", :start=>62551963, :end=>67551963, :none=>0.0, :count=>1.0}, {:gene_name=>"hs17", :start=>62602763, :end=>67602763, :none=>0.0, :count=>1.0}, {:gene_name=>"hs17", :start=>7577570, :end=>12577570, :none=>0.0, :count=>1.0}, {:gene_name=>"hs17", :start=>78272227, :end=>83272227, :none=>0.0, :count=>1.0}, {:gene_name=>"hs18", :start=>77246406, :end=>82246406, :none=>0.0, :count=>1.0}, {:gene_name=>"hs19", :start=>46823750, :end=>51823750, :none=>0.0, :count=>1.0}, {:gene_name=>"hs20", :start=>25262748, :end=>30262748, :none=>0.0, :count=>1.0}, {:gene_name=>"hs20", :start=>50048730, :end=>55048730, :none=>0.0, :count=>1.0}, {:gene_name=>"hs20", :start=>56138228, :end=>61138228, :none=>0.0, :count=>1.0}, {:gene_name=>"hs20", :start=>5935298, :end=>10935298, :none=>0.0, :count=>1.0}, {:gene_name=>"hs2", :start=>102782726, :end=>107782726, :none=>0.0, :count=>1.0}, {:gene_name=>"hs2", :start=>109371659, :end=>114371659, :none=>0.0, :count=>1.0}, {:gene_name=>"hs2", :start=>109378557, :end=>114378557, :none=>0.0, :count=>2.0}, {:gene_name=>"hs21", :start=>43171279, :end=>48171279, :none=>0.0, :count=>1.0}, {:gene_name=>"hs2", :start=>170003432, :end=>175003432, :none=>0.0, :count=>1.0}, {:gene_name=>"hs2", :start=>172841177, :end=>177841177, :none=>0.0, :count=>1.0}, {:gene_name=>"hs2", :start=>179441663, :end=>184441663, :none=>0.0, :count=>1.0}, {:gene_name=>"hs2", :start=>179458592, :end=>184458592, :none=>0.0, :count=>1.0}, {:gene_name=>"hs2", :start=>179474021, :end=>184474021, :none=>0.0, :count=>1.0}, {:gene_name=>"hs2", :start=>179497919, :end=>184497919, :none=>0.0, :count=>1.0}, {:gene_name=>"hs2", :start=>210560016, :end=>215560016, :none=>0.0, :count=>1.0}, {:gene_name=>"hs22", :start=>23634794, :end=>28634794, :none=>0.0, :count=>1.0}, {:gene_name=>"hs22", :start=>26348276, :end=>31348276, :none=>0.0, :count=>1.0}, {:gene_name=>"hs22", :start=>29695754, :end=>34695754, :none=>0.0, :count=>1.0}, {:gene_name=>"hs2", :start=>242077496, :end=>247077496, :none=>0.0, :count=>1.0}, {:gene_name=>"hs2", :start=>44445635, :end=>49445635, :none=>0.0, :count=>1.0}, {:gene_name=>"hs2", :start=>73651650, :end=>78651650, :none=>0.0, :count=>1.0}, {:gene_name=>"hs2", :start=>80085192, :end=>85085192, :none=>0.0, :count=>3.0}, {:gene_name=>"hs2", :start=>88874891, :end=>93874891, :none=>0.0, :count=>1.0}, {:gene_name=>"hs3", :start=>111432915, :end=>116432915, :none=>0.0, :count=>1.0}, {:gene_name=>"hs3", :start=>128204951, :end=>133204951, :none=>0.0, :count=>1.0}, {:gene_name=>"hs3", :start=>132415626, :end=>137415626, :none=>0.0, :count=>1.0}, {:gene_name=>"hs3", :start=>138383924, :end=>143383924, :none=>0.0, :count=>1.0}, {:gene_name=>"hs3", :start=>138383926, :end=>143383926, :none=>0.0, :count=>1.0}, {:gene_name=>"hs3", :start=>1415695, :end=>6415695, :none=>0.0, :count=>1.0}, {:gene_name=>"hs3", :start=>178916645, :end=>183916645, :none=>0.0, :count=>1.0}, {:gene_name=>"hs3", :start=>178917478, :end=>183917478, :none=>0.0, :count=>1.0}, {:gene_name=>"hs3", :start=>178921553, :end=>183921553, :none=>0.0, :count=>1.0}, {:gene_name=>"hs3", :start=>178936091, :end=>183936091, :none=>0.0, :count=>2.0}, {:gene_name=>"hs3", :start=>178952085, :end=>183952085, :none=>0.0, :count=>3.0}, {:gene_name=>"hs3", :start=>196509577, :end=>201509577, :none=>0.0, :count=>1.0}, {:gene_name=>"hs3", :start=>30691872, :end=>35691872, :none=>0.0, :count=>1.0}, {:gene_name=>"hs3", :start=>41266035, :end=>46266035, :none=>0.0, :count=>1.0}, {:gene_name=>"hs3", :start=>43389910, :end=>48389910, :none=>0.0, :count=>1.0}, {:gene_name=>"hs3", :start=>44815895, :end=>49815895, :none=>0.0, :count=>1.0}, {:gene_name=>"hs3", :start=>47125385, :end=>52125385, :none=>0.0, :count=>1.0}, {:gene_name=>"hs3", :start=>52676058, :end=>57676058, :none=>0.0, :count=>1.0}, {:gene_name=>"hs4", :start=>104101560, :end=>109101560, :none=>0.0, :count=>1.0}, {:gene_name=>"hs4", :start=>107845794, :end=>112845794, :none=>0.0, :count=>1.0}, {:gene_name=>"hs4", :start=>114251445, :end=>119251445, :none=>0.0, :count=>1.0}, {:gene_name=>"hs4", :start=>122782752, :end=>127782752, :none=>0.0, :count=>1.0}, {:gene_name=>"hs4", :start=>175898988, :end=>180898988, :none=>0.0, :count=>1.0}, {:gene_name=>"hs4", :start=>187004218, :end=>192004218, :none=>0.0, :count=>1.0}, {:gene_name=>"hs4", :start=>25256691, :end=>30256691, :none=>0.0, :count=>1.0}, {:gene_name=>"hs4", :start=>78086985, :end=>83086985, :none=>0.0, :count=>1.0}, {:gene_name=>"hs5", :start=>122924121, :end=>127924121, :none=>0.0, :count=>1.0}, {:gene_name=>"hs5", :start=>14358319, :end=>19358319, :none=>0.0, :count=>1.0}, {:gene_name=>"hs5", :start=>14482749, :end=>19482749, :none=>0.0, :count=>1.0}, {:gene_name=>"hs5", :start=>14482753, :end=>19482753, :none=>0.0, :count=>2.0}, {:gene_name=>"hs5", :start=>149602280, :end=>154602280, :none=>0.0, :count=>1.0}, {:gene_name=>"hs5", :start=>162868084, :end=>167868084, :none=>0.0, :count=>1.0}, {:gene_name=>"hs5", :start=>23522939, :end=>28522939, :none=>0.0, :count=>1.0}, {:gene_name=>"hs5", :start=>23527492, :end=>28527492, :none=>0.0, :count=>1.0}, {:gene_name=>"hs5", :start=>39002728, :end=>44002728, :none=>0.0, :count=>1.0}, {:gene_name=>"hs5", :start=>80040428, :end=>85040428, :none=>0.0, :count=>1.0}, {:gene_name=>"hs5", :start=>86629082, :end=>91629082, :none=>0.0, :count=>2.0}, {:gene_name=>"hs6", :start=>117622184, :end=>122622184, :none=>0.0, :count=>1.0}, {:gene_name=>"hs6", :start=>117622188, :end=>122622188, :none=>0.0, :count=>1.0}, {:gene_name=>"hs6", :start=>129807629, :end=>134807629, :none=>0.0, :count=>1.0}, {:gene_name=>"hs6", :start=>3104493, :end=>8104493, :none=>0.0, :count=>1.0}, {:gene_name=>"hs6", :start=>31778963, :end=>36778963, :none=>0.0, :count=>4.0}, {:gene_name=>"hs6", :start=>41903782, :end=>46903782, :none=>0.0, :count=>1.0}, {:gene_name=>"hs6", :start=>51909775, :end=>56909775, :none=>0.0, :count=>1.0}, {:gene_name=>"hs7", :start=>113517815, :end=>118517815, :none=>0.0, :count=>1.0}, {:gene_name=>"hs7", :start=>120969769, :end=>125969769, :none=>0.0, :count=>1.0}, {:gene_name=>"hs7", :start=>128478663, :end=>133478663, :none=>0.0, :count=>1.0}, {:gene_name=>"hs7", :start=>139797431, :end=>144797431, :none=>0.0, :count=>1.0}, {:gene_name=>"hs7", :start=>140477877, :end=>145477877, :none=>0.0, :count=>1.0}, {:gene_name=>"hs7", :start=>143088824, :end=>148088824, :none=>0.0, :count=>1.0}, {:gene_name=>"hs7", :start=>151902221, :end=>156902221, :none=>0.0, :count=>1.0}, {:gene_name=>"hs7", :start=>151921099, :end=>156921099, :none=>0.0, :count=>1.0}, {:gene_name=>"hs7", :start=>55259512, :end=>60259512, :none=>0.0, :count=>1.0}, {:gene_name=>"hs7", :start=>56088902, :end=>61088902, :none=>0.0, :count=>1.0}, {:gene_name=>"hs8", :start=>113241054, :end=>118241054, :none=>0.0, :count=>1.0}, {:gene_name=>"hs8", :start=>117878915, :end=>122878915, :none=>0.0, :count=>1.0}, {:gene_name=>"hs8", :start=>145059254, :end=>150059254, :none=>0.0, :count=>1.0}, {:gene_name=>"hs8", :start=>38173525, :end=>43173525, :none=>0.0, :count=>1.0}, {:gene_name=>"hs8", :start=>41615650, :end=>46615650, :none=>0.0, :count=>1.0}, {:gene_name=>"hs8", :start=>48713371, :end=>53713371, :none=>0.0, :count=>2.0}, {:gene_name=>"hs8", :start=>48744484, :end=>53744484, :none=>0.0, :count=>4.0}, {:gene_name=>"hs9", :start=>102988354, :end=>107988354, :none=>0.0, :count=>1.0}, {:gene_name=>"hs9", :start=>107620867, :end=>112620867, :none=>0.0, :count=>1.0}, {:gene_name=>"hs9", :start=>139266496, :end=>144266496, :none=>0.0, :count=>1.0}, {:gene_name=>"hs9", :start=>77365639, :end=>82365639, :none=>0.0, :count=>1.0}]
In [42]:
bin_size = df.size.max/50
chr_name = df.column(:name).to_a
nested = df.column(:size).to_a.map.with_index do |size, i|
  vals = hash[chr_name[i]]
  vals2 = hash4[chr_name[i]]
  names = hash2[chr_name[i]]
  vals = [] if vals.nil?
  vals2 = [] if vals2.nil?
  names = [] if names.nil?
  raw = Array.new(size/bin_size, 0).map.with_index {|val, i|
    val = vals.reduce(0){|memo, v| next memo + v[:val] if v[:start] > i*bin_size && v[:start] < (i+1)*bin_size; memo}
    val2 = vals2.reduce(0){|memo, v| next memo + v[:val] if v[:start] > i*bin_size && v[:start] < (i+1)*bin_size; memo};
    name = names.select {|name| name[:locale] > i*bin_size && name[:locale] < (i+1)*bin_size}
    {axis: i*bin_size, val: val, val2: val2, name: (name.length==0 ? '' : name[0][:name])}
  }
  Nyaplot::DataFrame.new(raw)
end
df.df = nested
df
Out[42]:
namesizedf
chr1249250621
axisvalval2name
021.00CDK11A
49850121.00PARK7
997002410.00TNFRSF1B
1495503600
1994004816.00PINK1
2492506001.0
2991007200
3489508404.0
398800961.02.0MPL
448651083.00MUTYH
4985012000
5483513220.00USP24
5982014400
6480515600
6979016800
7477518000
............
24426558800
chr2243199373
axisvalval2name
000
498501200
997002411.00ROCK2
1495503600
1994004800
2492506000
2991007200
3489508400
3988009601.0
448651085.00MSH6
4985012000
5483513200
5982014400
6480515600
6979016801.0
7477518000
............
23429556400
chr3198022430
axisvalval2name
001.0
498501200
997002412.00XPC
1495503600
1994004800
2492506000
2991007201.0
3489508410.00MLH1
3988009603.0
4486510811.01.0MST1
4985012001.0
5483513200
5982014400
6480515600
6979016800
7477518000
............
18943045600
chr4191154276
axisvalval2name
017.00GRK4
498501200
997002400
1495503600
1994004815.00PPARGC1A
2492506001.0
2991007200
3489508410.00TLR1
3988009600
4486510800
4985012000
5483513213.00KDR
5982014400
6480515600
6979016800
7477518010.01.0BTC
............
18444544433.01.0CASP3
chr5180915260
axisvalval2name
000
498501200
99700241.04.0DNAH5
1495503600
1994004802.0
2492506000
2991007200
3489508401.0
3988009600
4486510800
498501204.00ITGA2
5483513200
5982014400
648051568.00PIK3R1
6979016800
7477518010.00THBS4
............
17447542000
chr6171115067
axisvalval2name
001.0
498501200
997002400
1495503600
1994004800
2492506000
2991007230.04.0EHMT2
3489508400
398800961.01.0SLC29A1
4486510800
498501204.01.0PKHD1
5483513200
5982014400
6480515600
6979016800
7477518000
............
16450539600
chr7159138663
axisvalval2name
01.00MAD1L1
498501200
997002400
1495503600
1994004800
2492506000
2991007200
3489508400
398800962.00GLI3
4486510811.00IGFBP1
4985012000
5483513211.02.0EGFR
5982014400
6480515600
6979016800
7477518000
............
14955036002.0
chr8146364022
axisvalval2name
000
498501200
99700241.00BLK
1495503600
199400487.00TNFRSF10A
2492506000
2991007211.00WRN
3489508401.0
3988009601.0
4486510806.0
4985012000
5483513200
5982014400
6480515600
6979016800
7477518000
............
13958033600
chr9141213431
axisvalval2name
000
49850129.00KDM4C
997002418.00CER1
1495503600
1994004800
2492506000
2991007200
3489508400
3988009600
4486510800
4985012000
5483513200
5982014400
6480515600
6979016800
7477518001.0
............
13459532412.01.0CARD9
chr10135534747
axisvalval2name
000
498501203.0
997002402.0
149550362.00CUBN
1994004810.00PIP4K2A
2492506001.0
2991007200
3489508400
3988009613.00RET
4486510800
4985012002.0
5483513200
5982014400
6480515610.01.0CTNNA3
6979016810.00NODAL
7477518002.0
............
12961031216.00MGMT
chr11135006516
axisvalval2name
000
498501200
997002400
1495503600
1994004800
2492506000
2991007200
3489508400
3988009600
4486510810.01.0PTPRJ
4985012000
5483513200
5982014401.0
6480515621.00GSTP1
6979016800
7477518000
............
12961031200
chr12133851895
axisvalval2name
01.00FGF23
498501200
99700245.00CDKN1B
1495503613.00PIK3C2G
1994004800
2492506000
2991007200
3489508400
3988009610.01.0LRRK2
4486510800
498501201.00ATF1
5483513217.03.0GLI1
5982014400
6480515600
6979016800
7477518000
............
12462530000
chr13115169878
axisvalval2name
000
498501200
997002400
1495503600
1994004800
2492506000
2991007218.01.0BRCA2
3489508400
3988009602.0
4486510802.0
4985012015.01.0SETDB2
5483513200
5982014400
6480515600
6979016800
7477518000
............
10967026412.01.0COL4A1
chr14107349540
axisvalval2name
000
498501200
997002400
1495503600
199400489.01.0RPGRIP1
2492506000
2991007200
3489508401.0
3988009600
4486510800
4985012012.01.0BMP4
5483513200
598201447.01.0PRKCH
6480515600
697901681.00PSEN1
747751801.00MLH3
............
9970024000
chr15102531392
axisvalval2name
000
498501200
997002400
1495503600
1994004800
2492506000
2991007200
3489508400
3988009633.00TP53BP1
4486510800
498501205.00TRPM7
5483513201.0
5982014400
6480515600
6979016800
7477518000
............
9471522800
chr1690354753
axisvalval2name
03.02.0NTHL1
498501200
99700241.00ERCC4
1495503600
199400487.00PALB2
2492506000
2991007201.0
3489508400
3988009600
4486510800
498501201.02.0RPGRIP1L
5483513200
5982014400
6480515601.0
6979016800
7477518000
............
8474520400
.........
chry59373566
axisvalval2name
000
498501200
997002400
1495503600
1994004800
2492506000
2991007200
3489508400
3988009600
4486510800
4985012000
In [43]:
df.name = df.column(:name).to_a.map{|name| name.match(/chr(.+)/)[1]}
df
Out[43]:
namesizedf
1249250621
axisvalval2name
021.00CDK11A
49850121.00PARK7
997002410.00TNFRSF1B
1495503600
1994004816.00PINK1
2492506001.0
2991007200
3489508404.0
398800961.02.0MPL
448651083.00MUTYH
4985012000
5483513220.00USP24
5982014400
6480515600
6979016800
7477518000
............
24426558800
2243199373
axisvalval2name
000
498501200
997002411.00ROCK2
1495503600
1994004800
2492506000
2991007200
3489508400
3988009601.0
448651085.00MSH6
4985012000
5483513200
5982014400
6480515600
6979016801.0
7477518000
............
23429556400
3198022430
axisvalval2name
001.0
498501200
997002412.00XPC
1495503600
1994004800
2492506000
2991007201.0
3489508410.00MLH1
3988009603.0
4486510811.01.0MST1
4985012001.0
5483513200
5982014400
6480515600
6979016800
7477518000
............
18943045600
4191154276
axisvalval2name
017.00GRK4
498501200
997002400
1495503600
1994004815.00PPARGC1A
2492506001.0
2991007200
3489508410.00TLR1
3988009600
4486510800
4985012000
5483513213.00KDR
5982014400
6480515600
6979016800
7477518010.01.0BTC
............
18444544433.01.0CASP3
5180915260
axisvalval2name
000
498501200
99700241.04.0DNAH5
1495503600
1994004802.0
2492506000
2991007200
3489508401.0
3988009600
4486510800
498501204.00ITGA2
5483513200
5982014400
648051568.00PIK3R1
6979016800
7477518010.00THBS4
............
17447542000
6171115067
axisvalval2name
001.0
498501200
997002400
1495503600
1994004800
2492506000
2991007230.04.0EHMT2
3489508400
398800961.01.0SLC29A1
4486510800
498501204.01.0PKHD1
5483513200
5982014400
6480515600
6979016800
7477518000
............
16450539600
7159138663
axisvalval2name
01.00MAD1L1
498501200
997002400
1495503600
1994004800
2492506000
2991007200
3489508400
398800962.00GLI3
4486510811.00IGFBP1
4985012000
5483513211.02.0EGFR
5982014400
6480515600
6979016800
7477518000
............
14955036002.0
8146364022
axisvalval2name
000
498501200
99700241.00BLK
1495503600
199400487.00TNFRSF10A
2492506000
2991007211.00WRN
3489508401.0
3988009601.0
4486510806.0
4985012000
5483513200
5982014400
6480515600
6979016800
7477518000
............
13958033600
9141213431
axisvalval2name
000
49850129.00KDM4C
997002418.00CER1
1495503600
1994004800
2492506000
2991007200
3489508400
3988009600
4486510800
4985012000
5483513200
5982014400
6480515600
6979016800
7477518001.0
............
13459532412.01.0CARD9
10135534747
axisvalval2name
000
498501203.0
997002402.0
149550362.00CUBN
1994004810.00PIP4K2A
2492506001.0
2991007200
3489508400
3988009613.00RET
4486510800
4985012002.0
5483513200
5982014400
6480515610.01.0CTNNA3
6979016810.00NODAL
7477518002.0
............
12961031216.00MGMT
11135006516
axisvalval2name
000
498501200
997002400
1495503600
1994004800
2492506000
2991007200
3489508400
3988009600
4486510810.01.0PTPRJ
4985012000
5483513200
5982014401.0
6480515621.00GSTP1
6979016800
7477518000
............
12961031200
12133851895
axisvalval2name
01.00FGF23
498501200
99700245.00CDKN1B
1495503613.00PIK3C2G
1994004800
2492506000
2991007200
3489508400
3988009610.01.0LRRK2
4486510800
498501201.00ATF1
5483513217.03.0GLI1
5982014400
6480515600
6979016800
7477518000
............
12462530000
13115169878
axisvalval2name
000
498501200
997002400
1495503600
1994004800
2492506000
2991007218.01.0BRCA2
3489508400
3988009602.0
4486510802.0
4985012015.01.0SETDB2
5483513200
5982014400
6480515600
6979016800
7477518000
............
10967026412.01.0COL4A1
14107349540
axisvalval2name
000
498501200
997002400
1495503600
199400489.01.0RPGRIP1
2492506000
2991007200
3489508401.0
3988009600
4486510800
4985012012.01.0BMP4
5483513200
598201447.01.0PRKCH
6480515600
697901681.00PSEN1
747751801.00MLH3
............
9970024000
15102531392
axisvalval2name
000
498501200
997002400
1495503600
1994004800
2492506000
2991007200
3489508400
3988009633.00TP53BP1
4486510800
498501205.00TRPM7
5483513201.0
5982014400
6480515600
6979016800
7477518000
............
9471522800
1690354753
axisvalval2name
03.02.0NTHL1
498501200
99700241.00ERCC4
1495503600
199400487.00PALB2
2492506000
2991007201.0
3489508400
3988009600
4486510800
498501201.02.0RPGRIP1L
5483513200
5982014400
6480515601.0
6979016800
7477518000
............
8474520400
.........
y59373566
axisvalval2name
000
498501200
997002400
1495503600
1994004800
2492506000
2991007200
3489508400
3988009600
4486510800
4985012000
In [17]:
 
In [44]:
color = Nyaplot::Colors.qual
Out[44]:
rgb(141,211,199)rgb(255,255,179)rgb(190,186,218)rgb(251,128,114)rgb(128,177,211)rgb(253,180,98)rgb(179,222,105)rgb(252,205,229)rgb(217,217,217)
         
In [48]:
plot2 = Nyaplot::CircularPlot.new(df, :name, :df)
arc = plot2.add(1, :arc, :axis, :val)
arc2 = plot2.add(2, :arc, :axis, :val2)
arc.color(["rgb(56,108,176)"])
arc2.color(["#e34a33"])
labels = plot2.add(3, :labels, :axis, :name)
labels.text_size("0.3em")
plot2.color(color)
plot2.text_size("0.5em")
plot2.text_color("#000")
plot2.show
Out[48]:
In [20]:
from=[]; to=[]
df.each_row do |row|
  chr_name = row[:name]
  axis = row[:df].axis.to_a
  2.times do |i|
    num = axis.sample
    from.push(chr_name + '.' + num.to_s)
    num = axis.sample
    to.push(chr_name + '.' + num.to_s)
  end
end
connector_df = Nyaplot::DataFrame.new({from: from.shuffle,to: to.shuffle})
connector_df
Out[20]:
fromto
3.7477518018.69790168
15.0y.39880096
5.1595203846.14955036
1.17447542021.4985012
20.1495503617.74775180
6.299100726.134595324
y.997002418.19940048
5.1545353724.119640288
19.3988009613.54835132
9.1994004819.24925060
2.2342955642.174475420
19.4985012010.99700240
16.249250607.9970024
12.12462530021.0
4.17447542014.74775180
10.3489508422.9970024
......
18.448651085.144565348
In [21]:
plot2.add_connector_with_df(connector_df, :from, :to)
plot2.show
Out[21]:
In [ ]: