@jbrowse/plugin-wiggle 2.16.1 → 2.17.0

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 (83) hide show
  1. package/dist/LinearWiggleDisplay/components/Tooltip.js +1 -1
  2. package/dist/LinearWiggleDisplay/components/WiggleDisplayComponent.d.ts +1 -1
  3. package/dist/LinearWiggleDisplay/{models/configSchema.js → configSchema.js} +2 -2
  4. package/dist/LinearWiggleDisplay/index.d.ts +1 -1
  5. package/dist/LinearWiggleDisplay/index.js +3 -3
  6. package/{esm/LinearWiggleDisplay/models → dist/LinearWiggleDisplay}/model.d.ts +22 -6
  7. package/dist/LinearWiggleDisplay/{models/model.js → model.js} +82 -47
  8. package/dist/LinearWiggleDisplay/{models/renderSvg.js → renderSvg.js} +2 -1
  9. package/dist/MultiLinearWiggleDisplay/components/ColorLegend.d.ts +1 -1
  10. package/dist/MultiLinearWiggleDisplay/components/ScoreLegend.d.ts +1 -1
  11. package/dist/MultiLinearWiggleDisplay/components/WiggleDisplayComponent.d.ts +1 -1
  12. package/dist/MultiLinearWiggleDisplay/components/YScaleBars.d.ts +1 -1
  13. package/dist/MultiLinearWiggleDisplay/components/util.d.ts +1 -1
  14. package/dist/MultiLinearWiggleDisplay/{models/configSchema.js → configSchema.js} +2 -2
  15. package/dist/MultiLinearWiggleDisplay/index.js +2 -2
  16. package/dist/MultiLinearWiggleDisplay/{models/model.d.ts → model.d.ts} +30 -12
  17. package/dist/MultiLinearWiggleDisplay/{models/model.js → model.js} +118 -87
  18. package/dist/MultiLinearWiggleDisplay/{models/renderSvg.js → renderSvg.js} +1 -1
  19. package/dist/MultiRowXYPlotRenderer/configSchema.js +1 -1
  20. package/dist/MultiWiggleAdapter/MultiWiggleAdapter.d.ts +1 -1
  21. package/dist/MultiWiggleAdapter/MultiWiggleAdapter.js +4 -2
  22. package/dist/MultiXYPlotRenderer/configSchema.js +1 -1
  23. package/dist/WiggleBaseRenderer.d.ts +1 -1
  24. package/dist/XYPlotRenderer/configSchema.js +1 -1
  25. package/dist/getMultiWiggleSourcesAutorun.d.ts +17 -0
  26. package/dist/getMultiWiggleSourcesAutorun.js +35 -0
  27. package/dist/getQuantitativeStats.d.ts +13 -0
  28. package/dist/getQuantitativeStats.js +78 -0
  29. package/dist/getQuantitativeStatsAutorun.d.ts +13 -0
  30. package/dist/getQuantitativeStatsAutorun.js +37 -0
  31. package/dist/index.d.ts +2 -2
  32. package/{esm/shared/modelShared.d.ts → dist/shared/SharedWiggleMixin.d.ts} +17 -3
  33. package/dist/shared/{modelShared.js → SharedWiggleMixin.js} +21 -10
  34. package/dist/util.d.ts +5 -29
  35. package/dist/util.js +4 -100
  36. package/esm/LinearWiggleDisplay/components/Tooltip.js +1 -1
  37. package/esm/LinearWiggleDisplay/components/WiggleDisplayComponent.d.ts +1 -1
  38. package/esm/LinearWiggleDisplay/{models/configSchema.js → configSchema.js} +1 -1
  39. package/esm/LinearWiggleDisplay/index.d.ts +1 -1
  40. package/esm/LinearWiggleDisplay/index.js +3 -3
  41. package/{dist/LinearWiggleDisplay/models → esm/LinearWiggleDisplay}/model.d.ts +22 -6
  42. package/esm/LinearWiggleDisplay/{models/model.js → model.js} +82 -47
  43. package/esm/LinearWiggleDisplay/{models/renderSvg.js → renderSvg.js} +2 -1
  44. package/esm/MultiLinearWiggleDisplay/components/ColorLegend.d.ts +1 -1
  45. package/esm/MultiLinearWiggleDisplay/components/ScoreLegend.d.ts +1 -1
  46. package/esm/MultiLinearWiggleDisplay/components/WiggleDisplayComponent.d.ts +1 -1
  47. package/esm/MultiLinearWiggleDisplay/components/YScaleBars.d.ts +1 -1
  48. package/esm/MultiLinearWiggleDisplay/components/util.d.ts +1 -1
  49. package/esm/MultiLinearWiggleDisplay/{models/configSchema.js → configSchema.js} +1 -1
  50. package/esm/MultiLinearWiggleDisplay/index.js +2 -2
  51. package/esm/MultiLinearWiggleDisplay/{models/model.d.ts → model.d.ts} +30 -12
  52. package/esm/MultiLinearWiggleDisplay/{models/model.js → model.js} +119 -88
  53. package/esm/MultiLinearWiggleDisplay/{models/renderSvg.js → renderSvg.js} +1 -1
  54. package/esm/MultiRowXYPlotRenderer/configSchema.js +1 -1
  55. package/esm/MultiWiggleAdapter/MultiWiggleAdapter.d.ts +1 -1
  56. package/esm/MultiWiggleAdapter/MultiWiggleAdapter.js +4 -2
  57. package/esm/MultiXYPlotRenderer/configSchema.js +1 -1
  58. package/esm/WiggleBaseRenderer.d.ts +1 -1
  59. package/esm/XYPlotRenderer/configSchema.js +1 -1
  60. package/esm/getMultiWiggleSourcesAutorun.d.ts +17 -0
  61. package/esm/getMultiWiggleSourcesAutorun.js +32 -0
  62. package/esm/getQuantitativeStats.d.ts +13 -0
  63. package/esm/getQuantitativeStats.js +75 -0
  64. package/esm/getQuantitativeStatsAutorun.d.ts +13 -0
  65. package/esm/getQuantitativeStatsAutorun.js +34 -0
  66. package/esm/index.d.ts +2 -2
  67. package/{dist/shared/modelShared.d.ts → esm/shared/SharedWiggleMixin.d.ts} +17 -3
  68. package/esm/shared/{modelShared.js → SharedWiggleMixin.js} +21 -10
  69. package/esm/util.d.ts +5 -29
  70. package/esm/util.js +4 -98
  71. package/package.json +2 -2
  72. /package/dist/LinearWiggleDisplay/{models/configSchema.d.ts → configSchema.d.ts} +0 -0
  73. /package/dist/LinearWiggleDisplay/{models/renderSvg.d.ts → renderSvg.d.ts} +0 -0
  74. /package/dist/MultiLinearWiggleDisplay/{models/configSchema.d.ts → configSchema.d.ts} +0 -0
  75. /package/dist/MultiLinearWiggleDisplay/{models/renderSvg.d.ts → renderSvg.d.ts} +0 -0
  76. /package/dist/shared/{configShared.d.ts → SharedWiggleConfigSchema.d.ts} +0 -0
  77. /package/dist/shared/{configShared.js → SharedWiggleConfigSchema.js} +0 -0
  78. /package/esm/LinearWiggleDisplay/{models/configSchema.d.ts → configSchema.d.ts} +0 -0
  79. /package/esm/LinearWiggleDisplay/{models/renderSvg.d.ts → renderSvg.d.ts} +0 -0
  80. /package/esm/MultiLinearWiggleDisplay/{models/configSchema.d.ts → configSchema.d.ts} +0 -0
  81. /package/esm/MultiLinearWiggleDisplay/{models/renderSvg.d.ts → renderSvg.d.ts} +0 -0
  82. /package/esm/shared/{configShared.d.ts → SharedWiggleConfigSchema.d.ts} +0 -0
  83. /package/esm/shared/{configShared.js → SharedWiggleConfigSchema.js} +0 -0
