Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

* Add support for user settable window function (wig track) #1734

Merged
merged 1 commit into from
Nov 18, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
52 changes: 0 additions & 52 deletions dev/wig/encode.html

This file was deleted.

83 changes: 83 additions & 0 deletions dev/wig/windowFunctions.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>IGV-JB</title>
<!-- Font Awesome CSS-->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/font-awesome/4.2.0/css/font-awesome.min.css">

<!-- Juicebox CSS-->
<link rel="stylesheet" type="text/css" href="https://cdn.jsdelivr.net/npm/juicebox.js@2.2.2/dist/css/juicebox.css">

</head>
<body>


<div id="igvDiv" style="flex-grow:0;flex-shrink:0;flex-basis: 950px"></div>


<script type="module">

import igv from "../../js"


// Start igv.js and create regions
const igvConfig =
{
genome: "hg19",
locus: "chr8:61,424,086-62,080,568",
"tracks": [
{
"url": "https://www.encodeproject.org/files/ENCFF000ARZ/@@download/ENCFF000ARZ.bigWig",
"name": "H3K4me1 bigwig",
"autoscaleGroup": "1"
},
{
"url": "../../test/data/tdf/ENCFF000ARZ.wig.tdf",
"name": "H3K4me1 tdf",
"autoscaleGroup": "1"
},
{
"url": "../../test/data/wig/ENCFF000ARZ.wig",
"name": "H3K4me1 mean",
"autoscaleGroup": "1"
},
{
"url": "../../test/data/wig/ENCFF000ARZ.wig",
"name": "H3K4me1 min",
"windowFunction": "min",
"autoscaleGroup": "1"
},
{
"url": "../../test/data/wig/ENCFF000ARZ.wig",
"name": "H3K4me1 max",
"windowFunction": "max",
"autoscaleGroup": "1"
},
{
"url": "../../test/data/wig/ENCFF000ARZ.wig",
"name": "H3K4me1 none",
"windowFunction": "none",
"autoscaleGroup": "1"
},
{
"url": "../../test/data/wig/ENCFF000ARZ.wig",
"name": "H3K4me1 points",
"graphType": "points",
"autoscaleGroup": "1"
}
]
}

igv.createBrowser(document.getElementById("igvDiv"), igvConfig)

.then(async function (igvBrowser) {


})


</script>

</body>
</html>
17 changes: 4 additions & 13 deletions js/bigwig/bwReader.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ import {BGZip, igvxhr, StringUtils} from "../../node_modules/igv-utils/src/index
import {buildOptions, isDataURL} from "../util/igvUtils.js"
import getDecoder from "./bbDecoders.js"
import {parseAutoSQL} from "../util/ucscUtils.js"
import summarizeWigData from "./summarizeWigData.js"
import Trix from "./trix.js"
import BPTree from "./bpTree.js"

Expand Down Expand Up @@ -131,7 +130,7 @@ class BWReader {
}))

// Parse data and return features
const allFeatures = []
const features = []
for (let item of leafItems) {
const uint8Array = new Uint8Array(arrayBuffer, item.dataOffset - start, item.dataSize)
let plain
Expand All @@ -141,22 +140,14 @@ class BWReader {
} else {
plain = uint8Array
}
decodeFunction.call(this, new DataView(plain.buffer), chrIdx1, bpStart, chrIdx2, bpEnd, allFeatures, this.chromTree.idToName, windowFunction)
decodeFunction.call(this, new DataView(plain.buffer), chrIdx1, bpStart, chrIdx2, bpEnd, features, this.chromTree.idToName, windowFunction)
}

allFeatures.sort(function (a, b) {
features.sort(function (a, b) {
return a.start - b.start
})

// If we are reading "raw" wig data optionally summarize it with window function.
// Zoom level data is already summarized
if (decodeFunction === decodeWigData &&
bpPerPixel &&
("mean" === windowFunction || "min" === windowFunction || "max" === windowFunction)) {
return summarizeWigData(allFeatures, bpPerPixel, windowFunction)
} else {
return allFeatures
}
return features
}
}

Expand Down
6 changes: 4 additions & 2 deletions js/bigwig/bwSource.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,14 @@ import pack from "../feature/featurePacker.js"

class BWSource {

queryable = true
wgValues = {}
windowFunctions = ["mean", "min", "max"]

constructor(config, genome) {
this.reader = new BWReader(config, genome)
this.genome = genome
this.format = config.format || "bigwig"
this.wgValues = {}
this.queryable = true
}

async getFeatures({chr, start, end, bpPerPixel, windowFunction}) {
Expand Down
69 changes: 0 additions & 69 deletions js/bigwig/summarizeWigData.js

This file was deleted.

3 changes: 3 additions & 0 deletions js/feature/textFeatureSource.js
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,9 @@ class TextFeatureSource {
const queryChr = genome ? genome.getChromosomeName(chr) : chr
const isWholeGenome = ("all" === queryChr.toLowerCase())

start = start || 0
end = end || Number.MAX_SAFE_INTEGER

// Various conditions that can require a feature load
// * view is "whole genome" but no features are loaded
// * cache is disabled
Expand Down
Loading
Loading