-
Notifications
You must be signed in to change notification settings - Fork 2
/
epiviz-genes-track.html
300 lines (248 loc) · 13.5 KB
/
epiviz-genes-track.html
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
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
<!-- Polymer dependency -->
<link rel="import" href="bower_components/polymer/polymer-element.html">
<!-- Epiviz imports dependency -->
<!-- <link rel="import" href="bower_components/epiviz-imports/epiviz-common-js.html"> -->
<!-- Epiviz Polymer Behaviors dependency -->
<link rel="import" href="chart-behavior.html">
<link rel="import" href="chart-settings.html">
<link rel="import" href="chart-colors.html">
<link rel="import" href="chart-remove.html">
<link rel="import" href="chart-grid-behavior.html">
<link rel="import" href="chart-viz-transcripts.html">
<!-- Epiviz Shared css -->
<link rel="import" type="css" href="chart-shared-css.html">
<!--
<h2> Chart Component </h2>
epiviz-chart components are a collection of reusable and extensible visualization components for
genomic data.
An epiviz-chart component requires two attributes to render a visualization on the page
<ul>
<li>data attribute, </li>
<li>dimensions (or columns) from the data attribute to visualize.</li>
</ul>
`<epiviz-genes-track>` creates a genes track chart. Genes track visualizes the
location of genes in a genomic region and the exon positions.
Element attributes are defined in <a href="#epiviz.ChartBehavior">`<epiviz.ChartBehavior>`</a> element.
To create a genes track on a HTML page, add
<epiviz-genes-track></epiviz-genes-track>
@demo demo/index-genes-track.html Example page showing a genes track
-->
<dom-module id="epiviz-genes-track">
<!--<link rel="import" href="bower_components/epiviz-imports/epiviz-common-css.html">-->
<template>
<style include="shared-settings"></style>
<style include="chart-shared-css"></style>
<style>
:host {
width: 100%;
height: 100%;
box-sizing: border-box;
display: inline-block;
border: 1px solid black;
border-radius: 5px;
transition: width 0.01s, height 0.01s;
resize: vertical;
overflow: auto;
position: relative;
}
[hidden] {
display: none;
}
</style>
<!-- local DOM goes here -->
<paper-spinner-lite active class="green"></paper-spinner-lite>
<div id="chart" on-drag="hostDragged" on-mouseover="hostHovered" on-mouseout="hostUnhovered">
<slot name="dragHandle"></slot>
<div id="{{plotId}}"></div>
</div>
</template>
<script>
// Extend Polymer.Element base class
// EpivizChartRemoveBehavior(EpivizChartColorsBehavior(EpivizChartSettingsBehavior(EpivizChartBehavior(Polymer.Element))))
class EpivizGenesTrack extends EpivizVizTranscriptsBehavior(EpivizChartGridBehavior(EpivizChartRemoveBehavior(EpivizChartColorsBehavior(EpivizChartSettingsBehavior(EpivizChartBehavior(Polymer.Element)))))) {
static get is() { return 'epiviz-genes-track'; }
static get properties() {
return {
/**
* Default chart properties for genes track.
*
* @type {Object}
*/
configSrc: {
type: Object,
notify: true,
value: function () {
epiviz.Config.SETTINGS = {
dataProviders: [
["epiviz.data.WebServerDataProvider", "umd", "http://epiviz-dev.cbcb.umd.edu/api/"]
],
workspacesDataProvider: sprintf('epiviz.data.EmptyResponseDataProvider', 'empty', ''),
useCache: true,
chartSettings: {
default: {
colors: 'd3-category10',
decorations: [
'epiviz.ui.charts.decoration.RemoveChartButton',
'epiviz.ui.charts.decoration.SaveChartButton',
'epiviz.ui.charts.decoration.CustomSettingsButton',
'epiviz.ui.charts.decoration.EditCodeButton',
'epiviz.ui.charts.decoration.ChartColorsButton',
'epiviz.ui.charts.decoration.ChartLoaderAnimation',
'epiviz.ui.charts.decoration.ChartResize'
]
},
plot: {
width: 400,
height: 400,
margins: new epiviz.ui.charts.Margins(15, 30, 30, 15),
decorations: [
'epiviz.ui.charts.decoration.ToggleTooltipButton',
'epiviz.ui.charts.decoration.ChartTooltip',
'epiviz.ui.charts.decoration.ChartFilterCodeButton'
]
},
track: {
width: 900,
height: 90,
margins: new epiviz.ui.charts.Margins(25, 40, 23, 10),
decorations: [
'epiviz.ui.charts.decoration.ToggleTooltipButton',
'epiviz.ui.charts.decoration.ChartTooltip',
'epiviz.ui.charts.decoration.ChartFilterCodeButton'
]
},
'epiviz.plugins.charts.GenesTrack': {
height: 120,
colors: 'genes-default'
},
},
chartCustomSettings: {
'epiviz.plugins.charts.GenesTrack': {
},
},
colorPalettes: [
new epiviz.ui.charts.ColorPalette(
['#025167', '#e7003e', '#ffcd00', '#057d9f', '#970026', '#ffe373', '#ff8100'],
'Epiviz v1.0 Colors', 'epiviz-v1'),
new epiviz.ui.charts.ColorPalette(
['#1859a9', '#ed2d2e', '#008c47', '#010101', '#f37d22', '#662c91', '#a11d20', '#b33893'],
'Epiviz v2.0 Bright', 'epiviz-v2-bright'),
new epiviz.ui.charts.ColorPalette(
['#b8d2eb', '#f2aeac', '#d8e4aa', '#cccccc', '#f2d1b0', '#d4b2d3', '#ddb8a9', '#ebbfd9'],
'Epiviz v2.0 Light', 'epiviz-v2-light'),
new epiviz.ui.charts.ColorPalette(
['#599ad3', '#f1595f', '#79c36a', '#727272', '#f9a65a', '#9e66ab', '#cd7058', '#d77fb3'],
'Epiviz v2.0 Medium', 'epiviz-v2-medium'),
new epiviz.ui.charts.ColorPalette(
["#1f77b4", "#ff7f0e", "#2ca02c", "#d62728", "#9467bd", "#8c564b", "#e377c2", "#7f7f7f", "#bcbd22", "#17becf"],
'D3 Category 10', 'd3-category10'),
new epiviz.ui.charts.ColorPalette(
["#1f77b4", "#aec7e8", "#ff7f0e", "#ffbb78", "#2ca02c", "#98df8a", "#d62728", "#ff9896", "#9467bd", "#c5b0d5", "#8c564b", "#c49c94", "#e377c2", "#f7b6d2", "#7f7f7f", "#c7c7c7", "#bcbd22", "#dbdb8d", "#17becf", "#9edae5"],
'D3 Category 20', 'd3-category20'),
new epiviz.ui.charts.ColorPalette(
["#393b79", "#5254a3", "#6b6ecf", "#9c9ede", "#637939", "#8ca252", "#b5cf6b", "#cedb9c", "#8c6d31", "#bd9e39", "#e7ba52", "#e7cb94", "#843c39", "#ad494a", "#d6616b", "#e7969c", "#7b4173", "#a55194", "#ce6dbd", "#de9ed6"],
'D3 Category 20b', 'd3-category20b'),
new epiviz.ui.charts.ColorPalette(
["#3182bd", "#6baed6", "#9ecae1", "#c6dbef", "#e6550d", "#fd8d3c", "#fdae6b", "#fdd0a2", "#31a354", "#74c476", "#a1d99b", "#c7e9c0", "#756bb1", "#9e9ac8", "#bcbddc", "#dadaeb", "#636363", "#969696", "#bdbdbd", "#d9d9d9"],
'D3 Category 20c', 'd3-category20c'),
new epiviz.ui.charts.ColorPalette(
['#f9a65a', '#599ad3', '#79c36a', '#f1595f', '#727272', '#cd7058', '#d77fb3'],
'Genes Default', 'genes-default'),
new epiviz.ui.charts.ColorPalette(
['#1859a9', '#ed2d2e', '#008c47', '#010101', '#f37d22', '#662c91', '#a11d20', '#b33893'],
'Heatmap Default', 'heatmap-default')
]
};
return epiviz.Config.SETTINGS;
}
}
}
}
static get observers() {
return []
}
constructor() {
super();
}
connectedCallback() {
super.connectedCallback();
var self = this;
if (self.useDefaultDataProvider) {
self.measurements = self.measurements || [{
'id': 'genes',
'name': 'genes',
'type': 'range',
'datasourceId': 'genes',
'datasourceGroup': 'genes',
'dataprovider': 'umd',
'formula': null,
'defaultChartType': "Genes Track",
'annotation': null,
'minValue': null,
'maxValue': null,
'metadata': ['gene', 'exon_starts', 'exon_ends']
}];
self.range = self.range || new epiviz.datatypes.GenomicRange("chr11", 80000000, 3000000);
// self._measurementsChanged();
var chartMeasMap = {};
chartMeasMap[self.plotId] = self.visConfigSelection.measurements;
var dataProviderFactory = new epiviz.data.DataProviderFactory(self.config);
var dataManager = new epiviz.data.DataManager(self.config, dataProviderFactory);
dataManager.getData(self.range, chartMeasMap, function (id, data) {
self.data = data;
});
}
self._initializeGrid();
self._measurementsChanged();
}
disconnectedCallback() {
super.disconnectedCallback();
}
ready() {
super.ready();
this.plotId = self.plotId || this._generatePlotId();
// this.scopeSubtree(this.$.chart, true);
this.config = new epiviz.Config(this.configSrc);
}
/**
* Draws the chart.
*
* @param {Object<epiviz.datatypes.GenomicRange>} range genomic range.
* @param {Object<epiviz.datatypes.MapGenomicData>} data to plot
*/
_draw() {
var self = this;
if(this.data) {
if (this.canvas) {
this.chart.drawCanvas(this.range, this.data);
}
else {
this.chart.draw(this.range, this.data);
}
self.chart._propagateNavigationChanges.addListener(new epiviz.events.EventListener(function(e) {
self.dispatchEvent(new CustomEvent('GenesTrackRangeUpdate',
{
detail: {
id: e.id,
range: e.range,
},
bubbles: true
}
)
);
}));
this.shadowRoot.querySelector("paper-spinner-lite").active = false;
}
}
/**
* Creates an instance of the genes track chart.
*
* @return {epiviz.plugins.charts.GenesTrackType} BlocksTrack chart object
*/
_createChart() {
return new epiviz.plugins.charts.GenesTrackType(new epiviz.Config(this.configSrc));
}
};
customElements.define(EpivizGenesTrack.is, EpivizGenesTrack);
</script>
</dom-module>