@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
@@ -3,11 +3,7 @@ import { AnyConfigurationSchemaType } from '@jbrowse/core/configuration';
3
3
  import { Feature, AnyReactComponentType } from '@jbrowse/core/util';
4
4
  import PluginManager from '@jbrowse/core/PluginManager';
5
5
  import { ExportSvgDisplayOptions } from '@jbrowse/plugin-linear-genome-view';
6
- interface Source {
7
- name: string;
8
- color?: string;
9
- group?: string;
10
- }
6
+ import { Source } from '../util';
11
7
  /**
12
8
  * #stateModel MultiLinearWiggleDisplay
13
9
  * extends
@@ -166,12 +162,12 @@ export declare function stateModelFactory(pluginManager: PluginManager, configSc
166
162
  rendererTypeName: string;
167
163
  error: unknown;
168
164
  message: string | undefined;
169
- } & import("mobx-state-tree" /**
170
- * #action
171
- */).IStateTreeNode<import("mobx-state-tree").IModelType<{
165
+ } & import("mobx-state-tree").IStateTreeNode<import("mobx-state-tree").IModelType<{
172
166
  id: import("mobx-state-tree").IOptionalIType<import("mobx-state-tree").ISimpleType<string>, [undefined]>;
173
167
  type: import("mobx-state-tree").ISimpleType<string>;
174
- rpcDriverName: import("mobx-state-tree").IMaybe<import("mobx-state-tree").ISimpleType<string>>;
168
+ rpcDriverName: import("mobx-state-tree" /**
169
+ * #getter
170
+ */).IMaybe<import("mobx-state-tree").ISimpleType<string>>;
175
171
  }, {
176
172
  rendererTypeName: string;
177
173
  error: unknown;
@@ -261,19 +257,21 @@ export declare function stateModelFactory(pluginManager: PluginManager, configSc
261
257
  } & {
262
258
  message: undefined | string;
263
259
  stats: {
260
+ currStatsBpPerPx: number;
264
261
  scoreMin: number;
265
262
  scoreMax: number;
266
263
  } | undefined;
267
264
  statsFetchInProgress: undefined | AbortController;
268
265
  } & {
269
266
  updateQuantitativeStats(stats: {
267
+ currStatsBpPerPx: number;
270
268
  scoreMin: number;
271
269
  scoreMax: number;
272
270
  }): void;
273
271
  setColor(color?: string): void;
274
272
  setPosColor(color?: string): void;
275
273
  setNegColor(color?: string): void;
276
- setLoading(aborter: AbortController): void;
274
+ setStatsLoading(aborter: AbortController): void;
277
275
  selectFeature(feature: Feature): void;
278
276
  setResolution(res: number): void;
279
277
  setFill(fill: number): void;
@@ -303,7 +301,9 @@ export declare function stateModelFactory(pluginManager: PluginManager, configSc
303
301
  } & import("mobx-state-tree/dist/internal").NonEmptyObject & {
304
302
  setSubschema(slotName: string, data: Record<string, unknown>): Record<string, unknown> | ({
305
303
  [x: string]: any;
306
- } & import("mobx-state-tree/dist/internal").NonEmptyObject & any & import("mobx-state-tree").IStateTreeNode<AnyConfigurationSchemaType>);
304
+ } & import("mobx-state-tree/dist/internal" /**
305
+ * #property
306
+ */).NonEmptyObject & any & import("mobx-state-tree").IStateTreeNode<AnyConfigurationSchemaType>);
307
307
  } & import("mobx-state-tree").IStateTreeNode<AnyConfigurationSchemaType>);
308
308
  } & import("mobx-state-tree").IStateTreeNode<AnyConfigurationSchemaType>;
309
309
  readonly autoscaleType: any;
