report_html 0.3.8 → 0.4.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +5 -5
- data/js/canvasXpress.css +5403 -1657
- data/js/canvasXpress.min.js +46 -63
- data/lib/report_html/report_html.rb +94 -16
- data/lib/report_html/version.rb +1 -1
- metadata +6 -7
@@ -14,6 +14,7 @@ class Report_html
|
|
14
14
|
@plots_data = []
|
15
15
|
@count_objects = 0
|
16
16
|
@dt_tables = [] #Tables to be styled with the DataTables js lib"
|
17
|
+
@bs_tables = [] #Tables to be styled with the bootstrap js lib"
|
17
18
|
end
|
18
19
|
|
19
20
|
def build(template)
|
@@ -57,7 +58,8 @@ class Report_html
|
|
57
58
|
<meta charset=\"utf-8\">
|
58
59
|
<meta http-equiv=\"CACHE-CONTROL\" CONTENT=\"NO-CACHE\">
|
59
60
|
<meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\" />
|
60
|
-
<meta http-equiv=\"Content-Language\" content=\"en-us\"
|
61
|
+
<meta http-equiv=\"Content-Language\" content=\"en-us\" />
|
62
|
+
<meta name=\"viewport\" content=\"width=device-width, initial-scale=1, shrink-to-fit=no\">\n"
|
61
63
|
|
62
64
|
# ADD JS LIBRARIES AND CSS
|
63
65
|
js_libraries = []
|
@@ -66,10 +68,18 @@ class Report_html
|
|
66
68
|
js_libraries << 'canvasXpress.min.js'
|
67
69
|
css_files << 'canvasXpress.css'
|
68
70
|
end
|
71
|
+
|
72
|
+
if !@dt_tables.empty? || !@bs_tables.empty? #Bootstrap for datatables or only for static tables. Use bootstrap version needed by datatables to avoid incompatibility issues
|
73
|
+
@all_report << '<link rel="stylesheet" type="text/css" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css"/>'+"\n"
|
74
|
+
end
|
75
|
+
|
69
76
|
if !@dt_tables.empty? # CDN load, this library is difficult to embed in html file
|
70
|
-
|
71
|
-
|
72
|
-
|
77
|
+
@all_report << '<link rel="stylesheet" type="text/css" href="https://cdn.datatables.net/1.10.21/css/dataTables.bootstrap.min.css"/>'+"\n"
|
78
|
+
@all_report << '<script type="text/javascript" src="https://code.jquery.com/jquery-3.5.1.js"></script>' + "\n"
|
79
|
+
@all_report << '<script type="text/javascript" src="https://cdn.datatables.net/1.10.21/js/jquery.dataTables.min.js"></script>' + "\n"
|
80
|
+
@all_report << '<script type="text/javascript" src="https://cdn.datatables.net/1.10.21/js/dataTables.bootstrap.min.js"></script>' + "\n"
|
81
|
+
end
|
82
|
+
|
73
83
|
loaded_js_libraries = load_js_libraries(js_libraries)
|
74
84
|
loaded_css = load_css(css_files)
|
75
85
|
loaded_css.each do |css|
|
@@ -221,6 +231,7 @@ class Report_html
|
|
221
231
|
rowspan, colspan = get_col_n_row_span(array_data)
|
222
232
|
table_id = 'table_' + @count_objects.to_s
|
223
233
|
@dt_tables << table_id if options[:styled] == 'dt'
|
234
|
+
@bs_tables << table_id if options[:styled] == 'bs'
|
224
235
|
tbody_tag = false
|
225
236
|
html = "
|
226
237
|
<table id=\"#{table_id}\" border=\"#{options[:border]}\" #{table_attr}>
|
@@ -364,7 +375,7 @@ class Report_html
|
|
364
375
|
}
|
365
376
|
options.merge!(user_options)
|
366
377
|
config = {
|
367
|
-
'
|
378
|
+
'toolbarType' => 'under',
|
368
379
|
'xAxisTitle' => options[:x_label],
|
369
380
|
'title' => options[:title]
|
370
381
|
}
|
@@ -389,7 +400,9 @@ class Report_html
|
|
389
400
|
end
|
390
401
|
values = data_array
|
391
402
|
|
392
|
-
|
403
|
+
x = {}
|
404
|
+
z = {}
|
405
|
+
yield(options, config, samples, vars, values, object_id, x, z)
|
393
406
|
# Build JSON objects and Javascript code
|
394
407
|
#-----------------------------------------------
|
395
408
|
@count_objects += 1
|
@@ -398,7 +411,9 @@ class Report_html
|
|
398
411
|
'vars' => vars,
|
399
412
|
'smps' => samples,
|
400
413
|
'data' => values
|
401
|
-
}
|
414
|
+
},
|
415
|
+
'x' => x,
|
416
|
+
'z' => z
|
402
417
|
}
|
403
418
|
events = false
|
404
419
|
info = false
|
@@ -431,7 +446,7 @@ class Report_html
|
|
431
446
|
default_options = {
|
432
447
|
row_names: true
|
433
448
|
}.merge!(user_options)
|
434
|
-
html_string = canvasXpress_main(default_options, block) do |options, config, samples, vars, values, object_id|
|
449
|
+
html_string = canvasXpress_main(default_options, block) do |options, config, samples, vars, values, object_id, x, z|
|
435
450
|
config['graphType'] = 'Line'
|
436
451
|
end
|
437
452
|
return html_string
|
@@ -441,7 +456,7 @@ class Report_html
|
|
441
456
|
default_options = {
|
442
457
|
row_names: true,
|
443
458
|
}.merge!(user_options)
|
444
|
-
html_string = canvasXpress_main(default_options, block) do |options, config, samples, vars, values, object_id|
|
459
|
+
html_string = canvasXpress_main(default_options, block) do |options, config, samples, vars, values, object_id, x, z|
|
445
460
|
config['graphType'] = 'Stacked'
|
446
461
|
end
|
447
462
|
return html_string
|
@@ -451,17 +466,33 @@ class Report_html
|
|
451
466
|
default_options = {
|
452
467
|
row_names: true
|
453
468
|
}.merge!(user_options)
|
454
|
-
html_string = canvasXpress_main(default_options, block) do |options, config, samples, vars, values, object_id|
|
469
|
+
html_string = canvasXpress_main(default_options, block) do |options, config, samples, vars, values, object_id, x, z|
|
455
470
|
config['graphType'] = 'Bar'
|
456
471
|
end
|
457
472
|
return html_string
|
458
473
|
end
|
459
474
|
|
475
|
+
def dotplot(user_options = {}, &block)
|
476
|
+
default_options = {
|
477
|
+
row_names: true,
|
478
|
+
connect: false
|
479
|
+
}.merge!(user_options)
|
480
|
+
html_string = canvasXpress_main(default_options, block) do |options, config, samples, vars, values, object_id, x, z|
|
481
|
+
config['graphType'] = 'Dotplot'
|
482
|
+
if default_options[:connect]
|
483
|
+
config['dotplotType'] = "stacked"
|
484
|
+
config['connectBy'] = "Connect"
|
485
|
+
z[:Connect] = Array.new(vars.length, 1)
|
486
|
+
end
|
487
|
+
end
|
488
|
+
return html_string
|
489
|
+
end
|
490
|
+
|
460
491
|
def heatmap(user_options = {}, &block)
|
461
492
|
default_options = {
|
462
493
|
row_names: true
|
463
494
|
}.merge!(user_options)
|
464
|
-
html_string = canvasXpress_main(default_options, block) do |options, config, samples, vars, values, object_id|
|
495
|
+
html_string = canvasXpress_main(default_options, block) do |options, config, samples, vars, values, object_id, x, z|
|
465
496
|
config['graphType'] = 'Heatmap'
|
466
497
|
end
|
467
498
|
return html_string
|
@@ -472,7 +503,7 @@ class Report_html
|
|
472
503
|
row_names: true,
|
473
504
|
header: true
|
474
505
|
}.merge!(user_options)
|
475
|
-
html_string = canvasXpress_main(default_options, block) do |options, config, samples, vars, values, object_id|
|
506
|
+
html_string = canvasXpress_main(default_options, block) do |options, config, samples, vars, values, object_id, x, z|
|
476
507
|
config['graphType'] = 'Boxplot'
|
477
508
|
options[:mod_data_structure] = 'boxplot'
|
478
509
|
if options[:extracode].nil?
|
@@ -486,7 +517,7 @@ class Report_html
|
|
486
517
|
default_options = {
|
487
518
|
transpose: false
|
488
519
|
}.merge!(user_options)
|
489
|
-
html_string = canvasXpress_main(default_options, block) do |options, config, samples, vars, values, object_id|
|
520
|
+
html_string = canvasXpress_main(default_options, block) do |options, config, samples, vars, values, object_id, x, z|
|
490
521
|
config['graphType'] = 'Pie'
|
491
522
|
if samples.length > 1
|
492
523
|
config['showPieGrid'] = true
|
@@ -498,12 +529,24 @@ class Report_html
|
|
498
529
|
return html_string
|
499
530
|
end
|
500
531
|
|
532
|
+
def corplot(user_options = {}, &block)
|
533
|
+
default_options = {
|
534
|
+
transpose: false,
|
535
|
+
correlationAxis: 'samples'
|
536
|
+
}.merge!(user_options)
|
537
|
+
html_string = canvasXpress_main(default_options, block) do |options, config, samples, vars, values, object_id, x, z|
|
538
|
+
config['graphType'] = 'Correlation'
|
539
|
+
config['correlationAxis'] = default_options[:correlationAxis]
|
540
|
+
end
|
541
|
+
return html_string
|
542
|
+
end
|
543
|
+
|
501
544
|
def sccater2D(user_options = {}, &block)
|
502
545
|
default_options = {
|
503
546
|
row_names: false,
|
504
547
|
transpose: false
|
505
548
|
}.merge!(user_options)
|
506
|
-
html_string = canvasXpress_main(default_options, block) do |options, config, samples, vars, values, object_id|
|
549
|
+
html_string = canvasXpress_main(default_options, block) do |options, config, samples, vars, values, object_id, x, z|
|
507
550
|
config['graphType'] = 'Scatter2D'
|
508
551
|
config['xAxis'] = [samples.first] if config['xAxis'].nil?
|
509
552
|
config['yAxis'] = samples[1..samples.length-1] if config['yAxis'].nil?
|
@@ -519,12 +562,14 @@ class Report_html
|
|
519
562
|
return html_string
|
520
563
|
end
|
521
564
|
|
565
|
+
alias scatter2D sccater2D # Fix for wrong name method
|
566
|
+
|
522
567
|
def scatterbubble2D(user_options = {}, &block)
|
523
568
|
default_options = {
|
524
569
|
row_names: true,
|
525
570
|
transpose: false
|
526
571
|
}.merge!(user_options)
|
527
|
-
html_string = canvasXpress_main(default_options, block) do |options, config, samples, vars, values, object_id|
|
572
|
+
html_string = canvasXpress_main(default_options, block) do |options, config, samples, vars, values, object_id, x, z|
|
528
573
|
config['graphType'] = 'ScatterBubble2D'
|
529
574
|
if options[:xAxis].nil?
|
530
575
|
config['xAxis'] = [samples[0]]
|
@@ -566,7 +611,7 @@ class Report_html
|
|
566
611
|
ringsType: [],
|
567
612
|
ringsWeight: []
|
568
613
|
}.merge!(user_options)
|
569
|
-
html_string = canvasXpress_main(default_options, block) do |options, config, samples, vars, values, object_id|
|
614
|
+
html_string = canvasXpress_main(default_options, block) do |options, config, samples, vars, values, object_id, x, z|
|
570
615
|
options[:mod_data_structure] = 'circular'
|
571
616
|
config['graphType'] = 'Circular'
|
572
617
|
config['segregateVariablesBy'] = ['Ring']
|
@@ -618,6 +663,39 @@ class Report_html
|
|
618
663
|
end
|
619
664
|
end
|
620
665
|
|
666
|
+
def circular_genome(user_options = {}, &block)
|
667
|
+
default_options = {}.merge!(user_options)
|
668
|
+
coordinates = user_options[:genomic_coordinates]
|
669
|
+
html_string = canvasXpress_main(default_options, block) do |options, config, samples, vars, values, object_id, x, z|
|
670
|
+
config['graphType'] = 'Circular'
|
671
|
+
config["arcSegmentsSeparation"] = 3
|
672
|
+
config["colorScheme"] = "Tableau"
|
673
|
+
config["colors"] = ["#332288","#6699CC","#88CCEE","#44AA99","#117733","#999933","#DDCC77","#661100","#CC6677","#AA4466","#882255","#AA4499"]
|
674
|
+
config["showIdeogram"] = true
|
675
|
+
chr = []
|
676
|
+
pos = []
|
677
|
+
tags2remove = []
|
678
|
+
vars.each_with_index do |var, i|
|
679
|
+
coord = coordinates[var]
|
680
|
+
if !coord.nil?
|
681
|
+
tag = coord.first.gsub(/[^\dXY]/,'')
|
682
|
+
if tag == 'X' || tag == 'Y' || (tag.to_i > 0 && tag.to_i <= 22)
|
683
|
+
chr << coord.first.gsub(/[^\dXY]/,'')
|
684
|
+
pos << coord.last - 1
|
685
|
+
else
|
686
|
+
tags2remove << i
|
687
|
+
end
|
688
|
+
else
|
689
|
+
tags2remove << i
|
690
|
+
end
|
691
|
+
end
|
692
|
+
tags2remove.reverse_each{|i| ent = vars.delete_at(i); warn("Feature #{ent} has not valid coordinates")} # Remove entities with invalid coordinates
|
693
|
+
z['chr'] = chr
|
694
|
+
z['pos'] = pos
|
695
|
+
end
|
696
|
+
return html_string
|
697
|
+
end
|
698
|
+
|
621
699
|
# EMBED FILES
|
622
700
|
###################################################################################
|
623
701
|
|
data/lib/report_html/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: report_html
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.4.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- seoanezonjic
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2021-12-23 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -72,7 +72,7 @@ homepage: ''
|
|
72
72
|
licenses:
|
73
73
|
- MIT
|
74
74
|
metadata: {}
|
75
|
-
post_install_message:
|
75
|
+
post_install_message:
|
76
76
|
rdoc_options: []
|
77
77
|
require_paths:
|
78
78
|
- lib
|
@@ -87,9 +87,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
87
87
|
- !ruby/object:Gem::Version
|
88
88
|
version: '0'
|
89
89
|
requirements: []
|
90
|
-
|
91
|
-
|
92
|
-
signing_key:
|
90
|
+
rubygems_version: 3.2.15
|
91
|
+
signing_key:
|
93
92
|
specification_version: 4
|
94
93
|
summary: Gem to build html interactive reports.
|
95
94
|
test_files: []
|