higlass 1.13.4 → 1.13.6

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.
Files changed (139) hide show
  1. package/README.md +48 -54
  2. package/app/globals.d.ts +1 -1
  3. package/app/missing-types.d.ts +4 -1
  4. package/app/scripts/AddTrackDialog.jsx +3 -3
  5. package/app/scripts/AddTrackPositionMenu.jsx +2 -2
  6. package/app/scripts/Annotations1dTrack.js +1 -1
  7. package/app/scripts/Annotations2dTrack.js +3 -5
  8. package/app/scripts/Autocomplete.jsx +14 -21
  9. package/app/scripts/AxisPixi.js +10 -12
  10. package/app/scripts/BarTrack.js +3 -3
  11. package/app/scripts/BedLikeTrack.js +12 -13
  12. package/app/scripts/Button.jsx +1 -1
  13. package/app/scripts/CNVIntervalTrack.js +1 -1
  14. package/app/scripts/CenterTrack.jsx +8 -7
  15. package/app/scripts/Chromosome2DAnnotations.js +1 -1
  16. package/app/scripts/Chromosome2DLabels.js +1 -1
  17. package/app/scripts/ChromosomeGrid.js +49 -38
  18. package/app/scripts/ChromosomeInfo.js +4 -2
  19. package/app/scripts/CombinedTrack.js +3 -1
  20. package/app/scripts/ConfigTrackMenu.jsx +1 -1
  21. package/app/scripts/ConfigViewMenu.jsx +2 -2
  22. package/app/scripts/ContextMenuContainer.jsx +1 -2
  23. package/app/scripts/ContextMenuItem.jsx +1 -0
  24. package/app/scripts/CrossRule.js +1 -1
  25. package/app/scripts/CustomTrackDialog.jsx +2 -2
  26. package/app/scripts/Dialog.jsx +2 -2
  27. package/app/scripts/DragListeningDiv.jsx +1 -1
  28. package/app/scripts/DraggableDiv.jsx +2 -3
  29. package/app/scripts/ExportLinkDialog.jsx +1 -1
  30. package/app/scripts/GalleryTracks.jsx +77 -78
  31. package/app/scripts/GenomePositionSearchBox.jsx +10 -9
  32. package/app/scripts/HeatmapOptions.jsx +8 -3
  33. package/app/scripts/HeatmapTiledPixiTrack.js +72 -53
  34. package/app/scripts/HiGlassComponent.jsx +75 -98
  35. package/app/scripts/Horizontal1dHeatmapTrack.js +1 -1
  36. package/app/scripts/Horizontal2DDomainsTrack.js +1 -1
  37. package/app/scripts/HorizontalChromosomeLabels.js +28 -22
  38. package/app/scripts/HorizontalGeneAnnotationsTrack.js +1 -1
  39. package/app/scripts/HorizontalHeatmapTrack.js +2 -2
  40. package/app/scripts/HorizontalMultivecTrack.js +6 -7
  41. package/app/scripts/HorizontalRule.js +1 -2
  42. package/app/scripts/HorizontalTiled1DPixiTrack.js +4 -4
  43. package/app/scripts/HorizontalTiledPlot.jsx +9 -9
  44. package/app/scripts/LeftTrackModifier.js +4 -0
  45. package/app/scripts/ListWrapper.jsx +1 -2
  46. package/app/scripts/MapboxTilesTrack.js +4 -4
  47. package/app/scripts/Modal.jsx +2 -2
  48. package/app/scripts/MoveableTrack.jsx +10 -12
  49. package/app/scripts/NestedContextMenu.jsx +2 -1
  50. package/app/scripts/OSMTileIdsTrack.js +1 -1
  51. package/app/scripts/OverlayTrack.js +4 -4
  52. package/app/scripts/PixiTrack.js +58 -17
  53. package/app/scripts/PlotTypeChooser.jsx +3 -4
  54. package/app/scripts/RasterTilesTrack.js +3 -2
  55. package/app/scripts/SearchField.js +5 -5
  56. package/app/scripts/SeriesListItems.jsx +3 -4
  57. package/app/scripts/SeriesListMenu.jsx +81 -11
  58. package/app/scripts/SeriesListSubmenuMixin.jsx +5 -1
  59. package/app/scripts/SketchInlinePicker.jsx +2 -2
  60. package/app/scripts/SortableList.jsx +1 -1
  61. package/app/scripts/Tiled1DPixiTrack.js +5 -1
  62. package/app/scripts/TiledPixiTrack.js +221 -76
  63. package/app/scripts/TiledPlot.jsx +35 -43
  64. package/app/scripts/TilesetFinder.jsx +12 -4
  65. package/app/scripts/Track.js +2 -2
  66. package/app/scripts/TrackArea.jsx +4 -0
  67. package/app/scripts/TrackControl.jsx +2 -2
  68. package/app/scripts/TrackRenderer.jsx +30 -31
  69. package/app/scripts/UnknownPixiTrack.js +1 -1
  70. package/app/scripts/ValueIntervalTrack.js +1 -1
  71. package/app/scripts/VerticalRule.js +2 -2
  72. package/app/scripts/VerticalTiledPlot.jsx +7 -7
  73. package/app/scripts/ViewConfigEditor.jsx +1 -1
  74. package/app/scripts/ViewContextMenu.jsx +4 -4
  75. package/app/scripts/ViewHeader.jsx +6 -7
  76. package/app/scripts/ViewportTracker2D.js +1 -1
  77. package/app/scripts/api.js +5 -6
  78. package/app/scripts/configs/available-track-types.js +1 -1
  79. package/app/scripts/configs/positions-by-datatype.js +2 -2
  80. package/app/scripts/configs/themes.js +0 -1
  81. package/app/scripts/configs/tracks-info-by-type.js +11 -8
  82. package/app/scripts/configs/tracks-info.js +2 -2
  83. package/app/scripts/d3-context-menu.js +3 -4
  84. package/app/scripts/data-fetchers/DataFetcher.js +107 -91
  85. package/app/scripts/data-fetchers/genbank-fetcher.js +6 -10
  86. package/app/scripts/data-fetchers/local-tile-fetcher.js +2 -6
  87. package/app/scripts/gosling-exports.js +29 -0
  88. package/app/scripts/hglib.jsx +3 -1
  89. package/app/scripts/hocs/with-modal.jsx +32 -10
  90. package/app/scripts/hocs/with-pub-sub.js +28 -0
  91. package/app/scripts/hocs/with-theme.jsx +21 -14
  92. package/app/scripts/icons.jsx +3 -2
  93. package/app/scripts/mixwith.js +2 -2
  94. package/app/scripts/plugins/get-data-fetcher.js +2 -3
  95. package/app/scripts/services/chrom-info.js +32 -4
  96. package/app/scripts/services/element-resize-listener.js +2 -2
  97. package/app/scripts/services/index.js +0 -1
  98. package/app/scripts/services/tile-proxy.js +370 -282
  99. package/app/scripts/services/worker.js +36 -34
  100. package/app/scripts/test-helpers/test-helpers.jsx +3 -3
  101. package/app/scripts/types.ts +73 -38
  102. package/app/scripts/utils/DenseDataExtrema1D.js +1 -1
  103. package/app/scripts/utils/DenseDataExtrema2D.js +2 -1
  104. package/app/scripts/utils/LruCache.js +3 -2
  105. package/app/scripts/utils/assert.js +19 -0
  106. package/app/scripts/utils/background-task-scheduler.js +2 -0
  107. package/app/scripts/utils/color-domain-to-rgba-array.js +13 -3
  108. package/app/scripts/utils/color-to-hex.js +1 -1
  109. package/app/scripts/utils/dict-items.js +1 -0
  110. package/app/scripts/utils/dict-keys.js +1 -0
  111. package/app/scripts/utils/dict-values.js +1 -0
  112. package/app/scripts/utils/expand-combined-tracks.js +11 -7
  113. package/app/scripts/utils/fake-pub-sub.js +12 -0
  114. package/app/scripts/utils/fill-in-min-widths.js +47 -21
  115. package/app/scripts/utils/flatten.js +0 -1
  116. package/app/scripts/utils/get-aggregation-function.js +1 -1
  117. package/app/scripts/utils/get-default-track-for-datatype.js +36 -10
  118. package/app/scripts/utils/get-higlass-components.js +27 -3
  119. package/app/scripts/utils/get-track-position-by-uid.js +8 -1
  120. package/app/scripts/utils/get-xylofon.js +12 -9
  121. package/app/scripts/utils/has-parent.js +5 -5
  122. package/app/scripts/utils/hex-string-to-int.js +1 -1
  123. package/app/scripts/utils/interval-tree.js +222 -177
  124. package/app/scripts/utils/load-chrom-infos.js +4 -1
  125. package/app/scripts/utils/pixi-text-to-svg.js +5 -9
  126. package/app/scripts/utils/range-query-2d.js +3 -3
  127. package/app/scripts/utils/reduce.js +12 -5
  128. package/app/scripts/utils/segments-to-rows.js +14 -11
  129. package/app/scripts/utils/show-mouse-position.js +17 -1
  130. package/app/scripts/utils/svg-line.js +7 -8
  131. package/app/scripts/utils/type-guards.js +16 -7
  132. package/app/scripts/utils/visit-positioned-tracks.js +7 -5
  133. package/app/styles/d3-context-menu.css +0 -1
  134. package/app/styles/prism.css +1 -0
  135. package/dist/hglib.js +85885 -85618
  136. package/dist/hglib.min.js +110 -109
  137. package/dist/higlass.mjs +86301 -86034
  138. package/package.json +13 -17
  139. package/app/scripts/hocs/with-pub-sub.jsx +0 -28
