-
Notifications
You must be signed in to change notification settings - Fork 2
/
epiviz-genes-table.html
174 lines (145 loc) · 5.71 KB
/
epiviz-genes-table.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
<!-- 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"> -->
<link rel="import" href="epiviz-genes-track.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">
<!-- 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-table>` displays a table for a list of genes in the given genomic region. This component extends the
`epiviz-genes-track` element
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-table></epiviz-genes-table>
@demo demo/index-genes-table.html Example page showing a genes table
-->
<dom-module id="epiviz-genes-table">
<!--<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;
}
table.gridtable {
height: 100%;
width: 100%;
margin-left: 10px;
grid-column: span 4;
border-collapse: collapse;
border-spacing: 0;
border: 1px solid #eee;
border-bottom: 2px solid #4285f4;
}
th,
td {
/* color: #999; */
/* border: 1px solid #eee; */
padding: 7px 14px;
border-collapse: collapse;
text-align: center;
white-space: nowrap;
}
tr,
thead,
th {
border: 1px solid #eee;
}
</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">
<div id="{{plotId}}">
</div>
<table class="gridtable">
<thead>
<tr>
<th>Gene </th>
<th>Start</th>
<th>End</th>
</tr>
</thead>
<tbody>
<template is="dom-repeat" items="[[geneTable]]" as="row" initial-count="30">
<tr>
<td>[[row.gene]]</td>
<td>[[row.start]]</td>
<td>[[row.end]]</td>
</tr>
</template>
</tbody>
</table>
</div>
</template>
<script>
// Extend Polymer.Element base class
// EpivizChartRemoveBehavior(EpivizChartColorsBehavior(EpivizChartSettingsBehavior(EpivizChartBehavior(Polymer.Element))))
class EpivizGenesTable extends EpivizGenesTrack {
static get is() { return 'epiviz-genes-table'; }
static get properties() {
return {
geneTable: {
type: Array,
notify: true
}
}
}
constructor() {
super();
}
/**
* Draws the chart.
*
* @param {Object<epiviz.datatypes.GenomicRange>} range genomic range.
* @param {Object<epiviz.datatypes.MapGenomicData>} data to plot
*/
_draw() {
var series = this.data.firstSeries();
var indices = epiviz.utils.range(series.size());
var geneTable = [];
var dataItems = indices
.map(function (i) {
var cell = series.get(i);
var item = cell.rowItem;
geneTable.push({
"gene": item.metadata("gene"),
"start": item.start(),
"end": item.end(),
"exonStarts": JSON.stringify(item.metadata('exon_starts').split(',').map(function (s) { return parseInt(s); })),
"exonEnds": JSON.stringify(item.metadata('exon_ends').split(',').map(function (s) { return parseInt(s); }))
});
});
this.set("geneTable", geneTable);
this.shadowRoot.querySelector("paper-spinner-lite").active = false;
}
};
customElements.define(EpivizGenesTable.is, EpivizGenesTable);
</script>
</dom-module>