@jbrowse/plugin-wiggle 2.16.0 → 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.
- package/dist/BigWigAdapter/BigWigAdapter.js +2 -1
- package/dist/BigWigAdapter/configSchema.d.ts +8 -0
- package/dist/BigWigAdapter/configSchema.js +8 -0
- package/dist/LinearWiggleDisplay/components/Tooltip.js +1 -1
- package/dist/LinearWiggleDisplay/components/WiggleDisplayComponent.d.ts +1 -1
- package/dist/LinearWiggleDisplay/{models/configSchema.js → configSchema.js} +2 -2
- package/dist/LinearWiggleDisplay/index.d.ts +1 -1
- package/dist/LinearWiggleDisplay/index.js +3 -3
- package/{esm/LinearWiggleDisplay/models → dist/LinearWiggleDisplay}/model.d.ts +22 -6
- package/dist/LinearWiggleDisplay/{models/model.js → model.js} +82 -47
- package/dist/LinearWiggleDisplay/{models/renderSvg.js → renderSvg.js} +2 -1
- package/dist/MultiLinearWiggleDisplay/components/ColorLegend.d.ts +1 -1
- package/dist/MultiLinearWiggleDisplay/components/ScoreLegend.d.ts +1 -1
- package/dist/MultiLinearWiggleDisplay/components/WiggleDisplayComponent.d.ts +1 -1
- package/dist/MultiLinearWiggleDisplay/components/YScaleBars.d.ts +1 -1
- package/dist/MultiLinearWiggleDisplay/components/util.d.ts +1 -1
- package/dist/MultiLinearWiggleDisplay/{models/configSchema.js → configSchema.js} +2 -2
- package/dist/MultiLinearWiggleDisplay/index.js +2 -2
- package/dist/MultiLinearWiggleDisplay/{models/model.d.ts → model.d.ts} +30 -12
- package/dist/MultiLinearWiggleDisplay/{models/model.js → model.js} +118 -87
- package/dist/MultiLinearWiggleDisplay/{models/renderSvg.js → renderSvg.js} +1 -1
- package/dist/MultiRowXYPlotRenderer/configSchema.js +1 -1
- package/dist/MultiWiggleAdapter/MultiWiggleAdapter.d.ts +1 -1
- package/dist/MultiWiggleAdapter/MultiWiggleAdapter.js +4 -2
- package/dist/MultiWiggleAddTrackWorkflow/AddTrackWorkflow.js +52 -44
- package/dist/MultiXYPlotRenderer/configSchema.js +1 -1
- package/dist/WiggleBaseRenderer.d.ts +1 -1
- package/dist/XYPlotRenderer/configSchema.js +1 -1
- package/dist/getMultiWiggleSourcesAutorun.d.ts +17 -0
- package/dist/getMultiWiggleSourcesAutorun.js +35 -0
- package/dist/getQuantitativeStats.d.ts +13 -0
- package/dist/getQuantitativeStats.js +78 -0
- package/dist/getQuantitativeStatsAutorun.d.ts +13 -0
- package/dist/getQuantitativeStatsAutorun.js +37 -0
- package/dist/index.d.ts +2 -2
- package/{esm/shared/modelShared.d.ts → dist/shared/SharedWiggleMixin.d.ts} +17 -3
- package/dist/shared/{modelShared.js → SharedWiggleMixin.js} +21 -10
- package/dist/util.d.ts +5 -29
- package/dist/util.js +4 -100
- package/esm/BigWigAdapter/BigWigAdapter.js +2 -1
- package/esm/BigWigAdapter/configSchema.d.ts +8 -0
- package/esm/BigWigAdapter/configSchema.js +8 -0
- package/esm/LinearWiggleDisplay/components/Tooltip.js +1 -1
- package/esm/LinearWiggleDisplay/components/WiggleDisplayComponent.d.ts +1 -1
- package/esm/LinearWiggleDisplay/{models/configSchema.js → configSchema.js} +1 -1
- package/esm/LinearWiggleDisplay/index.d.ts +1 -1
- package/esm/LinearWiggleDisplay/index.js +3 -3
- package/{dist/LinearWiggleDisplay/models → esm/LinearWiggleDisplay}/model.d.ts +22 -6
- package/esm/LinearWiggleDisplay/{models/model.js → model.js} +82 -47
- package/esm/LinearWiggleDisplay/{models/renderSvg.js → renderSvg.js} +2 -1
- package/esm/MultiLinearWiggleDisplay/components/ColorLegend.d.ts +1 -1
- package/esm/MultiLinearWiggleDisplay/components/ScoreLegend.d.ts +1 -1
- package/esm/MultiLinearWiggleDisplay/components/WiggleDisplayComponent.d.ts +1 -1
- package/esm/MultiLinearWiggleDisplay/components/YScaleBars.d.ts +1 -1
- package/esm/MultiLinearWiggleDisplay/components/util.d.ts +1 -1
- package/esm/MultiLinearWiggleDisplay/{models/configSchema.js → configSchema.js} +1 -1
- package/esm/MultiLinearWiggleDisplay/index.js +2 -2
- package/esm/MultiLinearWiggleDisplay/{models/model.d.ts → model.d.ts} +30 -12
- package/esm/MultiLinearWiggleDisplay/{models/model.js → model.js} +119 -88
- package/esm/MultiLinearWiggleDisplay/{models/renderSvg.js → renderSvg.js} +1 -1
- package/esm/MultiRowXYPlotRenderer/configSchema.js +1 -1
- package/esm/MultiWiggleAdapter/MultiWiggleAdapter.d.ts +1 -1
- package/esm/MultiWiggleAdapter/MultiWiggleAdapter.js +4 -2
- package/esm/MultiWiggleAddTrackWorkflow/AddTrackWorkflow.js +52 -44
- package/esm/MultiXYPlotRenderer/configSchema.js +1 -1
- package/esm/WiggleBaseRenderer.d.ts +1 -1
- package/esm/XYPlotRenderer/configSchema.js +1 -1
- package/esm/getMultiWiggleSourcesAutorun.d.ts +17 -0
- package/esm/getMultiWiggleSourcesAutorun.js +32 -0
- package/esm/getQuantitativeStats.d.ts +13 -0
- package/esm/getQuantitativeStats.js +75 -0
- package/esm/getQuantitativeStatsAutorun.d.ts +13 -0
- package/esm/getQuantitativeStatsAutorun.js +34 -0
- package/esm/index.d.ts +2 -2
- package/{dist/shared/modelShared.d.ts → esm/shared/SharedWiggleMixin.d.ts} +17 -3
- package/esm/shared/{modelShared.js → SharedWiggleMixin.js} +21 -10
- package/esm/util.d.ts +5 -29
- package/esm/util.js +4 -98
- package/package.json +2 -2
- /package/dist/LinearWiggleDisplay/{models/configSchema.d.ts → configSchema.d.ts} +0 -0
- /package/dist/LinearWiggleDisplay/{models/renderSvg.d.ts → renderSvg.d.ts} +0 -0
- /package/dist/MultiLinearWiggleDisplay/{models/configSchema.d.ts → configSchema.d.ts} +0 -0
- /package/dist/MultiLinearWiggleDisplay/{models/renderSvg.d.ts → renderSvg.d.ts} +0 -0
- /package/dist/shared/{configShared.d.ts → SharedWiggleConfigSchema.d.ts} +0 -0
- /package/dist/shared/{configShared.js → SharedWiggleConfigSchema.js} +0 -0
- /package/esm/LinearWiggleDisplay/{models/configSchema.d.ts → configSchema.d.ts} +0 -0
- /package/esm/LinearWiggleDisplay/{models/renderSvg.d.ts → renderSvg.d.ts} +0 -0
- /package/esm/MultiLinearWiggleDisplay/{models/configSchema.d.ts → configSchema.d.ts} +0 -0
- /package/esm/MultiLinearWiggleDisplay/{models/renderSvg.d.ts → renderSvg.d.ts} +0 -0
- /package/esm/shared/{configShared.d.ts → SharedWiggleConfigSchema.d.ts} +0 -0
- /package/esm/shared/{configShared.js → SharedWiggleConfigSchema.js} +0 -0
|
@@ -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 {
|
|
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,
|
|
@@ -4,9 +4,6 @@ import { makeStyles } from 'tss-react/mui';
|
|
|
4
4
|
import { getSession, isElectron, isSessionModelWithWidgets, isSessionWithAddTracks, } from '@jbrowse/core/util';
|
|
5
5
|
import { storeBlobLocation } from '@jbrowse/core/util/tracks';
|
|
6
6
|
const useStyles = makeStyles()(theme => ({
|
|
7
|
-
textbox: {
|
|
8
|
-
width: '100%',
|
|
9
|
-
},
|
|
10
7
|
paper: {
|
|
11
8
|
margin: theme.spacing(),
|
|
12
9
|
padding: theme.spacing(),
|
|
@@ -17,6 +14,16 @@ const useStyles = makeStyles()(theme => ({
|
|
|
17
14
|
display: 'block',
|
|
18
15
|
},
|
|
19
16
|
}));
|
|
17
|
+
// on electron, use path to LocalFileLocation, on web, use the BlobLocation
|
|
18
|
+
function makeFileLocation(file) {
|
|
19
|
+
const { webUtils } = window.require('electron');
|
|
20
|
+
return isElectron
|
|
21
|
+
? {
|
|
22
|
+
localPath: webUtils.getPathForFile(file),
|
|
23
|
+
locationType: 'LocalPathLocation',
|
|
24
|
+
}
|
|
25
|
+
: storeBlobLocation({ blob: file });
|
|
26
|
+
}
|
|
20
27
|
export default function MultiWiggleWidget({ model }) {
|
|
21
28
|
const { classes } = useStyles();
|
|
22
29
|
const [val, setVal] = useState('');
|
|
@@ -25,64 +32,65 @@ export default function MultiWiggleWidget({ model }) {
|
|
|
25
32
|
React.createElement("ul", null,
|
|
26
33
|
React.createElement("li", null, "Enter list of URLs for bigwig files in the textbox"),
|
|
27
34
|
React.createElement("li", null, "Or, use the button below the text box to select files from your computer")),
|
|
28
|
-
React.createElement(TextField, { multiline: true, rows: 10, value: val, onChange: event => {
|
|
35
|
+
React.createElement(TextField, { multiline: true, fullWidth: true, rows: 10, value: val, placeholder: "Paste list of URLs here, or use file selector below", variant: "outlined", onChange: event => {
|
|
29
36
|
setVal(event.target.value);
|
|
30
|
-
}
|
|
37
|
+
} }),
|
|
31
38
|
React.createElement(Button, { variant: "outlined", component: "label" },
|
|
32
39
|
"Choose Files from your computer",
|
|
33
40
|
React.createElement("input", { type: "file", hidden: true, multiple: true, onChange: ({ target }) => {
|
|
34
41
|
const res = [...(target.files || [])].map(file => ({
|
|
35
42
|
type: 'BigWigAdapter',
|
|
36
|
-
bigWigLocation:
|
|
37
|
-
? {
|
|
38
|
-
localPath: file.path,
|
|
39
|
-
locationType: 'LocalPathLocation',
|
|
40
|
-
}
|
|
41
|
-
: storeBlobLocation({ blob: file }),
|
|
43
|
+
bigWigLocation: makeFileLocation(file),
|
|
42
44
|
source: file.name,
|
|
43
45
|
}));
|
|
44
46
|
setVal(JSON.stringify(res, null, 2));
|
|
45
47
|
} })),
|
|
46
|
-
React.createElement(TextField, { value: trackName, onChange: event => {
|
|
48
|
+
React.createElement(TextField, { value: trackName, helperText: "Track name", onChange: event => {
|
|
47
49
|
setTrackName(event.target.value);
|
|
48
|
-
}
|
|
50
|
+
} }),
|
|
49
51
|
React.createElement(Button, { variant: "contained", className: classes.submit, onClick: () => {
|
|
50
52
|
var _a;
|
|
51
53
|
const session = getSession(model);
|
|
52
|
-
const trackId = [
|
|
53
|
-
`${trackName.toLowerCase().replaceAll(' ', '_')}-${Date.now()}`,
|
|
54
|
-
session.adminMode ? '' : '-sessionTrack',
|
|
55
|
-
].join('');
|
|
56
|
-
// allow list of bigwigs in JSON format or line-by-line
|
|
57
|
-
let bigWigs;
|
|
58
54
|
try {
|
|
59
|
-
|
|
55
|
+
const trackId = [
|
|
56
|
+
`${trackName.toLowerCase().replaceAll(' ', '_')}-${Date.now()}`,
|
|
57
|
+
session.adminMode ? '' : '-sessionTrack',
|
|
58
|
+
].join('');
|
|
59
|
+
// allow list of bigwigs in JSON format or line-by-line
|
|
60
|
+
let bigWigs;
|
|
61
|
+
try {
|
|
62
|
+
bigWigs = JSON.parse(val);
|
|
63
|
+
}
|
|
64
|
+
catch (e) {
|
|
65
|
+
bigWigs = val
|
|
66
|
+
.split(/\n|\r\n|\r/)
|
|
67
|
+
.map(f => f.trim())
|
|
68
|
+
.filter(f => !!f);
|
|
69
|
+
}
|
|
70
|
+
const obj = typeof bigWigs[0] === 'string'
|
|
71
|
+
? { bigWigs }
|
|
72
|
+
: { subadapters: bigWigs };
|
|
73
|
+
if (isSessionWithAddTracks(session)) {
|
|
74
|
+
session.addTrackConf({
|
|
75
|
+
trackId,
|
|
76
|
+
type: 'MultiQuantitativeTrack',
|
|
77
|
+
name: trackName,
|
|
78
|
+
assemblyNames: [model.assembly],
|
|
79
|
+
adapter: {
|
|
80
|
+
type: 'MultiWiggleAdapter',
|
|
81
|
+
...obj,
|
|
82
|
+
},
|
|
83
|
+
});
|
|
84
|
+
(_a = model.view) === null || _a === void 0 ? void 0 : _a.showTrack(trackId);
|
|
85
|
+
}
|
|
86
|
+
model.clearData();
|
|
87
|
+
if (isSessionModelWithWidgets(session)) {
|
|
88
|
+
session.hideWidget(model);
|
|
89
|
+
}
|
|
60
90
|
}
|
|
61
91
|
catch (e) {
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
.map(f => f.trim())
|
|
65
|
-
.filter(f => !!f);
|
|
66
|
-
}
|
|
67
|
-
const obj = typeof bigWigs[0] === 'string'
|
|
68
|
-
? { bigWigs }
|
|
69
|
-
: { subadapters: bigWigs };
|
|
70
|
-
if (isSessionWithAddTracks(session)) {
|
|
71
|
-
session.addTrackConf({
|
|
72
|
-
trackId,
|
|
73
|
-
type: 'MultiQuantitativeTrack',
|
|
74
|
-
name: trackName,
|
|
75
|
-
assemblyNames: [model.assembly],
|
|
76
|
-
adapter: {
|
|
77
|
-
type: 'MultiWiggleAdapter',
|
|
78
|
-
...obj,
|
|
79
|
-
},
|
|
80
|
-
});
|
|
81
|
-
(_a = model.view) === null || _a === void 0 ? void 0 : _a.showTrack(trackId);
|
|
82
|
-
}
|
|
83
|
-
model.clearData();
|
|
84
|
-
if (isSessionModelWithWidgets(session)) {
|
|
85
|
-
session.hideWidget(model);
|
|
92
|
+
console.error(e);
|
|
93
|
+
session.notifyError(`${e}`, e);
|
|
86
94
|
}
|
|
87
95
|
} }, "Submit"),
|
|
88
96
|
React.createElement("p", null, "Additional notes: "),
|
|
@@ -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 {
|
|
57
|
+
export type { RenderArgsSerialized, RenderResults, ResultsDeserialized, ResultsSerialized, } from '@jbrowse/core/pluggableElementTypes/renderers/FeatureRendererType';
|
|
@@ -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
|
+
}
|
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/
|
|
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 {
|
|
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"
|
|
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
|
-
|
|
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
|
|
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 = {
|
|
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
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
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
|
|
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):
|
|
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
|
-
*
|
|
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;
|