@vitessce/scatterplot-gating 2.0.3 → 3.0.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/{deflate.244b5e4d.mjs → deflate-9e0df7d6.js} +2 -2
- package/dist/{index.2b98eb03.mjs → index-55139ae6.js} +32333 -21228
- package/dist/index.js +7 -0
- package/dist/{jpeg.0c78cd80.mjs → jpeg-401dc42f.js} +1 -1
- package/dist/{lerc.2aba4384.mjs → lerc-0b18eed1.js} +76 -5
- package/dist/{lzw.83308f93.mjs → lzw-4ce0a11f.js} +1 -1
- package/dist/{packbits.b29c602e.mjs → packbits-2356dc29.js} +1 -1
- package/dist/{pako.esm.4b234125.mjs → pako.esm-68f84e2a.js} +97 -15
- package/dist/{raw.7e14c8c2.mjs → raw-cb261cd1.js} +1 -1
- package/dist/{webimage.ed12ec5b.mjs → webimage-a363de79.js} +1 -1
- package/dist-tsc/GatingScatterplotOptions.d.ts +2 -0
- package/dist-tsc/GatingScatterplotOptions.d.ts.map +1 -0
- package/dist-tsc/GatingScatterplotOptions.js +54 -0
- package/dist-tsc/GatingSubscriber.d.ts +22 -0
- package/dist-tsc/GatingSubscriber.d.ts.map +1 -0
- package/dist-tsc/GatingSubscriber.js +209 -0
- package/dist-tsc/index.d.ts +2 -0
- package/dist-tsc/index.d.ts.map +1 -0
- package/dist-tsc/index.js +1 -1
- package/package.json +21 -12
- package/src/GatingScatterplotOptions.js +1 -3
- package/src/GatingSubscriber.js +20 -23
- package/src/index.js +1 -1
- package/dist/index.mjs +0 -8
|
@@ -0,0 +1,209 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import React, { useState, useEffect, useCallback, useMemo, } from 'react';
|
|
3
|
+
import plur from 'plur';
|
|
4
|
+
import { extent } from 'd3-array';
|
|
5
|
+
import { isEqual } from 'lodash-es';
|
|
6
|
+
import { capitalize, commaNumber, getCellColors, getValueTransformFunction, VALUE_TRANSFORM_OPTIONS, } from '@vitessce/utils';
|
|
7
|
+
import { TitleInfo, useDeckCanvasSize, useReady, useUrls, useUint8FeatureSelection, useExpressionValueGetter, useObsSetsData, useFeatureSelection, useObsFeatureMatrixIndices, useCoordination, useLoaders, useSetComponentHover, useSetComponentViewInfo, } from '@vitessce/vit-s';
|
|
8
|
+
import { getCellSetPolygons, mergeObsSets, setObsSelection } from '@vitessce/sets-utils';
|
|
9
|
+
import { Scatterplot, ScatterplotTooltipSubscriber, ScatterplotOptions, getPointSizeDevicePixels, getPointOpacity, EmptyMessage, } from '@vitessce/scatterplot';
|
|
10
|
+
import { ViewType, COMPONENT_COORDINATION_TYPES } from '@vitessce/constants-internal';
|
|
11
|
+
import GatingScatterplotOptions from './GatingScatterplotOptions.js';
|
|
12
|
+
/**
|
|
13
|
+
* A subscriber component for the gating scatterplot.
|
|
14
|
+
* @param {object} props
|
|
15
|
+
* @param {number} props.uuid The unique identifier for this component.
|
|
16
|
+
* @param {string} props.theme The current theme name.
|
|
17
|
+
* @param {object} props.coordinationScopes The mapping from coordination types to coordination
|
|
18
|
+
* scopes.
|
|
19
|
+
* @param {boolean} props.disableTooltip Should the tooltip be disabled?
|
|
20
|
+
* @param {function} props.removeGridComponent The callback function to pass to TitleInfo,
|
|
21
|
+
* to call when the component has been removed from the grid.
|
|
22
|
+
* @param {number} props.averageFillDensity Override the average fill density calculation
|
|
23
|
+
* when using dynamic opacity mode.
|
|
24
|
+
*/
|
|
25
|
+
export function GatingSubscriber(props) {
|
|
26
|
+
const { uuid, coordinationScopes, removeGridComponent, theme, disableTooltip = false, title: titleOverride,
|
|
27
|
+
// Average fill density for dynamic opacity calculation.
|
|
28
|
+
averageFillDensity, } = props;
|
|
29
|
+
const loaders = useLoaders();
|
|
30
|
+
const setComponentHover = useSetComponentHover();
|
|
31
|
+
const setComponentViewInfo = useSetComponentViewInfo(uuid);
|
|
32
|
+
// Get "props" from the coordination space.
|
|
33
|
+
const [{ dataset, obsType, featureType, featureValueType, embeddingZoom: zoom, embeddingTargetX: targetX, embeddingTargetY: targetY, embeddingTargetZ: targetZ, obsFilter: cellFilter, obsHighlight: cellHighlight, obsSetSelection: cellSetSelection, obsSetColor: cellSetColor, obsColorEncoding: cellColorEncoding, additionalObsSets: additionalCellSets, embeddingObsSetPolygonsVisible: cellSetPolygonsVisible, embeddingObsSetLabelsVisible: cellSetLabelsVisible, embeddingObsSetLabelSize: cellSetLabelSize, embeddingObsRadius: cellRadiusFixed, embeddingObsRadiusMode: cellRadiusMode, embeddingObsOpacity: cellOpacityFixed, embeddingObsOpacityMode: cellOpacityMode, featureValueColormap: geneExpressionColormap, featureValueColormapRange: geneExpressionColormapRange, featureSelection: gatingFeatureSelectionColor, featureValueTransform, featureValueTransformCoefficient, gatingFeatureSelectionX, gatingFeatureSelectionY, }, { setEmbeddingZoom: setZoom, setEmbeddingTargetX: setTargetX, setEmbeddingTargetY: setTargetY, setEmbeddingTargetZ: setTargetZ, setObsFilter: setCellFilter, setObsSetSelection: setCellSetSelection, setObsHighlight: setCellHighlight, setObsSetColor: setCellSetColor, setObsColorEncoding: setCellColorEncoding, setAdditionalObsSets: setAdditionalCellSets, setEmbeddingObsSetPolygonsVisible: setCellSetPolygonsVisible, setEmbeddingObsSetLabelsVisible: setCellSetLabelsVisible, setEmbeddingObsSetLabelSize: setCellSetLabelSize, setEmbeddingObsRadius: setCellRadiusFixed, setEmbeddingObsRadiusMode: setCellRadiusMode, setEmbeddingObsOpacity: setCellOpacityFixed, setEmbeddingObsOpacityMode: setCellOpacityMode, setFeatureValueColormap: setGeneExpressionColormap, setFeatureValueColormapRange: setGeneExpressionColormapRange, setFeatureValueTransform, setFeatureValueTransformCoefficient, setGatingFeatureSelectionX, setGatingFeatureSelectionY, }] = useCoordination(COMPONENT_COORDINATION_TYPES[ViewType.GATING], coordinationScopes);
|
|
34
|
+
const [width, height, deckRef] = useDeckCanvasSize();
|
|
35
|
+
const title = useMemo(() => {
|
|
36
|
+
if (titleOverride) {
|
|
37
|
+
return titleOverride;
|
|
38
|
+
}
|
|
39
|
+
if (!(gatingFeatureSelectionX && gatingFeatureSelectionY)) {
|
|
40
|
+
return 'Gating';
|
|
41
|
+
}
|
|
42
|
+
return `Gating (${gatingFeatureSelectionX} vs ${gatingFeatureSelectionY})`;
|
|
43
|
+
}, [titleOverride, gatingFeatureSelectionX, gatingFeatureSelectionY]);
|
|
44
|
+
const featureSelectionX = useMemo(() => (gatingFeatureSelectionX ? [gatingFeatureSelectionX] : null), [gatingFeatureSelectionX]);
|
|
45
|
+
const featureSelectionY = useMemo(() => (gatingFeatureSelectionY ? [gatingFeatureSelectionY] : null), [gatingFeatureSelectionY]);
|
|
46
|
+
// Get data from loaders using the data hooks.
|
|
47
|
+
const [{ obsSets: cellSets }, obsSetsStatus, obsSetsUrls] = useObsSetsData(loaders, dataset, false, { setObsSetSelection: setCellSetSelection, setObsSetColor: setCellSetColor }, { obsSetSelection: cellSetSelection, obsSetColor: cellSetColor }, { obsType });
|
|
48
|
+
// eslint-disable-next-line no-unused-vars
|
|
49
|
+
const [expressionDataColor, loadedColor, featureSelectionColorStatus] = useFeatureSelection(loaders, dataset, false, gatingFeatureSelectionColor, { obsType, featureType, featureValueType });
|
|
50
|
+
// eslint-disable-next-line no-unused-vars
|
|
51
|
+
const [expressionDataX, loadedX, featureSelectionXStatus] = useFeatureSelection(loaders, dataset, false, featureSelectionX, { obsType, featureType, featureValueType });
|
|
52
|
+
// eslint-disable-next-line no-unused-vars
|
|
53
|
+
const [expressionDataY, loadedY, featureSelectionYStatus] = useFeatureSelection(loaders, dataset, false, featureSelectionY, { obsType, featureType, featureValueType });
|
|
54
|
+
const [{ obsIndex, featureIndex }, matrixIndicesStatus, matrixIndicesUrls,] = useObsFeatureMatrixIndices(loaders, dataset, false, { obsType, featureType, featureValueType });
|
|
55
|
+
const cellsCount = obsIndex?.length || 0;
|
|
56
|
+
const isReady = useReady([
|
|
57
|
+
obsSetsStatus,
|
|
58
|
+
featureSelectionColorStatus,
|
|
59
|
+
featureSelectionXStatus,
|
|
60
|
+
featureSelectionYStatus,
|
|
61
|
+
matrixIndicesStatus,
|
|
62
|
+
]);
|
|
63
|
+
const urls = useUrls([
|
|
64
|
+
obsSetsUrls,
|
|
65
|
+
matrixIndicesUrls,
|
|
66
|
+
]);
|
|
67
|
+
// Generate a new cells object with a mapping added for the user selected genes.
|
|
68
|
+
const obsXY = useMemo(() => {
|
|
69
|
+
if (!(cellsCount && expressionDataX?.[0] && expressionDataY?.[0]
|
|
70
|
+
&& featureSelectionX && featureSelectionY)) {
|
|
71
|
+
return null;
|
|
72
|
+
}
|
|
73
|
+
// Get transform coefficient for log and arcsinh
|
|
74
|
+
let coefficient = 1;
|
|
75
|
+
const parsedTransformCoefficient = Number(featureValueTransformCoefficient);
|
|
76
|
+
if (!Number.isNaN(parsedTransformCoefficient) && parsedTransformCoefficient > 0) {
|
|
77
|
+
coefficient = parsedTransformCoefficient;
|
|
78
|
+
}
|
|
79
|
+
// Set transform function
|
|
80
|
+
const transformFunction = getValueTransformFunction(featureValueTransform, coefficient);
|
|
81
|
+
const obsX = new Float32Array(cellsCount);
|
|
82
|
+
const obsY = new Float32Array(cellsCount);
|
|
83
|
+
for (let i = 0; i < cellsCount; i += 1) {
|
|
84
|
+
obsX[i] = transformFunction(expressionDataX[0][i]);
|
|
85
|
+
obsY[i] = transformFunction(expressionDataY[0][i]);
|
|
86
|
+
}
|
|
87
|
+
return {
|
|
88
|
+
data: [obsX, obsY],
|
|
89
|
+
shape: [2, cellsCount],
|
|
90
|
+
};
|
|
91
|
+
}, [cellsCount, expressionDataX, expressionDataY,
|
|
92
|
+
featureValueTransform, featureValueTransformCoefficient,
|
|
93
|
+
featureSelectionX, featureSelectionY,
|
|
94
|
+
]);
|
|
95
|
+
const [dynamicCellRadius, setDynamicCellRadius] = useState(cellRadiusFixed);
|
|
96
|
+
const [dynamicCellOpacity, setDynamicCellOpacity] = useState(cellOpacityFixed);
|
|
97
|
+
const mergedCellSets = useMemo(() => mergeObsSets(cellSets, additionalCellSets), [cellSets, additionalCellSets]);
|
|
98
|
+
const setCellSelectionProp = useCallback((v) => {
|
|
99
|
+
setObsSelection(v, additionalCellSets, cellSetColor, setCellSetSelection, setAdditionalCellSets, setCellSetColor, setCellColorEncoding);
|
|
100
|
+
}, [additionalCellSets, cellSetColor, setCellColorEncoding,
|
|
101
|
+
setAdditionalCellSets, setCellSetColor, setCellSetSelection]);
|
|
102
|
+
const cellColors = useMemo(() => getCellColors({
|
|
103
|
+
cellSets: mergedCellSets,
|
|
104
|
+
cellSetSelection,
|
|
105
|
+
cellSetColor,
|
|
106
|
+
obsIndex,
|
|
107
|
+
theme,
|
|
108
|
+
}), [mergedCellSets, theme,
|
|
109
|
+
cellSetSelection, cellSetColor, obsIndex]);
|
|
110
|
+
// cellSetPolygonCache is an array of tuples like [(key0, val0), (key1, val1), ...],
|
|
111
|
+
// where the keys are cellSetSelection arrays.
|
|
112
|
+
const [cellSetPolygonCache, setCellSetPolygonCache] = useState([]);
|
|
113
|
+
const cacheHas = (cache, key) => cache.findIndex(el => isEqual(el[0], key)) !== -1;
|
|
114
|
+
const cacheGet = (cache, key) => cache.find(el => isEqual(el[0], key))?.[1];
|
|
115
|
+
const cellSetPolygons = useMemo(() => {
|
|
116
|
+
if ((cellSetLabelsVisible || cellSetPolygonsVisible)
|
|
117
|
+
&& !cacheHas(cellSetPolygonCache, cellSetSelection)
|
|
118
|
+
&& mergedCellSets?.tree?.length
|
|
119
|
+
&& obsXY
|
|
120
|
+
&& obsIndex
|
|
121
|
+
&& cellSetColor?.length) {
|
|
122
|
+
const newCellSetPolygons = getCellSetPolygons({
|
|
123
|
+
obsIndex,
|
|
124
|
+
obsEmbedding: obsXY,
|
|
125
|
+
cellSets: mergedCellSets,
|
|
126
|
+
cellSetSelection,
|
|
127
|
+
cellSetColor,
|
|
128
|
+
theme,
|
|
129
|
+
});
|
|
130
|
+
setCellSetPolygonCache(cache => [...cache, [cellSetSelection, newCellSetPolygons]]);
|
|
131
|
+
return newCellSetPolygons;
|
|
132
|
+
}
|
|
133
|
+
return cacheGet(cellSetPolygonCache, cellSetSelection) || [];
|
|
134
|
+
}, [cellSetPolygonsVisible, cellSetPolygonCache, cellSetLabelsVisible, theme,
|
|
135
|
+
obsIndex, obsXY, mergedCellSets, cellSetSelection, cellSetColor]);
|
|
136
|
+
const cellSelection = useMemo(() => Array.from(cellColors.keys()), [cellColors]);
|
|
137
|
+
const [xRange, yRange, xExtent, yExtent, numCells] = useMemo(() => {
|
|
138
|
+
if (obsXY && obsXY.data && obsXY.shape) {
|
|
139
|
+
const cellCount = obsXY.shape[1];
|
|
140
|
+
const xE = extent(obsXY.data[0]);
|
|
141
|
+
const yE = extent(obsXY.data[1]);
|
|
142
|
+
const xR = xE[1] - xE[0];
|
|
143
|
+
const yR = yE[1] - yE[0];
|
|
144
|
+
return [xR, yR, xE, yE, cellCount];
|
|
145
|
+
}
|
|
146
|
+
return [null, null, null, null, null];
|
|
147
|
+
}, [obsXY]);
|
|
148
|
+
// After cells have loaded or changed,
|
|
149
|
+
// compute the cell radius scale based on the
|
|
150
|
+
// extents of the cell coordinates on the x/y axes.
|
|
151
|
+
useEffect(() => {
|
|
152
|
+
if (xRange && yRange) {
|
|
153
|
+
const pointSizeDevicePixels = getPointSizeDevicePixels(window.devicePixelRatio, zoom, xRange, yRange, width, height);
|
|
154
|
+
setDynamicCellRadius(pointSizeDevicePixels);
|
|
155
|
+
const nextCellOpacityScale = getPointOpacity(zoom, xRange, yRange, width, height, numCells, averageFillDensity);
|
|
156
|
+
setDynamicCellOpacity(nextCellOpacityScale);
|
|
157
|
+
if (typeof targetX !== 'number' || typeof targetY !== 'number') {
|
|
158
|
+
const newTargetX = xExtent[0] + xRange / 2;
|
|
159
|
+
const newTargetY = yExtent[0] + yRange / 2;
|
|
160
|
+
const newZoom = Math.log2(Math.min(width / xRange, height / yRange));
|
|
161
|
+
setTargetX(newTargetX);
|
|
162
|
+
// Graphics rendering has the y-axis going south so we need to multiply by negative one.
|
|
163
|
+
setTargetY(-newTargetY);
|
|
164
|
+
setZoom(newZoom);
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
168
|
+
}, [xRange, yRange, xExtent, yExtent, numCells,
|
|
169
|
+
width, height, zoom, averageFillDensity]);
|
|
170
|
+
const cellSelectionSet = useMemo(() => new Set(cellSelection), [cellSelection]);
|
|
171
|
+
const getCellIsSelected = useCallback((object, { index }) => ((cellSelectionSet || new Set([])).has(obsIndex[index]) ? 1.0 : 0.0), [cellSelectionSet, obsIndex]);
|
|
172
|
+
const cellRadius = (cellRadiusMode === 'manual' ? cellRadiusFixed : dynamicCellRadius);
|
|
173
|
+
const cellOpacity = (cellOpacityMode === 'manual' ? cellOpacityFixed : dynamicCellOpacity);
|
|
174
|
+
const [uint8ExpressionData] = useUint8FeatureSelection(expressionDataColor);
|
|
175
|
+
// Set up a getter function for gene expression values, to be used
|
|
176
|
+
// by the DeckGL layer to obtain values for instanced attributes.
|
|
177
|
+
const getExpressionValue = useExpressionValueGetter({
|
|
178
|
+
instanceObsIndex: obsIndex,
|
|
179
|
+
matrixObsIndex: obsIndex,
|
|
180
|
+
expressionData: uint8ExpressionData,
|
|
181
|
+
});
|
|
182
|
+
// Puts the mapping values in the cell info tooltip.
|
|
183
|
+
const getObsInfo = useCallback((obsId) => {
|
|
184
|
+
const selectedTransformName = VALUE_TRANSFORM_OPTIONS.find(o => o.value === featureValueTransform)?.name;
|
|
185
|
+
const genePrefix = featureValueTransform ? `${selectedTransformName} ` : '';
|
|
186
|
+
const obsIdx = obsIndex?.indexOf(obsId);
|
|
187
|
+
const obsInfo = { [`${capitalize(obsType)} ID`]: obsId };
|
|
188
|
+
if (gatingFeatureSelectionX && gatingFeatureSelectionY) {
|
|
189
|
+
obsInfo[genePrefix + gatingFeatureSelectionX] = obsXY.data[0][obsIdx];
|
|
190
|
+
obsInfo[genePrefix + gatingFeatureSelectionY] = obsXY.data[1][obsIdx];
|
|
191
|
+
}
|
|
192
|
+
return obsInfo;
|
|
193
|
+
}, [obsXY, obsIndex, featureValueTransform,
|
|
194
|
+
gatingFeatureSelectionX, gatingFeatureSelectionY, obsType,
|
|
195
|
+
]);
|
|
196
|
+
return (_jsxs(TitleInfo, { title: title, info: `${commaNumber(cellsCount)} ${plur(obsType, cellsCount)}`, removeGridComponent: removeGridComponent, urls: urls, theme: theme, isReady: isReady, options: (_jsx(ScatterplotOptions, { observationsLabel: obsType, cellRadius: cellRadiusFixed, setCellRadius: setCellRadiusFixed, cellRadiusMode: cellRadiusMode, setCellRadiusMode: setCellRadiusMode, cellOpacity: cellOpacityFixed, setCellOpacity: setCellOpacityFixed, cellOpacityMode: cellOpacityMode, setCellOpacityMode: setCellOpacityMode, cellSetLabelsVisible: cellSetLabelsVisible, setCellSetLabelsVisible: setCellSetLabelsVisible, cellSetLabelSize: cellSetLabelSize, setCellSetLabelSize: setCellSetLabelSize, cellSetPolygonsVisible: cellSetPolygonsVisible, setCellSetPolygonsVisible: setCellSetPolygonsVisible, cellColorEncoding: cellColorEncoding, setCellColorEncoding: setCellColorEncoding, geneExpressionColormap: geneExpressionColormap, setGeneExpressionColormap: setGeneExpressionColormap, geneExpressionColormapRange: geneExpressionColormapRange, setGeneExpressionColormapRange: setGeneExpressionColormapRange, children: _jsx(GatingScatterplotOptions, { featureType: featureType, gatingFeatureSelectionX: gatingFeatureSelectionX, setGatingFeatureSelectionX: setGatingFeatureSelectionX, gatingFeatureSelectionY: gatingFeatureSelectionY, setGatingFeatureSelectionY: setGatingFeatureSelectionY, gatingFeatureValueTransform: featureValueTransform, setGatingFeatureValueTransform: (newValue) => {
|
|
197
|
+
setFeatureValueTransform(newValue);
|
|
198
|
+
setTargetX(null);
|
|
199
|
+
setTargetY(null);
|
|
200
|
+
setZoom(null);
|
|
201
|
+
}, gatingFeatureValueTransformCoefficient: featureValueTransformCoefficient, setGatingFeatureValueTransformCoefficient: setFeatureValueTransformCoefficient, geneSelectOptions: featureIndex, transformOptions: VALUE_TRANSFORM_OPTIONS }) })), children: [_jsx(EmptyMessage, { visible: !(gatingFeatureSelectionX && gatingFeatureSelectionY), message: `Select two ${plur(featureType, 2)} in the plot settings.` }), _jsx(Scatterplot, { ref: deckRef, uuid: uuid, theme: theme, hideTools: !(gatingFeatureSelectionX && gatingFeatureSelectionY), viewState: { zoom, target: [targetX, targetY, targetZ] }, setViewState: ({ zoom: newZoom, target }) => {
|
|
202
|
+
setZoom(newZoom);
|
|
203
|
+
setTargetX(target[0]);
|
|
204
|
+
setTargetY(target[1]);
|
|
205
|
+
setTargetZ(target[2] || 0);
|
|
206
|
+
}, obsEmbeddingIndex: obsIndex, obsEmbedding: obsXY, cellFilter: cellFilter, cellSelection: cellSelection, cellHighlight: cellHighlight, cellColors: cellColors, cellSetPolygons: cellSetPolygons, cellSetLabelSize: cellSetLabelSize, cellSetLabelsVisible: cellSetLabelsVisible, cellSetPolygonsVisible: cellSetPolygonsVisible, setCellFilter: setCellFilter, setCellSelection: setCellSelectionProp, setCellHighlight: setCellHighlight, cellRadius: cellRadius, cellOpacity: cellOpacity, cellColorEncoding: cellColorEncoding, geneExpressionColormap: geneExpressionColormap, geneExpressionColormapRange: geneExpressionColormapRange, setComponentHover: () => {
|
|
207
|
+
setComponentHover(uuid);
|
|
208
|
+
}, updateViewInfo: setComponentViewInfo, getExpressionValue: getExpressionValue, getCellIsSelected: getCellIsSelected }), !disableTooltip && (_jsx(ScatterplotTooltipSubscriber, { parentUuid: uuid, obsHighlight: cellHighlight, width: width, height: height, getObsInfo: getObsInfo }))] }));
|
|
209
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.js"],"names":[],"mappings":""}
|
package/dist-tsc/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export { GatingSubscriber
|
|
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.1",
|
|
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
|
-
"
|
|
11
|
+
"type": "module",
|
|
12
|
+
"main": "dist/index.js",
|
|
12
13
|
"files": [
|
|
14
|
+
"src",
|
|
13
15
|
"dist",
|
|
14
|
-
"
|
|
16
|
+
"dist-tsc"
|
|
15
17
|
],
|
|
16
18
|
"dependencies": {
|
|
17
19
|
"@material-ui/core": "~4.12.3",
|
|
18
20
|
"d3-array": "^2.4.0",
|
|
19
|
-
"lodash": "^4.17.21",
|
|
21
|
+
"lodash-es": "^4.17.21",
|
|
20
22
|
"plur": "^5.1.0",
|
|
21
|
-
"@vitessce/constants-internal": "
|
|
22
|
-
"@vitessce/scatterplot": "
|
|
23
|
-
"@vitessce/sets-utils": "
|
|
24
|
-
"@vitessce/utils": "
|
|
25
|
-
"@vitessce/vit-s": "
|
|
23
|
+
"@vitessce/constants-internal": "3.0.1",
|
|
24
|
+
"@vitessce/scatterplot": "3.0.1",
|
|
25
|
+
"@vitessce/sets-utils": "3.0.1",
|
|
26
|
+
"@vitessce/utils": "3.0.1",
|
|
27
|
+
"@vitessce/vit-s": "3.0.1"
|
|
26
28
|
},
|
|
27
29
|
"devDependencies": {
|
|
28
30
|
"react": "^18.0.0",
|
|
29
|
-
"vite": "^3.0
|
|
30
|
-
"vitest": "^0.
|
|
31
|
+
"vite": "^4.3.0",
|
|
32
|
+
"vitest": "^0.32.2"
|
|
31
33
|
},
|
|
32
34
|
"peerDependencies": {
|
|
33
35
|
"react": "^16.8.0 || ^17.0.0 || ^18.0.0"
|
|
34
36
|
},
|
|
35
37
|
"scripts": {
|
|
36
38
|
"bundle": "pnpm exec vite build -c ../../../scripts/vite.config.js",
|
|
37
|
-
"test": "pnpm exec vitest --run
|
|
39
|
+
"test": "pnpm exec vitest --run"
|
|
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
|
}
|
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import plur from 'plur';
|
|
3
|
-
import TableCell from '@material-ui/core
|
|
4
|
-
import TableRow from '@material-ui/core/TableRow';
|
|
5
|
-
import TextField from '@material-ui/core/TextField';
|
|
3
|
+
import { TableCell, TableRow, TextField } from '@material-ui/core';
|
|
6
4
|
import { usePlotOptionsStyles, OptionSelect } from '@vitessce/vit-s';
|
|
7
5
|
import { capitalize } from '@vitessce/utils';
|
|
8
6
|
|
package/src/GatingSubscriber.js
CHANGED
|
@@ -3,7 +3,7 @@ import React, {
|
|
|
3
3
|
} from 'react';
|
|
4
4
|
import plur from 'plur';
|
|
5
5
|
import { extent } from 'd3-array';
|
|
6
|
-
import isEqual from 'lodash
|
|
6
|
+
import { isEqual } from 'lodash-es';
|
|
7
7
|
import {
|
|
8
8
|
capitalize, commaNumber,
|
|
9
9
|
getCellColors,
|
|
@@ -11,7 +11,9 @@ import {
|
|
|
11
11
|
} from '@vitessce/utils';
|
|
12
12
|
import {
|
|
13
13
|
TitleInfo,
|
|
14
|
-
useDeckCanvasSize, useReady, useUrls,
|
|
14
|
+
useDeckCanvasSize, useReady, useUrls,
|
|
15
|
+
useUint8FeatureSelection,
|
|
16
|
+
useExpressionValueGetter,
|
|
15
17
|
useObsSetsData,
|
|
16
18
|
useFeatureSelection,
|
|
17
19
|
useObsFeatureMatrixIndices,
|
|
@@ -19,7 +21,6 @@ import {
|
|
|
19
21
|
useLoaders,
|
|
20
22
|
useSetComponentHover,
|
|
21
23
|
useSetComponentViewInfo,
|
|
22
|
-
registerPluginViewType,
|
|
23
24
|
} from '@vitessce/vit-s';
|
|
24
25
|
import { getCellSetPolygons, mergeObsSets, setObsSelection } from '@vitessce/sets-utils';
|
|
25
26
|
import {
|
|
@@ -29,7 +30,7 @@ import {
|
|
|
29
30
|
EmptyMessage,
|
|
30
31
|
} from '@vitessce/scatterplot';
|
|
31
32
|
import { ViewType, COMPONENT_COORDINATION_TYPES } from '@vitessce/constants-internal';
|
|
32
|
-
import GatingScatterplotOptions from './GatingScatterplotOptions';
|
|
33
|
+
import GatingScatterplotOptions from './GatingScatterplotOptions.js';
|
|
33
34
|
|
|
34
35
|
/**
|
|
35
36
|
* A subscriber component for the gating scatterplot.
|
|
@@ -119,7 +120,6 @@ export function GatingSubscriber(props) {
|
|
|
119
120
|
coordinationScopes,
|
|
120
121
|
);
|
|
121
122
|
|
|
122
|
-
const [urls, addUrl] = useUrls(loaders, dataset);
|
|
123
123
|
const [width, height, deckRef] = useDeckCanvasSize();
|
|
124
124
|
|
|
125
125
|
const title = useMemo(() => {
|
|
@@ -140,8 +140,8 @@ export function GatingSubscriber(props) {
|
|
|
140
140
|
), [gatingFeatureSelectionY]);
|
|
141
141
|
|
|
142
142
|
// Get data from loaders using the data hooks.
|
|
143
|
-
const [{ obsSets: cellSets }, obsSetsStatus] = useObsSetsData(
|
|
144
|
-
loaders, dataset,
|
|
143
|
+
const [{ obsSets: cellSets }, obsSetsStatus, obsSetsUrls] = useObsSetsData(
|
|
144
|
+
loaders, dataset, false,
|
|
145
145
|
{ setObsSetSelection: setCellSetSelection, setObsSetColor: setCellSetColor },
|
|
146
146
|
{ obsSetSelection: cellSetSelection, obsSetColor: cellSetColor },
|
|
147
147
|
{ obsType },
|
|
@@ -161,8 +161,10 @@ export function GatingSubscriber(props) {
|
|
|
161
161
|
loaders, dataset, false, featureSelectionY,
|
|
162
162
|
{ obsType, featureType, featureValueType },
|
|
163
163
|
);
|
|
164
|
-
const [
|
|
165
|
-
|
|
164
|
+
const [
|
|
165
|
+
{ obsIndex, featureIndex }, matrixIndicesStatus, matrixIndicesUrls,
|
|
166
|
+
] = useObsFeatureMatrixIndices(
|
|
167
|
+
loaders, dataset, false,
|
|
166
168
|
{ obsType, featureType, featureValueType },
|
|
167
169
|
);
|
|
168
170
|
const cellsCount = obsIndex?.length || 0;
|
|
@@ -174,6 +176,10 @@ export function GatingSubscriber(props) {
|
|
|
174
176
|
featureSelectionYStatus,
|
|
175
177
|
matrixIndicesStatus,
|
|
176
178
|
]);
|
|
179
|
+
const urls = useUrls([
|
|
180
|
+
obsSetsUrls,
|
|
181
|
+
matrixIndicesUrls,
|
|
182
|
+
]);
|
|
177
183
|
|
|
178
184
|
// Generate a new cells object with a mapping added for the user selected genes.
|
|
179
185
|
const obsXY = useMemo(() => {
|
|
@@ -228,16 +234,13 @@ export function GatingSubscriber(props) {
|
|
|
228
234
|
setAdditionalCellSets, setCellSetColor, setCellSetSelection]);
|
|
229
235
|
|
|
230
236
|
const cellColors = useMemo(() => getCellColors({
|
|
231
|
-
cellColorEncoding,
|
|
232
|
-
expressionData: expressionDataColor && expressionDataColor[0],
|
|
233
|
-
geneSelection: gatingFeatureSelectionColor,
|
|
234
237
|
cellSets: mergedCellSets,
|
|
235
238
|
cellSetSelection,
|
|
236
239
|
cellSetColor,
|
|
237
240
|
obsIndex,
|
|
238
241
|
theme,
|
|
239
|
-
}), [
|
|
240
|
-
cellSetSelection, cellSetColor,
|
|
242
|
+
}), [mergedCellSets, theme,
|
|
243
|
+
cellSetSelection, cellSetColor, obsIndex]);
|
|
241
244
|
|
|
242
245
|
// cellSetPolygonCache is an array of tuples like [(key0, val0), (key1, val1), ...],
|
|
243
246
|
// where the keys are cellSetSelection arrays.
|
|
@@ -318,12 +321,14 @@ export function GatingSubscriber(props) {
|
|
|
318
321
|
const cellRadius = (cellRadiusMode === 'manual' ? cellRadiusFixed : dynamicCellRadius);
|
|
319
322
|
const cellOpacity = (cellOpacityMode === 'manual' ? cellOpacityFixed : dynamicCellOpacity);
|
|
320
323
|
|
|
324
|
+
const [uint8ExpressionData] = useUint8FeatureSelection(expressionDataColor);
|
|
325
|
+
|
|
321
326
|
// Set up a getter function for gene expression values, to be used
|
|
322
327
|
// by the DeckGL layer to obtain values for instanced attributes.
|
|
323
328
|
const getExpressionValue = useExpressionValueGetter({
|
|
324
329
|
instanceObsIndex: obsIndex,
|
|
325
330
|
matrixObsIndex: obsIndex,
|
|
326
|
-
expressionData:
|
|
331
|
+
expressionData: uint8ExpressionData,
|
|
327
332
|
});
|
|
328
333
|
|
|
329
334
|
// Puts the mapping values in the cell info tooltip.
|
|
@@ -450,11 +455,3 @@ export function GatingSubscriber(props) {
|
|
|
450
455
|
</TitleInfo>
|
|
451
456
|
);
|
|
452
457
|
}
|
|
453
|
-
|
|
454
|
-
export function register() {
|
|
455
|
-
registerPluginViewType(
|
|
456
|
-
ViewType.GATING,
|
|
457
|
-
GatingSubscriber,
|
|
458
|
-
COMPONENT_COORDINATION_TYPES[ViewType.GATING],
|
|
459
|
-
);
|
|
460
|
-
}
|
package/src/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export { GatingSubscriber
|
|
1
|
+
export { GatingSubscriber } from './GatingSubscriber.js';
|