Skip to content

Commit f92cdc2

Browse files
committed
Respect rgb colors in bedpe files. Fixes #1935
1 parent 8c69387 commit f92cdc2

File tree

3 files changed

+70
-7
lines changed

3 files changed

+70
-7
lines changed

dev/interact/bedpe-color.html

+50
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
<!DOCTYPE html>
2+
<html lang="en">
3+
<head>
4+
<meta charset="utf-8">
5+
<meta content="IE=edge" http-equiv="X-UA-Compatible">
6+
<meta content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no" name="viewport">
7+
<meta content="" name="description">
8+
<meta content="" name="author">
9+
<link href=https://igv.org/web/img/favicon.ico rel="shortcut icon">
10+
<title>IGV - Dev</title>
11+
12+
</head>
13+
14+
<body>
15+
16+
<h1>CTCF Loops</h1>
17+
18+
<div id="igvDiv" style="padding-top: 50px;padding-bottom: 20px; height: auto"></div>
19+
20+
<script type="module">
21+
22+
import igv from "../../js";
23+
24+
var options =
25+
{
26+
genome: "hg38",
27+
locus: "chr13:33,981,486-34,180,985",
28+
tracks: [
29+
{
30+
url: "../../test/data/bedpe/bedpe_with_colors.bedpe",
31+
type: "interact",
32+
format: "bedpe"
33+
}
34+
]
35+
};
36+
37+
var igvDiv = document.getElementById("igvDiv");
38+
39+
igv.createBrowser(igvDiv, options)
40+
.then(function (browser) {
41+
console.log("Created IGV browser");
42+
window.igvBrowser = browser;
43+
})
44+
45+
46+
</script>
47+
48+
</body>
49+
50+
</html>

js/feature/interactionTrack.js

+15-7
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,6 @@ class InteractionTrack extends TrackBase {
6060
showBlocks: true,
6161
blockHeight: 3,
6262
thickness: 1,
63-
color: "rgb(180,25,137)",
6463
alpha: 0.02,
6564
logScale: true,
6665
}
@@ -74,11 +73,11 @@ class InteractionTrack extends TrackBase {
7473
super.init(config)
7574

7675
// Backward compatibility hack, arcOrientation was previously a boolean, now a string
77-
if(config.arcOrientation === false) {
76+
if (config.arcOrientation === false) {
7877
this.arcOrientation = "DOWN"
79-
} else if(config.arcOrientation === true) {
78+
} else if (config.arcOrientation === true) {
8079
this.arcOrientation = "UP"
81-
} else if(config.arcOrientation) {
80+
} else if (config.arcOrientation) {
8281
this.arcOrientation = config.arcOrientation.toUpperCase()
8382
} else {
8483
this.arcOrientation = "UP"
@@ -141,7 +140,7 @@ class InteractionTrack extends TrackBase {
141140
}
142141

143142
get supportsWholeGenome() {
144-
return typeof this.featureSource.supportsWholeGenome === 'function' ? this.featureSource.supportsWholeGenome() : true;
143+
return typeof this.featureSource.supportsWholeGenome === 'function' ? this.featureSource.supportsWholeGenome() : true
145144
}
146145

147146
async getFeatures(chr, start, end) {
@@ -394,8 +393,17 @@ class InteractionTrack extends TrackBase {
394393
// }
395394

396395
const counterClockwise = direction
397-
const color = feature.color || this.color
398-
ctx.strokeStyle = color
396+
397+
let color
398+
if (typeof this.color === 'function') {
399+
color = this.color(feature)
400+
} else {
401+
color = this.color || feature.color || DEFAULT_ARC_COLOR
402+
}
403+
404+
const strokeColor = this.config.useScore ? getAlphaColor(color, scoreShade(feature.score)) : color
405+
406+
ctx.strokeStyle = strokeColor
399407
ctx.lineWidth = feature.thickness || this.thickness || 1
400408

401409
if (true === ctx.isSVG) {
+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
#columns color=11;thickness=12
2+
chr13 34129457 34132233 chr13 34146252 34151608 . . . . 204,204,204 1.105
3+
chr13 34074145 34080582 chr13 34146252 34151608 . . . . 255,165,0 0.678
4+
chr13 34033313 34041197 chr13 34146252 34151608 . . . . 204,204,204 0.9400000000000001
5+
chr13 34002097 34003021 chr13 34146252 34151608 . . . . 204,204,204 5

0 commit comments

Comments
 (0)