@@ -315,6 +315,7 @@ export declare function stateModelFactory(pluginManager: PluginManager, configSc
315
315
  readonly scaleOpts: {
316
316
  domain: number[] | undefined;
317
317
  stats: {
318
+ currStatsBpPerPx: number;
318
319
  scoreMin: number;
319
320
  scoreMax: number;
320
321
  } | undefined;
@@ -402,6 +403,9 @@ export declare function stateModelFactory(pluginManager: PluginManager, configSc
402
403
  * implemented like this yet but flag can be used for this
403
404
  */
404
405
  readonly needsCustomLegend: boolean;
406
+ /**
407
+ * #getter
408
+ */
405
409
  readonly canHaveFill: boolean;
406
410
  /**
407
411
  * #getter
@@ -421,9 +425,14 @@ export declare function stateModelFactory(pluginManager: PluginManager, configSc
421
425
  */
422
426
  readonly sources: {
423
427
  color: string;
428
+ baseUri?: string;
424
429
  name: string;
425
430
  group?: string;
426
431
  }[] | undefined;
432
+ /**
433
+ * #getter
434
+ */
435
+ readonly quantitativeStatsReady: boolean;
427
436
  } & {
428
437
  /**
429
438
  * #getter
@@ -438,6 +447,10 @@ export declare function stateModelFactory(pluginManager: PluginManager, configSc
438
447
  */
439
448
  readonly useMinimalTicks: any;
440
449
  } & {
450
+ /**
451
+ * #method
452
+ */
453
+ adapterProps(): any;
441
454
  /**
442
455
  * #getter
443
456
  */
@@ -451,6 +464,11 @@ export declare function stateModelFactory(pluginManager: PluginManager, configSc
451
464
  * #getter
452
465
  */
453
466
  readonly colors: string[];
467
+ /**
468
+ * #getter
469
+ * unused currently
470
+ */
471
+ readonly quantitativeStatsRelevantToCurrentZoom: boolean;
454
472
  } & {
455
473
  /**
456
474
  * #method
@@ -467,7 +485,7 @@ export declare function stateModelFactory(pluginManager: PluginManager, configSc
467
485
  /**
468
486
  * #getter
469
487
  */
470
- readonly fillSetting: 2 | 0 | 1;
488
+ readonly fillSetting: 2 | 1 | 0;
471
489
  } & {
472
490
  /**
473
491
  * #method
@@ -1,20 +1,18 @@
1
1
  import { lazy } from 'react';
2
- import { addDisposer, isAlive, types } from 'mobx-state-tree';
3
- import { autorun } from 'mobx';
2
+ import { isAlive, types } from 'mobx-state-tree';
4
3
  import { axisPropsFromTickScale } from 'react-d3-axis-mod';
5
4
  import deepEqual from 'fast-deep-equal';
6
5
  // jbrowse imports
7
6
  import { getConf, } from '@jbrowse/core/configuration';
8
- import { getSession } from '@jbrowse/core/util';
9
- import { getRpcSessionId } from '@jbrowse/core/util/tracks';
7
+ import { getSession, getContainingView, } from '@jbrowse/core/util';
10
8
  import { set1 as colors } from '@jbrowse/core/ui/colors';
11
9
  // locals
12
- import { getScale, YSCALEBAR_LABEL_OFFSET } from '../../util';
13
- import SharedWiggleMixin from '../../shared/modelShared';
10
+ import { getScale, YSCALEBAR_LABEL_OFFSET } from '../util';
11
+ import SharedWiggleMixin from '../shared/SharedWiggleMixin';
14
12
  const randomColor = () => '#000000'.replaceAll('0', () => (~~(Math.random() * 16)).toString(16));
15
13
  // lazies
16
- const Tooltip = lazy(() => import('../components/Tooltip'));
17
- const SetColorDialog = lazy(() => import('../components/SetColorDialog'));
14
+ const Tooltip = lazy(() => import('./components/Tooltip'));
15
+ const SetColorDialog = lazy(() => import('./components/SetColorDialog'));
18
16
  // using a map because it preserves order
19
17
  const rendererTypes = new Map([
20
18
  ['xyplot', 'MultiXYPlotRenderer'],
@@ -130,6 +128,9 @@ export function stateModelFactory(pluginManager, configSchema) {
130
128
  get needsCustomLegend() {
131
129
  return self.rendererTypeName === 'MultiDensityRenderer';
132
130
  },
131
+ /**
132
+ * #getter
133
+ */
133
134
  get canHaveFill() {
134
135
  return (self.rendererTypeName === 'MultiXYPlotRenderer' ||
135
136
  self.rendererTypeName === 'MultiRowXYPlotRenderer');
@@ -168,6 +169,16 @@ export function stateModelFactory(pluginManager, configSchema) {
168
169
  (!this.isMultiRow ? colors[i] || randomColor() : 'blue'),
169
170
  }));
170
171
  },
172
+ /**
173
+ * #getter
174
+ */
175
+ get quantitativeStatsReady() {
176
+ const view = getContainingView(self);
177
+ return (view.initialized &&
178
+ self.featureDensityStatsReady &&
179
+ !self.regionTooLarge &&
180
+ !self.error);
181
+ },
171
182
  }))
