@jbrowse/plugin-wiggle 2.6.3 → 2.7.1

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 (84) hide show
  1. package/dist/CreateMultiWiggleExtension/index.js +14 -11
  2. package/dist/DensityRenderer/DensityRenderer.js +2 -2
  3. package/dist/LinePlotRenderer/LinePlotRenderer.js +2 -2
  4. package/dist/LinearWiggleDisplay/components/SetColorDialog.d.ts +6 -7
  5. package/dist/LinearWiggleDisplay/components/SetColorDialog.js +3 -3
  6. package/dist/LinearWiggleDisplay/components/Tooltip.js +1 -1
  7. package/dist/MultiDensityRenderer/MultiDensityRenderer.js +5 -8
  8. package/dist/MultiLineRenderer/MultiLineRenderer.js +5 -9
  9. package/dist/MultiLinearWiggleDisplay/components/DraggableDialog.d.ts +3 -4
  10. package/dist/MultiLinearWiggleDisplay/components/DraggableDialog.js +3 -3
  11. package/dist/MultiLinearWiggleDisplay/components/SetColorDialog.js +2 -96
  12. package/dist/MultiLinearWiggleDisplay/components/SourcesGrid.d.ts +8 -0
  13. package/dist/MultiLinearWiggleDisplay/components/SourcesGrid.js +138 -0
  14. package/dist/MultiLinearWiggleDisplay/components/Tooltip.d.ts +3 -2
  15. package/dist/MultiLinearWiggleDisplay/components/Tooltip.js +1 -1
  16. package/dist/MultiLinearWiggleDisplay/components/WiggleDisplayComponent.d.ts +2 -3
  17. package/dist/MultiLinearWiggleDisplay/components/WiggleDisplayComponent.js +2 -4
  18. package/dist/MultiLinearWiggleDisplay/components/util.js +2 -4
  19. package/dist/MultiRowLineRenderer/MultiRowLineRenderer.js +5 -5
  20. package/dist/MultiRowXYPlotRenderer/MultiRowXYPlotRenderer.js +5 -34
  21. package/dist/MultiWiggleAddTrackWidget/AddTrackWorkflow.js +16 -12
  22. package/dist/MultiWiggleRendering.d.ts +3 -4
  23. package/dist/MultiWiggleRendering.js +7 -5
  24. package/dist/MultiXYPlotRenderer/MultiXYPlotRenderer.js +5 -33
  25. package/dist/Tooltip.d.ts +5 -6
  26. package/dist/Tooltip.js +3 -3
  27. package/dist/WiggleRendering.d.ts +3 -4
  28. package/dist/WiggleRendering.js +3 -3
  29. package/dist/XYPlotRenderer/XYPlotRenderer.js +2 -27
  30. package/dist/drawDensity.d.ts +17 -0
  31. package/dist/drawDensity.js +66 -0
  32. package/dist/drawLine.d.ts +19 -0
  33. package/dist/drawLine.js +73 -0
  34. package/dist/drawXY.d.ts +19 -0
  35. package/dist/drawXY.js +164 -0
  36. package/dist/shared/YScaleBar.d.ts +2 -2
  37. package/dist/shared/YScaleBar.js +2 -1
  38. package/dist/shared/modelShared.d.ts +4 -1
  39. package/dist/util.d.ts +1 -0
  40. package/dist/util.js +17 -1
  41. package/esm/CreateMultiWiggleExtension/index.js +14 -11
  42. package/esm/DensityRenderer/DensityRenderer.js +1 -1
  43. package/esm/LinePlotRenderer/LinePlotRenderer.js +1 -1
  44. package/esm/LinearWiggleDisplay/components/SetColorDialog.d.ts +6 -7
  45. package/esm/LinearWiggleDisplay/components/SetColorDialog.js +3 -3
  46. package/esm/LinearWiggleDisplay/components/Tooltip.js +1 -1
  47. package/esm/MultiDensityRenderer/MultiDensityRenderer.js +4 -7
  48. package/esm/MultiLineRenderer/MultiLineRenderer.js +4 -8
  49. package/esm/MultiLinearWiggleDisplay/components/DraggableDialog.d.ts +3 -4
  50. package/esm/MultiLinearWiggleDisplay/components/DraggableDialog.js +3 -3
  51. package/esm/MultiLinearWiggleDisplay/components/SetColorDialog.js +2 -96
  52. package/esm/MultiLinearWiggleDisplay/components/SourcesGrid.d.ts +8 -0
  53. package/esm/MultiLinearWiggleDisplay/components/SourcesGrid.js +110 -0
  54. package/esm/MultiLinearWiggleDisplay/components/Tooltip.d.ts +3 -2
  55. package/esm/MultiLinearWiggleDisplay/components/Tooltip.js +1 -1
  56. package/esm/MultiLinearWiggleDisplay/components/WiggleDisplayComponent.d.ts +2 -3
  57. package/esm/MultiLinearWiggleDisplay/components/WiggleDisplayComponent.js +2 -2
  58. package/esm/MultiLinearWiggleDisplay/components/util.js +2 -4
  59. package/esm/MultiRowLineRenderer/MultiRowLineRenderer.js +4 -4
  60. package/esm/MultiRowXYPlotRenderer/MultiRowXYPlotRenderer.js +4 -10
  61. package/esm/MultiWiggleAddTrackWidget/AddTrackWorkflow.js +17 -13
  62. package/esm/MultiWiggleRendering.d.ts +3 -4
  63. package/esm/MultiWiggleRendering.js +7 -5
  64. package/esm/MultiXYPlotRenderer/MultiXYPlotRenderer.js +4 -9
  65. package/esm/Tooltip.d.ts +5 -6
  66. package/esm/Tooltip.js +3 -3
  67. package/esm/WiggleRendering.d.ts +3 -4
  68. package/esm/WiggleRendering.js +3 -3
  69. package/esm/XYPlotRenderer/XYPlotRenderer.js +1 -3
  70. package/esm/drawDensity.d.ts +17 -0
  71. package/esm/drawDensity.js +62 -0
  72. package/esm/drawLine.d.ts +19 -0
  73. package/esm/drawLine.js +69 -0
  74. package/esm/drawXY.d.ts +19 -0
  75. package/esm/{drawxy.js → drawXY.js} +17 -140
  76. package/esm/shared/YScaleBar.d.ts +2 -2
  77. package/esm/shared/YScaleBar.js +2 -1
  78. package/esm/shared/modelShared.d.ts +4 -1
  79. package/esm/util.d.ts +1 -0
  80. package/esm/util.js +15 -0
  81. package/package.json +3 -4
  82. package/dist/drawxy.d.ts +0 -50
  83. package/dist/drawxy.js +0 -289
  84. package/esm/drawxy.d.ts +0 -50