package/esm/index.d.ts CHANGED
@@ -9,7 +9,7 @@ export default class WigglePlugin extends Plugin {
9
9
  install(pm: PluginManager): void;
10
10
  exports: {
11
11
  LinearWiggleDisplayReactComponent: (props: {
12
- model: import("./LinearWiggleDisplay/models/model").WiggleDisplayModel;
12
+ model: import("./LinearWiggleDisplay/model").WiggleDisplayModel;
13
13
  }) => import("react").JSX.Element;
14
14
  XYPlotRendererReactComponent: (props: {
15
15
  regions: import("@jbrowse/core/util/types").Region[];
@@ -84,5 +84,5 @@ export default class WigglePlugin extends Plugin {
84
84
  export * from './util';
85
85
  export { default as WiggleRendering } from './WiggleRendering';
86
86
  export { Tooltip, ReactComponent as LinearWiggleDisplayReactComponent, modelFactory as linearWiggleDisplayModelFactory, } from './LinearWiggleDisplay';
87
- export { type TooltipContentsComponent } from './Tooltip';
87
+ export type { TooltipContentsComponent } from './Tooltip';
88
88
  export { default as WiggleBaseRenderer } from './WiggleBaseRenderer';
@@ -195,7 +195,9 @@ export default function SharedWiggleMixin(configSchema: AnyConfigurationSchemaTy
195
195
  message: string | undefined;
196
196
  } & import("mobx-state-tree").IStateTreeNode<import("mobx-state-tree").IModelType<{
197
197
  id: import("mobx-state-tree").IOptionalIType<import("mobx-state-tree").ISimpleType<string>, [undefined]>;
198
- type: import("mobx-state-tree").ISimpleType<string>;
198
+ type: import("mobx-state-tree" /**
199
+ * #action
200
+ */).ISimpleType<string>;
199
201
  rpcDriverName: import("mobx-state-tree").IMaybe<import("mobx-state-tree").ISimpleType<string>>;
200
202
  }, {
201
203
  rendererTypeName: string;
@@ -284,17 +286,28 @@ export default function SharedWiggleMixin(configSchema: AnyConfigurationSchemaTy
284
286
  renderSvg(opts: import("@jbrowse/plugin-linear-genome-view").ExportSvgDisplayOptions): Promise<import("react").JSX.Element>;
285
287
  afterAttach(): void;
286
288
  } & {
289
+ /**
290
+ * #volatile
291
+ */
287
292
  message: undefined | string;
293
+ /**
294
+ * #volatile
295
+ */
288
296
  stats: {
297
+ currStatsBpPerPx: number;
289
298
  scoreMin: number;
290
299
  scoreMax: number;
291
300
  } | undefined;
301
+ /**
302
+ * #volatile
303
+ */
292
304
  statsFetchInProgress: undefined | AbortController;
293
305
  } & {
294
306
  /**
295
307
  * #action
296
308
  */
297
309
  updateQuantitativeStats(stats: {
310
+ currStatsBpPerPx: number;
298
311
  scoreMin: number;
299
312
  scoreMax: number;
300
313
  }): void;
@@ -313,7 +326,7 @@ export default function SharedWiggleMixin(configSchema: AnyConfigurationSchemaTy
313
326
  /**
314
327
  * #action
315
328
  */
316
- setLoading(aborter: AbortController): void;
329
+ setStatsLoading(aborter: AbortController): void;
317
330
  /**
318
331
  * #action
319
332
  * this overrides the BaseLinearDisplayModel to avoid popping up a
@@ -436,6 +449,7 @@ export default function SharedWiggleMixin(configSchema: AnyConfigurationSchemaTy
436
449
  readonly scaleOpts: {
437
450
  domain: number[] | undefined;
438
451
  stats: {
452
+ currStatsBpPerPx: number;
439
453
  scoreMin: number;
440
454
  scoreMax: number;
441
455
  } | undefined;
@@ -585,8 +599,8 @@ export default function SharedWiggleMixin(configSchema: AnyConfigurationSchemaTy
585
599
  };
586
600
  }, import("@jbrowse/core/configuration/configurationSchema").ConfigurationSchemaOptions<undefined, "displayId">>;
587
601
  }>> & import("mobx-state-tree/dist/internal").NonEmptyObject & import("mobx-state-tree")._NotCustomized, {
588
- type: string;
589
602
  id: string;
603
+ type: string;
590
604
  configuration: import("mobx-state-tree").ModelSnapshotType<Record<string, any>>;
591
605
  heightPreConfig: number | undefined;
592
606
  rpcDriverName: string | undefined;
@@ -74,8 +74,17 @@ export default function SharedWiggleMixin(configSchema) {
74
74
  configuration: ConfigurationReference(configSchema),
75
75
  }))
76
76
  .volatile(() => ({
77
+ /**
78
+ * #volatile
79
+ */
77
80
  message: undefined,
81
+ /**
82
+ * #volatile
83
+ */
78
84
  stats: undefined,
85
+ /**
86
+ * #volatile
87
+ */
79
88
  statsFetchInProgress: undefined,
80
89
  }))
81
90
  .actions(self => ({
@@ -83,14 +92,16 @@ export default function SharedWiggleMixin(configSchema) {
83
92
  * #action
84
93
  */
85
94
  updateQuantitativeStats(stats) {
86
- const { scoreMin, scoreMax } = stats;
95
+ const { currStatsBpPerPx, scoreMin, scoreMax } = stats;
87
96
  const EPSILON = 0.000001;
88
- if (!self.stats) {
89
- self.stats = { scoreMin, scoreMax };
90
- }
91
- else if (Math.abs(self.stats.scoreMax - scoreMax) > EPSILON ||
97
+ if (!self.stats ||
98
+ Math.abs(self.stats.scoreMax - scoreMax) > EPSILON ||
92
99
  Math.abs(self.stats.scoreMin - scoreMin) > EPSILON) {
93
- self.stats = { scoreMin, scoreMax };
100
+ self.stats = {
101
+ currStatsBpPerPx,
102
+ scoreMin,
103
+ scoreMax,
104
+ };
94
105
  }
95
106
  },
96
107
  /**
@@ -114,10 +125,10 @@ export default function SharedWiggleMixin(configSchema) {
114
125
  /**
115
126
  * #action
116
127
  */
117
- setLoading(aborter) {
118
- const { statsFetchInProgress: statsFetch } = self;
119
- if (statsFetch !== undefined && !statsFetch.signal.aborted) {
120
- statsFetch.abort();
128
+ setStatsLoading(aborter) {
129
+ if (self.statsFetchInProgress !== undefined &&
130
+ !self.statsFetchInProgress.signal.aborted) {
131
+ self.statsFetchInProgress.abort();
121
132
  }
122
133
  self.statsFetchInProgress = aborter;
123
134
  },
package/esm/util.d.ts CHANGED
@@ -1,5 +1,3 @@
1
- import { QuantitativeStats } from '@jbrowse/core/util/stats';
2
- import { AnyConfigurationModel } from '@jbrowse/core/configuration';
3
1
  export declare const YSCALEBAR_LABEL_OFFSET = 5;
4
2
  export interface ScaleOpts {
5
3
  domain: number[];
@@ -27,14 +25,15 @@ export interface Source {
27
25
  */
28
26
  export declare function getScale({ domain, range, scaleType, pivotValue, inverted, }: ScaleOpts): import("d3-scale").ScaleLinear<number, number, never> | import("d3-scale").ScaleLogarithmic<number, number, never> | import("d3-scale").ScaleQuantize<number, never>;
29
27
  /**
30
- * gets the origin for drawing the graph. for linear this is 0, for log this is arbitrarily set to log(1)==0
28
+ * gets the origin for drawing the graph. for linear this is 0, for log this is
29
+ * arbitrarily set to log(1)==0
31
30
  *
32
31
  * @param scaleType -
33
32
  */
34
- export declare function getOrigin(scaleType: string): 0 | 1;
33
+ export declare function getOrigin(scaleType: string): 1 | 0;
35
34
  /**
36
- * produces a "nice" domain that actually rounds down to 0 for the min
37
- * or 0 to the max depending on if all values are positive or negative
35
+ * produces a "nice" domain that actually rounds down to 0 for the min or 0 to
36
+ * the max depending on if all values are positive or negative
38
37
  *
39
38
  * @param object - containing attributes
40
39
  * - domain [min,max]
@@ -48,29 +47,6 @@ export declare function getNiceDomain({ scaleType, domain, bounds, }: {
48
47
  domain: readonly [number, number];
49
48
  bounds: readonly [number | undefined, number | undefined];
50
49
  }): [number, number];
51
- export declare function getQuantitativeStats(self: {
52
- adapterConfig: AnyConfigurationModel;
53
- configuration: AnyConfigurationModel;
54
- autoscaleType: string;
55
- setMessage: (str: string) => void;
56
- }, opts: {
57
- headers?: Record<string, string>;
58
- signal?: AbortSignal;
59
- filters: string[];
60
- }): Promise<QuantitativeStats>;
61
- export declare function quantitativeStatsAutorun(self: {
62
- featureDensityStatsReady: boolean;
63
- regionTooLarge: boolean;
64
- error: unknown;
65
- setLoading: (aborter: AbortController) => void;
66
- setError: (error: unknown) => void;
67
- updateQuantitativeStats: (stats: QuantitativeStats, statsRegion: string) => void;
68
- renderProps: () => Record<string, unknown>;
69
- configuration: AnyConfigurationModel;
70
- adapterConfig: AnyConfigurationModel;
71
- autoscaleType: string;
72
- setMessage: (str: string) => void;
73
- }): void;
74
50
  export declare function toP(s?: number): number;
75
51
  export declare function round(value: number): number;
76
52
  export declare function fillRectCtx(x: number, y: number, width: number, height: number, ctx: CanvasRenderingContext2D, color?: string): void;
package/esm/util.js CHANGED
@@ -1,9 +1,4 @@
1
1
  import { scaleLinear, scaleLog, scaleQuantize, } from '@mui/x-charts-vendor/d3-scale';
2
- import { autorun } from 'mobx';
3
- import { isAbortException, getSession, getContainingView, } from '@jbrowse/core/util';
4
- import { getRpcSessionId } from '@jbrowse/core/util/tracks';
5
- import { addDisposer, isAlive } from 'mobx-state-tree';
6
- import { getConf } from '@jbrowse/core/configuration';
7
2
  export const YSCALEBAR_LABEL_OFFSET = 5;
8
3
  /**
9
4
  * produces a d3-scale from arguments. applies a "nice domain" adjustment
@@ -44,7 +39,8 @@ export function getScale({ domain = [], range = [], scaleType, pivotValue, inver
44
39
  return scale;
45
40
  }
46
41
  /**
47
- * gets the origin for drawing the graph. for linear this is 0, for log this is arbitrarily set to log(1)==0
42
+ * gets the origin for drawing the graph. for linear this is 0, for log this is
43
+ * arbitrarily set to log(1)==0
48
44
  *
49
45
  * @param scaleType -
50
46
  */
@@ -67,8 +63,8 @@ export function getOrigin(scaleType /* , pivot, stats */) {
67
63
  return 0;
68
64
  }
69
65
  /**
70
- * produces a "nice" domain that actually rounds down to 0 for the min
71
- * or 0 to the max depending on if all values are positive or negative
66
+ * produces a "nice" domain that actually rounds down to 0 for the min or 0 to
67
+ * the max depending on if all values are positive or negative
72
68
  *
73
69
  * @param object - containing attributes
74
70
  * - domain [min,max]
@@ -121,96 +117,6 @@ export function getNiceDomain({ scaleType, domain, bounds, }) {
121
117
  scale.nice();
122
118
  return scale.domain();
123
119
  }
124
- export async function getQuantitativeStats(self, opts) {
125
- const { rpcManager } = getSession(self);
126
- const numStdDev = getConf(self, 'numStdDev') || 3;
127
- const { adapterConfig, autoscaleType } = self;
128
- const sessionId = getRpcSessionId(self);
129
- const params = {
130
- sessionId,
131
- adapterConfig,
132
- statusCallback: (message) => {
133
- if (isAlive(self)) {
134
- self.setMessage(message);
135
- }
136
- },
137
- ...opts,
138
- };
139
- if (autoscaleType === 'global' || autoscaleType === 'globalsd') {
140
- const results = (await rpcManager.call(sessionId, 'WiggleGetGlobalQuantitativeStats', params));
141
- const { scoreMin, scoreMean, scoreStdDev } = results;
142
- // globalsd uses heuristic to avoid unnecessary scoreMin<0
143
- // if the scoreMin is never less than 0
144
- // helps with most coverage bigwigs just being >0
145
- return autoscaleType === 'globalsd'
146
- ? {
147
- ...results,
148
- scoreMin: scoreMin >= 0 ? 0 : scoreMean - numStdDev * scoreStdDev,
149
- scoreMax: scoreMean + numStdDev * scoreStdDev,
150
- }
151
- : results;
152
- }
153
- if (autoscaleType === 'local' || autoscaleType === 'localsd') {
154
- const { dynamicBlocks, bpPerPx } = getContainingView(self);
155
- const results = (await rpcManager.call(sessionId, 'WiggleGetMultiRegionQuantitativeStats', {
156
- ...params,
157
- regions: dynamicBlocks.contentBlocks.map(region => {
158
- const { start, end } = region;
159
- return {
160
- ...JSON.parse(JSON.stringify(region)),
161
- start: Math.floor(start),
162
- end: Math.ceil(end),
163
- };
164
- }),
165
- bpPerPx,
166
- }));
167
- const { scoreMin, scoreMean, scoreStdDev } = results;
168
- // localsd uses heuristic to avoid unnecessary scoreMin<0 if the
169
- // scoreMin is never less than 0 helps with most coverage bigwigs
170
- // just being >0
171
- return autoscaleType === 'localsd'
172
- ? {
173
- ...results,
174
- scoreMin: scoreMin >= 0 ? 0 : scoreMean - numStdDev * scoreStdDev,
175
- scoreMax: scoreMean + numStdDev * scoreStdDev,
176
- }
177
- : results;
178
- }
179
- if (autoscaleType === 'zscale') {
180
- return rpcManager.call(sessionId, 'WiggleGetGlobalQuantitativeStats', params);
181
- }
182
- throw new Error(`invalid autoscaleType '${autoscaleType}'`);
183
- }
184
- export function quantitativeStatsAutorun(self) {
185
- addDisposer(self, autorun(async () => {
186
- try {
187
- const aborter = new AbortController();
188
- const view = getContainingView(self);
189
- self.setLoading(aborter);
190
- if (!view.initialized ||
191
- !self.featureDensityStatsReady ||
192
- self.regionTooLarge ||
193
- self.error) {
194
- return;
195
- }
196
- const statsRegion = JSON.stringify(view.dynamicBlocks);
197
- const wiggleStats = await getQuantitativeStats(self, {
198
- signal: aborter.signal,
199
- filters: [],
200
- ...self.renderProps(),
201
- });
202
- if (isAlive(self)) {
203
- self.updateQuantitativeStats(wiggleStats, statsRegion);
204
- }
205
- }
206
- catch (e) {
207
- if (!isAbortException(e) && isAlive(self)) {
208
- console.error(e);
209
- self.setError(e);
210
- }
211
- }
212
- }, { delay: 1000 }));
213
- }
214
120
  export function toP(s = 0) {
215
121
  return +(+s).toPrecision(6);
216
122
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jbrowse/plugin-wiggle",
3
- "version": "2.16.1",
3
+ "version": "2.17.0",
4
4
  "description": "JBrowse 2 wiggle adapters, tracks, etc.",
5
5
  "keywords": [
6
6
  "jbrowse",
@@ -65,5 +65,5 @@
65
65
  "distModule": "esm/index.js",
66
66
  "srcModule": "src/index.ts",
67
67
  "module": "esm/index.js",
68
- "gitHead": "c6a658d2344989895543f0456b1cf7dd3b937769"
68
+ "gitHead": "eed30b5e671f8f7823652d7cecc51aa89226de46"
69
69
  }