@vitessce/scatterplot-embedding 2.0.3-beta.0 → 2.0.3
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.0903602c.mjs +13 -0
- package/dist/index.30ffff67.mjs +133748 -0
- package/dist/index.mjs +8 -0
- package/dist/jpeg.b1faad97.mjs +840 -0
- package/dist/lerc.6382beb0.mjs +1943 -0
- package/dist/lzw.db43ecd8.mjs +128 -0
- package/dist/packbits.0886c4a4.mjs +30 -0
- package/dist/pako.esm.4b234125.mjs +3940 -0
- package/dist/raw.779e896c.mjs +12 -0
- package/dist/webimage.53b96d4c.mjs +32 -0
- package/{dist → dist-tsc}/index.js +0 -0
- package/package.json +10 -10
- package/src/EmbeddingScatterplotOptions.js +47 -0
- package/src/EmbeddingScatterplotSubscriber.js +361 -0
- package/src/index.js +1 -0
- package/dist/EmbeddingScatterplotOptions.js +0 -18
- package/dist/EmbeddingScatterplotSubscriber.js +0 -153
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { B as BaseDecoder } from "./index.30ffff67.mjs";
|
|
2
|
+
import "react";
|
|
3
|
+
import "@vitessce/vit-s";
|
|
4
|
+
import "react-dom";
|
|
5
|
+
class RawDecoder extends BaseDecoder {
|
|
6
|
+
decodeBlock(buffer) {
|
|
7
|
+
return buffer;
|
|
8
|
+
}
|
|
9
|
+
}
|
|
10
|
+
export {
|
|
11
|
+
RawDecoder as default
|
|
12
|
+
};
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { B as BaseDecoder } from "./index.30ffff67.mjs";
|
|
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
|
+
};
|
|
File without changes
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vitessce/scatterplot-embedding",
|
|
3
|
-
"version": "2.0.3
|
|
3
|
+
"version": "2.0.3",
|
|
4
4
|
"author": "Gehlenborg Lab",
|
|
5
5
|
"homepage": "http://vitessce.io",
|
|
6
6
|
"repository": {
|
|
@@ -8,20 +8,21 @@
|
|
|
8
8
|
"url": "git+https://github.com/vitessce/vitessce.git"
|
|
9
9
|
},
|
|
10
10
|
"license": "MIT",
|
|
11
|
-
"main": "dist/index.
|
|
11
|
+
"main": "dist/index.mjs",
|
|
12
12
|
"files": [
|
|
13
|
-
"dist"
|
|
13
|
+
"dist",
|
|
14
|
+
"src"
|
|
14
15
|
],
|
|
15
16
|
"dependencies": {
|
|
16
17
|
"@material-ui/core": "~4.12.3",
|
|
17
18
|
"d3-array": "^2.4.0",
|
|
18
19
|
"lodash": "^4.17.21",
|
|
19
20
|
"plur": "^5.1.0",
|
|
20
|
-
"@vitessce/
|
|
21
|
-
"@vitessce/
|
|
22
|
-
"@vitessce/
|
|
23
|
-
"@vitessce/
|
|
24
|
-
"@vitessce/
|
|
21
|
+
"@vitessce/constants-internal": "2.0.3",
|
|
22
|
+
"@vitessce/scatterplot": "2.0.3",
|
|
23
|
+
"@vitessce/sets-utils": "2.0.3",
|
|
24
|
+
"@vitessce/utils": "2.0.3",
|
|
25
|
+
"@vitessce/vit-s": "2.0.3"
|
|
25
26
|
},
|
|
26
27
|
"devDependencies": {
|
|
27
28
|
"react": "^18.0.0",
|
|
@@ -32,8 +33,7 @@
|
|
|
32
33
|
"react": "^16.8.0 || ^17.0.0 || ^18.0.0"
|
|
33
34
|
},
|
|
34
35
|
"scripts": {
|
|
35
|
-
"
|
|
36
|
-
"build": "tsc",
|
|
36
|
+
"bundle": "pnpm exec vite build -c ../../../scripts/vite.config.js",
|
|
37
37
|
"test": "pnpm exec vitest --run -r ../../../ --dir ."
|
|
38
38
|
}
|
|
39
39
|
}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import TableCell from '@material-ui/core/TableCell';
|
|
3
|
+
import TableRow from '@material-ui/core/TableRow';
|
|
4
|
+
import { usePlotOptionsStyles, OptionSelect } from '@vitessce/vit-s';
|
|
5
|
+
|
|
6
|
+
export default function EmbeddingScatterplotOptions(props) {
|
|
7
|
+
const {
|
|
8
|
+
mappingSelectEnabled,
|
|
9
|
+
mappings,
|
|
10
|
+
selectedMapping,
|
|
11
|
+
setSelectedMapping,
|
|
12
|
+
} = props;
|
|
13
|
+
|
|
14
|
+
const classes = usePlotOptionsStyles();
|
|
15
|
+
|
|
16
|
+
// Handlers for custom option field changes.
|
|
17
|
+
const handleSelectedMappingChange = (event) => {
|
|
18
|
+
setSelectedMapping(event.target.value);
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
return mappingSelectEnabled
|
|
22
|
+
? (
|
|
23
|
+
<TableRow key="mapping-option-row">
|
|
24
|
+
<TableCell className={classes.labelCell}>
|
|
25
|
+
Embedding Type
|
|
26
|
+
</TableCell>
|
|
27
|
+
<TableCell className={classes.inputCell}>
|
|
28
|
+
<OptionSelect
|
|
29
|
+
key="scatterplot-mapping-select"
|
|
30
|
+
className={classes.select}
|
|
31
|
+
value={selectedMapping}
|
|
32
|
+
onChange={handleSelectedMappingChange}
|
|
33
|
+
inputProps={{
|
|
34
|
+
id: 'scatterplot-mapping-select',
|
|
35
|
+
}}
|
|
36
|
+
>
|
|
37
|
+
{mappings.map(name => (
|
|
38
|
+
<option key={name} value={name}>
|
|
39
|
+
{name}
|
|
40
|
+
</option>
|
|
41
|
+
))}
|
|
42
|
+
</OptionSelect>
|
|
43
|
+
</TableCell>
|
|
44
|
+
</TableRow>
|
|
45
|
+
)
|
|
46
|
+
: null;
|
|
47
|
+
}
|
|
@@ -0,0 +1,361 @@
|
|
|
1
|
+
import React, {
|
|
2
|
+
useState, useEffect, useCallback, useMemo,
|
|
3
|
+
} from 'react';
|
|
4
|
+
import { extent } from 'd3-array';
|
|
5
|
+
import isEqual from 'lodash/isEqual';
|
|
6
|
+
import plur from 'plur';
|
|
7
|
+
import {
|
|
8
|
+
TitleInfo,
|
|
9
|
+
registerPluginViewType,
|
|
10
|
+
useReady, useUrls,
|
|
11
|
+
useDeckCanvasSize,
|
|
12
|
+
useExpressionValueGetter, useGetObsInfo,
|
|
13
|
+
useObsEmbeddingData,
|
|
14
|
+
useObsSetsData,
|
|
15
|
+
useFeatureSelection,
|
|
16
|
+
useObsFeatureMatrixIndices,
|
|
17
|
+
useMultiObsLabels,
|
|
18
|
+
useCoordination,
|
|
19
|
+
useLoaders,
|
|
20
|
+
useSetComponentHover,
|
|
21
|
+
useSetComponentViewInfo,
|
|
22
|
+
} from '@vitessce/vit-s';
|
|
23
|
+
import { setObsSelection, mergeObsSets, getCellSetPolygons } from '@vitessce/sets-utils';
|
|
24
|
+
import { getCellColors, commaNumber } from '@vitessce/utils';
|
|
25
|
+
import {
|
|
26
|
+
Scatterplot, ScatterplotTooltipSubscriber, ScatterplotOptions,
|
|
27
|
+
getPointSizeDevicePixels,
|
|
28
|
+
getPointOpacity,
|
|
29
|
+
} from '@vitessce/scatterplot';
|
|
30
|
+
import { ViewType, COMPONENT_COORDINATION_TYPES } from '@vitessce/constants-internal';
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* A subscriber component for the scatterplot.
|
|
34
|
+
* @param {object} props
|
|
35
|
+
* @param {number} props.uuid The unique identifier for this component.
|
|
36
|
+
* @param {string} props.theme The current theme name.
|
|
37
|
+
* @param {object} props.coordinationScopes The mapping from coordination types to coordination
|
|
38
|
+
* scopes.
|
|
39
|
+
* @param {boolean} props.disableTooltip Should the tooltip be disabled?
|
|
40
|
+
* @param {function} props.removeGridComponent The callback function to pass to TitleInfo,
|
|
41
|
+
* to call when the component has been removed from the grid.
|
|
42
|
+
* @param {string} props.title An override value for the component title.
|
|
43
|
+
* @param {number} props.averageFillDensity Override the average fill density calculation
|
|
44
|
+
* when using dynamic opacity mode.
|
|
45
|
+
*/
|
|
46
|
+
export function EmbeddingScatterplotSubscriber(props) {
|
|
47
|
+
const {
|
|
48
|
+
uuid,
|
|
49
|
+
coordinationScopes,
|
|
50
|
+
removeGridComponent,
|
|
51
|
+
theme,
|
|
52
|
+
disableTooltip = false,
|
|
53
|
+
observationsLabelOverride,
|
|
54
|
+
title: titleOverride,
|
|
55
|
+
// Average fill density for dynamic opacity calculation.
|
|
56
|
+
averageFillDensity,
|
|
57
|
+
} = props;
|
|
58
|
+
|
|
59
|
+
const loaders = useLoaders();
|
|
60
|
+
const setComponentHover = useSetComponentHover();
|
|
61
|
+
const setComponentViewInfo = useSetComponentViewInfo(uuid);
|
|
62
|
+
|
|
63
|
+
// Get "props" from the coordination space.
|
|
64
|
+
const [{
|
|
65
|
+
dataset,
|
|
66
|
+
obsType,
|
|
67
|
+
featureType,
|
|
68
|
+
featureValueType,
|
|
69
|
+
embeddingZoom: zoom,
|
|
70
|
+
embeddingTargetX: targetX,
|
|
71
|
+
embeddingTargetY: targetY,
|
|
72
|
+
embeddingTargetZ: targetZ,
|
|
73
|
+
embeddingType: mapping,
|
|
74
|
+
obsFilter: cellFilter,
|
|
75
|
+
obsHighlight: cellHighlight,
|
|
76
|
+
featureSelection: geneSelection,
|
|
77
|
+
obsSetSelection: cellSetSelection,
|
|
78
|
+
obsSetColor: cellSetColor,
|
|
79
|
+
obsColorEncoding: cellColorEncoding,
|
|
80
|
+
additionalObsSets: additionalCellSets,
|
|
81
|
+
embeddingObsSetPolygonsVisible: cellSetPolygonsVisible,
|
|
82
|
+
embeddingObsSetLabelsVisible: cellSetLabelsVisible,
|
|
83
|
+
embeddingObsSetLabelSize: cellSetLabelSize,
|
|
84
|
+
embeddingObsRadius: cellRadiusFixed,
|
|
85
|
+
embeddingObsRadiusMode: cellRadiusMode,
|
|
86
|
+
embeddingObsOpacity: cellOpacityFixed,
|
|
87
|
+
embeddingObsOpacityMode: cellOpacityMode,
|
|
88
|
+
featureValueColormap: geneExpressionColormap,
|
|
89
|
+
featureValueColormapRange: geneExpressionColormapRange,
|
|
90
|
+
}, {
|
|
91
|
+
setEmbeddingZoom: setZoom,
|
|
92
|
+
setEmbeddingTargetX: setTargetX,
|
|
93
|
+
setEmbeddingTargetY: setTargetY,
|
|
94
|
+
setEmbeddingTargetZ: setTargetZ,
|
|
95
|
+
setObsFilter: setCellFilter,
|
|
96
|
+
setObsSetSelection: setCellSetSelection,
|
|
97
|
+
setObsHighlight: setCellHighlight,
|
|
98
|
+
setObsSetColor: setCellSetColor,
|
|
99
|
+
setObsColorEncoding: setCellColorEncoding,
|
|
100
|
+
setAdditionalObsSets: setAdditionalCellSets,
|
|
101
|
+
setEmbeddingObsSetPolygonsVisible: setCellSetPolygonsVisible,
|
|
102
|
+
setEmbeddingObsSetLabelsVisible: setCellSetLabelsVisible,
|
|
103
|
+
setEmbeddingObsSetLabelSize: setCellSetLabelSize,
|
|
104
|
+
setEmbeddingObsRadius: setCellRadiusFixed,
|
|
105
|
+
setEmbeddingObsRadiusMode: setCellRadiusMode,
|
|
106
|
+
setEmbeddingObsOpacity: setCellOpacityFixed,
|
|
107
|
+
setEmbeddingObsOpacityMode: setCellOpacityMode,
|
|
108
|
+
setFeatureValueColormap: setGeneExpressionColormap,
|
|
109
|
+
setFeatureValueColormapRange: setGeneExpressionColormapRange,
|
|
110
|
+
}] = useCoordination(COMPONENT_COORDINATION_TYPES[ViewType.SCATTERPLOT], coordinationScopes);
|
|
111
|
+
|
|
112
|
+
const observationsLabel = observationsLabelOverride || obsType;
|
|
113
|
+
|
|
114
|
+
const [urls, addUrl] = useUrls(loaders, dataset);
|
|
115
|
+
const [width, height, deckRef] = useDeckCanvasSize();
|
|
116
|
+
|
|
117
|
+
const title = titleOverride || `Scatterplot (${mapping})`;
|
|
118
|
+
|
|
119
|
+
const [obsLabelsTypes, obsLabelsData] = useMultiObsLabels(
|
|
120
|
+
coordinationScopes, obsType, loaders, dataset, addUrl,
|
|
121
|
+
);
|
|
122
|
+
|
|
123
|
+
// Get data from loaders using the data hooks.
|
|
124
|
+
const [{ obsIndex: obsEmbeddingIndex, obsEmbedding }, obsEmbeddingStatus] = useObsEmbeddingData(
|
|
125
|
+
loaders, dataset, addUrl, true, {}, {},
|
|
126
|
+
{ obsType, embeddingType: mapping },
|
|
127
|
+
);
|
|
128
|
+
const cellsCount = obsEmbeddingIndex?.length || 0;
|
|
129
|
+
const [{ obsSets: cellSets, obsSetsMembership }, obsSetsStatus] = useObsSetsData(
|
|
130
|
+
loaders, dataset, addUrl, false,
|
|
131
|
+
{ setObsSetSelection: setCellSetSelection, setObsSetColor: setCellSetColor },
|
|
132
|
+
{ obsSetSelection: cellSetSelection, obsSetColor: cellSetColor },
|
|
133
|
+
{ obsType },
|
|
134
|
+
);
|
|
135
|
+
// eslint-disable-next-line no-unused-vars
|
|
136
|
+
const [expressionData, loadedFeatureSelection, featureSelectionStatus] = useFeatureSelection(
|
|
137
|
+
loaders, dataset, false, geneSelection,
|
|
138
|
+
{ obsType, featureType, featureValueType },
|
|
139
|
+
);
|
|
140
|
+
const [{ obsIndex: matrixObsIndex }, matrixIndicesStatus] = useObsFeatureMatrixIndices(
|
|
141
|
+
loaders, dataset, addUrl, false,
|
|
142
|
+
{ obsType, featureType, featureValueType },
|
|
143
|
+
);
|
|
144
|
+
|
|
145
|
+
const isReady = useReady([
|
|
146
|
+
obsEmbeddingStatus,
|
|
147
|
+
obsSetsStatus,
|
|
148
|
+
featureSelectionStatus,
|
|
149
|
+
matrixIndicesStatus,
|
|
150
|
+
]);
|
|
151
|
+
|
|
152
|
+
const [dynamicCellRadius, setDynamicCellRadius] = useState(cellRadiusFixed);
|
|
153
|
+
const [dynamicCellOpacity, setDynamicCellOpacity] = useState(cellOpacityFixed);
|
|
154
|
+
|
|
155
|
+
const mergedCellSets = useMemo(() => mergeObsSets(
|
|
156
|
+
cellSets, additionalCellSets,
|
|
157
|
+
), [cellSets, additionalCellSets]);
|
|
158
|
+
|
|
159
|
+
const setCellSelectionProp = useCallback((v) => {
|
|
160
|
+
setObsSelection(
|
|
161
|
+
v, additionalCellSets, cellSetColor,
|
|
162
|
+
setCellSetSelection, setAdditionalCellSets, setCellSetColor,
|
|
163
|
+
setCellColorEncoding,
|
|
164
|
+
);
|
|
165
|
+
}, [additionalCellSets, cellSetColor, setCellColorEncoding,
|
|
166
|
+
setAdditionalCellSets, setCellSetColor, setCellSetSelection]);
|
|
167
|
+
|
|
168
|
+
const cellColors = useMemo(() => getCellColors({
|
|
169
|
+
cellColorEncoding,
|
|
170
|
+
expressionData: expressionData && expressionData[0],
|
|
171
|
+
geneSelection,
|
|
172
|
+
cellSets: mergedCellSets,
|
|
173
|
+
cellSetSelection,
|
|
174
|
+
cellSetColor,
|
|
175
|
+
obsIndex: matrixObsIndex,
|
|
176
|
+
theme,
|
|
177
|
+
}), [cellColorEncoding, geneSelection, mergedCellSets, theme,
|
|
178
|
+
cellSetSelection, cellSetColor, expressionData, matrixObsIndex]);
|
|
179
|
+
|
|
180
|
+
// cellSetPolygonCache is an array of tuples like [(key0, val0), (key1, val1), ...],
|
|
181
|
+
// where the keys are cellSetSelection arrays.
|
|
182
|
+
const [cellSetPolygonCache, setCellSetPolygonCache] = useState([]);
|
|
183
|
+
const cacheHas = (cache, key) => cache.findIndex(el => isEqual(el[0], key)) !== -1;
|
|
184
|
+
const cacheGet = (cache, key) => cache.find(el => isEqual(el[0], key))?.[1];
|
|
185
|
+
const cellSetPolygons = useMemo(() => {
|
|
186
|
+
if ((cellSetLabelsVisible || cellSetPolygonsVisible)
|
|
187
|
+
&& !cacheHas(cellSetPolygonCache, cellSetSelection)
|
|
188
|
+
&& mergedCellSets?.tree?.length
|
|
189
|
+
&& obsEmbedding
|
|
190
|
+
&& obsEmbeddingIndex
|
|
191
|
+
&& cellSetColor?.length) {
|
|
192
|
+
const newCellSetPolygons = getCellSetPolygons({
|
|
193
|
+
obsIndex: obsEmbeddingIndex,
|
|
194
|
+
obsEmbedding,
|
|
195
|
+
cellSets: mergedCellSets,
|
|
196
|
+
cellSetSelection,
|
|
197
|
+
cellSetColor,
|
|
198
|
+
theme,
|
|
199
|
+
});
|
|
200
|
+
setCellSetPolygonCache(cache => [...cache, [cellSetSelection, newCellSetPolygons]]);
|
|
201
|
+
return newCellSetPolygons;
|
|
202
|
+
}
|
|
203
|
+
return cacheGet(cellSetPolygonCache, cellSetSelection) || [];
|
|
204
|
+
}, [cellSetPolygonsVisible, cellSetPolygonCache, cellSetLabelsVisible, theme,
|
|
205
|
+
obsEmbeddingIndex, obsEmbedding, mergedCellSets, cellSetSelection, cellSetColor]);
|
|
206
|
+
|
|
207
|
+
|
|
208
|
+
const cellSelection = useMemo(() => Array.from(cellColors.keys()), [cellColors]);
|
|
209
|
+
|
|
210
|
+
const [xRange, yRange, xExtent, yExtent, numCells] = useMemo(() => {
|
|
211
|
+
if (obsEmbedding && obsEmbedding.data && obsEmbedding.shape) {
|
|
212
|
+
const cellCount = obsEmbedding.shape[1];
|
|
213
|
+
const xE = extent(obsEmbedding.data[0]);
|
|
214
|
+
const yE = extent(obsEmbedding.data[1]);
|
|
215
|
+
const xR = xE[1] - xE[0];
|
|
216
|
+
const yR = yE[1] - yE[0];
|
|
217
|
+
return [xR, yR, xE, yE, cellCount];
|
|
218
|
+
}
|
|
219
|
+
return [null, null, null, null, null];
|
|
220
|
+
}, [obsEmbedding]);
|
|
221
|
+
|
|
222
|
+
// After cells have loaded or changed,
|
|
223
|
+
// compute the cell radius scale based on the
|
|
224
|
+
// extents of the cell coordinates on the x/y axes.
|
|
225
|
+
useEffect(() => {
|
|
226
|
+
if (xRange && yRange) {
|
|
227
|
+
const pointSizeDevicePixels = getPointSizeDevicePixels(
|
|
228
|
+
window.devicePixelRatio, zoom, xRange, yRange, width, height,
|
|
229
|
+
);
|
|
230
|
+
setDynamicCellRadius(pointSizeDevicePixels);
|
|
231
|
+
|
|
232
|
+
const nextCellOpacityScale = getPointOpacity(
|
|
233
|
+
zoom, xRange, yRange, width, height, numCells, averageFillDensity,
|
|
234
|
+
);
|
|
235
|
+
setDynamicCellOpacity(nextCellOpacityScale);
|
|
236
|
+
|
|
237
|
+
if (typeof targetX !== 'number' || typeof targetY !== 'number') {
|
|
238
|
+
const newTargetX = xExtent[0] + xRange / 2;
|
|
239
|
+
const newTargetY = yExtent[0] + yRange / 2;
|
|
240
|
+
const newZoom = Math.log2(Math.min(width / xRange, height / yRange));
|
|
241
|
+
setTargetX(newTargetX);
|
|
242
|
+
// Graphics rendering has the y-axis going south so we need to multiply by negative one.
|
|
243
|
+
setTargetY(-newTargetY);
|
|
244
|
+
setZoom(newZoom);
|
|
245
|
+
}
|
|
246
|
+
}
|
|
247
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
248
|
+
}, [xRange, yRange, xExtent, yExtent, numCells,
|
|
249
|
+
width, height, zoom, averageFillDensity]);
|
|
250
|
+
|
|
251
|
+
const getObsInfo = useGetObsInfo(
|
|
252
|
+
observationsLabel, obsLabelsTypes, obsLabelsData, obsSetsMembership,
|
|
253
|
+
);
|
|
254
|
+
|
|
255
|
+
const cellSelectionSet = useMemo(() => new Set(cellSelection), [cellSelection]);
|
|
256
|
+
const getCellIsSelected = useCallback((object, { index }) => (
|
|
257
|
+
(cellSelectionSet || new Set([])).has(obsEmbeddingIndex[index]) ? 1.0 : 0.0
|
|
258
|
+
), [cellSelectionSet, obsEmbeddingIndex]);
|
|
259
|
+
|
|
260
|
+
const cellRadius = (cellRadiusMode === 'manual' ? cellRadiusFixed : dynamicCellRadius);
|
|
261
|
+
const cellOpacity = (cellOpacityMode === 'manual' ? cellOpacityFixed : dynamicCellOpacity);
|
|
262
|
+
|
|
263
|
+
// Set up a getter function for gene expression values, to be used
|
|
264
|
+
// by the DeckGL layer to obtain values for instanced attributes.
|
|
265
|
+
const getExpressionValue = useExpressionValueGetter({
|
|
266
|
+
instanceObsIndex: obsEmbeddingIndex,
|
|
267
|
+
matrixObsIndex,
|
|
268
|
+
expressionData,
|
|
269
|
+
});
|
|
270
|
+
|
|
271
|
+
return (
|
|
272
|
+
<TitleInfo
|
|
273
|
+
title={title}
|
|
274
|
+
info={`${commaNumber(cellsCount)} ${plur(observationsLabel, cellsCount)}`}
|
|
275
|
+
removeGridComponent={removeGridComponent}
|
|
276
|
+
urls={urls}
|
|
277
|
+
theme={theme}
|
|
278
|
+
isReady={isReady}
|
|
279
|
+
options={(
|
|
280
|
+
<ScatterplotOptions
|
|
281
|
+
observationsLabel={observationsLabel}
|
|
282
|
+
cellRadius={cellRadiusFixed}
|
|
283
|
+
setCellRadius={setCellRadiusFixed}
|
|
284
|
+
cellRadiusMode={cellRadiusMode}
|
|
285
|
+
setCellRadiusMode={setCellRadiusMode}
|
|
286
|
+
cellOpacity={cellOpacityFixed}
|
|
287
|
+
setCellOpacity={setCellOpacityFixed}
|
|
288
|
+
cellOpacityMode={cellOpacityMode}
|
|
289
|
+
setCellOpacityMode={setCellOpacityMode}
|
|
290
|
+
cellSetLabelsVisible={cellSetLabelsVisible}
|
|
291
|
+
setCellSetLabelsVisible={setCellSetLabelsVisible}
|
|
292
|
+
cellSetLabelSize={cellSetLabelSize}
|
|
293
|
+
setCellSetLabelSize={setCellSetLabelSize}
|
|
294
|
+
cellSetPolygonsVisible={cellSetPolygonsVisible}
|
|
295
|
+
setCellSetPolygonsVisible={setCellSetPolygonsVisible}
|
|
296
|
+
cellColorEncoding={cellColorEncoding}
|
|
297
|
+
setCellColorEncoding={setCellColorEncoding}
|
|
298
|
+
geneExpressionColormap={geneExpressionColormap}
|
|
299
|
+
setGeneExpressionColormap={setGeneExpressionColormap}
|
|
300
|
+
geneExpressionColormapRange={geneExpressionColormapRange}
|
|
301
|
+
setGeneExpressionColormapRange={setGeneExpressionColormapRange}
|
|
302
|
+
/>
|
|
303
|
+
)}
|
|
304
|
+
>
|
|
305
|
+
<Scatterplot
|
|
306
|
+
ref={deckRef}
|
|
307
|
+
uuid={uuid}
|
|
308
|
+
theme={theme}
|
|
309
|
+
viewState={{ zoom, target: [targetX, targetY, targetZ] }}
|
|
310
|
+
setViewState={({ zoom: newZoom, target }) => {
|
|
311
|
+
setZoom(newZoom);
|
|
312
|
+
setTargetX(target[0]);
|
|
313
|
+
setTargetY(target[1]);
|
|
314
|
+
setTargetZ(target[2] || 0);
|
|
315
|
+
}}
|
|
316
|
+
obsEmbeddingIndex={obsEmbeddingIndex}
|
|
317
|
+
obsEmbedding={obsEmbedding}
|
|
318
|
+
cellFilter={cellFilter}
|
|
319
|
+
cellSelection={cellSelection}
|
|
320
|
+
cellHighlight={cellHighlight}
|
|
321
|
+
cellColors={cellColors}
|
|
322
|
+
cellSetPolygons={cellSetPolygons}
|
|
323
|
+
cellSetLabelSize={cellSetLabelSize}
|
|
324
|
+
cellSetLabelsVisible={cellSetLabelsVisible}
|
|
325
|
+
cellSetPolygonsVisible={cellSetPolygonsVisible}
|
|
326
|
+
setCellFilter={setCellFilter}
|
|
327
|
+
setCellSelection={setCellSelectionProp}
|
|
328
|
+
setCellHighlight={setCellHighlight}
|
|
329
|
+
cellRadius={cellRadius}
|
|
330
|
+
cellOpacity={cellOpacity}
|
|
331
|
+
cellColorEncoding={cellColorEncoding}
|
|
332
|
+
geneExpressionColormap={geneExpressionColormap}
|
|
333
|
+
geneExpressionColormapRange={geneExpressionColormapRange}
|
|
334
|
+
setComponentHover={() => {
|
|
335
|
+
setComponentHover(uuid);
|
|
336
|
+
}}
|
|
337
|
+
updateViewInfo={setComponentViewInfo}
|
|
338
|
+
getExpressionValue={getExpressionValue}
|
|
339
|
+
getCellIsSelected={getCellIsSelected}
|
|
340
|
+
|
|
341
|
+
/>
|
|
342
|
+
{!disableTooltip && (
|
|
343
|
+
<ScatterplotTooltipSubscriber
|
|
344
|
+
parentUuid={uuid}
|
|
345
|
+
obsHighlight={cellHighlight}
|
|
346
|
+
width={width}
|
|
347
|
+
height={height}
|
|
348
|
+
getObsInfo={getObsInfo}
|
|
349
|
+
/>
|
|
350
|
+
)}
|
|
351
|
+
</TitleInfo>
|
|
352
|
+
);
|
|
353
|
+
}
|
|
354
|
+
|
|
355
|
+
export function register() {
|
|
356
|
+
registerPluginViewType(
|
|
357
|
+
ViewType.SCATTERPLOT,
|
|
358
|
+
EmbeddingScatterplotSubscriber,
|
|
359
|
+
COMPONENT_COORDINATION_TYPES[ViewType.SCATTERPLOT],
|
|
360
|
+
);
|
|
361
|
+
}
|
package/src/index.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { EmbeddingScatterplotSubscriber, register } from './EmbeddingScatterplotSubscriber';
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
import React from 'react';
|
|
3
|
-
import TableCell from '@material-ui/core/TableCell';
|
|
4
|
-
import TableRow from '@material-ui/core/TableRow';
|
|
5
|
-
import { usePlotOptionsStyles, OptionSelect } from '@vitessce/vit-s';
|
|
6
|
-
export default function EmbeddingScatterplotOptions(props) {
|
|
7
|
-
const { mappingSelectEnabled, mappings, selectedMapping, setSelectedMapping, } = props;
|
|
8
|
-
const classes = usePlotOptionsStyles();
|
|
9
|
-
// Handlers for custom option field changes.
|
|
10
|
-
const handleSelectedMappingChange = (event) => {
|
|
11
|
-
setSelectedMapping(event.target.value);
|
|
12
|
-
};
|
|
13
|
-
return mappingSelectEnabled
|
|
14
|
-
? (_jsxs(TableRow, { children: [_jsx(TableCell, { className: classes.labelCell, children: "Embedding Type" }), _jsx(TableCell, { className: classes.inputCell, children: _jsx(OptionSelect, { className: classes.select, value: selectedMapping, onChange: handleSelectedMappingChange, inputProps: {
|
|
15
|
-
id: 'scatterplot-mapping-select',
|
|
16
|
-
}, children: mappings.map(name => (_jsx("option", { value: name, children: name }, name))) }, "scatterplot-mapping-select") })] }, "mapping-option-row"))
|
|
17
|
-
: null;
|
|
18
|
-
}
|