@@ -1,34 +1,40 @@
1
1
  // @ts-nocheck
2
- import ndarray from 'ndarray';
3
2
  import { brushY } from 'd3-brush';
4
3
  import { format } from 'd3-format';
5
4
  import { scaleLinear } from 'd3-scale';
6
5
  import { select } from 'd3-selection';
6
+ import ndarray from 'ndarray';
7
7
  import slugid from 'slugid';
8
- import {
9
- colorToRgba,
10
- absToChr,
11
- colorDomainToRgbaArray,
12
- colorToHex,
13
- download,
14
- ndarrayAssign,
15
- ndarrayFlatten,
16
- objVals,
17
- showMousePosition,
18
- valueToColor,
19
- } from './utils';
20
8
 
21
- import TiledPixiTrack, { getValueScale } from './TiledPixiTrack';
9
+ import absToChr from './utils/abs-to-chr';
10
+ import colorDomainToRgbaArray from './utils/color-domain-to-rgba-array';
11
+ import colorToHex from './utils/color-to-hex';
12
+ // Utils
13
+ import colorToRgba from './utils/color-to-rgba';
14
+ import { download } from './utils/download';
15
+ import ndarrayAssign from './utils/ndarray-assign';
16
+ import ndarrayFlatten from './utils/ndarray-flatten';
17
+ import objVals from './utils/obj-vals';
18
+ import showMousePosition from './utils/show-mouse-position';
19
+ import valueToColor from './utils/value-to-color';
20
+
22
21
  import AxisPixi from './AxisPixi';
