@haniffalab/cherita-react 0.2.0-dev.2024-09-26.d9293c4c → 0.2.0-dev.2024-09-26.1ea62883
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/components/dotplot/Dotplot.js +11 -5
- package/dist/components/dotplot/DotplotControls.js +11 -10
- package/dist/components/heatmap/Heatmap.js +11 -5
- package/dist/components/matrixplot/Matrixplot.js +11 -5
- package/dist/components/matrixplot/MatrixplotControls.js +8 -7
- package/dist/components/scatterplot/Scatterplot.js +32 -24
- package/dist/components/search-bar/SearchBar.js +18 -2
- package/dist/components/search-bar/SearchResults.js +8 -8
- package/dist/components/var-list/VarItem.js +25 -22
- package/dist/components/var-list/VarList.js +158 -42
- package/dist/components/var-list/VarSet.js +214 -0
- package/dist/components/violin/Violin.js +42 -26
- package/dist/components/violin/ViolinControls.js +13 -18
- package/dist/constants/constants.js +39 -28
- package/dist/context/DatasetContext.js +81 -29
- package/dist/helpers/zarr-helper.js +35 -13
- package/dist/utils/search.js +3 -56
- package/package.json +2 -2
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.VIOLIN_MODES = exports.
|
|
6
|
+
exports.VIOLIN_MODES = exports.VIOLINPLOT_SCALES = exports.UNSELECTED_POLYGON_FILLCOLOR = exports.SELECTION_MODES = exports.SELECTED_POLYGON_FILLCOLOR = exports.OBS_TYPES = exports.MATRIXPLOT_SCALES = exports.LOCAL_STORAGE_KEY = exports.DOTPLOT_SCALES = exports.COLOR_ENCODINGS = void 0;
|
|
7
7
|
const LOCAL_STORAGE_KEY = exports.LOCAL_STORAGE_KEY = "CHERITA";
|
|
8
8
|
const COLOR_ENCODINGS = exports.COLOR_ENCODINGS = {
|
|
9
9
|
VAR: "var",
|
|
@@ -25,30 +25,41 @@ const VIOLIN_MODES = exports.VIOLIN_MODES = {
|
|
|
25
25
|
MULTIKEY: "multikey",
|
|
26
26
|
GROUPBY: "groupby"
|
|
27
27
|
};
|
|
28
|
-
const
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
}
|
|
28
|
+
const MATRIXPLOT_SCALES = exports.MATRIXPLOT_SCALES = {
|
|
29
|
+
NONE: {
|
|
30
|
+
value: null,
|
|
31
|
+
name: "None"
|
|
32
|
+
},
|
|
33
|
+
GROUP: {
|
|
34
|
+
value: "group",
|
|
35
|
+
name: "Group"
|
|
36
|
+
},
|
|
37
|
+
VAR: {
|
|
38
|
+
value: "var",
|
|
39
|
+
name: "Var"
|
|
40
|
+
}
|
|
41
|
+
};
|
|
42
|
+
const DOTPLOT_SCALES = exports.DOTPLOT_SCALES = {
|
|
43
|
+
NONE: {
|
|
44
|
+
value: null,
|
|
45
|
+
name: "None"
|
|
46
|
+
},
|
|
47
|
+
GROUP: {
|
|
48
|
+
value: "group",
|
|
49
|
+
name: "Group"
|
|
50
|
+
},
|
|
51
|
+
VAR: {
|
|
52
|
+
value: "var",
|
|
53
|
+
name: "Var"
|
|
54
|
+
}
|
|
55
|
+
};
|
|
56
|
+
const VIOLINPLOT_SCALES = exports.VIOLINPLOT_SCALES = {
|
|
57
|
+
WIDTH: {
|
|
58
|
+
value: "width",
|
|
59
|
+
name: "Width"
|
|
60
|
+
},
|
|
61
|
+
COUNT: {
|
|
62
|
+
value: "count",
|
|
63
|
+
name: "Count"
|
|
64
|
+
}
|
|
65
|
+
};
|
|
@@ -28,7 +28,7 @@ const queryClient = new _reactQuery.QueryClient({
|
|
|
28
28
|
},
|
|
29
29
|
queryCache: new _reactQuery.QueryCache({
|
|
30
30
|
onError: (error, query) => {
|
|
31
|
-
console.error(error);
|
|
31
|
+
console.error(error, query);
|
|
32
32
|
}
|
|
33
33
|
})
|
|
34
34
|
});
|
|
@@ -61,6 +61,7 @@ const initialDataset = {
|
|
|
61
61
|
selectedMultiVar: [],
|
|
62
62
|
colorEncoding: null,
|
|
63
63
|
labelObs: [],
|
|
64
|
+
varSets: [],
|
|
64
65
|
sliceBy: {
|
|
65
66
|
obs: false,
|
|
66
67
|
polygons: false
|
|
@@ -75,16 +76,16 @@ const initialDataset = {
|
|
|
75
76
|
cmin: 0,
|
|
76
77
|
cmax: 1
|
|
77
78
|
},
|
|
78
|
-
|
|
79
|
+
scale: {
|
|
80
|
+
dotplot: _constants.DOTPLOT_SCALES.NONE,
|
|
81
|
+
matrixplot: _constants.MATRIXPLOT_SCALES.NONE,
|
|
82
|
+
violinplot: _constants.VIOLINPLOT_SCALES.WIDTH
|
|
83
|
+
},
|
|
79
84
|
meanOnlyExpressed: false,
|
|
80
85
|
expressionCutoff: 0.0
|
|
81
86
|
},
|
|
82
87
|
diseaseDatasets: [],
|
|
83
|
-
selectedDisease:
|
|
84
|
-
id: null,
|
|
85
|
-
name: null,
|
|
86
|
-
genes: []
|
|
87
|
-
}
|
|
88
|
+
selectedDisease: null
|
|
88
89
|
};
|
|
89
90
|
const initializer = initialState => {
|
|
90
91
|
const localObj = (JSON.parse(localStorage.getItem(_constants.LOCAL_STORAGE_KEY)) || {})[initialState.url] || {};
|
|
@@ -172,7 +173,7 @@ function datasetReducer(dataset, action) {
|
|
|
172
173
|
}
|
|
173
174
|
case "select.multivar":
|
|
174
175
|
{
|
|
175
|
-
if (dataset.selectedMultiVar.find(i =>
|
|
176
|
+
if (dataset.selectedMultiVar.find(i => action.var.isSet ? i.name === action.var.name : i.matrix_index === action.var.matrix_index)) {
|
|
176
177
|
return dataset;
|
|
177
178
|
} else {
|
|
178
179
|
return {
|
|
@@ -181,19 +182,23 @@ function datasetReducer(dataset, action) {
|
|
|
181
182
|
};
|
|
182
183
|
}
|
|
183
184
|
}
|
|
184
|
-
case "deselect.
|
|
185
|
+
case "deselect.multivar":
|
|
185
186
|
{
|
|
186
187
|
return {
|
|
187
188
|
...dataset,
|
|
188
|
-
|
|
189
|
-
colorEncoding: dataset.colorEncoding === _constants.COLOR_ENCODINGS.VAR ? null : dataset.colorEncoding
|
|
189
|
+
selectedMultiVar: dataset.selectedMultiVar.filter(a => action.var.isSet ? a.name !== action.var.name : a.matrix_index !== action.var.matrix_index)
|
|
190
190
|
};
|
|
191
191
|
}
|
|
192
|
-
case "
|
|
192
|
+
case "update.multivar":
|
|
193
193
|
{
|
|
194
194
|
return {
|
|
195
195
|
...dataset,
|
|
196
|
-
|
|
196
|
+
selelectedMultiVar: dataset.selectedMultiVar.map(i => {
|
|
197
|
+
if (i.isSet) {
|
|
198
|
+
return action.vars.find(s => s.name === i.name);
|
|
199
|
+
}
|
|
200
|
+
return i;
|
|
201
|
+
})
|
|
197
202
|
};
|
|
198
203
|
}
|
|
199
204
|
case "set.colorEncoding":
|
|
@@ -219,24 +224,72 @@ function datasetReducer(dataset, action) {
|
|
|
219
224
|
colorEncoding: dataset.colorEncoding === _constants.COLOR_ENCODINGS.VAR ? null : dataset.colorEncoding
|
|
220
225
|
};
|
|
221
226
|
}
|
|
222
|
-
case "
|
|
227
|
+
case "add.varSet":
|
|
223
228
|
{
|
|
224
229
|
return {
|
|
225
230
|
...dataset,
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
+
varSets: [...dataset.varSets, action.varSet]
|
|
232
|
+
};
|
|
233
|
+
}
|
|
234
|
+
case "remove.varSet":
|
|
235
|
+
{
|
|
236
|
+
return {
|
|
237
|
+
...dataset,
|
|
238
|
+
varSets: dataset.varSets.filter(a => a.name !== action.varSet.name)
|
|
239
|
+
};
|
|
240
|
+
}
|
|
241
|
+
case "reset.varSets":
|
|
242
|
+
{
|
|
243
|
+
return {
|
|
244
|
+
...dataset,
|
|
245
|
+
varSets: []
|
|
246
|
+
};
|
|
247
|
+
}
|
|
248
|
+
case "add.varSet.var":
|
|
249
|
+
{
|
|
250
|
+
const varSet = dataset.varSets.find(s => s.name === action.varSet.name);
|
|
251
|
+
if (varSet.vars.find(v => _lodash.default.isEqual(v, action.var))) {
|
|
252
|
+
return dataset;
|
|
253
|
+
} else {
|
|
254
|
+
return {
|
|
255
|
+
...dataset,
|
|
256
|
+
varSets: dataset.varSets.map(s => {
|
|
257
|
+
if (s.name === varSet.name) {
|
|
258
|
+
return {
|
|
259
|
+
...s,
|
|
260
|
+
vars: [...s.vars, action.var]
|
|
261
|
+
};
|
|
262
|
+
} else {
|
|
263
|
+
return s;
|
|
264
|
+
}
|
|
265
|
+
})
|
|
266
|
+
};
|
|
267
|
+
}
|
|
268
|
+
}
|
|
269
|
+
case "remove.varSet.var":
|
|
270
|
+
{
|
|
271
|
+
const varSet = dataset.varSets.find(s => s.name === action.varSet.name);
|
|
272
|
+
return {
|
|
273
|
+
...dataset,
|
|
274
|
+
varSets: dataset.varSets.map(s => {
|
|
275
|
+
if (s.name === varSet.name) {
|
|
276
|
+
return {
|
|
277
|
+
...s,
|
|
278
|
+
vars: s.vars.filter(v => v.name !== action.var.name)
|
|
279
|
+
};
|
|
280
|
+
} else {
|
|
281
|
+
return s;
|
|
282
|
+
}
|
|
283
|
+
})
|
|
231
284
|
};
|
|
232
285
|
}
|
|
233
|
-
case "
|
|
286
|
+
case "select.disease":
|
|
234
287
|
{
|
|
235
288
|
return {
|
|
236
289
|
...dataset,
|
|
237
290
|
selectedDisease: {
|
|
238
|
-
|
|
239
|
-
|
|
291
|
+
id: action.id,
|
|
292
|
+
name: action.name
|
|
240
293
|
}
|
|
241
294
|
};
|
|
242
295
|
}
|
|
@@ -244,11 +297,7 @@ function datasetReducer(dataset, action) {
|
|
|
244
297
|
{
|
|
245
298
|
return {
|
|
246
299
|
...dataset,
|
|
247
|
-
selectedDisease:
|
|
248
|
-
id: null,
|
|
249
|
-
name: null,
|
|
250
|
-
genes: []
|
|
251
|
-
}
|
|
300
|
+
selectedDisease: null
|
|
252
301
|
};
|
|
253
302
|
}
|
|
254
303
|
case "set.controls.colorScale":
|
|
@@ -331,13 +380,16 @@ function datasetReducer(dataset, action) {
|
|
|
331
380
|
}
|
|
332
381
|
};
|
|
333
382
|
}
|
|
334
|
-
case "set.controls.
|
|
383
|
+
case "set.controls.scale":
|
|
335
384
|
{
|
|
336
385
|
return {
|
|
337
386
|
...dataset,
|
|
338
387
|
controls: {
|
|
339
388
|
...dataset.controls,
|
|
340
|
-
|
|
389
|
+
scale: {
|
|
390
|
+
...dataset.controls.scale,
|
|
391
|
+
[action.plot]: action.scale
|
|
392
|
+
}
|
|
341
393
|
}
|
|
342
394
|
};
|
|
343
395
|
}
|
|
@@ -66,21 +66,43 @@ const useZarr = function (_ref2) {
|
|
|
66
66
|
};
|
|
67
67
|
};
|
|
68
68
|
exports.useZarr = useZarr;
|
|
69
|
+
const fetchDataFromZarrs = async (inputs, opts) => {
|
|
70
|
+
try {
|
|
71
|
+
const results = await Promise.all(inputs.map(input => fetchDataFromZarr(input.url, input.path, input.s, opts)));
|
|
72
|
+
return results;
|
|
73
|
+
} catch (error) {
|
|
74
|
+
throw new Error(error.message);
|
|
75
|
+
}
|
|
76
|
+
};
|
|
77
|
+
const aggregateData = (inputs, data) => {
|
|
78
|
+
const dataObject = {};
|
|
79
|
+
data.forEach((result, index) => {
|
|
80
|
+
const key = inputs[index].key;
|
|
81
|
+
dataObject[key] = result;
|
|
82
|
+
});
|
|
83
|
+
return dataObject;
|
|
84
|
+
};
|
|
69
85
|
const useMultipleZarr = function (inputs) {
|
|
70
86
|
let opts = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
71
|
-
|
|
87
|
+
let agg = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : aggregateData;
|
|
88
|
+
const [data, setData] = (0, _react.useState)(null);
|
|
89
|
+
const [isPending, setIsPending] = (0, _react.useState)(true);
|
|
90
|
+
const [serverError, setServerError] = (0, _react.useState)(null);
|
|
72
91
|
(0, _react.useEffect)(() => {
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
};
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
92
|
+
setIsPending(true);
|
|
93
|
+
setServerError(null);
|
|
94
|
+
fetchDataFromZarrs(inputs, opts).then(data => {
|
|
95
|
+
setData(agg(inputs, data));
|
|
96
|
+
}).catch(error => {
|
|
97
|
+
setServerError(error.message);
|
|
98
|
+
}).finally(() => {
|
|
99
|
+
setIsPending(false);
|
|
100
|
+
});
|
|
101
|
+
}, [agg, inputs, opts]);
|
|
102
|
+
return {
|
|
103
|
+
data,
|
|
104
|
+
isPending,
|
|
105
|
+
serverError
|
|
106
|
+
};
|
|
85
107
|
};
|
|
86
108
|
exports.useMultipleZarr = useMultipleZarr;
|
package/dist/utils/search.js
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.useVarSearch = exports.
|
|
6
|
+
exports.useVarSearch = exports.useDiseaseSearch = void 0;
|
|
7
7
|
var _react = require("react");
|
|
8
8
|
var _requests = require("./requests");
|
|
9
9
|
var _DatasetContext = require("../context/DatasetContext");
|
|
@@ -28,7 +28,6 @@ exports.useDiseaseSearch = useDiseaseSearch;
|
|
|
28
28
|
const useVarSearch = () => {
|
|
29
29
|
const ENDPOINT = "var/names";
|
|
30
30
|
const dataset = (0, _DatasetContext.useDataset)();
|
|
31
|
-
const dispatch = (0, _DatasetContext.useDatasetDispatch)();
|
|
32
31
|
const [params, setParams] = (0, _react.useState)({
|
|
33
32
|
url: dataset.url,
|
|
34
33
|
col: dataset.varNamesCol,
|
|
@@ -37,62 +36,10 @@ const useVarSearch = () => {
|
|
|
37
36
|
const data = (0, _requests.useFetch)(ENDPOINT, params, {
|
|
38
37
|
enabled: !!params.text.length
|
|
39
38
|
});
|
|
40
|
-
const onSelect = item => {
|
|
41
|
-
dispatch({
|
|
42
|
-
type: "select.var",
|
|
43
|
-
var: item
|
|
44
|
-
});
|
|
45
|
-
dispatch({
|
|
46
|
-
type: "select.multivar",
|
|
47
|
-
var: item
|
|
48
|
-
});
|
|
49
|
-
dispatch({
|
|
50
|
-
type: "set.colorEncoding",
|
|
51
|
-
value: "var"
|
|
52
|
-
});
|
|
53
|
-
};
|
|
54
39
|
return {
|
|
55
40
|
params,
|
|
56
41
|
setParams,
|
|
57
|
-
data
|
|
58
|
-
onSelect
|
|
42
|
+
data
|
|
59
43
|
};
|
|
60
44
|
};
|
|
61
|
-
exports.useVarSearch = useVarSearch;
|
|
62
|
-
const useGetDisease = () => {
|
|
63
|
-
var _dataset$selectedDise, _dataset$selectedDise2, _params$diseaseName;
|
|
64
|
-
const ENDPOINT = "disease/genes";
|
|
65
|
-
const dataset = (0, _DatasetContext.useDataset)();
|
|
66
|
-
const dispatch = (0, _DatasetContext.useDatasetDispatch)();
|
|
67
|
-
const [params, setParams] = (0, _react.useState)({
|
|
68
|
-
url: dataset.url,
|
|
69
|
-
col: dataset.varNamesCol,
|
|
70
|
-
diseaseName: (_dataset$selectedDise = dataset.selectedDisease) === null || _dataset$selectedDise === void 0 ? void 0 : _dataset$selectedDise.name,
|
|
71
|
-
diseaseDatasets: dataset.diseaseDatasets
|
|
72
|
-
});
|
|
73
|
-
(0, _react.useEffect)(() => {
|
|
74
|
-
setParams(p => {
|
|
75
|
-
return {
|
|
76
|
-
...p,
|
|
77
|
-
diseaseName: dataset.selectedDisease.name
|
|
78
|
-
};
|
|
79
|
-
});
|
|
80
|
-
}, [(_dataset$selectedDise2 = dataset.selectedDisease) === null || _dataset$selectedDise2 === void 0 ? void 0 : _dataset$selectedDise2.name]);
|
|
81
|
-
const {
|
|
82
|
-
fetchedData,
|
|
83
|
-
isPending,
|
|
84
|
-
serverError
|
|
85
|
-
} = (0, _requests.useFetch)(ENDPOINT, params, {
|
|
86
|
-
enabled: !!((_params$diseaseName = params.diseaseName) !== null && _params$diseaseName !== void 0 && _params$diseaseName.length)
|
|
87
|
-
});
|
|
88
|
-
(0, _react.useEffect)(() => {
|
|
89
|
-
if (!isPending && !serverError) {
|
|
90
|
-
dispatch({
|
|
91
|
-
type: "set.disease.genes",
|
|
92
|
-
genes: fetchedData
|
|
93
|
-
});
|
|
94
|
-
}
|
|
95
|
-
}, [dispatch, fetchedData, isPending, serverError]);
|
|
96
|
-
return;
|
|
97
|
-
};
|
|
98
|
-
exports.useGetDisease = useGetDisease;
|
|
45
|
+
exports.useVarSearch = useVarSearch;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@haniffalab/cherita-react",
|
|
3
|
-
"version": "0.2.0-dev.2024-09-26.
|
|
3
|
+
"version": "0.2.0-dev.2024-09-26.1ea62883",
|
|
4
4
|
"author": "",
|
|
5
5
|
"license": "",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -85,5 +85,5 @@
|
|
|
85
85
|
"url": "https://github.com/haniffalab/cherita-react/issues"
|
|
86
86
|
},
|
|
87
87
|
"homepage": "https://github.com/haniffalab/cherita-react#readme",
|
|
88
|
-
"prereleaseSha": "
|
|
88
|
+
"prereleaseSha": "1ea628835d7acdea1f92e6058e59a72092d535c4"
|
|
89
89
|
}
|