package/dist/drawxy.js DELETED
@@ -1,289 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.drawDensity = exports.drawLine = exports.drawXY = void 0;
4
- const configuration_1 = require("@jbrowse/core/configuration");
5
- const util_1 = require("@jbrowse/core/util");
6
- // locals
7
- const util_2 = require("./util");
8
- // avoid drawing negative width features for SVG exports
9
- function fillRectCtx(x, y, width, height, ctx, color) {
10
- if (width < 0) {
11
- x += width;
12
- width = -width;
13
- }
14
- if (height < 0) {
15
- y += height;
16
- height = -height;
17
- }
18
- if (color) {
19
- ctx.fillStyle = color;
20
- }
21
- ctx.fillRect(x, y, width, height);
22
- }
23
- const fudgeFactor = 0.4;
24
- const clipHeight = 2;
25
- function drawXY(ctx, props) {
26
- const { features, bpPerPx, regions, scaleOpts, height: unadjustedHeight, config, ticks, displayCrossHatches, offset = 0, colorCallback, Color, } = props;
27
- const [region] = regions;
28
- const width = (region.end - region.start) / bpPerPx;
29
- // the adjusted height takes into account YSCALEBAR_LABEL_OFFSET from the
30
- // wiggle display, and makes the height of the actual drawn area add
31
- // "padding" to the top and bottom of the display
32
- const height = unadjustedHeight - offset * 2;
33
- const filled = (0, configuration_1.readConfObject)(config, 'filled');
34
- const clipColor = (0, configuration_1.readConfObject)(config, 'clipColor');
35
- const summaryScoreMode = (0, configuration_1.readConfObject)(config, 'summaryScoreMode');
36
- const pivotValue = (0, configuration_1.readConfObject)(config, 'bicolorPivotValue');
37
- const minSize = (0, configuration_1.readConfObject)(config, 'minSize');
38
- const scale = (0, util_2.getScale)({ ...scaleOpts, range: [0, height] });
39
- const originY = (0, util_2.getOrigin)(scaleOpts.scaleType);
40
- const [niceMin, niceMax] = scale.domain();
41
- const toY = (n) => (0, util_1.clamp)(height - (scale(n) || 0), 0, height) + offset;
42
- const toOrigin = (n) => toY(originY) - toY(n);
43
- const getHeight = (n) => (filled ? toOrigin(n) : Math.max(minSize, 1));
44
- let hasClipping = false;
45
- let prevLeftPx = -Infinity;
46
- const reducedFeatures = [];
47
- const crossingOrigin = niceMin < pivotValue && niceMax > pivotValue;
48
- // we handle whiskers separately to render max row, min row, and avg in three
49
- // passes. this reduces subpixel rendering issues. note: for stylistic
50
- // reasons, clipping indicator is only drawn for score, not min/max score
51
- if (summaryScoreMode === 'whiskers') {
52
- let lastCol;
53
- let lastMix;
54
- for (const feature of features.values()) {
55
- const [leftPx, rightPx] = (0, util_1.featureSpanPx)(feature, region, bpPerPx);
56
- if (feature.get('summary')) {
57
- const w = Math.max(rightPx - leftPx + fudgeFactor, minSize);
58
- const max = feature.get('maxScore');
59
- const c = colorCallback(feature, max);
60
- const effectiveC = crossingOrigin
61
- ? c
62
- : c === lastCol
63
- ? lastMix
64
- : (lastMix = Color(c).lighten(0.4).toString());
65
- fillRectCtx(leftPx, toY(max), w, getHeight(max), ctx, effectiveC);
66
- lastCol = c;
67
- }
68
- }
69
- lastMix = undefined;
70
- lastCol = undefined;
71
- for (const feature of features.values()) {
72
- const [leftPx, rightPx] = (0, util_1.featureSpanPx)(feature, region, bpPerPx);
73
- const score = feature.get('score');
74
- const max = feature.get('maxScore');
75
- const min = feature.get('minScore');
76
- const summary = feature.get('summary');
77
- const c = colorCallback(feature, score);
78
- const effectiveC = crossingOrigin && summary
79
- ? c === lastCol
80
- ? lastMix
81
- : (lastMix = Color(colorCallback(feature, max))
82
- .mix(Color(colorCallback(feature, min)))
83
- .toString())
84
- : c;
85
- const w = Math.max(rightPx - leftPx + fudgeFactor, minSize);
86
- // create reduced features, avoiding multiple features per px
87
- if (Math.floor(leftPx) !== Math.floor(prevLeftPx)) {
88
- reducedFeatures.push(feature);
89
- prevLeftPx = leftPx;
90
- }
91
- hasClipping = hasClipping || score < niceMin || score > niceMax;
92
- fillRectCtx(leftPx, toY(score), w, getHeight(score), ctx, effectiveC);
93
- lastCol = c;
94
- }
95
- lastMix = undefined;
96
- lastCol = undefined;
97
- for (const feature of features.values()) {
98
- const [leftPx, rightPx] = (0, util_1.featureSpanPx)(feature, region, bpPerPx);
99
- if (feature.get('summary')) {
100
- const min = feature.get('minScore');
101
- const c = colorCallback(feature, min);
102
- const w = Math.max(rightPx - leftPx + fudgeFactor, minSize);
103
- const effectiveC = crossingOrigin
104
- ? c
105
- : c === lastCol
106
- ? lastMix
107
- : (lastMix = Color(c).darken(0.4).toString());
108
- fillRectCtx(leftPx, toY(min), w, getHeight(min), ctx, effectiveC);
109
- lastCol = c;
110
- }
111
- }
112
- }
113
- else {
114
- for (const feature of features.values()) {
115
- const [leftPx, rightPx] = (0, util_1.featureSpanPx)(feature, region, bpPerPx);
116
- // create reduced features, avoiding multiple features per px
117
- if (Math.floor(leftPx) !== Math.floor(prevLeftPx)) {
118
- reducedFeatures.push(feature);
119
- prevLeftPx = leftPx;
120
- }
121
- const score = feature.get('score');
122
- const c = colorCallback(feature, score);
123
- hasClipping = hasClipping || score < niceMin || score > niceMax;
124
- const w = Math.max(rightPx - leftPx + fudgeFactor, minSize);
125
- if (summaryScoreMode === 'max') {
126
- const s = feature.get('summary') ? feature.get('maxScore') : score;
127
- fillRectCtx(leftPx, toY(s), w, getHeight(s), ctx, c);
128
- }
129
- else if (summaryScoreMode === 'min') {
130
- const s = feature.get('summary') ? feature.get('minScore') : score;
131
- fillRectCtx(leftPx, toY(s), w, getHeight(s), ctx, c);
132
- }
133
- else {
134
- fillRectCtx(leftPx, toY(score), w, getHeight(score), ctx, c);
135
- }
136
- }
137
- }
138
- // second pass: draw clipping
139
- // avoid persisting the red fillstyle with save/restore
140
- ctx.save();
141
- if (hasClipping) {
142
- ctx.fillStyle = clipColor;
143
- for (const feature of features.values()) {
144
- const [leftPx, rightPx] = (0, util_1.featureSpanPx)(feature, region, bpPerPx);
145
- const w = rightPx - leftPx + fudgeFactor;
146
- const score = feature.get('score');
147
- if (score > niceMax) {
148
- fillRectCtx(leftPx, offset, w, clipHeight, ctx);
149
- }
150
- else if (score < niceMin && scaleOpts.scaleType !== 'log') {
151
- fillRectCtx(leftPx, unadjustedHeight, w, clipHeight, ctx);
152
- }
153
- }
154
- }
155
- ctx.restore();
156
- if (displayCrossHatches) {
157
- ctx.lineWidth = 1;
158
- ctx.strokeStyle = 'rgba(200,200,200,0.5)';
159
- ticks.values.forEach(tick => {
160
- ctx.beginPath();
161
- ctx.moveTo(0, Math.round(toY(tick)));
162
- ctx.lineTo(width, Math.round(toY(tick)));
163
- ctx.stroke();
164
- });
165
- }
166
- return { reducedFeatures };
167
- }
168
- exports.drawXY = drawXY;
169
- function drawLine(ctx, props) {
170
- const { features, regions, bpPerPx, scaleOpts, height: unadjustedHeight, ticks: { values }, displayCrossHatches, colorCallback, config, offset = 0, } = props;
171
- const [region] = regions;
172
- const width = (region.end - region.start) / bpPerPx;
173
- // the adjusted height takes into account YSCALEBAR_LABEL_OFFSET from the
174
- // wiggle display, and makes the height of the actual drawn area add
175
- // "padding" to the top and bottom of the display
176
- const height = unadjustedHeight - offset * 2;
177
- const clipColor = (0, configuration_1.readConfObject)(config, 'clipColor');
178
- const scale = (0, util_2.getScale)({ ...scaleOpts, range: [0, height] });
179
- const [niceMin, niceMax] = scale.domain();
180
- const toY = (n) => (0, util_1.clamp)(height - (scale(n) || 0), 0, height) + offset;
181
- let lastVal;
182
- let prevLeftPx = -Infinity;
183
- const reducedFeatures = [];
184
- for (const feature of features.values()) {
185
- const [leftPx, rightPx] = (0, util_1.featureSpanPx)(feature, region, bpPerPx);
186
- // create reduced features, avoiding multiple features per px
187
- if (Math.floor(leftPx) !== Math.floor(prevLeftPx)) {
188
- reducedFeatures.push(feature);
189
- prevLeftPx = leftPx;
190
- }
191
- const score = feature.get('score');
192
- const lowClipping = score < niceMin;
193
- const highClipping = score > niceMax;
194
- const w = rightPx - leftPx + fudgeFactor;
195
- const c = colorCallback(feature, score);
196
- ctx.beginPath();
197
- ctx.strokeStyle = c;
198
- const startPos = lastVal !== undefined ? lastVal : score;
199
- if (!region.reversed) {
200
- ctx.moveTo(leftPx, toY(startPos));
201
- ctx.lineTo(leftPx, toY(score));
202
- ctx.lineTo(rightPx, toY(score));
203
- }
204
- else {
205
- ctx.moveTo(rightPx, toY(startPos));
206
- ctx.lineTo(rightPx, toY(score));
207
- ctx.lineTo(leftPx, toY(score));
208
- }
209
- ctx.stroke();
210
- lastVal = score;
211
- if (highClipping) {
212
- ctx.fillStyle = clipColor;
213
- ctx.fillRect(leftPx, offset, w, clipHeight);
214
- }
215
- else if (lowClipping && scaleOpts.scaleType !== 'log') {
216
- ctx.fillStyle = clipColor;
217
- ctx.fillRect(leftPx, height - clipHeight, w, height);
218
- }
219
- }
220
- if (displayCrossHatches) {
221
- ctx.lineWidth = 1;
222
- ctx.strokeStyle = 'rgba(200,200,200,0.5)';
223
- values.forEach(tick => {
224
- ctx.beginPath();
225
- ctx.moveTo(0, Math.round(toY(tick)));
226
- ctx.lineTo(width, Math.round(toY(tick)));
227
- ctx.stroke();
228
- });
229
- }
230
- return { reducedFeatures };
231
- }
232
- exports.drawLine = drawLine;
233
- function drawDensity(ctx, props) {
234
- const { features, regions, bpPerPx, scaleOpts, height, config } = props;
235
- const [region] = regions;
236
- const pivot = (0, configuration_1.readConfObject)(config, 'bicolorPivot');
237
- const pivotValue = (0, configuration_1.readConfObject)(config, 'bicolorPivotValue');
238
- const negColor = (0, configuration_1.readConfObject)(config, 'negColor');
239
- const posColor = (0, configuration_1.readConfObject)(config, 'posColor');
240
- const color = (0, configuration_1.readConfObject)(config, 'color');
241
- const clipColor = (0, configuration_1.readConfObject)(config, 'clipColor');
242
- const crossing = pivot !== 'none' && scaleOpts.scaleType !== 'log';
243
- const scale = (0, util_2.getScale)({
244
- ...scaleOpts,
245
- pivotValue: crossing ? pivotValue : undefined,
246
- range: crossing ? [negColor, 'white', posColor] : ['white', posColor],
247
- });
248
- const scale2 = (0, util_2.getScale)({ ...scaleOpts, range: [0, height] });
249
- const cb = color === '#f0f'
250
- ? (_, score) => scale(score)
251
- : (feature, score) => (0, configuration_1.readConfObject)(config, 'color', { feature, score });
252
- const [niceMin, niceMax] = scale2.domain();
253
- let prevLeftPx = -Infinity;
254
- let hasClipping = false;
255
- const reducedFeatures = [];
256
- for (const feature of features.values()) {
257
- const [leftPx, rightPx] = (0, util_1.featureSpanPx)(feature, region, bpPerPx);
258
- // create reduced features, avoiding multiple features per px
259
- if (Math.floor(leftPx) !== Math.floor(prevLeftPx)) {
260
- reducedFeatures.push(feature);
261
- prevLeftPx = leftPx;
262
- }
263
- const score = feature.get('score');
264
- hasClipping = hasClipping || score > niceMax || score < niceMin;
265
- const w = rightPx - leftPx + fudgeFactor;
266
- ctx.fillStyle = cb(feature, score);
267
- ctx.fillRect(leftPx, 0, w, height);
268
- }
269
- // second pass: draw clipping
270
- // avoid persisting the red fillstyle with save/restore
271
- ctx.save();
272
- if (hasClipping) {
273
- ctx.fillStyle = clipColor;
274
- for (const feature of features.values()) {
275
- const [leftPx, rightPx] = (0, util_1.featureSpanPx)(feature, region, bpPerPx);
276
- const w = rightPx - leftPx + fudgeFactor;
277
- const score = feature.get('score');
278
- if (score > niceMax) {
279
- fillRectCtx(leftPx, 0, w, clipHeight, ctx);
280
- }
281
- else if (score < niceMin && scaleOpts.scaleType !== 'log') {
282
- fillRectCtx(leftPx, 0, w, clipHeight, ctx);
283
- }
284
- }
285
- }
286
- ctx.restore();
287
- return { reducedFeatures };
288
- }
289
- exports.drawDensity = drawDensity;
package/esm/drawxy.d.ts DELETED
@@ -1,50 +0,0 @@
1
- import { AnyConfigurationModel } from '@jbrowse/core/configuration';
2
- import { Feature, Region } from '@jbrowse/core/util';
3
- import { ScaleOpts } from './util';
4
- export declare function drawXY(ctx: CanvasRenderingContext2D, props: {
5
- features: Map<string, Feature> | Feature[];
6
- bpPerPx: number;
7
- regions: Region[];
8
- scaleOpts: ScaleOpts;
9
- height: number;
10
- ticks: {
11
- values: number[];
12
- };
13
- config: AnyConfigurationModel;
14
- displayCrossHatches: boolean;
15
- offset?: number;
16
- colorCallback: (f: Feature, score: number) => string;
17
- Color: typeof import('color');
18
- }): {
19
- reducedFeatures: Feature[];
20
- };
21
- export declare function drawLine(ctx: CanvasRenderingContext2D, props: {
22
- features: Map<string, Feature> | Feature[];
23
- regions: Region[];
24
- bpPerPx: number;
25
- scaleOpts: ScaleOpts;
26
- height: number;
27
- ticks: {
28
- values: number[];
29
- };
30
- displayCrossHatches: boolean;
31
- colorCallback: (f: Feature, score: number) => string;
32
- config: AnyConfigurationModel;
33
- offset?: number;
34
- }): {
35
- reducedFeatures: Feature[];
36
- };
37
- export declare function drawDensity(ctx: CanvasRenderingContext2D, props: {
38
- features: Map<string, Feature> | Feature[];
39
- regions: Region[];
40
- bpPerPx: number;
41
- scaleOpts: ScaleOpts;
42
- height: number;
43
- ticks: {
44
- values: number[];
45
- };
46
- displayCrossHatches: boolean;
47
- config: AnyConfigurationModel;
48
- }): {
49
- reducedFeatures: Feature[];
50
- };