172
183
  .views(self => ({
173
184
  /**
@@ -189,42 +200,6 @@ export function stateModelFactory(pluginManager, configSchema) {
189
200
  get useMinimalTicks() {
190
201
  return (getConf(self, 'minimalTicks') || this.rowHeightTooSmallForScalebar);
191
202
  },
192
- }))
193
- .views(self => ({
194
- /**
195
- * #getter
196
- */
197
- get ticks() {
198
- const { scaleType, domain, isMultiRow, rowHeight, useMinimalTicks } = self;
199
- if (!domain) {
200
- return undefined;
201
- }
202
- const offset = isMultiRow ? 0 : YSCALEBAR_LABEL_OFFSET;
203
- const ticks = axisPropsFromTickScale(getScale({
204
- scaleType,
205
- domain,
206
- range: [rowHeight - offset, offset],
207
- inverted: getConf(self, 'inverted'),
208
- }), 4);
209
- return useMinimalTicks ? { ...ticks, values: domain } : ticks;
210
- },
211
- /**
212
- * #getter
213
- */
214
- get colors() {
215
- return [
216
- 'red',
217
- 'blue',
218
- 'green',
219
- 'orange',
220
- 'purple',
221
- 'cyan',
222
- 'pink',
223
- 'darkblue',
224
- 'darkred',
225
- 'pink',
226
- ];
227
- },
228
203
  }))
