@vitessce/scatterplot-gating 2.0.3-beta.0 → 3.0.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/deflate-de0bc9c8.js +13 -0
- package/dist/index-6f1cc356.js +148824 -0
- package/dist/index.js +7 -1
- package/dist/jpeg-a72c0702.js +840 -0
- package/dist/lerc-27230ebf.js +2014 -0
- package/dist/lzw-e71d3b12.js +128 -0
- package/dist/packbits-5ddf3db9.js +30 -0
- package/dist/pako.esm-68f84e2a.js +4022 -0
- package/dist/raw-424e77e0.js +12 -0
- package/dist/webimage-93e70904.js +32 -0
- package/dist-tsc/GatingScatterplotOptions.d.ts +2 -0
- package/dist-tsc/GatingScatterplotOptions.d.ts.map +1 -0
- package/{dist → dist-tsc}/GatingScatterplotOptions.js +1 -3
- package/dist-tsc/GatingSubscriber.d.ts +22 -0
- package/dist-tsc/GatingSubscriber.d.ts.map +1 -0
- package/{dist → dist-tsc}/GatingSubscriber.js +7 -12
- package/dist-tsc/index.d.ts +2 -0
- package/dist-tsc/index.d.ts.map +1 -0
- package/dist-tsc/index.js +1 -0
- package/package.json +20 -11
- package/src/GatingScatterplotOptions.js +128 -0
- package/src/GatingSubscriber.js +452 -0
- package/src/index.js +1 -0
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { B as BaseDecoder } from "./index-6f1cc356.js";
|
|
2
|
+
import "react";
|
|
3
|
+
import "@vitessce/vit-s";
|
|
4
|
+
import "react-dom";
|
|
5
|
+
class WebImageDecoder extends BaseDecoder {
|
|
6
|
+
constructor() {
|
|
7
|
+
super();
|
|
8
|
+
if (typeof createImageBitmap === "undefined") {
|
|
9
|
+
throw new Error("Cannot decode WebImage as `createImageBitmap` is not available");
|
|
10
|
+
} else if (typeof document === "undefined" && typeof OffscreenCanvas === "undefined") {
|
|
11
|
+
throw new Error("Cannot decode WebImage as neither `document` nor `OffscreenCanvas` is not available");
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
async decode(fileDirectory, buffer) {
|
|
15
|
+
const blob = new Blob([buffer]);
|
|
16
|
+
const imageBitmap = await createImageBitmap(blob);
|
|
17
|
+
let canvas;
|
|
18
|
+
if (typeof document !== "undefined") {
|
|
19
|
+
canvas = document.createElement("canvas");
|
|
20
|
+
canvas.width = imageBitmap.width;
|
|
21
|
+
canvas.height = imageBitmap.height;
|
|
22
|
+
} else {
|
|
23
|
+
canvas = new OffscreenCanvas(imageBitmap.width, imageBitmap.height);
|
|
24
|
+
}
|
|
25
|
+
const ctx = canvas.getContext("2d");
|
|
26
|
+
ctx.drawImage(imageBitmap, 0, 0);
|
|
27
|
+
return ctx.getImageData(0, 0, imageBitmap.width, imageBitmap.height).data.buffer;
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
export {
|
|
31
|
+
WebImageDecoder as default
|
|
32
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"GatingScatterplotOptions.d.ts","sourceRoot":"","sources":["../src/GatingScatterplotOptions.js"],"names":[],"mappings":"AAMA,0EAyHC"}
|
|
@@ -1,9 +1,7 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
2
|
import React from 'react';
|
|
3
3
|
import plur from 'plur';
|
|
4
|
-
import TableCell from '@material-ui/core
|
|
5
|
-
import TableRow from '@material-ui/core/TableRow';
|
|
6
|
-
import TextField from '@material-ui/core/TextField';
|
|
4
|
+
import { TableCell, TableRow, TextField } from '@material-ui/core';
|
|
7
5
|
import { usePlotOptionsStyles, OptionSelect } from '@vitessce/vit-s';
|
|
8
6
|
import { capitalize } from '@vitessce/utils';
|
|
9
7
|
export default function GatingScatterplotOptions(props) {
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A subscriber component for the gating scatterplot.
|
|
3
|
+
* @param {object} props
|
|
4
|
+
* @param {number} props.uuid The unique identifier for this component.
|
|
5
|
+
* @param {string} props.theme The current theme name.
|
|
6
|
+
* @param {object} props.coordinationScopes The mapping from coordination types to coordination
|
|
7
|
+
* scopes.
|
|
8
|
+
* @param {boolean} props.disableTooltip Should the tooltip be disabled?
|
|
9
|
+
* @param {function} props.removeGridComponent The callback function to pass to TitleInfo,
|
|
10
|
+
* to call when the component has been removed from the grid.
|
|
11
|
+
* @param {number} props.averageFillDensity Override the average fill density calculation
|
|
12
|
+
* when using dynamic opacity mode.
|
|
13
|
+
*/
|
|
14
|
+
export function GatingSubscriber(props: {
|
|
15
|
+
uuid: number;
|
|
16
|
+
theme: string;
|
|
17
|
+
coordinationScopes: object;
|
|
18
|
+
disableTooltip: boolean;
|
|
19
|
+
removeGridComponent: Function;
|
|
20
|
+
averageFillDensity: number;
|
|
21
|
+
}): JSX.Element;
|
|
22
|
+
//# sourceMappingURL=GatingSubscriber.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"GatingSubscriber.d.ts","sourceRoot":"","sources":["../src/GatingSubscriber.js"],"names":[],"mappings":"AAkCA;;;;;;;;;;;;KAYK;AACL;IAV2B,IAAI,EAAlB,MAAM;IACQ,KAAK,EAAnB,MAAM;IACQ,kBAAkB,EAAhC,MAAM;IAES,cAAc,EAA7B,OAAO;IACS,mBAAmB;IAErB,kBAAkB,EAAhC,MAAM;gBAuZlB"}
|
|
@@ -2,13 +2,13 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
|
2
2
|
import React, { useState, useEffect, useCallback, useMemo, } from 'react';
|
|
3
3
|
import plur from 'plur';
|
|
4
4
|
import { extent } from 'd3-array';
|
|
5
|
-
import isEqual from 'lodash
|
|
5
|
+
import { isEqual } from 'lodash-es';
|
|
6
6
|
import { capitalize, commaNumber, getCellColors, getValueTransformFunction, VALUE_TRANSFORM_OPTIONS, } from '@vitessce/utils';
|
|
7
|
-
import { TitleInfo, useDeckCanvasSize, useReady, useUrls, useExpressionValueGetter, useObsSetsData, useFeatureSelection, useObsFeatureMatrixIndices, useCoordination, useLoaders, useSetComponentHover, useSetComponentViewInfo,
|
|
7
|
+
import { TitleInfo, useDeckCanvasSize, useReady, useUrls, useUint8FeatureSelection, useExpressionValueGetter, useObsSetsData, useFeatureSelection, useObsFeatureMatrixIndices, useCoordination, useLoaders, useSetComponentHover, useSetComponentViewInfo, } from '@vitessce/vit-s';
|
|
8
8
|
import { getCellSetPolygons, mergeObsSets, setObsSelection } from '@vitessce/sets-utils';
|
|
9
9
|
import { Scatterplot, ScatterplotTooltipSubscriber, ScatterplotOptions, getPointSizeDevicePixels, getPointOpacity, EmptyMessage, } from '@vitessce/scatterplot';
|
|
10
10
|
import { ViewType, COMPONENT_COORDINATION_TYPES } from '@vitessce/constants-internal';
|
|
11
|
-
import GatingScatterplotOptions from './GatingScatterplotOptions';
|
|
11
|
+
import GatingScatterplotOptions from './GatingScatterplotOptions.js';
|
|
12
12
|
/**
|
|
13
13
|
* A subscriber component for the gating scatterplot.
|
|
14
14
|
* @param {object} props
|
|
@@ -97,16 +97,13 @@ export function GatingSubscriber(props) {
|
|
|
97
97
|
}, [additionalCellSets, cellSetColor, setCellColorEncoding,
|
|
98
98
|
setAdditionalCellSets, setCellSetColor, setCellSetSelection]);
|
|
99
99
|
const cellColors = useMemo(() => getCellColors({
|
|
100
|
-
cellColorEncoding,
|
|
101
|
-
expressionData: expressionDataColor && expressionDataColor[0],
|
|
102
|
-
geneSelection: gatingFeatureSelectionColor,
|
|
103
100
|
cellSets: mergedCellSets,
|
|
104
101
|
cellSetSelection,
|
|
105
102
|
cellSetColor,
|
|
106
103
|
obsIndex,
|
|
107
104
|
theme,
|
|
108
|
-
}), [
|
|
109
|
-
cellSetSelection, cellSetColor,
|
|
105
|
+
}), [mergedCellSets, theme,
|
|
106
|
+
cellSetSelection, cellSetColor, obsIndex]);
|
|
110
107
|
// cellSetPolygonCache is an array of tuples like [(key0, val0), (key1, val1), ...],
|
|
111
108
|
// where the keys are cellSetSelection arrays.
|
|
112
109
|
const [cellSetPolygonCache, setCellSetPolygonCache] = useState([]);
|
|
@@ -171,12 +168,13 @@ export function GatingSubscriber(props) {
|
|
|
171
168
|
const getCellIsSelected = useCallback((object, { index }) => ((cellSelectionSet || new Set([])).has(obsIndex[index]) ? 1.0 : 0.0), [cellSelectionSet, obsIndex]);
|
|
172
169
|
const cellRadius = (cellRadiusMode === 'manual' ? cellRadiusFixed : dynamicCellRadius);
|
|
173
170
|
const cellOpacity = (cellOpacityMode === 'manual' ? cellOpacityFixed : dynamicCellOpacity);
|
|
171
|
+
const [uint8ExpressionData] = useUint8FeatureSelection(expressionDataColor);
|
|
174
172
|
// Set up a getter function for gene expression values, to be used
|
|
175
173
|
// by the DeckGL layer to obtain values for instanced attributes.
|
|
176
174
|
const getExpressionValue = useExpressionValueGetter({
|
|
177
175
|
instanceObsIndex: obsIndex,
|
|
178
176
|
matrixObsIndex: obsIndex,
|
|
179
|
-
expressionData:
|
|
177
|
+
expressionData: uint8ExpressionData,
|
|
180
178
|
});
|
|
181
179
|
// Puts the mapping values in the cell info tooltip.
|
|
182
180
|
const getObsInfo = useCallback((obsId) => {
|
|
@@ -206,6 +204,3 @@ export function GatingSubscriber(props) {
|
|
|
206
204
|
setComponentHover(uuid);
|
|
207
205
|
}, updateViewInfo: setComponentViewInfo, getExpressionValue: getExpressionValue, getCellIsSelected: getCellIsSelected }), !disableTooltip && (_jsx(ScatterplotTooltipSubscriber, { parentUuid: uuid, obsHighlight: cellHighlight, width: width, height: height, getObsInfo: getObsInfo }))] }));
|
|
208
206
|
}
|
|
209
|
-
export function register() {
|
|
210
|
-
registerPluginViewType(ViewType.GATING, GatingSubscriber, COMPONENT_COORDINATION_TYPES[ViewType.GATING]);
|
|
211
|
-
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.js"],"names":[],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { GatingSubscriber } from './GatingSubscriber.js';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vitessce/scatterplot-gating",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "3.0.0",
|
|
4
4
|
"author": "Gehlenborg Lab",
|
|
5
5
|
"homepage": "http://vitessce.io",
|
|
6
6
|
"repository": {
|
|
@@ -8,32 +8,41 @@
|
|
|
8
8
|
"url": "git+https://github.com/vitessce/vitessce.git"
|
|
9
9
|
},
|
|
10
10
|
"license": "MIT",
|
|
11
|
+
"type": "module",
|
|
11
12
|
"main": "dist/index.js",
|
|
12
13
|
"files": [
|
|
13
|
-
"
|
|
14
|
+
"src",
|
|
15
|
+
"dist",
|
|
16
|
+
"dist-tsc"
|
|
14
17
|
],
|
|
15
18
|
"dependencies": {
|
|
16
19
|
"@material-ui/core": "~4.12.3",
|
|
17
20
|
"d3-array": "^2.4.0",
|
|
18
|
-
"lodash": "^4.17.21",
|
|
21
|
+
"lodash-es": "^4.17.21",
|
|
19
22
|
"plur": "^5.1.0",
|
|
20
|
-
"@vitessce/constants-internal": "
|
|
21
|
-
"@vitessce/
|
|
22
|
-
"@vitessce/
|
|
23
|
-
"@vitessce/
|
|
24
|
-
"@vitessce/
|
|
23
|
+
"@vitessce/constants-internal": "3.0.0",
|
|
24
|
+
"@vitessce/sets-utils": "3.0.0",
|
|
25
|
+
"@vitessce/scatterplot": "3.0.0",
|
|
26
|
+
"@vitessce/vit-s": "3.0.0",
|
|
27
|
+
"@vitessce/utils": "3.0.0"
|
|
25
28
|
},
|
|
26
29
|
"devDependencies": {
|
|
27
30
|
"react": "^18.0.0",
|
|
28
|
-
"vite": "^3.0
|
|
31
|
+
"vite": "^4.3.0",
|
|
29
32
|
"vitest": "^0.23.4"
|
|
30
33
|
},
|
|
31
34
|
"peerDependencies": {
|
|
32
35
|
"react": "^16.8.0 || ^17.0.0 || ^18.0.0"
|
|
33
36
|
},
|
|
34
37
|
"scripts": {
|
|
35
|
-
"
|
|
36
|
-
"build": "tsc",
|
|
38
|
+
"bundle": "pnpm exec vite build -c ../../../scripts/vite.config.js",
|
|
37
39
|
"test": "pnpm exec vitest --run -r ../../../ --dir ."
|
|
40
|
+
},
|
|
41
|
+
"module": "dist/index.js",
|
|
42
|
+
"exports": {
|
|
43
|
+
".": {
|
|
44
|
+
"types": "./dist-tsc/index.d.ts",
|
|
45
|
+
"import": "./dist/index.js"
|
|
46
|
+
}
|
|
38
47
|
}
|
|
39
48
|
}
|
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import plur from 'plur';
|
|
3
|
+
import { TableCell, TableRow, TextField } from '@material-ui/core';
|
|
4
|
+
import { usePlotOptionsStyles, OptionSelect } from '@vitessce/vit-s';
|
|
5
|
+
import { capitalize } from '@vitessce/utils';
|
|
6
|
+
|
|
7
|
+
export default function GatingScatterplotOptions(props) {
|
|
8
|
+
const {
|
|
9
|
+
featureType,
|
|
10
|
+
gatingFeatureSelectionX,
|
|
11
|
+
setGatingFeatureSelectionX,
|
|
12
|
+
gatingFeatureSelectionY,
|
|
13
|
+
setGatingFeatureSelectionY,
|
|
14
|
+
gatingFeatureValueTransform,
|
|
15
|
+
setGatingFeatureValueTransform,
|
|
16
|
+
gatingFeatureValueTransformCoefficient,
|
|
17
|
+
setGatingFeatureValueTransformCoefficient,
|
|
18
|
+
geneSelectOptions,
|
|
19
|
+
transformOptions,
|
|
20
|
+
} = props;
|
|
21
|
+
|
|
22
|
+
const classes = usePlotOptionsStyles();
|
|
23
|
+
|
|
24
|
+
// Handlers for custom option field changes.
|
|
25
|
+
const handleGeneSelectChange = (event) => {
|
|
26
|
+
const { options } = event.target;
|
|
27
|
+
const newValues = [];
|
|
28
|
+
for (let i = 0, l = options.length; i < l; i += 1) {
|
|
29
|
+
if (options[i].selected) {
|
|
30
|
+
newValues.push(options[i].value);
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
if (newValues.length === 1
|
|
35
|
+
&& gatingFeatureSelectionX
|
|
36
|
+
&& !gatingFeatureSelectionY
|
|
37
|
+
&& newValues[0] !== gatingFeatureSelectionX) {
|
|
38
|
+
setGatingFeatureSelectionY(newValues[0]);
|
|
39
|
+
} else if (newValues.length <= 2) {
|
|
40
|
+
setGatingFeatureSelectionX(newValues[0]);
|
|
41
|
+
setGatingFeatureSelectionY(newValues[1]);
|
|
42
|
+
}
|
|
43
|
+
};
|
|
44
|
+
|
|
45
|
+
const handleTransformChange = (event) => {
|
|
46
|
+
setGatingFeatureValueTransform(event.target.value === '' ? null : event.target.value);
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
// Feels a little hacky, but I think this is the best way to handle
|
|
50
|
+
// the limitations of the v4 material-ui number input.
|
|
51
|
+
const handleTransformCoefficientChange = (event) => {
|
|
52
|
+
const { value } = event.target;
|
|
53
|
+
if (!value) {
|
|
54
|
+
setGatingFeatureValueTransformCoefficient(value);
|
|
55
|
+
} else {
|
|
56
|
+
const newCoefficient = Number(value);
|
|
57
|
+
if (!Number.isNaN(newCoefficient) && newCoefficient >= 0) {
|
|
58
|
+
setGatingFeatureValueTransformCoefficient(value);
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
};
|
|
62
|
+
|
|
63
|
+
return (
|
|
64
|
+
<>
|
|
65
|
+
<TableRow key="gene-option-row">
|
|
66
|
+
<TableCell className={classes.labelCell}>
|
|
67
|
+
{capitalize(plur(featureType, geneSelectOptions?.length))}
|
|
68
|
+
</TableCell>
|
|
69
|
+
<TableCell className={classes.inputCell}>
|
|
70
|
+
<OptionSelect
|
|
71
|
+
key="gating-gene-select"
|
|
72
|
+
multiple
|
|
73
|
+
className={classes.select}
|
|
74
|
+
value={[gatingFeatureSelectionX, gatingFeatureSelectionY].filter(v => v)}
|
|
75
|
+
onChange={handleGeneSelectChange}
|
|
76
|
+
inputProps={{
|
|
77
|
+
id: 'scatterplot-gene-select',
|
|
78
|
+
}}
|
|
79
|
+
>
|
|
80
|
+
{geneSelectOptions.map(name => (
|
|
81
|
+
<option key={name} value={name}>
|
|
82
|
+
{name}
|
|
83
|
+
</option>
|
|
84
|
+
))}
|
|
85
|
+
</OptionSelect>
|
|
86
|
+
</TableCell>
|
|
87
|
+
</TableRow>
|
|
88
|
+
<TableRow key="transform-option-row">
|
|
89
|
+
<TableCell className={classes.labelCell}>
|
|
90
|
+
Transform
|
|
91
|
+
</TableCell>
|
|
92
|
+
<TableCell className={classes.inputCell}>
|
|
93
|
+
<OptionSelect
|
|
94
|
+
key="gating-transform-select"
|
|
95
|
+
className={classes.select}
|
|
96
|
+
value={gatingFeatureValueTransform === null ? '' : gatingFeatureValueTransform}
|
|
97
|
+
onChange={handleTransformChange}
|
|
98
|
+
inputProps={{
|
|
99
|
+
id: 'scatterplot-transform-select',
|
|
100
|
+
}}
|
|
101
|
+
>
|
|
102
|
+
{transformOptions.map(opt => (
|
|
103
|
+
<option key={opt.name} value={opt.value === null ? '' : opt.value}>
|
|
104
|
+
{opt.name}
|
|
105
|
+
</option>
|
|
106
|
+
))}
|
|
107
|
+
</OptionSelect>
|
|
108
|
+
</TableCell>
|
|
109
|
+
</TableRow>
|
|
110
|
+
<TableRow key="transform-coefficient-option-row">
|
|
111
|
+
<TableCell className={classes.labelCell}>
|
|
112
|
+
Transform Coefficient
|
|
113
|
+
</TableCell>
|
|
114
|
+
<TableCell className={classes.inputCell}>
|
|
115
|
+
<TextField
|
|
116
|
+
label="Number"
|
|
117
|
+
type="number"
|
|
118
|
+
onChange={handleTransformCoefficientChange}
|
|
119
|
+
value={gatingFeatureValueTransformCoefficient}
|
|
120
|
+
InputLabelProps={{
|
|
121
|
+
shrink: true,
|
|
122
|
+
}}
|
|
123
|
+
/>
|
|
124
|
+
</TableCell>
|
|
125
|
+
</TableRow>
|
|
126
|
+
</>
|
|
127
|
+
);
|
|
128
|
+
}
|