@vitessce/dev 2.0.0-beta.2 → 2.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.fd6a2bf5.mjs → deflate.199a1acc.mjs} +1 -1
- package/dist/{index.879a4eb2.mjs → index.00c6d36a.mjs} +1560 -1539
- package/dist/index.mjs +1 -1
- package/dist/index.umd.js +1553 -1532
- package/dist/{jpeg.da6a1ce7.mjs → jpeg.21d1374d.mjs} +1 -1
- package/dist/{lerc.f650c15f.mjs → lerc.c99fbca0.mjs} +1 -1
- package/dist/{lzw.a7b59c9a.mjs → lzw.e9257ec2.mjs} +1 -1
- package/dist/{packbits.948b00a6.mjs → packbits.ab2ecbac.mjs} +1 -1
- package/dist/{raw.f81790cb.mjs → raw.741ddabe.mjs} +1 -1
- package/dist/{webimage.a23de56d.mjs → webimage.0fa273e8.mjs} +1 -1
- package/package.json +5 -5
package/dist/index.umd.js
CHANGED
|
@@ -552,6 +552,18 @@ var __publicField = (obj, key, value) => {
|
|
|
552
552
|
CoordinationType$2.FEATURE_SELECTION
|
|
553
553
|
]
|
|
554
554
|
};
|
|
555
|
+
const note = "This file is regenerated by push-demo.sh.";
|
|
556
|
+
const version$6 = "2.0.1";
|
|
557
|
+
const branch = "release-v2.0.1";
|
|
558
|
+
const date$3 = "2022-11-30";
|
|
559
|
+
const hash$1 = "0327a9c6";
|
|
560
|
+
const META_VERSION = {
|
|
561
|
+
note,
|
|
562
|
+
version: version$6,
|
|
563
|
+
branch,
|
|
564
|
+
date: date$3,
|
|
565
|
+
hash: hash$1
|
|
566
|
+
};
|
|
555
567
|
const ViewType$1 = {
|
|
556
568
|
GENES: [
|
|
557
569
|
"genes",
|
|
@@ -10130,7 +10142,11 @@ ${oldObj[prop][1]}`);
|
|
|
10130
10142
|
grayLight: "#D3D3D3",
|
|
10131
10143
|
grayMid: "#808080",
|
|
10132
10144
|
grayDark: "#555555",
|
|
10133
|
-
black: "#000000"
|
|
10145
|
+
black: "#000000",
|
|
10146
|
+
grayDarkL5: "rgb(98, 98, 98)",
|
|
10147
|
+
grayDarkD15: "rgb(47, 47, 47)",
|
|
10148
|
+
grayMidL10: "rgb(154, 154, 154)",
|
|
10149
|
+
grayLightL10: "rgb(237, 237, 237)"
|
|
10134
10150
|
};
|
|
10135
10151
|
const muiTheme = {
|
|
10136
10152
|
dark: createTheme({
|
|
@@ -10144,6 +10160,9 @@ ${oldObj[prop][1]}`);
|
|
|
10144
10160
|
primaryBackgroundDim: "#333333",
|
|
10145
10161
|
primaryBackgroundLight: "#757575",
|
|
10146
10162
|
primaryForeground: "#D3D3D3",
|
|
10163
|
+
primaryForegroundL5: "rgb(224, 224, 224)",
|
|
10164
|
+
primaryForegroundL10: "rgb(237, 237, 237)",
|
|
10165
|
+
primaryForegroundD15: "rgb(173, 173, 173)",
|
|
10147
10166
|
primaryForegroundDim: "#000000",
|
|
10148
10167
|
primaryForegroundActive: "#9bb7d6",
|
|
10149
10168
|
secondaryBackground: "#000000",
|
|
@@ -10170,6 +10189,9 @@ ${oldObj[prop][1]}`);
|
|
|
10170
10189
|
primaryBackgroundDim: "#8A8A8A",
|
|
10171
10190
|
primaryBackgroundLight: "#e0e0e0",
|
|
10172
10191
|
primaryForeground: "#333333",
|
|
10192
|
+
primaryForegroundL5: "rgb(64, 64, 64)",
|
|
10193
|
+
primaryForegroundL10: "rgb(77, 77, 77)",
|
|
10194
|
+
primaryForegroundD15: "rgb(13, 13, 13)",
|
|
10173
10195
|
primaryForegroundDim: "#808080",
|
|
10174
10196
|
primaryForegroundActive: "#0074D9",
|
|
10175
10197
|
secondaryBackground: "#F1F1F1",
|
|
@@ -10442,13 +10464,10 @@ ${oldObj[prop][1]}`);
|
|
|
10442
10464
|
};
|
|
10443
10465
|
}),
|
|
10444
10466
|
changeLayout: (newComponentProps) => set2((state) => {
|
|
10445
|
-
const newLayout = state.viewConfig.layout.slice()
|
|
10446
|
-
|
|
10447
|
-
|
|
10448
|
-
|
|
10449
|
-
...newProps
|
|
10450
|
-
};
|
|
10451
|
-
});
|
|
10467
|
+
const newLayout = state.viewConfig.layout.slice().map((componentProps) => ({
|
|
10468
|
+
...componentProps,
|
|
10469
|
+
...newComponentProps[componentProps.uid]
|
|
10470
|
+
}));
|
|
10452
10471
|
return {
|
|
10453
10472
|
viewConfig: {
|
|
10454
10473
|
...state.viewConfig,
|
|
@@ -15188,7 +15207,6 @@ ${oldObj[prop][1]}`);
|
|
|
15188
15207
|
module3.exports.Responsive.utils = responsiveUtils;
|
|
15189
15208
|
module3.exports.WidthProvider = WidthProvider.default;
|
|
15190
15209
|
})(reactGridLayoutWithLodash);
|
|
15191
|
-
const COMPONENT_ID_PREFIX = "i";
|
|
15192
15210
|
function sum$7(a2) {
|
|
15193
15211
|
return a2.reduce((x2, y2) => x2 + y2, 0);
|
|
15194
15212
|
}
|
|
@@ -15275,12 +15293,11 @@ ${oldObj[prop][1]}`);
|
|
|
15275
15293
|
const [lastValidGridLayouts, setLastValidGridLayouts] = React$i.useState(gridLayouts);
|
|
15276
15294
|
const onValidLayoutChange = (newLayout) => {
|
|
15277
15295
|
if (newLayout.length === Object.entries(gridComponents).length) {
|
|
15278
|
-
const newComponentProps =
|
|
15296
|
+
const newComponentProps = {};
|
|
15279
15297
|
newLayout.forEach((nextC) => {
|
|
15280
15298
|
const id2 = nextC.i;
|
|
15281
15299
|
const prevC = gridComponents[id2];
|
|
15282
15300
|
if (prevC) {
|
|
15283
|
-
const i2 = parseInt(id2.substring(id2.indexOf(COMPONENT_ID_PREFIX) + 1), 10);
|
|
15284
15301
|
const nextProps = {
|
|
15285
15302
|
x: nextC.x,
|
|
15286
15303
|
y: nextC.y,
|
|
@@ -15294,11 +15311,11 @@ ${oldObj[prop][1]}`);
|
|
|
15294
15311
|
h: prevC.h
|
|
15295
15312
|
};
|
|
15296
15313
|
if (!isEqual_1(nextProps, prevProps)) {
|
|
15297
|
-
newComponentProps
|
|
15314
|
+
newComponentProps[id2] = nextProps;
|
|
15298
15315
|
}
|
|
15299
15316
|
}
|
|
15300
15317
|
});
|
|
15301
|
-
if (newComponentProps.length > 0) {
|
|
15318
|
+
if (Object.keys(newComponentProps).length > 0) {
|
|
15302
15319
|
onLayoutChangeProp(newComponentProps);
|
|
15303
15320
|
}
|
|
15304
15321
|
}
|
|
@@ -27738,7 +27755,10 @@ After: ${JSON.stringify(coordinationValuesWithDefaults)}`);
|
|
|
27738
27755
|
const removeComponent = useRemoveComponent();
|
|
27739
27756
|
const changeLayout = useChangeLayout();
|
|
27740
27757
|
const layout = useLayout();
|
|
27741
|
-
const changeLayoutPostMount = React$i.useCallback(() =>
|
|
27758
|
+
const changeLayoutPostMount = React$i.useCallback((newComponentProps) => {
|
|
27759
|
+
if (componentWidth > 0) {
|
|
27760
|
+
changeLayout(newComponentProps);
|
|
27761
|
+
}
|
|
27742
27762
|
}, [changeLayout, componentWidth]);
|
|
27743
27763
|
React$i.useEffect(() => {
|
|
27744
27764
|
if (config2) {
|
|
@@ -49860,12 +49880,11 @@ If these are plugin file types, ensure that they have been properly registered.`
|
|
|
49860
49880
|
} while (upgradeFunction);
|
|
49861
49881
|
return [nextConfig, true];
|
|
49862
49882
|
}
|
|
49863
|
-
const packageJson$1 = { version: "unk" };
|
|
49864
49883
|
const generateClassName = createGenerateClassName({
|
|
49865
49884
|
disableGlobal: true
|
|
49866
49885
|
});
|
|
49867
49886
|
function logConfig(config2, name2) {
|
|
49868
|
-
console.groupCollapsed(`\u{1F684} Vitessce (${
|
|
49887
|
+
console.groupCollapsed(`\u{1F684} Vitessce (${META_VERSION.version}) ${name2}`);
|
|
49869
49888
|
console.info(`data:,${JSON.stringify(config2)}`);
|
|
49870
49889
|
console.info(JSON.stringify(config2, null, 2));
|
|
49871
49890
|
console.groupEnd();
|
|
@@ -64049,7 +64068,7 @@ If these are plugin file types, ensure that they have been properly registered.`
|
|
|
64049
64068
|
module3.exports = reactJsxDevRuntime_development;
|
|
64050
64069
|
}
|
|
64051
64070
|
})(jsxDevRuntime);
|
|
64052
|
-
var _jsxFileName$1 = "/
|
|
64071
|
+
var _jsxFileName$1 = "/home/runner/work/vitessce/vitessce/node_modules/.pnpm/rc-tree@2.1.0_biqbaboplfbrettd7655fr4n2y/node_modules/rc-tree/es/util.js";
|
|
64053
64072
|
var DRAG_SIDE_RANGE = 0.25;
|
|
64054
64073
|
var DRAG_MIN_GAP = 2;
|
|
64055
64074
|
var onlyTreeNodeWarned = false;
|
|
@@ -71801,7 +71820,7 @@ If these are plugin file types, ensure that they have been properly registered.`
|
|
|
71801
71820
|
cursor: "pointer",
|
|
71802
71821
|
border: "0",
|
|
71803
71822
|
backgroundColor: "transparent",
|
|
71804
|
-
color: theme.palette.
|
|
71823
|
+
color: theme.palette.grayDarkL5,
|
|
71805
71824
|
"&[disabled]": {
|
|
71806
71825
|
pointerEvents: "none",
|
|
71807
71826
|
"& svg": {
|
|
@@ -71815,8 +71834,8 @@ If these are plugin file types, ensure that they have been properly registered.`
|
|
|
71815
71834
|
marginTop: "1px"
|
|
71816
71835
|
},
|
|
71817
71836
|
"&:hover,:hover path": {
|
|
71818
|
-
color: theme.palette.
|
|
71819
|
-
fill: theme.palette.
|
|
71837
|
+
color: theme.palette.grayDarkD15,
|
|
71838
|
+
fill: theme.palette.grayDarkD15
|
|
71820
71839
|
}
|
|
71821
71840
|
}
|
|
71822
71841
|
},
|
|
@@ -71835,7 +71854,7 @@ If these are plugin file types, ensure that they have been properly registered.`
|
|
|
71835
71854
|
border: "1px solid transparent"
|
|
71836
71855
|
},
|
|
71837
71856
|
"@global .level-0-treenode > .rc-tree-switcher i svg path": {
|
|
71838
|
-
fill: theme.palette.
|
|
71857
|
+
fill: theme.palette.primaryForegroundL5
|
|
71839
71858
|
},
|
|
71840
71859
|
"@global .rc-tree-focused:not(.rc-tree-active-focused)": {
|
|
71841
71860
|
borderColor: "cyan"
|
|
@@ -71996,7 +72015,7 @@ If these are plugin file types, ensure that they have been properly registered.`
|
|
|
71996
72015
|
plusButton: {
|
|
71997
72016
|
border: "0",
|
|
71998
72017
|
backgroundColor: "transparent",
|
|
71999
|
-
color: theme.palette.
|
|
72018
|
+
color: theme.palette.primaryForegroundL5,
|
|
72000
72019
|
padding: "0",
|
|
72001
72020
|
fontSize: "18px",
|
|
72002
72021
|
marginBottom: "2rem",
|
|
@@ -72011,12 +72030,12 @@ If these are plugin file types, ensure that they have been properly registered.`
|
|
|
72011
72030
|
width: `${nodeHeight}px`,
|
|
72012
72031
|
top: "5.5px",
|
|
72013
72032
|
"&:hover": {
|
|
72014
|
-
fill: theme.palette.
|
|
72033
|
+
fill: theme.palette.grayMidL10
|
|
72015
72034
|
}
|
|
72016
72035
|
},
|
|
72017
72036
|
nodeSizeLabel: {
|
|
72018
72037
|
fontSize: "12px",
|
|
72019
|
-
color: theme.palette.
|
|
72038
|
+
color: theme.palette.primaryForegroundD15
|
|
72020
72039
|
},
|
|
72021
72040
|
levelButtonsContainer: {
|
|
72022
72041
|
height: "20px",
|
|
@@ -72032,8 +72051,8 @@ If these are plugin file types, ensure that they have been properly registered.`
|
|
|
72032
72051
|
height: "12px",
|
|
72033
72052
|
padding: "5px",
|
|
72034
72053
|
backgroundClip: "content-box",
|
|
72035
|
-
border: `2px solid ${theme.palette.
|
|
72036
|
-
backgroundColor: theme.palette.
|
|
72054
|
+
border: `2px solid ${theme.palette.primaryForegroundL10}`,
|
|
72055
|
+
backgroundColor: theme.palette.primaryForegroundL10,
|
|
72037
72056
|
borderRadius: "6px",
|
|
72038
72057
|
position: "relative",
|
|
72039
72058
|
top: "3px",
|
|
@@ -72053,7 +72072,7 @@ If these are plugin file types, ensure that they have been properly registered.`
|
|
|
72053
72072
|
height: `${nodeHeight - 8}px`,
|
|
72054
72073
|
lineHeight: `${nodeHeight - 8}px`,
|
|
72055
72074
|
border: "1px solid transparent",
|
|
72056
|
-
color: theme.palette.
|
|
72075
|
+
color: theme.palette.primaryForegroundL5,
|
|
72057
72076
|
background: "transparent",
|
|
72058
72077
|
backgroundColor: "transparent",
|
|
72059
72078
|
verticalAlign: "top",
|
|
@@ -72096,8 +72115,8 @@ If these are plugin file types, ensure that they have been properly registered.`
|
|
|
72096
72115
|
margin: 0,
|
|
72097
72116
|
padding: 0,
|
|
72098
72117
|
"&:hover": {
|
|
72099
|
-
backgroundColor: theme.palette.
|
|
72100
|
-
border: `1px solid ${theme.palette.
|
|
72118
|
+
backgroundColor: theme.palette.grayDarkL5,
|
|
72119
|
+
border: `1px solid ${theme.palette.grayDarkL5}`
|
|
72101
72120
|
}
|
|
72102
72121
|
},
|
|
72103
72122
|
"@global .vitessce-tooltip .ant-tooltip-content .ant-tooltip-inner": {
|
|
@@ -72247,7 +72266,7 @@ If these are plugin file types, ensure that they have been properly registered.`
|
|
|
72247
72266
|
backgroundColor: "transparent",
|
|
72248
72267
|
borderRadius: "2px",
|
|
72249
72268
|
"&:hover": {
|
|
72250
|
-
backgroundColor: theme.palette.
|
|
72269
|
+
backgroundColor: theme.palette.grayLightL10
|
|
72251
72270
|
}
|
|
72252
72271
|
},
|
|
72253
72272
|
"& li:not(:last-child)": {
|
|
@@ -72304,7 +72323,7 @@ If these are plugin file types, ensure that they have been properly registered.`
|
|
|
72304
72323
|
mouseLeaveDelay: 0,
|
|
72305
72324
|
destroyTooltipOnHide: true
|
|
72306
72325
|
};
|
|
72307
|
-
var _jsxFileName = "/
|
|
72326
|
+
var _jsxFileName = "/home/runner/work/vitessce/vitessce/node_modules/.pnpm/react-color-with-lodash@2.19.5_react@18.2.0/node_modules/react-color-with-lodash/dist/index.mjs";
|
|
72308
72327
|
var __defProp2 = Object.defineProperty;
|
|
72309
72328
|
var __defNormalProp2 = (obj, key2, value2) => key2 in obj ? __defProp2(obj, key2, {
|
|
72310
72329
|
enumerable: true,
|
|
@@ -193664,390 +193683,1541 @@ void main() {
|
|
|
193664
193683
|
}
|
|
193665
193684
|
BitmaskLayer.layerName = "BitmaskLayer";
|
|
193666
193685
|
BitmaskLayer.defaultProps = defaultProps;
|
|
193667
|
-
|
|
193668
|
-
|
|
193669
|
-
|
|
193670
|
-
|
|
193671
|
-
|
|
193672
|
-
|
|
193673
|
-
|
|
193674
|
-
|
|
193675
|
-
|
|
193676
|
-
|
|
193677
|
-
|
|
193678
|
-
|
|
193679
|
-
|
|
193680
|
-
|
|
193686
|
+
const useStyles$8 = makeStyles(() => ({
|
|
193687
|
+
tool: {
|
|
193688
|
+
position: "absolute",
|
|
193689
|
+
display: "inline",
|
|
193690
|
+
zIndex: "1000",
|
|
193691
|
+
opacity: ".65",
|
|
193692
|
+
color: "black",
|
|
193693
|
+
"&:hover": {
|
|
193694
|
+
opacity: ".90"
|
|
193695
|
+
}
|
|
193696
|
+
},
|
|
193697
|
+
iconButton: {
|
|
193698
|
+
padding: "0",
|
|
193699
|
+
height: "2em",
|
|
193700
|
+
width: "2em",
|
|
193701
|
+
backgroundColor: "white",
|
|
193702
|
+
display: "inline-block",
|
|
193703
|
+
fontWeight: "400",
|
|
193704
|
+
textAlign: "center",
|
|
193705
|
+
verticalAlign: "middle",
|
|
193706
|
+
cursor: "pointer",
|
|
193707
|
+
userSelect: "none",
|
|
193708
|
+
border: "1px solid #6c757d",
|
|
193709
|
+
fontSize: "1rem",
|
|
193710
|
+
lineHeight: "1.5",
|
|
193711
|
+
borderRadius: "0.25rem",
|
|
193712
|
+
transition: "color 0.15s ease-in-out, background-color 0.15s ease-in-out, border-color 0.15s ease-in-out, box-shadow 0.15s ease-in-out",
|
|
193713
|
+
color: "#6c757d",
|
|
193714
|
+
marginRight: "0.5rem",
|
|
193715
|
+
"& > svg": {
|
|
193716
|
+
verticalAlign: "middle"
|
|
193717
|
+
}
|
|
193718
|
+
},
|
|
193719
|
+
iconButtonActive: {
|
|
193720
|
+
color: "#fff",
|
|
193721
|
+
backgroundColor: "#6c757d",
|
|
193722
|
+
borderColor: "#6c757d",
|
|
193723
|
+
boxShadow: "0 0 0 0.2rem rgba(108, 117, 125, 0.5)"
|
|
193724
|
+
}
|
|
193725
|
+
}));
|
|
193726
|
+
function IconButton(props2) {
|
|
193727
|
+
const { alt, onClick, isActive: isActive2, children: children2 } = props2;
|
|
193728
|
+
const classes = useStyles$8();
|
|
193729
|
+
return jsx("button", { className: clsx(classes.iconButton, { [classes.iconButtonActive]: isActive2 }), onClick, type: "button", title: alt, children: children2 });
|
|
193730
|
+
}
|
|
193731
|
+
function ToolMenu(props2) {
|
|
193732
|
+
const { setActiveTool, activeTool, visibleTools = { pan: true, selectRectangle: true, selectLasso: true } } = props2;
|
|
193733
|
+
const classes = useStyles$8();
|
|
193734
|
+
return jsxs("div", { className: classes.tool, children: [visibleTools.pan && jsx(IconButton, { alt: "pointer tool", onClick: () => setActiveTool(null), isActive: activeTool === null, children: jsx(SvgNearMe, {}) }), visibleTools.selectRectangle ? jsx(IconButton, { alt: "select rectangle", onClick: () => setActiveTool(distEs6$2.SELECTION_TYPE.RECTANGLE), isActive: activeTool === distEs6$2.SELECTION_TYPE.RECTANGLE, children: jsx(SvgSelectionRectangle, {}) }) : null, visibleTools.selectLasso ? jsx(IconButton, { alt: "select lasso", onClick: () => setActiveTool(distEs6$2.SELECTION_TYPE.POLYGON), isActive: activeTool === distEs6$2.SELECTION_TYPE.POLYGON, children: jsx(SvgSelectionLasso, {}) }) : null] });
|
|
193735
|
+
}
|
|
193736
|
+
const getCursorWithTool = () => "crosshair";
|
|
193737
|
+
const getCursor = (interactionState) => interactionState.isDragging ? "grabbing" : "default";
|
|
193738
|
+
function getOnHoverCallback(obsIndex, setObsHighlight, setComponentHover) {
|
|
193739
|
+
return (info2) => {
|
|
193740
|
+
if (setComponentHover) {
|
|
193741
|
+
setComponentHover();
|
|
193742
|
+
}
|
|
193743
|
+
if (info2.index) {
|
|
193744
|
+
const obsId = obsIndex[info2.index];
|
|
193745
|
+
if (setObsHighlight) {
|
|
193746
|
+
setObsHighlight(obsId);
|
|
193747
|
+
}
|
|
193748
|
+
} else if (setObsHighlight) {
|
|
193749
|
+
setObsHighlight(null);
|
|
193750
|
+
}
|
|
193751
|
+
};
|
|
193752
|
+
}
|
|
193753
|
+
class AbstractSpatialOrScatterplot extends React$i.PureComponent {
|
|
193754
|
+
constructor(props2) {
|
|
193755
|
+
super(props2);
|
|
193756
|
+
this.state = {
|
|
193757
|
+
gl: null,
|
|
193758
|
+
tool: null
|
|
193759
|
+
};
|
|
193760
|
+
this.viewport = null;
|
|
193761
|
+
this.onViewStateChange = this.onViewStateChange.bind(this);
|
|
193762
|
+
this.onInitializeViewInfo = this.onInitializeViewInfo.bind(this);
|
|
193763
|
+
this.onWebGLInitialized = this.onWebGLInitialized.bind(this);
|
|
193764
|
+
this.onToolChange = this.onToolChange.bind(this);
|
|
193765
|
+
this.onHover = this.onHover.bind(this);
|
|
193766
|
+
}
|
|
193767
|
+
onViewStateChange({ viewState: nextViewState }) {
|
|
193768
|
+
const { setViewState, viewState, layers, spatialAxisFixed } = this.props;
|
|
193769
|
+
const use3d = layers == null ? void 0 : layers.some((l2) => l2.use3d);
|
|
193770
|
+
setViewState({
|
|
193771
|
+
...nextViewState,
|
|
193772
|
+
target: spatialAxisFixed && use3d ? viewState.target : nextViewState.target
|
|
193773
|
+
});
|
|
193774
|
+
}
|
|
193775
|
+
onInitializeViewInfo({ viewport }) {
|
|
193776
|
+
this.viewport = viewport;
|
|
193777
|
+
}
|
|
193778
|
+
onWebGLInitialized(gl) {
|
|
193779
|
+
this.setState({ gl });
|
|
193780
|
+
}
|
|
193781
|
+
onToolChange(tool) {
|
|
193782
|
+
const { onToolChange: onToolChangeProp } = this.props;
|
|
193783
|
+
this.setState({ tool });
|
|
193784
|
+
if (onToolChangeProp) {
|
|
193785
|
+
onToolChangeProp(tool);
|
|
193786
|
+
}
|
|
193787
|
+
}
|
|
193788
|
+
getLayers() {
|
|
193789
|
+
return [];
|
|
193790
|
+
}
|
|
193791
|
+
onHover(info2) {
|
|
193792
|
+
const { coordinate, sourceLayer: layer, tile } = info2;
|
|
193793
|
+
const { setCellHighlight, cellHighlight, setComponentHover, layers } = this.props;
|
|
193794
|
+
const hasBitmask = (layers || []).some((l2) => l2.type === "bitmask");
|
|
193795
|
+
if (!setCellHighlight || !tile) {
|
|
193796
|
+
return null;
|
|
193797
|
+
}
|
|
193798
|
+
if (!layer || !coordinate) {
|
|
193799
|
+
if (cellHighlight && hasBitmask) {
|
|
193800
|
+
setCellHighlight(null);
|
|
193801
|
+
}
|
|
193802
|
+
return null;
|
|
193803
|
+
}
|
|
193804
|
+
const { content: content2, bbox: bbox2, z } = tile;
|
|
193805
|
+
if (!content2) {
|
|
193806
|
+
if (cellHighlight && hasBitmask) {
|
|
193807
|
+
setCellHighlight(null);
|
|
193808
|
+
}
|
|
193809
|
+
return null;
|
|
193810
|
+
}
|
|
193811
|
+
const { data: data2, width: width2, height: height2 } = content2;
|
|
193812
|
+
const { left: left2, right: right2, top: top2, bottom: bottom2 } = bbox2;
|
|
193813
|
+
const bounds2 = [
|
|
193814
|
+
left2,
|
|
193815
|
+
data2.height < layer.tileSize ? height2 : bottom2,
|
|
193816
|
+
data2.width < layer.tileSize ? width2 : right2,
|
|
193817
|
+
top2
|
|
193818
|
+
];
|
|
193819
|
+
if (!data2) {
|
|
193820
|
+
if (cellHighlight && hasBitmask) {
|
|
193821
|
+
setCellHighlight(null);
|
|
193822
|
+
}
|
|
193823
|
+
return null;
|
|
193824
|
+
}
|
|
193825
|
+
if (layer.id.includes("bitmask")) {
|
|
193826
|
+
const layerZoomScale = Math.max(1, 2 ** Math.round(-z));
|
|
193827
|
+
const dataCoords = [
|
|
193828
|
+
Math.floor((coordinate[0] - bounds2[0]) / layerZoomScale),
|
|
193829
|
+
Math.floor((coordinate[1] - bounds2[3]) / layerZoomScale)
|
|
193830
|
+
];
|
|
193831
|
+
const coords = dataCoords[1] * width2 + dataCoords[0];
|
|
193832
|
+
const hoverData = data2.map((d) => d[coords]);
|
|
193833
|
+
const cellId = hoverData.find((i2) => i2 > 0);
|
|
193834
|
+
if (cellId !== Number(cellHighlight)) {
|
|
193835
|
+
if (setComponentHover) {
|
|
193836
|
+
setComponentHover();
|
|
193837
|
+
}
|
|
193838
|
+
setCellHighlight(cellId ? String(cellId) : null);
|
|
193839
|
+
}
|
|
193840
|
+
}
|
|
193841
|
+
}
|
|
193842
|
+
viewInfoDidUpdate(obsIndex, obsLocations, makeGetObsCoords) {
|
|
193843
|
+
const { updateViewInfo, uuid } = this.props;
|
|
193844
|
+
const { viewport } = this;
|
|
193845
|
+
if (updateViewInfo && viewport) {
|
|
193846
|
+
updateViewInfo({
|
|
193847
|
+
uuid,
|
|
193848
|
+
project: (obsId) => {
|
|
193849
|
+
try {
|
|
193850
|
+
if (obsIndex && obsLocations) {
|
|
193851
|
+
const getObsCoords = makeGetObsCoords(obsLocations);
|
|
193852
|
+
const obsIdx = obsIndex.indexOf(obsId);
|
|
193853
|
+
const obsCoord = getObsCoords(obsIdx);
|
|
193854
|
+
return viewport.project(obsCoord);
|
|
193681
193855
|
}
|
|
193856
|
+
return [null, null];
|
|
193857
|
+
} catch (e3) {
|
|
193858
|
+
return [null, null];
|
|
193682
193859
|
}
|
|
193683
193860
|
}
|
|
193684
|
-
|
|
193685
|
-
}, module3.exports.__esModule = true, module3.exports["default"] = module3.exports;
|
|
193686
|
-
return _extends2.apply(this, arguments);
|
|
193861
|
+
});
|
|
193687
193862
|
}
|
|
193688
|
-
module3.exports = _extends2, module3.exports.__esModule = true, module3.exports["default"] = module3.exports;
|
|
193689
|
-
})(_extends$1);
|
|
193690
|
-
return _extends$1.exports;
|
|
193691
|
-
}
|
|
193692
|
-
var _extendsExports = require_extends();
|
|
193693
|
-
var DEFAULT_CONFIG = {
|
|
193694
|
-
epsilon: 1e-12,
|
|
193695
|
-
matrix: "Matrix",
|
|
193696
|
-
number: "number",
|
|
193697
|
-
precision: 64,
|
|
193698
|
-
predictable: false,
|
|
193699
|
-
randomSeed: null
|
|
193700
|
-
};
|
|
193701
|
-
function isNumber$2(x2) {
|
|
193702
|
-
return typeof x2 === "number";
|
|
193703
|
-
}
|
|
193704
|
-
function isBigNumber(x2) {
|
|
193705
|
-
if (!x2 || typeof x2 !== "object" || typeof x2.constructor !== "function") {
|
|
193706
|
-
return false;
|
|
193707
193863
|
}
|
|
193708
|
-
|
|
193709
|
-
return true;
|
|
193864
|
+
componentDidUpdate() {
|
|
193710
193865
|
}
|
|
193711
|
-
|
|
193712
|
-
return
|
|
193866
|
+
use3d() {
|
|
193867
|
+
return false;
|
|
193868
|
+
}
|
|
193869
|
+
render() {
|
|
193870
|
+
var _a3, _b2, _c, _d;
|
|
193871
|
+
const { deckRef, viewState, uuid, hideTools } = this.props;
|
|
193872
|
+
const { gl, tool } = this.state;
|
|
193873
|
+
const layers = this.getLayers();
|
|
193874
|
+
const use3d = this.use3d();
|
|
193875
|
+
const showCellSelectionTools = this.obsSegmentationsData !== null;
|
|
193876
|
+
const showPanTool = layers.length > 0;
|
|
193877
|
+
const useDevicePixels = !use3d && (((_b2 = (_a3 = this.obsSegmentationsData) == null ? void 0 : _a3.shape) == null ? void 0 : _b2[0]) < 1e5 || ((_d = (_c = this.obsLocationsData) == null ? void 0 : _c.shape) == null ? void 0 : _d[1]) < 1e5);
|
|
193878
|
+
return jsxs(Fragment, { children: [jsx(ToolMenu, { activeTool: tool, setActiveTool: this.onToolChange, visibleTools: {
|
|
193879
|
+
pan: showPanTool && !hideTools,
|
|
193880
|
+
selectRectangle: showCellSelectionTools && !hideTools,
|
|
193881
|
+
selectLasso: showCellSelectionTools && !hideTools
|
|
193882
|
+
} }), jsx(DeckGL$1, { id: `deckgl-overlay-${uuid}`, ref: deckRef, views: [
|
|
193883
|
+
use3d ? new OrbitView({ id: "orbit", controller: true, orbitAxis: "Y" }) : new OrthographicView({
|
|
193884
|
+
id: "ortho"
|
|
193885
|
+
})
|
|
193886
|
+
], layers: gl && viewState.target.slice(0, 2).every((i2) => typeof i2 === "number") ? layers : [], glOptions: DEFAULT_GL_OPTIONS, onWebGLInitialized: this.onWebGLInitialized, onViewStateChange: this.onViewStateChange, viewState, useDevicePixels, controller: tool ? { dragPan: false } : true, getCursor: tool ? getCursorWithTool : getCursor, onHover: this.onHover, children: this.onInitializeViewInfo })] });
|
|
193713
193887
|
}
|
|
193714
|
-
return false;
|
|
193715
|
-
}
|
|
193716
|
-
function isComplex(x2) {
|
|
193717
|
-
return x2 && typeof x2 === "object" && Object.getPrototypeOf(x2).isComplex === true || false;
|
|
193718
|
-
}
|
|
193719
|
-
function isFraction(x2) {
|
|
193720
|
-
return x2 && typeof x2 === "object" && Object.getPrototypeOf(x2).isFraction === true || false;
|
|
193721
|
-
}
|
|
193722
|
-
function isUnit(x2) {
|
|
193723
|
-
return x2 && x2.constructor.prototype.isUnit === true || false;
|
|
193724
|
-
}
|
|
193725
|
-
function isString$1(x2) {
|
|
193726
|
-
return typeof x2 === "string";
|
|
193727
|
-
}
|
|
193728
|
-
var isArray$1 = Array.isArray;
|
|
193729
|
-
function isMatrix(x2) {
|
|
193730
|
-
return x2 && x2.constructor.prototype.isMatrix === true || false;
|
|
193731
|
-
}
|
|
193732
|
-
function isCollection(x2) {
|
|
193733
|
-
return Array.isArray(x2) || isMatrix(x2);
|
|
193734
|
-
}
|
|
193735
|
-
function isDenseMatrix(x2) {
|
|
193736
|
-
return x2 && x2.isDenseMatrix && x2.constructor.prototype.isMatrix === true || false;
|
|
193737
|
-
}
|
|
193738
|
-
function isSparseMatrix(x2) {
|
|
193739
|
-
return x2 && x2.isSparseMatrix && x2.constructor.prototype.isMatrix === true || false;
|
|
193740
|
-
}
|
|
193741
|
-
function isRange(x2) {
|
|
193742
|
-
return x2 && x2.constructor.prototype.isRange === true || false;
|
|
193743
|
-
}
|
|
193744
|
-
function isIndex(x2) {
|
|
193745
|
-
return x2 && x2.constructor.prototype.isIndex === true || false;
|
|
193746
|
-
}
|
|
193747
|
-
function isBoolean$3(x2) {
|
|
193748
|
-
return typeof x2 === "boolean";
|
|
193749
|
-
}
|
|
193750
|
-
function isResultSet(x2) {
|
|
193751
|
-
return x2 && x2.constructor.prototype.isResultSet === true || false;
|
|
193752
|
-
}
|
|
193753
|
-
function isHelp(x2) {
|
|
193754
|
-
return x2 && x2.constructor.prototype.isHelp === true || false;
|
|
193755
|
-
}
|
|
193756
|
-
function isFunction$2(x2) {
|
|
193757
|
-
return typeof x2 === "function";
|
|
193758
|
-
}
|
|
193759
|
-
function isDate$2(x2) {
|
|
193760
|
-
return x2 instanceof Date;
|
|
193761
|
-
}
|
|
193762
|
-
function isRegExp$1(x2) {
|
|
193763
|
-
return x2 instanceof RegExp;
|
|
193764
|
-
}
|
|
193765
|
-
function isObject$1(x2) {
|
|
193766
|
-
return !!(x2 && typeof x2 === "object" && x2.constructor === Object && !isComplex(x2) && !isFraction(x2));
|
|
193767
|
-
}
|
|
193768
|
-
function isNull(x2) {
|
|
193769
|
-
return x2 === null;
|
|
193770
|
-
}
|
|
193771
|
-
function isUndefined(x2) {
|
|
193772
|
-
return x2 === void 0;
|
|
193773
|
-
}
|
|
193774
|
-
function isAccessorNode(x2) {
|
|
193775
|
-
return x2 && x2.isAccessorNode === true && x2.constructor.prototype.isNode === true || false;
|
|
193776
|
-
}
|
|
193777
|
-
function isArrayNode(x2) {
|
|
193778
|
-
return x2 && x2.isArrayNode === true && x2.constructor.prototype.isNode === true || false;
|
|
193779
|
-
}
|
|
193780
|
-
function isAssignmentNode(x2) {
|
|
193781
|
-
return x2 && x2.isAssignmentNode === true && x2.constructor.prototype.isNode === true || false;
|
|
193782
|
-
}
|
|
193783
|
-
function isBlockNode(x2) {
|
|
193784
|
-
return x2 && x2.isBlockNode === true && x2.constructor.prototype.isNode === true || false;
|
|
193785
|
-
}
|
|
193786
|
-
function isConditionalNode(x2) {
|
|
193787
|
-
return x2 && x2.isConditionalNode === true && x2.constructor.prototype.isNode === true || false;
|
|
193788
|
-
}
|
|
193789
|
-
function isConstantNode(x2) {
|
|
193790
|
-
return x2 && x2.isConstantNode === true && x2.constructor.prototype.isNode === true || false;
|
|
193791
|
-
}
|
|
193792
|
-
function isFunctionAssignmentNode(x2) {
|
|
193793
|
-
return x2 && x2.isFunctionAssignmentNode === true && x2.constructor.prototype.isNode === true || false;
|
|
193794
|
-
}
|
|
193795
|
-
function isFunctionNode(x2) {
|
|
193796
|
-
return x2 && x2.isFunctionNode === true && x2.constructor.prototype.isNode === true || false;
|
|
193797
|
-
}
|
|
193798
|
-
function isIndexNode(x2) {
|
|
193799
|
-
return x2 && x2.isIndexNode === true && x2.constructor.prototype.isNode === true || false;
|
|
193800
193888
|
}
|
|
193801
|
-
function
|
|
193802
|
-
|
|
193889
|
+
function createQuadTree(obsEmbedding, getCellCoords) {
|
|
193890
|
+
if (!obsEmbedding) {
|
|
193891
|
+
return null;
|
|
193892
|
+
}
|
|
193893
|
+
const tree2 = quadtree$1().x((i2) => getCellCoords(i2)[0]).y((i2) => getCellCoords(i2)[1]).addAll(range_1(obsEmbedding.shape[1]));
|
|
193894
|
+
return tree2;
|
|
193803
193895
|
}
|
|
193804
|
-
function
|
|
193805
|
-
return
|
|
193896
|
+
function constant$5(v) {
|
|
193897
|
+
return () => v;
|
|
193806
193898
|
}
|
|
193807
|
-
function
|
|
193808
|
-
return
|
|
193899
|
+
function jiggle$1(v) {
|
|
193900
|
+
return v + (Math.random() - 0.5) * 1e-6;
|
|
193809
193901
|
}
|
|
193810
|
-
function
|
|
193811
|
-
|
|
193902
|
+
function forceCollideRects() {
|
|
193903
|
+
let nodes;
|
|
193904
|
+
let masses;
|
|
193905
|
+
let strength = 1;
|
|
193906
|
+
let iterations2 = 1;
|
|
193907
|
+
let sizes;
|
|
193908
|
+
let size2 = constant$5([0, 0]);
|
|
193909
|
+
function xCenter(d) {
|
|
193910
|
+
return d.x + d.vx + sizes[d.index][0] / 2;
|
|
193911
|
+
}
|
|
193912
|
+
function yCenter(d) {
|
|
193913
|
+
return d.y + d.vy + sizes[d.index][1] / 2;
|
|
193914
|
+
}
|
|
193915
|
+
function prepare2(quad2) {
|
|
193916
|
+
if (quad2.data) {
|
|
193917
|
+
quad2.size = sizes[quad2.data.index];
|
|
193918
|
+
} else {
|
|
193919
|
+
quad2.size = [0, 0];
|
|
193920
|
+
for (let i2 = 0; i2 < 4; i2++) {
|
|
193921
|
+
if (quad2[i2] && quad2[i2].size) {
|
|
193922
|
+
quad2.size[0] = Math.max(quad2.size[0], quad2[i2].size[0]);
|
|
193923
|
+
quad2.size[1] = Math.max(quad2.size[1], quad2[i2].size[1]);
|
|
193924
|
+
}
|
|
193925
|
+
}
|
|
193926
|
+
}
|
|
193927
|
+
}
|
|
193928
|
+
function force2() {
|
|
193929
|
+
let node;
|
|
193930
|
+
let nodeSize;
|
|
193931
|
+
let nodeMass;
|
|
193932
|
+
let xi;
|
|
193933
|
+
let yi;
|
|
193934
|
+
const tree2 = quadtree$1(nodes, xCenter, yCenter).visitAfter(prepare2);
|
|
193935
|
+
function apply2(quad2, x02, y02, x12, y12) {
|
|
193936
|
+
const { data: data2 } = quad2;
|
|
193937
|
+
const xSize = (nodeSize[0] + quad2.size[0]) / 2;
|
|
193938
|
+
const ySize = (nodeSize[1] + quad2.size[1]) / 2;
|
|
193939
|
+
if (data2 && data2.index > node.index) {
|
|
193940
|
+
let x2 = jiggle$1(xi - xCenter(data2));
|
|
193941
|
+
let y2 = jiggle$1(yi - yCenter(data2));
|
|
193942
|
+
const xd = Math.abs(x2) - xSize;
|
|
193943
|
+
const yd = Math.abs(y2) - ySize;
|
|
193944
|
+
if (xd < 0 && yd < 0) {
|
|
193945
|
+
const l2 = Math.sqrt(x2 * x2 + y2 * y2);
|
|
193946
|
+
const m2 = masses[data2.index] / (nodeMass + masses[data2.index]);
|
|
193947
|
+
if (Math.abs(xd) < Math.abs(yd)) {
|
|
193948
|
+
node.vx -= (x2 *= xd / l2 * strength) * m2;
|
|
193949
|
+
data2.vx += x2 * (1 - m2);
|
|
193950
|
+
} else {
|
|
193951
|
+
node.vy -= (y2 *= yd / l2 * strength) * m2;
|
|
193952
|
+
data2.vy += y2 * (1 - m2);
|
|
193953
|
+
}
|
|
193954
|
+
}
|
|
193955
|
+
return x02 > xi + xSize || x12 < xi - xSize || y02 > yi + ySize || y12 < yi - ySize;
|
|
193956
|
+
}
|
|
193957
|
+
return false;
|
|
193958
|
+
}
|
|
193959
|
+
function iterate2() {
|
|
193960
|
+
for (let j2 = 0; j2 < nodes.length; j2++) {
|
|
193961
|
+
node = nodes[j2];
|
|
193962
|
+
nodeSize = sizes[j2];
|
|
193963
|
+
nodeMass = masses[j2];
|
|
193964
|
+
xi = xCenter(node);
|
|
193965
|
+
yi = yCenter(node);
|
|
193966
|
+
tree2.visit(apply2);
|
|
193967
|
+
}
|
|
193968
|
+
}
|
|
193969
|
+
for (let i2 = 0; i2 < iterations2; i2++) {
|
|
193970
|
+
iterate2();
|
|
193971
|
+
}
|
|
193972
|
+
}
|
|
193973
|
+
force2.initialize = (v) => {
|
|
193974
|
+
nodes = v;
|
|
193975
|
+
sizes = nodes.map(size2);
|
|
193976
|
+
masses = sizes.map((d) => d[0] + d[1]);
|
|
193977
|
+
};
|
|
193978
|
+
force2.iterations = (...v) => {
|
|
193979
|
+
if (v.length) {
|
|
193980
|
+
iterations2 = +v[0];
|
|
193981
|
+
return force2;
|
|
193982
|
+
}
|
|
193983
|
+
return iterations2;
|
|
193984
|
+
};
|
|
193985
|
+
force2.strength = (...v) => {
|
|
193986
|
+
if (v.length) {
|
|
193987
|
+
strength = +v[0];
|
|
193988
|
+
return force2;
|
|
193989
|
+
}
|
|
193990
|
+
return strength;
|
|
193991
|
+
};
|
|
193992
|
+
force2.size = (...v) => {
|
|
193993
|
+
if (v.length) {
|
|
193994
|
+
size2 = typeof v[0] === "function" ? v[0] : constant$5(v[0]);
|
|
193995
|
+
return force2;
|
|
193996
|
+
}
|
|
193997
|
+
return size2;
|
|
193998
|
+
};
|
|
193999
|
+
return force2;
|
|
193812
194000
|
}
|
|
193813
|
-
function
|
|
193814
|
-
|
|
194001
|
+
function baseClamp$1(number2, lower, upper) {
|
|
194002
|
+
if (number2 === number2) {
|
|
194003
|
+
if (upper !== void 0) {
|
|
194004
|
+
number2 = number2 <= upper ? number2 : upper;
|
|
194005
|
+
}
|
|
194006
|
+
if (lower !== void 0) {
|
|
194007
|
+
number2 = number2 >= lower ? number2 : lower;
|
|
194008
|
+
}
|
|
194009
|
+
}
|
|
194010
|
+
return number2;
|
|
193815
194011
|
}
|
|
193816
|
-
|
|
193817
|
-
|
|
194012
|
+
var _baseClamp = baseClamp$1;
|
|
194013
|
+
var baseClamp = _baseClamp, toNumber$1 = toNumber_1$1;
|
|
194014
|
+
function clamp$2(number2, lower, upper) {
|
|
194015
|
+
if (upper === void 0) {
|
|
194016
|
+
upper = lower;
|
|
194017
|
+
lower = void 0;
|
|
194018
|
+
}
|
|
194019
|
+
if (upper !== void 0) {
|
|
194020
|
+
upper = toNumber$1(upper);
|
|
194021
|
+
upper = upper === upper ? upper : 0;
|
|
194022
|
+
}
|
|
194023
|
+
if (lower !== void 0) {
|
|
194024
|
+
lower = toNumber$1(lower);
|
|
194025
|
+
lower = lower === lower ? lower : 0;
|
|
194026
|
+
}
|
|
194027
|
+
return baseClamp(toNumber$1(number2), lower, upper);
|
|
193818
194028
|
}
|
|
193819
|
-
|
|
193820
|
-
|
|
194029
|
+
var clamp_1 = clamp$2;
|
|
194030
|
+
function getPointSizeDevicePixels(devicePixelRatio2, zoom2, xRange, yRange, width2, height2) {
|
|
194031
|
+
const pointSize = 5e-4;
|
|
194032
|
+
const pointScreenSizeMax = 10;
|
|
194033
|
+
const pointScreenSizeMin = 1 / devicePixelRatio2;
|
|
194034
|
+
const scaleFactor = 2 ** zoom2;
|
|
194035
|
+
const xAxisRange = 2 / (xRange * scaleFactor / width2);
|
|
194036
|
+
const yAxisRange = 2 / (yRange * scaleFactor / height2);
|
|
194037
|
+
const diagonalScreenSize = Math.sqrt(width2 ** 2 + height2 ** 2);
|
|
194038
|
+
const diagonalAxisRange = Math.sqrt(xAxisRange ** 2 + yAxisRange ** 2);
|
|
194039
|
+
const diagonalFraction = pointSize / diagonalAxisRange;
|
|
194040
|
+
const deviceSize = diagonalFraction * diagonalScreenSize;
|
|
194041
|
+
const pointSizeDevicePixels = clamp_1(deviceSize, pointScreenSizeMin, pointScreenSizeMax);
|
|
194042
|
+
return pointSizeDevicePixels;
|
|
193821
194043
|
}
|
|
193822
|
-
function
|
|
193823
|
-
|
|
193824
|
-
|
|
193825
|
-
|
|
193826
|
-
|
|
193827
|
-
|
|
193828
|
-
|
|
193829
|
-
|
|
193830
|
-
|
|
193831
|
-
|
|
193832
|
-
|
|
193833
|
-
|
|
193834
|
-
|
|
193835
|
-
|
|
193836
|
-
|
|
193837
|
-
|
|
193838
|
-
return "Fraction";
|
|
193839
|
-
if (isMatrix(x2))
|
|
193840
|
-
return "Matrix";
|
|
193841
|
-
if (isUnit(x2))
|
|
193842
|
-
return "Unit";
|
|
193843
|
-
if (isIndex(x2))
|
|
193844
|
-
return "Index";
|
|
193845
|
-
if (isRange(x2))
|
|
193846
|
-
return "Range";
|
|
193847
|
-
if (isResultSet(x2))
|
|
193848
|
-
return "ResultSet";
|
|
193849
|
-
if (isNode(x2))
|
|
193850
|
-
return x2.type;
|
|
193851
|
-
if (isChain(x2))
|
|
193852
|
-
return "Chain";
|
|
193853
|
-
if (isHelp(x2))
|
|
193854
|
-
return "Help";
|
|
193855
|
-
return "Object";
|
|
194044
|
+
function getPointOpacity(zoom2, xRange, yRange, width2, height2, numCells, avgFillDensity) {
|
|
194045
|
+
const N2 = numCells;
|
|
194046
|
+
const [minX, minY, maxX, maxY2] = new OrthographicView({ zoom: zoom2 }).makeViewport({
|
|
194047
|
+
height: height2,
|
|
194048
|
+
width: width2,
|
|
194049
|
+
viewState: { zoom: zoom2, target: [0, 0, 0] }
|
|
194050
|
+
}).getBounds();
|
|
194051
|
+
const X3 = maxY2 - minY;
|
|
194052
|
+
const Y3 = maxX - minX;
|
|
194053
|
+
const X02 = xRange;
|
|
194054
|
+
const Y02 = yRange;
|
|
194055
|
+
const W = width2;
|
|
194056
|
+
const H = height2;
|
|
194057
|
+
let rho = avgFillDensity;
|
|
194058
|
+
if (!rho) {
|
|
194059
|
+
rho = Math.min(1, 1 / 10 ** (Math.log10(N2) - 3));
|
|
193856
194060
|
}
|
|
193857
|
-
|
|
193858
|
-
|
|
193859
|
-
return
|
|
194061
|
+
const alpha2 = rho * W * H / N2 * (Y02 / Y3) * (X02 / X3);
|
|
194062
|
+
const pointOpacity = clamp_1(alpha2, 1.01 / 255, 1);
|
|
194063
|
+
return pointOpacity;
|
|
193860
194064
|
}
|
|
193861
|
-
|
|
193862
|
-
|
|
193863
|
-
|
|
193864
|
-
|
|
193865
|
-
|
|
193866
|
-
|
|
193867
|
-
|
|
194065
|
+
const CELLS_LAYER_ID$1 = "scatterplot";
|
|
194066
|
+
const LABEL_FONT_FAMILY = "-apple-system, 'Helvetica Neue', Arial, sans-serif";
|
|
194067
|
+
const NUM_FORCE_SIMULATION_TICKS = 100;
|
|
194068
|
+
const LABEL_UPDATE_ZOOM_DELTA = 0.25;
|
|
194069
|
+
const makeDefaultGetCellColors$1 = (cellColors, obsIndex, theme) => (object2, { index: index2 }) => {
|
|
194070
|
+
const [r2, g2, b2, a2] = cellColors && obsIndex && cellColors.get(obsIndex[index2]) || getDefaultColor(theme);
|
|
194071
|
+
return [r2, g2, b2, 255 * (a2 || 1)];
|
|
194072
|
+
};
|
|
194073
|
+
const makeDefaultGetObsCoords$1 = (obsEmbedding) => (i2) => [
|
|
194074
|
+
obsEmbedding.data[0][i2],
|
|
194075
|
+
obsEmbedding.data[1][i2],
|
|
194076
|
+
0
|
|
194077
|
+
];
|
|
194078
|
+
const makeFlippedGetObsCoords = (obsEmbedding) => (i2) => [
|
|
194079
|
+
obsEmbedding.data[0][i2],
|
|
194080
|
+
-obsEmbedding.data[1][i2],
|
|
194081
|
+
0
|
|
194082
|
+
];
|
|
194083
|
+
const getPosition = (object2, { index: index2, data: data2, target: target2 }) => {
|
|
194084
|
+
target2[0] = data2.src.obsEmbedding.data[0][index2];
|
|
194085
|
+
target2[1] = -data2.src.obsEmbedding.data[1][index2];
|
|
194086
|
+
target2[2] = 0;
|
|
194087
|
+
return target2;
|
|
194088
|
+
};
|
|
194089
|
+
class Scatterplot extends AbstractSpatialOrScatterplot {
|
|
194090
|
+
constructor(props2) {
|
|
194091
|
+
super(props2);
|
|
194092
|
+
this.cellsQuadTree = null;
|
|
194093
|
+
this.cellsLayer = null;
|
|
194094
|
+
this.cellsData = null;
|
|
194095
|
+
this.cellSetsForceSimulation = forceCollideRects();
|
|
194096
|
+
this.cellSetsLabelPrevZoom = null;
|
|
194097
|
+
this.cellSetsLayers = [];
|
|
194098
|
+
this.onUpdateCellsData();
|
|
194099
|
+
this.onUpdateCellsLayer();
|
|
194100
|
+
this.onUpdateCellSetsLayers();
|
|
193868
194101
|
}
|
|
193869
|
-
|
|
193870
|
-
|
|
193871
|
-
|
|
194102
|
+
createCellsLayer() {
|
|
194103
|
+
const {
|
|
194104
|
+
obsEmbeddingIndex: obsIndex,
|
|
194105
|
+
theme,
|
|
194106
|
+
cellRadius = 1,
|
|
194107
|
+
cellOpacity = 1,
|
|
194108
|
+
cellSelection,
|
|
194109
|
+
setCellHighlight,
|
|
194110
|
+
setComponentHover,
|
|
194111
|
+
getCellIsSelected,
|
|
194112
|
+
cellColors,
|
|
194113
|
+
getCellColor = makeDefaultGetCellColors$1(cellColors, obsIndex, theme),
|
|
194114
|
+
getExpressionValue,
|
|
194115
|
+
onCellClick,
|
|
194116
|
+
geneExpressionColormap,
|
|
194117
|
+
geneExpressionColormapRange = [0, 1],
|
|
194118
|
+
cellColorEncoding
|
|
194119
|
+
} = this.props;
|
|
194120
|
+
return new ScatterplotLayer({
|
|
194121
|
+
id: CELLS_LAYER_ID$1,
|
|
194122
|
+
data: this.cellsData,
|
|
194123
|
+
coordinateSystem: COORDINATE_SYSTEM.CARTESIAN,
|
|
194124
|
+
visible: true,
|
|
194125
|
+
pickable: true,
|
|
194126
|
+
autoHighlight: true,
|
|
194127
|
+
filled: true,
|
|
194128
|
+
stroked: true,
|
|
194129
|
+
backgroundColor: theme === "dark" ? [0, 0, 0] : [241, 241, 241],
|
|
194130
|
+
getCellIsSelected,
|
|
194131
|
+
opacity: cellOpacity,
|
|
194132
|
+
radiusScale: cellRadius,
|
|
194133
|
+
radiusMinPixels: 1,
|
|
194134
|
+
radiusMaxPixels: 30,
|
|
194135
|
+
radiusUnits: "pixels",
|
|
194136
|
+
lineWidthUnits: "pixels",
|
|
194137
|
+
getPosition,
|
|
194138
|
+
getFillColor: getCellColor,
|
|
194139
|
+
getLineColor: getCellColor,
|
|
194140
|
+
getRadius: 1,
|
|
194141
|
+
getExpressionValue,
|
|
194142
|
+
getLineWidth: 0,
|
|
194143
|
+
extensions: [
|
|
194144
|
+
new ScaledExpressionExtension(),
|
|
194145
|
+
new SelectionExtension({ instanced: true })
|
|
194146
|
+
],
|
|
194147
|
+
colorScaleLo: geneExpressionColormapRange[0],
|
|
194148
|
+
colorScaleHi: geneExpressionColormapRange[1],
|
|
194149
|
+
isExpressionMode: cellColorEncoding === "geneSelection",
|
|
194150
|
+
colormap: geneExpressionColormap,
|
|
194151
|
+
onClick: (info2) => {
|
|
194152
|
+
if (onCellClick) {
|
|
194153
|
+
onCellClick(info2);
|
|
194154
|
+
}
|
|
194155
|
+
},
|
|
194156
|
+
onHover: getOnHoverCallback(obsIndex, setCellHighlight, setComponentHover),
|
|
194157
|
+
updateTriggers: {
|
|
194158
|
+
getExpressionValue,
|
|
194159
|
+
getFillColor: [cellColorEncoding, cellSelection, cellColors],
|
|
194160
|
+
getLineColor: [cellColorEncoding, cellSelection, cellColors],
|
|
194161
|
+
getCellIsSelected
|
|
194162
|
+
}
|
|
193872
194163
|
});
|
|
193873
194164
|
}
|
|
193874
|
-
|
|
193875
|
-
|
|
193876
|
-
|
|
193877
|
-
|
|
193878
|
-
|
|
193879
|
-
|
|
193880
|
-
|
|
193881
|
-
|
|
193882
|
-
|
|
193883
|
-
|
|
193884
|
-
|
|
193885
|
-
|
|
193886
|
-
|
|
194165
|
+
createCellSetsLayers() {
|
|
194166
|
+
const { theme, cellSetPolygons, viewState, cellSetPolygonsVisible, cellSetLabelsVisible, cellSetLabelSize } = this.props;
|
|
194167
|
+
const result = [];
|
|
194168
|
+
if (cellSetPolygonsVisible) {
|
|
194169
|
+
result.push(new PolygonLayer({
|
|
194170
|
+
id: "cell-sets-polygon-layer",
|
|
194171
|
+
data: cellSetPolygons,
|
|
194172
|
+
stroked: true,
|
|
194173
|
+
filled: false,
|
|
194174
|
+
wireframe: true,
|
|
194175
|
+
lineWidthMaxPixels: 1,
|
|
194176
|
+
getPolygon: (d) => d.hull,
|
|
194177
|
+
getLineColor: (d) => d.color,
|
|
194178
|
+
getLineWidth: 1
|
|
194179
|
+
}));
|
|
193887
194180
|
}
|
|
193888
|
-
|
|
193889
|
-
|
|
193890
|
-
|
|
193891
|
-
|
|
193892
|
-
|
|
193893
|
-
|
|
193894
|
-
|
|
194181
|
+
if (cellSetLabelsVisible) {
|
|
194182
|
+
const { zoom: zoom2 } = viewState;
|
|
194183
|
+
const nodes = cellSetPolygons.map((p) => ({
|
|
194184
|
+
x: p.centroid[0],
|
|
194185
|
+
y: p.centroid[1],
|
|
194186
|
+
label: p.name
|
|
194187
|
+
}));
|
|
194188
|
+
const collisionForce = this.cellSetsForceSimulation.size((d) => [
|
|
194189
|
+
cellSetLabelSize * 1 / 2 ** zoom2 * 4 * d.label.length,
|
|
194190
|
+
cellSetLabelSize * 1 / 2 ** zoom2 * 1.5
|
|
194191
|
+
]);
|
|
194192
|
+
forceSimulation$1().nodes(nodes).force("collision", collisionForce).tick(NUM_FORCE_SIMULATION_TICKS);
|
|
194193
|
+
result.push(new TextLayer({
|
|
194194
|
+
id: "cell-sets-text-layer",
|
|
194195
|
+
data: nodes,
|
|
194196
|
+
getPosition: (d) => [d.x, d.y],
|
|
194197
|
+
getText: (d) => d.label,
|
|
194198
|
+
getColor: theme === "dark" ? [255, 255, 255] : [0, 0, 0],
|
|
194199
|
+
getSize: cellSetLabelSize,
|
|
194200
|
+
getAngle: 0,
|
|
194201
|
+
getTextAnchor: "middle",
|
|
194202
|
+
getAlignmentBaseline: "center",
|
|
194203
|
+
fontFamily: LABEL_FONT_FAMILY,
|
|
194204
|
+
fontWeight: "normal"
|
|
194205
|
+
}));
|
|
193895
194206
|
}
|
|
194207
|
+
return result;
|
|
193896
194208
|
}
|
|
193897
|
-
|
|
193898
|
-
|
|
193899
|
-
|
|
193900
|
-
|
|
193901
|
-
|
|
193902
|
-
|
|
193903
|
-
|
|
194209
|
+
createSelectionLayers() {
|
|
194210
|
+
const { obsEmbeddingIndex: obsIndex, obsEmbedding, viewState, setCellSelection } = this.props;
|
|
194211
|
+
const { tool } = this.state;
|
|
194212
|
+
const { cellsQuadTree } = this;
|
|
194213
|
+
const flipYTooltip = true;
|
|
194214
|
+
const getCellCoords = makeDefaultGetObsCoords$1(obsEmbedding);
|
|
194215
|
+
return getSelectionLayers(tool, viewState.zoom, CELLS_LAYER_ID$1, getCellCoords, obsIndex, setCellSelection, cellsQuadTree, flipYTooltip);
|
|
194216
|
+
}
|
|
194217
|
+
getLayers() {
|
|
194218
|
+
const { cellsLayer, cellSetsLayers } = this;
|
|
194219
|
+
return [
|
|
194220
|
+
cellsLayer,
|
|
194221
|
+
...cellSetsLayers,
|
|
194222
|
+
...this.createSelectionLayers()
|
|
194223
|
+
];
|
|
194224
|
+
}
|
|
194225
|
+
onUpdateCellsData() {
|
|
194226
|
+
const { obsEmbedding } = this.props;
|
|
194227
|
+
if (obsEmbedding) {
|
|
194228
|
+
const getCellCoords = makeDefaultGetObsCoords$1(obsEmbedding);
|
|
194229
|
+
this.cellsQuadTree = createQuadTree(obsEmbedding, getCellCoords);
|
|
194230
|
+
this.cellsData = {
|
|
194231
|
+
src: {
|
|
194232
|
+
obsEmbedding
|
|
194233
|
+
},
|
|
194234
|
+
length: obsEmbedding.shape[1]
|
|
194235
|
+
};
|
|
193904
194236
|
}
|
|
193905
|
-
|
|
193906
|
-
|
|
194237
|
+
}
|
|
194238
|
+
onUpdateCellsLayer() {
|
|
194239
|
+
const { obsEmbeddingIndex, obsEmbedding } = this.props;
|
|
194240
|
+
if (obsEmbeddingIndex && obsEmbedding) {
|
|
194241
|
+
this.cellsLayer = this.createCellsLayer();
|
|
194242
|
+
} else {
|
|
194243
|
+
this.cellsLayer = null;
|
|
193907
194244
|
}
|
|
193908
|
-
|
|
193909
|
-
|
|
193910
|
-
|
|
194245
|
+
}
|
|
194246
|
+
onUpdateCellSetsLayers(onlyViewStateChange) {
|
|
194247
|
+
if (onlyViewStateChange) {
|
|
194248
|
+
const { viewState, cellSetLabelsVisible } = this.props;
|
|
194249
|
+
const { zoom: zoom2 } = viewState;
|
|
194250
|
+
const { cellSetsLabelPrevZoom } = this;
|
|
194251
|
+
if (cellSetLabelsVisible && (cellSetsLabelPrevZoom === null || Math.abs(cellSetsLabelPrevZoom - zoom2) > LABEL_UPDATE_ZOOM_DELTA)) {
|
|
194252
|
+
this.cellSetsLayers = this.createCellSetsLayers();
|
|
194253
|
+
this.cellSetsLabelPrevZoom = zoom2;
|
|
193911
194254
|
}
|
|
194255
|
+
} else {
|
|
194256
|
+
this.cellSetsLayers = this.createCellSetsLayers();
|
|
193912
194257
|
}
|
|
193913
|
-
|
|
193914
|
-
|
|
193915
|
-
|
|
193916
|
-
|
|
193917
|
-
|
|
193918
|
-
|
|
194258
|
+
}
|
|
194259
|
+
viewInfoDidUpdate() {
|
|
194260
|
+
const { obsEmbeddingIndex, obsEmbedding } = this.props;
|
|
194261
|
+
super.viewInfoDidUpdate(obsEmbeddingIndex, obsEmbedding, makeFlippedGetObsCoords);
|
|
194262
|
+
}
|
|
194263
|
+
componentDidUpdate(prevProps) {
|
|
194264
|
+
this.viewInfoDidUpdate();
|
|
194265
|
+
const shallowDiff = (propName) => prevProps[propName] !== this.props[propName];
|
|
194266
|
+
let forceUpdate = false;
|
|
194267
|
+
if (["obsEmbedding"].some(shallowDiff)) {
|
|
194268
|
+
this.onUpdateCellsData();
|
|
194269
|
+
forceUpdate = true;
|
|
193919
194270
|
}
|
|
193920
|
-
|
|
193921
|
-
|
|
193922
|
-
|
|
193923
|
-
|
|
194271
|
+
if ([
|
|
194272
|
+
"obsEmbeddingIndex",
|
|
194273
|
+
"obsEmbedding",
|
|
194274
|
+
"cellFilter",
|
|
194275
|
+
"cellSelection",
|
|
194276
|
+
"cellColors",
|
|
194277
|
+
"cellRadius",
|
|
194278
|
+
"cellOpacity",
|
|
194279
|
+
"cellRadiusMode",
|
|
194280
|
+
"geneExpressionColormap",
|
|
194281
|
+
"geneExpressionColormapRange",
|
|
194282
|
+
"geneSelection",
|
|
194283
|
+
"cellColorEncoding"
|
|
194284
|
+
].some(shallowDiff)) {
|
|
194285
|
+
this.onUpdateCellsLayer();
|
|
194286
|
+
forceUpdate = true;
|
|
193924
194287
|
}
|
|
193925
|
-
|
|
193926
|
-
|
|
193927
|
-
|
|
193928
|
-
|
|
194288
|
+
if ([
|
|
194289
|
+
"cellSetPolygons",
|
|
194290
|
+
"cellSetPolygonsVisible",
|
|
194291
|
+
"cellSetLabelsVisible",
|
|
194292
|
+
"cellSetLabelSize"
|
|
194293
|
+
].some(shallowDiff)) {
|
|
194294
|
+
this.onUpdateCellSetsLayers(false);
|
|
194295
|
+
forceUpdate = true;
|
|
194296
|
+
}
|
|
194297
|
+
if (shallowDiff("viewState")) {
|
|
194298
|
+
this.onUpdateCellSetsLayers(true);
|
|
194299
|
+
forceUpdate = true;
|
|
194300
|
+
}
|
|
194301
|
+
if (forceUpdate) {
|
|
194302
|
+
this.forceUpdate();
|
|
193929
194303
|
}
|
|
193930
|
-
return true;
|
|
193931
|
-
} else {
|
|
193932
|
-
return a2 === b2;
|
|
193933
194304
|
}
|
|
193934
194305
|
}
|
|
193935
|
-
|
|
193936
|
-
|
|
194306
|
+
const ScatterplotWrapper = React$i.forwardRef((props2, deckRef) => jsx(Scatterplot, { ...props2, deckRef }));
|
|
194307
|
+
function ScatterplotOptions(props2) {
|
|
194308
|
+
const { children: children2, observationsLabel, cellRadius, setCellRadius, cellRadiusMode, setCellRadiusMode, cellOpacity, setCellOpacity, cellOpacityMode, setCellOpacityMode, cellSetLabelsVisible, setCellSetLabelsVisible, cellSetLabelSize, setCellSetLabelSize, cellSetPolygonsVisible, setCellSetPolygonsVisible, cellColorEncoding, setCellColorEncoding, geneExpressionColormap, setGeneExpressionColormap, geneExpressionColormapRange, setGeneExpressionColormapRange } = props2;
|
|
194309
|
+
const observationsLabelNice = capitalize$2(observationsLabel);
|
|
194310
|
+
const classes = useStyles$b();
|
|
194311
|
+
function handleCellRadiusModeChange(event2) {
|
|
194312
|
+
setCellRadiusMode(event2.target.value);
|
|
194313
|
+
}
|
|
194314
|
+
function handleCellOpacityModeChange(event2) {
|
|
194315
|
+
setCellOpacityMode(event2.target.value);
|
|
194316
|
+
}
|
|
194317
|
+
function handleRadiusChange(event2, value2) {
|
|
194318
|
+
setCellRadius(value2);
|
|
194319
|
+
}
|
|
194320
|
+
function handleOpacityChange(event2, value2) {
|
|
194321
|
+
setCellOpacity(value2);
|
|
194322
|
+
}
|
|
194323
|
+
function handleLabelVisibilityChange(event2) {
|
|
194324
|
+
setCellSetLabelsVisible(event2.target.checked);
|
|
194325
|
+
}
|
|
194326
|
+
function handleLabelSizeChange(event2, value2) {
|
|
194327
|
+
setCellSetLabelSize(value2);
|
|
194328
|
+
}
|
|
194329
|
+
function handlePolygonVisibilityChange(event2) {
|
|
194330
|
+
setCellSetPolygonsVisible(event2.target.checked);
|
|
194331
|
+
}
|
|
194332
|
+
function handleGeneExpressionColormapChange(event2) {
|
|
194333
|
+
setGeneExpressionColormap(event2.target.value);
|
|
194334
|
+
}
|
|
194335
|
+
function handleColormapRangeChange(event2, value2) {
|
|
194336
|
+
setGeneExpressionColormapRange(value2);
|
|
194337
|
+
}
|
|
194338
|
+
const handleColormapRangeChangeDebounced = React$i.useCallback(debounce_1$1(handleColormapRangeChange, 5, { trailing: true }), [handleColormapRangeChange]);
|
|
194339
|
+
return jsxs(OptionsContainer, { children: [children2, jsx(CellColorEncodingOption, { observationsLabel, cellColorEncoding, setCellColorEncoding }), jsxs(TableRow$1, { children: [jsxs(TableCell$1, { className: classes.labelCell, children: [observationsLabelNice, " Set Labels Visible"] }), jsx(TableCell$1, { className: classes.inputCell, children: jsx(Checkbox$1, { className: classes.checkbox, checked: cellSetLabelsVisible, onChange: handleLabelVisibilityChange, name: "scatterplot-option-cell-set-labels", color: "default" }) })] }), jsxs(TableRow$1, { children: [jsxs(TableCell$1, { className: classes.labelCell, children: [observationsLabelNice, " Set Label Size"] }), jsx(TableCell$1, { className: classes.inputCell, children: jsx(Slider$1, { disabled: !cellSetLabelsVisible, classes: { root: classes.slider, valueLabel: classes.sliderValueLabel }, value: cellSetLabelSize, onChange: handleLabelSizeChange, "aria-labelledby": "cell-set-label-size-slider", valueLabelDisplay: "auto", step: 1, min: 8, max: 36 }) })] }), jsxs(TableRow$1, { children: [jsxs(TableCell$1, { className: classes.labelCell, children: [observationsLabelNice, " Set Polygons Visible"] }), jsx(TableCell$1, { className: classes.inputCell, children: jsx(Checkbox$1, { className: classes.checkbox, checked: cellSetPolygonsVisible, onChange: handlePolygonVisibilityChange, name: "scatterplot-option-cell-set-polygons", color: "default" }) })] }), jsxs(TableRow$1, { children: [jsxs(TableCell$1, { className: classes.labelCell, htmlFor: "cell-radius-mode-select", children: [observationsLabelNice, " Radius Mode"] }), jsx(TableCell$1, { className: classes.inputCell, children: jsxs(OptionSelect, { className: classes.select, value: cellRadiusMode, onChange: handleCellRadiusModeChange, inputProps: {
|
|
194340
|
+
id: "cell-radius-mode-select"
|
|
194341
|
+
}, children: [jsx("option", { value: "auto", children: "Auto" }), jsx("option", { value: "manual", children: "Manual" })] }) })] }), jsxs(TableRow$1, { children: [jsxs(TableCell$1, { className: classes.labelCell, children: [observationsLabelNice, " Radius"] }), jsx(TableCell$1, { className: classes.inputCell, children: jsx(Slider$1, { disabled: cellRadiusMode !== "manual", classes: { root: classes.slider, valueLabel: classes.sliderValueLabel }, value: cellRadius, onChange: handleRadiusChange, "aria-labelledby": "cell-radius-slider", valueLabelDisplay: "auto", step: 0.01, min: 0.01, max: 10 }) })] }), jsxs(TableRow$1, { children: [jsxs(TableCell$1, { className: classes.labelCell, htmlFor: "cell-opacity-mode-select", children: [observationsLabelNice, " Opacity Mode"] }), jsx(TableCell$1, { className: classes.inputCell, children: jsxs(OptionSelect, { className: classes.select, value: cellOpacityMode, onChange: handleCellOpacityModeChange, inputProps: {
|
|
194342
|
+
id: "cell-opacity-mode-select"
|
|
194343
|
+
}, children: [jsx("option", { value: "auto", children: "Auto" }), jsx("option", { value: "manual", children: "Manual" })] }) })] }), jsxs(TableRow$1, { children: [jsxs(TableCell$1, { className: classes.labelCell, children: [observationsLabelNice, " Opacity"] }), jsx(TableCell$1, { className: classes.inputCell, children: jsx(Slider$1, { disabled: cellOpacityMode !== "manual", classes: { root: classes.slider, valueLabel: classes.sliderValueLabel }, value: cellOpacity, onChange: handleOpacityChange, "aria-labelledby": "cell-opacity-slider", valueLabelDisplay: "auto", step: 0.05, min: 0, max: 1 }) })] }), jsxs(TableRow$1, { children: [jsx(TableCell$1, { className: classes.labelCell, htmlFor: "gene-expression-colormap-select", children: "Gene Expression Colormap" }), jsx(TableCell$1, { className: classes.inputCell, children: jsx(OptionSelect, { className: classes.select, value: geneExpressionColormap, onChange: handleGeneExpressionColormapChange, inputProps: {
|
|
194344
|
+
id: "gene-expression-colormap-select"
|
|
194345
|
+
}, children: GLSL_COLORMAPS.map((cmap) => jsx("option", { value: cmap, children: cmap }, cmap)) }) })] }), jsxs(TableRow$1, { children: [jsx(TableCell$1, { className: classes.labelCell, children: "Gene Expression Colormap Range" }), jsx(TableCell$1, { className: classes.inputCell, children: jsx(Slider$1, { classes: { root: classes.slider, valueLabel: classes.sliderValueLabel }, value: geneExpressionColormapRange, onChange: handleColormapRangeChangeDebounced, "aria-labelledby": "gene-expression-colormap-range-slider", valueLabelDisplay: "auto", step: 5e-3, min: 0, max: 1 }) })] })] });
|
|
193937
194346
|
}
|
|
193938
|
-
|
|
193939
|
-
|
|
193940
|
-
|
|
193941
|
-
|
|
193942
|
-
|
|
193943
|
-
|
|
193944
|
-
|
|
194347
|
+
const styles = makeStyles(() => ({
|
|
194348
|
+
tooltipAnchor: {
|
|
194349
|
+
position: "relative",
|
|
194350
|
+
width: "0px",
|
|
194351
|
+
height: "0px",
|
|
194352
|
+
pointerEvents: "none",
|
|
194353
|
+
userSelect: "none"
|
|
194354
|
+
},
|
|
194355
|
+
tooltipContent: {
|
|
194356
|
+
opacity: 0.9,
|
|
194357
|
+
padding: "5px",
|
|
194358
|
+
pointerEvents: "none",
|
|
194359
|
+
"& table > tbody > tr > th, & table > tbody > tr > td": {
|
|
194360
|
+
fontSize: "80%",
|
|
194361
|
+
opacity: 0.8,
|
|
194362
|
+
outline: 0,
|
|
194363
|
+
padding: "0 2px"
|
|
194364
|
+
},
|
|
194365
|
+
"& table": {
|
|
194366
|
+
borderCollapse: "collapse"
|
|
193945
194367
|
}
|
|
193946
194368
|
}
|
|
193947
|
-
|
|
194369
|
+
}));
|
|
194370
|
+
function Tooltip(props2) {
|
|
194371
|
+
const { x: x2, y: y2, parentWidth, parentHeight, children: children2 } = props2;
|
|
194372
|
+
const ref2 = React$i.useRef();
|
|
194373
|
+
const classes = styles();
|
|
194374
|
+
const [placementX, setPlacementX] = React$i.useState("start");
|
|
194375
|
+
const [placementY, setPlacementY] = React$i.useState("bottom");
|
|
194376
|
+
const getTooltipContainer = useVitessceContainer(ref2);
|
|
194377
|
+
React$i.useEffect(() => {
|
|
194378
|
+
if (ref2 && ref2.current) {
|
|
194379
|
+
const flipX = x2 > parentWidth / 2;
|
|
194380
|
+
const flipY = y2 > parentHeight / 2;
|
|
194381
|
+
setPlacementX(flipX ? "end" : "start");
|
|
194382
|
+
setPlacementY(flipY ? "top" : "bottom");
|
|
194383
|
+
ref2.current.style.left = `${x2 + (flipX ? -20 : 5)}px`;
|
|
194384
|
+
ref2.current.style.top = `${y2 + (flipY ? -20 : 5)}px`;
|
|
194385
|
+
}
|
|
194386
|
+
}, [x2, y2, parentWidth, parentHeight]);
|
|
194387
|
+
return jsx("div", { ref: ref2, className: classes.tooltipAnchor, children: ref2 && ref2.current ? jsx(Popper$1, { open: true, anchorEl: ref2.current, container: getTooltipContainer, transition: true, placement: `${placementY}-${placementX}`, children: jsx(Paper$1, { elevation: 4, className: classes.tooltipContent, children: children2 }) }) : null });
|
|
193948
194388
|
}
|
|
193949
|
-
|
|
193950
|
-
|
|
193951
|
-
|
|
193952
|
-
|
|
193953
|
-
throw new Error("The global config is readonly. \nPlease create a mathjs instance if you want to change the default configuration. \nExample:\n\n import { create, all } from 'mathjs';\n const mathjs = create(all);\n mathjs.config({ number: 'BigNumber' });\n");
|
|
194389
|
+
function Tooltip2D(props2) {
|
|
194390
|
+
const { parentUuid, sourceUuid, x: x2, y: y2, parentWidth, parentHeight, children: children2 } = props2;
|
|
194391
|
+
if (x2 < 0 || x2 > parentWidth || y2 < 0 || y2 > parentHeight) {
|
|
194392
|
+
return null;
|
|
193954
194393
|
}
|
|
193955
|
-
|
|
193956
|
-
|
|
193957
|
-
|
|
193958
|
-
|
|
193959
|
-
|
|
193960
|
-
|
|
193961
|
-
|
|
193962
|
-
|
|
193963
|
-
|
|
193964
|
-
{
|
|
193965
|
-
|
|
193966
|
-
}
|
|
193967
|
-
})
|
|
193968
|
-
|
|
193969
|
-
|
|
193970
|
-
|
|
193971
|
-
|
|
193972
|
-
|
|
193973
|
-
|
|
193974
|
-
|
|
193975
|
-
|
|
193976
|
-
|
|
193977
|
-
|
|
193978
|
-
|
|
193979
|
-
|
|
193980
|
-
|
|
193981
|
-
|
|
193982
|
-
|
|
193983
|
-
|
|
193984
|
-
|
|
193985
|
-
|
|
193986
|
-
|
|
193987
|
-
|
|
193988
|
-
|
|
193989
|
-
|
|
193990
|
-
|
|
193991
|
-
|
|
193992
|
-
|
|
193993
|
-
|
|
193994
|
-
|
|
193995
|
-
|
|
193996
|
-
|
|
193997
|
-
|
|
193998
|
-
|
|
193999
|
-
|
|
194000
|
-
|
|
194001
|
-
|
|
194002
|
-
|
|
194003
|
-
|
|
194004
|
-
|
|
194005
|
-
|
|
194006
|
-
|
|
194007
|
-
|
|
194008
|
-
|
|
194009
|
-
|
|
194010
|
-
|
|
194011
|
-
|
|
194012
|
-
|
|
194013
|
-
|
|
194014
|
-
|
|
194015
|
-
|
|
194016
|
-
|
|
194017
|
-
|
|
194018
|
-
|
|
194019
|
-
|
|
194020
|
-
|
|
194021
|
-
|
|
194022
|
-
|
|
194023
|
-
|
|
194024
|
-
|
|
194025
|
-
|
|
194026
|
-
|
|
194027
|
-
|
|
194028
|
-
|
|
194029
|
-
|
|
194030
|
-
|
|
194031
|
-
|
|
194032
|
-
|
|
194033
|
-
|
|
194034
|
-
|
|
194035
|
-
|
|
194036
|
-
|
|
194037
|
-
|
|
194038
|
-
|
|
194039
|
-
|
|
194040
|
-
|
|
194041
|
-
|
|
194042
|
-
|
|
194043
|
-
|
|
194044
|
-
|
|
194045
|
-
|
|
194046
|
-
|
|
194047
|
-
|
|
194048
|
-
|
|
194049
|
-
|
|
194050
|
-
|
|
194394
|
+
const isTooltipVisible = parentUuid === sourceUuid;
|
|
194395
|
+
const crosshairWidth = 1;
|
|
194396
|
+
return jsx(Fragment, { children: isTooltipVisible ? jsx(Tooltip, { x: x2, y: y2, parentWidth, parentHeight, children: children2 }) : jsxs(Fragment, { children: [x2 !== null ? jsx("div", { className: "cell-emphasis-crosshair", style: {
|
|
194397
|
+
left: `${x2 - crosshairWidth / 2}px`,
|
|
194398
|
+
top: 0,
|
|
194399
|
+
width: `${crosshairWidth}px`,
|
|
194400
|
+
height: `${parentHeight}px`
|
|
194401
|
+
} }) : null, y2 !== null ? jsx("div", { className: "cell-emphasis-crosshair", style: {
|
|
194402
|
+
left: 0,
|
|
194403
|
+
top: `${y2 - crosshairWidth / 2}px`,
|
|
194404
|
+
width: `${parentWidth}px`,
|
|
194405
|
+
height: `${crosshairWidth}px`
|
|
194406
|
+
} }) : null] }) });
|
|
194407
|
+
}
|
|
194408
|
+
function TooltipContent(props2) {
|
|
194409
|
+
const { info: info2 } = props2;
|
|
194410
|
+
return jsx("table", { children: jsx("tbody", { children: Object.entries(info2).map(([key2, value2]) => jsxs("tr", { children: [jsx("th", { children: key2 }), jsx("td", { children: value2 })] }, key2)) }) });
|
|
194411
|
+
}
|
|
194412
|
+
function ScatterplotTooltipSubscriber(props2) {
|
|
194413
|
+
const { parentUuid, obsHighlight, width: width2, height: height2, getObsInfo } = props2;
|
|
194414
|
+
const sourceUuid = useComponentHover();
|
|
194415
|
+
const viewInfo = useComponentViewInfo(parentUuid);
|
|
194416
|
+
const [cellInfo, x2, y2] = obsHighlight && getObsInfo ? [
|
|
194417
|
+
getObsInfo(obsHighlight),
|
|
194418
|
+
...viewInfo && viewInfo.project ? viewInfo.project(obsHighlight) : [null, null]
|
|
194419
|
+
] : [null, null, null];
|
|
194420
|
+
return cellInfo ? jsx(Tooltip2D, { x: x2, y: y2, parentUuid, sourceUuid, parentWidth: width2, parentHeight: height2, children: jsx(TooltipContent, { info: cellInfo }) }) : null;
|
|
194421
|
+
}
|
|
194422
|
+
function EmptyMessage(props2) {
|
|
194423
|
+
const { visible, message } = props2;
|
|
194424
|
+
return visible ? jsx("div", { children: message }) : null;
|
|
194425
|
+
}
|
|
194426
|
+
function EmbeddingScatterplotSubscriber(props2) {
|
|
194427
|
+
const {
|
|
194428
|
+
uuid,
|
|
194429
|
+
coordinationScopes,
|
|
194430
|
+
removeGridComponent,
|
|
194431
|
+
theme,
|
|
194432
|
+
disableTooltip = false,
|
|
194433
|
+
observationsLabelOverride,
|
|
194434
|
+
title: titleOverride,
|
|
194435
|
+
averageFillDensity
|
|
194436
|
+
} = props2;
|
|
194437
|
+
const loaders = useLoaders();
|
|
194438
|
+
const setComponentHover = useSetComponentHover();
|
|
194439
|
+
const setComponentViewInfo = useSetComponentViewInfo(uuid);
|
|
194440
|
+
const [{ dataset, obsType, featureType, featureValueType, embeddingZoom: zoom2, embeddingTargetX: targetX2, embeddingTargetY: targetY2, embeddingTargetZ: targetZ, embeddingType: mapping, obsFilter: cellFilter, obsHighlight: cellHighlight, featureSelection: geneSelection, 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 }, { 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 }] = useCoordination(COMPONENT_COORDINATION_TYPES[ViewType$2.SCATTERPLOT], coordinationScopes);
|
|
194441
|
+
const observationsLabel = observationsLabelOverride || obsType;
|
|
194442
|
+
const [urls2, addUrl2] = useUrls(loaders, dataset);
|
|
194443
|
+
const [width2, height2, deckRef] = useDeckCanvasSize();
|
|
194444
|
+
const title2 = titleOverride || `Scatterplot (${mapping})`;
|
|
194445
|
+
const [obsLabelsTypes, obsLabelsData] = useMultiObsLabels(coordinationScopes, obsType, loaders, dataset, addUrl2);
|
|
194446
|
+
const [{ obsIndex: obsEmbeddingIndex, obsEmbedding }, obsEmbeddingStatus] = useObsEmbeddingData(loaders, dataset, addUrl2, true, {}, {}, { obsType, embeddingType: mapping });
|
|
194447
|
+
const cellsCount = (obsEmbeddingIndex == null ? void 0 : obsEmbeddingIndex.length) || 0;
|
|
194448
|
+
const [{ obsSets: cellSets, obsSetsMembership }, obsSetsStatus] = useObsSetsData(loaders, dataset, addUrl2, false, { setObsSetSelection: setCellSetSelection, setObsSetColor: setCellSetColor }, { obsSetSelection: cellSetSelection, obsSetColor: cellSetColor }, { obsType });
|
|
194449
|
+
const [expressionData, loadedFeatureSelection, featureSelectionStatus] = useFeatureSelection(loaders, dataset, false, geneSelection, { obsType, featureType, featureValueType });
|
|
194450
|
+
const [{ obsIndex: matrixObsIndex }, matrixIndicesStatus] = useObsFeatureMatrixIndices(loaders, dataset, addUrl2, false, { obsType, featureType, featureValueType });
|
|
194451
|
+
const isReady = useReady([
|
|
194452
|
+
obsEmbeddingStatus,
|
|
194453
|
+
obsSetsStatus,
|
|
194454
|
+
featureSelectionStatus,
|
|
194455
|
+
matrixIndicesStatus
|
|
194456
|
+
]);
|
|
194457
|
+
const [dynamicCellRadius, setDynamicCellRadius] = React$i.useState(cellRadiusFixed);
|
|
194458
|
+
const [dynamicCellOpacity, setDynamicCellOpacity] = React$i.useState(cellOpacityFixed);
|
|
194459
|
+
const mergedCellSets = React$i.useMemo(() => mergeObsSets(cellSets, additionalCellSets), [cellSets, additionalCellSets]);
|
|
194460
|
+
const setCellSelectionProp = React$i.useCallback((v) => {
|
|
194461
|
+
setObsSelection(v, additionalCellSets, cellSetColor, setCellSetSelection, setAdditionalCellSets, setCellSetColor, setCellColorEncoding);
|
|
194462
|
+
}, [
|
|
194463
|
+
additionalCellSets,
|
|
194464
|
+
cellSetColor,
|
|
194465
|
+
setCellColorEncoding,
|
|
194466
|
+
setAdditionalCellSets,
|
|
194467
|
+
setCellSetColor,
|
|
194468
|
+
setCellSetSelection
|
|
194469
|
+
]);
|
|
194470
|
+
const cellColors = React$i.useMemo(() => getCellColors({
|
|
194471
|
+
cellColorEncoding,
|
|
194472
|
+
expressionData: expressionData && expressionData[0],
|
|
194473
|
+
geneSelection,
|
|
194474
|
+
cellSets: mergedCellSets,
|
|
194475
|
+
cellSetSelection,
|
|
194476
|
+
cellSetColor,
|
|
194477
|
+
obsIndex: matrixObsIndex,
|
|
194478
|
+
theme
|
|
194479
|
+
}), [
|
|
194480
|
+
cellColorEncoding,
|
|
194481
|
+
geneSelection,
|
|
194482
|
+
mergedCellSets,
|
|
194483
|
+
theme,
|
|
194484
|
+
cellSetSelection,
|
|
194485
|
+
cellSetColor,
|
|
194486
|
+
expressionData,
|
|
194487
|
+
matrixObsIndex
|
|
194488
|
+
]);
|
|
194489
|
+
const [cellSetPolygonCache, setCellSetPolygonCache] = React$i.useState([]);
|
|
194490
|
+
const cacheHas2 = (cache2, key2) => cache2.findIndex((el2) => isEqual_1(el2[0], key2)) !== -1;
|
|
194491
|
+
const cacheGet = (cache2, key2) => {
|
|
194492
|
+
var _a3;
|
|
194493
|
+
return (_a3 = cache2.find((el2) => isEqual_1(el2[0], key2))) == null ? void 0 : _a3[1];
|
|
194494
|
+
};
|
|
194495
|
+
const cellSetPolygons = React$i.useMemo(() => {
|
|
194496
|
+
var _a3;
|
|
194497
|
+
if ((cellSetLabelsVisible || cellSetPolygonsVisible) && !cacheHas2(cellSetPolygonCache, cellSetSelection) && ((_a3 = mergedCellSets == null ? void 0 : mergedCellSets.tree) == null ? void 0 : _a3.length) && obsEmbedding && obsEmbeddingIndex && (cellSetColor == null ? void 0 : cellSetColor.length)) {
|
|
194498
|
+
const newCellSetPolygons = getCellSetPolygons({
|
|
194499
|
+
obsIndex: obsEmbeddingIndex,
|
|
194500
|
+
obsEmbedding,
|
|
194501
|
+
cellSets: mergedCellSets,
|
|
194502
|
+
cellSetSelection,
|
|
194503
|
+
cellSetColor,
|
|
194504
|
+
theme
|
|
194505
|
+
});
|
|
194506
|
+
setCellSetPolygonCache((cache2) => [...cache2, [cellSetSelection, newCellSetPolygons]]);
|
|
194507
|
+
return newCellSetPolygons;
|
|
194508
|
+
}
|
|
194509
|
+
return cacheGet(cellSetPolygonCache, cellSetSelection) || [];
|
|
194510
|
+
}, [
|
|
194511
|
+
cellSetPolygonsVisible,
|
|
194512
|
+
cellSetPolygonCache,
|
|
194513
|
+
cellSetLabelsVisible,
|
|
194514
|
+
theme,
|
|
194515
|
+
obsEmbeddingIndex,
|
|
194516
|
+
obsEmbedding,
|
|
194517
|
+
mergedCellSets,
|
|
194518
|
+
cellSetSelection,
|
|
194519
|
+
cellSetColor
|
|
194520
|
+
]);
|
|
194521
|
+
const cellSelection = React$i.useMemo(() => Array.from(cellColors.keys()), [cellColors]);
|
|
194522
|
+
const [xRange, yRange, xExtent, yExtent, numCells] = React$i.useMemo(() => {
|
|
194523
|
+
if (obsEmbedding && obsEmbedding.data && obsEmbedding.shape) {
|
|
194524
|
+
const cellCount = obsEmbedding.shape[1];
|
|
194525
|
+
const xE = extent$2(obsEmbedding.data[0]);
|
|
194526
|
+
const yE = extent$2(obsEmbedding.data[1]);
|
|
194527
|
+
const xR = xE[1] - xE[0];
|
|
194528
|
+
const yR = yE[1] - yE[0];
|
|
194529
|
+
return [xR, yR, xE, yE, cellCount];
|
|
194530
|
+
}
|
|
194531
|
+
return [null, null, null, null, null];
|
|
194532
|
+
}, [obsEmbedding]);
|
|
194533
|
+
React$i.useEffect(() => {
|
|
194534
|
+
if (xRange && yRange) {
|
|
194535
|
+
const pointSizeDevicePixels = getPointSizeDevicePixels(window.devicePixelRatio, zoom2, xRange, yRange, width2, height2);
|
|
194536
|
+
setDynamicCellRadius(pointSizeDevicePixels);
|
|
194537
|
+
const nextCellOpacityScale = getPointOpacity(zoom2, xRange, yRange, width2, height2, numCells, averageFillDensity);
|
|
194538
|
+
setDynamicCellOpacity(nextCellOpacityScale);
|
|
194539
|
+
if (typeof targetX2 !== "number" || typeof targetY2 !== "number") {
|
|
194540
|
+
const newTargetX = xExtent[0] + xRange / 2;
|
|
194541
|
+
const newTargetY = yExtent[0] + yRange / 2;
|
|
194542
|
+
const newZoom = Math.log2(Math.min(width2 / xRange, height2 / yRange));
|
|
194543
|
+
setTargetX(newTargetX);
|
|
194544
|
+
setTargetY(-newTargetY);
|
|
194545
|
+
setZoom(newZoom);
|
|
194546
|
+
}
|
|
194547
|
+
}
|
|
194548
|
+
}, [
|
|
194549
|
+
xRange,
|
|
194550
|
+
yRange,
|
|
194551
|
+
xExtent,
|
|
194552
|
+
yExtent,
|
|
194553
|
+
numCells,
|
|
194554
|
+
width2,
|
|
194555
|
+
height2,
|
|
194556
|
+
zoom2,
|
|
194557
|
+
averageFillDensity
|
|
194558
|
+
]);
|
|
194559
|
+
const getObsInfo = useGetObsInfo(observationsLabel, obsLabelsTypes, obsLabelsData, obsSetsMembership);
|
|
194560
|
+
const cellSelectionSet = React$i.useMemo(() => new Set(cellSelection), [cellSelection]);
|
|
194561
|
+
const getCellIsSelected = React$i.useCallback((object2, { index: index2 }) => (cellSelectionSet || /* @__PURE__ */ new Set([])).has(obsEmbeddingIndex[index2]) ? 1 : 0, [cellSelectionSet, obsEmbeddingIndex]);
|
|
194562
|
+
const cellRadius = cellRadiusMode === "manual" ? cellRadiusFixed : dynamicCellRadius;
|
|
194563
|
+
const cellOpacity = cellOpacityMode === "manual" ? cellOpacityFixed : dynamicCellOpacity;
|
|
194564
|
+
const getExpressionValue = useExpressionValueGetter({
|
|
194565
|
+
instanceObsIndex: obsEmbeddingIndex,
|
|
194566
|
+
matrixObsIndex,
|
|
194567
|
+
expressionData
|
|
194568
|
+
});
|
|
194569
|
+
return jsxs(TitleInfo, { title: title2, info: `${commaNumber(cellsCount)} ${plur(observationsLabel, cellsCount)}`, removeGridComponent, urls: urls2, theme, isReady, options: jsx(ScatterplotOptions, { observationsLabel, cellRadius: cellRadiusFixed, setCellRadius: setCellRadiusFixed, cellRadiusMode, setCellRadiusMode, cellOpacity: cellOpacityFixed, setCellOpacity: setCellOpacityFixed, cellOpacityMode, setCellOpacityMode, cellSetLabelsVisible, setCellSetLabelsVisible, cellSetLabelSize, setCellSetLabelSize, cellSetPolygonsVisible, setCellSetPolygonsVisible, cellColorEncoding, setCellColorEncoding, geneExpressionColormap, setGeneExpressionColormap, geneExpressionColormapRange, setGeneExpressionColormapRange }), children: [jsx(ScatterplotWrapper, { ref: deckRef, uuid, theme, viewState: { zoom: zoom2, target: [targetX2, targetY2, targetZ] }, setViewState: ({ zoom: newZoom, target: target2 }) => {
|
|
194570
|
+
setZoom(newZoom);
|
|
194571
|
+
setTargetX(target2[0]);
|
|
194572
|
+
setTargetY(target2[1]);
|
|
194573
|
+
setTargetZ(target2[2] || 0);
|
|
194574
|
+
}, obsEmbeddingIndex, obsEmbedding, cellFilter, cellSelection, cellHighlight, cellColors, cellSetPolygons, cellSetLabelSize, cellSetLabelsVisible, cellSetPolygonsVisible, setCellFilter, setCellSelection: setCellSelectionProp, setCellHighlight, cellRadius, cellOpacity, cellColorEncoding, geneExpressionColormap, geneExpressionColormapRange, setComponentHover: () => {
|
|
194575
|
+
setComponentHover(uuid);
|
|
194576
|
+
}, updateViewInfo: setComponentViewInfo, getExpressionValue, getCellIsSelected }), !disableTooltip && jsx(ScatterplotTooltipSubscriber, { parentUuid: uuid, obsHighlight: cellHighlight, width: width2, height: height2, getObsInfo })] });
|
|
194577
|
+
}
|
|
194578
|
+
function register$c() {
|
|
194579
|
+
registerPluginViewType(ViewType$2.SCATTERPLOT, EmbeddingScatterplotSubscriber, COMPONENT_COORDINATION_TYPES[ViewType$2.SCATTERPLOT]);
|
|
194580
|
+
}
|
|
194581
|
+
function GatingScatterplotOptions(props2) {
|
|
194582
|
+
const { featureType, gatingFeatureSelectionX, setGatingFeatureSelectionX, gatingFeatureSelectionY, setGatingFeatureSelectionY, gatingFeatureValueTransform, setGatingFeatureValueTransform, gatingFeatureValueTransformCoefficient, setGatingFeatureValueTransformCoefficient, geneSelectOptions, transformOptions } = props2;
|
|
194583
|
+
const classes = useStyles$b();
|
|
194584
|
+
const handleGeneSelectChange = (event2) => {
|
|
194585
|
+
const { options } = event2.target;
|
|
194586
|
+
const newValues = [];
|
|
194587
|
+
for (let i2 = 0, l2 = options.length; i2 < l2; i2 += 1) {
|
|
194588
|
+
if (options[i2].selected) {
|
|
194589
|
+
newValues.push(options[i2].value);
|
|
194590
|
+
}
|
|
194591
|
+
}
|
|
194592
|
+
if (newValues.length === 1 && gatingFeatureSelectionX && !gatingFeatureSelectionY && newValues[0] !== gatingFeatureSelectionX) {
|
|
194593
|
+
setGatingFeatureSelectionY(newValues[0]);
|
|
194594
|
+
} else if (newValues.length <= 2) {
|
|
194595
|
+
setGatingFeatureSelectionX(newValues[0]);
|
|
194596
|
+
setGatingFeatureSelectionY(newValues[1]);
|
|
194597
|
+
}
|
|
194598
|
+
};
|
|
194599
|
+
const handleTransformChange = (event2) => {
|
|
194600
|
+
setGatingFeatureValueTransform(event2.target.value === "" ? null : event2.target.value);
|
|
194601
|
+
};
|
|
194602
|
+
const handleTransformCoefficientChange = (event2) => {
|
|
194603
|
+
const { value: value2 } = event2.target;
|
|
194604
|
+
if (!value2) {
|
|
194605
|
+
setGatingFeatureValueTransformCoefficient(value2);
|
|
194606
|
+
} else {
|
|
194607
|
+
const newCoefficient = Number(value2);
|
|
194608
|
+
if (!Number.isNaN(newCoefficient) && newCoefficient >= 0) {
|
|
194609
|
+
setGatingFeatureValueTransformCoefficient(value2);
|
|
194610
|
+
}
|
|
194611
|
+
}
|
|
194612
|
+
};
|
|
194613
|
+
return jsxs(Fragment, { children: [jsxs(TableRow$1, { children: [jsx(TableCell$1, { className: classes.labelCell, children: capitalize$2(plur(featureType, geneSelectOptions == null ? void 0 : geneSelectOptions.length)) }), jsx(TableCell$1, { className: classes.inputCell, children: jsx(OptionSelect, { multiple: true, className: classes.select, value: [gatingFeatureSelectionX, gatingFeatureSelectionY].filter((v) => v), onChange: handleGeneSelectChange, inputProps: {
|
|
194614
|
+
id: "scatterplot-gene-select"
|
|
194615
|
+
}, children: geneSelectOptions.map((name2) => jsx("option", { value: name2, children: name2 }, name2)) }, "gating-gene-select") })] }, "gene-option-row"), jsxs(TableRow$1, { children: [jsx(TableCell$1, { className: classes.labelCell, children: "Transform" }), jsx(TableCell$1, { className: classes.inputCell, children: jsx(OptionSelect, { className: classes.select, value: gatingFeatureValueTransform === null ? "" : gatingFeatureValueTransform, onChange: handleTransformChange, inputProps: {
|
|
194616
|
+
id: "scatterplot-transform-select"
|
|
194617
|
+
}, 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$1, { children: [jsx(TableCell$1, { className: classes.labelCell, children: "Transform Coefficient" }), jsx(TableCell$1, { className: classes.inputCell, children: jsx(TextField$1, { label: "Number", type: "number", onChange: handleTransformCoefficientChange, value: gatingFeatureValueTransformCoefficient, InputLabelProps: {
|
|
194618
|
+
shrink: true
|
|
194619
|
+
} }) })] }, "transform-coefficient-option-row")] });
|
|
194620
|
+
}
|
|
194621
|
+
function GatingSubscriber(props2) {
|
|
194622
|
+
const {
|
|
194623
|
+
uuid,
|
|
194624
|
+
coordinationScopes,
|
|
194625
|
+
removeGridComponent,
|
|
194626
|
+
theme,
|
|
194627
|
+
disableTooltip = false,
|
|
194628
|
+
title: titleOverride,
|
|
194629
|
+
averageFillDensity
|
|
194630
|
+
} = props2;
|
|
194631
|
+
const loaders = useLoaders();
|
|
194632
|
+
const setComponentHover = useSetComponentHover();
|
|
194633
|
+
const setComponentViewInfo = useSetComponentViewInfo(uuid);
|
|
194634
|
+
const [{ dataset, obsType, featureType, featureValueType, embeddingZoom: zoom2, embeddingTargetX: targetX2, embeddingTargetY: targetY2, 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$2.GATING], coordinationScopes);
|
|
194635
|
+
const [urls2, addUrl2] = useUrls(loaders, dataset);
|
|
194636
|
+
const [width2, height2, deckRef] = useDeckCanvasSize();
|
|
194637
|
+
const title2 = React$i.useMemo(() => {
|
|
194638
|
+
if (titleOverride) {
|
|
194639
|
+
return titleOverride;
|
|
194640
|
+
}
|
|
194641
|
+
if (!(gatingFeatureSelectionX && gatingFeatureSelectionY)) {
|
|
194642
|
+
return "Gating";
|
|
194643
|
+
}
|
|
194644
|
+
return `Gating (${gatingFeatureSelectionX} vs ${gatingFeatureSelectionY})`;
|
|
194645
|
+
}, [titleOverride, gatingFeatureSelectionX, gatingFeatureSelectionY]);
|
|
194646
|
+
const featureSelectionX = React$i.useMemo(() => gatingFeatureSelectionX ? [gatingFeatureSelectionX] : null, [gatingFeatureSelectionX]);
|
|
194647
|
+
const featureSelectionY = React$i.useMemo(() => gatingFeatureSelectionY ? [gatingFeatureSelectionY] : null, [gatingFeatureSelectionY]);
|
|
194648
|
+
const [{ obsSets: cellSets }, obsSetsStatus] = useObsSetsData(loaders, dataset, addUrl2, false, { setObsSetSelection: setCellSetSelection, setObsSetColor: setCellSetColor }, { obsSetSelection: cellSetSelection, obsSetColor: cellSetColor }, { obsType });
|
|
194649
|
+
const [expressionDataColor, loadedColor, featureSelectionColorStatus] = useFeatureSelection(loaders, dataset, false, gatingFeatureSelectionColor, { obsType, featureType, featureValueType });
|
|
194650
|
+
const [expressionDataX, loadedX, featureSelectionXStatus] = useFeatureSelection(loaders, dataset, false, featureSelectionX, { obsType, featureType, featureValueType });
|
|
194651
|
+
const [expressionDataY, loadedY, featureSelectionYStatus] = useFeatureSelection(loaders, dataset, false, featureSelectionY, { obsType, featureType, featureValueType });
|
|
194652
|
+
const [{ obsIndex, featureIndex }, matrixIndicesStatus] = useObsFeatureMatrixIndices(loaders, dataset, addUrl2, false, { obsType, featureType, featureValueType });
|
|
194653
|
+
const cellsCount = (obsIndex == null ? void 0 : obsIndex.length) || 0;
|
|
194654
|
+
const isReady = useReady([
|
|
194655
|
+
obsSetsStatus,
|
|
194656
|
+
featureSelectionColorStatus,
|
|
194657
|
+
featureSelectionXStatus,
|
|
194658
|
+
featureSelectionYStatus,
|
|
194659
|
+
matrixIndicesStatus
|
|
194660
|
+
]);
|
|
194661
|
+
const obsXY = React$i.useMemo(() => {
|
|
194662
|
+
if (!(cellsCount && (expressionDataX == null ? void 0 : expressionDataX[0]) && (expressionDataY == null ? void 0 : expressionDataY[0]) && featureSelectionX && featureSelectionY)) {
|
|
194663
|
+
return null;
|
|
194664
|
+
}
|
|
194665
|
+
let coefficient = 1;
|
|
194666
|
+
const parsedTransformCoefficient = Number(featureValueTransformCoefficient);
|
|
194667
|
+
if (!Number.isNaN(parsedTransformCoefficient) && parsedTransformCoefficient > 0) {
|
|
194668
|
+
coefficient = parsedTransformCoefficient;
|
|
194669
|
+
}
|
|
194670
|
+
const transformFunction = getValueTransformFunction(featureValueTransform, coefficient);
|
|
194671
|
+
const obsX = new Float32Array(cellsCount);
|
|
194672
|
+
const obsY = new Float32Array(cellsCount);
|
|
194673
|
+
for (let i2 = 0; i2 < cellsCount; i2 += 1) {
|
|
194674
|
+
obsX[i2] = transformFunction(expressionDataX[0][i2]);
|
|
194675
|
+
obsY[i2] = transformFunction(expressionDataY[0][i2]);
|
|
194676
|
+
}
|
|
194677
|
+
return {
|
|
194678
|
+
data: [obsX, obsY],
|
|
194679
|
+
shape: [2, cellsCount]
|
|
194680
|
+
};
|
|
194681
|
+
}, [
|
|
194682
|
+
cellsCount,
|
|
194683
|
+
expressionDataX,
|
|
194684
|
+
expressionDataY,
|
|
194685
|
+
featureValueTransform,
|
|
194686
|
+
featureValueTransformCoefficient,
|
|
194687
|
+
featureSelectionX,
|
|
194688
|
+
featureSelectionY
|
|
194689
|
+
]);
|
|
194690
|
+
const [dynamicCellRadius, setDynamicCellRadius] = React$i.useState(cellRadiusFixed);
|
|
194691
|
+
const [dynamicCellOpacity, setDynamicCellOpacity] = React$i.useState(cellOpacityFixed);
|
|
194692
|
+
const mergedCellSets = React$i.useMemo(() => mergeObsSets(cellSets, additionalCellSets), [cellSets, additionalCellSets]);
|
|
194693
|
+
const setCellSelectionProp = React$i.useCallback((v) => {
|
|
194694
|
+
setObsSelection(v, additionalCellSets, cellSetColor, setCellSetSelection, setAdditionalCellSets, setCellSetColor, setCellColorEncoding);
|
|
194695
|
+
}, [
|
|
194696
|
+
additionalCellSets,
|
|
194697
|
+
cellSetColor,
|
|
194698
|
+
setCellColorEncoding,
|
|
194699
|
+
setAdditionalCellSets,
|
|
194700
|
+
setCellSetColor,
|
|
194701
|
+
setCellSetSelection
|
|
194702
|
+
]);
|
|
194703
|
+
const cellColors = React$i.useMemo(() => getCellColors({
|
|
194704
|
+
cellColorEncoding,
|
|
194705
|
+
expressionData: expressionDataColor && expressionDataColor[0],
|
|
194706
|
+
geneSelection: gatingFeatureSelectionColor,
|
|
194707
|
+
cellSets: mergedCellSets,
|
|
194708
|
+
cellSetSelection,
|
|
194709
|
+
cellSetColor,
|
|
194710
|
+
obsIndex,
|
|
194711
|
+
theme
|
|
194712
|
+
}), [
|
|
194713
|
+
cellColorEncoding,
|
|
194714
|
+
gatingFeatureSelectionColor,
|
|
194715
|
+
mergedCellSets,
|
|
194716
|
+
theme,
|
|
194717
|
+
cellSetSelection,
|
|
194718
|
+
cellSetColor,
|
|
194719
|
+
expressionDataColor,
|
|
194720
|
+
obsIndex
|
|
194721
|
+
]);
|
|
194722
|
+
const [cellSetPolygonCache, setCellSetPolygonCache] = React$i.useState([]);
|
|
194723
|
+
const cacheHas2 = (cache2, key2) => cache2.findIndex((el2) => isEqual_1(el2[0], key2)) !== -1;
|
|
194724
|
+
const cacheGet = (cache2, key2) => {
|
|
194725
|
+
var _a3;
|
|
194726
|
+
return (_a3 = cache2.find((el2) => isEqual_1(el2[0], key2))) == null ? void 0 : _a3[1];
|
|
194727
|
+
};
|
|
194728
|
+
const cellSetPolygons = React$i.useMemo(() => {
|
|
194729
|
+
var _a3;
|
|
194730
|
+
if ((cellSetLabelsVisible || cellSetPolygonsVisible) && !cacheHas2(cellSetPolygonCache, cellSetSelection) && ((_a3 = mergedCellSets == null ? void 0 : mergedCellSets.tree) == null ? void 0 : _a3.length) && obsXY && obsIndex && (cellSetColor == null ? void 0 : cellSetColor.length)) {
|
|
194731
|
+
const newCellSetPolygons = getCellSetPolygons({
|
|
194732
|
+
obsIndex,
|
|
194733
|
+
obsEmbedding: obsXY,
|
|
194734
|
+
cellSets: mergedCellSets,
|
|
194735
|
+
cellSetSelection,
|
|
194736
|
+
cellSetColor,
|
|
194737
|
+
theme
|
|
194738
|
+
});
|
|
194739
|
+
setCellSetPolygonCache((cache2) => [...cache2, [cellSetSelection, newCellSetPolygons]]);
|
|
194740
|
+
return newCellSetPolygons;
|
|
194741
|
+
}
|
|
194742
|
+
return cacheGet(cellSetPolygonCache, cellSetSelection) || [];
|
|
194743
|
+
}, [
|
|
194744
|
+
cellSetPolygonsVisible,
|
|
194745
|
+
cellSetPolygonCache,
|
|
194746
|
+
cellSetLabelsVisible,
|
|
194747
|
+
theme,
|
|
194748
|
+
obsIndex,
|
|
194749
|
+
obsXY,
|
|
194750
|
+
mergedCellSets,
|
|
194751
|
+
cellSetSelection,
|
|
194752
|
+
cellSetColor
|
|
194753
|
+
]);
|
|
194754
|
+
const cellSelection = React$i.useMemo(() => Array.from(cellColors.keys()), [cellColors]);
|
|
194755
|
+
const [xRange, yRange, xExtent, yExtent, numCells] = React$i.useMemo(() => {
|
|
194756
|
+
if (obsXY && obsXY.data && obsXY.shape) {
|
|
194757
|
+
const cellCount = obsXY.shape[1];
|
|
194758
|
+
const xE = extent$2(obsXY.data[0]);
|
|
194759
|
+
const yE = extent$2(obsXY.data[1]);
|
|
194760
|
+
const xR = xE[1] - xE[0];
|
|
194761
|
+
const yR = yE[1] - yE[0];
|
|
194762
|
+
return [xR, yR, xE, yE, cellCount];
|
|
194763
|
+
}
|
|
194764
|
+
return [null, null, null, null, null];
|
|
194765
|
+
}, [obsXY]);
|
|
194766
|
+
React$i.useEffect(() => {
|
|
194767
|
+
if (xRange && yRange) {
|
|
194768
|
+
const pointSizeDevicePixels = getPointSizeDevicePixels(window.devicePixelRatio, zoom2, xRange, yRange, width2, height2);
|
|
194769
|
+
setDynamicCellRadius(pointSizeDevicePixels);
|
|
194770
|
+
const nextCellOpacityScale = getPointOpacity(zoom2, xRange, yRange, width2, height2, numCells, averageFillDensity);
|
|
194771
|
+
setDynamicCellOpacity(nextCellOpacityScale);
|
|
194772
|
+
if (typeof targetX2 !== "number" || typeof targetY2 !== "number") {
|
|
194773
|
+
const newTargetX = xExtent[0] + xRange / 2;
|
|
194774
|
+
const newTargetY = yExtent[0] + yRange / 2;
|
|
194775
|
+
const newZoom = Math.log2(Math.min(width2 / xRange, height2 / yRange));
|
|
194776
|
+
setTargetX(newTargetX);
|
|
194777
|
+
setTargetY(-newTargetY);
|
|
194778
|
+
setZoom(newZoom);
|
|
194779
|
+
}
|
|
194780
|
+
}
|
|
194781
|
+
}, [
|
|
194782
|
+
xRange,
|
|
194783
|
+
yRange,
|
|
194784
|
+
xExtent,
|
|
194785
|
+
yExtent,
|
|
194786
|
+
numCells,
|
|
194787
|
+
width2,
|
|
194788
|
+
height2,
|
|
194789
|
+
zoom2,
|
|
194790
|
+
averageFillDensity
|
|
194791
|
+
]);
|
|
194792
|
+
const cellSelectionSet = React$i.useMemo(() => new Set(cellSelection), [cellSelection]);
|
|
194793
|
+
const getCellIsSelected = React$i.useCallback((object2, { index: index2 }) => (cellSelectionSet || /* @__PURE__ */ new Set([])).has(obsIndex[index2]) ? 1 : 0, [cellSelectionSet, obsIndex]);
|
|
194794
|
+
const cellRadius = cellRadiusMode === "manual" ? cellRadiusFixed : dynamicCellRadius;
|
|
194795
|
+
const cellOpacity = cellOpacityMode === "manual" ? cellOpacityFixed : dynamicCellOpacity;
|
|
194796
|
+
const getExpressionValue = useExpressionValueGetter({
|
|
194797
|
+
instanceObsIndex: obsIndex,
|
|
194798
|
+
matrixObsIndex: obsIndex,
|
|
194799
|
+
expressionData: expressionDataColor
|
|
194800
|
+
});
|
|
194801
|
+
const getObsInfo = React$i.useCallback((obsId) => {
|
|
194802
|
+
var _a3;
|
|
194803
|
+
const selectedTransformName = (_a3 = VALUE_TRANSFORM_OPTIONS.find((o2) => o2.value === featureValueTransform)) == null ? void 0 : _a3.name;
|
|
194804
|
+
const genePrefix = featureValueTransform ? `${selectedTransformName} ` : "";
|
|
194805
|
+
const obsIdx = obsIndex == null ? void 0 : obsIndex.indexOf(obsId);
|
|
194806
|
+
const obsInfo = { [`${capitalize$2(obsType)} ID`]: obsId };
|
|
194807
|
+
if (gatingFeatureSelectionX && gatingFeatureSelectionY) {
|
|
194808
|
+
obsInfo[genePrefix + gatingFeatureSelectionX] = obsXY.data[0][obsIdx];
|
|
194809
|
+
obsInfo[genePrefix + gatingFeatureSelectionY] = obsXY.data[1][obsIdx];
|
|
194810
|
+
}
|
|
194811
|
+
return obsInfo;
|
|
194812
|
+
}, [
|
|
194813
|
+
obsXY,
|
|
194814
|
+
obsIndex,
|
|
194815
|
+
featureValueTransform,
|
|
194816
|
+
gatingFeatureSelectionX,
|
|
194817
|
+
gatingFeatureSelectionY,
|
|
194818
|
+
obsType
|
|
194819
|
+
]);
|
|
194820
|
+
return jsxs(TitleInfo, { title: title2, info: `${commaNumber(cellsCount)} ${plur(obsType, cellsCount)}`, removeGridComponent, urls: urls2, theme, isReady, options: jsx(ScatterplotOptions, { observationsLabel: obsType, cellRadius: cellRadiusFixed, setCellRadius: setCellRadiusFixed, cellRadiusMode, setCellRadiusMode, cellOpacity: cellOpacityFixed, setCellOpacity: setCellOpacityFixed, cellOpacityMode, setCellOpacityMode, cellSetLabelsVisible, setCellSetLabelsVisible, cellSetLabelSize, setCellSetLabelSize, cellSetPolygonsVisible, setCellSetPolygonsVisible, cellColorEncoding, setCellColorEncoding, geneExpressionColormap, setGeneExpressionColormap, geneExpressionColormapRange, setGeneExpressionColormapRange, children: jsx(GatingScatterplotOptions, { featureType, gatingFeatureSelectionX, setGatingFeatureSelectionX, gatingFeatureSelectionY, setGatingFeatureSelectionY, gatingFeatureValueTransform: featureValueTransform, setGatingFeatureValueTransform: (newValue) => {
|
|
194821
|
+
setFeatureValueTransform(newValue);
|
|
194822
|
+
setTargetX(null);
|
|
194823
|
+
setTargetY(null);
|
|
194824
|
+
setZoom(null);
|
|
194825
|
+
}, 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(ScatterplotWrapper, { ref: deckRef, uuid, theme, hideTools: !(gatingFeatureSelectionX && gatingFeatureSelectionY), viewState: { zoom: zoom2, target: [targetX2, targetY2, targetZ] }, setViewState: ({ zoom: newZoom, target: target2 }) => {
|
|
194826
|
+
setZoom(newZoom);
|
|
194827
|
+
setTargetX(target2[0]);
|
|
194828
|
+
setTargetY(target2[1]);
|
|
194829
|
+
setTargetZ(target2[2] || 0);
|
|
194830
|
+
}, obsEmbeddingIndex: obsIndex, obsEmbedding: obsXY, cellFilter, cellSelection, cellHighlight, cellColors, cellSetPolygons, cellSetLabelSize, cellSetLabelsVisible, cellSetPolygonsVisible, setCellFilter, setCellSelection: setCellSelectionProp, setCellHighlight, cellRadius, cellOpacity, cellColorEncoding, geneExpressionColormap, geneExpressionColormapRange, setComponentHover: () => {
|
|
194831
|
+
setComponentHover(uuid);
|
|
194832
|
+
}, updateViewInfo: setComponentViewInfo, getExpressionValue, getCellIsSelected }), !disableTooltip && jsx(ScatterplotTooltipSubscriber, { parentUuid: uuid, obsHighlight: cellHighlight, width: width2, height: height2, getObsInfo })] });
|
|
194833
|
+
}
|
|
194834
|
+
function register$b() {
|
|
194835
|
+
registerPluginViewType(ViewType$2.GATING, GatingSubscriber, COMPONENT_COORDINATION_TYPES[ViewType$2.GATING]);
|
|
194836
|
+
}
|
|
194837
|
+
var _extends$1 = { exports: {} };
|
|
194838
|
+
var hasRequired_extends;
|
|
194839
|
+
function require_extends() {
|
|
194840
|
+
if (hasRequired_extends)
|
|
194841
|
+
return _extends$1.exports;
|
|
194842
|
+
hasRequired_extends = 1;
|
|
194843
|
+
(function(module3) {
|
|
194844
|
+
function _extends2() {
|
|
194845
|
+
module3.exports = _extends2 = Object.assign ? Object.assign.bind() : function(target2) {
|
|
194846
|
+
for (var i2 = 1; i2 < arguments.length; i2++) {
|
|
194847
|
+
var source2 = arguments[i2];
|
|
194848
|
+
for (var key2 in source2) {
|
|
194849
|
+
if (Object.prototype.hasOwnProperty.call(source2, key2)) {
|
|
194850
|
+
target2[key2] = source2[key2];
|
|
194851
|
+
}
|
|
194852
|
+
}
|
|
194853
|
+
}
|
|
194854
|
+
return target2;
|
|
194855
|
+
}, module3.exports.__esModule = true, module3.exports["default"] = module3.exports;
|
|
194856
|
+
return _extends2.apply(this, arguments);
|
|
194857
|
+
}
|
|
194858
|
+
module3.exports = _extends2, module3.exports.__esModule = true, module3.exports["default"] = module3.exports;
|
|
194859
|
+
})(_extends$1);
|
|
194860
|
+
return _extends$1.exports;
|
|
194861
|
+
}
|
|
194862
|
+
var _extendsExports = require_extends();
|
|
194863
|
+
var DEFAULT_CONFIG = {
|
|
194864
|
+
epsilon: 1e-12,
|
|
194865
|
+
matrix: "Matrix",
|
|
194866
|
+
number: "number",
|
|
194867
|
+
precision: 64,
|
|
194868
|
+
predictable: false,
|
|
194869
|
+
randomSeed: null
|
|
194870
|
+
};
|
|
194871
|
+
function isNumber$2(x2) {
|
|
194872
|
+
return typeof x2 === "number";
|
|
194873
|
+
}
|
|
194874
|
+
function isBigNumber(x2) {
|
|
194875
|
+
if (!x2 || typeof x2 !== "object" || typeof x2.constructor !== "function") {
|
|
194876
|
+
return false;
|
|
194877
|
+
}
|
|
194878
|
+
if (x2.isBigNumber === true && typeof x2.constructor.prototype === "object" && x2.constructor.prototype.isBigNumber === true) {
|
|
194879
|
+
return true;
|
|
194880
|
+
}
|
|
194881
|
+
if (typeof x2.constructor.isDecimal === "function" && x2.constructor.isDecimal(x2) === true) {
|
|
194882
|
+
return true;
|
|
194883
|
+
}
|
|
194884
|
+
return false;
|
|
194885
|
+
}
|
|
194886
|
+
function isComplex(x2) {
|
|
194887
|
+
return x2 && typeof x2 === "object" && Object.getPrototypeOf(x2).isComplex === true || false;
|
|
194888
|
+
}
|
|
194889
|
+
function isFraction(x2) {
|
|
194890
|
+
return x2 && typeof x2 === "object" && Object.getPrototypeOf(x2).isFraction === true || false;
|
|
194891
|
+
}
|
|
194892
|
+
function isUnit(x2) {
|
|
194893
|
+
return x2 && x2.constructor.prototype.isUnit === true || false;
|
|
194894
|
+
}
|
|
194895
|
+
function isString$1(x2) {
|
|
194896
|
+
return typeof x2 === "string";
|
|
194897
|
+
}
|
|
194898
|
+
var isArray$1 = Array.isArray;
|
|
194899
|
+
function isMatrix(x2) {
|
|
194900
|
+
return x2 && x2.constructor.prototype.isMatrix === true || false;
|
|
194901
|
+
}
|
|
194902
|
+
function isCollection(x2) {
|
|
194903
|
+
return Array.isArray(x2) || isMatrix(x2);
|
|
194904
|
+
}
|
|
194905
|
+
function isDenseMatrix(x2) {
|
|
194906
|
+
return x2 && x2.isDenseMatrix && x2.constructor.prototype.isMatrix === true || false;
|
|
194907
|
+
}
|
|
194908
|
+
function isSparseMatrix(x2) {
|
|
194909
|
+
return x2 && x2.isSparseMatrix && x2.constructor.prototype.isMatrix === true || false;
|
|
194910
|
+
}
|
|
194911
|
+
function isRange(x2) {
|
|
194912
|
+
return x2 && x2.constructor.prototype.isRange === true || false;
|
|
194913
|
+
}
|
|
194914
|
+
function isIndex(x2) {
|
|
194915
|
+
return x2 && x2.constructor.prototype.isIndex === true || false;
|
|
194916
|
+
}
|
|
194917
|
+
function isBoolean$3(x2) {
|
|
194918
|
+
return typeof x2 === "boolean";
|
|
194919
|
+
}
|
|
194920
|
+
function isResultSet(x2) {
|
|
194921
|
+
return x2 && x2.constructor.prototype.isResultSet === true || false;
|
|
194922
|
+
}
|
|
194923
|
+
function isHelp(x2) {
|
|
194924
|
+
return x2 && x2.constructor.prototype.isHelp === true || false;
|
|
194925
|
+
}
|
|
194926
|
+
function isFunction$2(x2) {
|
|
194927
|
+
return typeof x2 === "function";
|
|
194928
|
+
}
|
|
194929
|
+
function isDate$2(x2) {
|
|
194930
|
+
return x2 instanceof Date;
|
|
194931
|
+
}
|
|
194932
|
+
function isRegExp$1(x2) {
|
|
194933
|
+
return x2 instanceof RegExp;
|
|
194934
|
+
}
|
|
194935
|
+
function isObject$1(x2) {
|
|
194936
|
+
return !!(x2 && typeof x2 === "object" && x2.constructor === Object && !isComplex(x2) && !isFraction(x2));
|
|
194937
|
+
}
|
|
194938
|
+
function isNull(x2) {
|
|
194939
|
+
return x2 === null;
|
|
194940
|
+
}
|
|
194941
|
+
function isUndefined(x2) {
|
|
194942
|
+
return x2 === void 0;
|
|
194943
|
+
}
|
|
194944
|
+
function isAccessorNode(x2) {
|
|
194945
|
+
return x2 && x2.isAccessorNode === true && x2.constructor.prototype.isNode === true || false;
|
|
194946
|
+
}
|
|
194947
|
+
function isArrayNode(x2) {
|
|
194948
|
+
return x2 && x2.isArrayNode === true && x2.constructor.prototype.isNode === true || false;
|
|
194949
|
+
}
|
|
194950
|
+
function isAssignmentNode(x2) {
|
|
194951
|
+
return x2 && x2.isAssignmentNode === true && x2.constructor.prototype.isNode === true || false;
|
|
194952
|
+
}
|
|
194953
|
+
function isBlockNode(x2) {
|
|
194954
|
+
return x2 && x2.isBlockNode === true && x2.constructor.prototype.isNode === true || false;
|
|
194955
|
+
}
|
|
194956
|
+
function isConditionalNode(x2) {
|
|
194957
|
+
return x2 && x2.isConditionalNode === true && x2.constructor.prototype.isNode === true || false;
|
|
194958
|
+
}
|
|
194959
|
+
function isConstantNode(x2) {
|
|
194960
|
+
return x2 && x2.isConstantNode === true && x2.constructor.prototype.isNode === true || false;
|
|
194961
|
+
}
|
|
194962
|
+
function isFunctionAssignmentNode(x2) {
|
|
194963
|
+
return x2 && x2.isFunctionAssignmentNode === true && x2.constructor.prototype.isNode === true || false;
|
|
194964
|
+
}
|
|
194965
|
+
function isFunctionNode(x2) {
|
|
194966
|
+
return x2 && x2.isFunctionNode === true && x2.constructor.prototype.isNode === true || false;
|
|
194967
|
+
}
|
|
194968
|
+
function isIndexNode(x2) {
|
|
194969
|
+
return x2 && x2.isIndexNode === true && x2.constructor.prototype.isNode === true || false;
|
|
194970
|
+
}
|
|
194971
|
+
function isNode(x2) {
|
|
194972
|
+
return x2 && x2.isNode === true && x2.constructor.prototype.isNode === true || false;
|
|
194973
|
+
}
|
|
194974
|
+
function isObjectNode(x2) {
|
|
194975
|
+
return x2 && x2.isObjectNode === true && x2.constructor.prototype.isNode === true || false;
|
|
194976
|
+
}
|
|
194977
|
+
function isOperatorNode(x2) {
|
|
194978
|
+
return x2 && x2.isOperatorNode === true && x2.constructor.prototype.isNode === true || false;
|
|
194979
|
+
}
|
|
194980
|
+
function isParenthesisNode(x2) {
|
|
194981
|
+
return x2 && x2.isParenthesisNode === true && x2.constructor.prototype.isNode === true || false;
|
|
194982
|
+
}
|
|
194983
|
+
function isRangeNode(x2) {
|
|
194984
|
+
return x2 && x2.isRangeNode === true && x2.constructor.prototype.isNode === true || false;
|
|
194985
|
+
}
|
|
194986
|
+
function isSymbolNode(x2) {
|
|
194987
|
+
return x2 && x2.isSymbolNode === true && x2.constructor.prototype.isNode === true || false;
|
|
194988
|
+
}
|
|
194989
|
+
function isChain(x2) {
|
|
194990
|
+
return x2 && x2.constructor.prototype.isChain === true || false;
|
|
194991
|
+
}
|
|
194992
|
+
function typeOf(x2) {
|
|
194993
|
+
var t4 = typeof x2;
|
|
194994
|
+
if (t4 === "object") {
|
|
194995
|
+
if (x2 === null)
|
|
194996
|
+
return "null";
|
|
194997
|
+
if (Array.isArray(x2))
|
|
194998
|
+
return "Array";
|
|
194999
|
+
if (x2 instanceof Date)
|
|
195000
|
+
return "Date";
|
|
195001
|
+
if (x2 instanceof RegExp)
|
|
195002
|
+
return "RegExp";
|
|
195003
|
+
if (isBigNumber(x2))
|
|
195004
|
+
return "BigNumber";
|
|
195005
|
+
if (isComplex(x2))
|
|
195006
|
+
return "Complex";
|
|
195007
|
+
if (isFraction(x2))
|
|
195008
|
+
return "Fraction";
|
|
195009
|
+
if (isMatrix(x2))
|
|
195010
|
+
return "Matrix";
|
|
195011
|
+
if (isUnit(x2))
|
|
195012
|
+
return "Unit";
|
|
195013
|
+
if (isIndex(x2))
|
|
195014
|
+
return "Index";
|
|
195015
|
+
if (isRange(x2))
|
|
195016
|
+
return "Range";
|
|
195017
|
+
if (isResultSet(x2))
|
|
195018
|
+
return "ResultSet";
|
|
195019
|
+
if (isNode(x2))
|
|
195020
|
+
return x2.type;
|
|
195021
|
+
if (isChain(x2))
|
|
195022
|
+
return "Chain";
|
|
195023
|
+
if (isHelp(x2))
|
|
195024
|
+
return "Help";
|
|
195025
|
+
return "Object";
|
|
195026
|
+
}
|
|
195027
|
+
if (t4 === "function")
|
|
195028
|
+
return "Function";
|
|
195029
|
+
return t4;
|
|
195030
|
+
}
|
|
195031
|
+
function clone$2(x2) {
|
|
195032
|
+
var type2 = typeof x2;
|
|
195033
|
+
if (type2 === "number" || type2 === "string" || type2 === "boolean" || x2 === null || x2 === void 0) {
|
|
195034
|
+
return x2;
|
|
195035
|
+
}
|
|
195036
|
+
if (typeof x2.clone === "function") {
|
|
195037
|
+
return x2.clone();
|
|
195038
|
+
}
|
|
195039
|
+
if (Array.isArray(x2)) {
|
|
195040
|
+
return x2.map(function(value2) {
|
|
195041
|
+
return clone$2(value2);
|
|
195042
|
+
});
|
|
195043
|
+
}
|
|
195044
|
+
if (x2 instanceof Date)
|
|
195045
|
+
return new Date(x2.valueOf());
|
|
195046
|
+
if (isBigNumber(x2))
|
|
195047
|
+
return x2;
|
|
195048
|
+
if (x2 instanceof RegExp)
|
|
195049
|
+
throw new TypeError("Cannot clone " + x2);
|
|
195050
|
+
return mapObject(x2, clone$2);
|
|
195051
|
+
}
|
|
195052
|
+
function mapObject(object2, callback) {
|
|
195053
|
+
var clone2 = {};
|
|
195054
|
+
for (var key2 in object2) {
|
|
195055
|
+
if (hasOwnProperty$2(object2, key2)) {
|
|
195056
|
+
clone2[key2] = callback(object2[key2]);
|
|
195057
|
+
}
|
|
195058
|
+
}
|
|
195059
|
+
return clone2;
|
|
195060
|
+
}
|
|
195061
|
+
function extend$2(a2, b2) {
|
|
195062
|
+
for (var prop in b2) {
|
|
195063
|
+
if (hasOwnProperty$2(b2, prop)) {
|
|
195064
|
+
a2[prop] = b2[prop];
|
|
195065
|
+
}
|
|
195066
|
+
}
|
|
195067
|
+
return a2;
|
|
195068
|
+
}
|
|
195069
|
+
function deepStrictEqual(a2, b2) {
|
|
195070
|
+
var prop, i2, len2;
|
|
195071
|
+
if (Array.isArray(a2)) {
|
|
195072
|
+
if (!Array.isArray(b2)) {
|
|
195073
|
+
return false;
|
|
195074
|
+
}
|
|
195075
|
+
if (a2.length !== b2.length) {
|
|
195076
|
+
return false;
|
|
195077
|
+
}
|
|
195078
|
+
for (i2 = 0, len2 = a2.length; i2 < len2; i2++) {
|
|
195079
|
+
if (!deepStrictEqual(a2[i2], b2[i2])) {
|
|
195080
|
+
return false;
|
|
195081
|
+
}
|
|
195082
|
+
}
|
|
195083
|
+
return true;
|
|
195084
|
+
} else if (typeof a2 === "function") {
|
|
195085
|
+
return a2 === b2;
|
|
195086
|
+
} else if (a2 instanceof Object) {
|
|
195087
|
+
if (Array.isArray(b2) || !(b2 instanceof Object)) {
|
|
195088
|
+
return false;
|
|
195089
|
+
}
|
|
195090
|
+
for (prop in a2) {
|
|
195091
|
+
if (!(prop in b2) || !deepStrictEqual(a2[prop], b2[prop])) {
|
|
195092
|
+
return false;
|
|
195093
|
+
}
|
|
195094
|
+
}
|
|
195095
|
+
for (prop in b2) {
|
|
195096
|
+
if (!(prop in a2)) {
|
|
195097
|
+
return false;
|
|
195098
|
+
}
|
|
195099
|
+
}
|
|
195100
|
+
return true;
|
|
195101
|
+
} else {
|
|
195102
|
+
return a2 === b2;
|
|
195103
|
+
}
|
|
195104
|
+
}
|
|
195105
|
+
function hasOwnProperty$2(object2, property2) {
|
|
195106
|
+
return object2 && Object.hasOwnProperty.call(object2, property2);
|
|
195107
|
+
}
|
|
195108
|
+
function pickShallow(object2, properties2) {
|
|
195109
|
+
var copy2 = {};
|
|
195110
|
+
for (var i2 = 0; i2 < properties2.length; i2++) {
|
|
195111
|
+
var key2 = properties2[i2];
|
|
195112
|
+
var value2 = object2[key2];
|
|
195113
|
+
if (value2 !== void 0) {
|
|
195114
|
+
copy2[key2] = value2;
|
|
195115
|
+
}
|
|
195116
|
+
}
|
|
195117
|
+
return copy2;
|
|
195118
|
+
}
|
|
195119
|
+
var MATRIX_OPTIONS = ["Matrix", "Array"];
|
|
195120
|
+
var NUMBER_OPTIONS = ["number", "BigNumber", "Fraction"];
|
|
195121
|
+
var config$1 = function config2(options) {
|
|
195122
|
+
if (options) {
|
|
195123
|
+
throw new Error("The global config is readonly. \nPlease create a mathjs instance if you want to change the default configuration. \nExample:\n\n import { create, all } from 'mathjs';\n const mathjs = create(all);\n mathjs.config({ number: 'BigNumber' });\n");
|
|
195124
|
+
}
|
|
195125
|
+
return Object.freeze(DEFAULT_CONFIG);
|
|
195126
|
+
};
|
|
195127
|
+
_extendsExports(config$1, DEFAULT_CONFIG, {
|
|
195128
|
+
MATRIX_OPTIONS,
|
|
195129
|
+
NUMBER_OPTIONS
|
|
195130
|
+
});
|
|
195131
|
+
var typedFunction$1 = { exports: {} };
|
|
195132
|
+
(function(module3, exports3) {
|
|
195133
|
+
(function(root2, factory2) {
|
|
195134
|
+
{
|
|
195135
|
+
module3.exports = factory2();
|
|
195136
|
+
}
|
|
195137
|
+
})(commonjsGlobal$1, function() {
|
|
195138
|
+
function ok() {
|
|
195139
|
+
return true;
|
|
195140
|
+
}
|
|
195141
|
+
function notOk() {
|
|
195142
|
+
return false;
|
|
195143
|
+
}
|
|
195144
|
+
function undef() {
|
|
195145
|
+
return void 0;
|
|
195146
|
+
}
|
|
195147
|
+
function create2() {
|
|
195148
|
+
var _types = [
|
|
195149
|
+
{ name: "number", test: function(x2) {
|
|
195150
|
+
return typeof x2 === "number";
|
|
195151
|
+
} },
|
|
195152
|
+
{ name: "string", test: function(x2) {
|
|
195153
|
+
return typeof x2 === "string";
|
|
195154
|
+
} },
|
|
195155
|
+
{ name: "boolean", test: function(x2) {
|
|
195156
|
+
return typeof x2 === "boolean";
|
|
195157
|
+
} },
|
|
195158
|
+
{ name: "Function", test: function(x2) {
|
|
195159
|
+
return typeof x2 === "function";
|
|
195160
|
+
} },
|
|
195161
|
+
{ name: "Array", test: Array.isArray },
|
|
195162
|
+
{ name: "Date", test: function(x2) {
|
|
195163
|
+
return x2 instanceof Date;
|
|
195164
|
+
} },
|
|
195165
|
+
{ name: "RegExp", test: function(x2) {
|
|
195166
|
+
return x2 instanceof RegExp;
|
|
195167
|
+
} },
|
|
195168
|
+
{ name: "Object", test: function(x2) {
|
|
195169
|
+
return typeof x2 === "object" && x2 !== null && x2.constructor === Object;
|
|
195170
|
+
} },
|
|
195171
|
+
{ name: "null", test: function(x2) {
|
|
195172
|
+
return x2 === null;
|
|
195173
|
+
} },
|
|
195174
|
+
{ name: "undefined", test: function(x2) {
|
|
195175
|
+
return x2 === void 0;
|
|
195176
|
+
} }
|
|
195177
|
+
];
|
|
195178
|
+
var anyType = {
|
|
195179
|
+
name: "any",
|
|
195180
|
+
test: ok
|
|
195181
|
+
};
|
|
195182
|
+
var _ignore = [];
|
|
195183
|
+
var _conversions = [];
|
|
195184
|
+
var typed2 = {
|
|
195185
|
+
types: _types,
|
|
195186
|
+
conversions: _conversions,
|
|
195187
|
+
ignore: _ignore
|
|
195188
|
+
};
|
|
195189
|
+
function findTypeByName(typeName) {
|
|
195190
|
+
var entry2 = findInArray2(typed2.types, function(entry3) {
|
|
195191
|
+
return entry3.name === typeName;
|
|
195192
|
+
});
|
|
195193
|
+
if (entry2) {
|
|
195194
|
+
return entry2;
|
|
195195
|
+
}
|
|
195196
|
+
if (typeName === "any") {
|
|
195197
|
+
return anyType;
|
|
195198
|
+
}
|
|
195199
|
+
var hint2 = findInArray2(typed2.types, function(entry3) {
|
|
195200
|
+
return entry3.name.toLowerCase() === typeName.toLowerCase();
|
|
195201
|
+
});
|
|
195202
|
+
throw new TypeError('Unknown type "' + typeName + '"' + (hint2 ? '. Did you mean "' + hint2.name + '"?' : ""));
|
|
195203
|
+
}
|
|
195204
|
+
function findTypeIndex(type2) {
|
|
195205
|
+
if (type2 === anyType) {
|
|
195206
|
+
return 999;
|
|
195207
|
+
}
|
|
195208
|
+
return typed2.types.indexOf(type2);
|
|
195209
|
+
}
|
|
195210
|
+
function findTypeName(value2) {
|
|
195211
|
+
var entry2 = findInArray2(typed2.types, function(entry3) {
|
|
195212
|
+
return entry3.test(value2);
|
|
195213
|
+
});
|
|
195214
|
+
if (entry2) {
|
|
195215
|
+
return entry2.name;
|
|
195216
|
+
}
|
|
195217
|
+
throw new TypeError("Value has unknown type. Value: " + value2);
|
|
195218
|
+
}
|
|
195219
|
+
function find2(fn, signature) {
|
|
195220
|
+
if (!fn.signatures) {
|
|
194051
195221
|
throw new TypeError("Function is no typed-function");
|
|
194052
195222
|
}
|
|
194053
195223
|
var arr;
|
|
@@ -197831,7 +199001,7 @@ void main() {
|
|
|
197831
199001
|
function ceil$2(x2) {
|
|
197832
199002
|
return finalise(x2 = new this(x2), x2.e + 1, 2);
|
|
197833
199003
|
}
|
|
197834
|
-
function clamp$
|
|
199004
|
+
function clamp$1(x2, min2, max2) {
|
|
197835
199005
|
return new this(x2).clamp(min2, max2);
|
|
197836
199006
|
}
|
|
197837
199007
|
function config(obj) {
|
|
@@ -198000,7 +199170,7 @@ void main() {
|
|
|
198000
199170
|
Decimal2.atan2 = atan2$2;
|
|
198001
199171
|
Decimal2.cbrt = cbrt;
|
|
198002
199172
|
Decimal2.ceil = ceil$2;
|
|
198003
|
-
Decimal2.clamp = clamp$
|
|
199173
|
+
Decimal2.clamp = clamp$1;
|
|
198004
199174
|
Decimal2.cos = cos$3;
|
|
198005
199175
|
Decimal2.cosh = cosh$1;
|
|
198006
199176
|
Decimal2.div = div;
|
|
@@ -208417,1157 +209587,6 @@ void main() {
|
|
|
208417
209587
|
const autoImageLayerDefs = await Promise.all(autoImageLayerDefPromises);
|
|
208418
209588
|
return [autoImageLayerDefs, nextImageLoaders, nextImageMetaAndLayers];
|
|
208419
209589
|
}
|
|
208420
|
-
const useStyles$8 = makeStyles(() => ({
|
|
208421
|
-
tool: {
|
|
208422
|
-
position: "absolute",
|
|
208423
|
-
display: "inline",
|
|
208424
|
-
zIndex: "1000",
|
|
208425
|
-
opacity: ".65",
|
|
208426
|
-
color: "black",
|
|
208427
|
-
"&:hover": {
|
|
208428
|
-
opacity: ".90"
|
|
208429
|
-
}
|
|
208430
|
-
},
|
|
208431
|
-
iconButton: {
|
|
208432
|
-
padding: "0",
|
|
208433
|
-
height: "2em",
|
|
208434
|
-
width: "2em",
|
|
208435
|
-
backgroundColor: "white",
|
|
208436
|
-
display: "inline-block",
|
|
208437
|
-
fontWeight: "400",
|
|
208438
|
-
textAlign: "center",
|
|
208439
|
-
verticalAlign: "middle",
|
|
208440
|
-
cursor: "pointer",
|
|
208441
|
-
userSelect: "none",
|
|
208442
|
-
border: "1px solid #6c757d",
|
|
208443
|
-
fontSize: "1rem",
|
|
208444
|
-
lineHeight: "1.5",
|
|
208445
|
-
borderRadius: "0.25rem",
|
|
208446
|
-
transition: "color 0.15s ease-in-out, background-color 0.15s ease-in-out, border-color 0.15s ease-in-out, box-shadow 0.15s ease-in-out",
|
|
208447
|
-
color: "#6c757d",
|
|
208448
|
-
marginRight: "0.5rem",
|
|
208449
|
-
"& > svg": {
|
|
208450
|
-
verticalAlign: "middle"
|
|
208451
|
-
}
|
|
208452
|
-
},
|
|
208453
|
-
iconButtonActive: {
|
|
208454
|
-
color: "#fff",
|
|
208455
|
-
backgroundColor: "#6c757d",
|
|
208456
|
-
borderColor: "#6c757d",
|
|
208457
|
-
boxShadow: "0 0 0 0.2rem rgba(108, 117, 125, 0.5)"
|
|
208458
|
-
}
|
|
208459
|
-
}));
|
|
208460
|
-
function IconButton(props2) {
|
|
208461
|
-
const { alt, onClick, isActive: isActive2, children: children2 } = props2;
|
|
208462
|
-
const classes = useStyles$8();
|
|
208463
|
-
return jsx("button", { className: clsx(classes.iconButton, { [classes.iconButtonActive]: isActive2 }), onClick, type: "button", title: alt, children: children2 });
|
|
208464
|
-
}
|
|
208465
|
-
function ToolMenu(props2) {
|
|
208466
|
-
const { setActiveTool, activeTool, visibleTools = { pan: true, selectRectangle: true, selectLasso: true } } = props2;
|
|
208467
|
-
const classes = useStyles$8();
|
|
208468
|
-
return jsxs("div", { className: classes.tool, children: [visibleTools.pan && jsx(IconButton, { alt: "pointer tool", onClick: () => setActiveTool(null), isActive: activeTool === null, children: jsx(SvgNearMe, {}) }), visibleTools.selectRectangle ? jsx(IconButton, { alt: "select rectangle", onClick: () => setActiveTool(distEs6$2.SELECTION_TYPE.RECTANGLE), isActive: activeTool === distEs6$2.SELECTION_TYPE.RECTANGLE, children: jsx(SvgSelectionRectangle, {}) }) : null, visibleTools.selectLasso ? jsx(IconButton, { alt: "select lasso", onClick: () => setActiveTool(distEs6$2.SELECTION_TYPE.POLYGON), isActive: activeTool === distEs6$2.SELECTION_TYPE.POLYGON, children: jsx(SvgSelectionLasso, {}) }) : null] });
|
|
208469
|
-
}
|
|
208470
|
-
const getCursorWithTool = () => "crosshair";
|
|
208471
|
-
const getCursor = (interactionState) => interactionState.isDragging ? "grabbing" : "default";
|
|
208472
|
-
function getOnHoverCallback(obsIndex, setObsHighlight, setComponentHover) {
|
|
208473
|
-
return (info2) => {
|
|
208474
|
-
if (setComponentHover) {
|
|
208475
|
-
setComponentHover();
|
|
208476
|
-
}
|
|
208477
|
-
if (info2.index) {
|
|
208478
|
-
const obsId = obsIndex[info2.index];
|
|
208479
|
-
if (setObsHighlight) {
|
|
208480
|
-
setObsHighlight(obsId);
|
|
208481
|
-
}
|
|
208482
|
-
} else if (setObsHighlight) {
|
|
208483
|
-
setObsHighlight(null);
|
|
208484
|
-
}
|
|
208485
|
-
};
|
|
208486
|
-
}
|
|
208487
|
-
class AbstractSpatialOrScatterplot extends React$i.PureComponent {
|
|
208488
|
-
constructor(props2) {
|
|
208489
|
-
super(props2);
|
|
208490
|
-
this.state = {
|
|
208491
|
-
gl: null,
|
|
208492
|
-
tool: null
|
|
208493
|
-
};
|
|
208494
|
-
this.viewport = null;
|
|
208495
|
-
this.onViewStateChange = this.onViewStateChange.bind(this);
|
|
208496
|
-
this.onInitializeViewInfo = this.onInitializeViewInfo.bind(this);
|
|
208497
|
-
this.onWebGLInitialized = this.onWebGLInitialized.bind(this);
|
|
208498
|
-
this.onToolChange = this.onToolChange.bind(this);
|
|
208499
|
-
this.onHover = this.onHover.bind(this);
|
|
208500
|
-
}
|
|
208501
|
-
onViewStateChange({ viewState: nextViewState }) {
|
|
208502
|
-
const { setViewState, viewState, layers, spatialAxisFixed } = this.props;
|
|
208503
|
-
const use3d = layers == null ? void 0 : layers.some((l2) => l2.use3d);
|
|
208504
|
-
setViewState({
|
|
208505
|
-
...nextViewState,
|
|
208506
|
-
target: spatialAxisFixed && use3d ? viewState.target : nextViewState.target
|
|
208507
|
-
});
|
|
208508
|
-
}
|
|
208509
|
-
onInitializeViewInfo({ viewport }) {
|
|
208510
|
-
this.viewport = viewport;
|
|
208511
|
-
}
|
|
208512
|
-
onWebGLInitialized(gl) {
|
|
208513
|
-
this.setState({ gl });
|
|
208514
|
-
}
|
|
208515
|
-
onToolChange(tool) {
|
|
208516
|
-
const { onToolChange: onToolChangeProp } = this.props;
|
|
208517
|
-
this.setState({ tool });
|
|
208518
|
-
if (onToolChangeProp) {
|
|
208519
|
-
onToolChangeProp(tool);
|
|
208520
|
-
}
|
|
208521
|
-
}
|
|
208522
|
-
getLayers() {
|
|
208523
|
-
return [];
|
|
208524
|
-
}
|
|
208525
|
-
onHover(info2) {
|
|
208526
|
-
const { coordinate, sourceLayer: layer, tile } = info2;
|
|
208527
|
-
const { setCellHighlight, cellHighlight, setComponentHover, layers } = this.props;
|
|
208528
|
-
const hasBitmask = (layers || []).some((l2) => l2.type === "bitmask");
|
|
208529
|
-
if (!setCellHighlight || !tile) {
|
|
208530
|
-
return null;
|
|
208531
|
-
}
|
|
208532
|
-
if (!layer || !coordinate) {
|
|
208533
|
-
if (cellHighlight && hasBitmask) {
|
|
208534
|
-
setCellHighlight(null);
|
|
208535
|
-
}
|
|
208536
|
-
return null;
|
|
208537
|
-
}
|
|
208538
|
-
const { content: content2, bbox: bbox2, z } = tile;
|
|
208539
|
-
if (!content2) {
|
|
208540
|
-
if (cellHighlight && hasBitmask) {
|
|
208541
|
-
setCellHighlight(null);
|
|
208542
|
-
}
|
|
208543
|
-
return null;
|
|
208544
|
-
}
|
|
208545
|
-
const { data: data2, width: width2, height: height2 } = content2;
|
|
208546
|
-
const { left: left2, right: right2, top: top2, bottom: bottom2 } = bbox2;
|
|
208547
|
-
const bounds2 = [
|
|
208548
|
-
left2,
|
|
208549
|
-
data2.height < layer.tileSize ? height2 : bottom2,
|
|
208550
|
-
data2.width < layer.tileSize ? width2 : right2,
|
|
208551
|
-
top2
|
|
208552
|
-
];
|
|
208553
|
-
if (!data2) {
|
|
208554
|
-
if (cellHighlight && hasBitmask) {
|
|
208555
|
-
setCellHighlight(null);
|
|
208556
|
-
}
|
|
208557
|
-
return null;
|
|
208558
|
-
}
|
|
208559
|
-
if (layer.id.includes("bitmask")) {
|
|
208560
|
-
const layerZoomScale = Math.max(1, 2 ** Math.round(-z));
|
|
208561
|
-
const dataCoords = [
|
|
208562
|
-
Math.floor((coordinate[0] - bounds2[0]) / layerZoomScale),
|
|
208563
|
-
Math.floor((coordinate[1] - bounds2[3]) / layerZoomScale)
|
|
208564
|
-
];
|
|
208565
|
-
const coords = dataCoords[1] * width2 + dataCoords[0];
|
|
208566
|
-
const hoverData = data2.map((d) => d[coords]);
|
|
208567
|
-
const cellId = hoverData.find((i2) => i2 > 0);
|
|
208568
|
-
if (cellId !== Number(cellHighlight)) {
|
|
208569
|
-
if (setComponentHover) {
|
|
208570
|
-
setComponentHover();
|
|
208571
|
-
}
|
|
208572
|
-
setCellHighlight(cellId ? String(cellId) : null);
|
|
208573
|
-
}
|
|
208574
|
-
}
|
|
208575
|
-
}
|
|
208576
|
-
viewInfoDidUpdate(obsIndex, obsLocations, makeGetObsCoords) {
|
|
208577
|
-
const { updateViewInfo, uuid } = this.props;
|
|
208578
|
-
const { viewport } = this;
|
|
208579
|
-
if (updateViewInfo && viewport) {
|
|
208580
|
-
updateViewInfo({
|
|
208581
|
-
uuid,
|
|
208582
|
-
project: (obsId) => {
|
|
208583
|
-
try {
|
|
208584
|
-
if (obsIndex && obsLocations) {
|
|
208585
|
-
const getObsCoords = makeGetObsCoords(obsLocations);
|
|
208586
|
-
const obsIdx = obsIndex.indexOf(obsId);
|
|
208587
|
-
const obsCoord = getObsCoords(obsIdx);
|
|
208588
|
-
return viewport.project(obsCoord);
|
|
208589
|
-
}
|
|
208590
|
-
return [null, null];
|
|
208591
|
-
} catch (e3) {
|
|
208592
|
-
return [null, null];
|
|
208593
|
-
}
|
|
208594
|
-
}
|
|
208595
|
-
});
|
|
208596
|
-
}
|
|
208597
|
-
}
|
|
208598
|
-
componentDidUpdate() {
|
|
208599
|
-
}
|
|
208600
|
-
use3d() {
|
|
208601
|
-
return false;
|
|
208602
|
-
}
|
|
208603
|
-
render() {
|
|
208604
|
-
var _a3, _b2, _c, _d;
|
|
208605
|
-
const { deckRef, viewState, uuid, hideTools } = this.props;
|
|
208606
|
-
const { gl, tool } = this.state;
|
|
208607
|
-
const layers = this.getLayers();
|
|
208608
|
-
const use3d = this.use3d();
|
|
208609
|
-
const showCellSelectionTools = this.obsSegmentationsData !== null;
|
|
208610
|
-
const showPanTool = layers.length > 0;
|
|
208611
|
-
const useDevicePixels = !use3d && (((_b2 = (_a3 = this.obsSegmentationsData) == null ? void 0 : _a3.shape) == null ? void 0 : _b2[0]) < 1e5 || ((_d = (_c = this.obsLocationsData) == null ? void 0 : _c.shape) == null ? void 0 : _d[1]) < 1e5);
|
|
208612
|
-
return jsxs(Fragment, { children: [jsx(ToolMenu, { activeTool: tool, setActiveTool: this.onToolChange, visibleTools: {
|
|
208613
|
-
pan: showPanTool && !hideTools,
|
|
208614
|
-
selectRectangle: showCellSelectionTools && !hideTools,
|
|
208615
|
-
selectLasso: showCellSelectionTools && !hideTools
|
|
208616
|
-
} }), jsx(DeckGL$1, { id: `deckgl-overlay-${uuid}`, ref: deckRef, views: [
|
|
208617
|
-
use3d ? new OrbitView({ id: "orbit", controller: true, orbitAxis: "Y" }) : new OrthographicView({
|
|
208618
|
-
id: "ortho"
|
|
208619
|
-
})
|
|
208620
|
-
], layers: gl && viewState.target.slice(0, 2).every((i2) => typeof i2 === "number") ? layers : [], glOptions: DEFAULT_GL_OPTIONS, onWebGLInitialized: this.onWebGLInitialized, onViewStateChange: this.onViewStateChange, viewState, useDevicePixels, controller: tool ? { dragPan: false } : true, getCursor: tool ? getCursorWithTool : getCursor, onHover: this.onHover, children: this.onInitializeViewInfo })] });
|
|
208621
|
-
}
|
|
208622
|
-
}
|
|
208623
|
-
function createQuadTree(obsEmbedding, getCellCoords) {
|
|
208624
|
-
if (!obsEmbedding) {
|
|
208625
|
-
return null;
|
|
208626
|
-
}
|
|
208627
|
-
const tree2 = quadtree$1().x((i2) => getCellCoords(i2)[0]).y((i2) => getCellCoords(i2)[1]).addAll(range_1(obsEmbedding.shape[1]));
|
|
208628
|
-
return tree2;
|
|
208629
|
-
}
|
|
208630
|
-
function constant$5(v) {
|
|
208631
|
-
return () => v;
|
|
208632
|
-
}
|
|
208633
|
-
function jiggle$1(v) {
|
|
208634
|
-
return v + (Math.random() - 0.5) * 1e-6;
|
|
208635
|
-
}
|
|
208636
|
-
function forceCollideRects() {
|
|
208637
|
-
let nodes;
|
|
208638
|
-
let masses;
|
|
208639
|
-
let strength = 1;
|
|
208640
|
-
let iterations2 = 1;
|
|
208641
|
-
let sizes;
|
|
208642
|
-
let size2 = constant$5([0, 0]);
|
|
208643
|
-
function xCenter(d) {
|
|
208644
|
-
return d.x + d.vx + sizes[d.index][0] / 2;
|
|
208645
|
-
}
|
|
208646
|
-
function yCenter(d) {
|
|
208647
|
-
return d.y + d.vy + sizes[d.index][1] / 2;
|
|
208648
|
-
}
|
|
208649
|
-
function prepare2(quad2) {
|
|
208650
|
-
if (quad2.data) {
|
|
208651
|
-
quad2.size = sizes[quad2.data.index];
|
|
208652
|
-
} else {
|
|
208653
|
-
quad2.size = [0, 0];
|
|
208654
|
-
for (let i2 = 0; i2 < 4; i2++) {
|
|
208655
|
-
if (quad2[i2] && quad2[i2].size) {
|
|
208656
|
-
quad2.size[0] = Math.max(quad2.size[0], quad2[i2].size[0]);
|
|
208657
|
-
quad2.size[1] = Math.max(quad2.size[1], quad2[i2].size[1]);
|
|
208658
|
-
}
|
|
208659
|
-
}
|
|
208660
|
-
}
|
|
208661
|
-
}
|
|
208662
|
-
function force2() {
|
|
208663
|
-
let node;
|
|
208664
|
-
let nodeSize;
|
|
208665
|
-
let nodeMass;
|
|
208666
|
-
let xi;
|
|
208667
|
-
let yi;
|
|
208668
|
-
const tree2 = quadtree$1(nodes, xCenter, yCenter).visitAfter(prepare2);
|
|
208669
|
-
function apply2(quad2, x02, y02, x12, y12) {
|
|
208670
|
-
const { data: data2 } = quad2;
|
|
208671
|
-
const xSize = (nodeSize[0] + quad2.size[0]) / 2;
|
|
208672
|
-
const ySize = (nodeSize[1] + quad2.size[1]) / 2;
|
|
208673
|
-
if (data2 && data2.index > node.index) {
|
|
208674
|
-
let x2 = jiggle$1(xi - xCenter(data2));
|
|
208675
|
-
let y2 = jiggle$1(yi - yCenter(data2));
|
|
208676
|
-
const xd = Math.abs(x2) - xSize;
|
|
208677
|
-
const yd = Math.abs(y2) - ySize;
|
|
208678
|
-
if (xd < 0 && yd < 0) {
|
|
208679
|
-
const l2 = Math.sqrt(x2 * x2 + y2 * y2);
|
|
208680
|
-
const m2 = masses[data2.index] / (nodeMass + masses[data2.index]);
|
|
208681
|
-
if (Math.abs(xd) < Math.abs(yd)) {
|
|
208682
|
-
node.vx -= (x2 *= xd / l2 * strength) * m2;
|
|
208683
|
-
data2.vx += x2 * (1 - m2);
|
|
208684
|
-
} else {
|
|
208685
|
-
node.vy -= (y2 *= yd / l2 * strength) * m2;
|
|
208686
|
-
data2.vy += y2 * (1 - m2);
|
|
208687
|
-
}
|
|
208688
|
-
}
|
|
208689
|
-
return x02 > xi + xSize || x12 < xi - xSize || y02 > yi + ySize || y12 < yi - ySize;
|
|
208690
|
-
}
|
|
208691
|
-
return false;
|
|
208692
|
-
}
|
|
208693
|
-
function iterate2() {
|
|
208694
|
-
for (let j2 = 0; j2 < nodes.length; j2++) {
|
|
208695
|
-
node = nodes[j2];
|
|
208696
|
-
nodeSize = sizes[j2];
|
|
208697
|
-
nodeMass = masses[j2];
|
|
208698
|
-
xi = xCenter(node);
|
|
208699
|
-
yi = yCenter(node);
|
|
208700
|
-
tree2.visit(apply2);
|
|
208701
|
-
}
|
|
208702
|
-
}
|
|
208703
|
-
for (let i2 = 0; i2 < iterations2; i2++) {
|
|
208704
|
-
iterate2();
|
|
208705
|
-
}
|
|
208706
|
-
}
|
|
208707
|
-
force2.initialize = (v) => {
|
|
208708
|
-
nodes = v;
|
|
208709
|
-
sizes = nodes.map(size2);
|
|
208710
|
-
masses = sizes.map((d) => d[0] + d[1]);
|
|
208711
|
-
};
|
|
208712
|
-
force2.iterations = (...v) => {
|
|
208713
|
-
if (v.length) {
|
|
208714
|
-
iterations2 = +v[0];
|
|
208715
|
-
return force2;
|
|
208716
|
-
}
|
|
208717
|
-
return iterations2;
|
|
208718
|
-
};
|
|
208719
|
-
force2.strength = (...v) => {
|
|
208720
|
-
if (v.length) {
|
|
208721
|
-
strength = +v[0];
|
|
208722
|
-
return force2;
|
|
208723
|
-
}
|
|
208724
|
-
return strength;
|
|
208725
|
-
};
|
|
208726
|
-
force2.size = (...v) => {
|
|
208727
|
-
if (v.length) {
|
|
208728
|
-
size2 = typeof v[0] === "function" ? v[0] : constant$5(v[0]);
|
|
208729
|
-
return force2;
|
|
208730
|
-
}
|
|
208731
|
-
return size2;
|
|
208732
|
-
};
|
|
208733
|
-
return force2;
|
|
208734
|
-
}
|
|
208735
|
-
function baseClamp$1(number2, lower, upper) {
|
|
208736
|
-
if (number2 === number2) {
|
|
208737
|
-
if (upper !== void 0) {
|
|
208738
|
-
number2 = number2 <= upper ? number2 : upper;
|
|
208739
|
-
}
|
|
208740
|
-
if (lower !== void 0) {
|
|
208741
|
-
number2 = number2 >= lower ? number2 : lower;
|
|
208742
|
-
}
|
|
208743
|
-
}
|
|
208744
|
-
return number2;
|
|
208745
|
-
}
|
|
208746
|
-
var _baseClamp = baseClamp$1;
|
|
208747
|
-
var baseClamp = _baseClamp, toNumber$1 = toNumber_1$1;
|
|
208748
|
-
function clamp$1(number2, lower, upper) {
|
|
208749
|
-
if (upper === void 0) {
|
|
208750
|
-
upper = lower;
|
|
208751
|
-
lower = void 0;
|
|
208752
|
-
}
|
|
208753
|
-
if (upper !== void 0) {
|
|
208754
|
-
upper = toNumber$1(upper);
|
|
208755
|
-
upper = upper === upper ? upper : 0;
|
|
208756
|
-
}
|
|
208757
|
-
if (lower !== void 0) {
|
|
208758
|
-
lower = toNumber$1(lower);
|
|
208759
|
-
lower = lower === lower ? lower : 0;
|
|
208760
|
-
}
|
|
208761
|
-
return baseClamp(toNumber$1(number2), lower, upper);
|
|
208762
|
-
}
|
|
208763
|
-
var clamp_1 = clamp$1;
|
|
208764
|
-
function getPointSizeDevicePixels(devicePixelRatio2, zoom2, xRange, yRange, width2, height2) {
|
|
208765
|
-
const pointSize = 5e-4;
|
|
208766
|
-
const pointScreenSizeMax = 10;
|
|
208767
|
-
const pointScreenSizeMin = 1 / devicePixelRatio2;
|
|
208768
|
-
const scaleFactor = 2 ** zoom2;
|
|
208769
|
-
const xAxisRange = 2 / (xRange * scaleFactor / width2);
|
|
208770
|
-
const yAxisRange = 2 / (yRange * scaleFactor / height2);
|
|
208771
|
-
const diagonalScreenSize = Math.sqrt(width2 ** 2 + height2 ** 2);
|
|
208772
|
-
const diagonalAxisRange = Math.sqrt(xAxisRange ** 2 + yAxisRange ** 2);
|
|
208773
|
-
const diagonalFraction = pointSize / diagonalAxisRange;
|
|
208774
|
-
const deviceSize = diagonalFraction * diagonalScreenSize;
|
|
208775
|
-
const pointSizeDevicePixels = clamp_1(deviceSize, pointScreenSizeMin, pointScreenSizeMax);
|
|
208776
|
-
return pointSizeDevicePixels;
|
|
208777
|
-
}
|
|
208778
|
-
function getPointOpacity(zoom2, xRange, yRange, width2, height2, numCells, avgFillDensity) {
|
|
208779
|
-
const N2 = numCells;
|
|
208780
|
-
const [minX, minY, maxX, maxY2] = new OrthographicView({ zoom: zoom2 }).makeViewport({
|
|
208781
|
-
height: height2,
|
|
208782
|
-
width: width2,
|
|
208783
|
-
viewState: { zoom: zoom2, target: [0, 0, 0] }
|
|
208784
|
-
}).getBounds();
|
|
208785
|
-
const X3 = maxY2 - minY;
|
|
208786
|
-
const Y3 = maxX - minX;
|
|
208787
|
-
const X02 = xRange;
|
|
208788
|
-
const Y02 = yRange;
|
|
208789
|
-
const W = width2;
|
|
208790
|
-
const H = height2;
|
|
208791
|
-
let rho = avgFillDensity;
|
|
208792
|
-
if (!rho) {
|
|
208793
|
-
rho = Math.min(1, 1 / 10 ** (Math.log10(N2) - 3));
|
|
208794
|
-
}
|
|
208795
|
-
const alpha2 = rho * W * H / N2 * (Y02 / Y3) * (X02 / X3);
|
|
208796
|
-
const pointOpacity = clamp_1(alpha2, 1.01 / 255, 1);
|
|
208797
|
-
return pointOpacity;
|
|
208798
|
-
}
|
|
208799
|
-
const CELLS_LAYER_ID$1 = "scatterplot";
|
|
208800
|
-
const LABEL_FONT_FAMILY = "-apple-system, 'Helvetica Neue', Arial, sans-serif";
|
|
208801
|
-
const NUM_FORCE_SIMULATION_TICKS = 100;
|
|
208802
|
-
const LABEL_UPDATE_ZOOM_DELTA = 0.25;
|
|
208803
|
-
const makeDefaultGetCellColors$1 = (cellColors, obsIndex, theme) => (object2, { index: index2 }) => {
|
|
208804
|
-
const [r2, g2, b2, a2] = cellColors && obsIndex && cellColors.get(obsIndex[index2]) || getDefaultColor(theme);
|
|
208805
|
-
return [r2, g2, b2, 255 * (a2 || 1)];
|
|
208806
|
-
};
|
|
208807
|
-
const makeDefaultGetObsCoords$1 = (obsEmbedding) => (i2) => [
|
|
208808
|
-
obsEmbedding.data[0][i2],
|
|
208809
|
-
obsEmbedding.data[1][i2],
|
|
208810
|
-
0
|
|
208811
|
-
];
|
|
208812
|
-
const makeFlippedGetObsCoords = (obsEmbedding) => (i2) => [
|
|
208813
|
-
obsEmbedding.data[0][i2],
|
|
208814
|
-
-obsEmbedding.data[1][i2],
|
|
208815
|
-
0
|
|
208816
|
-
];
|
|
208817
|
-
const getPosition = (object2, { index: index2, data: data2, target: target2 }) => {
|
|
208818
|
-
target2[0] = data2.src.obsEmbedding.data[0][index2];
|
|
208819
|
-
target2[1] = -data2.src.obsEmbedding.data[1][index2];
|
|
208820
|
-
target2[2] = 0;
|
|
208821
|
-
return target2;
|
|
208822
|
-
};
|
|
208823
|
-
class Scatterplot extends AbstractSpatialOrScatterplot {
|
|
208824
|
-
constructor(props2) {
|
|
208825
|
-
super(props2);
|
|
208826
|
-
this.cellsQuadTree = null;
|
|
208827
|
-
this.cellsLayer = null;
|
|
208828
|
-
this.cellsData = null;
|
|
208829
|
-
this.cellSetsForceSimulation = forceCollideRects();
|
|
208830
|
-
this.cellSetsLabelPrevZoom = null;
|
|
208831
|
-
this.cellSetsLayers = [];
|
|
208832
|
-
this.onUpdateCellsData();
|
|
208833
|
-
this.onUpdateCellsLayer();
|
|
208834
|
-
this.onUpdateCellSetsLayers();
|
|
208835
|
-
}
|
|
208836
|
-
createCellsLayer() {
|
|
208837
|
-
const {
|
|
208838
|
-
obsEmbeddingIndex: obsIndex,
|
|
208839
|
-
theme,
|
|
208840
|
-
cellRadius = 1,
|
|
208841
|
-
cellOpacity = 1,
|
|
208842
|
-
cellSelection,
|
|
208843
|
-
setCellHighlight,
|
|
208844
|
-
setComponentHover,
|
|
208845
|
-
getCellIsSelected,
|
|
208846
|
-
cellColors,
|
|
208847
|
-
getCellColor = makeDefaultGetCellColors$1(cellColors, obsIndex, theme),
|
|
208848
|
-
getExpressionValue,
|
|
208849
|
-
onCellClick,
|
|
208850
|
-
geneExpressionColormap,
|
|
208851
|
-
geneExpressionColormapRange = [0, 1],
|
|
208852
|
-
cellColorEncoding
|
|
208853
|
-
} = this.props;
|
|
208854
|
-
return new ScatterplotLayer({
|
|
208855
|
-
id: CELLS_LAYER_ID$1,
|
|
208856
|
-
data: this.cellsData,
|
|
208857
|
-
coordinateSystem: COORDINATE_SYSTEM.CARTESIAN,
|
|
208858
|
-
visible: true,
|
|
208859
|
-
pickable: true,
|
|
208860
|
-
autoHighlight: true,
|
|
208861
|
-
filled: true,
|
|
208862
|
-
stroked: true,
|
|
208863
|
-
backgroundColor: theme === "dark" ? [0, 0, 0] : [241, 241, 241],
|
|
208864
|
-
getCellIsSelected,
|
|
208865
|
-
opacity: cellOpacity,
|
|
208866
|
-
radiusScale: cellRadius,
|
|
208867
|
-
radiusMinPixels: 1,
|
|
208868
|
-
radiusMaxPixels: 30,
|
|
208869
|
-
radiusUnits: "pixels",
|
|
208870
|
-
lineWidthUnits: "pixels",
|
|
208871
|
-
getPosition,
|
|
208872
|
-
getFillColor: getCellColor,
|
|
208873
|
-
getLineColor: getCellColor,
|
|
208874
|
-
getRadius: 1,
|
|
208875
|
-
getExpressionValue,
|
|
208876
|
-
getLineWidth: 0,
|
|
208877
|
-
extensions: [
|
|
208878
|
-
new ScaledExpressionExtension(),
|
|
208879
|
-
new SelectionExtension({ instanced: true })
|
|
208880
|
-
],
|
|
208881
|
-
colorScaleLo: geneExpressionColormapRange[0],
|
|
208882
|
-
colorScaleHi: geneExpressionColormapRange[1],
|
|
208883
|
-
isExpressionMode: cellColorEncoding === "geneSelection",
|
|
208884
|
-
colormap: geneExpressionColormap,
|
|
208885
|
-
onClick: (info2) => {
|
|
208886
|
-
if (onCellClick) {
|
|
208887
|
-
onCellClick(info2);
|
|
208888
|
-
}
|
|
208889
|
-
},
|
|
208890
|
-
onHover: getOnHoverCallback(obsIndex, setCellHighlight, setComponentHover),
|
|
208891
|
-
updateTriggers: {
|
|
208892
|
-
getExpressionValue,
|
|
208893
|
-
getFillColor: [cellColorEncoding, cellSelection, cellColors],
|
|
208894
|
-
getLineColor: [cellColorEncoding, cellSelection, cellColors],
|
|
208895
|
-
getCellIsSelected
|
|
208896
|
-
}
|
|
208897
|
-
});
|
|
208898
|
-
}
|
|
208899
|
-
createCellSetsLayers() {
|
|
208900
|
-
const { theme, cellSetPolygons, viewState, cellSetPolygonsVisible, cellSetLabelsVisible, cellSetLabelSize } = this.props;
|
|
208901
|
-
const result = [];
|
|
208902
|
-
if (cellSetPolygonsVisible) {
|
|
208903
|
-
result.push(new PolygonLayer({
|
|
208904
|
-
id: "cell-sets-polygon-layer",
|
|
208905
|
-
data: cellSetPolygons,
|
|
208906
|
-
stroked: true,
|
|
208907
|
-
filled: false,
|
|
208908
|
-
wireframe: true,
|
|
208909
|
-
lineWidthMaxPixels: 1,
|
|
208910
|
-
getPolygon: (d) => d.hull,
|
|
208911
|
-
getLineColor: (d) => d.color,
|
|
208912
|
-
getLineWidth: 1
|
|
208913
|
-
}));
|
|
208914
|
-
}
|
|
208915
|
-
if (cellSetLabelsVisible) {
|
|
208916
|
-
const { zoom: zoom2 } = viewState;
|
|
208917
|
-
const nodes = cellSetPolygons.map((p) => ({
|
|
208918
|
-
x: p.centroid[0],
|
|
208919
|
-
y: p.centroid[1],
|
|
208920
|
-
label: p.name
|
|
208921
|
-
}));
|
|
208922
|
-
const collisionForce = this.cellSetsForceSimulation.size((d) => [
|
|
208923
|
-
cellSetLabelSize * 1 / 2 ** zoom2 * 4 * d.label.length,
|
|
208924
|
-
cellSetLabelSize * 1 / 2 ** zoom2 * 1.5
|
|
208925
|
-
]);
|
|
208926
|
-
forceSimulation$1().nodes(nodes).force("collision", collisionForce).tick(NUM_FORCE_SIMULATION_TICKS);
|
|
208927
|
-
result.push(new TextLayer({
|
|
208928
|
-
id: "cell-sets-text-layer",
|
|
208929
|
-
data: nodes,
|
|
208930
|
-
getPosition: (d) => [d.x, d.y],
|
|
208931
|
-
getText: (d) => d.label,
|
|
208932
|
-
getColor: theme === "dark" ? [255, 255, 255] : [0, 0, 0],
|
|
208933
|
-
getSize: cellSetLabelSize,
|
|
208934
|
-
getAngle: 0,
|
|
208935
|
-
getTextAnchor: "middle",
|
|
208936
|
-
getAlignmentBaseline: "center",
|
|
208937
|
-
fontFamily: LABEL_FONT_FAMILY,
|
|
208938
|
-
fontWeight: "normal"
|
|
208939
|
-
}));
|
|
208940
|
-
}
|
|
208941
|
-
return result;
|
|
208942
|
-
}
|
|
208943
|
-
createSelectionLayers() {
|
|
208944
|
-
const { obsEmbeddingIndex: obsIndex, obsEmbedding, viewState, setCellSelection } = this.props;
|
|
208945
|
-
const { tool } = this.state;
|
|
208946
|
-
const { cellsQuadTree } = this;
|
|
208947
|
-
const flipYTooltip = true;
|
|
208948
|
-
const getCellCoords = makeDefaultGetObsCoords$1(obsEmbedding);
|
|
208949
|
-
return getSelectionLayers(tool, viewState.zoom, CELLS_LAYER_ID$1, getCellCoords, obsIndex, setCellSelection, cellsQuadTree, flipYTooltip);
|
|
208950
|
-
}
|
|
208951
|
-
getLayers() {
|
|
208952
|
-
const { cellsLayer, cellSetsLayers } = this;
|
|
208953
|
-
return [
|
|
208954
|
-
cellsLayer,
|
|
208955
|
-
...cellSetsLayers,
|
|
208956
|
-
...this.createSelectionLayers()
|
|
208957
|
-
];
|
|
208958
|
-
}
|
|
208959
|
-
onUpdateCellsData() {
|
|
208960
|
-
const { obsEmbedding } = this.props;
|
|
208961
|
-
if (obsEmbedding) {
|
|
208962
|
-
const getCellCoords = makeDefaultGetObsCoords$1(obsEmbedding);
|
|
208963
|
-
this.cellsQuadTree = createQuadTree(obsEmbedding, getCellCoords);
|
|
208964
|
-
this.cellsData = {
|
|
208965
|
-
src: {
|
|
208966
|
-
obsEmbedding
|
|
208967
|
-
},
|
|
208968
|
-
length: obsEmbedding.shape[1]
|
|
208969
|
-
};
|
|
208970
|
-
}
|
|
208971
|
-
}
|
|
208972
|
-
onUpdateCellsLayer() {
|
|
208973
|
-
const { obsEmbeddingIndex, obsEmbedding } = this.props;
|
|
208974
|
-
if (obsEmbeddingIndex && obsEmbedding) {
|
|
208975
|
-
this.cellsLayer = this.createCellsLayer();
|
|
208976
|
-
} else {
|
|
208977
|
-
this.cellsLayer = null;
|
|
208978
|
-
}
|
|
208979
|
-
}
|
|
208980
|
-
onUpdateCellSetsLayers(onlyViewStateChange) {
|
|
208981
|
-
if (onlyViewStateChange) {
|
|
208982
|
-
const { viewState, cellSetLabelsVisible } = this.props;
|
|
208983
|
-
const { zoom: zoom2 } = viewState;
|
|
208984
|
-
const { cellSetsLabelPrevZoom } = this;
|
|
208985
|
-
if (cellSetLabelsVisible && (cellSetsLabelPrevZoom === null || Math.abs(cellSetsLabelPrevZoom - zoom2) > LABEL_UPDATE_ZOOM_DELTA)) {
|
|
208986
|
-
this.cellSetsLayers = this.createCellSetsLayers();
|
|
208987
|
-
this.cellSetsLabelPrevZoom = zoom2;
|
|
208988
|
-
}
|
|
208989
|
-
} else {
|
|
208990
|
-
this.cellSetsLayers = this.createCellSetsLayers();
|
|
208991
|
-
}
|
|
208992
|
-
}
|
|
208993
|
-
viewInfoDidUpdate() {
|
|
208994
|
-
const { obsEmbeddingIndex, obsEmbedding } = this.props;
|
|
208995
|
-
super.viewInfoDidUpdate(obsEmbeddingIndex, obsEmbedding, makeFlippedGetObsCoords);
|
|
208996
|
-
}
|
|
208997
|
-
componentDidUpdate(prevProps) {
|
|
208998
|
-
this.viewInfoDidUpdate();
|
|
208999
|
-
const shallowDiff = (propName) => prevProps[propName] !== this.props[propName];
|
|
209000
|
-
let forceUpdate = false;
|
|
209001
|
-
if (["obsEmbedding"].some(shallowDiff)) {
|
|
209002
|
-
this.onUpdateCellsData();
|
|
209003
|
-
forceUpdate = true;
|
|
209004
|
-
}
|
|
209005
|
-
if ([
|
|
209006
|
-
"obsEmbeddingIndex",
|
|
209007
|
-
"obsEmbedding",
|
|
209008
|
-
"cellFilter",
|
|
209009
|
-
"cellSelection",
|
|
209010
|
-
"cellColors",
|
|
209011
|
-
"cellRadius",
|
|
209012
|
-
"cellOpacity",
|
|
209013
|
-
"cellRadiusMode",
|
|
209014
|
-
"geneExpressionColormap",
|
|
209015
|
-
"geneExpressionColormapRange",
|
|
209016
|
-
"geneSelection",
|
|
209017
|
-
"cellColorEncoding"
|
|
209018
|
-
].some(shallowDiff)) {
|
|
209019
|
-
this.onUpdateCellsLayer();
|
|
209020
|
-
forceUpdate = true;
|
|
209021
|
-
}
|
|
209022
|
-
if ([
|
|
209023
|
-
"cellSetPolygons",
|
|
209024
|
-
"cellSetPolygonsVisible",
|
|
209025
|
-
"cellSetLabelsVisible",
|
|
209026
|
-
"cellSetLabelSize"
|
|
209027
|
-
].some(shallowDiff)) {
|
|
209028
|
-
this.onUpdateCellSetsLayers(false);
|
|
209029
|
-
forceUpdate = true;
|
|
209030
|
-
}
|
|
209031
|
-
if (shallowDiff("viewState")) {
|
|
209032
|
-
this.onUpdateCellSetsLayers(true);
|
|
209033
|
-
forceUpdate = true;
|
|
209034
|
-
}
|
|
209035
|
-
if (forceUpdate) {
|
|
209036
|
-
this.forceUpdate();
|
|
209037
|
-
}
|
|
209038
|
-
}
|
|
209039
|
-
}
|
|
209040
|
-
const ScatterplotWrapper = React$i.forwardRef((props2, deckRef) => jsx(Scatterplot, { ...props2, deckRef }));
|
|
209041
|
-
function ScatterplotOptions(props2) {
|
|
209042
|
-
const { children: children2, observationsLabel, cellRadius, setCellRadius, cellRadiusMode, setCellRadiusMode, cellOpacity, setCellOpacity, cellOpacityMode, setCellOpacityMode, cellSetLabelsVisible, setCellSetLabelsVisible, cellSetLabelSize, setCellSetLabelSize, cellSetPolygonsVisible, setCellSetPolygonsVisible, cellColorEncoding, setCellColorEncoding, geneExpressionColormap, setGeneExpressionColormap, geneExpressionColormapRange, setGeneExpressionColormapRange } = props2;
|
|
209043
|
-
const observationsLabelNice = capitalize$2(observationsLabel);
|
|
209044
|
-
const classes = useStyles$b();
|
|
209045
|
-
function handleCellRadiusModeChange(event2) {
|
|
209046
|
-
setCellRadiusMode(event2.target.value);
|
|
209047
|
-
}
|
|
209048
|
-
function handleCellOpacityModeChange(event2) {
|
|
209049
|
-
setCellOpacityMode(event2.target.value);
|
|
209050
|
-
}
|
|
209051
|
-
function handleRadiusChange(event2, value2) {
|
|
209052
|
-
setCellRadius(value2);
|
|
209053
|
-
}
|
|
209054
|
-
function handleOpacityChange(event2, value2) {
|
|
209055
|
-
setCellOpacity(value2);
|
|
209056
|
-
}
|
|
209057
|
-
function handleLabelVisibilityChange(event2) {
|
|
209058
|
-
setCellSetLabelsVisible(event2.target.checked);
|
|
209059
|
-
}
|
|
209060
|
-
function handleLabelSizeChange(event2, value2) {
|
|
209061
|
-
setCellSetLabelSize(value2);
|
|
209062
|
-
}
|
|
209063
|
-
function handlePolygonVisibilityChange(event2) {
|
|
209064
|
-
setCellSetPolygonsVisible(event2.target.checked);
|
|
209065
|
-
}
|
|
209066
|
-
function handleGeneExpressionColormapChange(event2) {
|
|
209067
|
-
setGeneExpressionColormap(event2.target.value);
|
|
209068
|
-
}
|
|
209069
|
-
function handleColormapRangeChange(event2, value2) {
|
|
209070
|
-
setGeneExpressionColormapRange(value2);
|
|
209071
|
-
}
|
|
209072
|
-
const handleColormapRangeChangeDebounced = React$i.useCallback(debounce_1$1(handleColormapRangeChange, 5, { trailing: true }), [handleColormapRangeChange]);
|
|
209073
|
-
return jsxs(OptionsContainer, { children: [children2, jsx(CellColorEncodingOption, { observationsLabel, cellColorEncoding, setCellColorEncoding }), jsxs(TableRow$1, { children: [jsxs(TableCell$1, { className: classes.labelCell, children: [observationsLabelNice, " Set Labels Visible"] }), jsx(TableCell$1, { className: classes.inputCell, children: jsx(Checkbox$1, { className: classes.checkbox, checked: cellSetLabelsVisible, onChange: handleLabelVisibilityChange, name: "scatterplot-option-cell-set-labels", color: "default" }) })] }), jsxs(TableRow$1, { children: [jsxs(TableCell$1, { className: classes.labelCell, children: [observationsLabelNice, " Set Label Size"] }), jsx(TableCell$1, { className: classes.inputCell, children: jsx(Slider$1, { disabled: !cellSetLabelsVisible, classes: { root: classes.slider, valueLabel: classes.sliderValueLabel }, value: cellSetLabelSize, onChange: handleLabelSizeChange, "aria-labelledby": "cell-set-label-size-slider", valueLabelDisplay: "auto", step: 1, min: 8, max: 36 }) })] }), jsxs(TableRow$1, { children: [jsxs(TableCell$1, { className: classes.labelCell, children: [observationsLabelNice, " Set Polygons Visible"] }), jsx(TableCell$1, { className: classes.inputCell, children: jsx(Checkbox$1, { className: classes.checkbox, checked: cellSetPolygonsVisible, onChange: handlePolygonVisibilityChange, name: "scatterplot-option-cell-set-polygons", color: "default" }) })] }), jsxs(TableRow$1, { children: [jsxs(TableCell$1, { className: classes.labelCell, htmlFor: "cell-radius-mode-select", children: [observationsLabelNice, " Radius Mode"] }), jsx(TableCell$1, { className: classes.inputCell, children: jsxs(OptionSelect, { className: classes.select, value: cellRadiusMode, onChange: handleCellRadiusModeChange, inputProps: {
|
|
209074
|
-
id: "cell-radius-mode-select"
|
|
209075
|
-
}, children: [jsx("option", { value: "auto", children: "Auto" }), jsx("option", { value: "manual", children: "Manual" })] }) })] }), jsxs(TableRow$1, { children: [jsxs(TableCell$1, { className: classes.labelCell, children: [observationsLabelNice, " Radius"] }), jsx(TableCell$1, { className: classes.inputCell, children: jsx(Slider$1, { disabled: cellRadiusMode !== "manual", classes: { root: classes.slider, valueLabel: classes.sliderValueLabel }, value: cellRadius, onChange: handleRadiusChange, "aria-labelledby": "cell-radius-slider", valueLabelDisplay: "auto", step: 0.01, min: 0.01, max: 10 }) })] }), jsxs(TableRow$1, { children: [jsxs(TableCell$1, { className: classes.labelCell, htmlFor: "cell-opacity-mode-select", children: [observationsLabelNice, " Opacity Mode"] }), jsx(TableCell$1, { className: classes.inputCell, children: jsxs(OptionSelect, { className: classes.select, value: cellOpacityMode, onChange: handleCellOpacityModeChange, inputProps: {
|
|
209076
|
-
id: "cell-opacity-mode-select"
|
|
209077
|
-
}, children: [jsx("option", { value: "auto", children: "Auto" }), jsx("option", { value: "manual", children: "Manual" })] }) })] }), jsxs(TableRow$1, { children: [jsxs(TableCell$1, { className: classes.labelCell, children: [observationsLabelNice, " Opacity"] }), jsx(TableCell$1, { className: classes.inputCell, children: jsx(Slider$1, { disabled: cellOpacityMode !== "manual", classes: { root: classes.slider, valueLabel: classes.sliderValueLabel }, value: cellOpacity, onChange: handleOpacityChange, "aria-labelledby": "cell-opacity-slider", valueLabelDisplay: "auto", step: 0.05, min: 0, max: 1 }) })] }), jsxs(TableRow$1, { children: [jsx(TableCell$1, { className: classes.labelCell, htmlFor: "gene-expression-colormap-select", children: "Gene Expression Colormap" }), jsx(TableCell$1, { className: classes.inputCell, children: jsx(OptionSelect, { className: classes.select, value: geneExpressionColormap, onChange: handleGeneExpressionColormapChange, inputProps: {
|
|
209078
|
-
id: "gene-expression-colormap-select"
|
|
209079
|
-
}, children: GLSL_COLORMAPS.map((cmap) => jsx("option", { value: cmap, children: cmap }, cmap)) }) })] }), jsxs(TableRow$1, { children: [jsx(TableCell$1, { className: classes.labelCell, children: "Gene Expression Colormap Range" }), jsx(TableCell$1, { className: classes.inputCell, children: jsx(Slider$1, { classes: { root: classes.slider, valueLabel: classes.sliderValueLabel }, value: geneExpressionColormapRange, onChange: handleColormapRangeChangeDebounced, "aria-labelledby": "gene-expression-colormap-range-slider", valueLabelDisplay: "auto", step: 5e-3, min: 0, max: 1 }) })] })] });
|
|
209080
|
-
}
|
|
209081
|
-
const styles = makeStyles(() => ({
|
|
209082
|
-
tooltipAnchor: {
|
|
209083
|
-
position: "relative",
|
|
209084
|
-
width: "0px",
|
|
209085
|
-
height: "0px",
|
|
209086
|
-
pointerEvents: "none",
|
|
209087
|
-
userSelect: "none"
|
|
209088
|
-
},
|
|
209089
|
-
tooltipContent: {
|
|
209090
|
-
opacity: 0.9,
|
|
209091
|
-
padding: "5px",
|
|
209092
|
-
pointerEvents: "none",
|
|
209093
|
-
"& table > tbody > tr > th, & table > tbody > tr > td": {
|
|
209094
|
-
fontSize: "80%",
|
|
209095
|
-
opacity: 0.8,
|
|
209096
|
-
outline: 0,
|
|
209097
|
-
padding: "0 2px"
|
|
209098
|
-
},
|
|
209099
|
-
"& table": {
|
|
209100
|
-
borderCollapse: "collapse"
|
|
209101
|
-
}
|
|
209102
|
-
}
|
|
209103
|
-
}));
|
|
209104
|
-
function Tooltip(props2) {
|
|
209105
|
-
const { x: x2, y: y2, parentWidth, parentHeight, children: children2 } = props2;
|
|
209106
|
-
const ref2 = React$i.useRef();
|
|
209107
|
-
const classes = styles();
|
|
209108
|
-
const [placementX, setPlacementX] = React$i.useState("start");
|
|
209109
|
-
const [placementY, setPlacementY] = React$i.useState("bottom");
|
|
209110
|
-
const getTooltipContainer = useVitessceContainer(ref2);
|
|
209111
|
-
React$i.useEffect(() => {
|
|
209112
|
-
if (ref2 && ref2.current) {
|
|
209113
|
-
const flipX = x2 > parentWidth / 2;
|
|
209114
|
-
const flipY = y2 > parentHeight / 2;
|
|
209115
|
-
setPlacementX(flipX ? "end" : "start");
|
|
209116
|
-
setPlacementY(flipY ? "top" : "bottom");
|
|
209117
|
-
ref2.current.style.left = `${x2 + (flipX ? -20 : 5)}px`;
|
|
209118
|
-
ref2.current.style.top = `${y2 + (flipY ? -20 : 5)}px`;
|
|
209119
|
-
}
|
|
209120
|
-
}, [x2, y2, parentWidth, parentHeight]);
|
|
209121
|
-
return jsx("div", { ref: ref2, className: classes.tooltipAnchor, children: ref2 && ref2.current ? jsx(Popper$1, { open: true, anchorEl: ref2.current, container: getTooltipContainer, transition: true, placement: `${placementY}-${placementX}`, children: jsx(Paper$1, { elevation: 4, className: classes.tooltipContent, children: children2 }) }) : null });
|
|
209122
|
-
}
|
|
209123
|
-
function Tooltip2D(props2) {
|
|
209124
|
-
const { parentUuid, sourceUuid, x: x2, y: y2, parentWidth, parentHeight, children: children2 } = props2;
|
|
209125
|
-
if (x2 < 0 || x2 > parentWidth || y2 < 0 || y2 > parentHeight) {
|
|
209126
|
-
return null;
|
|
209127
|
-
}
|
|
209128
|
-
const isTooltipVisible = parentUuid === sourceUuid;
|
|
209129
|
-
const crosshairWidth = 1;
|
|
209130
|
-
return jsx(Fragment, { children: isTooltipVisible ? jsx(Tooltip, { x: x2, y: y2, parentWidth, parentHeight, children: children2 }) : jsxs(Fragment, { children: [x2 !== null ? jsx("div", { className: "cell-emphasis-crosshair", style: {
|
|
209131
|
-
left: `${x2 - crosshairWidth / 2}px`,
|
|
209132
|
-
top: 0,
|
|
209133
|
-
width: `${crosshairWidth}px`,
|
|
209134
|
-
height: `${parentHeight}px`
|
|
209135
|
-
} }) : null, y2 !== null ? jsx("div", { className: "cell-emphasis-crosshair", style: {
|
|
209136
|
-
left: 0,
|
|
209137
|
-
top: `${y2 - crosshairWidth / 2}px`,
|
|
209138
|
-
width: `${parentWidth}px`,
|
|
209139
|
-
height: `${crosshairWidth}px`
|
|
209140
|
-
} }) : null] }) });
|
|
209141
|
-
}
|
|
209142
|
-
function TooltipContent(props2) {
|
|
209143
|
-
const { info: info2 } = props2;
|
|
209144
|
-
return jsx("table", { children: jsx("tbody", { children: Object.entries(info2).map(([key2, value2]) => jsxs("tr", { children: [jsx("th", { children: key2 }), jsx("td", { children: value2 })] }, key2)) }) });
|
|
209145
|
-
}
|
|
209146
|
-
function ScatterplotTooltipSubscriber(props2) {
|
|
209147
|
-
const { parentUuid, obsHighlight, width: width2, height: height2, getObsInfo } = props2;
|
|
209148
|
-
const sourceUuid = useComponentHover();
|
|
209149
|
-
const viewInfo = useComponentViewInfo(parentUuid);
|
|
209150
|
-
const [cellInfo, x2, y2] = obsHighlight && getObsInfo ? [
|
|
209151
|
-
getObsInfo(obsHighlight),
|
|
209152
|
-
...viewInfo && viewInfo.project ? viewInfo.project(obsHighlight) : [null, null]
|
|
209153
|
-
] : [null, null, null];
|
|
209154
|
-
return cellInfo ? jsx(Tooltip2D, { x: x2, y: y2, parentUuid, sourceUuid, parentWidth: width2, parentHeight: height2, children: jsx(TooltipContent, { info: cellInfo }) }) : null;
|
|
209155
|
-
}
|
|
209156
|
-
function EmptyMessage(props2) {
|
|
209157
|
-
const { visible, message } = props2;
|
|
209158
|
-
return visible ? jsx("div", { children: message }) : null;
|
|
209159
|
-
}
|
|
209160
|
-
function EmbeddingScatterplotSubscriber(props2) {
|
|
209161
|
-
const {
|
|
209162
|
-
uuid,
|
|
209163
|
-
coordinationScopes,
|
|
209164
|
-
removeGridComponent,
|
|
209165
|
-
theme,
|
|
209166
|
-
disableTooltip = false,
|
|
209167
|
-
observationsLabelOverride,
|
|
209168
|
-
title: titleOverride,
|
|
209169
|
-
averageFillDensity
|
|
209170
|
-
} = props2;
|
|
209171
|
-
const loaders = useLoaders();
|
|
209172
|
-
const setComponentHover = useSetComponentHover();
|
|
209173
|
-
const setComponentViewInfo = useSetComponentViewInfo(uuid);
|
|
209174
|
-
const [{ dataset, obsType, featureType, featureValueType, embeddingZoom: zoom2, embeddingTargetX: targetX2, embeddingTargetY: targetY2, embeddingTargetZ: targetZ, embeddingType: mapping, obsFilter: cellFilter, obsHighlight: cellHighlight, featureSelection: geneSelection, 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 }, { 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 }] = useCoordination(COMPONENT_COORDINATION_TYPES[ViewType$2.SCATTERPLOT], coordinationScopes);
|
|
209175
|
-
const observationsLabel = observationsLabelOverride || obsType;
|
|
209176
|
-
const [urls2, addUrl2] = useUrls(loaders, dataset);
|
|
209177
|
-
const [width2, height2, deckRef] = useDeckCanvasSize();
|
|
209178
|
-
const title2 = titleOverride || `Scatterplot (${mapping})`;
|
|
209179
|
-
const [obsLabelsTypes, obsLabelsData] = useMultiObsLabels(coordinationScopes, obsType, loaders, dataset, addUrl2);
|
|
209180
|
-
const [{ obsIndex: obsEmbeddingIndex, obsEmbedding }, obsEmbeddingStatus] = useObsEmbeddingData(loaders, dataset, addUrl2, true, {}, {}, { obsType, embeddingType: mapping });
|
|
209181
|
-
const cellsCount = (obsEmbeddingIndex == null ? void 0 : obsEmbeddingIndex.length) || 0;
|
|
209182
|
-
const [{ obsSets: cellSets, obsSetsMembership }, obsSetsStatus] = useObsSetsData(loaders, dataset, addUrl2, false, { setObsSetSelection: setCellSetSelection, setObsSetColor: setCellSetColor }, { obsSetSelection: cellSetSelection, obsSetColor: cellSetColor }, { obsType });
|
|
209183
|
-
const [expressionData, loadedFeatureSelection, featureSelectionStatus] = useFeatureSelection(loaders, dataset, false, geneSelection, { obsType, featureType, featureValueType });
|
|
209184
|
-
const [{ obsIndex: matrixObsIndex }, matrixIndicesStatus] = useObsFeatureMatrixIndices(loaders, dataset, addUrl2, false, { obsType, featureType, featureValueType });
|
|
209185
|
-
const isReady = useReady([
|
|
209186
|
-
obsEmbeddingStatus,
|
|
209187
|
-
obsSetsStatus,
|
|
209188
|
-
featureSelectionStatus,
|
|
209189
|
-
matrixIndicesStatus
|
|
209190
|
-
]);
|
|
209191
|
-
const [dynamicCellRadius, setDynamicCellRadius] = React$i.useState(cellRadiusFixed);
|
|
209192
|
-
const [dynamicCellOpacity, setDynamicCellOpacity] = React$i.useState(cellOpacityFixed);
|
|
209193
|
-
const mergedCellSets = React$i.useMemo(() => mergeObsSets(cellSets, additionalCellSets), [cellSets, additionalCellSets]);
|
|
209194
|
-
const setCellSelectionProp = React$i.useCallback((v) => {
|
|
209195
|
-
setObsSelection(v, additionalCellSets, cellSetColor, setCellSetSelection, setAdditionalCellSets, setCellSetColor, setCellColorEncoding);
|
|
209196
|
-
}, [
|
|
209197
|
-
additionalCellSets,
|
|
209198
|
-
cellSetColor,
|
|
209199
|
-
setCellColorEncoding,
|
|
209200
|
-
setAdditionalCellSets,
|
|
209201
|
-
setCellSetColor,
|
|
209202
|
-
setCellSetSelection
|
|
209203
|
-
]);
|
|
209204
|
-
const cellColors = React$i.useMemo(() => getCellColors({
|
|
209205
|
-
cellColorEncoding,
|
|
209206
|
-
expressionData: expressionData && expressionData[0],
|
|
209207
|
-
geneSelection,
|
|
209208
|
-
cellSets: mergedCellSets,
|
|
209209
|
-
cellSetSelection,
|
|
209210
|
-
cellSetColor,
|
|
209211
|
-
obsIndex: matrixObsIndex,
|
|
209212
|
-
theme
|
|
209213
|
-
}), [
|
|
209214
|
-
cellColorEncoding,
|
|
209215
|
-
geneSelection,
|
|
209216
|
-
mergedCellSets,
|
|
209217
|
-
theme,
|
|
209218
|
-
cellSetSelection,
|
|
209219
|
-
cellSetColor,
|
|
209220
|
-
expressionData,
|
|
209221
|
-
matrixObsIndex
|
|
209222
|
-
]);
|
|
209223
|
-
const [cellSetPolygonCache, setCellSetPolygonCache] = React$i.useState([]);
|
|
209224
|
-
const cacheHas2 = (cache2, key2) => cache2.findIndex((el2) => isEqual_1(el2[0], key2)) !== -1;
|
|
209225
|
-
const cacheGet = (cache2, key2) => {
|
|
209226
|
-
var _a3;
|
|
209227
|
-
return (_a3 = cache2.find((el2) => isEqual_1(el2[0], key2))) == null ? void 0 : _a3[1];
|
|
209228
|
-
};
|
|
209229
|
-
const cellSetPolygons = React$i.useMemo(() => {
|
|
209230
|
-
var _a3;
|
|
209231
|
-
if ((cellSetLabelsVisible || cellSetPolygonsVisible) && !cacheHas2(cellSetPolygonCache, cellSetSelection) && ((_a3 = mergedCellSets == null ? void 0 : mergedCellSets.tree) == null ? void 0 : _a3.length) && obsEmbedding && obsEmbeddingIndex && (cellSetColor == null ? void 0 : cellSetColor.length)) {
|
|
209232
|
-
const newCellSetPolygons = getCellSetPolygons({
|
|
209233
|
-
obsIndex: obsEmbeddingIndex,
|
|
209234
|
-
obsEmbedding,
|
|
209235
|
-
cellSets: mergedCellSets,
|
|
209236
|
-
cellSetSelection,
|
|
209237
|
-
cellSetColor,
|
|
209238
|
-
theme
|
|
209239
|
-
});
|
|
209240
|
-
setCellSetPolygonCache((cache2) => [...cache2, [cellSetSelection, newCellSetPolygons]]);
|
|
209241
|
-
return newCellSetPolygons;
|
|
209242
|
-
}
|
|
209243
|
-
return cacheGet(cellSetPolygonCache, cellSetSelection) || [];
|
|
209244
|
-
}, [
|
|
209245
|
-
cellSetPolygonsVisible,
|
|
209246
|
-
cellSetPolygonCache,
|
|
209247
|
-
cellSetLabelsVisible,
|
|
209248
|
-
theme,
|
|
209249
|
-
obsEmbeddingIndex,
|
|
209250
|
-
obsEmbedding,
|
|
209251
|
-
mergedCellSets,
|
|
209252
|
-
cellSetSelection,
|
|
209253
|
-
cellSetColor
|
|
209254
|
-
]);
|
|
209255
|
-
const cellSelection = React$i.useMemo(() => Array.from(cellColors.keys()), [cellColors]);
|
|
209256
|
-
const [xRange, yRange, xExtent, yExtent, numCells] = React$i.useMemo(() => {
|
|
209257
|
-
if (obsEmbedding && obsEmbedding.data && obsEmbedding.shape) {
|
|
209258
|
-
const cellCount = obsEmbedding.shape[1];
|
|
209259
|
-
const xE = extent$2(obsEmbedding.data[0]);
|
|
209260
|
-
const yE = extent$2(obsEmbedding.data[1]);
|
|
209261
|
-
const xR = xE[1] - xE[0];
|
|
209262
|
-
const yR = yE[1] - yE[0];
|
|
209263
|
-
return [xR, yR, xE, yE, cellCount];
|
|
209264
|
-
}
|
|
209265
|
-
return [null, null, null, null, null];
|
|
209266
|
-
}, [obsEmbedding]);
|
|
209267
|
-
React$i.useEffect(() => {
|
|
209268
|
-
if (xRange && yRange) {
|
|
209269
|
-
const pointSizeDevicePixels = getPointSizeDevicePixels(window.devicePixelRatio, zoom2, xRange, yRange, width2, height2);
|
|
209270
|
-
setDynamicCellRadius(pointSizeDevicePixels);
|
|
209271
|
-
const nextCellOpacityScale = getPointOpacity(zoom2, xRange, yRange, width2, height2, numCells, averageFillDensity);
|
|
209272
|
-
setDynamicCellOpacity(nextCellOpacityScale);
|
|
209273
|
-
if (typeof targetX2 !== "number" || typeof targetY2 !== "number") {
|
|
209274
|
-
const newTargetX = xExtent[0] + xRange / 2;
|
|
209275
|
-
const newTargetY = yExtent[0] + yRange / 2;
|
|
209276
|
-
const newZoom = Math.log2(Math.min(width2 / xRange, height2 / yRange));
|
|
209277
|
-
setTargetX(newTargetX);
|
|
209278
|
-
setTargetY(-newTargetY);
|
|
209279
|
-
setZoom(newZoom);
|
|
209280
|
-
}
|
|
209281
|
-
}
|
|
209282
|
-
}, [
|
|
209283
|
-
xRange,
|
|
209284
|
-
yRange,
|
|
209285
|
-
xExtent,
|
|
209286
|
-
yExtent,
|
|
209287
|
-
numCells,
|
|
209288
|
-
width2,
|
|
209289
|
-
height2,
|
|
209290
|
-
zoom2,
|
|
209291
|
-
averageFillDensity
|
|
209292
|
-
]);
|
|
209293
|
-
const getObsInfo = useGetObsInfo(observationsLabel, obsLabelsTypes, obsLabelsData, obsSetsMembership);
|
|
209294
|
-
const cellSelectionSet = React$i.useMemo(() => new Set(cellSelection), [cellSelection]);
|
|
209295
|
-
const getCellIsSelected = React$i.useCallback((object2, { index: index2 }) => (cellSelectionSet || /* @__PURE__ */ new Set([])).has(obsEmbeddingIndex[index2]) ? 1 : 0, [cellSelectionSet, obsEmbeddingIndex]);
|
|
209296
|
-
const cellRadius = cellRadiusMode === "manual" ? cellRadiusFixed : dynamicCellRadius;
|
|
209297
|
-
const cellOpacity = cellOpacityMode === "manual" ? cellOpacityFixed : dynamicCellOpacity;
|
|
209298
|
-
const getExpressionValue = useExpressionValueGetter({
|
|
209299
|
-
instanceObsIndex: obsEmbeddingIndex,
|
|
209300
|
-
matrixObsIndex,
|
|
209301
|
-
expressionData
|
|
209302
|
-
});
|
|
209303
|
-
return jsxs(TitleInfo, { title: title2, info: `${commaNumber(cellsCount)} ${plur(observationsLabel, cellsCount)}`, removeGridComponent, urls: urls2, theme, isReady, options: jsx(ScatterplotOptions, { observationsLabel, cellRadius: cellRadiusFixed, setCellRadius: setCellRadiusFixed, cellRadiusMode, setCellRadiusMode, cellOpacity: cellOpacityFixed, setCellOpacity: setCellOpacityFixed, cellOpacityMode, setCellOpacityMode, cellSetLabelsVisible, setCellSetLabelsVisible, cellSetLabelSize, setCellSetLabelSize, cellSetPolygonsVisible, setCellSetPolygonsVisible, cellColorEncoding, setCellColorEncoding, geneExpressionColormap, setGeneExpressionColormap, geneExpressionColormapRange, setGeneExpressionColormapRange }), children: [jsx(ScatterplotWrapper, { ref: deckRef, uuid, theme, viewState: { zoom: zoom2, target: [targetX2, targetY2, targetZ] }, setViewState: ({ zoom: newZoom, target: target2 }) => {
|
|
209304
|
-
setZoom(newZoom);
|
|
209305
|
-
setTargetX(target2[0]);
|
|
209306
|
-
setTargetY(target2[1]);
|
|
209307
|
-
setTargetZ(target2[2] || 0);
|
|
209308
|
-
}, obsEmbeddingIndex, obsEmbedding, cellFilter, cellSelection, cellHighlight, cellColors, cellSetPolygons, cellSetLabelSize, cellSetLabelsVisible, cellSetPolygonsVisible, setCellFilter, setCellSelection: setCellSelectionProp, setCellHighlight, cellRadius, cellOpacity, cellColorEncoding, geneExpressionColormap, geneExpressionColormapRange, setComponentHover: () => {
|
|
209309
|
-
setComponentHover(uuid);
|
|
209310
|
-
}, updateViewInfo: setComponentViewInfo, getExpressionValue, getCellIsSelected }), !disableTooltip && jsx(ScatterplotTooltipSubscriber, { parentUuid: uuid, obsHighlight: cellHighlight, width: width2, height: height2, getObsInfo })] });
|
|
209311
|
-
}
|
|
209312
|
-
function register$c() {
|
|
209313
|
-
registerPluginViewType(ViewType$2.SCATTERPLOT, EmbeddingScatterplotSubscriber, COMPONENT_COORDINATION_TYPES[ViewType$2.SCATTERPLOT]);
|
|
209314
|
-
}
|
|
209315
|
-
function GatingScatterplotOptions(props2) {
|
|
209316
|
-
const { featureType, gatingFeatureSelectionX, setGatingFeatureSelectionX, gatingFeatureSelectionY, setGatingFeatureSelectionY, gatingFeatureValueTransform, setGatingFeatureValueTransform, gatingFeatureValueTransformCoefficient, setGatingFeatureValueTransformCoefficient, geneSelectOptions, transformOptions } = props2;
|
|
209317
|
-
const classes = useStyles$b();
|
|
209318
|
-
const handleGeneSelectChange = (event2) => {
|
|
209319
|
-
const { options } = event2.target;
|
|
209320
|
-
const newValues = [];
|
|
209321
|
-
for (let i2 = 0, l2 = options.length; i2 < l2; i2 += 1) {
|
|
209322
|
-
if (options[i2].selected) {
|
|
209323
|
-
newValues.push(options[i2].value);
|
|
209324
|
-
}
|
|
209325
|
-
}
|
|
209326
|
-
if (newValues.length === 1 && gatingFeatureSelectionX && !gatingFeatureSelectionY && newValues[0] !== gatingFeatureSelectionX) {
|
|
209327
|
-
setGatingFeatureSelectionY(newValues[0]);
|
|
209328
|
-
} else if (newValues.length <= 2) {
|
|
209329
|
-
setGatingFeatureSelectionX(newValues[0]);
|
|
209330
|
-
setGatingFeatureSelectionY(newValues[1]);
|
|
209331
|
-
}
|
|
209332
|
-
};
|
|
209333
|
-
const handleTransformChange = (event2) => {
|
|
209334
|
-
setGatingFeatureValueTransform(event2.target.value === "" ? null : event2.target.value);
|
|
209335
|
-
};
|
|
209336
|
-
const handleTransformCoefficientChange = (event2) => {
|
|
209337
|
-
const { value: value2 } = event2.target;
|
|
209338
|
-
if (!value2) {
|
|
209339
|
-
setGatingFeatureValueTransformCoefficient(value2);
|
|
209340
|
-
} else {
|
|
209341
|
-
const newCoefficient = Number(value2);
|
|
209342
|
-
if (!Number.isNaN(newCoefficient) && newCoefficient >= 0) {
|
|
209343
|
-
setGatingFeatureValueTransformCoefficient(value2);
|
|
209344
|
-
}
|
|
209345
|
-
}
|
|
209346
|
-
};
|
|
209347
|
-
return jsxs(Fragment, { children: [jsxs(TableRow$1, { children: [jsx(TableCell$1, { className: classes.labelCell, children: capitalize$2(plur(featureType, geneSelectOptions == null ? void 0 : geneSelectOptions.length)) }), jsx(TableCell$1, { className: classes.inputCell, children: jsx(OptionSelect, { multiple: true, className: classes.select, value: [gatingFeatureSelectionX, gatingFeatureSelectionY].filter((v) => v), onChange: handleGeneSelectChange, inputProps: {
|
|
209348
|
-
id: "scatterplot-gene-select"
|
|
209349
|
-
}, children: geneSelectOptions.map((name2) => jsx("option", { value: name2, children: name2 }, name2)) }, "gating-gene-select") })] }, "gene-option-row"), jsxs(TableRow$1, { children: [jsx(TableCell$1, { className: classes.labelCell, children: "Transform" }), jsx(TableCell$1, { className: classes.inputCell, children: jsx(OptionSelect, { className: classes.select, value: gatingFeatureValueTransform === null ? "" : gatingFeatureValueTransform, onChange: handleTransformChange, inputProps: {
|
|
209350
|
-
id: "scatterplot-transform-select"
|
|
209351
|
-
}, 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$1, { children: [jsx(TableCell$1, { className: classes.labelCell, children: "Transform Coefficient" }), jsx(TableCell$1, { className: classes.inputCell, children: jsx(TextField$1, { label: "Number", type: "number", onChange: handleTransformCoefficientChange, value: gatingFeatureValueTransformCoefficient, InputLabelProps: {
|
|
209352
|
-
shrink: true
|
|
209353
|
-
} }) })] }, "transform-coefficient-option-row")] });
|
|
209354
|
-
}
|
|
209355
|
-
function GatingSubscriber(props2) {
|
|
209356
|
-
const {
|
|
209357
|
-
uuid,
|
|
209358
|
-
coordinationScopes,
|
|
209359
|
-
removeGridComponent,
|
|
209360
|
-
theme,
|
|
209361
|
-
disableTooltip = false,
|
|
209362
|
-
title: titleOverride,
|
|
209363
|
-
averageFillDensity
|
|
209364
|
-
} = props2;
|
|
209365
|
-
const loaders = useLoaders();
|
|
209366
|
-
const setComponentHover = useSetComponentHover();
|
|
209367
|
-
const setComponentViewInfo = useSetComponentViewInfo(uuid);
|
|
209368
|
-
const [{ dataset, obsType, featureType, featureValueType, embeddingZoom: zoom2, embeddingTargetX: targetX2, embeddingTargetY: targetY2, 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$2.GATING], coordinationScopes);
|
|
209369
|
-
const [urls2, addUrl2] = useUrls(loaders, dataset);
|
|
209370
|
-
const [width2, height2, deckRef] = useDeckCanvasSize();
|
|
209371
|
-
const title2 = React$i.useMemo(() => {
|
|
209372
|
-
if (titleOverride) {
|
|
209373
|
-
return titleOverride;
|
|
209374
|
-
}
|
|
209375
|
-
if (!(gatingFeatureSelectionX && gatingFeatureSelectionY)) {
|
|
209376
|
-
return "Gating";
|
|
209377
|
-
}
|
|
209378
|
-
return `Gating (${gatingFeatureSelectionX} vs ${gatingFeatureSelectionY})`;
|
|
209379
|
-
}, [titleOverride, gatingFeatureSelectionX, gatingFeatureSelectionY]);
|
|
209380
|
-
const featureSelectionX = React$i.useMemo(() => gatingFeatureSelectionX ? [gatingFeatureSelectionX] : null, [gatingFeatureSelectionX]);
|
|
209381
|
-
const featureSelectionY = React$i.useMemo(() => gatingFeatureSelectionY ? [gatingFeatureSelectionY] : null, [gatingFeatureSelectionY]);
|
|
209382
|
-
const [{ obsSets: cellSets }, obsSetsStatus] = useObsSetsData(loaders, dataset, addUrl2, false, { setObsSetSelection: setCellSetSelection, setObsSetColor: setCellSetColor }, { obsSetSelection: cellSetSelection, obsSetColor: cellSetColor }, { obsType });
|
|
209383
|
-
const [expressionDataColor, loadedColor, featureSelectionColorStatus] = useFeatureSelection(loaders, dataset, false, gatingFeatureSelectionColor, { obsType, featureType, featureValueType });
|
|
209384
|
-
const [expressionDataX, loadedX, featureSelectionXStatus] = useFeatureSelection(loaders, dataset, false, featureSelectionX, { obsType, featureType, featureValueType });
|
|
209385
|
-
const [expressionDataY, loadedY, featureSelectionYStatus] = useFeatureSelection(loaders, dataset, false, featureSelectionY, { obsType, featureType, featureValueType });
|
|
209386
|
-
const [{ obsIndex, featureIndex }, matrixIndicesStatus] = useObsFeatureMatrixIndices(loaders, dataset, addUrl2, false, { obsType, featureType, featureValueType });
|
|
209387
|
-
const cellsCount = (obsIndex == null ? void 0 : obsIndex.length) || 0;
|
|
209388
|
-
const isReady = useReady([
|
|
209389
|
-
obsSetsStatus,
|
|
209390
|
-
featureSelectionColorStatus,
|
|
209391
|
-
featureSelectionXStatus,
|
|
209392
|
-
featureSelectionYStatus,
|
|
209393
|
-
matrixIndicesStatus
|
|
209394
|
-
]);
|
|
209395
|
-
const obsXY = React$i.useMemo(() => {
|
|
209396
|
-
if (!(cellsCount && (expressionDataX == null ? void 0 : expressionDataX[0]) && (expressionDataY == null ? void 0 : expressionDataY[0]) && featureSelectionX && featureSelectionY)) {
|
|
209397
|
-
return null;
|
|
209398
|
-
}
|
|
209399
|
-
let coefficient = 1;
|
|
209400
|
-
const parsedTransformCoefficient = Number(featureValueTransformCoefficient);
|
|
209401
|
-
if (!Number.isNaN(parsedTransformCoefficient) && parsedTransformCoefficient > 0) {
|
|
209402
|
-
coefficient = parsedTransformCoefficient;
|
|
209403
|
-
}
|
|
209404
|
-
const transformFunction = getValueTransformFunction(featureValueTransform, coefficient);
|
|
209405
|
-
const obsX = new Float32Array(cellsCount);
|
|
209406
|
-
const obsY = new Float32Array(cellsCount);
|
|
209407
|
-
for (let i2 = 0; i2 < cellsCount; i2 += 1) {
|
|
209408
|
-
obsX[i2] = transformFunction(expressionDataX[0][i2]);
|
|
209409
|
-
obsY[i2] = transformFunction(expressionDataY[0][i2]);
|
|
209410
|
-
}
|
|
209411
|
-
return {
|
|
209412
|
-
data: [obsX, obsY],
|
|
209413
|
-
shape: [2, cellsCount]
|
|
209414
|
-
};
|
|
209415
|
-
}, [
|
|
209416
|
-
cellsCount,
|
|
209417
|
-
expressionDataX,
|
|
209418
|
-
expressionDataY,
|
|
209419
|
-
featureValueTransform,
|
|
209420
|
-
featureValueTransformCoefficient,
|
|
209421
|
-
featureSelectionX,
|
|
209422
|
-
featureSelectionY
|
|
209423
|
-
]);
|
|
209424
|
-
const [dynamicCellRadius, setDynamicCellRadius] = React$i.useState(cellRadiusFixed);
|
|
209425
|
-
const [dynamicCellOpacity, setDynamicCellOpacity] = React$i.useState(cellOpacityFixed);
|
|
209426
|
-
const mergedCellSets = React$i.useMemo(() => mergeObsSets(cellSets, additionalCellSets), [cellSets, additionalCellSets]);
|
|
209427
|
-
const setCellSelectionProp = React$i.useCallback((v) => {
|
|
209428
|
-
setObsSelection(v, additionalCellSets, cellSetColor, setCellSetSelection, setAdditionalCellSets, setCellSetColor, setCellColorEncoding);
|
|
209429
|
-
}, [
|
|
209430
|
-
additionalCellSets,
|
|
209431
|
-
cellSetColor,
|
|
209432
|
-
setCellColorEncoding,
|
|
209433
|
-
setAdditionalCellSets,
|
|
209434
|
-
setCellSetColor,
|
|
209435
|
-
setCellSetSelection
|
|
209436
|
-
]);
|
|
209437
|
-
const cellColors = React$i.useMemo(() => getCellColors({
|
|
209438
|
-
cellColorEncoding,
|
|
209439
|
-
expressionData: expressionDataColor && expressionDataColor[0],
|
|
209440
|
-
geneSelection: gatingFeatureSelectionColor,
|
|
209441
|
-
cellSets: mergedCellSets,
|
|
209442
|
-
cellSetSelection,
|
|
209443
|
-
cellSetColor,
|
|
209444
|
-
obsIndex,
|
|
209445
|
-
theme
|
|
209446
|
-
}), [
|
|
209447
|
-
cellColorEncoding,
|
|
209448
|
-
gatingFeatureSelectionColor,
|
|
209449
|
-
mergedCellSets,
|
|
209450
|
-
theme,
|
|
209451
|
-
cellSetSelection,
|
|
209452
|
-
cellSetColor,
|
|
209453
|
-
expressionDataColor,
|
|
209454
|
-
obsIndex
|
|
209455
|
-
]);
|
|
209456
|
-
const [cellSetPolygonCache, setCellSetPolygonCache] = React$i.useState([]);
|
|
209457
|
-
const cacheHas2 = (cache2, key2) => cache2.findIndex((el2) => isEqual_1(el2[0], key2)) !== -1;
|
|
209458
|
-
const cacheGet = (cache2, key2) => {
|
|
209459
|
-
var _a3;
|
|
209460
|
-
return (_a3 = cache2.find((el2) => isEqual_1(el2[0], key2))) == null ? void 0 : _a3[1];
|
|
209461
|
-
};
|
|
209462
|
-
const cellSetPolygons = React$i.useMemo(() => {
|
|
209463
|
-
var _a3;
|
|
209464
|
-
if ((cellSetLabelsVisible || cellSetPolygonsVisible) && !cacheHas2(cellSetPolygonCache, cellSetSelection) && ((_a3 = mergedCellSets == null ? void 0 : mergedCellSets.tree) == null ? void 0 : _a3.length) && obsXY && obsIndex && (cellSetColor == null ? void 0 : cellSetColor.length)) {
|
|
209465
|
-
const newCellSetPolygons = getCellSetPolygons({
|
|
209466
|
-
obsIndex,
|
|
209467
|
-
obsEmbedding: obsXY,
|
|
209468
|
-
cellSets: mergedCellSets,
|
|
209469
|
-
cellSetSelection,
|
|
209470
|
-
cellSetColor,
|
|
209471
|
-
theme
|
|
209472
|
-
});
|
|
209473
|
-
setCellSetPolygonCache((cache2) => [...cache2, [cellSetSelection, newCellSetPolygons]]);
|
|
209474
|
-
return newCellSetPolygons;
|
|
209475
|
-
}
|
|
209476
|
-
return cacheGet(cellSetPolygonCache, cellSetSelection) || [];
|
|
209477
|
-
}, [
|
|
209478
|
-
cellSetPolygonsVisible,
|
|
209479
|
-
cellSetPolygonCache,
|
|
209480
|
-
cellSetLabelsVisible,
|
|
209481
|
-
theme,
|
|
209482
|
-
obsIndex,
|
|
209483
|
-
obsXY,
|
|
209484
|
-
mergedCellSets,
|
|
209485
|
-
cellSetSelection,
|
|
209486
|
-
cellSetColor
|
|
209487
|
-
]);
|
|
209488
|
-
const cellSelection = React$i.useMemo(() => Array.from(cellColors.keys()), [cellColors]);
|
|
209489
|
-
const [xRange, yRange, xExtent, yExtent, numCells] = React$i.useMemo(() => {
|
|
209490
|
-
if (obsXY && obsXY.data && obsXY.shape) {
|
|
209491
|
-
const cellCount = obsXY.shape[1];
|
|
209492
|
-
const xE = extent$2(obsXY.data[0]);
|
|
209493
|
-
const yE = extent$2(obsXY.data[1]);
|
|
209494
|
-
const xR = xE[1] - xE[0];
|
|
209495
|
-
const yR = yE[1] - yE[0];
|
|
209496
|
-
return [xR, yR, xE, yE, cellCount];
|
|
209497
|
-
}
|
|
209498
|
-
return [null, null, null, null, null];
|
|
209499
|
-
}, [obsXY]);
|
|
209500
|
-
React$i.useEffect(() => {
|
|
209501
|
-
if (xRange && yRange) {
|
|
209502
|
-
const pointSizeDevicePixels = getPointSizeDevicePixels(window.devicePixelRatio, zoom2, xRange, yRange, width2, height2);
|
|
209503
|
-
setDynamicCellRadius(pointSizeDevicePixels);
|
|
209504
|
-
const nextCellOpacityScale = getPointOpacity(zoom2, xRange, yRange, width2, height2, numCells, averageFillDensity);
|
|
209505
|
-
setDynamicCellOpacity(nextCellOpacityScale);
|
|
209506
|
-
if (typeof targetX2 !== "number" || typeof targetY2 !== "number") {
|
|
209507
|
-
const newTargetX = xExtent[0] + xRange / 2;
|
|
209508
|
-
const newTargetY = yExtent[0] + yRange / 2;
|
|
209509
|
-
const newZoom = Math.log2(Math.min(width2 / xRange, height2 / yRange));
|
|
209510
|
-
setTargetX(newTargetX);
|
|
209511
|
-
setTargetY(-newTargetY);
|
|
209512
|
-
setZoom(newZoom);
|
|
209513
|
-
}
|
|
209514
|
-
}
|
|
209515
|
-
}, [
|
|
209516
|
-
xRange,
|
|
209517
|
-
yRange,
|
|
209518
|
-
xExtent,
|
|
209519
|
-
yExtent,
|
|
209520
|
-
numCells,
|
|
209521
|
-
width2,
|
|
209522
|
-
height2,
|
|
209523
|
-
zoom2,
|
|
209524
|
-
averageFillDensity
|
|
209525
|
-
]);
|
|
209526
|
-
const cellSelectionSet = React$i.useMemo(() => new Set(cellSelection), [cellSelection]);
|
|
209527
|
-
const getCellIsSelected = React$i.useCallback((object2, { index: index2 }) => (cellSelectionSet || /* @__PURE__ */ new Set([])).has(obsIndex[index2]) ? 1 : 0, [cellSelectionSet, obsIndex]);
|
|
209528
|
-
const cellRadius = cellRadiusMode === "manual" ? cellRadiusFixed : dynamicCellRadius;
|
|
209529
|
-
const cellOpacity = cellOpacityMode === "manual" ? cellOpacityFixed : dynamicCellOpacity;
|
|
209530
|
-
const getExpressionValue = useExpressionValueGetter({
|
|
209531
|
-
instanceObsIndex: obsIndex,
|
|
209532
|
-
matrixObsIndex: obsIndex,
|
|
209533
|
-
expressionData: expressionDataColor
|
|
209534
|
-
});
|
|
209535
|
-
const getObsInfo = React$i.useCallback((obsId) => {
|
|
209536
|
-
var _a3;
|
|
209537
|
-
const selectedTransformName = (_a3 = VALUE_TRANSFORM_OPTIONS.find((o2) => o2.value === featureValueTransform)) == null ? void 0 : _a3.name;
|
|
209538
|
-
const genePrefix = featureValueTransform ? `${selectedTransformName} ` : "";
|
|
209539
|
-
const obsIdx = obsIndex == null ? void 0 : obsIndex.indexOf(obsId);
|
|
209540
|
-
const obsInfo = { [`${capitalize$2(obsType)} ID`]: obsId };
|
|
209541
|
-
if (gatingFeatureSelectionX && gatingFeatureSelectionY) {
|
|
209542
|
-
obsInfo[genePrefix + gatingFeatureSelectionX] = obsXY.data[0][obsIdx];
|
|
209543
|
-
obsInfo[genePrefix + gatingFeatureSelectionY] = obsXY.data[1][obsIdx];
|
|
209544
|
-
}
|
|
209545
|
-
return obsInfo;
|
|
209546
|
-
}, [
|
|
209547
|
-
obsXY,
|
|
209548
|
-
obsIndex,
|
|
209549
|
-
featureValueTransform,
|
|
209550
|
-
gatingFeatureSelectionX,
|
|
209551
|
-
gatingFeatureSelectionY,
|
|
209552
|
-
obsType
|
|
209553
|
-
]);
|
|
209554
|
-
return jsxs(TitleInfo, { title: title2, info: `${commaNumber(cellsCount)} ${plur(obsType, cellsCount)}`, removeGridComponent, urls: urls2, theme, isReady, options: jsx(ScatterplotOptions, { observationsLabel: obsType, cellRadius: cellRadiusFixed, setCellRadius: setCellRadiusFixed, cellRadiusMode, setCellRadiusMode, cellOpacity: cellOpacityFixed, setCellOpacity: setCellOpacityFixed, cellOpacityMode, setCellOpacityMode, cellSetLabelsVisible, setCellSetLabelsVisible, cellSetLabelSize, setCellSetLabelSize, cellSetPolygonsVisible, setCellSetPolygonsVisible, cellColorEncoding, setCellColorEncoding, geneExpressionColormap, setGeneExpressionColormap, geneExpressionColormapRange, setGeneExpressionColormapRange, children: jsx(GatingScatterplotOptions, { featureType, gatingFeatureSelectionX, setGatingFeatureSelectionX, gatingFeatureSelectionY, setGatingFeatureSelectionY, gatingFeatureValueTransform: featureValueTransform, setGatingFeatureValueTransform: (newValue) => {
|
|
209555
|
-
setFeatureValueTransform(newValue);
|
|
209556
|
-
setTargetX(null);
|
|
209557
|
-
setTargetY(null);
|
|
209558
|
-
setZoom(null);
|
|
209559
|
-
}, 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(ScatterplotWrapper, { ref: deckRef, uuid, theme, hideTools: !(gatingFeatureSelectionX && gatingFeatureSelectionY), viewState: { zoom: zoom2, target: [targetX2, targetY2, targetZ] }, setViewState: ({ zoom: newZoom, target: target2 }) => {
|
|
209560
|
-
setZoom(newZoom);
|
|
209561
|
-
setTargetX(target2[0]);
|
|
209562
|
-
setTargetY(target2[1]);
|
|
209563
|
-
setTargetZ(target2[2] || 0);
|
|
209564
|
-
}, obsEmbeddingIndex: obsIndex, obsEmbedding: obsXY, cellFilter, cellSelection, cellHighlight, cellColors, cellSetPolygons, cellSetLabelSize, cellSetLabelsVisible, cellSetPolygonsVisible, setCellFilter, setCellSelection: setCellSelectionProp, setCellHighlight, cellRadius, cellOpacity, cellColorEncoding, geneExpressionColormap, geneExpressionColormapRange, setComponentHover: () => {
|
|
209565
|
-
setComponentHover(uuid);
|
|
209566
|
-
}, updateViewInfo: setComponentViewInfo, getExpressionValue, getCellIsSelected }), !disableTooltip && jsx(ScatterplotTooltipSubscriber, { parentUuid: uuid, obsHighlight: cellHighlight, width: width2, height: height2, getObsInfo })] });
|
|
209567
|
-
}
|
|
209568
|
-
function register$b() {
|
|
209569
|
-
registerPluginViewType(ViewType$2.GATING, GatingSubscriber, COMPONENT_COORDINATION_TYPES[ViewType$2.GATING]);
|
|
209570
|
-
}
|
|
209571
209590
|
var shortNumber$1 = { exports: {} };
|
|
209572
209591
|
(function(module3, exports3) {
|
|
209573
209592
|
(function(global2, factory2) {
|
|
@@ -209990,7 +210009,8 @@ void main() {
|
|
|
209990
210009
|
ySlice: layerDef.ySlice,
|
|
209991
210010
|
zSlice: layerDef.zSlice,
|
|
209992
210011
|
callback: layerDef.callback,
|
|
209993
|
-
visibilities: layerDef.channels.map((c2) => !layerDef.visible && typeof layerDef.visible === "boolean" ? false : c2.visible)
|
|
210012
|
+
visibilities: layerDef.channels.map((c2) => !layerDef.visible && typeof layerDef.visible === "boolean" ? false : c2.visible),
|
|
210013
|
+
excludeBackground: useTransparentColor
|
|
209994
210014
|
};
|
|
209995
210015
|
if (!loader2 || !layerProps)
|
|
209996
210016
|
return null;
|
|
@@ -210046,6 +210066,7 @@ void main() {
|
|
|
210046
210066
|
ySlice: layerProps.ySlice,
|
|
210047
210067
|
zSlice: layerProps.zSlice,
|
|
210048
210068
|
onViewportLoad: layerProps.callback,
|
|
210069
|
+
excludeBackground: layerProps.excludeBackground,
|
|
210049
210070
|
extensions
|
|
210050
210071
|
});
|
|
210051
210072
|
}
|