@jbrowse/plugin-wiggle 1.6.3 → 1.6.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/BigWigAdapter/configSchema.d.ts +1 -1
- package/dist/DensityRenderer/index.d.ts +1 -1
- package/dist/LinePlotRenderer/LinePlotRenderer.d.ts +1 -1
- package/dist/LinePlotRenderer/configSchema.d.ts +1 -1
- package/dist/LinePlotRenderer/index.d.ts +1 -1
- package/dist/LinearWiggleDisplay/components/Tooltip.d.ts +2 -2
- package/dist/LinearWiggleDisplay/components/WiggleDisplayComponent.d.ts +2 -4
- package/dist/LinearWiggleDisplay/components/YScaleBar.d.ts +7 -0
- package/dist/LinearWiggleDisplay/models/configSchema.d.ts +1 -1
- package/dist/LinearWiggleDisplay/models/model.d.ts +4 -4
- package/dist/WiggleBaseRenderer.d.ts +1 -1
- package/dist/XYPlotRenderer/index.d.ts +1 -1
- package/dist/configSchema.d.ts +1 -1
- package/dist/index.d.ts +11 -11
- package/dist/plugin-wiggle.cjs.development.js +48 -64
- package/dist/plugin-wiggle.cjs.development.js.map +1 -1
- package/dist/plugin-wiggle.cjs.production.min.js +1 -1
- package/dist/plugin-wiggle.cjs.production.min.js.map +1 -1
- package/dist/plugin-wiggle.esm.js +50 -66
- package/dist/plugin-wiggle.esm.js.map +1 -1
- package/package.json +5 -5
- package/src/LinearWiggleDisplay/components/Tooltip.tsx +3 -3
- package/src/LinearWiggleDisplay/components/WiggleDisplayComponent.tsx +18 -23
- package/src/LinearWiggleDisplay/components/YScaleBar.tsx +26 -0
- package/src/LinearWiggleDisplay/models/configSchema.ts +5 -0
- package/src/LinearWiggleDisplay/models/model.tsx +26 -29
- package/src/WiggleBaseRenderer.tsx +2 -2
- package/src/WiggleRPC/rpcMethods.ts +2 -9
- package/src/XYPlotRenderer/XYPlotRenderer.ts +3 -7
- package/src/declare.d.ts +1 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@jbrowse/plugin-wiggle",
|
|
3
|
-
"version": "1.6.
|
|
3
|
+
"version": "1.6.6",
|
|
4
4
|
"description": "JBrowse 2 wiggle adapters, tracks, etc.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"jbrowse",
|
|
@@ -35,15 +35,15 @@
|
|
|
35
35
|
"useSrc": "node ../../scripts/useSrc.js"
|
|
36
36
|
},
|
|
37
37
|
"dependencies": {
|
|
38
|
-
"@gmod/bbi": "^1.0.
|
|
38
|
+
"@gmod/bbi": "^1.0.32",
|
|
39
39
|
"@material-ui/icons": "^4.11.2",
|
|
40
40
|
"@popperjs/core": "^2.11.0",
|
|
41
|
-
"abortable-promise-cache": "^1.
|
|
41
|
+
"abortable-promise-cache": "^1.5.0",
|
|
42
42
|
"color": "^3.1.1",
|
|
43
43
|
"d3-scale": "^3.2.3",
|
|
44
44
|
"json-stable-stringify": "^1.0.1",
|
|
45
45
|
"react-color": "^2.19.3",
|
|
46
|
-
"react-d3-axis": "^0.1.
|
|
46
|
+
"react-d3-axis-mod": "^0.1.3",
|
|
47
47
|
"react-popper": "^2.0.0"
|
|
48
48
|
},
|
|
49
49
|
"peerDependencies": {
|
|
@@ -60,5 +60,5 @@
|
|
|
60
60
|
"publishConfig": {
|
|
61
61
|
"access": "public"
|
|
62
62
|
},
|
|
63
|
-
"gitHead": "
|
|
63
|
+
"gitHead": "9fcca7793af0df2d6e527ddaace2b368c8ed2879"
|
|
64
64
|
}
|
|
@@ -29,7 +29,7 @@ const useStyles = makeStyles(theme => ({
|
|
|
29
29
|
color: theme.palette.common.white,
|
|
30
30
|
fontFamily: theme.typography.fontFamily,
|
|
31
31
|
padding: '4px 8px',
|
|
32
|
-
fontSize: theme.typography.pxToRem(
|
|
32
|
+
fontSize: theme.typography.pxToRem(12),
|
|
33
33
|
lineHeight: `${round(14 / 10)}em`,
|
|
34
34
|
maxWidth: 300,
|
|
35
35
|
wordWrap: 'break-word',
|
|
@@ -91,7 +91,7 @@ const Tooltip = observer(
|
|
|
91
91
|
height: number
|
|
92
92
|
clientMouseCoord: Coord
|
|
93
93
|
offsetMouseCoord: Coord
|
|
94
|
-
clientRect?:
|
|
94
|
+
clientRect?: DOMRect
|
|
95
95
|
|
|
96
96
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
97
97
|
TooltipContents: React.FC<any>
|
|
@@ -161,7 +161,7 @@ const WiggleTooltip = observer(
|
|
|
161
161
|
height: number
|
|
162
162
|
offsetMouseCoord: Coord
|
|
163
163
|
clientMouseCoord: Coord
|
|
164
|
-
clientRect?:
|
|
164
|
+
clientRect?: DOMRect
|
|
165
165
|
}) => {
|
|
166
166
|
return <Tooltip TooltipContents={TooltipContents} {...props} />
|
|
167
167
|
},
|
|
@@ -1,32 +1,25 @@
|
|
|
1
|
+
import React from 'react'
|
|
2
|
+
import {
|
|
3
|
+
measureText,
|
|
4
|
+
getContainingView,
|
|
5
|
+
getContainingTrack,
|
|
6
|
+
} from '@jbrowse/core/util'
|
|
7
|
+
import { getConf } from '@jbrowse/core/configuration'
|
|
1
8
|
import { BaseLinearDisplayComponent } from '@jbrowse/plugin-linear-genome-view'
|
|
2
9
|
import { observer } from 'mobx-react'
|
|
3
|
-
import React from 'react'
|
|
4
|
-
import { Axis, LEFT, RIGHT } from 'react-d3-axis'
|
|
5
10
|
import { WiggleDisplayModel } from '../models/model'
|
|
6
|
-
|
|
7
|
-
export const YScaleBar = observer(
|
|
8
|
-
({
|
|
9
|
-
model,
|
|
10
|
-
orientation,
|
|
11
|
-
}: {
|
|
12
|
-
model: WiggleDisplayModel
|
|
13
|
-
orientation?: string
|
|
14
|
-
}) => {
|
|
15
|
-
const { ticks } = model
|
|
16
|
-
|
|
17
|
-
return (
|
|
18
|
-
<Axis
|
|
19
|
-
{...ticks}
|
|
20
|
-
format={(n: number) => n}
|
|
21
|
-
style={{ orient: orientation === 'left' ? LEFT : RIGHT }}
|
|
22
|
-
/>
|
|
23
|
-
)
|
|
24
|
-
},
|
|
25
|
-
)
|
|
11
|
+
import YScaleBar from './YScaleBar'
|
|
26
12
|
|
|
27
13
|
const LinearWiggleDisplay = observer((props: { model: WiggleDisplayModel }) => {
|
|
28
14
|
const { model } = props
|
|
29
15
|
const { stats, height, needsScalebar } = model
|
|
16
|
+
|
|
17
|
+
// @ts-ignore
|
|
18
|
+
const { trackLabels } = getContainingView(model)
|
|
19
|
+
const left =
|
|
20
|
+
trackLabels === 'overlapping'
|
|
21
|
+
? measureText(getConf(getContainingTrack(model), 'name'), 12.8) + 100
|
|
22
|
+
: 50
|
|
30
23
|
return (
|
|
31
24
|
<div>
|
|
32
25
|
<BaseLinearDisplayComponent {...props} />
|
|
@@ -35,7 +28,7 @@ const LinearWiggleDisplay = observer((props: { model: WiggleDisplayModel }) => {
|
|
|
35
28
|
style={{
|
|
36
29
|
position: 'absolute',
|
|
37
30
|
top: 0,
|
|
38
|
-
left
|
|
31
|
+
left,
|
|
39
32
|
pointerEvents: 'none',
|
|
40
33
|
height,
|
|
41
34
|
width: 50,
|
|
@@ -49,3 +42,5 @@ const LinearWiggleDisplay = observer((props: { model: WiggleDisplayModel }) => {
|
|
|
49
42
|
})
|
|
50
43
|
|
|
51
44
|
export default LinearWiggleDisplay
|
|
45
|
+
|
|
46
|
+
export { YScaleBar }
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import React from 'react'
|
|
2
|
+
import { observer } from 'mobx-react'
|
|
3
|
+
import { Axis, LEFT, RIGHT } from 'react-d3-axis-mod'
|
|
4
|
+
import { WiggleDisplayModel } from '../models/model'
|
|
5
|
+
|
|
6
|
+
const YScaleBar = observer(
|
|
7
|
+
({
|
|
8
|
+
model,
|
|
9
|
+
orientation,
|
|
10
|
+
}: {
|
|
11
|
+
model: WiggleDisplayModel
|
|
12
|
+
orientation?: string
|
|
13
|
+
}) => {
|
|
14
|
+
const { ticks } = model
|
|
15
|
+
|
|
16
|
+
return ticks ? (
|
|
17
|
+
<Axis
|
|
18
|
+
{...ticks}
|
|
19
|
+
shadow={2}
|
|
20
|
+
format={(n: number) => n}
|
|
21
|
+
style={{ orient: orientation === 'left' ? LEFT : RIGHT }}
|
|
22
|
+
/>
|
|
23
|
+
) : null
|
|
24
|
+
},
|
|
25
|
+
)
|
|
26
|
+
export default YScaleBar
|
|
@@ -27,6 +27,11 @@ export default function WiggleConfigFactory(pluginManager: PluginManager) {
|
|
|
27
27
|
description:
|
|
28
28
|
'global/local using their min/max values or w/ standard deviations (globalsd/localsd)',
|
|
29
29
|
},
|
|
30
|
+
minimalTicks: {
|
|
31
|
+
type: 'boolean',
|
|
32
|
+
defaultValue: false,
|
|
33
|
+
description: 'use the minimal amount of ticks',
|
|
34
|
+
},
|
|
30
35
|
|
|
31
36
|
minScore: {
|
|
32
37
|
type: 'number',
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import React, { lazy } from 'react'
|
|
2
2
|
import {
|
|
3
3
|
ConfigurationReference,
|
|
4
|
+
AnyConfigurationSchemaType,
|
|
4
5
|
getConf,
|
|
5
6
|
readConfObject,
|
|
6
7
|
} from '@jbrowse/core/configuration'
|
|
@@ -15,14 +16,13 @@ import {
|
|
|
15
16
|
BaseLinearDisplay,
|
|
16
17
|
LinearGenomeViewModel,
|
|
17
18
|
} from '@jbrowse/plugin-linear-genome-view'
|
|
18
|
-
import { autorun,
|
|
19
|
+
import { autorun, when } from 'mobx'
|
|
19
20
|
import { addDisposer, isAlive, types, getEnv, Instance } from 'mobx-state-tree'
|
|
20
21
|
import PluginManager from '@jbrowse/core/PluginManager'
|
|
21
22
|
|
|
22
|
-
import { AnyConfigurationSchemaType } from '@jbrowse/core/configuration/configurationSchema'
|
|
23
23
|
import { FeatureStats } from '@jbrowse/core/util/stats'
|
|
24
24
|
import { Feature } from '@jbrowse/core/util/simpleFeature'
|
|
25
|
-
import { axisPropsFromTickScale } from 'react-d3-axis'
|
|
25
|
+
import { axisPropsFromTickScale } from 'react-d3-axis-mod'
|
|
26
26
|
import { getNiceDomain, getScale } from '../../util'
|
|
27
27
|
|
|
28
28
|
import Tooltip from '../components/Tooltip'
|
|
@@ -41,13 +41,6 @@ const rendererTypes = new Map([
|
|
|
41
41
|
['line', 'LinePlotRenderer'],
|
|
42
42
|
])
|
|
43
43
|
|
|
44
|
-
function logb(x: number, y: number) {
|
|
45
|
-
return Math.log(y) / Math.log(x)
|
|
46
|
-
}
|
|
47
|
-
function round(v: number, b = 1.5) {
|
|
48
|
-
return (v >= 0 ? 1 : -1) * Math.pow(b, 1 + Math.floor(logb(b, Math.abs(v))))
|
|
49
|
-
}
|
|
50
|
-
|
|
51
44
|
type LGV = LinearGenomeViewModel
|
|
52
45
|
|
|
53
46
|
const stateModelFactory = (
|
|
@@ -84,13 +77,23 @@ const stateModelFactory = (
|
|
|
84
77
|
.volatile(() => ({
|
|
85
78
|
statsReady: false,
|
|
86
79
|
message: undefined as undefined | string,
|
|
87
|
-
stats:
|
|
80
|
+
stats: { scoreMin: 0, scoreMax: 50 },
|
|
88
81
|
statsFetchInProgress: undefined as undefined | AbortController,
|
|
89
82
|
}))
|
|
90
83
|
.actions(self => ({
|
|
91
|
-
updateStats(
|
|
92
|
-
|
|
93
|
-
|
|
84
|
+
updateStats({
|
|
85
|
+
scoreMin,
|
|
86
|
+
scoreMax,
|
|
87
|
+
}: {
|
|
88
|
+
scoreMin: number
|
|
89
|
+
scoreMax: number
|
|
90
|
+
}) {
|
|
91
|
+
if (
|
|
92
|
+
self.stats.scoreMin !== scoreMin ||
|
|
93
|
+
self.stats.scoreMax !== scoreMax
|
|
94
|
+
) {
|
|
95
|
+
self.stats = { scoreMin, scoreMax }
|
|
96
|
+
}
|
|
94
97
|
self.statsReady = true
|
|
95
98
|
},
|
|
96
99
|
setColor(color: string) {
|
|
@@ -242,28 +245,19 @@ const stateModelFactory = (
|
|
|
242
245
|
},
|
|
243
246
|
get domain() {
|
|
244
247
|
const { stats, scaleType, minScore, maxScore } = self
|
|
248
|
+
const { scoreMin, scoreMax } = stats
|
|
245
249
|
|
|
246
250
|
const ret = getNiceDomain({
|
|
247
|
-
domain: [
|
|
251
|
+
domain: [scoreMin, scoreMax],
|
|
248
252
|
bounds: [minScore, maxScore],
|
|
249
253
|
scaleType,
|
|
250
254
|
})
|
|
251
|
-
const headroom = getConf(self, 'headroom') || 0
|
|
252
255
|
|
|
253
256
|
// avoid weird scalebar if log value and empty region displayed
|
|
254
257
|
if (scaleType === 'log' && ret[1] === Number.MIN_VALUE) {
|
|
255
258
|
return [0, Number.MIN_VALUE]
|
|
256
259
|
}
|
|
257
260
|
|
|
258
|
-
// heuristic to just give some extra headroom on bigwig scores if no
|
|
259
|
-
// maxScore/minScore specified (they have MAX_VALUE/MIN_VALUE if so)
|
|
260
|
-
if (maxScore === Number.MAX_VALUE && ret[1] > 1.0) {
|
|
261
|
-
ret[1] = round(ret[1] + headroom)
|
|
262
|
-
}
|
|
263
|
-
if (minScore === Number.MIN_VALUE && ret[0] < -1.0) {
|
|
264
|
-
ret[0] = round(ret[0] - headroom)
|
|
265
|
-
}
|
|
266
|
-
|
|
267
261
|
// avoid returning a new object if it matches the old value
|
|
268
262
|
if (JSON.stringify(oldDomain) !== JSON.stringify(ret)) {
|
|
269
263
|
oldDomain = ret
|
|
@@ -307,6 +301,7 @@ const stateModelFactory = (
|
|
|
307
301
|
.views(self => ({
|
|
308
302
|
get ticks() {
|
|
309
303
|
const { scaleType, domain, height } = self
|
|
304
|
+
const minimalTicks = getConf(self, 'minimalTicks')
|
|
310
305
|
const range = [height - YSCALEBAR_LABEL_OFFSET, YSCALEBAR_LABEL_OFFSET]
|
|
311
306
|
const scale = getScale({
|
|
312
307
|
scaleType,
|
|
@@ -314,8 +309,10 @@ const stateModelFactory = (
|
|
|
314
309
|
range,
|
|
315
310
|
inverted: getConf(self, 'inverted'),
|
|
316
311
|
})
|
|
317
|
-
const ticks =
|
|
318
|
-
return
|
|
312
|
+
const ticks = axisPropsFromTickScale(scale, 4)
|
|
313
|
+
return height < 100 || minimalTicks
|
|
314
|
+
? { ...ticks, values: domain }
|
|
315
|
+
: ticks
|
|
319
316
|
},
|
|
320
317
|
}))
|
|
321
318
|
.views(self => {
|
|
@@ -450,7 +447,7 @@ const stateModelFactory = (
|
|
|
450
447
|
{
|
|
451
448
|
label: 'Set min/max score',
|
|
452
449
|
onClick: () => {
|
|
453
|
-
getSession(self).queueDialog(
|
|
450
|
+
getSession(self).queueDialog(doneCallback => [
|
|
454
451
|
SetMinMaxDlg,
|
|
455
452
|
{ model: self, handleClose: doneCallback },
|
|
456
453
|
])
|
|
@@ -459,7 +456,7 @@ const stateModelFactory = (
|
|
|
459
456
|
{
|
|
460
457
|
label: 'Set color',
|
|
461
458
|
onClick: () => {
|
|
462
|
-
getSession(self).queueDialog(
|
|
459
|
+
getSession(self).queueDialog(doneCallback => [
|
|
463
460
|
SetColorDlg,
|
|
464
461
|
{ model: self, handleClose: doneCallback },
|
|
465
462
|
])
|
|
@@ -78,8 +78,8 @@ export default abstract class WiggleBaseRenderer extends FeatureRendererType {
|
|
|
78
78
|
* draw features to context given props, to be used by derived renderer
|
|
79
79
|
* classes
|
|
80
80
|
*/
|
|
81
|
-
abstract draw(
|
|
81
|
+
abstract draw<T extends RenderArgsDeserializedWithFeatures>(
|
|
82
82
|
ctx: CanvasRenderingContext2D,
|
|
83
|
-
props:
|
|
83
|
+
props: T,
|
|
84
84
|
): void
|
|
85
85
|
}
|
|
@@ -44,15 +44,8 @@ export class WiggleGetGlobalStats extends RpcMethodType {
|
|
|
44
44
|
adapterConfig,
|
|
45
45
|
)
|
|
46
46
|
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
if (dataAdapter.capabilities.includes('hasGlobalStats')) {
|
|
50
|
-
// @ts-ignore
|
|
51
|
-
return dataAdapter.getGlobalStats(deserializedArgs)
|
|
52
|
-
}
|
|
53
|
-
throw new Error('Data adapter does not support global stats')
|
|
54
|
-
}
|
|
55
|
-
throw new Error('Data adapter not found')
|
|
47
|
+
// @ts-ignore
|
|
48
|
+
return dataAdapter.getGlobalStats(deserializedArgs)
|
|
56
49
|
}
|
|
57
50
|
}
|
|
58
51
|
|
|
@@ -20,7 +20,7 @@ export default class XYPlotRenderer extends WiggleBaseRenderer {
|
|
|
20
20
|
scaleOpts,
|
|
21
21
|
height: unadjustedHeight,
|
|
22
22
|
config,
|
|
23
|
-
ticks
|
|
23
|
+
ticks,
|
|
24
24
|
displayCrossHatches,
|
|
25
25
|
} = props
|
|
26
26
|
const [region] = regions
|
|
@@ -39,6 +39,7 @@ export default class XYPlotRenderer extends WiggleBaseRenderer {
|
|
|
39
39
|
const clipColor = readConfObject(config, 'clipColor')
|
|
40
40
|
const highlightColor = readConfObject(config, 'highlightColor')
|
|
41
41
|
const summaryScoreMode = readConfObject(config, 'summaryScoreMode')
|
|
42
|
+
|
|
42
43
|
const scale = getScale({ ...scaleOpts, range: [0, height] })
|
|
43
44
|
const originY = getOrigin(scaleOpts.scaleType)
|
|
44
45
|
const [niceMin, niceMax] = scale.domain()
|
|
@@ -53,11 +54,6 @@ export default class XYPlotRenderer extends WiggleBaseRenderer {
|
|
|
53
54
|
: (feature: Feature, _score: number) =>
|
|
54
55
|
readConfObject(config, 'color', { feature })
|
|
55
56
|
|
|
56
|
-
ctx.strokeStyle = 'grey'
|
|
57
|
-
ctx.moveTo(0, toY(0))
|
|
58
|
-
ctx.lineTo(width, toY(0))
|
|
59
|
-
ctx.stroke()
|
|
60
|
-
|
|
61
57
|
const crossingOrigin = niceMin < pivotValue && niceMax > pivotValue
|
|
62
58
|
for (const feature of features.values()) {
|
|
63
59
|
const [leftPx, rightPx] = featureSpanPx(feature, region, bpPerPx)
|
|
@@ -135,7 +131,7 @@ export default class XYPlotRenderer extends WiggleBaseRenderer {
|
|
|
135
131
|
if (displayCrossHatches) {
|
|
136
132
|
ctx.lineWidth = 1
|
|
137
133
|
ctx.strokeStyle = 'rgba(200,200,200,0.8)'
|
|
138
|
-
values.forEach(tick => {
|
|
134
|
+
ticks.values.forEach(tick => {
|
|
139
135
|
ctx.beginPath()
|
|
140
136
|
ctx.moveTo(0, Math.round(toY(tick)))
|
|
141
137
|
ctx.lineTo(width, Math.round(toY(tick)))
|
package/src/declare.d.ts
CHANGED