229
204
  .views(self => {
230
205
  const { renderProps: superRenderProps } = self;
@@ -232,58 +207,114 @@ export function stateModelFactory(pluginManager, configSchema) {
232
207
  /**
233
208
  * #method
234
209
  */
235
- renderProps() {
210
+ adapterProps() {
236
211
  const superProps = superRenderProps();
237
- const { displayCrossHatches, filters, height, resolution, rpcDriverName, scaleOpts, stats, sources, ticks, rendererConfig: config, } = self;
238
212
  return {
239
213
  ...superProps,
240
- notReady: superProps.notReady || !sources || !stats,
241
214
  displayModel: self,
242
- config,
243
- displayCrossHatches,
244
- filters,
245
- height,
246
- resolution,
247
- rpcDriverName,
248
- scaleOpts,
249
- sources,
250
- ticks,
251
- onMouseMove: (_, f) => {
252
- self.setFeatureUnderMouse(f);
253
- },
254
- onMouseLeave: () => {
255
- self.setFeatureUnderMouse(undefined);
256
- },
215
+ config: self.rendererConfig,
216
+ filters: self.filters,
217
+ resolution: self.resolution,
218
+ rpcDriverName: self.rpcDriverName,
219
+ sources: self.sources,
257
220
  };
258
221
  },
259
222
  /**
260
223
  * #getter
261
224
  */
262
- get hasResolution() {
263
- return self.adapterCapabilities.includes('hasResolution');
225
+ get ticks() {
226
+ const { scaleType, domain, isMultiRow, rowHeight, useMinimalTicks } = self;
227
+ if (!domain) {
228
+ return undefined;
229
+ }
230
+ const offset = isMultiRow ? 0 : YSCALEBAR_LABEL_OFFSET;
231
+ const ticks = axisPropsFromTickScale(getScale({
232
+ scaleType,
233
+ domain,
234
+ range: [rowHeight - offset, offset],
235
+ inverted: getConf(self, 'inverted'),
236
+ }), 4);
237
+ return useMinimalTicks ? { ...ticks, values: domain } : ticks;
264
238
  },
265
239
  /**
266
240
  * #getter
267
241
  */
268
- get hasGlobalStats() {
269
- return self.adapterCapabilities.includes('hasGlobalStats');
242
+ get colors() {
243
+ return [
244
+ 'red',
245
+ 'blue',
246
+ 'green',
247
+ 'orange',
248
+ 'purple',
249
+ 'cyan',
250
+ 'pink',
251
+ 'darkblue',
252
+ 'darkred',
253
+ 'pink',
254
+ ];
270
255
  },
271
256
  /**
272
257
  * #getter
258
+ * unused currently
273
259
  */
274
- get fillSetting() {
275
- if (self.filled) {
276
- return 0;
277
- }
278
- else if (self.minSize === 1) {
279
- return 1;
280
- }
281
- else {
282
- return 2;
283
- }
260
+ get quantitativeStatsRelevantToCurrentZoom() {
261
+ var _a;
262
+ const view = getContainingView(self);
263
+ return ((_a = self.stats) === null || _a === void 0 ? void 0 : _a.currStatsBpPerPx) === view.bpPerPx;
284
264
  },
285
265
  };
286
266
  })
267
+ .views(self => ({
268
+ /**
269
+ * #method
270
+ */
271
+ renderProps() {
272
+ const superProps = self.adapterProps();
273
+ return {
274
+ ...superProps,
275
+ notReady: superProps.notReady || !self.sources || !self.stats,
276
+ displayModel: self,
277
+ rpcDriverName: self.rpcDriverName,
278
+ displayCrossHatches: self.displayCrossHatches,
279
+ height: self.height,
280
+ ticks: self.ticks,
281
+ stats: self.stats,
282
+ scaleOpts: self.scaleOpts,
283
+ onMouseMove: (_, f) => {
284
+ self.setFeatureUnderMouse(f);
285
+ },
286
+ onMouseLeave: () => {
287
+ self.setFeatureUnderMouse(undefined);
288
+ },
289
+ };
290
+ },
291
+ /**
292
+ * #getter
293
+ */
294
+ get hasResolution() {
295
+ return self.adapterCapabilities.includes('hasResolution');
296
+ },
297
+ /**
298
+ * #getter
299
+ */
300
+ get hasGlobalStats() {
301
+ return self.adapterCapabilities.includes('hasGlobalStats');
302
+ },
303
+ /**
304
+ * #getter
305
+ */
306
+ get fillSetting() {
307
+ if (self.filled) {
308
+ return 0;
309
+ }
310
+ else if (self.minSize === 1) {
311
+ return 1;
312
+ }
313
+ else {
314
+ return 2;
315
+ }
316
+ },
317
+ }))
287
318
  .views(self => {
288
319
  const { trackMenuItems: superTrackMenuItems } = self;
289
320
  const hasRenderings = getConf(self, 'defaultRendering');
@@ -366,20 +397,20 @@ export function stateModelFactory(pluginManager, configSchema) {
366
397
  // eslint-disable-next-line @typescript-eslint/no-floating-promises
367
398
  ;
368
399
  (async () => {
369
- const { quantitativeStatsAutorun } = await import('../../util');
370
- quantitativeStatsAutorun(self);
371
- addDisposer(self, autorun(async () => {
372
- const { rpcManager } = getSession(self);
373
- const { adapterConfig } = self;
374
- const sessionId = getRpcSessionId(self);
375
- const sources = (await rpcManager.call(sessionId, 'MultiWiggleGetSources', {
376
- sessionId,
377
- adapterConfig,
378
- }));
400
+ try {
401
+ const [{ getMultiWiggleSourcesAutorun }, { getQuantitativeStatsAutorun },] = await Promise.all([
402
+ import('../getMultiWiggleSourcesAutorun'),
403
+ import('../getQuantitativeStatsAutorun'),
404
+ ]);
405
+ getQuantitativeStatsAutorun(self);
406
+ getMultiWiggleSourcesAutorun(self);
407
+ }
408
+ catch (e) {
379
409
  if (isAlive(self)) {
380
- self.setSources(sources);
410
+ console.error(e);
411
+ getSession(self).notifyError(`${e}`, e);
381
412
  }
382
- }));
413
+ }
383
414
  })();
384
415
  },
385
416
  /**
@@ -1,7 +1,7 @@
1
1
  import React from 'react';
2
2
  import { getContainingView } from '@jbrowse/core/util';
3
3
  import { when } from 'mobx';
4
- import YScaleBars from '../components/YScaleBars';
4
+ import YScaleBars from './components/YScaleBars';
5
5
  export async function renderSvg(self, opts, superRenderSvg) {
6
6
  await when(() => !!self.stats && !!self.regionCannotBeRenderedText);
7
7
  const { offsetPx } = getContainingView(self);
@@ -35,7 +35,7 @@ const configSchema = ConfigurationSchema('MultiRowXYPlotRenderer', {
35
35
  */
36
36
  minSize: {
37
37
  type: 'number',
38
- defaultValue: 0,
38
+ defaultValue: 0.7,
39
39
  },
40
40
  }, {
41
41
  /**
@@ -21,7 +21,7 @@ export default class MultiWiggleAdapter extends BaseFeatureDataAdapter {
21
21
  getMultiRegionFeatureDensityStats(_regions: Region[]): Promise<{
22
22
  featureDensity: number;
23
23
  }>;
24
- getSources(): Promise<{
24
+ getSources(_regions: Region[]): Promise<{
25
25
  name: string;
26
26
  __name: unknown;
27
27
  }[]>;
@@ -65,11 +65,13 @@ class MultiWiggleAdapter extends BaseFeatureDataAdapter {
65
65
  }
66
66
  // always render bigwig instead of calculating a feature density for it
67
67
  async getMultiRegionFeatureDensityStats(_regions) {
68
- return { featureDensity: 0 };
68
+ return {
69
+ featureDensity: 0,
70
+ };
69
71
  }
70
72
  // in another adapter type, this could be dynamic depending on region or
71
73
  // something, but it is static for this particular multi-wiggle adapter type
72
- async getSources() {
74
+ async getSources(_regions) {
73
75
  const adapters = await this.getAdapters();
74
76
  return adapters.map(({ dataAdapter, source, name, ...rest }) => ({
75
77
  name: source,
@@ -35,7 +35,7 @@ const configSchema = ConfigurationSchema('MultiXYPlotRenderer', {
35
35
  */
36
36
  minSize: {
37
37
  type: 'number',
38
- defaultValue: 0,
38
+ defaultValue: 0.7,
39
39
  },
40
40
  }, {
41
41
  /**
@@ -54,4 +54,4 @@ export default abstract class WiggleBaseRenderer extends FeatureRendererType {
54
54
  */
55
55
  abstract draw<T extends RenderArgsDeserializedWithFeatures>(ctx: CanvasRenderingContext2D, props: T): Promise<Record<string, unknown> | undefined>;
56
56
  }
57
- export { type RenderArgsSerialized, type RenderResults, type ResultsDeserialized, type ResultsSerialized, } from '@jbrowse/core/pluggableElementTypes/renderers/FeatureRendererType';
57
+ export type { RenderArgsSerialized, RenderResults, ResultsDeserialized, ResultsSerialized, } from '@jbrowse/core/pluggableElementTypes/renderers/FeatureRendererType';
@@ -35,7 +35,7 @@ const configSchema = ConfigurationSchema('XYPlotRenderer', {
35
35
  */
36
36
  minSize: {
37
37
  type: 'number',
38
- defaultValue: 0,
38
+ defaultValue: 0.7,
39
39
  },
40
40
  }, {
41
41
  /**
@@ -0,0 +1,17 @@
1
+ import { AnyConfigurationModel } from '@jbrowse/core/configuration';
2
+ export interface Source {
3
+ name: string;
4
+ color?: string;
5
+ group?: string;
6
+ }
7
+ export declare function getMultiWiggleSourcesAutorun(self: {
8
+ quantitativeStatsReady: boolean;
9
+ configuration: AnyConfigurationModel;
10
+ adapterConfig: AnyConfigurationModel;
11
+ autoscaleType: string;
12
+ adapterProps: () => Record<string, unknown>;
13
+ setStatsLoading: (aborter: AbortController) => void;
14
+ setError: (error: unknown) => void;
15
+ setMessage: (str: string) => void;
16
+ setSources: (sources: Source[]) => void;
17
+ }): void;
@@ -0,0 +1,32 @@
1
+ import { autorun } from 'mobx';
2
+ import { addDisposer, isAlive } from 'mobx-state-tree';
3
+ // jbrowse
4
+ import { getContainingView, getSession, isAbortException, } from '@jbrowse/core/util';
5
+ import { getRpcSessionId } from '@jbrowse/core/util/tracks';
6
+ export function getMultiWiggleSourcesAutorun(self) {
7
+ addDisposer(self, autorun(async () => {
8
+ try {
9
+ const { rpcManager } = getSession(self);
10
+ const { adapterConfig } = self;
11
+ const sessionId = getRpcSessionId(self);
12
+ const view = getContainingView(self);
13
+ if (!view.initialized) {
14
+ return;
15
+ }
16
+ const sources = (await rpcManager.call(sessionId, 'MultiWiggleGetSources', {
17
+ regions: view.staticBlocks.contentBlocks,
18
+ sessionId,
19
+ adapterConfig,
20
+ }));
21
+ if (isAlive(self)) {
22
+ self.setSources(sources);
23
+ }
24
+ }
25
+ catch (e) {
26
+ if (!isAbortException(e) && isAlive(self)) {
27
+ console.error(e);
28
+ getSession(self).notifyError(`${e}`, e);
29
+ }
30
+ }
31
+ }));
32
+ }
@@ -0,0 +1,13 @@
1
+ import { QuantitativeStats } from '@jbrowse/core/util/stats';
2
+ import { AnyConfigurationModel } from '@jbrowse/core/configuration';
3
+ export declare function getQuantitativeStats(self: {
4
+ adapterConfig: AnyConfigurationModel;
5
+ configuration: AnyConfigurationModel;
6
+ autoscaleType: string;
7
+ setMessage: (str: string) => void;
8
+ }, opts: {
9
+ headers?: Record<string, string>;
10
+ signal?: AbortSignal;
11
+ filters: string[];
12
+ currStatsBpPerPx: number;
13
+ }): Promise<QuantitativeStats>;
@@ -0,0 +1,75 @@
1
+ import { isAlive } from 'mobx-state-tree';
2
+ // jbrowse
3
+ import { getSession, getContainingView } from '@jbrowse/core/util';
4
+ import { getRpcSessionId } from '@jbrowse/core/util/tracks';
5
+ import { getConf } from '@jbrowse/core/configuration';
6
+ export async function getQuantitativeStats(self, opts) {
7
+ const { rpcManager } = getSession(self);
8
+ const numStdDev = getConf(self, 'numStdDev') || 3;
9
+ const { adapterConfig, autoscaleType } = self;
10
+ const sessionId = getRpcSessionId(self);
11
+ const { currStatsBpPerPx } = opts;
12
+ const params = {
13
+ sessionId,
14
+ adapterConfig,
15
+ statusCallback: (message) => {
16
+ if (isAlive(self)) {
17
+ self.setMessage(message);
18
+ }
19
+ },
20
+ ...opts,
21
+ };
22
+ if (autoscaleType === 'global' || autoscaleType === 'globalsd') {
23
+ const results = (await rpcManager.call(sessionId, 'WiggleGetGlobalQuantitativeStats', params));
24
+ const { scoreMin, scoreMean, scoreStdDev } = results;
25
+ // globalsd uses heuristic to avoid unnecessary scoreMin<0
26
+ //
27
+ // if the scoreMin is never less than 0 helps with most coverage bigwigs
28
+ // just being >0
29
+ return autoscaleType === 'globalsd'
30
+ ? {
31
+ ...results,
32
+ scoreMin: scoreMin >= 0 ? 0 : scoreMean - numStdDev * scoreStdDev,
33
+ scoreMax: scoreMean + numStdDev * scoreStdDev,
34
+ currStatsBpPerPx,
35
+ }
36
+ : {
37
+ ...results,
38
+ currStatsBpPerPx,
39
+ };
40
+ }
41
+ if (autoscaleType === 'local' || autoscaleType === 'localsd') {
42
+ const { dynamicBlocks, bpPerPx } = getContainingView(self);
43
+ const results = (await rpcManager.call(sessionId, 'WiggleGetMultiRegionQuantitativeStats', {
44
+ ...params,
45
+ regions: dynamicBlocks.contentBlocks.map(region => {
46
+ const { start, end } = region;
47
+ return {
48
+ ...JSON.parse(JSON.stringify(region)),
49
+ start: Math.floor(start),
50
+ end: Math.ceil(end),
51
+ };
52
+ }),
53
+ bpPerPx,
54
+ }));
55
+ const { scoreMin, scoreMean, scoreStdDev } = results;
56
+ // localsd uses heuristic to avoid unnecessary scoreMin<0 if the
57
+ // scoreMin is never less than 0 helps with most coverage bigwigs
58
+ // just being >0
59
+ return autoscaleType === 'localsd'
60
+ ? {
61
+ ...results,
62
+ scoreMin: scoreMin >= 0 ? 0 : scoreMean - numStdDev * scoreStdDev,
63
+ scoreMax: scoreMean + numStdDev * scoreStdDev,
64
+ currStatsBpPerPx,
65
+ }
66
+ : {
67
+ ...results,
68
+ currStatsBpPerPx,
69
+ };
70
+ }
71
+ if (autoscaleType === 'zscale') {
72
+ return rpcManager.call(sessionId, 'WiggleGetGlobalQuantitativeStats', params);
73
+ }
74
+ throw new Error(`invalid autoscaleType '${autoscaleType}'`);
75
+ }
@@ -0,0 +1,13 @@
1
+ import { QuantitativeStats } from '@jbrowse/core/util/stats';
2
+ import { AnyConfigurationModel } from '@jbrowse/core/configuration';
3
+ export declare function getQuantitativeStatsAutorun(self: {
4
+ quantitativeStatsReady: boolean;
5
+ configuration: AnyConfigurationModel;
6
+ adapterConfig: AnyConfigurationModel;
7
+ autoscaleType: string;
8
+ adapterProps: () => Record<string, unknown>;
9
+ setStatsLoading: (aborter: AbortController) => void;
10
+ setError: (error: unknown) => void;
11
+ setMessage: (str: string) => void;
12
+ updateQuantitativeStats: (stats: QuantitativeStats, region: string) => void;
13
+ }): void;
@@ -0,0 +1,34 @@
1
+ import { autorun } from 'mobx';
2
+ import { addDisposer, isAlive } from 'mobx-state-tree';
3
+ // jbrowse
4
+ import { isAbortException, getContainingView } from '@jbrowse/core/util';
5
+ // locals
6
+ import { getQuantitativeStats } from './getQuantitativeStats';
7
+ export function getQuantitativeStatsAutorun(self) {
8
+ addDisposer(self, autorun(async () => {
9
+ try {
10
+ const view = getContainingView(self);
11
+ const aborter = new AbortController();
12
+ self.setStatsLoading(aborter);
13
+ if (!self.quantitativeStatsReady) {
14
+ return;
15
+ }
16
+ const statsRegion = JSON.stringify(view.dynamicBlocks);
17
+ const wiggleStats = await getQuantitativeStats(self, {
18
+ signal: aborter.signal,
19
+ filters: [],
20
+ currStatsBpPerPx: view.bpPerPx,
21
+ ...self.adapterProps(),
22
+ });
23
+ if (isAlive(self)) {
24
+ self.updateQuantitativeStats(wiggleStats, statsRegion);
25
+ }
26
+ }
27
+ catch (e) {
28
+ console.error(e);
29
+ if (!isAbortException(e) && isAlive(self)) {
30
+ self.setError(e);
31
+ }
32
+ }
33
+ }, { delay: 1000 }));
34
+ }