Skip to content

Commit

Permalink
Merged track issues (#1866)
Browse files Browse the repository at this point in the history
Fix some issues with merged tracks.   Autoscale for merged and individual track settings could conflict.
  • Loading branch information
jrobinso authored Aug 7, 2024
1 parent c8fdb0e commit e0c29cb
Show file tree
Hide file tree
Showing 12 changed files with 271 additions and 154 deletions.
70 changes: 53 additions & 17 deletions dev/wig/merged.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
</head>

<body>
<button id="log-state">Log Session</button>
<button id="bookmark">Bookmark</button>

<h1>Merged track</h1>

Expand All @@ -22,25 +24,12 @@ <h1>Merged track</h1>

var options =
{
queryParametersSupported: true,
genome: "hg19",
locus: "chr4:40,174,668-40,221,204",
tracks: [
// {
// "type": "wig",
// "format": "bigwig",
// "url": "https://www.encodeproject.org/files/ENCFF000ASJ/@@download/ENCFF000ASJ.bigWig",
// "color": "red",
// "name": "ENCFF000ASJ"
// },
// {
// "type": "wig",
// "format": "bigwig",
// "url": "https://www.encodeproject.org/files/ENCFF351WPV/@@download/ENCFF351WPV.bigWig",
// "color": "green",
// "name": "ENCFF351WPV"
// },
{
name: "Merged - group autoscaled",
name: "Merged - autoscaled",
type: "merged",
autoscale: true,
tracks: [
Expand All @@ -58,6 +47,26 @@ <h1>Merged track</h1>
}
]
},
{
name: "Merged - fixed scale",
type: "merged",
min: 0,
max: 100,
tracks: [
{
"type": "wig",
"format": "bigwig",
"url": "https://www.encodeproject.org/files/ENCFF000ASJ/@@download/ENCFF000ASJ.bigWig",
"color": "red"
},
{
"type": "wig",
"format": "bigwig",
"url": "https://www.encodeproject.org/files/ENCFF351WPV/@@download/ENCFF351WPV.bigWig",
"color": "green"
}
]
},
{
name: "Merged - individual autoscaled",
type: "merged",
Expand All @@ -77,15 +86,42 @@ <h1>Merged track</h1>
"autoscale": true
}
]
}
},
{
name: "Merged - individual fixed scale",
type: "merged",
tracks: [
{
"type": "wig",
"format": "bigwig",
"url": "https://www.encodeproject.org/files/ENCFF000ASJ/@@download/ENCFF000ASJ.bigWig",
"color": "red",
"max": 100
},
{
"type": "wig",
"format": "bigwig",
"url": "https://www.encodeproject.org/files/ENCFF351WPV/@@download/ENCFF351WPV.bigWig",
"color": "green",
"max": 50
}
]
},
]
}

var igvDiv = document.getElementById("igvDiv")

igv.createBrowser(igvDiv, options)
.then(function (browser) {
console.log("Created IGV browser")
document.getElementById("log-state").addEventListener("click", () => console.log(browser.toJSON()))

document.getElementById('bookmark').addEventListener('click', () => {
const path = window.location.href.slice()
const idx = path.indexOf("?")
const url = (idx > 0 ? path.substring(0, idx) : path) + "?sessionURL=blob:" + browser.compressedSession()
window.history.pushState({}, "IGV", url)
})
})


Expand Down
22 changes: 21 additions & 1 deletion examples/mergedWig.html
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,27 @@ <h1>Merged track</h1>
"color": "green"
}
]
}
},
{
name: "Merged - individual autoscaled",
type: "merged",
tracks: [
{
"type": "wig",
"format": "bigwig",
"url": "https://www.encodeproject.org/files/ENCFF000ASJ/@@download/ENCFF000ASJ.bigWig",
"color": "red",
"autoscale": true
},
{
"type": "wig",
"format": "bigwig",
"url": "https://www.encodeproject.org/files/ENCFF351WPV/@@download/ENCFF351WPV.bigWig",
"color": "green",
"autoscale": true
}
]
},
]
}

Expand Down
35 changes: 33 additions & 2 deletions examples/spliceJunctions.html
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,41 @@ <h1>Splice junctions</h1>

<script type="module">

import igv from "../dist/igv.esm.js";
import igv from "../dist/igv.esm.min.js"

