igv 2.13.8 → 2.13.10

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -12,19 +12,19 @@ Below are examples and a quickstart guide. See the [Wiki](https://github.com/ig
12
12
 
13
13
  # Examples
14
14
 
15
- ***[Alignments](https://igv.org/web/release/2.13.8/examples/cram-vcf.html)***
15
+ ***[Alignments](https://igv.org/web/release/2.13.10/examples/cram-vcf.html)***
16
16
 
17
- ***[Interactions](https://igv.org/web/release/2.13.8/examples/interact.html)***
17
+ ***[Interactions](https://igv.org/web/release/2.13.10/examples/interact.html)***
18
18
 
19
- ***[Copy number](https://igv.org/web/release/2.13.8/examples/copyNumber.html)***
19
+ ***[Copy number](https://igv.org/web/release/2.13.10/examples/copyNumber.html)***
20
20
 
21
- ***[Multiple regions](https://igv.org/web/release/2.13.8/examples/multi-locus.html)***
21
+ ***[Multiple regions](https://igv.org/web/release/2.13.10/examples/multi-locus.html)***
22
22
 
23
- ***[Mutation Annotation Format (MAF)](https://igv.org/web/release/2.13.8/examples/maf-tcga.html)***
23
+ ***[Mutation Annotation Format (MAF)](https://igv.org/web/release/2.13.10/examples/maf-tcga.html)***
24
24
 
25
- ***[Variant color options](https://igv.org/web/release/2.13.8/examples/variant-colors.html)***
25
+ ***[Variant color options](https://igv.org/web/release/2.13.10/examples/variant-colors.html)***
26
26
 
27
- ***[More](https://igv.org/web/release/2.13.8/examples/)***
27
+ ***[More](https://igv.org/web/release/2.13.10/examples/)***
28
28
 
29
29
 
30
30
  # Quickstart
@@ -33,18 +33,18 @@ Below are examples and a quickstart guide. See the [Wiki](https://github.com/ig
33
33
  igv.js consists of a single javascript file with no external dependencies.
34
34
 
35
35
  Pre-built files for ES5 (igv.min.js) and ES6 (igv.esm.min.js)
36
- can be downloaded from [https://cdn.jsdelivr.net/npm/igv@2.13.8/dist/](https://cdn.jsdelivr.net/npm/igv@2.13.8/dist/).
36
+ can be downloaded from [https://cdn.jsdelivr.net/npm/igv@2.13.10/dist/](https://cdn.jsdelivr.net/npm/igv@2.13.10/dist/).
37
37
 
38
38
  To import igv as an ES6 module
39
39
 
40
40
  ```javascript
41
- import igv from "https://cdn.jsdelivr.net/npm/igv@2.13.8/dist/igv.esm.min.js"
41
+ import igv from "https://cdn.jsdelivr.net/npm/igv@2.13.10/dist/igv.esm.min.js"
42
42
  ```
43
43
 
44
44
  Or as a script include (defines the "igv" global)
45
45
 
46
46
  ```html
47
- <script src="https://cdn.jsdelivr.net/npm/igv@2.13.8/dist/igv.min.js"></script>
47
+ <script src="https://cdn.jsdelivr.net/npm/igv@2.13.10/dist/igv.min.js"></script>
48
48
  ```
49
49
 
50
50
  Alternatively you can install with npm
package/dist/igv.esm.js CHANGED
@@ -18596,11 +18596,7 @@ RandomColorGenerator.prototype.get = function (saturation, value) {
18596
18596
 
18597
18597
  };
18598
18598
 
18599
- const randomColorGenerator = new RandomColorGenerator();
18600
-
18601
- function randomColor() {
18602
- return randomColorGenerator.get()
18603
- }
18599
+ new RandomColorGenerator();
18604
18600
 
18605
18601
  function randomRGB$1(min, max) {
18606
18602
 
@@ -24215,7 +24211,7 @@ const Cytoband = function (start, end, name, typestain) {
24215
24211
  }
24216
24212
  };
24217
24213
 
24218
- const _version = "2.13.8";
24214
+ const _version = "2.13.10";
24219
24215
  function version() {
24220
24216
  return _version
24221
24217
  }
@@ -30104,13 +30100,17 @@ class BGZBlockLoader {
30104
30100
  /**
30105
30101
  * Return inflated data from startBlock through endBlock as an UInt8Array
30106
30102
  *
30107
- * @param startBlock
30108
- * @param endBlock
30103
+ * @param minv minimum virtual pointer {block, offset}
30104
+ * @param maxv maximum virtual pointer {block, offset}
30109
30105
  * @returns {Promise<Uint8Array>}
30110
30106
  */
30111
- async getData(startBlock, endBlock) {
30107
+ async getData(minv, maxv) {
30108
+
30109
+ const startBlock = minv.block;
30110
+ const endBlock = maxv.block;
30111
+ const skipEnd = maxv.offset === 0;
30112
30112
 
30113
- const blocks = await this.getInflatedBlocks(startBlock, endBlock);
30113
+ const blocks = await this.getInflatedBlocks(startBlock, endBlock, skipEnd);
30114
30114
  if (blocks.length === 1) {
30115
30115
  return blocks[0]
30116
30116
  }
@@ -30135,16 +30135,18 @@ class BGZBlockLoader {
30135
30135
  * @param endBlock
30136
30136
  * @returns {Promise<*[Uint8Array]>}
30137
30137
  */
30138
- async getInflatedBlocks(startBlock, endBlock) {
30138
+ async getInflatedBlocks(startBlock, endBlock, skipEnd) {
30139
30139
 
30140
30140
  if (!this.cacheBlocks) {
30141
- const buffer = await this.loadBLockData(startBlock, endBlock);
30141
+ const buffer = await this.loadBLockData(startBlock, endBlock, {skipEnd});
30142
30142
  return inflateBlocks(buffer)
30143
30143
  } else {
30144
30144
 
30145
30145
  const c = this.cache;
30146
- if (c && (c.startBlock <= startBlock && c.endBlock >= endBlock)) {
30147
- //console.log("Complete overlap")
30146
+ if (c &&
30147
+ c.startBlock <= startBlock &&
30148
+ (c.endBlock >= endBlock || skipEnd && c.nextEndBlock === endBlock)) {
30149
+ console.log("Complete overlap");
30148
30150
  const startOffset = startBlock - c.startBlock;
30149
30151
  const endOffset = endBlock - c.startBlock;
30150
30152
  return inflateBlocks(c.buffer, startOffset, endOffset)
@@ -30154,7 +30156,7 @@ class BGZBlockLoader {
30154
30156
  let buffer;
30155
30157
  if (!c || (c.startBlock > endBlock || c.endBlock < startBlock)) {
30156
30158
  // no overlap with cache
30157
- buffer = await this.loadBLockData(startBlock, endBlock);
30159
+ buffer = await this.loadBLockData(startBlock, endBlock, {skipEnd});
30158
30160
  } else {
30159
30161
 
30160
30162
  //console.log("Some overlap")
@@ -30193,14 +30195,21 @@ class BGZBlockLoader {
30193
30195
 
30194
30196
  // Load end blocks, if any
30195
30197
  if (endBlock > c.endBlock) {
30196
- const endBuffer = await this.loadBLockData(c.endBlock, endBlock, {skipStart: true});
30198
+ const endBuffer = await this.loadBLockData(c.endBlock, endBlock, {skipStart: true, skipEnd});
30197
30199
  arrayBuffers.push(endBuffer);
30198
30200
  }
30199
30201
 
30200
30202
  buffer = concatenateArrayBuffers(arrayBuffers);
30201
30203
  }
30202
30204
 
30203
- this.cache = {startBlock, endBlock, buffer};
30205
+ // If skipEnd === true we need to find boundary of last block in cache
30206
+ let nextEndBlock = endBlock;
30207
+ if(skipEnd) {
30208
+ const boundaries = findBlockBoundaries(buffer);
30209
+ endBlock = boundaries[boundaries.length - 1];
30210
+ }
30211
+
30212
+ this.cache = {startBlock, endBlock, nextEndBlock, buffer};
30204
30213
  return inflateBlocks(buffer)
30205
30214
  }
30206
30215
  }
@@ -30518,7 +30527,7 @@ class FeatureFileReader {
30518
30527
 
30519
30528
  let inflated;
30520
30529
  if (tabix) {
30521
- inflated = await this._blockLoader.getData(chunk.minv.block, chunk.maxv.block);
30530
+ inflated = await this._blockLoader.getData(chunk.minv, chunk.maxv);
30522
30531
  } else {
30523
30532
  const options = buildOptions(config, {
30524
30533
  range: {
@@ -36655,7 +36664,7 @@ class BamReader {
36655
36664
  }
36656
36665
 
36657
36666
  for (let c of chunks) {
36658
- const ba = await this._blockLoader.getData(c.minv.block, c.maxv.block);
36667
+ const ba = await this._blockLoader.getData(c.minv, c.maxv);
36659
36668
  const done = BamUtils.decodeBamRecords(ba, c.minv.offset, alignmentContainer, this.indexToChr, chrId, bpStart, bpEnd, this.filter);
36660
36669
  if (done) {
36661
36670
  break
@@ -42970,7 +42979,14 @@ class TrackView {
42970
42979
  const max = visibleViewport.featureCache.features.getMax(start, end);
42971
42980
  allFeatures = [{value: max}];
42972
42981
  } else {
42973
- allFeatures = FeatureUtils.findOverlapping(visibleViewport.featureCache.features, start, end);
42982
+ const viewFeatures = FeatureUtils.findOverlapping(visibleViewport.featureCache.features, start, end);
42983
+ if(!allFeatures) {
42984
+ allFeatures = viewFeatures;
42985
+ } else {
42986
+ for(let f of viewFeatures) {
42987
+ allFeatures.push(f);
42988
+ }
42989
+ }
42974
42990
  }
42975
42991
  }
42976
42992
  }
@@ -47304,21 +47320,16 @@ class EqtlTrack extends TrackBase {
47304
47320
  * Colors used for coding omosomes
47305
47321
  */
47306
47322
 
47307
- const Colors = {
47323
+ const GWASColors = {
47308
47324
  "X": "rgb(204, 153, 0)",
47309
47325
  "Y": "rgb(153, 204, 0)",
47310
47326
  "Un": "darkGray)",
47311
47327
  "1": "rgb(80, 80, 255)",
47312
- //"1": Color.red);
47313
- "I": "rgb(139, 155, 187)",
47314
47328
  "2": "rgb(206, 61, 50)",
47315
- "II": "rgb(206, 61, 50)",
47316
47329
  "2a": "rgb(210, 65, 55)",
47317
47330
  "2b": "rgb(215, 70, 60)",
47318
47331
  "3": "rgb(116, 155, 88)",
47319
- "III": "rgb(116, 155, 88)",
47320
47332
  "4": "rgb(240, 230, 133)",
47321
- "IV": "rgb(240, 230, 133)",
47322
47333
  "5": "rgb(70, 105, 131)",
47323
47334
  "6": "rgb(186, 99, 56)",
47324
47335
  "7": "rgb(93, 177, 221)",
@@ -47366,9 +47377,28 @@ const Colors = {
47366
47377
  };
47367
47378
 
47368
47379
  // aliasing
47369
- for (let key of Object.keys(Colors)) {
47380
+ for (let key of Object.keys(GWASColors)) {
47370
47381
  const altName = "chr" + key;
47371
- Colors[altName] = Colors[key];
47382
+ GWASColors[altName] = GWASColors[key];
47383
+ }
47384
+
47385
+ // romanizing
47386
+ for(let a = 1; a <= 48; a++) {
47387
+ if(a === 10) continue // Don't overide "X"
47388
+ const roman = romanize(a);
47389
+ GWASColors[roman] = GWASColors[a.toString()];
47390
+ }
47391
+
47392
+
47393
+ function romanize (num) {
47394
+ if (!+num) return false;
47395
+ var digits = String(+num).split('');
47396
+ var key = ['','C','CC','CCC','CD','D','DC','DCC','DCCC','CM',
47397
+ '','X','XX','XXX','XL','L','LX','LXX','LXXX','XC',
47398
+ '','I','II','III','IV','V','VI','VII','VIII','IX'];
47399
+ var roman = '', i = 3;
47400
+ while (i--) roman = (key[+digits.pop() + (i * 10)] || '') + roman;
47401
+ return Array(+digits.join('') + 1).join('M') + roman;
47372
47402
  }
47373
47403
 
47374
47404
  /*
@@ -47423,14 +47453,19 @@ class GWASTrack extends TrackBase {
47423
47453
  this.dotSize = config.dotSize || 3;
47424
47454
  this.popoverWindow = (config.popoverWindow === undefined ? DEFAULT_POPOVER_WINDOW : config.popoverWindow);
47425
47455
 
47426
- this.colorScales = config.color ?
47427
- new ConstantColorScale(config.color) :
47428
- {
47429
- "*": new BinnedColorScale(config.colorScale || {
47430
- thresholds: [5e-8, 5e-4, 0.5],
47431
- colors: ["rgb(255,50,50)", "rgb(251,100,100)", "rgb(251,170,170)", "rgb(227,238,249)"],
47432
- })
47433
- };
47456
+ // Color settings
47457
+ if (this.useChrColors) {
47458
+ this.colorScale = new ColorTable(config.colorTable || GWASColors);
47459
+ } else if (config.color) {
47460
+ this.colorScale = new ConstantColorScale(config.color);
47461
+ } else {
47462
+ this.colorScale =
47463
+ new BinnedColorScale(config.colorScale ||
47464
+ {
47465
+ thresholds: [5e-8, 5e-4, 0.5],
47466
+ colors: ["rgb(255,50,50)", "rgb(251,100,100)", "rgb(251,170,170)", "rgb(227,238,249)"],
47467
+ });
47468
+ }
47434
47469
 
47435
47470
  this.featureSource = FeatureSource(config, this.browser.genome);
47436
47471
  }
@@ -47439,7 +47474,7 @@ class GWASTrack extends TrackBase {
47439
47474
 
47440
47475
  if (typeof this.featureSource.getHeader === "function") {
47441
47476
  this.header = await this.featureSource.getHeader();
47442
- if(this.disposed) return; // This track was removed during async load
47477
+ if (this.disposed) return // This track was removed during async load
47443
47478
  }
47444
47479
 
47445
47480
  // Set properties from track line
@@ -47497,20 +47532,20 @@ class GWASTrack extends TrackBase {
47497
47532
  if (pos < bpStart) continue
47498
47533
  if (pos > bpEnd) break
47499
47534
 
47500
- const colorScale = this.getColorScale(variant._f ? variant._f.chr : variant.chr);
47501
-
47502
- let color;
47503
47535
  let val;
47504
47536
  if (this.posteriorProbability) {
47505
47537
  val = variant[this.valueProperty];
47506
- color = colorScale.getColor(val);
47507
47538
  } else {
47508
47539
  const pvalue = variant[this.valueProperty];
47509
47540
  if (!pvalue) continue
47510
47541
  val = -Math.log10(pvalue);
47511
- color = colorScale.getColor(val);
47512
47542
  }
47513
47543
 
47544
+ const colorKey = this.useChrColors ?
47545
+ variant._f ? variant._f.chr : variant.chr :
47546
+ val;
47547
+
47548
+ const color = this.colorScale.getColor(colorKey);
47514
47549
  const yScale = (this.dataRange.max - this.dataRange.min) / pixelHeight;
47515
47550
  const px = Math.round((pos - bpStart) / bpPerPixel);
47516
47551
  const py = Math.max(this.dotSize, pixelHeight - Math.round((val - this.dataRange.min) / yScale));
@@ -47525,21 +47560,6 @@ class GWASTrack extends TrackBase {
47525
47560
  }
47526
47561
  }
47527
47562
 
47528
- getColorScale(chr) {
47529
-
47530
- if (this.useChrColors) {
47531
- let cs = this.colorScales[chr];
47532
- if (!cs) {
47533
- const color = Colors[chr] || randomColor();
47534
- cs = new ConstantColorScale(color);
47535
- this.colorScales[chr] = cs;
47536
- }
47537
- return cs
47538
- } else {
47539
- return this.colorScales("*")
47540
- }
47541
- }
47542
-
47543
47563
  paintAxis(ctx, pixelWidth, pixelHeight) {
47544
47564
 
47545
47565
  IGVGraphics.fillRect(ctx, 0, 0, pixelWidth, pixelHeight, {'fillStyle': "rgb(255, 255, 255)"});
@@ -47576,7 +47596,7 @@ class GWASTrack extends TrackBase {
47576
47596
 
47577
47597
  popupData(clickState, features) {
47578
47598
 
47579
- if(features === undefined) features = clickState.viewport.cachedFeatures;
47599
+ if (features === undefined) features = clickState.viewport.cachedFeatures;
47580
47600
 
47581
47601
  let data = [];
47582
47602
  const track = clickState.viewport.trackView.track;
@@ -47637,13 +47657,10 @@ class GWASTrack extends TrackBase {
47637
47657
  } else {
47638
47658
  // No features -- pick something reasonable for PPAs and p-values
47639
47659
  if (this.posteriorProbability) {
47640
- this.dataRange.min = this.config.min || 0;
47641
- this.dataRange.max = this.config.max || 1;
47660
+ this.dataRange = {min: this.config.min || 0, max: this.config.max || 1};
47642
47661
  } else {
47643
- this.dataRange.max = this.config.max || 25;
47644
- this.dataRange.min = this.config.min || 0;
47662
+ this.dataRange = {min: this.config.max || 25, max: this.config.min || 0};
47645
47663
  }
47646
-
47647
47664
  }
47648
47665
 
47649
47666
  return this.dataRange