-
Notifications
You must be signed in to change notification settings - Fork 0
/
drugPage.php
173 lines (156 loc) · 6.16 KB
/
drugPage.php
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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Search Engine</title>
<!--Adding the d3 javaascript-->
<script type="text/javascript" src="d3.min.js"></script>
<!--Adding the stylesheet for jquery-->
<link rel="stylesheet" href="http://code.jquery.com/ui/1.11.1/themes/smoothness/jquery-ui.css">
<script src="http://code.jquery.com/jquery-1.10.2.js"></script>
<script src="http://code.jquery.com/ui/1.11.1/jquery-ui.js"></script>
<script type='text/javascript' src='DAT.GUI.min.js'></script>
<style type="text/css">
rect {
-moz-transition: all 0.3s;
-o-transition: all 0.3s;
-webkit-transition: all 0.3s;
transition: all 0.3s;
}
/*hover function*/
rect:hover {
fill: orange;
}
body {
background-image:url(gray_jean/gray_jean.png)
}
h1 {
position: relative;
left: 1%;
top: 2%;
font-size: 50px;
}
</style>
</head>
<body>
<body>
<table id="myTable" border="1">
<tr>
<td>DRUG</td>
<td>Adverse Risk</td>
<td>No Adverse Risk</td>
</tr>
<tr>
<td>Exposed to Drug</td>
<td> </td>
<td> </td>
</tr>
<tr>
<td>Not Exposed to Drug</td>
<td> </td>
<td> </td>
</tr>
</table>
<form>
<input type="button" onclick="changeContent()" value="Next Drug">
</form>
</body>
<script type="text/javascript">
var dL = [
<?php
$drugList = array();
$myfile = fopen("mwasData.txt", "r") or die("Unable to open file!"); // pre-processed (first 9 columns)
if ($myfile) {
while (($line = fgets($myfile)) !== false) {
$x = explode(chr(9), $line); // Tab = Ascii 9
$RANK = $x[0];
$MIN_DETECTABLE_RR = $x[1];
$SOURCE_ID = $x[2];
$DRUG_CONCEPT_ID = $x[3];
$CONDITION_CONCEPT_ID = $x[4];
$GROUND_TRUTH = $x[5];
$LOGRR = $x[6];
$LOGLB95RR = $x[7];
$P = $x[8];
$DRUG = array(
$RANK,
$MIN_DETECTABLE_RR,
$SOURCE_ID,
$DRUG_CONCEPT_ID,
$CONDITION_CONCEPT_ID,
$GROUND_TRUTH,
$LOGRR,
$LOGLB95RR,
$P
);
array_push($drugList, $DRUG);
}
} else {
echo "Error reading File";
}
fclose($myfile);
echo json_encode($drugList);
?>
];
//console.log(typeof(parseInt(dL[0][2][2])));
//Define Variables
barHeight = 20;
var w = 5000;
var h = 10; // Height to include every entry
var buffer = 15;
var textbuffer = 40
var svg = d3.select("body")
.append("svg")
.attr({
width: w,
height: h,
});
//console.log(dL[0]);
//Function to make Bars
var makeBars = function() {
svg.selectAll("rect")
.data(dL[0])
.enter()
.append("rect")
.attr({
//width: 100,
width: function(d,i) {
if (!isNaN(parseInt(d[8]))){
return parseInt(d[8])*100
}
}, //GROUND_TRUTH = d[5], LOGRR = d[6]
height: 100000,
fill: function(d){
return "rgb(100, 150, 100)";
},
y: function(d, i) {return i*1000}, // Adjust input for proper spacing
x: 100
})
//Adding the mouseOver function - Hover to highlight
.on("mouseover", function(d) {
var xPosition = (xScale(d3.select(this).attr("width")));
var yPosition = 300 + parseFloat(d3.select(this).attr("y"));
d3.select("#tooltip")
.style("right", xPosition + "px")
.style("top", yPosition + "px")
.select("#value")
.text(getRelativeEnrichments(d, queryList));
//.text(d)
d3.select("#tooltip").classed("hidden", false);
})
.on("mouseout", function() {
d3.select("#tooltip").classed("hidden", true);
})
}
makeBars();
var i = 0
function changeContent(){
var x=document.getElementById('myTable').rows
var header =x[0].cells //
header[0].innerHTML=dL[0][i][0]
var drug = x[1].cells
drug[0].innerHTML = "drug"
drug[1].innerHTML = "drug2"
}
</script>
</body>