@haniffalab/cherita-react 0.2.0-dev.2024-05-21.ca7d726c → 0.2.0-dev.2024-09-26.f9979478
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/App.scss +67 -12
- package/dist/components/Offcanvas/index.js +9 -6
- package/dist/components/dotplot/Dotplot.js +5 -189
- package/dist/components/dotplot/DotplotControls.js +197 -0
- package/dist/components/heatmap/Heatmap.js +5 -31
- package/dist/components/heatmap/HeatmapControls.js +36 -0
- package/dist/components/matrixplot/Matrixplot.js +5 -59
- package/dist/components/matrixplot/MatrixplotControls.js +65 -0
- package/dist/components/obs-list/ObsList.js +251 -93
- package/dist/components/obs-list/ObsValueList.js +101 -0
- package/dist/components/obsm-list/ObsmList.js +25 -16
- package/dist/components/scatterplot/Legend.js +28 -36
- package/dist/components/scatterplot/Scatterplot.js +303 -119
- package/dist/components/scatterplot/ScatterplotControls.js +93 -0
- package/dist/components/scatterplot/SpatialControls.js +172 -0
- package/dist/components/scatterplot/Toolbox.js +18 -72
- package/dist/components/search-bar/SearchBar.js +2 -2
- package/dist/components/search-bar/SearchResults.js +2 -2
- package/dist/components/var-list/VarList.js +102 -40
- package/dist/components/violin/Violin.js +7 -46
- package/dist/components/violin/ViolinControls.js +50 -0
- package/dist/constants/colorscales.js +28 -0
- package/dist/constants/constants.js +11 -43
- package/dist/context/DatasetContext.js +122 -23
- package/dist/helpers/color-helper.js +54 -21
- package/dist/helpers/zarr-helper.js +39 -17
- package/dist/index.js +17 -11
- package/dist/utils/LoadingIndicators.js +33 -0
- package/dist/utils/requests.js +1 -1
- package/dist/utils/search.js +4 -3
- package/package.json +10 -4
- package/dist/utils/LoadingSpinner.js +0 -44
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.COLORSCALES = void 0;
|
|
7
|
+
// From plotly https://github.com/plotly/plotly.js/blob/5bc25b490702e5ed61265207833dbd58e8ab27f1/src/components/colorscale/scales.js
|
|
8
|
+
const COLORSCALES = exports.COLORSCALES = {
|
|
9
|
+
Greys: ["#000000", "#ffffff"],
|
|
10
|
+
YlGnBu: ["#081d58", "#253494", "#225ea8", "#1d91c0", "#41b6c4", "#7fcdbb", "#c7e9b4", "#edf8d9", "#ffffd9"],
|
|
11
|
+
Greens: ["#00441b", "#006d2c", "#238b45", "#41ab5d", "#74c476", "#a1d9a5", "#c7e9c0", "#e5f5e0", "#f7fcf5"],
|
|
12
|
+
YlOrRd: ["#800026", "#bd0026", "#e31a1c", "#fc4e2a", "#fd8d3c", "#feb24c", "#fed976", "#ffed9f", "#ffffcc"],
|
|
13
|
+
Bluered: ["#0000ff", "#ff0000"],
|
|
14
|
+
RdBu: ["#050aac", "#6a89f7", "#bebebe", "#dcaa84", "#e6915a", "#b20a1c"],
|
|
15
|
+
Reds: ["#dcdcdc", "#f5c39d", "#f5a069", "#b20a1c"],
|
|
16
|
+
Blues: ["#050aac", "#283cba", "#4664f5", "#5a78f5", "#6a89f7", "#dcdcdc"],
|
|
17
|
+
Picnic: ["#0000ff", "#3399ff", "#66ccff", "#99ccff", "#ccccff", "#ffffff", "#ffccff", "#ff99ff", "#ff66cc", "#ff6666", "#ff0000"],
|
|
18
|
+
Rainbow: ["#96005a", "#0000c8", "#0019ff", "#0098ff", "#2cff96", "#97ff00", "#ffe600", "#ff6f00", "#ff0000"],
|
|
19
|
+
Portland: ["#0c3383", "#0a88ba", "#f2d338", "#f28f38", "#d91e1e"],
|
|
20
|
+
Jet: ["#000083", "#003caa", "#05ffff", "#ffff00", "#fa0000", "#800000"],
|
|
21
|
+
Hot: ["#000000", "#e60000", "#ffd200", "#ffffff"],
|
|
22
|
+
Blackbody: ["#000000", "#e60000", "#e6d200", "#ffffff", "#a0c8ff"],
|
|
23
|
+
Earth: ["#000082", "#00b4b4", "#28d228", "#e6e632", "#784614", "#ffffff"],
|
|
24
|
+
Electric: ["#000000", "#1e0064", "#780064", "#a05a00", "#e6c800", "#fffadc"],
|
|
25
|
+
Viridis: ["#440154", "#48186a", "#472d7b", "#424086", "#3b528b", "#33638d", "#2c728e", "#26828e", "#21918c", "#1fa088", "#28ae80", "#3fbc73", "#5ec962", "#84d44b", "#addc30", "#d8e219", "#fde725"],
|
|
26
|
+
Cividis: ["#00204c", "#002a66", "#00346e", "#273f6c", "#3c4a6c", "#4c556b", "#5b5f6d", "#686a70", "#757575", "#838178", "#929c78", "#a19676", "#b0a572", "#c0af6d", "#d1ba65", "#e1c75c", "#f3db4f", "#ffe945"],
|
|
27
|
+
Accent: ["#7fc97f", "#beaed4", "#fdc086", "#ffff99", "#386cb0", "#f0027f", "#bf5b17", "#666666"]
|
|
28
|
+
};
|
|
@@ -3,51 +3,19 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.VIOLIN_MODES = exports.VIOLINPLOT_STANDARDSCALES = exports.SELECTION_MODES = exports.
|
|
6
|
+
exports.VIOLIN_MODES = exports.VIOLINPLOT_STANDARDSCALES = exports.UNSELECTED_POLYGON_FILLCOLOR = exports.SELECTION_MODES = exports.SELECTED_POLYGON_FILLCOLOR = exports.OBS_TYPES = exports.MATRIXPLOT_STANDARDSCALES = exports.LOCAL_STORAGE_KEY = exports.DOTPLOT_STANDARDSCALES = exports.COLOR_ENCODINGS = void 0;
|
|
7
7
|
const LOCAL_STORAGE_KEY = exports.LOCAL_STORAGE_KEY = "CHERITA";
|
|
8
|
-
const
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
YlGn: ["#ffffe5", "#f7fcb9", "#d9f0a3", "#addd8e", "#78c679", "#41ab5d", "#238443", "#006837", "#004529"],
|
|
17
|
-
Reds: ["#fff5f0", "#fee0d2", "#fcbba1", "#fc9272", "#fb6a4a", "#ef3b2c", "#cb181d", "#a50f15", "#67000d"],
|
|
18
|
-
RdPu: ["#fff7f3", "#fde0dd", "#fcc5c0", "#fa9fb5", "#f768a1", "#dd3497", "#ae017e", "#7a0177", "#49006a"],
|
|
19
|
-
Greens: ["#f7fcf5", "#e5f5e0", "#c7e9c0", "#a1d99b", "#74c476", "#41ab5d", "#238b45", "#006d2c", "#00441b"],
|
|
20
|
-
YlGnBu: ["#ffffd9", "#edf8b1", "#c7e9b4", "#7fcdbb", "#41b6c4", "#1d91c0", "#225ea8", "#253494", "#081d58"],
|
|
21
|
-
Purples: ["#fcfbfd", "#efedf5", "#dadaeb", "#bcbddc", "#9e9ac8", "#807dba", "#6a51a3", "#54278f", "#3f007d"],
|
|
22
|
-
GnBu: ["#f7fcf0", "#e0f3db", "#ccebc5", "#a8ddb5", "#7bccc4", "#4eb3d3", "#2b8cbe", "#0868ac", "#084081"],
|
|
23
|
-
Greys: ["#ffffff", "#f0f0f0", "#d9d9d9", "#bdbdbd", "#969696", "#737373", "#525252", "#252525", "#000000"],
|
|
24
|
-
YlOrRd: ["#ffffcc", "#ffeda0", "#fed976", "#feb24c", "#fd8d3c", "#fc4e2a", "#e31a1c", "#bd0026", "#800026"],
|
|
25
|
-
PuRd: ["#f7f4f9", "#e7e1ef", "#d4b9da", "#c994c7", "#df65b0", "#e7298a", "#ce1256", "#980043", "#67001f"],
|
|
26
|
-
Blues: ["#f7fbff", "#deebf7", "#c6dbef", "#9ecae1", "#6baed6", "#4292c6", "#2171b5", "#08519c", "#08306b"],
|
|
27
|
-
PuBuGn: ["#fff7fb", "#ece2f0", "#d0d1e6", "#a6bddb", "#67a9cf", "#3690c0", "#02818a", "#016c59", "#014636"],
|
|
28
|
-
Viridis: ["#440154", "#482777", "#3f4a8a", "#31678e", "#26838f", "#1f9d8a", "#6cce5a", "#b6de2b", "#fee825"],
|
|
29
|
-
// diverging
|
|
30
|
-
|
|
31
|
-
Spectral: ["#9e0142", "#d53e4f", "#f46d43", "#fdae61", "#fee08b", "#ffffbf", "#e6f598", "#abdda4", "#66c2a5", "#3288bd", "#5e4fa2"],
|
|
32
|
-
RdYlGn: ["#a50026", "#d73027", "#f46d43", "#fdae61", "#fee08b", "#ffffbf", "#d9ef8b", "#a6d96a", "#66bd63", "#1a9850", "#006837"],
|
|
33
|
-
RdBu: ["#67001f", "#b2182b", "#d6604d", "#f4a582", "#fddbc7", "#f7f7f7", "#d1e5f0", "#92c5de", "#4393c3", "#2166ac", "#053061"],
|
|
34
|
-
PiYG: ["#8e0152", "#c51b7d", "#de77ae", "#f1b6da", "#fde0ef", "#f7f7f7", "#e6f5d0", "#b8e186", "#7fbc41", "#4d9221", "#276419"],
|
|
35
|
-
PRGn: ["#40004b", "#762a83", "#9970ab", "#c2a5cf", "#e7d4e8", "#f7f7f7", "#d9f0d3", "#a6dba0", "#5aae61", "#1b7837", "#00441b"],
|
|
36
|
-
RdYlBu: ["#a50026", "#d73027", "#f46d43", "#fdae61", "#fee090", "#ffffbf", "#e0f3f8", "#abd9e9", "#74add1", "#4575b4", "#313695"],
|
|
37
|
-
BrBG: ["#543005", "#8c510a", "#bf812d", "#dfc27d", "#f6e8c3", "#f5f5f5", "#c7eae5", "#80cdc1", "#35978f", "#01665e", "#003c30"],
|
|
38
|
-
RdGy: ["#67001f", "#b2182b", "#d6604d", "#f4a582", "#fddbc7", "#ffffff", "#e0e0e0", "#bababa", "#878787", "#4d4d4d", "#1a1a1a"],
|
|
39
|
-
PuOr: ["#7f3b08", "#b35806", "#e08214", "#fdb863", "#fee0b6", "#f7f7f7", "#d8daeb", "#b2abd2", "#8073ac", "#542788", "#2d004b"],
|
|
40
|
-
// qualitative
|
|
41
|
-
|
|
42
|
-
Set2: ["#66c2a5", "#fc8d62", "#8da0cb", "#e78ac3", "#a6d854", "#ffd92f", "#e5c494", "#b3b3b3"],
|
|
43
|
-
Accent: ["#7fc97f", "#beaed4", "#fdc086", "#ffff99", "#386cb0", "#f0027f", "#bf5b17", "#666666"],
|
|
44
|
-
Set1: ["#e41a1c", "#377eb8", "#4daf4a", "#984ea3", "#ff7f00", "#ffff33", "#a65628", "#f781bf", "#999999"],
|
|
45
|
-
Set3: ["#8dd3c7", "#ffffb3", "#bebada", "#fb8072", "#80b1d3", "#fdb462", "#b3de69", "#fccde5", "#d9d9d9", "#bc80bd", "#ccebc5", "#ffed6f"],
|
|
46
|
-
Dark2: ["#1b9e77", "#d95f02", "#7570b3", "#e7298a", "#66a61e", "#e6ab02", "#a6761d", "#666666"],
|
|
47
|
-
Paired: ["#a6cee3", "#1f78b4", "#b2df8a", "#33a02c", "#fb9a99", "#e31a1c", "#fdbf6f", "#ff7f00", "#cab2d6", "#6a3d9a", "#ffff99", "#b15928"],
|
|
48
|
-
Pastel2: ["#b3e2cd", "#fdcdac", "#cbd5e8", "#f4cae4", "#e6f5c9", "#fff2ae", "#f1e2cc", "#cccccc"],
|
|
49
|
-
Pastel1: ["#fbb4ae", "#b3cde3", "#ccebc5", "#decbe4", "#fed9a6", "#ffffcc", "#e5d8bd", "#fddaec", "#f2f2f2"]
|
|
8
|
+
const COLOR_ENCODINGS = exports.COLOR_ENCODINGS = {
|
|
9
|
+
VAR: "var",
|
|
10
|
+
OBS: "obs"
|
|
11
|
+
};
|
|
12
|
+
const OBS_TYPES = exports.OBS_TYPES = {
|
|
13
|
+
CATEGORICAL: "categorical",
|
|
14
|
+
DISCRETE: "discrete",
|
|
15
|
+
CONTINUOUS: "continuous"
|
|
50
16
|
};
|
|
17
|
+
const SELECTED_POLYGON_FILLCOLOR = exports.SELECTED_POLYGON_FILLCOLOR = [107, 170, 209, 255 / 2];
|
|
18
|
+
const UNSELECTED_POLYGON_FILLCOLOR = exports.UNSELECTED_POLYGON_FILLCOLOR = [167, 191, 211, 255 / 3];
|
|
51
19
|
const SELECTION_MODES = exports.SELECTION_MODES = {
|
|
52
20
|
SINGLE: "single",
|
|
53
21
|
MULTIPLE: "multiple"
|
|
@@ -8,15 +8,15 @@ exports.DatasetProvider = DatasetProvider;
|
|
|
8
8
|
exports.useDataset = useDataset;
|
|
9
9
|
exports.useDatasetDispatch = useDatasetDispatch;
|
|
10
10
|
var _react = _interopRequireWildcard(require("react"));
|
|
11
|
-
var
|
|
11
|
+
var _querySyncStoragePersister = require("@tanstack/query-sync-storage-persister");
|
|
12
12
|
var _reactQuery = require("@tanstack/react-query");
|
|
13
13
|
var _reactQueryPersistClient = require("@tanstack/react-query-persist-client");
|
|
14
|
-
var
|
|
14
|
+
var _lodash = _interopRequireDefault(require("lodash"));
|
|
15
15
|
var _constants = require("../constants/constants");
|
|
16
16
|
var _jsxRuntime = require("react/jsx-runtime");
|
|
17
|
-
function _interopRequireDefault(
|
|
17
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
18
18
|
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
|
|
19
|
-
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u &&
|
|
19
|
+
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
|
20
20
|
const DatasetContext = exports.DatasetContext = /*#__PURE__*/(0, _react.createContext)(null);
|
|
21
21
|
const DatasetDispatchContext = exports.DatasetDispatchContext = /*#__PURE__*/(0, _react.createContext)(null);
|
|
22
22
|
const queryClient = new _reactQuery.QueryClient({
|
|
@@ -52,7 +52,6 @@ const persistOptions = {
|
|
|
52
52
|
// @TODO: add maxAge and buster (app and api version numbers as busters)
|
|
53
53
|
};
|
|
54
54
|
const initialDataset = {
|
|
55
|
-
obs: {},
|
|
56
55
|
varNamesCol: null,
|
|
57
56
|
selectedObs: null,
|
|
58
57
|
selectedObsm: null,
|
|
@@ -60,8 +59,15 @@ const initialDataset = {
|
|
|
60
59
|
selectedMultiObs: [],
|
|
61
60
|
selectedMultiVar: [],
|
|
62
61
|
colorEncoding: null,
|
|
62
|
+
labelObs: [],
|
|
63
|
+
sliceBy: {
|
|
64
|
+
obs: false,
|
|
65
|
+
polygons: false
|
|
66
|
+
},
|
|
63
67
|
controls: {
|
|
64
68
|
colorScale: "Viridis",
|
|
69
|
+
valueRange: [0, 1],
|
|
70
|
+
range: [0, 1],
|
|
65
71
|
colorAxis: {
|
|
66
72
|
dmin: 0,
|
|
67
73
|
dmax: 1,
|
|
@@ -72,9 +78,6 @@ const initialDataset = {
|
|
|
72
78
|
meanOnlyExpressed: false,
|
|
73
79
|
expressionCutoff: 0.0
|
|
74
80
|
},
|
|
75
|
-
state: {
|
|
76
|
-
obs: {}
|
|
77
|
-
},
|
|
78
81
|
diseaseDatasets: [],
|
|
79
82
|
selectedDisease: {
|
|
80
83
|
id: null,
|
|
@@ -100,7 +103,9 @@ function DatasetProvider(_ref2) {
|
|
|
100
103
|
}), dataset_params));
|
|
101
104
|
(0, _react.useEffect)(() => {
|
|
102
105
|
try {
|
|
106
|
+
const localObj = JSON.parse(localStorage.getItem(_constants.LOCAL_STORAGE_KEY)) || {};
|
|
103
107
|
localStorage.setItem(_constants.LOCAL_STORAGE_KEY, JSON.stringify({
|
|
108
|
+
...localObj,
|
|
104
109
|
[dataset.url]: dataset
|
|
105
110
|
}));
|
|
106
111
|
} catch (err) {
|
|
@@ -131,35 +136,33 @@ function useDatasetDispatch() {
|
|
|
131
136
|
}
|
|
132
137
|
function datasetReducer(dataset, action) {
|
|
133
138
|
switch (action.type) {
|
|
134
|
-
case "
|
|
135
|
-
{
|
|
136
|
-
return {
|
|
137
|
-
...dataset,
|
|
138
|
-
obs: action.value
|
|
139
|
-
};
|
|
140
|
-
}
|
|
141
|
-
case "obsSelected":
|
|
139
|
+
case "select.obs":
|
|
142
140
|
{
|
|
141
|
+
var _action$obs;
|
|
143
142
|
return {
|
|
144
143
|
...dataset,
|
|
145
|
-
selectedObs: action.obs
|
|
144
|
+
selectedObs: action.obs,
|
|
145
|
+
controls: {
|
|
146
|
+
...dataset.controls,
|
|
147
|
+
range: ((_action$obs = action.obs) === null || _action$obs === void 0 ? void 0 : _action$obs.type) === _constants.OBS_TYPES.CATEGORICAL ? [0, 1] : dataset.controls.range
|
|
148
|
+
}
|
|
146
149
|
};
|
|
147
150
|
}
|
|
148
|
-
case "
|
|
151
|
+
case "select.obsm":
|
|
149
152
|
{
|
|
150
153
|
return {
|
|
151
154
|
...dataset,
|
|
152
155
|
selectedObsm: action.obsm
|
|
153
156
|
};
|
|
154
157
|
}
|
|
155
|
-
case "
|
|
158
|
+
case "select.var":
|
|
156
159
|
{
|
|
157
160
|
return {
|
|
158
161
|
...dataset,
|
|
159
162
|
selectedVar: action.var
|
|
160
163
|
};
|
|
161
164
|
}
|
|
162
|
-
case "
|
|
165
|
+
case "select.multivar":
|
|
163
166
|
{
|
|
164
167
|
if (dataset.selectedMultiVar.find(i => _lodash.default.isEqual(i, action.var))) {
|
|
165
168
|
return dataset;
|
|
@@ -170,7 +173,15 @@ function datasetReducer(dataset, action) {
|
|
|
170
173
|
};
|
|
171
174
|
}
|
|
172
175
|
}
|
|
173
|
-
case "
|
|
176
|
+
case "deselect.var":
|
|
177
|
+
{
|
|
178
|
+
return {
|
|
179
|
+
...dataset,
|
|
180
|
+
selectedVar: null,
|
|
181
|
+
colorEncoding: dataset.colorEncoding === _constants.COLOR_ENCODINGS.VAR ? null : dataset.colorEncoding
|
|
182
|
+
};
|
|
183
|
+
}
|
|
184
|
+
case "deselect.multivar":
|
|
174
185
|
{
|
|
175
186
|
return {
|
|
176
187
|
...dataset,
|
|
@@ -188,14 +199,16 @@ function datasetReducer(dataset, action) {
|
|
|
188
199
|
{
|
|
189
200
|
return {
|
|
190
201
|
...dataset,
|
|
191
|
-
selectedMultiVar: []
|
|
202
|
+
selectedMultiVar: [],
|
|
203
|
+
colorEncoding: dataset.colorEncoding === _constants.COLOR_ENCODINGS.VAR ? null : dataset.colorEncoding
|
|
192
204
|
};
|
|
193
205
|
}
|
|
194
206
|
case "reset.var":
|
|
195
207
|
{
|
|
196
208
|
return {
|
|
197
209
|
...dataset,
|
|
198
|
-
selectedVar: null
|
|
210
|
+
selectedVar: null,
|
|
211
|
+
colorEncoding: dataset.colorEncoding === _constants.COLOR_ENCODINGS.VAR ? null : dataset.colorEncoding
|
|
199
212
|
};
|
|
200
213
|
}
|
|
201
214
|
case "select.disease":
|
|
@@ -240,6 +253,26 @@ function datasetReducer(dataset, action) {
|
|
|
240
253
|
}
|
|
241
254
|
};
|
|
242
255
|
}
|
|
256
|
+
case "set.controls.valueRange":
|
|
257
|
+
{
|
|
258
|
+
return {
|
|
259
|
+
...dataset,
|
|
260
|
+
controls: {
|
|
261
|
+
...dataset.controls,
|
|
262
|
+
valueRange: action.valueRange
|
|
263
|
+
}
|
|
264
|
+
};
|
|
265
|
+
}
|
|
266
|
+
case "set.controls.range":
|
|
267
|
+
{
|
|
268
|
+
return {
|
|
269
|
+
...dataset,
|
|
270
|
+
controls: {
|
|
271
|
+
...dataset.controls,
|
|
272
|
+
range: action.range
|
|
273
|
+
}
|
|
274
|
+
};
|
|
275
|
+
}
|
|
243
276
|
case "set.controls.colorAxis":
|
|
244
277
|
{
|
|
245
278
|
return {
|
|
@@ -320,6 +353,72 @@ function datasetReducer(dataset, action) {
|
|
|
320
353
|
}
|
|
321
354
|
};
|
|
322
355
|
}
|
|
356
|
+
case "toggle.slice.obs":
|
|
357
|
+
{
|
|
358
|
+
if (_lodash.default.isEqual(dataset.selectedObs, action.obs)) {
|
|
359
|
+
return {
|
|
360
|
+
...dataset,
|
|
361
|
+
sliceBy: {
|
|
362
|
+
...dataset.sliceBy,
|
|
363
|
+
obs: !dataset.sliceBy.obs
|
|
364
|
+
}
|
|
365
|
+
};
|
|
366
|
+
} else {
|
|
367
|
+
return {
|
|
368
|
+
...dataset,
|
|
369
|
+
selectedObs: action.obs,
|
|
370
|
+
sliceBy: {
|
|
371
|
+
...dataset.sliceBy,
|
|
372
|
+
obs: true
|
|
373
|
+
}
|
|
374
|
+
};
|
|
375
|
+
}
|
|
376
|
+
}
|
|
377
|
+
case "toggle.slice.polygons":
|
|
378
|
+
{
|
|
379
|
+
return {
|
|
380
|
+
...dataset,
|
|
381
|
+
sliceBy: {
|
|
382
|
+
...dataset.sliceBy,
|
|
383
|
+
polygons: !dataset.sliceBy.polygons
|
|
384
|
+
}
|
|
385
|
+
};
|
|
386
|
+
}
|
|
387
|
+
case "disable.slice.polygons":
|
|
388
|
+
{
|
|
389
|
+
return {
|
|
390
|
+
...dataset,
|
|
391
|
+
sliceBy: {
|
|
392
|
+
...dataset.sliceBy,
|
|
393
|
+
polygons: false
|
|
394
|
+
}
|
|
395
|
+
};
|
|
396
|
+
}
|
|
397
|
+
case "add.label.obs":
|
|
398
|
+
{
|
|
399
|
+
if (dataset.labelObs.find(i => _lodash.default.isEqual(i, action.obs))) {
|
|
400
|
+
return dataset;
|
|
401
|
+
} else {
|
|
402
|
+
return {
|
|
403
|
+
...dataset,
|
|
404
|
+
labelObs: [...dataset.labelObs, action.obs]
|
|
405
|
+
};
|
|
406
|
+
}
|
|
407
|
+
}
|
|
408
|
+
case "remove.label.obs":
|
|
409
|
+
{
|
|
410
|
+
return {
|
|
411
|
+
...dataset,
|
|
412
|
+
labelObs: dataset.labelObs.filter(a => a.name !== action.obsName)
|
|
413
|
+
};
|
|
414
|
+
}
|
|
415
|
+
case "reset.label.obs":
|
|
416
|
+
{
|
|
417
|
+
return {
|
|
418
|
+
...dataset,
|
|
419
|
+
labelObs: []
|
|
420
|
+
};
|
|
421
|
+
}
|
|
323
422
|
default:
|
|
324
423
|
{
|
|
325
424
|
throw Error("Unknown action: " + action.type);
|
|
@@ -3,34 +3,67 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.useColor = void 0;
|
|
7
|
-
var _chromaJs = _interopRequireDefault(require("chroma-js"));
|
|
8
|
-
var _lodash = _interopRequireDefault(require("lodash"));
|
|
9
|
-
var _constants = require("../constants/constants");
|
|
10
|
-
var _DatasetContext = require("../context/DatasetContext");
|
|
6
|
+
exports.useColor = exports.rgbToHex = void 0;
|
|
11
7
|
var _react = require("react");
|
|
12
|
-
|
|
8
|
+
var _colorscales = require("../constants/colorscales");
|
|
9
|
+
var _DatasetContext = require("../context/DatasetContext");
|
|
10
|
+
const GRAY = [214, 212, 212];
|
|
11
|
+
const parseHexColor = color => {
|
|
12
|
+
const r = parseInt(color === null || color === void 0 ? void 0 : color.substring(1, 3), 16);
|
|
13
|
+
const g = parseInt(color === null || color === void 0 ? void 0 : color.substring(3, 5), 16);
|
|
14
|
+
const b = parseInt(color === null || color === void 0 ? void 0 : color.substring(5, 7), 16);
|
|
15
|
+
return [r, g, b];
|
|
16
|
+
};
|
|
17
|
+
const interpolateColor = (color1, color2, factor) => {
|
|
18
|
+
const [r1, g1, b1] = parseHexColor(color1);
|
|
19
|
+
const [r2, g2, b2] = parseHexColor(color2);
|
|
20
|
+
const r = Math.round(r1 + factor * (r2 - r1));
|
|
21
|
+
const g = Math.round(g1 + factor * (g2 - g1));
|
|
22
|
+
const b = Math.round(b1 + factor * (b2 - b1));
|
|
23
|
+
return [r, g, b];
|
|
24
|
+
};
|
|
25
|
+
const computeColor = (colormap, value) => {
|
|
26
|
+
if (!colormap || Number.isNaN(value)) {
|
|
27
|
+
return [0, 0, 0, 255];
|
|
28
|
+
} else if (value <= 0) {
|
|
29
|
+
return parseHexColor(colormap[0]);
|
|
30
|
+
} else if (value >= 1) {
|
|
31
|
+
return parseHexColor(colormap[colormap.length - 1]);
|
|
32
|
+
}
|
|
33
|
+
const index1 = Math.floor(value * (colormap.length - 1));
|
|
34
|
+
const index2 = Math.ceil(value * (colormap.length - 1));
|
|
35
|
+
const factor = value * (colormap.length - 1) % 1;
|
|
36
|
+
return interpolateColor(colormap[index1], colormap[index2], factor);
|
|
37
|
+
};
|
|
38
|
+
const rgbToHex = color => {
|
|
39
|
+
const [r, g, b] = color || [0, 0, 0, 0];
|
|
40
|
+
return "#" + ((1 << 24) + (r << 16) + (g << 8) + b).toString(16).slice(1);
|
|
41
|
+
};
|
|
42
|
+
exports.rgbToHex = rgbToHex;
|
|
13
43
|
const useColor = () => {
|
|
14
|
-
var _dataset$selectedObs2;
|
|
15
44
|
const dataset = (0, _DatasetContext.useDataset)();
|
|
16
|
-
const
|
|
17
|
-
let
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
45
|
+
const getColor = (0, _react.useCallback)(function (value) {
|
|
46
|
+
let categorical = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
|
|
47
|
+
let grayOut = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
|
|
48
|
+
let {
|
|
49
|
+
alpha = 0.75,
|
|
50
|
+
gray = 0.95
|
|
51
|
+
} = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {};
|
|
52
|
+
let colorEncoding = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : dataset.colorEncoding;
|
|
53
|
+
const colormap = _colorscales.COLORSCALES[categorical ? "Accent" : dataset.controls.colorScale];
|
|
54
|
+
if (colorEncoding) {
|
|
55
|
+
if (grayOut) {
|
|
56
|
+
// Mix color with gray manually instead of chroma.mix to get better performance with deck.gl
|
|
57
|
+
const rgb = computeColor(colormap, value);
|
|
58
|
+
return [rgb[0] * (1 - gray) + GRAY[0] * gray, rgb[1] * (1 - gray) + GRAY[1] * gray, rgb[2] * (1 - gray) + GRAY[2] * gray, 255 * alpha];
|
|
59
|
+
} else {
|
|
60
|
+
return [...computeColor(colormap, value), 255];
|
|
61
|
+
}
|
|
28
62
|
} else {
|
|
29
63
|
return null;
|
|
30
64
|
}
|
|
31
|
-
}, [dataset.colorEncoding, dataset.
|
|
65
|
+
}, [dataset.colorEncoding, dataset.controls.colorScale]);
|
|
32
66
|
return {
|
|
33
|
-
getScale,
|
|
34
67
|
getColor
|
|
35
68
|
};
|
|
36
69
|
};
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.useZarr = exports.ZarrHelper = exports.GET_OPTIONS = void 0;
|
|
6
|
+
exports.useZarr = exports.useMultipleZarr = exports.ZarrHelper = exports.GET_OPTIONS = void 0;
|
|
7
7
|
var _react = require("react");
|
|
8
8
|
var _zarr = require("zarr");
|
|
9
9
|
const GET_OPTIONS = exports.GET_OPTIONS = {
|
|
@@ -28,6 +28,16 @@ class ZarrHelper {
|
|
|
28
28
|
}
|
|
29
29
|
}
|
|
30
30
|
exports.ZarrHelper = ZarrHelper;
|
|
31
|
+
const fetchDataFromZarr = async (url, path, s, opts) => {
|
|
32
|
+
try {
|
|
33
|
+
const zarrHelper = new ZarrHelper();
|
|
34
|
+
const z = await zarrHelper.open(url, path);
|
|
35
|
+
const result = await z.get(s, opts);
|
|
36
|
+
return result.data;
|
|
37
|
+
} catch (error) {
|
|
38
|
+
throw new Error(error.message);
|
|
39
|
+
}
|
|
40
|
+
};
|
|
31
41
|
const useZarr = function (_ref2) {
|
|
32
42
|
let {
|
|
33
43
|
url,
|
|
@@ -39,21 +49,15 @@ const useZarr = function (_ref2) {
|
|
|
39
49
|
const [isPending, setIsPending] = (0, _react.useState)(true);
|
|
40
50
|
const [serverError, setServerError] = (0, _react.useState)(null);
|
|
41
51
|
(0, _react.useEffect)(() => {
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
setServerError(error.message);
|
|
52
|
-
} finally {
|
|
53
|
-
setIsPending(false);
|
|
54
|
-
}
|
|
55
|
-
};
|
|
56
|
-
fetchData();
|
|
52
|
+
setIsPending(true);
|
|
53
|
+
setServerError(null);
|
|
54
|
+
fetchDataFromZarr(url, path, s, opts).then(data => {
|
|
55
|
+
setData(data);
|
|
56
|
+
}).catch(error => {
|
|
57
|
+
setServerError(error.message);
|
|
58
|
+
}).finally(() => {
|
|
59
|
+
setIsPending(false);
|
|
60
|
+
});
|
|
57
61
|
}, [opts, path, s, url]);
|
|
58
62
|
return {
|
|
59
63
|
data,
|
|
@@ -61,4 +65,22 @@ const useZarr = function (_ref2) {
|
|
|
61
65
|
serverError
|
|
62
66
|
};
|
|
63
67
|
};
|
|
64
|
-
exports.useZarr = useZarr;
|
|
68
|
+
exports.useZarr = useZarr;
|
|
69
|
+
const useMultipleZarr = function (inputs) {
|
|
70
|
+
let opts = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
71
|
+
const [results, setResults] = (0, _react.useState)({});
|
|
72
|
+
(0, _react.useEffect)(() => {
|
|
73
|
+
const fetchData = async () => {
|
|
74
|
+
const results = await Promise.all(inputs.map(input => fetchDataFromZarr(input.url, input.path, input.s, opts)));
|
|
75
|
+
const dataObject = {};
|
|
76
|
+
results.forEach((result, index) => {
|
|
77
|
+
const key = inputs[index].key;
|
|
78
|
+
dataObject[key] = result;
|
|
79
|
+
});
|
|
80
|
+
setResults(dataObject);
|
|
81
|
+
};
|
|
82
|
+
fetchData();
|
|
83
|
+
}, [inputs, opts]);
|
|
84
|
+
return results;
|
|
85
|
+
};
|
|
86
|
+
exports.useMultipleZarr = useMultipleZarr;
|
package/dist/index.js
CHANGED
|
@@ -3,6 +3,12 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
+
Object.defineProperty(exports, "COLORSCALES", {
|
|
7
|
+
enumerable: true,
|
|
8
|
+
get: function () {
|
|
9
|
+
return _colorscales.COLORSCALES;
|
|
10
|
+
}
|
|
11
|
+
});
|
|
6
12
|
Object.defineProperty(exports, "DatasetProvider", {
|
|
7
13
|
enumerable: true,
|
|
8
14
|
get: function () {
|
|
@@ -18,7 +24,7 @@ Object.defineProperty(exports, "Dotplot", {
|
|
|
18
24
|
Object.defineProperty(exports, "DotplotControls", {
|
|
19
25
|
enumerable: true,
|
|
20
26
|
get: function () {
|
|
21
|
-
return
|
|
27
|
+
return _DotplotControls.DotplotControls;
|
|
22
28
|
}
|
|
23
29
|
});
|
|
24
30
|
Object.defineProperty(exports, "Heatmap", {
|
|
@@ -30,7 +36,7 @@ Object.defineProperty(exports, "Heatmap", {
|
|
|
30
36
|
Object.defineProperty(exports, "HeatmapControls", {
|
|
31
37
|
enumerable: true,
|
|
32
38
|
get: function () {
|
|
33
|
-
return
|
|
39
|
+
return _HeatmapControls.HeatmapControls;
|
|
34
40
|
}
|
|
35
41
|
});
|
|
36
42
|
Object.defineProperty(exports, "Matrixplot", {
|
|
@@ -42,7 +48,7 @@ Object.defineProperty(exports, "Matrixplot", {
|
|
|
42
48
|
Object.defineProperty(exports, "MatrixplotControls", {
|
|
43
49
|
enumerable: true,
|
|
44
50
|
get: function () {
|
|
45
|
-
return
|
|
51
|
+
return _MatrixplotControls.MatrixplotControls;
|
|
46
52
|
}
|
|
47
53
|
});
|
|
48
54
|
Object.defineProperty(exports, "ObsColsList", {
|
|
@@ -87,12 +93,6 @@ Object.defineProperty(exports, "OffcanvasVars", {
|
|
|
87
93
|
return _Offcanvas.OffcanvasVars;
|
|
88
94
|
}
|
|
89
95
|
});
|
|
90
|
-
Object.defineProperty(exports, "PLOTLY_COLORSCALES", {
|
|
91
|
-
enumerable: true,
|
|
92
|
-
get: function () {
|
|
93
|
-
return _constants.PLOTLY_COLORSCALES;
|
|
94
|
-
}
|
|
95
|
-
});
|
|
96
96
|
Object.defineProperty(exports, "SELECTION_MODES", {
|
|
97
97
|
enumerable: true,
|
|
98
98
|
get: function () {
|
|
@@ -108,7 +108,7 @@ Object.defineProperty(exports, "Scatterplot", {
|
|
|
108
108
|
Object.defineProperty(exports, "ScatterplotControls", {
|
|
109
109
|
enumerable: true,
|
|
110
110
|
get: function () {
|
|
111
|
-
return
|
|
111
|
+
return _ScatterplotControls.ScatterplotControls;
|
|
112
112
|
}
|
|
113
113
|
});
|
|
114
114
|
Object.defineProperty(exports, "SearchBar", {
|
|
@@ -138,7 +138,7 @@ Object.defineProperty(exports, "Violin", {
|
|
|
138
138
|
Object.defineProperty(exports, "ViolinControls", {
|
|
139
139
|
enumerable: true,
|
|
140
140
|
get: function () {
|
|
141
|
-
return
|
|
141
|
+
return _ViolinControls.ViolinControls;
|
|
142
142
|
}
|
|
143
143
|
});
|
|
144
144
|
var _ObsList = require("./components/obs-list/ObsList");
|
|
@@ -146,10 +146,16 @@ var _ObsmList = require("./components/obsm-list/ObsmList");
|
|
|
146
146
|
var _VarList = require("./components/var-list/VarList");
|
|
147
147
|
var _SearchBar = require("./components/search-bar/SearchBar");
|
|
148
148
|
var _Heatmap = require("./components/heatmap/Heatmap");
|
|
149
|
+
var _HeatmapControls = require("./components/heatmap/HeatmapControls");
|
|
149
150
|
var _Dotplot = require("./components/dotplot/Dotplot");
|
|
151
|
+
var _DotplotControls = require("./components/dotplot/DotplotControls");
|
|
150
152
|
var _Scatterplot = require("./components/scatterplot/Scatterplot");
|
|
153
|
+
var _ScatterplotControls = require("./components/scatterplot/ScatterplotControls");
|
|
151
154
|
var _Matrixplot = require("./components/matrixplot/Matrixplot");
|
|
155
|
+
var _MatrixplotControls = require("./components/matrixplot/MatrixplotControls");
|
|
152
156
|
var _Violin = require("./components/violin/Violin");
|
|
157
|
+
var _ViolinControls = require("./components/violin/ViolinControls");
|
|
153
158
|
var _constants = require("./constants/constants");
|
|
159
|
+
var _colorscales = require("./constants/colorscales");
|
|
154
160
|
var _DatasetContext = require("./context/DatasetContext");
|
|
155
161
|
var _Offcanvas = require("./components/Offcanvas");
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.LoadingSpinner = exports.LoadingLinear = void 0;
|
|
7
|
+
var _material = require("@mui/material");
|
|
8
|
+
var _jsxRuntime = require("react/jsx-runtime");
|
|
9
|
+
const LoadingSpinner = _ref => {
|
|
10
|
+
let {
|
|
11
|
+
text = null,
|
|
12
|
+
disableShrink = false
|
|
13
|
+
} = _ref;
|
|
14
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsxs)("div", {
|
|
15
|
+
className: "loading-spinner",
|
|
16
|
+
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_material.CircularProgress, {
|
|
17
|
+
disableShrink: disableShrink
|
|
18
|
+
}), (text === null || text === void 0 ? void 0 : text.length) && /*#__PURE__*/(0, _jsxRuntime.jsx)("span", {
|
|
19
|
+
className: "visually-hidden",
|
|
20
|
+
children: text
|
|
21
|
+
})]
|
|
22
|
+
});
|
|
23
|
+
};
|
|
24
|
+
exports.LoadingSpinner = LoadingSpinner;
|
|
25
|
+
const LoadingLinear = () => {
|
|
26
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_material.Box, {
|
|
27
|
+
sx: {
|
|
28
|
+
width: "100%"
|
|
29
|
+
},
|
|
30
|
+
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_material.LinearProgress, {})
|
|
31
|
+
});
|
|
32
|
+
};
|
|
33
|
+
exports.LoadingLinear = LoadingLinear;
|
package/dist/utils/requests.js
CHANGED
|
@@ -5,8 +5,8 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.fetchData = fetchData;
|
|
7
7
|
exports.useFetch = exports.useDebouncedFetch = void 0;
|
|
8
|
-
var _usehooks = require("@uidotdev/usehooks");
|
|
9
8
|
var _reactQuery = require("@tanstack/react-query");
|
|
9
|
+
var _usehooks = require("@uidotdev/usehooks");
|
|
10
10
|
var _errors = require("./errors");
|
|
11
11
|
async function fetchData(endpoint, params) {
|
|
12
12
|
let signal = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null;
|