-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.js
More file actions
165 lines (134 loc) · 5.41 KB
/
main.js
File metadata and controls
165 lines (134 loc) · 5.41 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
/**
*
*/
var debug = 0;
var debug2 = 0;
var rangeModule = 0;
//define the main module having 4 dependencies: d3 (external library), caleydo main, caleydo data, and a header template for a common styling
define(['jquery', 'd3', '../caleydo_core/ajax', '../caleydo_core/main', '../caleydo_core/data',
'../caleydo_d3/databrowser', '../caleydo_vis/axis', '../caleydo_vis/box', '../caleydo_vis/distribution',
'../caleydo_vis/barplot', '../caleydo_vis/heatmap', '../caleydo_core/multiform', '../caleydo_window/main',
'../gene_vis/linechart', '../gene_vis/boxchart', '../gene_vis/boxplot', '../caleydo_core/range',
'../caleydo_core/plugin', '../wrapper_bootstrap_fontawesome/header'],
function ($, d3, ajax, C, data, browser, axis, box, dist, bars, heatmap, multiform, window, linechart, boxchart, boxplot, range, plugin, header) {
'use strict';
var appHeader = header.create(document.body,
{
app: 'Gene App'
});
var base = document.getElementById('plots');
var axisDiv = document.getElementById('axis');
debug2 = data;
rangeModule = range;
function renderGenomicData(gene)
{
console.log(gene);
debug = gene;
// extract column slice
//var colData = gene.slice(121);
// for row data --> take transposed matrix and use slice function
var rowData = gene.t.slice(0);
rowData.data().then( function(arr)
{
//debug2 = arr;
console.log(arr);
rowData.desc.value.range = d3.extent(arr);
console.log('create plots');
//box.create(rowData, base);
//dist.create(rowData, base, { scale: [2,3] });
//bars.create(rowData, base, { width: 1000, heighti: 200 });
//axis.create(rowData, axisDiv, {r: 0, scale: [8,0.08], shift: 20, orient: 'bottom'});
// for
// first look for all the divs and the one with id main, then append
// a new division to it with css attribute position
var winBoxChart = $('<div>').css('position', 'relative').appendTo('.boxChart')[0];
// create a new visualization window
var winBox = window.createVisWindow(winBoxChart,
{
closeable: false, animatedHeader: false, zcontrols: false,
zoomAble: true, resizeable: false, draggable: false
});
var winBoxPlot = $('<div>').css('position', 'relative').appendTo('.boxPlot')[0];
var winBoxP = window.createVisWindow(winBoxPlot,
{
closeable: false, animatedHeader: false, zcontrols: false,
zoomAble: true, resizeable: false, draggable: false
});
//var test = [[1,2,3],[3,4,5]];
//
//var mat = matrix.constructor()
//heatmap.create(test, win.node);
// create a new multiform
// displays a window with title and all plugins that are able to display the data
//var multiP = Promise.resolve(multiform.create(gene, win.node, { initialVis : 2 }));
//heatmap.create(gene, win.node, { scale: [0.1,0.1] });
//dist.create(rowData, win.node, { scale: [2,4] });
//win.title = 'Histogram';
//var lineC = linechart.create(rowData, win.node);
//win.title = 'First Line Chart';
//$('.slices').on('change', function() {
// //console.log(this.value);
// var rowData = gene.slice(this.value, this.value + 1);
// lineC.updateGraph(rowData); });
var boxC = boxchart.create(rowData, winBox.node);
winBox.title = 'First Box Chart';
$('.slices').on('change', function() {
//console.log(this.value);
var rowData = gene.t.slice(this.value, this.value + 1);
boxC.updateGraph(rowData); });
var boxP = boxplot.create(rowData, winBoxP.node);
winBoxP.title = 'First Box Plot';
$('.slices').on('change', function() {
//console.log(this.value);
var rowData = gene.t.slice(this.value, this.value + 1);
boxP.updateGraph(rowData); });
$('.slices').on('change', function() {
var newValue = this.value;
$('.sliderText').text('Slice: ' + String(newValue));
});
//multiP.then(function(multi)
//{
// console.log('multiform creation completed');
// // add icon viewer to choose which vis plugin should be used
// multiform.addIconVisChooser(win.toolbar.node, multi);
// // attach multiform to window
// win.attachVis(multi, multi.asMetaData);
// // set position if pos is not valid
// win.pos = [400, 50];
// // make window movable
// var vis = win.adapter(multi);
// // this is important, otherwise title will not be displayed and window is not movable
//
// var entry =
// {
// mw: win,
// multi : multi
// };
//
// return entry;
//});
});
//var query = {};
////console.log(path);
//console.log('try to invoke clustering')
//var test = ajax.getAPIJSON('/gene_clustering/kmeans/3/' + gene.desc.id, query);
//test.then(function (d) { console.log(d); });
//
//var test2 = ajax.getAPIJSON('/gene_clustering/hierarchical/complete/' + gene.desc.id, query);
//test2.then(function (d) { console.log(d); });
console.log('finished.');
//test2 = rowData;
}
// get one specific data
data.getFirstByName('OV_D1_Mean_Tumor_7p_Mean_Small').then(
function(d) {
renderGenomicData(d);
});
// list all available datasets
//data.list().then(function(list) {
//for (var i = 0; i < list.length; ++i)
//{
// console.log(list[i].desc.name);
//}
//});
});