Skip to content

Commit 8d15c85

Browse files
committed
Link each eQTL histogram bars to region covered by that bar.
Faciliatte rudimentary zoom in to eqtl of interest in a region.
1 parent 583bbd7 commit 8d15c85

File tree

1 file changed

+24
-2
lines changed

1 file changed

+24
-2
lines changed

src/components/histogram/EqtlCount.vue

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,10 @@ export default {
9494
this.eqtlData = response.data
9595
this.eqtlDataBinned = this.bin_data(response.data, this.start, this.stop)
9696
.filter((ele) => ele.length > 0)
97+
this.eqtlDataBinned.forEach((ele, idx, arr)=> {
98+
arr[idx].href=`region.html?chrom=${ele[0].chrom}&start=${ele.x0}&stop=${ele.x1}`
99+
})
100+
97101
this.draw()
98102
})
99103
},
@@ -121,6 +125,16 @@ export default {
121125
let binned = binner(eqtl_data)
122126
return binned
123127
},
128+
fill_rect_attrs: function(rect, x_scale, y_scale){
129+
rect
130+
.attr("x", (d) => x_scale(d.x0))
131+
.attr("width", (d) => x_scale(d.x1) - x_scale(d.x0))
132+
.attr("y", (d) => `${100 - y_scale(d.length)}%`)
133+
.attr("height", (d) => `${y_scale(d.length)}%`)
134+
.style("stroke", "blue")
135+
.style("stroke-width", "1px")
136+
.style("fill", "lightblue")
137+
},
124138
draw: function(){
125139
const svg = d3.select("#eqtlHist")
126140
const aggs = svg.select("#eqtlAggregated")
@@ -160,18 +174,26 @@ export default {
160174
161175
aggs.selectAll("rect")
162176
.data(this.eqtlDataBinned)
177+
.join(
178+
enter => {
179+
let sel = enter.append("a").attr("href", (d) => d.href)
180+
sel.append("rect").call(this.fill_rect_attrs, x_scale, y_scale)
181+
return sel
182+
},
183+
update => update,
184+
exit => exit.remove()
185+
)
163186
.join("rect")
164187
.attr("x", (d) => x_scale(d.x0))
165188
.attr("width", (d) => x_scale(d.x1) - x_scale(d.x0))
166-
.attr("y", (d) => `${100 - y_scale(d.length)}%`)
189+
.attr("y", (d) => `${100 - y_scale(d.length)}%`)
167190
.attr("height", (d) => `${y_scale(d.length)}%`)
168191
.style("stroke", "blue")
169192
.style("stroke-width", "1px")
170193
.style("fill", "lightblue")
171194
},
172195
debouncedDraw: debounce(function(){
173196
this.draw()
174-
console.log("debounced eqtl draw")
175197
}, 50),
176198
},
177199
mounted: function(){

0 commit comments

Comments
 (0)