higlass 1.13.2 → 1.13.3
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 +0 -2
- package/app/globals.d.ts +4 -4
- package/app/missing-types.d.ts +3 -3
- package/app/scripts/AddTrackDialog.jsx +1 -0
- package/app/scripts/AddTrackPositionMenu.jsx +17 -4
- package/app/scripts/Annotations1dTrack.js +1 -0
- package/app/scripts/Annotations2dTrack.js +1 -0
- package/app/scripts/ArrowheadDomainsTrack.js +1 -0
- package/app/scripts/Autocomplete.jsx +1 -0
- package/app/scripts/AxisPixi.js +1 -0
- package/app/scripts/BarTrack.js +1 -0
- package/app/scripts/BedLikeTrack.js +1 -0
- package/app/scripts/Button.jsx +1 -0
- package/app/scripts/CNVIntervalTrack.js +1 -0
- package/app/scripts/CenterTiledPlot.jsx +1 -0
- package/app/scripts/CenterTrack.jsx +1 -0
- package/app/scripts/Chromosome2DAnnotations.js +1 -0
- package/app/scripts/Chromosome2DLabels.js +1 -0
- package/app/scripts/ChromosomeGrid.js +1 -0
- package/app/scripts/ChromosomeInfo.js +1 -0
- package/app/scripts/CloseTrackMenu.jsx +1 -0
- package/app/scripts/CombinedTrack.js +1 -0
- package/app/scripts/ConfigTrackMenu.jsx +1 -0
- package/app/scripts/ConfigViewMenu.jsx +1 -0
- package/app/scripts/ConfigureSeriesMenu.jsx +1 -0
- package/app/scripts/ContextMenuContainer.jsx +1 -0
- package/app/scripts/ContextMenuItem.jsx +1 -0
- package/app/scripts/Cross.jsx +1 -0
- package/app/scripts/CrossRule.js +1 -0
- package/app/scripts/CustomTrackDialog.jsx +1 -0
- package/app/scripts/Dialog.jsx +1 -0
- package/app/scripts/DivergentBarTrack.js +1 -0
- package/app/scripts/DragListeningDiv.jsx +1 -0
- package/app/scripts/DraggableDiv.jsx +1 -0
- package/app/scripts/ExportLinkDialog.jsx +1 -0
- package/app/scripts/FixedTrack.jsx +1 -0
- package/app/scripts/GalleryTracks.jsx +1 -0
- package/app/scripts/GenomePositionSearchBox.jsx +1 -0
- package/app/scripts/HeatmapOptions.jsx +1 -0
- package/app/scripts/HeatmapTiledPixiTrack.js +1 -0
- package/app/scripts/HiGlassComponent.jsx +1 -0
- package/app/scripts/HiGlassTrackComponent.jsx +1 -0
- package/app/scripts/Horizontal1dHeatmapTrack.js +1 -0
- package/app/scripts/Horizontal2DDomainsTrack.js +1 -0
- package/app/scripts/HorizontalChromosomeLabels.js +1 -0
- package/app/scripts/HorizontalGeneAnnotationsTrack.js +1 -0
- package/app/scripts/HorizontalHeatmapTrack.js +1 -0
- package/app/scripts/HorizontalItem.jsx +1 -0
- package/app/scripts/HorizontalLine1DPixiTrack.js +1 -0
- package/app/scripts/HorizontalMultivecTrack.js +1 -0
- package/app/scripts/HorizontalPoint1DPixiTrack.js +1 -0
- package/app/scripts/HorizontalRule.js +1 -0
- package/app/scripts/HorizontalTiled1DPixiTrack.js +1 -0
- package/app/scripts/HorizontalTiledPlot.jsx +1 -0
- package/app/scripts/HorizontalTrack.jsx +1 -0
- package/app/scripts/Id2DTiledPixiTrack.js +1 -0
- package/app/scripts/IdHorizontal1DTiledPixiTrack.js +1 -0
- package/app/scripts/IdVertical1DTiledPixiTrack.js +1 -0
- package/app/scripts/LeftAxisTrack.js +1 -0
- package/app/scripts/LeftTrackModifier.js +1 -0
- package/app/scripts/ListWrapper.jsx +1 -0
- package/app/scripts/MapboxTilesTrack.js +1 -0
- package/app/scripts/Modal.jsx +1 -0
- package/app/scripts/MoveableTrack.jsx +1 -0
- package/app/scripts/NestedContextMenu.jsx +1 -0
- package/app/scripts/OSMTileIdsTrack.js +1 -0
- package/app/scripts/OSMTilesTrack.js +1 -0
- package/app/scripts/OverlayTrack.js +1 -0
- package/app/scripts/PixiTrack.js +0 -1
- package/app/scripts/PlotTypeChooser.jsx +1 -0
- package/app/scripts/PopupMenu.jsx +1 -0
- package/app/scripts/RasterTilesTrack.js +1 -0
- package/app/scripts/RuleMixin.js +1 -0
- package/app/scripts/SVGTrack.js +1 -0
- package/app/scripts/SearchField.js +1 -0
- package/app/scripts/SeriesListItems.jsx +1 -0
- package/app/scripts/SeriesListMenu.jsx +1 -0
- package/app/scripts/SeriesListSubmenuMixin.jsx +1 -0
- package/app/scripts/SketchInlinePicker.jsx +1 -0
- package/app/scripts/SortableList.jsx +1 -0
- package/app/scripts/SquareMarkersTrack.js +1 -0
- package/app/scripts/Tiled1DPixiTrack.js +1 -0
- package/app/scripts/TiledPixiTrack.js +1 -0
- package/app/scripts/TiledPlot.jsx +1 -0
- package/app/scripts/TilesetFinder.jsx +1 -0
- package/app/scripts/TopAxisTrack.js +1 -0
- package/app/scripts/Track.js +0 -1
- package/app/scripts/TrackArea.jsx +1 -0
- package/app/scripts/TrackControl.jsx +1 -0
- package/app/scripts/TrackRenderer.jsx +0 -1
- package/app/scripts/UnknownPixiTrack.js +1 -0
- package/app/scripts/ValueIntervalTrack.js +1 -0
- package/app/scripts/VerticalItem.jsx +1 -0
- package/app/scripts/VerticalRule.js +1 -0
- package/app/scripts/VerticalTiled1DPixiTrack.js +1 -0
- package/app/scripts/VerticalTiledPlot.jsx +1 -0
- package/app/scripts/VerticalTrack.jsx +1 -0
- package/app/scripts/ViewConfigEditor.jsx +1 -0
- package/app/scripts/ViewContextMenu.jsx +1 -0
- package/app/scripts/ViewHeader.jsx +1 -0
- package/app/scripts/ViewportTracker2D.js +1 -0
- package/app/scripts/ViewportTracker2DPixi.js +1 -0
- package/app/scripts/ViewportTrackerHorizontal.js +1 -0
- package/app/scripts/ViewportTrackerVertical.js +1 -0
- package/app/scripts/api.js +1 -0
- package/app/scripts/configs/available-track-types.js +1 -0
- package/app/scripts/configs/colormaps.js +1 -0
- package/app/scripts/configs/datatype-to-track-type.js +1 -0
- package/app/scripts/configs/default-tracks-for-datatype.js +0 -1
- package/app/scripts/configs/dense-data-extrema-config.js +1 -0
- package/app/scripts/configs/globals.js +1 -0
- package/app/scripts/configs/index.js +1 -0
- package/app/scripts/configs/positions-by-datatype.js +1 -0
- package/app/scripts/configs/primitives.js +0 -1
- package/app/scripts/configs/themes.js +1 -0
- package/app/scripts/configs/tracks-info-by-type.js +0 -1
- package/app/scripts/configs/tracks-info.js +0 -1
- package/app/scripts/d3-context-menu.js +1 -0
- package/app/scripts/data-fetchers/DataFetcher.js +193 -153
- package/app/scripts/data-fetchers/genbank-fetcher.js +205 -87
- package/app/scripts/data-fetchers/index.js +1 -0
- package/app/scripts/data-fetchers/local-tile-fetcher.js +37 -4
- package/app/scripts/hglib.jsx +1 -0
- package/app/scripts/hocs/with-modal.jsx +1 -0
- package/app/scripts/hocs/with-pub-sub.jsx +1 -0
- package/app/scripts/hocs/with-theme.jsx +1 -0
- package/app/scripts/icons.jsx +1 -0
- package/app/scripts/mixwith.js +1 -0
- package/app/scripts/options-info.js +1 -0
- package/app/scripts/plugins/available-for-plugins.js +1 -0
- package/app/scripts/plugins/get-data-fetcher.js +1 -0
- package/app/scripts/plugins/index.js +1 -0
- package/app/scripts/services/chrom-info.js +1 -0
- package/app/scripts/services/dom-event.js +1 -0
- package/app/scripts/services/element-resize-listener.js +1 -0
- package/app/scripts/services/index.js +1 -0
- package/app/scripts/services/tile-proxy.js +14 -10
- package/app/scripts/services/worker.js +161 -84
- package/app/scripts/symbol.js +1 -0
- package/app/scripts/test-helpers/index.js +1 -0
- package/app/scripts/test-helpers/test-helpers.jsx +1 -0
- package/app/scripts/track-utils.js +1 -0
- package/app/scripts/types.ts +59 -22
- package/app/scripts/utils/DenseDataExtrema1D.js +32 -19
- package/app/scripts/utils/DenseDataExtrema2D.js +51 -31
- package/app/scripts/utils/LruCache.js +1 -0
- package/app/scripts/utils/abs-to-chr.js +0 -1
- package/app/scripts/utils/accessor-transposition.js +0 -2
- package/app/scripts/utils/add-arrays.js +0 -2
- package/app/scripts/utils/add-class.js +0 -1
- package/app/scripts/utils/add-event-listener-once.js +0 -2
- package/app/scripts/utils/background-task-scheduler.js +0 -2
- package/app/scripts/utils/base64-to-canvas.js +0 -2
- package/app/scripts/utils/chr-to-abs.js +0 -2
- package/app/scripts/utils/chrom-info-bisector.js +0 -1
- package/app/scripts/utils/clone-event.js +0 -2
- package/app/scripts/utils/color-domain-to-rgba-array.js +1 -0
- package/app/scripts/utils/color-to-hex.js +0 -1
- package/app/scripts/utils/color-to-rgba.js +0 -1
- package/app/scripts/utils/data-to-genomic-loci.js +0 -1
- package/app/scripts/utils/debounce.js +0 -2
- package/app/scripts/utils/dec-to-hex-str.js +0 -1
- package/app/scripts/utils/dict-from-tuples.js +0 -2
- package/app/scripts/utils/dict-items.js +0 -2
- package/app/scripts/utils/dict-keys.js +0 -2
- package/app/scripts/utils/dict-values.js +0 -2
- package/app/scripts/utils/download.js +0 -2
- package/app/scripts/utils/expand-combined-tracks.js +1 -0
- package/app/scripts/utils/fill-in-min-widths.js +1 -0
- package/app/scripts/utils/flatten.js +1 -0
- package/app/scripts/utils/for-each.js +0 -1
- package/app/scripts/utils/forward-event.js +0 -1
- package/app/scripts/utils/genome-loci-to-pixels.js +0 -1
- package/app/scripts/utils/genomic-range-to-chromosome-chunks.js +0 -2
- package/app/scripts/utils/get-aggregation-function.js +6 -12
- package/app/scripts/utils/get-default-track-for-datatype.js +1 -0
- package/app/scripts/utils/get-element-dim.js +0 -1
- package/app/scripts/utils/get-higlass-components.js +1 -0
- package/app/scripts/utils/get-track-by-uid.js +1 -0
- package/app/scripts/utils/get-track-conf-from-hgc.js +1 -0
- package/app/scripts/utils/get-track-obj-by-id.js +1 -0
- package/app/scripts/utils/get-track-position-by-uid.js +1 -0
- package/app/scripts/utils/get-xylofon.js +1 -0
- package/app/scripts/utils/gradient.js +0 -2
- package/app/scripts/utils/has-class.js +0 -2
- package/app/scripts/utils/has-parent.js +1 -0
- package/app/scripts/utils/hex-string-to-int.js +0 -1
- package/app/scripts/utils/index.js +0 -1
- package/app/scripts/utils/interval-tree.js +1 -0
- package/app/scripts/utils/into-the-void.js +0 -1
- package/app/scripts/utils/is-track-or-child-track.js +0 -1
- package/app/scripts/utils/is-track-range-selectable.js +0 -1
- package/app/scripts/utils/is-within.js +0 -2
- package/app/scripts/utils/lat-to-y.js +0 -2
- package/app/scripts/utils/lng-to-x.js +0 -1
- package/app/scripts/utils/load-chrom-infos.js +1 -0
- package/app/scripts/utils/map.js +0 -1
- package/app/scripts/utils/max-non-zero.js +0 -1
- package/app/scripts/utils/max.js +0 -1
- package/app/scripts/utils/min-non-zero.js +0 -1
- package/app/scripts/utils/min.js +0 -1
- package/app/scripts/utils/mod.js +0 -1
- package/app/scripts/utils/ndarray-assign.js +1 -0
- package/app/scripts/utils/ndarray-flatten.js +1 -0
- package/app/scripts/utils/ndarray-to-list.js +1 -0
- package/app/scripts/utils/numericify-version.js +0 -1
- package/app/scripts/utils/obj-vals.js +1 -0
- package/app/scripts/utils/or.js +0 -1
- package/app/scripts/utils/parse-chromsizes-rows.js +0 -2
- package/app/scripts/utils/pixi-text-to-svg.js +1 -0
- package/app/scripts/utils/q.js +1 -0
- package/app/scripts/utils/rad-to-deg.js +0 -1
- package/app/scripts/utils/range-query-2d.js +1 -0
- package/app/scripts/utils/reduce.js +1 -0
- package/app/scripts/utils/rel-to-abs-chrom-pos.js +0 -2
- package/app/scripts/utils/remove-class.js +0 -1
- package/app/scripts/utils/reset-d3-brush-style.js +0 -2
- package/app/scripts/utils/rgb-to-hex.js +0 -2
- package/app/scripts/utils/scales-center-and-k.js +0 -2
- package/app/scripts/utils/scales-to-genome-loci.js +0 -1
- package/app/scripts/utils/segments-to-rows.js +1 -0
- package/app/scripts/utils/selected-items-to-cum-weights.js +0 -1
- package/app/scripts/utils/selected-items-to-size.js +0 -1
- package/app/scripts/utils/show-mouse-position.js +0 -1
- package/app/scripts/utils/some.js +0 -1
- package/app/scripts/utils/sum.js +0 -1
- package/app/scripts/utils/svg-line.js +1 -0
- package/app/scripts/utils/throttle-and-debounce.js +0 -1
- package/app/scripts/utils/tile-to-canvas.js +0 -1
- package/app/scripts/utils/timeout.js +0 -1
- package/app/scripts/utils/to-void.js +0 -1
- package/app/scripts/utils/total-track-pixel-height.js +0 -1
- package/app/scripts/utils/trim-trailing-slash.js +0 -1
- package/app/scripts/utils/type-guards.js +0 -2
- package/app/scripts/utils/value-to-color.js +0 -1
- package/app/scripts/utils/visit-positioned-tracks.js +0 -1
- package/app/scripts/utils/visit-tracks.js +0 -1
- package/dist/esm.html +13 -14
- package/dist/hglib.css +1 -1724
- package/dist/hglib.js +122661 -28
- package/dist/hglib.min.js +116 -119
- package/dist/higlass.mjs +122643 -28
- package/dist/index.html +5 -6
- package/package.json +23 -16
|
@@ -1,27 +1,36 @@
|
|
|
1
1
|
import { NUM_PRECOMP_SUBSETS_PER_1D_TTILE } from '../configs';
|
|
2
2
|
|
|
3
|
+
/**
|
|
4
|
+
* @template {ArrayLike<number>} [T=ArrayLike<number>]
|
|
5
|
+
*/
|
|
3
6
|
class DenseDataExtrema1D {
|
|
4
7
|
/**
|
|
5
8
|
* This module efficiently computes extrema of arbitrary subsets of a given data array.
|
|
6
9
|
* The array is subdivided into 'numSubsets' subsets where extrema are precomputed.
|
|
7
10
|
* These values are used to compute extrema given arbitrary start and end indices via
|
|
8
11
|
* the getMinNonZeroInSubset and getMaxNonZeroInSubset methods.
|
|
9
|
-
* @param
|
|
12
|
+
* @param {T} data
|
|
10
13
|
*/
|
|
11
14
|
constructor(data) {
|
|
15
|
+
/** @type {number} */
|
|
12
16
|
this.epsilon = 1e-6;
|
|
17
|
+
/** @type {T} */
|
|
13
18
|
this.data = data;
|
|
14
19
|
|
|
20
|
+
/** @type {number} */
|
|
15
21
|
this.tileSize = this.data.length; // might not be a power of 2
|
|
22
|
+
/** @type {number} */
|
|
16
23
|
this.paddedTileSize = 2 ** Math.ceil(Math.log2(this.tileSize));
|
|
17
24
|
|
|
18
25
|
// This controls how many subsets are created and precomputed.
|
|
19
26
|
// Setting numSubsets to 1, is equivalent to no precomputation in
|
|
20
27
|
// most cases
|
|
28
|
+
/** @type {number} */
|
|
21
29
|
this.numSubsets = Math.min(
|
|
22
30
|
NUM_PRECOMP_SUBSETS_PER_1D_TTILE,
|
|
23
31
|
this.paddedTileSize,
|
|
24
32
|
);
|
|
33
|
+
/** @type {number} */
|
|
25
34
|
this.subsetSize = this.paddedTileSize / this.numSubsets;
|
|
26
35
|
|
|
27
36
|
this.subsetMinimums = this.computeSubsetNonZeroMinimums();
|
|
@@ -33,8 +42,9 @@ class DenseDataExtrema1D {
|
|
|
33
42
|
/**
|
|
34
43
|
* Computes the non-zero minimum in a subset using precomputed values,
|
|
35
44
|
* if possible. data[end] is not considered.
|
|
36
|
-
*
|
|
37
|
-
* @
|
|
45
|
+
*
|
|
46
|
+
* @param {[start: number, end: number]} indexBounds
|
|
47
|
+
* @return {number} non-zero minium of the subset
|
|
38
48
|
*/
|
|
39
49
|
getMinNonZeroInSubset(indexBounds) {
|
|
40
50
|
const start = indexBounds[0];
|
|
@@ -79,10 +89,10 @@ class DenseDataExtrema1D {
|
|
|
79
89
|
}
|
|
80
90
|
|
|
81
91
|
/**
|
|
82
|
-
* Computes the non-zero maximum in a subset using precomputed values,
|
|
83
|
-
*
|
|
84
|
-
* @param
|
|
85
|
-
* @return
|
|
92
|
+
* Computes the non-zero maximum in a subset using precomputed values, if possible
|
|
93
|
+
*
|
|
94
|
+
* @param {[start: number, end: number]} indexBounds
|
|
95
|
+
* @return {number} non-zero maxium of the subset
|
|
86
96
|
*/
|
|
87
97
|
getMaxNonZeroInSubset(indexBounds) {
|
|
88
98
|
const start = indexBounds[0];
|
|
@@ -128,10 +138,11 @@ class DenseDataExtrema1D {
|
|
|
128
138
|
|
|
129
139
|
/**
|
|
130
140
|
* Precomputes non-zero minimums of subsets of the given data vector
|
|
131
|
-
*
|
|
132
|
-
*
|
|
141
|
+
*
|
|
142
|
+
* @returns {Array<number>} - Minimums of the regularly subdivided data vector
|
|
133
143
|
*/
|
|
134
144
|
computeSubsetNonZeroMinimums() {
|
|
145
|
+
/** @type {Array<number>} */
|
|
135
146
|
const minimums = [];
|
|
136
147
|
|
|
137
148
|
for (let i = 0; i < this.numSubsets; i++) {
|
|
@@ -159,10 +170,10 @@ class DenseDataExtrema1D {
|
|
|
159
170
|
|
|
160
171
|
/**
|
|
161
172
|
* Precomputes non-zero maximums of subsets of the given data vector
|
|
162
|
-
* @return
|
|
163
|
-
* data vector
|
|
173
|
+
* @return {Array<number>} Maximums of the regularly subdivided data vector
|
|
164
174
|
*/
|
|
165
175
|
computeSubsetNonZeroMaximums() {
|
|
176
|
+
/** @type {Array<number>} */
|
|
166
177
|
const maximums = [];
|
|
167
178
|
|
|
168
179
|
for (let i = 0; i < this.numSubsets; i++) {
|
|
@@ -190,7 +201,8 @@ class DenseDataExtrema1D {
|
|
|
190
201
|
|
|
191
202
|
/**
|
|
192
203
|
* Computes the non-zero minimum in the entire data array using precomputed values
|
|
193
|
-
*
|
|
204
|
+
*
|
|
205
|
+
* @return {number} Non-zeros maximum of the data
|
|
194
206
|
*/
|
|
195
207
|
getMinNonZeroInTile() {
|
|
196
208
|
return Math.min(...this.subsetMinimums);
|
|
@@ -198,7 +210,8 @@ class DenseDataExtrema1D {
|
|
|
198
210
|
|
|
199
211
|
/**
|
|
200
212
|
* Computes the non-zero maximum in the entire data array using precomputed values
|
|
201
|
-
*
|
|
213
|
+
*
|
|
214
|
+
* @return {number} Non-zeros maximum of the data
|
|
202
215
|
*/
|
|
203
216
|
getMaxNonZeroInTile() {
|
|
204
217
|
return Math.max(...this.subsetMaximums);
|
|
@@ -208,9 +221,9 @@ class DenseDataExtrema1D {
|
|
|
208
221
|
* Calculate the minimum non-zero value in the data from start
|
|
209
222
|
* to end. No precomputations are used to compute the min.
|
|
210
223
|
*
|
|
211
|
-
* @param {
|
|
212
|
-
* @param {
|
|
213
|
-
* @param {
|
|
224
|
+
* @param {ArrayLike<number>} data
|
|
225
|
+
* @param {number} start
|
|
226
|
+
* @param {number} end
|
|
214
227
|
* @return {number} non-zero min in subset
|
|
215
228
|
*/
|
|
216
229
|
minNonZero(data, start, end) {
|
|
@@ -235,9 +248,9 @@ class DenseDataExtrema1D {
|
|
|
235
248
|
* Calculate the maximum non-zero value in the data from start
|
|
236
249
|
* to end. No precomputations are used to compute the max.
|
|
237
250
|
*
|
|
238
|
-
* @param {
|
|
239
|
-
|
|
240
|
-
* @param {
|
|
251
|
+
* @param {ArrayLike<number>} data
|
|
252
|
+
* @param {number} start
|
|
253
|
+
* @param {number} end
|
|
241
254
|
* @return {number} non-zero max in subset
|
|
242
255
|
*/
|
|
243
256
|
maxNonZero(data, start, end) {
|
|
@@ -1,7 +1,12 @@
|
|
|
1
1
|
import ndarray from 'ndarray';
|
|
2
|
-
|
|
3
2
|
import { NUM_PRECOMP_SUBSETS_PER_2D_TTILE } from '../configs';
|
|
4
3
|
|
|
4
|
+
/**
|
|
5
|
+
* @typedef View2D
|
|
6
|
+
* @property {(i: number, j: number) => number} get
|
|
7
|
+
* @property {(i: number, j: number, v: number) => void} set
|
|
8
|
+
*/
|
|
9
|
+
|
|
5
10
|
class DenseDataExtrema2D {
|
|
6
11
|
/**
|
|
7
12
|
* This module efficiently computes extrema of subsets of a given data matrix.
|
|
@@ -9,11 +14,12 @@ class DenseDataExtrema2D {
|
|
|
9
14
|
* These values are used to efficiently approximate extrema given arbitrary subsets.
|
|
10
15
|
* Larger values of 'numSubsets' lead to more accurate approximations (more expensive).
|
|
11
16
|
*
|
|
12
|
-
* @param
|
|
17
|
+
* @param {ArrayLike<number>} data array of quadratic length
|
|
13
18
|
*/
|
|
14
19
|
constructor(data) {
|
|
20
|
+
/** @type {number} */
|
|
15
21
|
this.epsilon = 1e-6;
|
|
16
|
-
|
|
22
|
+
/** @type {number} */
|
|
17
23
|
this.tileSize = Math.sqrt(data.length);
|
|
18
24
|
|
|
19
25
|
if (!Number.isSafeInteger(this.tileSize)) {
|
|
@@ -23,25 +29,33 @@ class DenseDataExtrema2D {
|
|
|
23
29
|
}
|
|
24
30
|
|
|
25
31
|
// if this.numSubsets == this.tilesize the extrema are computed exactly (expensive).
|
|
32
|
+
/** @type {number} */
|
|
26
33
|
this.numSubsets = Math.min(NUM_PRECOMP_SUBSETS_PER_2D_TTILE, this.tileSize);
|
|
34
|
+
/** @type {number} */
|
|
27
35
|
this.subsetSize = this.tileSize / this.numSubsets;
|
|
28
36
|
|
|
29
37
|
// Convert data to 2d array
|
|
38
|
+
/** @type {View2D} */
|
|
30
39
|
const dataMatrix = ndarray(Array.from(data), [
|
|
31
40
|
this.tileSize,
|
|
32
41
|
this.tileSize,
|
|
33
42
|
]);
|
|
34
43
|
|
|
44
|
+
/** @type {View2D} */
|
|
35
45
|
this.subsetMinimums = this.computeSubsetNonZeroMinimums(dataMatrix);
|
|
46
|
+
/** @type {View2D} */
|
|
36
47
|
this.subsetMaximums = this.computeSubsetNonZeroMaximums(dataMatrix);
|
|
48
|
+
/** @type {number} */
|
|
37
49
|
this.minNonZeroInTile = this.getMinNonZeroInTile();
|
|
50
|
+
/** @type {number} */
|
|
38
51
|
this.maxNonZeroInTile = this.getMaxNonZeroInTile();
|
|
39
52
|
}
|
|
40
53
|
|
|
41
54
|
/**
|
|
42
55
|
* Computes an approximation of the non-zero minimum in a subset
|
|
43
|
-
*
|
|
44
|
-
* @
|
|
56
|
+
*
|
|
57
|
+
* @param {[startX: number, startY: number, endX: number, endY: number]} indexBounds
|
|
58
|
+
* @return {number} Non-zero minium of the subset
|
|
45
59
|
*/
|
|
46
60
|
getMinNonZeroInSubset(indexBounds) {
|
|
47
61
|
const startX = indexBounds[0];
|
|
@@ -69,8 +83,9 @@ class DenseDataExtrema2D {
|
|
|
69
83
|
|
|
70
84
|
/**
|
|
71
85
|
* Computes an approximation of the non-zero maximum in a subset
|
|
72
|
-
*
|
|
73
|
-
* @
|
|
86
|
+
*
|
|
87
|
+
* @param {[startX: number, startY: number, endX: number, endY: number]} indexBounds
|
|
88
|
+
* @return {number} Non-zero maxium of the subset
|
|
74
89
|
*/
|
|
75
90
|
getMaxNonZeroInSubset(indexBounds) {
|
|
76
91
|
const startX = indexBounds[0];
|
|
@@ -98,13 +113,14 @@ class DenseDataExtrema2D {
|
|
|
98
113
|
|
|
99
114
|
/**
|
|
100
115
|
* Precomputes non-zero minimums of subsets of a given matrix
|
|
101
|
-
* @param
|
|
102
|
-
* @return
|
|
103
|
-
* after subdivision using a regular grid
|
|
116
|
+
* @param {View2D} dataMatrix
|
|
117
|
+
* @return {View2D} Matrix containing minimums of the dataMatrix after subdivision using a regular grid
|
|
104
118
|
*/
|
|
105
119
|
computeSubsetNonZeroMinimums(dataMatrix) {
|
|
106
|
-
|
|
107
|
-
|
|
120
|
+
const minimums = ndarray(new Array(this.numSubsets ** 2), [
|
|
121
|
+
this.numSubsets,
|
|
122
|
+
this.numSubsets,
|
|
123
|
+
]);
|
|
108
124
|
|
|
109
125
|
for (let i = 0; i < this.numSubsets; i++) {
|
|
110
126
|
for (let j = 0; j < this.numSubsets; j++) {
|
|
@@ -123,13 +139,15 @@ class DenseDataExtrema2D {
|
|
|
123
139
|
|
|
124
140
|
/**
|
|
125
141
|
* Precomputes non-zero maximums of subsets of a given matrix
|
|
126
|
-
*
|
|
127
|
-
* @
|
|
128
|
-
*
|
|
142
|
+
*
|
|
143
|
+
* @param {View2D} dataMatrix
|
|
144
|
+
* @return {View2D} Matrix containing maximums of the dataMatrix after subdivision using a regular grid
|
|
129
145
|
*/
|
|
130
146
|
computeSubsetNonZeroMaximums(dataMatrix) {
|
|
131
|
-
|
|
132
|
-
|
|
147
|
+
const maximums = ndarray(new Array(this.numSubsets ** 2), [
|
|
148
|
+
this.numSubsets,
|
|
149
|
+
this.numSubsets,
|
|
150
|
+
]);
|
|
133
151
|
|
|
134
152
|
for (let i = 0; i < this.numSubsets; i++) {
|
|
135
153
|
for (let j = 0; j < this.numSubsets; j++) {
|
|
@@ -148,12 +166,12 @@ class DenseDataExtrema2D {
|
|
|
148
166
|
|
|
149
167
|
/**
|
|
150
168
|
* Computes the non-zero minimum of a subset of a matrix (ndarray)
|
|
151
|
-
* @param
|
|
152
|
-
* @param
|
|
153
|
-
* @param
|
|
154
|
-
* @param
|
|
155
|
-
* @param
|
|
156
|
-
* @return
|
|
169
|
+
* @param {View2D} arr
|
|
170
|
+
* @param {number} rowOffset - Starting row of the subset
|
|
171
|
+
* @param {number} colOffset - Starting column of the subset
|
|
172
|
+
* @param {number} width - Width (num columns) of the subset
|
|
173
|
+
* @param {number} height - Height (num rows) of the subset
|
|
174
|
+
* @return {number} Non-zeros - minimum of the subset
|
|
157
175
|
*/
|
|
158
176
|
getMinNonZeroInNdarraySubset(arr, rowOffset, colOffset, width, height) {
|
|
159
177
|
let curMin = Number.MAX_SAFE_INTEGER;
|
|
@@ -175,12 +193,12 @@ class DenseDataExtrema2D {
|
|
|
175
193
|
|
|
176
194
|
/**
|
|
177
195
|
* Computes the non-zero maximum of a subset of a matrix (ndarray)
|
|
178
|
-
* @param
|
|
179
|
-
* @param
|
|
180
|
-
* @param
|
|
181
|
-
* @param
|
|
182
|
-
* @param
|
|
183
|
-
* @return
|
|
196
|
+
* @param {View2D} arr
|
|
197
|
+
* @param {number} rowOffset - Starting row of the subset
|
|
198
|
+
* @param {number} colOffset - Starting column of the subset
|
|
199
|
+
* @param {number} width - Width (num columns) of the subset
|
|
200
|
+
* @param {number} height - Height (num rows) of the subset
|
|
201
|
+
* @return {number} Non-zeros maximum of the subset
|
|
184
202
|
*/
|
|
185
203
|
getMaxNonZeroInNdarraySubset(arr, rowOffset, colOffset, width, height) {
|
|
186
204
|
let curMax = Number.MIN_SAFE_INTEGER;
|
|
@@ -211,7 +229,8 @@ class DenseDataExtrema2D {
|
|
|
211
229
|
|
|
212
230
|
/**
|
|
213
231
|
* Computes the non-zero minimum in the entire data array using precomputed values
|
|
214
|
-
*
|
|
232
|
+
*
|
|
233
|
+
* @return {number} Non-zeros minimum of the data
|
|
215
234
|
*/
|
|
216
235
|
getMinNonZeroInTile() {
|
|
217
236
|
return this.getMinNonZeroInNdarraySubset(
|
|
@@ -225,7 +244,8 @@ class DenseDataExtrema2D {
|
|
|
225
244
|
|
|
226
245
|
/**
|
|
227
246
|
* Computes the non-zero maximum in the entire data array using precomputed values
|
|
228
|
-
*
|
|
247
|
+
*
|
|
248
|
+
* @return {number} Non-zeros maximum of the data
|
|
229
249
|
*/
|
|
230
250
|
getMaxNonZeroInTile() {
|
|
231
251
|
return this.getMaxNonZeroInNdarraySubset(
|
|
@@ -1,20 +1,15 @@
|
|
|
1
|
-
// @ts-check
|
|
2
1
|
import { mean, sum, variance, deviation } from 'd3-array';
|
|
3
2
|
|
|
3
|
+
/** @typedef {(values: number[]) => number | undefined} Aggregation */
|
|
4
|
+
|
|
4
5
|
/**
|
|
5
6
|
* Get an aggregation function from a function name.
|
|
6
|
-
* @
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
* the mean function will be used, and a console warning will be thrown.
|
|
10
|
-
* @returns {{
|
|
11
|
-
* mean: typeof mean,
|
|
12
|
-
* sum: typeof sum,
|
|
13
|
-
* variance: typeof variance,
|
|
14
|
-
* deviation: typeof deviation,
|
|
15
|
-
* }[Type]} The function of interest as determined by the string,
|
|
7
|
+
* @param {'mean' | 'sum' | 'variance' | 'deviation'} name - The type of aggregation.
|
|
8
|
+
* If an unknown string is passed, the mean function will be used (and a warning will be logged).
|
|
9
|
+
* @returns {Aggregation} The function of interest as determined by the string,
|
|
16
10
|
*/
|
|
17
11
|
const getAggregationFunction = (name) => {
|
|
12
|
+
/** @type {Aggregation} */
|
|
18
13
|
let aggFunc;
|
|
19
14
|
const lowerCaseName = name ? name.toLowerCase() : name;
|
|
20
15
|
switch (lowerCaseName) {
|
|
@@ -36,7 +31,6 @@ const getAggregationFunction = (name) => {
|
|
|
36
31
|
'Encountered an unsupported selectedRowsAggregationMode option.',
|
|
37
32
|
);
|
|
38
33
|
}
|
|
39
|
-
// @ts-expect-error - TS can't infer type-mapping
|
|
40
34
|
return aggFunc;
|
|
41
35
|
};
|
|
42
36
|
|