const tracks = [
{
type: 'junction',
name: 'Junctions',
format: 'bed',
url: `https://www.dropbox.com/s/nvmy55hhe24plpv/splice_junction_track_test_cases_sampleA.chr15-92835700-93031800.SJ.out.bed.gz?dl=0`,
indexURL: `https://www.dropbox.com/s/iv5tcg3t8v3xu23/splice_junction_track_test_cases_sampleA.chr15-92835700-93031800.SJ.out.bed.gz.tbi?dl=0`,
displayMode: 'COLLAPSED',
minUniquelyMappedReads: 1,
minTotalReads: 1,
maxFractionMultiMappedReads: 1,
minSplicedAlignmentOverhang: 0,
thicknessBasedOn: 'numUniqueReads', //options: numUniqueReads (default), numReads, isAnnotatedJunction
bounceHeightBasedOn: 'random', //options: random (default), distance, thickness
colorBy: 'isAnnotatedJunction', //options: numUniqueReads (default), numReads, isAnnotatedJunction, strand, motif
labelUniqueReadCount: true,
labelMultiMappedReadCount: true,
labelTotalReadCount: false,
labelMotif: false,
labelIsAnnotatedJunction: " [A]",
hideAnnotatedJunctions: false,
hideUnannotatedJunctions: false,
hideMotifs: ['GT/AT', 'non-canonical'], //options: 'GT/AG', 'CT/AC', 'GC/AG', 'CT/GC', 'AT/AC', 'GT/AT', 'non-canonical'
},
{
type: 'wig',
name: 'Coverage',
format: "bigwig",
url: 'https://www.dropbox.com/s/8j2uf0hsqprusnc/splice_junction_track_test_cases_sampleA.chr15-92835700-93031800.bigWig?dl=0',
},
{
type: 'merged',
name: 'Splice Junctions',
name: 'Junctions + Coverage',
height: 150,
tracks: [
{
Expand All @@ -43,12 +72,14 @@ <h1>Splice junctions</h1>
hideAnnotatedJunctions: false,
hideUnannotatedJunctions: false,
hideMotifs: ['GT/AT', 'non-canonical'], //options: 'GT/AG', 'CT/AC', 'GC/AG', 'CT/GC', 'AT/AC', 'GT/AT', 'non-canonical'
height: 150
},
{
type: 'wig',
name: 'Coverage',
format: "bigwig",
url: 'https://www.dropbox.com/s/8j2uf0hsqprusnc/splice_junction_track_test_cases_sampleA.chr15-92835700-93031800.bigWig?dl=0',
height: 150
}
]
}
Expand Down
1 change: 1 addition & 0 deletions js/bam/coverageTrack.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ class CoverageTrack {


constructor(config, parent) {
this.featureType = 'numeric'
this.parent = parent
this.featureSource = parent.featureSource

Expand Down
4 changes: 2 additions & 2 deletions js/cnvpytor/cnvpytorTrack.js
Original file line number Diff line number Diff line change
Expand Up @@ -141,12 +141,12 @@ class CNVPytorTrack extends TrackBase {
if (this.signals.includes(signal_name)) {
let tconf = {}
tconf.type = "wig"
tconf.isMergedTrack = true
tconf.features = wig
tconf.name = signal_name
tconf.color = this.signal_colors.filter(x => x.singal_name === signal_name).map(x => x.color)
const t = await this.browser.createTrack(tconf)
if (t) {
t.isMergedTrack = true
t.autoscale = false // Scaling done from merged track
this.tracks.push(t)
} else {
Expand Down Expand Up @@ -328,12 +328,12 @@ class CNVPytorTrack extends TrackBase {
if (this.signals.includes(signal_name)) {
let tconf = {}
tconf.type = "wig"
tconf.isMergedTrack = true
tconf.features = wig
tconf.name = signal_name
tconf.color = this.signal_colors.filter(x => x.singal_name === signal_name).map(x => x.color)
const t = await this.browser.createTrack(tconf)
if (t) {
t.isMergedTrack = true
t.autoscale = false // Scaling done from merged track
this.tracks.push(t)
} else {
Expand Down
2 changes: 1 addition & 1 deletion js/feature/featureTrack.js
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ class FeatureTrack extends TrackBase {
}


if (!this.config.isMergedTrack) {
if (!this.isMergedTrack) {
IGVGraphics.fillRect(context, 0, options.pixelTop, pixelWidth, pixelHeight, {'fillStyle': "rgb(255, 255, 255)"})
}

Expand Down
Loading

0 comments on commit e0c29cb

Please sign in to comment.