@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.
- package/dist/CreateMultiWiggleExtension/index.js +14 -11
- package/dist/DensityRenderer/DensityRenderer.js +2 -2
- package/dist/LinePlotRenderer/LinePlotRenderer.js +2 -2
- package/dist/LinearWiggleDisplay/components/SetColorDialog.d.ts +6 -7
- package/dist/LinearWiggleDisplay/components/SetColorDialog.js +3 -3
- package/dist/LinearWiggleDisplay/components/Tooltip.js +1 -1
- package/dist/MultiDensityRenderer/MultiDensityRenderer.js +5 -8
- package/dist/MultiLineRenderer/MultiLineRenderer.js +5 -9
- package/dist/MultiLinearWiggleDisplay/components/DraggableDialog.d.ts +3 -4
- package/dist/MultiLinearWiggleDisplay/components/DraggableDialog.js +3 -3
- package/dist/MultiLinearWiggleDisplay/components/SetColorDialog.js +2 -96
- package/dist/MultiLinearWiggleDisplay/components/SourcesGrid.d.ts +8 -0
- package/dist/MultiLinearWiggleDisplay/components/SourcesGrid.js +138 -0
- package/dist/MultiLinearWiggleDisplay/components/Tooltip.d.ts +3 -2
- package/dist/MultiLinearWiggleDisplay/components/Tooltip.js +1 -1
- package/dist/MultiLinearWiggleDisplay/components/WiggleDisplayComponent.d.ts +2 -3
- package/dist/MultiLinearWiggleDisplay/components/WiggleDisplayComponent.js +2 -4
- package/dist/MultiLinearWiggleDisplay/components/util.js +2 -4
- package/dist/MultiRowLineRenderer/MultiRowLineRenderer.js +5 -5
- package/dist/MultiRowXYPlotRenderer/MultiRowXYPlotRenderer.js +5 -34
- package/dist/MultiWiggleAddTrackWidget/AddTrackWorkflow.js +16 -12
- package/dist/MultiWiggleRendering.d.ts +3 -4
- package/dist/MultiWiggleRendering.js +7 -5
- package/dist/MultiXYPlotRenderer/MultiXYPlotRenderer.js +5 -33
- package/dist/Tooltip.d.ts +5 -6
- package/dist/Tooltip.js +3 -3
- package/dist/WiggleRendering.d.ts +3 -4
- package/dist/WiggleRendering.js +3 -3
- package/dist/XYPlotRenderer/XYPlotRenderer.js +2 -27
- package/dist/drawDensity.d.ts +17 -0
- package/dist/drawDensity.js +66 -0
- package/dist/drawLine.d.ts +19 -0
- package/dist/drawLine.js +73 -0
- package/dist/drawXY.d.ts +19 -0
- package/dist/drawXY.js +164 -0
- package/dist/shared/YScaleBar.d.ts +2 -2
- package/dist/shared/YScaleBar.js +2 -1
- package/dist/shared/modelShared.d.ts +4 -1
- package/dist/util.d.ts +1 -0
- package/dist/util.js +17 -1
- package/esm/CreateMultiWiggleExtension/index.js +14 -11
- package/esm/DensityRenderer/DensityRenderer.js +1 -1
- package/esm/LinePlotRenderer/LinePlotRenderer.js +1 -1
- package/esm/LinearWiggleDisplay/components/SetColorDialog.d.ts +6 -7
- package/esm/LinearWiggleDisplay/components/SetColorDialog.js +3 -3
- package/esm/LinearWiggleDisplay/components/Tooltip.js +1 -1
- package/esm/MultiDensityRenderer/MultiDensityRenderer.js +4 -7
- package/esm/MultiLineRenderer/MultiLineRenderer.js +4 -8
- package/esm/MultiLinearWiggleDisplay/components/DraggableDialog.d.ts +3 -4
- package/esm/MultiLinearWiggleDisplay/components/DraggableDialog.js +3 -3
- package/esm/MultiLinearWiggleDisplay/components/SetColorDialog.js +2 -96
- package/esm/MultiLinearWiggleDisplay/components/SourcesGrid.d.ts +8 -0
- package/esm/MultiLinearWiggleDisplay/components/SourcesGrid.js +110 -0
- package/esm/MultiLinearWiggleDisplay/components/Tooltip.d.ts +3 -2
- package/esm/MultiLinearWiggleDisplay/components/Tooltip.js +1 -1
- package/esm/MultiLinearWiggleDisplay/components/WiggleDisplayComponent.d.ts +2 -3
- package/esm/MultiLinearWiggleDisplay/components/WiggleDisplayComponent.js +2 -2
- package/esm/MultiLinearWiggleDisplay/components/util.js +2 -4
- package/esm/MultiRowLineRenderer/MultiRowLineRenderer.js +4 -4
- package/esm/MultiRowXYPlotRenderer/MultiRowXYPlotRenderer.js +4 -10
- package/esm/MultiWiggleAddTrackWidget/AddTrackWorkflow.js +17 -13
- package/esm/MultiWiggleRendering.d.ts +3 -4
- package/esm/MultiWiggleRendering.js +7 -5
- package/esm/MultiXYPlotRenderer/MultiXYPlotRenderer.js +4 -9
- package/esm/Tooltip.d.ts +5 -6
- package/esm/Tooltip.js +3 -3
- package/esm/WiggleRendering.d.ts +3 -4
- package/esm/WiggleRendering.js +3 -3
- package/esm/XYPlotRenderer/XYPlotRenderer.js +1 -3
- package/esm/drawDensity.d.ts +17 -0
- package/esm/drawDensity.js +62 -0
- package/esm/drawLine.d.ts +19 -0
- package/esm/drawLine.js +69 -0
- package/esm/drawXY.d.ts +19 -0
- package/esm/{drawxy.js → drawXY.js} +17 -140
- package/esm/shared/YScaleBar.d.ts +2 -2
- package/esm/shared/YScaleBar.js +2 -1
- package/esm/shared/modelShared.d.ts +4 -1
- package/esm/util.d.ts +1 -0
- package/esm/util.js +15 -0
- package/package.json +3 -4
- package/dist/drawxy.d.ts +0 -50
- package/dist/drawxy.js +0 -289
- package/esm/drawxy.d.ts +0 -50
|
@@ -1,56 +1,27 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
-
if (mod && mod.__esModule) return mod;
|
|
20
|
-
var result = {};
|
|
21
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
-
__setModuleDefault(result, mod);
|
|
23
|
-
return result;
|
|
24
|
-
};
|
|
25
2
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
26
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
27
4
|
};
|
|
28
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
6
|
const util_1 = require("@jbrowse/core/util");
|
|
30
|
-
const
|
|
7
|
+
const drawXY_1 = require("../drawXY");
|
|
31
8
|
const WiggleBaseRenderer_1 = __importDefault(require("../WiggleBaseRenderer"));
|
|
32
9
|
class MultiXYPlotRenderer extends WiggleBaseRenderer_1.default {
|
|
33
10
|
// @ts-expect-error
|
|
34
11
|
async draw(ctx, props) {
|
|
35
12
|
const { bpPerPx, sources, regions, features } = props;
|
|
36
13
|
const [region] = regions;
|
|
37
|
-
const groups = (0, util_1.groupBy)(
|
|
14
|
+
const groups = (0, util_1.groupBy)(features.values(), f => f.get('source'));
|
|
38
15
|
const height = props.height / sources.length;
|
|
39
16
|
const width = (region.end - region.start) / bpPerPx;
|
|
40
|
-
const Color = await Promise.resolve().then(() => __importStar(require('color'))).then(f => f.default);
|
|
41
17
|
let feats = [];
|
|
42
18
|
ctx.save();
|
|
43
19
|
sources.forEach(source => {
|
|
44
|
-
const
|
|
45
|
-
if (!features) {
|
|
46
|
-
return;
|
|
47
|
-
}
|
|
48
|
-
const { reducedFeatures } = (0, drawxy_1.drawXY)(ctx, {
|
|
20
|
+
const { reducedFeatures } = (0, drawXY_1.drawXY)(ctx, {
|
|
49
21
|
...props,
|
|
50
|
-
features,
|
|
22
|
+
features: groups[source.name] || [],
|
|
51
23
|
height,
|
|
52
24
|
colorCallback: () => source.color || 'blue',
|
|
53
|
-
Color,
|
|
54
25
|
});
|
|
55
26
|
ctx.strokeStyle = 'rgba(200,200,200,0.8)';
|
|
56
27
|
ctx.beginPath();
|
|
@@ -58,7 +29,7 @@ class MultiXYPlotRenderer extends WiggleBaseRenderer_1.default {
|
|
|
58
29
|
ctx.lineTo(width, height);
|
|
59
30
|
ctx.stroke();
|
|
60
31
|
ctx.translate(0, height);
|
|
61
|
-
feats =
|
|
32
|
+
feats = feats.concat(reducedFeatures);
|
|
62
33
|
});
|
|
63
34
|
ctx.restore();
|
|
64
35
|
return { reducedFeatures: feats };
|
|
@@ -85,19 +85,23 @@ function MultiWiggleWidget({ model }) {
|
|
|
85
85
|
const obj = typeof bigWigs[0] === 'string'
|
|
86
86
|
? { bigWigs }
|
|
87
87
|
: { subadapters: bigWigs };
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
88
|
+
if ((0, util_1.isSessionWithAddTracks)(session)) {
|
|
89
|
+
session.addTrackConf({
|
|
90
|
+
trackId,
|
|
91
|
+
type: 'MultiQuantitativeTrack',
|
|
92
|
+
name: trackName,
|
|
93
|
+
assemblyNames: [model.assembly],
|
|
94
|
+
adapter: {
|
|
95
|
+
type: 'MultiWiggleAdapter',
|
|
96
|
+
...obj,
|
|
97
|
+
},
|
|
98
|
+
});
|
|
99
|
+
(_a = model.view) === null || _a === void 0 ? void 0 : _a.showTrack(trackId);
|
|
100
|
+
}
|
|
99
101
|
model.clearData();
|
|
100
|
-
|
|
102
|
+
if ((0, util_1.isSessionModelWithWidgets)(session)) {
|
|
103
|
+
session.hideWidget(model);
|
|
104
|
+
}
|
|
101
105
|
} }, "Submit"),
|
|
102
106
|
react_1.default.createElement("p", null, "Additional notes: "),
|
|
103
107
|
react_1.default.createElement("ul", null,
|
|
@@ -2,7 +2,7 @@ import React from 'react';
|
|
|
2
2
|
import { Region } from '@jbrowse/core/util/types';
|
|
3
3
|
import { Feature } from '@jbrowse/core/util';
|
|
4
4
|
import { Source } from './util';
|
|
5
|
-
declare
|
|
5
|
+
declare const MultiWiggleRendering: (props: {
|
|
6
6
|
regions: Region[];
|
|
7
7
|
features: Map<string, Feature>;
|
|
8
8
|
bpPerPx: number;
|
|
@@ -16,6 +16,5 @@ declare function WiggleRendering(props: {
|
|
|
16
16
|
displayModel: {
|
|
17
17
|
isMultiRow: boolean;
|
|
18
18
|
};
|
|
19
|
-
})
|
|
20
|
-
|
|
21
|
-
export default _default;
|
|
19
|
+
}) => React.JSX.Element;
|
|
20
|
+
export default MultiWiggleRendering;
|
|
@@ -27,7 +27,7 @@ const mobx_react_1 = require("mobx-react");
|
|
|
27
27
|
const react_1 = __importStar(require("react"));
|
|
28
28
|
const util_1 = require("@jbrowse/core/util");
|
|
29
29
|
const ui_1 = require("@jbrowse/core/ui");
|
|
30
|
-
function
|
|
30
|
+
const MultiWiggleRendering = (0, mobx_react_1.observer)(function (props) {
|
|
31
31
|
const { regions, features, bpPerPx, width, height, sources, onMouseLeave = () => { }, onMouseMove = () => { }, onFeatureClick = () => { }, displayModel, } = props;
|
|
32
32
|
const [region] = regions;
|
|
33
33
|
const ref = (0, react_1.useRef)(null);
|
|
@@ -84,10 +84,12 @@ function WiggleRendering(props) {
|
|
|
84
84
|
return featureUnderMouse;
|
|
85
85
|
}
|
|
86
86
|
return (react_1.default.createElement("div", { ref: ref, onMouseMove: event => {
|
|
87
|
-
const
|
|
87
|
+
const { clientX, clientY } = event;
|
|
88
|
+
const featureUnderMouse = getFeatureUnderMouse(clientX, clientY);
|
|
88
89
|
onMouseMove(event, featureUnderMouse);
|
|
89
90
|
}, onClick: event => {
|
|
90
|
-
const
|
|
91
|
+
const { clientX, clientY } = event;
|
|
92
|
+
const featureUnderMouse = getFeatureUnderMouse(clientX, clientY);
|
|
91
93
|
onFeatureClick(event, featureUnderMouse);
|
|
92
94
|
}, onMouseLeave: event => onMouseLeave(event), style: {
|
|
93
95
|
overflow: 'visible',
|
|
@@ -95,5 +97,5 @@ function WiggleRendering(props) {
|
|
|
95
97
|
height,
|
|
96
98
|
} },
|
|
97
99
|
react_1.default.createElement(ui_1.PrerenderedCanvas, { ...props })));
|
|
98
|
-
}
|
|
99
|
-
exports.default =
|
|
100
|
+
});
|
|
101
|
+
exports.default = MultiWiggleRendering;
|
|
@@ -1,55 +1,27 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
-
if (mod && mod.__esModule) return mod;
|
|
20
|
-
var result = {};
|
|
21
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
-
__setModuleDefault(result, mod);
|
|
23
|
-
return result;
|
|
24
|
-
};
|
|
25
2
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
26
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
27
4
|
};
|
|
28
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
6
|
const util_1 = require("@jbrowse/core/util");
|
|
30
|
-
const
|
|
7
|
+
const drawXY_1 = require("../drawXY");
|
|
31
8
|
const util_2 = require("../util");
|
|
32
9
|
const WiggleBaseRenderer_1 = __importDefault(require("../WiggleBaseRenderer"));
|
|
33
10
|
class MultiXYPlotRenderer extends WiggleBaseRenderer_1.default {
|
|
34
11
|
// @ts-expect-error
|
|
35
12
|
async draw(ctx, props) {
|
|
36
13
|
const { sources, features } = props;
|
|
37
|
-
const groups = (0, util_1.groupBy)(
|
|
38
|
-
const Color = await Promise.resolve().then(() => __importStar(require('color'))).then(f => f.default);
|
|
14
|
+
const groups = (0, util_1.groupBy)(features.values(), f => f.get('source'));
|
|
39
15
|
let feats = [];
|
|
40
16
|
for (const source of sources) {
|
|
41
|
-
const features = groups[source.name];
|
|
42
|
-
|
|
43
|
-
continue;
|
|
44
|
-
}
|
|
45
|
-
const { reducedFeatures } = (0, drawxy_1.drawXY)(ctx, {
|
|
17
|
+
const features = groups[source.name] || [];
|
|
18
|
+
const { reducedFeatures } = (0, drawXY_1.drawXY)(ctx, {
|
|
46
19
|
...props,
|
|
47
20
|
features,
|
|
48
21
|
offset: util_2.YSCALEBAR_LABEL_OFFSET,
|
|
49
22
|
colorCallback: () => source.color || 'blue',
|
|
50
|
-
Color,
|
|
51
23
|
});
|
|
52
|
-
feats =
|
|
24
|
+
feats = feats.concat(reducedFeatures);
|
|
53
25
|
}
|
|
54
26
|
return { reducedFeatures: feats };
|
|
55
27
|
}
|
package/dist/Tooltip.d.ts
CHANGED
|
@@ -5,16 +5,15 @@ export type TooltipContentsComponent = React.ForwardRefExoticComponent<{
|
|
|
5
5
|
feature: Feature;
|
|
6
6
|
model: any;
|
|
7
7
|
} & React.RefAttributes<HTMLDivElement>>;
|
|
8
|
-
declare
|
|
8
|
+
declare const Tooltip: ({ model, height, clientMouseCoord, offsetMouseCoord, clientRect, TooltipContents, useClientY, }: {
|
|
9
9
|
model: {
|
|
10
10
|
featureUnderMouse: Feature;
|
|
11
11
|
};
|
|
12
|
-
useClientY?: boolean;
|
|
12
|
+
useClientY?: boolean | undefined;
|
|
13
13
|
height: number;
|
|
14
14
|
clientMouseCoord: Coord;
|
|
15
15
|
offsetMouseCoord: Coord;
|
|
16
|
-
clientRect?: DOMRect;
|
|
16
|
+
clientRect?: DOMRect | undefined;
|
|
17
17
|
TooltipContents: TooltipContentsComponent;
|
|
18
|
-
})
|
|
19
|
-
|
|
20
|
-
export default _default;
|
|
18
|
+
}) => React.JSX.Element | null;
|
|
19
|
+
export default Tooltip;
|
package/dist/Tooltip.js
CHANGED
|
@@ -57,7 +57,7 @@ const useStyles = (0, mui_1.makeStyles)()(theme => ({
|
|
|
57
57
|
pointerEvents: 'none',
|
|
58
58
|
},
|
|
59
59
|
}));
|
|
60
|
-
function Tooltip({ model, height, clientMouseCoord, offsetMouseCoord, clientRect, TooltipContents, useClientY, }) {
|
|
60
|
+
const Tooltip = (0, mobx_react_1.observer)(function Tooltip({ model, height, clientMouseCoord, offsetMouseCoord, clientRect, TooltipContents, useClientY, }) {
|
|
61
61
|
const { featureUnderMouse } = model;
|
|
62
62
|
const [width, setWidth] = (0, react_1.useState)(0);
|
|
63
63
|
const [anchorEl, setAnchorEl] = (0, react_1.useState)(null);
|
|
@@ -91,5 +91,5 @@ function Tooltip({ model, height, clientMouseCoord, offsetMouseCoord, clientRect
|
|
|
91
91
|
left: offsetMouseCoord[0],
|
|
92
92
|
height: height - util_1.YSCALEBAR_LABEL_OFFSET * 2,
|
|
93
93
|
} }))) : null;
|
|
94
|
-
}
|
|
95
|
-
exports.default =
|
|
94
|
+
});
|
|
95
|
+
exports.default = Tooltip;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { Region } from '@jbrowse/core/util/types';
|
|
3
3
|
import { Feature } from '@jbrowse/core/util';
|
|
4
|
-
declare
|
|
4
|
+
declare const WiggleRendering: (props: {
|
|
5
5
|
regions: Region[];
|
|
6
6
|
features: Map<string, Feature>;
|
|
7
7
|
bpPerPx: number;
|
|
@@ -11,6 +11,5 @@ declare function WiggleRendering(props: {
|
|
|
11
11
|
onMouseMove: Function;
|
|
12
12
|
onFeatureClick: Function;
|
|
13
13
|
blockKey: string;
|
|
14
|
-
})
|
|
15
|
-
|
|
16
|
-
export default _default;
|
|
14
|
+
}) => React.JSX.Element;
|
|
15
|
+
export default WiggleRendering;
|
package/dist/WiggleRendering.js
CHANGED
|
@@ -26,7 +26,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
26
26
|
const mobx_react_1 = require("mobx-react");
|
|
27
27
|
const react_1 = __importStar(require("react"));
|
|
28
28
|
const ui_1 = require("@jbrowse/core/ui");
|
|
29
|
-
|
|
29
|
+
const WiggleRendering = (0, mobx_react_1.observer)(function (props) {
|
|
30
30
|
const { regions, features, bpPerPx, width, height, onMouseLeave = () => { }, onMouseMove = () => { }, onFeatureClick = () => { }, } = props;
|
|
31
31
|
const [region] = regions;
|
|
32
32
|
const ref = (0, react_1.useRef)(null);
|
|
@@ -56,5 +56,5 @@ function WiggleRendering(props) {
|
|
|
56
56
|
height,
|
|
57
57
|
} },
|
|
58
58
|
react_1.default.createElement(ui_1.PrerenderedCanvas, { ...props })));
|
|
59
|
-
}
|
|
60
|
-
exports.default =
|
|
59
|
+
});
|
|
60
|
+
exports.default = WiggleRendering;
|
|
@@ -1,33 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
-
if (mod && mod.__esModule) return mod;
|
|
20
|
-
var result = {};
|
|
21
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
-
__setModuleDefault(result, mod);
|
|
23
|
-
return result;
|
|
24
|
-
};
|
|
25
2
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
26
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
27
4
|
};
|
|
28
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
6
|
const configuration_1 = require("@jbrowse/core/configuration");
|
|
30
|
-
const
|
|
7
|
+
const drawXY_1 = require("../drawXY");
|
|
31
8
|
const WiggleBaseRenderer_1 = __importDefault(require("../WiggleBaseRenderer"));
|
|
32
9
|
const util_1 = require("../util");
|
|
33
10
|
class XYPlotRenderer extends WiggleBaseRenderer_1.default {
|
|
@@ -39,15 +16,13 @@ class XYPlotRenderer extends WiggleBaseRenderer_1.default {
|
|
|
39
16
|
const pivotValue = (0, configuration_1.readConfObject)(config, 'bicolorPivotValue');
|
|
40
17
|
const negColor = (0, configuration_1.readConfObject)(config, 'negColor');
|
|
41
18
|
const posColor = (0, configuration_1.readConfObject)(config, 'posColor');
|
|
42
|
-
|
|
43
|
-
return (0, drawxy_1.drawXY)(ctx, {
|
|
19
|
+
return (0, drawXY_1.drawXY)(ctx, {
|
|
44
20
|
...props,
|
|
45
21
|
colorCallback: (0, configuration_1.readConfObject)(config, 'color') === '#f0f'
|
|
46
22
|
? (_, score) => score < pivotValue ? negColor : posColor
|
|
47
23
|
: (feature, _score) => (0, configuration_1.readConfObject)(config, 'color', { feature }),
|
|
48
24
|
offset: util_1.YSCALEBAR_LABEL_OFFSET,
|
|
49
25
|
features: [...features.values()],
|
|
50
|
-
Color,
|
|
51
26
|
});
|
|
52
27
|
}
|
|
53
28
|
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { AnyConfigurationModel } from '@jbrowse/core/configuration';
|
|
2
|
+
import { Feature, Region } from '@jbrowse/core/util';
|
|
3
|
+
import { ScaleOpts } from './util';
|
|
4
|
+
export declare function drawDensity(ctx: CanvasRenderingContext2D, props: {
|
|
5
|
+
features: Map<string, Feature> | Feature[];
|
|
6
|
+
regions: Region[];
|
|
7
|
+
bpPerPx: number;
|
|
8
|
+
scaleOpts: ScaleOpts;
|
|
9
|
+
height: number;
|
|
10
|
+
ticks: {
|
|
11
|
+
values: number[];
|
|
12
|
+
};
|
|
13
|
+
displayCrossHatches: boolean;
|
|
14
|
+
config: AnyConfigurationModel;
|
|
15
|
+
}): {
|
|
16
|
+
reducedFeatures: Feature[];
|
|
17
|
+
};
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.drawDensity = 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
|
+
const fudgeFactor = 0.3;
|
|
9
|
+
const clipHeight = 2;
|
|
10
|
+
function drawDensity(ctx, props) {
|
|
11
|
+
const { features, regions, bpPerPx, scaleOpts, height, config } = props;
|
|
12
|
+
const [region] = regions;
|
|
13
|
+
const pivot = (0, configuration_1.readConfObject)(config, 'bicolorPivot');
|
|
14
|
+
const pivotValue = (0, configuration_1.readConfObject)(config, 'bicolorPivotValue');
|
|
15
|
+
const negColor = (0, configuration_1.readConfObject)(config, 'negColor');
|
|
16
|
+
const posColor = (0, configuration_1.readConfObject)(config, 'posColor');
|
|
17
|
+
const color = (0, configuration_1.readConfObject)(config, 'color');
|
|
18
|
+
const clipColor = (0, configuration_1.readConfObject)(config, 'clipColor');
|
|
19
|
+
const crossing = pivot !== 'none' && scaleOpts.scaleType !== 'log';
|
|
20
|
+
const scale = (0, util_2.getScale)({
|
|
21
|
+
...scaleOpts,
|
|
22
|
+
pivotValue: crossing ? pivotValue : undefined,
|
|
23
|
+
range: crossing ? [negColor, 'white', posColor] : ['white', posColor],
|
|
24
|
+
});
|
|
25
|
+
const scale2 = (0, util_2.getScale)({ ...scaleOpts, range: [0, height] });
|
|
26
|
+
const cb = color === '#f0f'
|
|
27
|
+
? (_, score) => scale(score)
|
|
28
|
+
: (feature, score) => (0, configuration_1.readConfObject)(config, 'color', { feature, score });
|
|
29
|
+
const [niceMin, niceMax] = scale2.domain();
|
|
30
|
+
let prevLeftPx = -Infinity;
|
|
31
|
+
let hasClipping = false;
|
|
32
|
+
const reducedFeatures = [];
|
|
33
|
+
for (const feature of features.values()) {
|
|
34
|
+
const [leftPx, rightPx] = (0, util_1.featureSpanPx)(feature, region, bpPerPx);
|
|
35
|
+
// create reduced features, avoiding multiple features per px
|
|
36
|
+
if (Math.floor(leftPx) !== Math.floor(prevLeftPx)) {
|
|
37
|
+
reducedFeatures.push(feature);
|
|
38
|
+
prevLeftPx = leftPx;
|
|
39
|
+
}
|
|
40
|
+
const score = feature.get('score');
|
|
41
|
+
hasClipping = hasClipping || score > niceMax || score < niceMin;
|
|
42
|
+
const w = rightPx - leftPx + fudgeFactor;
|
|
43
|
+
ctx.fillStyle = cb(feature, score);
|
|
44
|
+
ctx.fillRect(leftPx, 0, w, height);
|
|
45
|
+
}
|
|
46
|
+
// second pass: draw clipping
|
|
47
|
+
// avoid persisting the red fillstyle with save/restore
|
|
48
|
+
ctx.save();
|
|
49
|
+
if (hasClipping) {
|
|
50
|
+
ctx.fillStyle = clipColor;
|
|
51
|
+
for (const feature of features.values()) {
|
|
52
|
+
const [leftPx, rightPx] = (0, util_1.featureSpanPx)(feature, region, bpPerPx);
|
|
53
|
+
const w = rightPx - leftPx + fudgeFactor;
|
|
54
|
+
const score = feature.get('score');
|
|
55
|
+
if (score > niceMax) {
|
|
56
|
+
(0, util_2.fillRectCtx)(leftPx, 0, w, clipHeight, ctx);
|
|
57
|
+
}
|
|
58
|
+
else if (score < niceMin && scaleOpts.scaleType !== 'log') {
|
|
59
|
+
(0, util_2.fillRectCtx)(leftPx, 0, w, clipHeight, ctx);
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
ctx.restore();
|
|
64
|
+
return { reducedFeatures };
|
|
65
|
+
}
|
|
66
|
+
exports.drawDensity = drawDensity;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { AnyConfigurationModel } from '@jbrowse/core/configuration';
|
|
2
|
+
import { Feature, Region } from '@jbrowse/core/util';
|
|
3
|
+
import { ScaleOpts } from './util';
|
|
4
|
+
export declare function drawLine(ctx: CanvasRenderingContext2D, props: {
|
|
5
|
+
features: Map<string, Feature> | Feature[];
|
|
6
|
+
regions: Region[];
|
|
7
|
+
bpPerPx: number;
|
|
8
|
+
scaleOpts: ScaleOpts;
|
|
9
|
+
height: number;
|
|
10
|
+
ticks: {
|
|
11
|
+
values: number[];
|
|
12
|
+
};
|
|
13
|
+
displayCrossHatches: boolean;
|
|
14
|
+
colorCallback: (f: Feature, score: number) => string;
|
|
15
|
+
config: AnyConfigurationModel;
|
|
16
|
+
offset?: number;
|
|
17
|
+
}): {
|
|
18
|
+
reducedFeatures: Feature[];
|
|
19
|
+
};
|
package/dist/drawLine.js
ADDED
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.drawLine = 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
|
+
const fudgeFactor = 0.3;
|
|
9
|
+
const clipHeight = 2;
|
|
10
|
+
function drawLine(ctx, props) {
|
|
11
|
+
const { features, regions, bpPerPx, scaleOpts, height: unadjustedHeight, ticks: { values }, displayCrossHatches, colorCallback, config, offset = 0, } = props;
|
|
12
|
+
const [region] = regions;
|
|
13
|
+
const width = (region.end - region.start) / bpPerPx;
|
|
14
|
+
// the adjusted height takes into account YSCALEBAR_LABEL_OFFSET from the
|
|
15
|
+
// wiggle display, and makes the height of the actual drawn area add
|
|
16
|
+
// "padding" to the top and bottom of the display
|
|
17
|
+
const height = unadjustedHeight - offset * 2;
|
|
18
|
+
const clipColor = (0, configuration_1.readConfObject)(config, 'clipColor');
|
|
19
|
+
const scale = (0, util_2.getScale)({ ...scaleOpts, range: [0, height] });
|
|
20
|
+
const [niceMin, niceMax] = scale.domain();
|
|
21
|
+
const toY = (n) => (0, util_1.clamp)(height - (scale(n) || 0), 0, height) + offset;
|
|
22
|
+
let lastVal;
|
|
23
|
+
let prevLeftPx = -Infinity;
|
|
24
|
+
const reducedFeatures = [];
|
|
25
|
+
for (const feature of features.values()) {
|
|
26
|
+
const [leftPx, rightPx] = (0, util_1.featureSpanPx)(feature, region, bpPerPx);
|
|
27
|
+
// create reduced features, avoiding multiple features per px
|
|
28
|
+
if (Math.floor(leftPx) !== Math.floor(prevLeftPx)) {
|
|
29
|
+
reducedFeatures.push(feature);
|
|
30
|
+
prevLeftPx = leftPx;
|
|
31
|
+
}
|
|
32
|
+
const score = feature.get('score');
|
|
33
|
+
const lowClipping = score < niceMin;
|
|
34
|
+
const highClipping = score > niceMax;
|
|
35
|
+
const w = rightPx - leftPx + fudgeFactor;
|
|
36
|
+
const c = colorCallback(feature, score);
|
|
37
|
+
ctx.beginPath();
|
|
38
|
+
ctx.strokeStyle = c;
|
|
39
|
+
const startPos = lastVal !== undefined ? lastVal : score;
|
|
40
|
+
if (!region.reversed) {
|
|
41
|
+
ctx.moveTo(leftPx, toY(startPos));
|
|
42
|
+
ctx.lineTo(leftPx, toY(score));
|
|
43
|
+
ctx.lineTo(rightPx, toY(score));
|
|
44
|
+
}
|
|
45
|
+
else {
|
|
46
|
+
ctx.moveTo(rightPx, toY(startPos));
|
|
47
|
+
ctx.lineTo(rightPx, toY(score));
|
|
48
|
+
ctx.lineTo(leftPx, toY(score));
|
|
49
|
+
}
|
|
50
|
+
ctx.stroke();
|
|
51
|
+
lastVal = score;
|
|
52
|
+
if (highClipping) {
|
|
53
|
+
ctx.fillStyle = clipColor;
|
|
54
|
+
ctx.fillRect(leftPx, offset, w, clipHeight);
|
|
55
|
+
}
|
|
56
|
+
else if (lowClipping && scaleOpts.scaleType !== 'log') {
|
|
57
|
+
ctx.fillStyle = clipColor;
|
|
58
|
+
ctx.fillRect(leftPx, height - clipHeight, w, height);
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
if (displayCrossHatches) {
|
|
62
|
+
ctx.lineWidth = 1;
|
|
63
|
+
ctx.strokeStyle = 'rgba(200,200,200,0.5)';
|
|
64
|
+
values.forEach(tick => {
|
|
65
|
+
ctx.beginPath();
|
|
66
|
+
ctx.moveTo(0, Math.round(toY(tick)));
|
|
67
|
+
ctx.lineTo(width, Math.round(toY(tick)));
|
|
68
|
+
ctx.stroke();
|
|
69
|
+
});
|
|
70
|
+
}
|
|
71
|
+
return { reducedFeatures };
|
|
72
|
+
}
|
|
73
|
+
exports.drawLine = drawLine;
|
package/dist/drawXY.d.ts
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
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
|
+
}): {
|
|
18
|
+
reducedFeatures: Feature[];
|
|
19
|
+
};
|