22
+ import TiledPixiTrack, { getValueScale } from './TiledPixiTrack';
23
23
 
24
24
  // Services
25
- import { tileProxy } from './services';
26
-
27
25
  import {
28
- GLOBALS,
29
- HEATED_OBJECT_MAP,
30
- NUM_PRECOMP_SUBSETS_PER_2D_TTILE,
31
- } from './configs';
26
+ calculateResolution,
27
+ calculateTileWidth,
28
+ calculateTiles,
29
+ calculateTilesFromResolution,
30
+ calculateZoomLevel,
31
+ calculateZoomLevelFromResolutions,
32
+ tileDataToPixData,
33
+ } from './services/tile-proxy';
34
+
35
+ import { HEATED_OBJECT_MAP } from './configs/colormaps';
36
+ import { NUM_PRECOMP_SUBSETS_PER_2D_TTILE } from './configs/dense-data-extrema-config';
37
+ import GLOBALS from './configs/globals';
32
38
 
33
39
  const COLORBAR_MAX_HEIGHT = 200;
34
40
  const COLORBAR_WIDTH = 10;
@@ -93,7 +99,7 @@ class HeatmapTiledPixiTrack extends TiledPixiTrack {
93
99
  // not a d3 color scale for speed
94
100
  this.colorScale = HEATED_OBJECT_MAP;
95
101
 
96
- if (options && options.colorRange) {
102
+ if (options?.colorRange) {
97
103
  this.colorScale = colorDomainToRgbaArray(options.colorRange);
98
104
  }
99
105
 
@@ -125,11 +131,7 @@ class HeatmapTiledPixiTrack extends TiledPixiTrack {
125
131
  );
126
132
  }
127
133
 
128
- if (
129
- this.options &&
130
- this.options.showMousePosition &&
131
- !this.hideMousePosition
132
- ) {
134
+ if (this.options?.showMousePosition && !this.hideMousePosition) {
133
135
  this.hideMousePosition = showMousePosition(
134
136
  this,
135
137
  this.is2d,
@@ -307,7 +309,7 @@ class HeatmapTiledPixiTrack extends TiledPixiTrack {
307
309
  }
308
310
 
309
311
  const [scaleType, valueScale] = getValueScale(
310
- (this.options && this.options.heatmapValueScaling) || 'log',
312
+ this.options?.heatmapValueScaling || 'log',
311
313
  minValue,
312
314
  this.medianVisibleValue,
313
315
  maxValue,
@@ -357,7 +359,7 @@ class HeatmapTiledPixiTrack extends TiledPixiTrack {
357
359
  // the normalization method may have changed
358
360
  this.calculateVisibleTiles();
359
361
 
360
- if (options && options.colorRange) {
362
+ if (options?.colorRange) {
361
363
  this.colorScale = colorDomainToRgbaArray(options.colorRange);
362
364
  }
363
365
 
@@ -371,11 +373,7 @@ class HeatmapTiledPixiTrack extends TiledPixiTrack {
371
373
  this.hideMousePosition = undefined;
372
374
  }
373
375
 
374
- if (
375
- this.options &&
376
- this.options.showMousePosition &&
377
- !this.hideMousePosition
378
- ) {
376
+ if (this.options?.showMousePosition && !this.hideMousePosition) {
379
377
  this.hideMousePosition = showMousePosition(
380
378
  this,
381
379
  this.is2d,
@@ -495,10 +493,10 @@ class HeatmapTiledPixiTrack extends TiledPixiTrack {
495
493
  // Fritz: I am disabling ESLint here twice because moving the slash onto the
496
494
  // next line breaks my editors style template somehow.
497
495
  const startPercent =
498
- (startDomain - axisValueScale.domain()[0]) / // eslint-disable-line operator-linebreak
496
+ (startDomain - axisValueScale.domain()[0]) /
499
497
  (axisValueScale.domain()[1] - axisValueScale.domain()[0]);
500
498
  const endPercent =
501
- (endDomain - axisValueScale.domain()[0]) / // eslint-disable-line operator-linebreak
499
+ (endDomain - axisValueScale.domain()[0]) /
502
500
  (axisValueScale.domain()[1] - axisValueScale.domain()[0]);
503
501
 
504
502
  newOptions.scaleStartPercent = startPercent.toFixed(SCALE_LIMIT_PRECISION);
@@ -906,7 +904,7 @@ class HeatmapTiledPixiTrack extends TiledPixiTrack {
906
904
  );
907
905
  } else {
908
906
  // when no tiles are loaded, color will be undefined and we don't want to crash
909
- rectColor.setAttribute('style', `fill: rgb(255,255,255,0)`);
907
+ rectColor.setAttribute('style', 'fill: rgb(255,255,255,0)');
910
908
  }
911
909
  }
912
910
 
@@ -973,7 +971,7 @@ class HeatmapTiledPixiTrack extends TiledPixiTrack {
973
971
  ? Math.min(this.tilesetInfo.max_zoom, zoomLevel)
974
972
  : zoomLevel;
975
973
 
976
- const calculatedWidth = tileProxy.calculateTileWidth(
974
+ const calculatedWidth = calculateTileWidth(
977
975
  this.tilesetInfo,
978
976
  zoomLevel,
979
977
  this.binsPerTile(),
@@ -1010,7 +1008,7 @@ class HeatmapTiledPixiTrack extends TiledPixiTrack {
1010
1008
  Math.ceil((limitedYDomain[1] - limitedYDomain[0]) / tileRes),
1011
1009
  );
1012
1010
 
1013
- const out = ndarray(new Array(binHeight * binWidth).fill(NaN), [
1011
+ const out = ndarray(new Array(binHeight * binWidth).fill(Number.NaN), [
1014
1012
  binHeight,
1015
1013
  binWidth,
1016
1014
  ]);
@@ -1218,19 +1216,19 @@ class HeatmapTiledPixiTrack extends TiledPixiTrack {
1218
1216
  this.renderingTiles.add(tile.tileId);
1219
1217
 
1220
1218
  if (this.tilesetInfo.tile_size) {
1221
- if (tile.tileData.dense.length < this.tilesetInfo.tile_size) {
1219
+ if (tile.tileData.dense?.length < this.tilesetInfo.tile_size) {
1222
1220
  // we haven't gotten a full tile from the server so we want to pad
1223
1221
  // it with nan values
1224
1222
  const newArray = new Float32Array(this.tilesetInfo.tile_size);
1225
1223
 
1226
- newArray.fill(NaN);
1224
+ newArray.fill(Number.NaN);
1227
1225
  newArray.set(tile.tileData.dense);
1228
1226
 
1229
1227
  tile.tileData.dense = newArray;
1230
1228
  }
1231
1229
  }
1232
1230
 
1233
- tileProxy.tileDataToPixData(
1231
+ tileDataToPixData(
1234
1232
  tile,
1235
1233
  scaleType,
1236
1234
  this.limitedValueScale.domain(),
@@ -1569,8 +1567,7 @@ class HeatmapTiledPixiTrack extends TiledPixiTrack {
1569
1567
  tilesToId(xTiles, yTiles, zoomLevel) {
1570
1568
  const rows = xTiles;
1571
1569
  const cols = yTiles;
1572
- const dataTransform =
1573
- (this.options && this.options.dataTransform) || 'default';
1570
+ const dataTransform = this.options?.dataTransform || 'default';
1574
1571
 
1575
1572
  // if we're mirroring tiles, then we only need tiles along the diagonal
1576
1573
  const tiles = [];
@@ -1625,20 +1622,20 @@ class HeatmapTiledPixiTrack extends TiledPixiTrack {
1625
1622
  .map((x) => +x)
1626
1623
  .sort((a, b) => b - a);
1627
1624
 
1628
- this.xTiles = tileProxy.calculateTilesFromResolution(
1625
+ this.xTiles = calculateTilesFromResolution(
1629
1626
  sortedResolutions[this.zoomLevel],
1630
1627
  this._xScale,
1631
1628
  this.tilesetInfo.min_pos[0],
1632
1629
  this.tilesetInfo.max_pos[0],
1633
1630
  );
1634
- this.yTiles = tileProxy.calculateTilesFromResolution(
1631
+ this.yTiles = calculateTilesFromResolution(
1635
1632
  sortedResolutions[this.zoomLevel],
1636
1633
  this._yScale,
1637
1634
  this.tilesetInfo.min_pos[0],
1638
1635
  this.tilesetInfo.max_pos[0],
1639
1636
  );
1640
1637
  } else {
1641
- this.xTiles = tileProxy.calculateTiles(
1638
+ this.xTiles = calculateTiles(
1642
1639
  this.zoomLevel,
1643
1640
  this._xScale,
1644
1641
  this.tilesetInfo.min_pos[0],
@@ -1647,7 +1644,7 @@ class HeatmapTiledPixiTrack extends TiledPixiTrack {
1647
1644
  this.tilesetInfo.max_width,
1648
1645
  );
1649
1646
 
1650
- this.yTiles = tileProxy.calculateTiles(
1647
+ this.yTiles = calculateTiles(
1651
1648
  this.zoomLevel,
1652
1649
  this._yScale,
1653
1650
  this.options.reverseYAxis
@@ -1674,6 +1671,28 @@ class HeatmapTiledPixiTrack extends TiledPixiTrack {
1674
1671
  );
1675
1672
  }
1676
1673
 
1674
+ contextMenuItems(trackX, trackY) {
1675
+ /* Get a list of context menu items to display and the actions
1676
+ to take */
1677
+
1678
+ // This should return items like this:
1679
+
1680
+ // return [
1681
+ // {
1682
+ // label: 'Change background color to black',
1683
+ // onClick: (evt, onTrackOptionsChanged) => {
1684
+ // // The onTrackOptionsChanged handler will handle any changes
1685
+ // // to the track's options that are triggered in this event.
1686
+ // // The only thing that needs to be passed is the new option being
1687
+ // // passed
1688
+ // onTrackOptionsChanged({ backgroundColor: 'black' });
1689
+ // },
1690
+ // },
1691
+ // ];
1692
+
1693
+ return [];
1694
+ }
1695
+
1677
1696
  getMouseOverHtml(trackX, trackY) {
1678
1697
  if (!this.options || !this.options.showTooltip) {
1679
1698
  return '';
@@ -1683,7 +1702,7 @@ class HeatmapTiledPixiTrack extends TiledPixiTrack {
1683
1702
  return '';
1684
1703
  }
1685
1704
 
1686
- const currentResolution = tileProxy.calculateResolution(
1705
+ const currentResolution = calculateResolution(
1687
1706
  this.tilesetInfo,
1688
1707
  this.zoomLevel,
1689
1708
  );
@@ -1803,13 +1822,13 @@ class HeatmapTiledPixiTrack extends TiledPixiTrack {
1803
1822
  let zoomLevel = null;
1804
1823
 
1805
1824
  if (this.tilesetInfo.resolutions) {
1806
- const zoomIndexX = tileProxy.calculateZoomLevelFromResolutions(
1825
+ const zoomIndexX = calculateZoomLevelFromResolutions(
1807
1826
  this.tilesetInfo.resolutions,
1808
1827
  this._xScale,
1809
1828
  minX,
1810
1829
  maxX,
1811
1830
  );
1812
- const zoomIndexY = tileProxy.calculateZoomLevelFromResolutions(
1831
+ const zoomIndexY = calculateZoomLevelFromResolutions(
1813
1832
  this.tilesetInfo.resolutions,
1814
1833
  this._yScale,
1815
1834
  minY,
@@ -1818,14 +1837,14 @@ class HeatmapTiledPixiTrack extends TiledPixiTrack {
1818
1837
 
1819
1838
  zoomLevel = Math.min(zoomIndexX, zoomIndexY);
1820
1839
  } else {
1821
- const xZoomLevel = tileProxy.calculateZoomLevel(
1840
+ const xZoomLevel = calculateZoomLevel(
1822
1841
  this._xScale,
1823
1842
  this.tilesetInfo.min_pos[0],
1824
1843
  this.tilesetInfo.max_pos[0],
1825
1844
  this.binsPerTile(),
1826
1845
  );
1827
1846
 
1828
- const yZoomLevel = tileProxy.calculateZoomLevel(
1847
+ const yZoomLevel = calculateZoomLevel(
1829
1848
  this._xScale,
1830
1849
  this.tilesetInfo.min_pos[1],
1831
1850
  this.tilesetInfo.max_pos[1],
@@ -1836,7 +1855,7 @@ class HeatmapTiledPixiTrack extends TiledPixiTrack {
1836
1855
  zoomLevel = Math.min(zoomLevel, this.maxZoom);
1837
1856
  }
1838
1857
 
1839
- if (this.options && this.options.maxZoom) {
1858
+ if (this.options?.maxZoom) {
1840
1859
  if (this.options.maxZoom >= 0) {
1841
1860
  zoomLevel = Math.min(this.options.maxZoom, zoomLevel);
1842
1861
  } else {