-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathATAC.html
445 lines (412 loc) · 20.1 KB
/
ATAC.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
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>CRE Explorer</title>
<link href="https://fonts.googleapis.com/css?family=Open+Sans:400,700&display=swap" rel="stylesheet">
<!-- Load jQuery -->
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.7.1/jquery.min.js"></script>
<!-- Load Google Charts -->
<script type="text/javascript" src="https://www.gstatic.com/charts/loader.js"></script>
<!-- Load DataTables CSS -->
<link rel="stylesheet" type="text/css" href="https://cdn.datatables.net/1.10.24/css/jquery.dataTables.css">
<!-- Load DataTables JavaScript -->
<script type="text/javascript" charset="utf8" src="https://cdn.datatables.net/1.10.24/js/jquery.dataTables.js"></script>
<!-- Load IGV JavaScript -->
<script type="text/javascript" src="https://cdn.jsdelivr.net/npm/igv@2.15.5/dist/igv.min.js"></script>
<!-- css styling -->
<link rel="stylesheet" type="text/css" href="style1.css">
<style>
header {
background-color: #36016b;
color: white;
padding: 10px 20px;
text-align: center;
}
footer {
background-color: #36016b;
color: white;
padding: 10px 20px;
text-align: center;
}
th {
background-color: #36016b;
color: white;
}
</style>
</head>
<body>
<header>
<h1>CRE Explorer</h1>
<p><em>Exploring Gene-CRE Associations and Genomic Locations in Brain Tissues</em></p>
<nav>
<ul>
<li><a class="menu__item" href="Team-10_database.html">Home</a></li>
<li><a class="menu__item" href="GRN-test.html">GRN</a></li>
<li><a class="menu__item" href="ATAC.html">CRE Explorer</a></li>
<li><a class="menu__item" href="eQTL-data.html">CRE + gene</a></li>
<li><a class="menu__item" href="help.html">Help Page</a></li>
<li><a class="menu__item" href="https://hougroup.xyz/" target="_blank">Hou Lab</a></li>
</ul>
</nav>
</header>
<div class="container">
<div class="search-container">
<h2>Gene Search</h2>
<p>Enter a gene name:</p>
<input type="text" id="gene_name" placeholder="Enter an Entrez ID">
<span class="example-gene">Eg: ENSG00000251727</span>
<h2>Chromosome Search</h2>
<p>Select Chromosome:</p>
<select id="chromosome">
<option value="">Select Chromosome</option>
<option value="chr1">chr1</option>
<option value="chr2">chr2</option>
<option value="chr3">chr3</option>
<option value="chr4">chr4</option>
<option value="chr5">chr5</option>
<option value="chr6">chr6</option>
<option value="chr7">chr7</option>
<option value="chr8">chr8</option>
<option value="chr9">chr9</option>
<option value="chr10">chr10</option>
<option value="chr11">chr11</option>
<option value="chr12">chr12</option>
<option value="chr13">chr13</option>
<option value="chr14">chr14</option>
<option value="chr15">chr15</option>
<option value="chr16">chr16</option>
<option value="chr17">chr17</option>
<option value="chr18">chr18</option>
<option value="chr19">chr19</option>
<option value="chr20">chr20</option>
<option value="chrX">chrX</option>
<option value="chrY">chrY</option>
<option value="GL000195.1">GL000195.1</option>
<option value="GL000219.1">GL000219.1</option>
<option value="KI270733.1">KI270733.1</option>
<option value="KI270713.1">KI270713.1</option>
<option value="GL000205.2">GL000205.2</option>
<option value="GL000225.1">GL000225.1</option>
<option value="GL000220.1">GL000220.1</option>
<option value="KI270727.1">KI270727.1</option>
<option value="KI270442.1">KI270442.1</option>
<option value="GL000216.2">GL000216.2</option>
<option value="KI270744.1">KI270744.1</option>
<option value="GL000194.1">GL000194.1</option>
<option value="KI270750.1">KI270750.1</option>
</select>
<!-- Start position -->
<p>Start Position:</p>
<input type="text" id="start" placeholder="Enter only numeric values">
<!-- End position -->
<p>End Position:</p>
<input type="text" id="end" placeholder="Enter only numeric values">
<div class="button-container">
<button id="PlotBtn" style="background-color: #36016b; color: white; transition: background-color 0.3s; border: none; padding: 10px 20px; cursor: pointer; border-radius: 5px" onmouseover="this.style.backgroundColor='#ad026e'" onmouseout="this.style.backgroundColor='#36016b'">Plot Abundance</button>
<button id="LoadTableBtn" style="background-color: #36016b; color: white; transition: background-color 0.3s; border: none; padding: 10px 20px; cursor: pointer; border-radius: 5px" onmouseover="this.style.backgroundColor='#ad026e'" onmouseout="this.style.backgroundColor='#36016b'">Load CRE table</button>
<button id="DownloadTxtBtn" style="background-color: #36016b; color: white; transition: background-color 0.3s; border: none; padding: 10px 20px; cursor: pointer; border-radius: 5px" onmouseover="this.style.backgroundColor='#ad026e'" onmouseout="this.style.backgroundColor='#36016b'">Download</button>
<button id="LoadIGVBtn" style="background-color: #36016b; color: white; transition: background-color 0.3s; border: none; padding: 10px 20px; cursor: pointer; border-radius: 5px" onmouseover="this.style.backgroundColor='#ad026e'" onmouseout="this.style.backgroundColor='#36016b'">Load in IGV</button>
</div>
<div class="chart-container">
<div id="PieChart" style="height: 400px;"></div>
</div>
<div id="PieTable"></div>
<div id="igvDiv"></div>
</div>
</div>
<footer>
<p> © cEpiReg Database</p>
</footer>
<script>
// JavaScript code
$(document).ready(function(){
var igvBrowser;
var additionalTracksLoaded = false;
// Event listener for Load IGV button
$("#LoadIGVBtn").click(function(){
var geneName = $("#gene_name").val();
var chromosome = $("#chromosome").val();
var start = $("#start").val();
var end = $("#end").val();
var locus;
// Check if chromosome and start-end positions are provided
if (chromosome && start && end) {
locus = chromosome + ":" + start + "-" + end;
}
// Check if chromosome and start-end positions are provided
if (chromosome) {
locus = chromosome;
}
// Check if gene name is provided
else if (geneName) {
locus = geneName;
}
// If neither gene name nor chromosome is provided
else {
alert("Please provide either a gene name or a chromosome number.");
return;
}
// Additional tracks
var additionalTracks = [
{ // ENCODE: BED file track
name: "ENCODE_CREs",
type: "annotation",
format:"bed",
url: 'https://downloads.wenglab.org/cCREs/GRCh38-PLS.bed'
},
{ // Epimap: Enhancers file track
name: "Epimap_Enhancers",
type: "annotation",
format:"bed",
url: 'https://bioed.bu.edu/students_24/Team_10/ENH_masterlist_locations.bed'
},
{ // Epimap: Promoters file track
name: "Epimap_Promoters",
type: "annotation",
format:"bed",
url: 'https://bioed.bu.edu/students_24/Team_10/PROM_masterlist_locations.bed'
},
{ // Brain:Bed file track
name: "Brain_Peaks",
type: "annotation",
format:"bed",
url: 'https://bioed.bu.edu/students_24/Team_10/GSM5589415_UMB4540_snATAC_frontal_cortex_rep2_fragments_summits.bed'
}
];
// Check if an IGV browser instance already exists
if (igvBrowser) {
// Refresh the existing IGV browser with new parameters
igvBrowser.search(locus).then(function () {
if (!additionalTracksLoaded) {
// Add additional tracks
igvBrowser.loadTrackList(additionalTracks);
additionalTracksLoaded = true; // Set the flag to true to indicate that additional tracks have been loaded
}
});
} else {
// Create IGV browser
igv.createBrowser($("#igvDiv")[0], {
genome: "hg38", // Specify the genome assembly
locus: locus, // Specify the genomic region or gene name
tracks: additionalTracks
}).then(function (browser) {
console.log("IGV browser initialized:", browser);
// Save the browser object for future use
igvBrowser = browser;
additionalTracksLoaded = true;
});
}
});
var dataTable;
function drawPieChart(data) {
console.log("Function drawPieChart() called.");
console.log("Received pie chart data:", data);
if (!data || data.length === 0 || data[0][0] === "No data found") {
document.getElementById('PieChart').innerHTML = 'No data available';
return;
}
google.charts.load('current', {'packages':['corechart']});
google.charts.setOnLoadCallback(function(){
var chartData = new google.visualization.DataTable();
chartData.addColumn('string', 'Type');
chartData.addColumn('number', 'Counts');
for (var i = 0; i < data.length; i++) {
chartData.addRow([data[i][0], data[i][1]]);
}
var options = {
title: 'Pie Chart of CREs linked to gene ' + $("#gene_name").val(),
legend: { position: 'right' },
is3D: true,
width: '900px', // Set the width to 100% of the container
height: '500px' // Set the height to your desired value
};
var chartTitle;
var geneName = $("#gene_name").val();
var chromosome = $("#chromosome").val();
var start = $("#start").val();
var end = $("#end").val();
if (geneName) {
chartTitle = "Pie Chart of CREs linked to " + geneName;
} else if (chromosome && start && end) {
chartTitle = "Pie Chart of CREs present in the region " + chromosome + " : " + start + " - " + end;
} else if (chromosome) {
chartTitle = "Pie Chart of CREs present in " + chromosome;
} else {
chartTitle = "Pie Chart";
}
options.title = chartTitle;
var chart = new google.visualization.PieChart(document.getElementById('PieChart'));
chart.draw(chartData, options);
});
}
function drawTable(data) {
console.log("Received table data:", data);
var geneName = $("#gene_name").val();
var chromosome = $("#chromosome").val();
var tableHtml = '';
var start = $("#start").val();
var end = $("#end").val();
if (data.length === 1 && data[0][0] === "No data found") {
tableHtml = '<h3>No data available</h3>';
} else {
tableHtml = '<h3>Table of CREs';
// Check if both gene name and chromosome are entered
if (geneName && chromosome && start && end) {
tableHtml += ' linked to ' + geneName + ' and ' + chromosome + ' : ' + start + ' - ' + end;
} else if (chromosome && start && end) {
tableHtml += ' linked to ' + chromosome + ' : ' + start + ' - ' + end;
} else if (chromosome && geneName) {
tableHtml += ' linked to ' + geneName + ' and ' + chromosome;
} else if (geneName && start && end) {
tableHtml += ' linked to ' + geneName + ' : ' + start + ' - ' + end;
} else if (geneName) {
tableHtml += ' linked to ' + geneName;
} else if (chromosome) {
tableHtml += ' linked to ' + chromosome;
}
tableHtml += '</h3>';
tableHtml += '<table id="dataTable" class="display"><thead><tr><th>Chr</th><th>Start</th><th>End</th><th>Peak Score</th><th>Annotation</th><th>Detailed Annotation</th><th>Distance to TSS</th><th>Nearest PromoterID</th><th>Entrez ID</th><th>Gene Name</th><th>Gene Type</th></tr></thead><tbody>';
for (var i = 0; i < data.length; i++) {
tableHtml += '<tr><td>' + data[i][0] + '</td><td>' + data[i][1] + '</td><td>' + data[i][2] + '</td><td>' + data[i][3] + '</td><td>' + data[i][4] + '</td><td>' + data[i][5] + '</td><td>' + data[i][6] + '</td><td>' + data[i][7] + '</td><td>' + data[i][8] + '</td><td>' + data[i][9] + '</td><td>' + data[i][10] + '</td></tr>';
}
tableHtml += '</tbody></table>';
}
$('#PieTable').html(tableHtml);
// Initialize DataTable
if (data.length > 0) {
dataTable = $('#dataTable').DataTable();
}
}
// AJAX request for pie chart data
$("#PlotBtn").click(function(){
var gene_name = $("#gene_name").val();
var chromosome = $("#chromosome").val();
var start = $("#start").val();
var end = $("#end").val();
// Check if any of the required fields is empty
if (!gene_name && !chromosome ) {
alert("Please provide either a gene name or a chromosome number.");
return; // Exit the function
}
if (gene_name) {
$.ajax({
type: "POST",
url: "https://bioed.bu.edu/cgi-bin/students_24/Team_10/ATAC_AJAX.py",
data: { gene_name: gene_name, chromosome: chromosome, selector: "Pie" , start: start, end: end },
success: function(data){
if (data.error) {
$("#PieChart").html("There was no CRE associated with the gene " + gene_name);
} else {
drawPieChart(data);
}
},
error: function(){
alert("Error in AJAX request for pie chart data.");
}
});
} else if (chromosome) {
$.ajax({
type: "POST",
url: "https://bioed.bu.edu/cgi-bin/students_24/Team_10/ATAC_AJAX.py",
data: { gene_name: gene_name, chromosome: chromosome, selector: "Pie", start: start, end: end },
success: function(data){
if (data.error) {
$("#PieChart").html("There was no data available for the selected chromosome.");
} else {
drawPieChart(data);
}
},
error: function(){
alert("Error in AJAX request for pie chart data.");
}
});
}
});
// AJAX request for table data
$("#LoadTableBtn").click(function(){
var gene_name = $("#gene_name").val();
var chromosome = $("#chromosome").val();
var start = $("#start").val();
var end = $("#end").val();
if (!gene_name && !chromosome ) {
alert("Please provide either a gene name or a chromosome number.");
return; // Exit the function
}
if (gene_name) {
$.ajax({
type: "POST",
url: "https://bioed.bu.edu/cgi-bin/students_24/Team_10/ATAC_AJAX.py",
data: { gene_name: gene_name, chromosome: chromosome, selector: "Table", start: start, end: end },
success: function(data){
if (data.error) {
$("#PieTable").html("There was no CRE associated with the gene " + gene_name);
} else {
drawTable(data);
}
},
error: function(){
alert("Error in AJAX request for table data.");
}
});
} else if (chromosome) {
$.ajax({
type: "POST",
url: "https://bioed.bu.edu/cgi-bin/students_24/Team_10/ATAC_AJAX.py",
data: { gene_name: gene_name, chromosome: chromosome, selector: "Table", start: start, end: end },
success: function(data){
console.log("Data got back:", data);
if (data.error) {
$("#PieTable").html("There was no data available for the selected chromosome.");
} else {
drawTable(data);
}
},
error: function(){
alert("Error in AJAX request for table data.");
}
});
}
});
// Event listener for download TXT button
$("#DownloadTxtBtn").click(function() {
var gene_name = $("#gene_name").val();
var chromosome = $("#chromosome").val();
var start = $("#start").val();
var end = $("#end").val();
// Check if neither gene name nor chromosome is entered
if (!gene_name && !chromosome) {
alert("Please provide either a gene name or a chromosome number.");
return; // Exit the function
}
// AJAX request for downloading TXT
$.ajax({
type: "POST",
url: "https://bioed.bu.edu/cgi-bin/students_24/Team_10/ATAC_AJAX.py",
data: {
selector: "Download",
gene_name: $("#gene_name").val(),
chromosome: $("#chromosome").val(),
start: $("#start").val(),
end: $("#end").val()
},
success: function(data){
// Create a temporary link element
var link = document.createElement("a");
// Set the href attribute to the file content
link.href = "data:text/plain;charset=utf-8," + encodeURIComponent(data);
// Set the download attribute to specify the filename
link.download = "table_data.txt";
// Trigger the click event to initiate the download
link.click();
},
error: function(){
alert("Error in AJAX request for downloading TXT.");
}
});
});
});
</script>
</body>
</html>