@vitessce/scatterplot-gating 2.0.0-beta.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/LICENSE +21 -0
- package/dist/GatingScatterplotOptions.js +56 -0
- package/dist/GatingSubscriber.js +211 -0
- package/dist/index.js +1 -0
- package/package.json +39 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2018
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
|
+
import React from 'react';
|
|
3
|
+
import plur from 'plur';
|
|
4
|
+
import TableCell from '@material-ui/core/TableCell';
|
|
5
|
+
import TableRow from '@material-ui/core/TableRow';
|
|
6
|
+
import TextField from '@material-ui/core/TextField';
|
|
7
|
+
import { usePlotOptionsStyles, OptionSelect } from '@vitessce/vit-s';
|
|
8
|
+
import { capitalize } from '@vitessce/utils';
|
|
9
|
+
export default function GatingScatterplotOptions(props) {
|
|
10
|
+
const { featureType, gatingFeatureSelectionX, setGatingFeatureSelectionX, gatingFeatureSelectionY, setGatingFeatureSelectionY, gatingFeatureValueTransform, setGatingFeatureValueTransform, gatingFeatureValueTransformCoefficient, setGatingFeatureValueTransformCoefficient, geneSelectOptions, transformOptions, } = props;
|
|
11
|
+
const classes = usePlotOptionsStyles();
|
|
12
|
+
// Handlers for custom option field changes.
|
|
13
|
+
const handleGeneSelectChange = (event) => {
|
|
14
|
+
const { options } = event.target;
|
|
15
|
+
const newValues = [];
|
|
16
|
+
for (let i = 0, l = options.length; i < l; i += 1) {
|
|
17
|
+
if (options[i].selected) {
|
|
18
|
+
newValues.push(options[i].value);
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
if (newValues.length === 1
|
|
22
|
+
&& gatingFeatureSelectionX
|
|
23
|
+
&& !gatingFeatureSelectionY
|
|
24
|
+
&& newValues[0] !== gatingFeatureSelectionX) {
|
|
25
|
+
setGatingFeatureSelectionY(newValues[0]);
|
|
26
|
+
}
|
|
27
|
+
else if (newValues.length <= 2) {
|
|
28
|
+
setGatingFeatureSelectionX(newValues[0]);
|
|
29
|
+
setGatingFeatureSelectionY(newValues[1]);
|
|
30
|
+
}
|
|
31
|
+
};
|
|
32
|
+
const handleTransformChange = (event) => {
|
|
33
|
+
setGatingFeatureValueTransform(event.target.value === '' ? null : event.target.value);
|
|
34
|
+
};
|
|
35
|
+
// Feels a little hacky, but I think this is the best way to handle
|
|
36
|
+
// the limitations of the v4 material-ui number input.
|
|
37
|
+
const handleTransformCoefficientChange = (event) => {
|
|
38
|
+
const { value } = event.target;
|
|
39
|
+
if (!value) {
|
|
40
|
+
setGatingFeatureValueTransformCoefficient(value);
|
|
41
|
+
}
|
|
42
|
+
else {
|
|
43
|
+
const newCoefficient = Number(value);
|
|
44
|
+
if (!Number.isNaN(newCoefficient) && newCoefficient >= 0) {
|
|
45
|
+
setGatingFeatureValueTransformCoefficient(value);
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
};
|
|
49
|
+
return (_jsxs(_Fragment, { children: [_jsxs(TableRow, { children: [_jsx(TableCell, { className: classes.labelCell, children: capitalize(plur(featureType, geneSelectOptions?.length)) }), _jsx(TableCell, { className: classes.inputCell, children: _jsx(OptionSelect, { multiple: true, className: classes.select, value: [gatingFeatureSelectionX, gatingFeatureSelectionY].filter(v => v), onChange: handleGeneSelectChange, inputProps: {
|
|
50
|
+
id: 'scatterplot-gene-select',
|
|
51
|
+
}, children: geneSelectOptions.map(name => (_jsx("option", { value: name, children: name }, name))) }, "gating-gene-select") })] }, "gene-option-row"), _jsxs(TableRow, { children: [_jsx(TableCell, { className: classes.labelCell, children: "Transform" }), _jsx(TableCell, { className: classes.inputCell, children: _jsx(OptionSelect, { className: classes.select, value: gatingFeatureValueTransform === null ? '' : gatingFeatureValueTransform, onChange: handleTransformChange, inputProps: {
|
|
52
|
+
id: 'scatterplot-transform-select',
|
|
53
|
+
}, children: transformOptions.map(opt => (_jsx("option", { value: opt.value === null ? '' : opt.value, children: opt.name }, opt.name))) }, "gating-transform-select") })] }, "transform-option-row"), _jsxs(TableRow, { children: [_jsx(TableCell, { className: classes.labelCell, children: "Transform Coefficient" }), _jsx(TableCell, { className: classes.inputCell, children: _jsx(TextField, { label: "Number", type: "number", onChange: handleTransformCoefficientChange, value: gatingFeatureValueTransformCoefficient, InputLabelProps: {
|
|
54
|
+
shrink: true,
|
|
55
|
+
} }) })] }, "transform-coefficient-option-row")] }));
|
|
56
|
+
}
|
|
@@ -0,0 +1,211 @@
|
|
|
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/isEqual';
|
|
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, registerPluginViewType, } from '@vitessce/vit-s';
|
|
8
|
+
import { getCellSetPolygons, mergeObsSets, setObsSelection } from '@vitessce/sets';
|
|
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';
|
|
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 [urls, addUrl] = useUrls(loaders, dataset);
|
|
35
|
+
const [width, height, deckRef] = useDeckCanvasSize();
|
|
36
|
+
const title = useMemo(() => {
|
|
37
|
+
if (titleOverride) {
|
|
38
|
+
return titleOverride;
|
|
39
|
+
}
|
|
40
|
+
if (!(gatingFeatureSelectionX && gatingFeatureSelectionY)) {
|
|
41
|
+
return 'Gating';
|
|
42
|
+
}
|
|
43
|
+
return `Gating (${gatingFeatureSelectionX} vs ${gatingFeatureSelectionY})`;
|
|
44
|
+
}, [titleOverride, gatingFeatureSelectionX, gatingFeatureSelectionY]);
|
|
45
|
+
const featureSelectionX = useMemo(() => (gatingFeatureSelectionX ? [gatingFeatureSelectionX] : null), [gatingFeatureSelectionX]);
|
|
46
|
+
const featureSelectionY = useMemo(() => (gatingFeatureSelectionY ? [gatingFeatureSelectionY] : null), [gatingFeatureSelectionY]);
|
|
47
|
+
// Get data from loaders using the data hooks.
|
|
48
|
+
const [{ obsSets: cellSets }, obsSetsStatus] = useObsSetsData(loaders, dataset, addUrl, false, { setObsSetSelection: setCellSetSelection, setObsSetColor: setCellSetColor }, { obsSetSelection: cellSetSelection, obsSetColor: cellSetColor }, { obsType });
|
|
49
|
+
// eslint-disable-next-line no-unused-vars
|
|
50
|
+
const [expressionDataColor, loadedColor, featureSelectionColorStatus] = useFeatureSelection(loaders, dataset, false, gatingFeatureSelectionColor, { obsType, featureType, featureValueType });
|
|
51
|
+
// eslint-disable-next-line no-unused-vars
|
|
52
|
+
const [expressionDataX, loadedX, featureSelectionXStatus] = useFeatureSelection(loaders, dataset, false, featureSelectionX, { obsType, featureType, featureValueType });
|
|
53
|
+
// eslint-disable-next-line no-unused-vars
|
|
54
|
+
const [expressionDataY, loadedY, featureSelectionYStatus] = useFeatureSelection(loaders, dataset, false, featureSelectionY, { obsType, featureType, featureValueType });
|
|
55
|
+
const [{ obsIndex, featureIndex }, matrixIndicesStatus] = useObsFeatureMatrixIndices(loaders, dataset, addUrl, false, { obsType, featureType, featureValueType });
|
|
56
|
+
const cellsCount = obsIndex?.length || 0;
|
|
57
|
+
const isReady = useReady([
|
|
58
|
+
obsSetsStatus,
|
|
59
|
+
featureSelectionColorStatus,
|
|
60
|
+
featureSelectionXStatus,
|
|
61
|
+
featureSelectionYStatus,
|
|
62
|
+
matrixIndicesStatus,
|
|
63
|
+
]);
|
|
64
|
+
// Generate a new cells object with a mapping added for the user selected genes.
|
|
65
|
+
const obsXY = useMemo(() => {
|
|
66
|
+
if (!(cellsCount && expressionDataX?.[0] && expressionDataY?.[0]
|
|
67
|
+
&& featureSelectionX && featureSelectionY)) {
|
|
68
|
+
return null;
|
|
69
|
+
}
|
|
70
|
+
// Get transform coefficient for log and arcsinh
|
|
71
|
+
let coefficient = 1;
|
|
72
|
+
const parsedTransformCoefficient = Number(featureValueTransformCoefficient);
|
|
73
|
+
if (!Number.isNaN(parsedTransformCoefficient) && parsedTransformCoefficient > 0) {
|
|
74
|
+
coefficient = parsedTransformCoefficient;
|
|
75
|
+
}
|
|
76
|
+
// Set transform function
|
|
77
|
+
const transformFunction = getValueTransformFunction(featureValueTransform, coefficient);
|
|
78
|
+
const obsX = new Float32Array(cellsCount);
|
|
79
|
+
const obsY = new Float32Array(cellsCount);
|
|
80
|
+
for (let i = 0; i < cellsCount; i += 1) {
|
|
81
|
+
obsX[i] = transformFunction(expressionDataX[0][i]);
|
|
82
|
+
obsY[i] = transformFunction(expressionDataY[0][i]);
|
|
83
|
+
}
|
|
84
|
+
return {
|
|
85
|
+
data: [obsX, obsY],
|
|
86
|
+
shape: [2, cellsCount],
|
|
87
|
+
};
|
|
88
|
+
}, [cellsCount, expressionDataX, expressionDataY,
|
|
89
|
+
featureValueTransform, featureValueTransformCoefficient,
|
|
90
|
+
featureSelectionX, featureSelectionY,
|
|
91
|
+
]);
|
|
92
|
+
const [dynamicCellRadius, setDynamicCellRadius] = useState(cellRadiusFixed);
|
|
93
|
+
const [dynamicCellOpacity, setDynamicCellOpacity] = useState(cellOpacityFixed);
|
|
94
|
+
const mergedCellSets = useMemo(() => mergeObsSets(cellSets, additionalCellSets), [cellSets, additionalCellSets]);
|
|
95
|
+
const setCellSelectionProp = useCallback((v) => {
|
|
96
|
+
setObsSelection(v, additionalCellSets, cellSetColor, setCellSetSelection, setAdditionalCellSets, setCellSetColor, setCellColorEncoding);
|
|
97
|
+
}, [additionalCellSets, cellSetColor, setCellColorEncoding,
|
|
98
|
+
setAdditionalCellSets, setCellSetColor, setCellSetSelection]);
|
|
99
|
+
const cellColors = useMemo(() => getCellColors({
|
|
100
|
+
cellColorEncoding,
|
|
101
|
+
expressionData: expressionDataColor && expressionDataColor[0],
|
|
102
|
+
geneSelection: gatingFeatureSelectionColor,
|
|
103
|
+
cellSets: mergedCellSets,
|
|
104
|
+
cellSetSelection,
|
|
105
|
+
cellSetColor,
|
|
106
|
+
obsIndex,
|
|
107
|
+
theme,
|
|
108
|
+
}), [cellColorEncoding, gatingFeatureSelectionColor, mergedCellSets, theme,
|
|
109
|
+
cellSetSelection, cellSetColor, expressionDataColor, 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
|
+
// Set up a getter function for gene expression values, to be used
|
|
175
|
+
// by the DeckGL layer to obtain values for instanced attributes.
|
|
176
|
+
const getExpressionValue = useExpressionValueGetter({
|
|
177
|
+
instanceObsIndex: obsIndex,
|
|
178
|
+
matrixObsIndex: obsIndex,
|
|
179
|
+
expressionData: expressionDataColor,
|
|
180
|
+
});
|
|
181
|
+
// Puts the mapping values in the cell info tooltip.
|
|
182
|
+
const getObsInfo = useCallback((obsId) => {
|
|
183
|
+
const selectedTransformName = VALUE_TRANSFORM_OPTIONS.find(o => o.value === featureValueTransform)?.name;
|
|
184
|
+
const genePrefix = featureValueTransform ? `${selectedTransformName} ` : '';
|
|
185
|
+
const obsIdx = obsIndex?.indexOf(obsId);
|
|
186
|
+
const obsInfo = { [`${capitalize(obsType)} ID`]: obsId };
|
|
187
|
+
if (gatingFeatureSelectionX && gatingFeatureSelectionY) {
|
|
188
|
+
obsInfo[genePrefix + gatingFeatureSelectionX] = obsXY.data[0][obsIdx];
|
|
189
|
+
obsInfo[genePrefix + gatingFeatureSelectionY] = obsXY.data[1][obsIdx];
|
|
190
|
+
}
|
|
191
|
+
return obsInfo;
|
|
192
|
+
}, [obsXY, obsIndex, featureValueTransform,
|
|
193
|
+
gatingFeatureSelectionX, gatingFeatureSelectionY, obsType,
|
|
194
|
+
]);
|
|
195
|
+
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) => {
|
|
196
|
+
setFeatureValueTransform(newValue);
|
|
197
|
+
setTargetX(null);
|
|
198
|
+
setTargetY(null);
|
|
199
|
+
setZoom(null);
|
|
200
|
+
}, 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 }) => {
|
|
201
|
+
setZoom(newZoom);
|
|
202
|
+
setTargetX(target[0]);
|
|
203
|
+
setTargetY(target[1]);
|
|
204
|
+
setTargetZ(target[2] || 0);
|
|
205
|
+
}, 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: () => {
|
|
206
|
+
setComponentHover(uuid);
|
|
207
|
+
}, updateViewInfo: setComponentViewInfo, getExpressionValue: getExpressionValue, getCellIsSelected: getCellIsSelected }), !disableTooltip && (_jsx(ScatterplotTooltipSubscriber, { parentUuid: uuid, obsHighlight: cellHighlight, width: width, height: height, getObsInfo: getObsInfo }))] }));
|
|
208
|
+
}
|
|
209
|
+
export function register() {
|
|
210
|
+
registerPluginViewType(ViewType.GATING, GatingSubscriber, COMPONENT_COORDINATION_TYPES[ViewType.GATING]);
|
|
211
|
+
}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { GatingSubscriber, register } from './GatingSubscriber';
|
package/package.json
ADDED
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@vitessce/scatterplot-gating",
|
|
3
|
+
"version": "2.0.0-beta.0",
|
|
4
|
+
"author": "Gehlenborg Lab",
|
|
5
|
+
"homepage": "http://vitessce.io",
|
|
6
|
+
"repository": {
|
|
7
|
+
"type": "git",
|
|
8
|
+
"url": "git+https://github.com/vitessce/vitessce.git"
|
|
9
|
+
},
|
|
10
|
+
"license": "MIT",
|
|
11
|
+
"main": "dist/index.js",
|
|
12
|
+
"files": [
|
|
13
|
+
"dist"
|
|
14
|
+
],
|
|
15
|
+
"dependencies": {
|
|
16
|
+
"@material-ui/core": "~4.12.3",
|
|
17
|
+
"@vitessce/constants-internal": "2.0.0-beta.0",
|
|
18
|
+
"@vitessce/scatterplot": "2.0.0-beta.0",
|
|
19
|
+
"@vitessce/sets": "2.0.0-beta.0",
|
|
20
|
+
"@vitessce/utils": "2.0.0-beta.0",
|
|
21
|
+
"@vitessce/vit-s": "2.0.0-beta.0",
|
|
22
|
+
"d3-array": "^2.4.0",
|
|
23
|
+
"lodash": "^4.17.21",
|
|
24
|
+
"plur": "^5.1.0"
|
|
25
|
+
},
|
|
26
|
+
"devDependencies": {
|
|
27
|
+
"react": "^18.0.0",
|
|
28
|
+
"vite": "^3.0.0",
|
|
29
|
+
"vitest": "^0.23.4"
|
|
30
|
+
},
|
|
31
|
+
"peerDependencies": {
|
|
32
|
+
"react": "^16.8.0 || ^17.0.0 || ^18.0.0"
|
|
33
|
+
},
|
|
34
|
+
"scripts": {
|
|
35
|
+
"start": "tsc --watch",
|
|
36
|
+
"build": "tsc",
|
|
37
|
+
"test": "pnpm exec vitest --run -r ../../../ --dir ."
|
|
38
|
+
}
|
|
39
|
+
}
|