@vitessce/vit-s 2.0.3 → 3.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +44072 -0
- package/dist-tsc/CallbackPublisher.d.ts +18 -0
- package/dist-tsc/CallbackPublisher.d.ts.map +1 -0
- package/dist-tsc/CallbackPublisher.js +62 -0
- package/dist-tsc/LoadingIndicator.d.ts +2 -0
- package/dist-tsc/LoadingIndicator.d.ts.map +1 -0
- package/dist-tsc/LoadingIndicator.js +26 -0
- package/dist-tsc/TitleInfo.d.ts +2 -0
- package/dist-tsc/TitleInfo.d.ts.map +1 -0
- package/dist-tsc/TitleInfo.js +74 -0
- package/dist-tsc/VitS.d.ts +50 -0
- package/dist-tsc/VitS.d.ts.map +1 -0
- package/dist-tsc/VitS.js +139 -0
- package/dist-tsc/VitessceGrid.d.ts +23 -0
- package/dist-tsc/VitessceGrid.d.ts.map +1 -0
- package/dist-tsc/VitessceGrid.js +63 -0
- package/dist-tsc/VitessceGrid.test.d.ts +2 -0
- package/dist-tsc/VitessceGrid.test.d.ts.map +1 -0
- package/dist-tsc/VitessceGrid.test.js +43 -0
- package/dist-tsc/Warning.d.ts +2 -0
- package/dist-tsc/Warning.d.ts.map +1 -0
- package/dist-tsc/Warning.js +45 -0
- package/dist-tsc/classNames.d.ts +8 -0
- package/dist-tsc/classNames.d.ts.map +1 -0
- package/dist-tsc/classNames.js +8 -0
- package/dist-tsc/data/AbstractLoader.d.ts +22 -0
- package/dist-tsc/data/AbstractLoader.d.ts.map +1 -0
- package/dist-tsc/data/AbstractLoader.js +18 -0
- package/dist-tsc/data/AbstractTwoStepLoader.d.ts +6 -0
- package/dist-tsc/data/AbstractTwoStepLoader.d.ts.map +1 -0
- package/dist-tsc/data/AbstractTwoStepLoader.js +7 -0
- package/dist-tsc/data/LoaderResult.d.ts +12 -0
- package/dist-tsc/data/LoaderResult.d.ts.map +1 -0
- package/dist-tsc/data/LoaderResult.js +12 -0
- package/dist-tsc/data/index.d.ts +4 -0
- package/dist-tsc/data/index.d.ts.map +1 -0
- package/dist-tsc/data/index.js +3 -0
- package/dist-tsc/data/loader-registry.d.ts +9 -0
- package/dist-tsc/data/loader-registry.d.ts.map +1 -0
- package/dist-tsc/data/loader-registry.js +27 -0
- package/dist-tsc/data-hook-utils.d.ts +65 -0
- package/dist-tsc/data-hook-utils.d.ts.map +1 -0
- package/dist-tsc/data-hook-utils.js +191 -0
- package/dist-tsc/data-hooks.d.ts +73 -0
- package/dist-tsc/data-hooks.d.ts.map +1 -0
- package/dist-tsc/data-hooks.js +254 -0
- package/dist-tsc/errors/AbstractLoaderError.d.ts +10 -0
- package/dist-tsc/errors/AbstractLoaderError.d.ts.map +1 -0
- package/dist-tsc/errors/AbstractLoaderError.js +13 -0
- package/dist-tsc/errors/DataSourceFetchError.d.ts +8 -0
- package/dist-tsc/errors/DataSourceFetchError.d.ts.map +1 -0
- package/dist-tsc/errors/DataSourceFetchError.js +13 -0
- package/dist-tsc/errors/DatasetNotFoundError.d.ts +6 -0
- package/dist-tsc/errors/DatasetNotFoundError.d.ts.map +1 -0
- package/dist-tsc/errors/DatasetNotFoundError.js +17 -0
- package/dist-tsc/errors/LoaderNotFoundError.d.ts +10 -0
- package/dist-tsc/errors/LoaderNotFoundError.d.ts.map +1 -0
- package/dist-tsc/errors/LoaderNotFoundError.js +17 -0
- package/dist-tsc/errors/LoaderValidationError.d.ts +10 -0
- package/dist-tsc/errors/LoaderValidationError.d.ts.map +1 -0
- package/dist-tsc/errors/LoaderValidationError.js +15 -0
- package/dist-tsc/errors/index.d.ts +6 -0
- package/dist-tsc/errors/index.d.ts.map +1 -0
- package/dist-tsc/errors/index.js +5 -0
- package/dist-tsc/hooks.d.ts +76 -0
- package/dist-tsc/hooks.d.ts.map +1 -0
- package/dist-tsc/hooks.js +262 -0
- package/dist-tsc/index.d.ts +12 -0
- package/dist-tsc/index.d.ts.map +1 -0
- package/dist-tsc/index.js +11 -17
- package/dist-tsc/mui-utils.d.ts +2 -0
- package/dist-tsc/mui-utils.d.ts.map +1 -0
- package/dist-tsc/mui-utils.js +44 -0
- package/dist-tsc/plugins.test.fixtures.d.ts +61 -0
- package/dist-tsc/plugins.test.fixtures.d.ts.map +1 -0
- package/dist-tsc/plugins.test.fixtures.js +76 -0
- package/dist-tsc/shared-mui/components.d.ts +2 -0
- package/dist-tsc/shared-mui/components.d.ts.map +1 -0
- package/dist-tsc/shared-mui/components.js +29 -0
- package/dist-tsc/shared-mui/container.d.ts +2 -0
- package/dist-tsc/shared-mui/container.d.ts.map +1 -0
- package/dist-tsc/shared-mui/container.js +211 -0
- package/dist-tsc/shared-mui/styles.d.ts +5 -0
- package/dist-tsc/shared-mui/styles.d.ts.map +1 -0
- package/dist-tsc/shared-mui/styles.js +109 -0
- package/dist-tsc/shared-plot-options/CellColorEncodingOption.d.ts +2 -0
- package/dist-tsc/shared-plot-options/CellColorEncodingOption.d.ts.map +1 -0
- package/dist-tsc/shared-plot-options/CellColorEncodingOption.js +17 -0
- package/dist-tsc/shared-plot-options/OptionSelect.d.ts +2 -0
- package/dist-tsc/shared-plot-options/OptionSelect.d.ts.map +1 -0
- package/dist-tsc/shared-plot-options/OptionSelect.js +12 -0
- package/dist-tsc/shared-plot-options/OptionsContainer.d.ts +2 -0
- package/dist-tsc/shared-plot-options/OptionsContainer.d.ts.map +1 -0
- package/dist-tsc/shared-plot-options/OptionsContainer.js +9 -0
- package/dist-tsc/shared-plot-options/index.d.ts +5 -0
- package/dist-tsc/shared-plot-options/index.d.ts.map +1 -0
- package/dist-tsc/shared-plot-options/index.js +4 -0
- package/dist-tsc/shared-plot-options/styles.d.ts +2 -0
- package/dist-tsc/shared-plot-options/styles.d.ts.map +1 -0
- package/dist-tsc/shared-plot-options/styles.js +48 -0
- package/dist-tsc/state/hooks.d.ts +242 -0
- package/dist-tsc/state/hooks.d.ts.map +1 -0
- package/dist-tsc/state/hooks.js +615 -0
- package/dist-tsc/title-styles.d.ts +2 -0
- package/dist-tsc/title-styles.d.ts.map +1 -0
- package/dist-tsc/title-styles.js +72 -0
- package/dist-tsc/view-config-utils.d.ts +31 -0
- package/dist-tsc/view-config-utils.d.ts.map +1 -0
- package/dist-tsc/view-config-utils.js +240 -0
- package/dist-tsc/view-config-utils.test.d.ts +2 -0
- package/dist-tsc/view-config-utils.test.d.ts.map +1 -0
- package/dist-tsc/view-config-utils.test.fixtures.d.ts +1049 -0
- package/dist-tsc/view-config-utils.test.fixtures.d.ts.map +1 -0
- package/dist-tsc/view-config-utils.test.fixtures.js +883 -0
- package/dist-tsc/view-config-utils.test.js +210 -0
- package/dist-tsc/vitessce-grid-layout/VitessceGridLayout.d.ts +8 -0
- package/dist-tsc/vitessce-grid-layout/VitessceGridLayout.d.ts.map +1 -0
- package/dist-tsc/vitessce-grid-layout/VitessceGridLayout.js +114 -0
- package/dist-tsc/vitessce-grid-layout/VitessceGridLayout.test.d.ts +2 -0
- package/dist-tsc/vitessce-grid-layout/VitessceGridLayout.test.d.ts.map +1 -0
- package/dist-tsc/vitessce-grid-layout/VitessceGridLayout.test.js +48 -0
- package/dist-tsc/vitessce-grid-layout/index.d.ts +2 -0
- package/dist-tsc/vitessce-grid-layout/index.d.ts.map +1 -0
- package/dist-tsc/vitessce-grid-layout/index.js +1 -0
- package/dist-tsc/vitessce-grid-layout/layout-utils.d.ts +15 -0
- package/dist-tsc/vitessce-grid-layout/layout-utils.d.ts.map +1 -0
- package/dist-tsc/vitessce-grid-layout/layout-utils.js +61 -0
- package/dist-tsc/vitessce-grid-layout/layout-utils.test.d.ts +2 -0
- package/dist-tsc/vitessce-grid-layout/layout-utils.test.d.ts.map +1 -0
- package/dist-tsc/vitessce-grid-layout/layout-utils.test.js +149 -0
- package/dist-tsc/vitessce-grid-utils.d.ts +13 -0
- package/dist-tsc/vitessce-grid-utils.d.ts.map +1 -0
- package/dist-tsc/vitessce-grid-utils.js +141 -0
- package/package.json +25 -11
- package/src/CallbackPublisher.js +7 -11
- package/src/LoadingIndicator.js +1 -2
- package/src/TitleInfo.js +12 -85
- package/src/VitS.js +143 -85
- package/src/VitessceGrid.js +35 -21
- package/src/VitessceGrid.test.jsx +23 -8
- package/src/Warning.js +4 -4
- package/src/data/AbstractLoader.js +2 -25
- package/src/data/AbstractTwoStepLoader.js +1 -1
- package/src/data/LoaderResult.js +5 -0
- package/src/data/index.js +3 -3
- package/src/data/loader-registry.js +22 -13
- package/src/data-hook-utils.js +119 -86
- package/src/data-hooks.js +150 -131
- package/src/errors/DataSourceFetchError.js +2 -2
- package/src/errors/DatasetNotFoundError.js +1 -1
- package/src/errors/LoaderNotFoundError.js +1 -1
- package/src/errors/LoaderValidationError.js +1 -1
- package/src/errors/index.js +5 -6
- package/src/hooks.js +81 -26
- package/src/index.js +23 -46
- package/src/mui-utils.js +52 -0
- package/src/shared-mui/components.js +10 -8
- package/src/shared-mui/container.js +1 -1
- package/src/shared-mui/styles.js +5 -2
- package/src/shared-plot-options/CellColorEncodingOption.js +3 -4
- package/src/shared-plot-options/OptionSelect.js +3 -3
- package/src/shared-plot-options/OptionsContainer.js +2 -5
- package/src/shared-plot-options/index.js +4 -4
- package/src/shared-plot-options/styles.js +2 -2
- package/src/state/hooks.js +75 -23
- package/src/title-styles.js +73 -0
- package/src/view-config-utils.js +54 -98
- package/src/view-config-utils.test.jsx +223 -0
- package/src/vitessce-grid-layout/VitessceGridLayout.js +51 -30
- package/src/vitessce-grid-layout/VitessceGridLayout.test.jsx +17 -9
- package/src/vitessce-grid-layout/index.js +1 -1
- package/src/vitessce-grid-layout/layout-utils.js +1 -1
- package/src/vitessce-grid-layout/layout-utils.test.js +2 -1
- package/src/vitessce-grid-utils.js +27 -15
- package/dist/index.mjs +0 -84801
- package/src/component-registry.js +0 -21
- package/src/errors/OptionsValidationError.js +0 -25
- package/src/file-options-schemas-legacy.js +0 -139
- package/src/file-options-schemas-legacy.test.js +0 -138
- package/src/file-options-schemas.js +0 -327
- package/src/file-options-schemas.test.js +0 -26
- package/src/joint-file-types-legacy.js +0 -298
- package/src/joint-file-types-legacy.test.js +0 -412
- package/src/joint-file-types.js +0 -171
- package/src/joint-file-types.test.js +0 -144
- package/src/json-schemas.js +0 -9
- package/src/plugins.js +0 -186
- package/src/plugins.test.js +0 -42
- package/src/schemas/config-0.1.0.schema.json +0 -85
- package/src/schemas/config-1.0.0.schema.json +0 -733
- package/src/schemas/config-1.0.1.schema.json +0 -909
- package/src/schemas/config-1.0.10.schema.json +0 -969
- package/src/schemas/config-1.0.11.schema.json +0 -990
- package/src/schemas/config-1.0.12.schema.json +0 -997
- package/src/schemas/config-1.0.13.schema.json +0 -1013
- package/src/schemas/config-1.0.14.schema.json +0 -1048
- package/src/schemas/config-1.0.15.schema.json +0 -1048
- package/src/schemas/config-1.0.16.schema.json +0 -1069
- package/src/schemas/config-1.0.16.schema.test.js +0 -32
- package/src/schemas/config-1.0.2.schema.json +0 -911
- package/src/schemas/config-1.0.3.schema.json +0 -911
- package/src/schemas/config-1.0.4.schema.json +0 -949
- package/src/schemas/config-1.0.5.schema.json +0 -949
- package/src/schemas/config-1.0.6.schema.json +0 -950
- package/src/schemas/config-1.0.7.schema.json +0 -950
- package/src/schemas/config-1.0.8.schema.json +0 -966
- package/src/schemas/config-1.0.9.schema.json +0 -965
- package/src/schemas/obsSets.schema.js +0 -195
- package/src/schemas/obsSetsTabular.schema.js +0 -39
- package/src/schemas/raster.schema.js +0 -121
- package/src/schemas/schema-schema.sh +0 -34
- package/src/schemas/schema.test-old.js +0 -49
- package/src/view-config-upgraders.js +0 -628
- package/src/view-config-utils.test.js +0 -95
- package/src/view-config-versions.js +0 -68
|
@@ -0,0 +1,254 @@
|
|
|
1
|
+
import { useState, useEffect, useMemo } from 'react';
|
|
2
|
+
import { CoordinationType, DataType, STATUS } from '@vitessce/constants-internal';
|
|
3
|
+
import { fromEntries } from '@vitessce/utils';
|
|
4
|
+
import { useQuery, useQueries } from '@tanstack/react-query';
|
|
5
|
+
import { getMatchingLoader, useMultiCoordinationValues, useSetWarning, } from './state/hooks.js';
|
|
6
|
+
import { LoaderNotFoundError, } from './errors/index.js';
|
|
7
|
+
import { warn, useDataType, useDataTypeMulti, } from './data-hook-utils.js';
|
|
8
|
+
/**
|
|
9
|
+
* Get the dataset description string.
|
|
10
|
+
* @param {object} loaders The object mapping
|
|
11
|
+
* datasets and data types to loader instances.
|
|
12
|
+
* @param {string} dataset The key for a dataset,
|
|
13
|
+
* used to identify which loader to use.
|
|
14
|
+
* @returns {array} [description] where
|
|
15
|
+
* description is a string.
|
|
16
|
+
*/
|
|
17
|
+
export function useDescription(loaders, dataset) {
|
|
18
|
+
const [description, setDescription] = useState();
|
|
19
|
+
useEffect(() => {
|
|
20
|
+
if (!loaders[dataset]) {
|
|
21
|
+
return;
|
|
22
|
+
}
|
|
23
|
+
if (loaders[dataset].description) {
|
|
24
|
+
setDescription(loaders[dataset].description);
|
|
25
|
+
}
|
|
26
|
+
else {
|
|
27
|
+
setDescription(null);
|
|
28
|
+
}
|
|
29
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
30
|
+
}, [loaders, dataset]);
|
|
31
|
+
return [description];
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Get data from a cells data type loader,
|
|
35
|
+
* updating "ready" and URL state appropriately.
|
|
36
|
+
* Throw warnings if the data is marked as required.
|
|
37
|
+
* Subscribe to loader updates.
|
|
38
|
+
* @param {object} loaders The object mapping
|
|
39
|
+
* datasets and data types to loader instances.
|
|
40
|
+
* @param {string} dataset The key for a dataset,
|
|
41
|
+
* used to identify which loader to use.
|
|
42
|
+
* @param {boolean} isRequired Should a warning be thrown if
|
|
43
|
+
* loading is unsuccessful?
|
|
44
|
+
* @param {object} coordinationSetters Object where
|
|
45
|
+
* keys are coordination type names with the prefix 'set',
|
|
46
|
+
* values are coordination setter functions.
|
|
47
|
+
* @param {object} initialCoordinationValues Object where
|
|
48
|
+
* keys are coordination type names with the prefix 'initialize',
|
|
49
|
+
* values are initialization preferences as boolean values.
|
|
50
|
+
* @returns {array} [cells, cellsCount] where
|
|
51
|
+
* cells is an object and cellsCount is the
|
|
52
|
+
* number of items in the cells object.
|
|
53
|
+
*/
|
|
54
|
+
export function useObsEmbeddingData(loaders, dataset, isRequired, coordinationSetters, initialCoordinationValues, matchOn) {
|
|
55
|
+
return useDataType(DataType.OBS_EMBEDDING, loaders, dataset, isRequired, coordinationSetters, initialCoordinationValues, matchOn);
|
|
56
|
+
}
|
|
57
|
+
export function useObsLocationsData(loaders, dataset, isRequired, coordinationSetters, initialCoordinationValues, matchOn) {
|
|
58
|
+
return useDataType(DataType.OBS_LOCATIONS, loaders, dataset, isRequired, coordinationSetters, initialCoordinationValues, matchOn);
|
|
59
|
+
}
|
|
60
|
+
export function useObsLabelsData(loaders, dataset, isRequired, coordinationSetters, initialCoordinationValues, matchOn) {
|
|
61
|
+
return useDataType(DataType.OBS_LABELS, loaders, dataset, isRequired, coordinationSetters, initialCoordinationValues, matchOn);
|
|
62
|
+
}
|
|
63
|
+
export function useObsSegmentationsData(loaders, dataset, isRequired, coordinationSetters, initialCoordinationValues, matchOn) {
|
|
64
|
+
return useDataType(DataType.OBS_SEGMENTATIONS, loaders, dataset, isRequired, coordinationSetters, initialCoordinationValues, matchOn);
|
|
65
|
+
}
|
|
66
|
+
export function useObsSetsData(loaders, dataset, isRequired, coordinationSetters, initialCoordinationValues, matchOn) {
|
|
67
|
+
return useDataType(DataType.OBS_SETS, loaders, dataset, isRequired, coordinationSetters, initialCoordinationValues, matchOn);
|
|
68
|
+
}
|
|
69
|
+
export function useObsFeatureMatrixData(loaders, dataset, isRequired, coordinationSetters, initialCoordinationValues, matchOn) {
|
|
70
|
+
return useDataType(DataType.OBS_FEATURE_MATRIX, loaders, dataset, isRequired, coordinationSetters, initialCoordinationValues, matchOn);
|
|
71
|
+
}
|
|
72
|
+
export function useFeatureLabelsData(loaders, dataset, isRequired, coordinationSetters, initialCoordinationValues, matchOn) {
|
|
73
|
+
return useDataType(DataType.FEATURE_LABELS, loaders, dataset, isRequired, coordinationSetters, initialCoordinationValues, matchOn);
|
|
74
|
+
}
|
|
75
|
+
export function useImageData(loaders, dataset, isRequired, coordinationSetters, initialCoordinationValues, matchOn) {
|
|
76
|
+
return useDataType(DataType.IMAGE, loaders, dataset, isRequired, coordinationSetters, initialCoordinationValues, matchOn);
|
|
77
|
+
}
|
|
78
|
+
export function useGenomicProfilesData(loaders, dataset, isRequired, coordinationSetters, initialCoordinationValues, matchOn) {
|
|
79
|
+
return useDataType(DataType.GENOMIC_PROFILES, loaders, dataset, isRequired, coordinationSetters, initialCoordinationValues, matchOn);
|
|
80
|
+
}
|
|
81
|
+
export function useNeighborhoodsData(loaders, dataset, isRequired, coordinationSetters, initialCoordinationValues, matchOn) {
|
|
82
|
+
return useDataType(DataType.NEIGHBORHOODS, loaders, dataset, isRequired, coordinationSetters, initialCoordinationValues, matchOn);
|
|
83
|
+
}
|
|
84
|
+
/**
|
|
85
|
+
* Get data from the expression matrix data type loader for a given gene selection.
|
|
86
|
+
* Throw warnings if the data is marked as required.
|
|
87
|
+
* Subscribe to loader updates.
|
|
88
|
+
* @param {object} loaders The object mapping
|
|
89
|
+
* datasets and data types to loader instances.
|
|
90
|
+
* @param {string} dataset The key for a dataset,
|
|
91
|
+
* used to identify which loader to use.
|
|
92
|
+
* @param {boolean} isRequired Should a warning be thrown if
|
|
93
|
+
* loading is unsuccessful?
|
|
94
|
+
* @param {boolean} selection A list of gene names to get expression data for.
|
|
95
|
+
* @returns {array} [geneData] where geneData is an array [Uint8Array, ..., Uint8Array]
|
|
96
|
+
* for however many genes are in the selection.
|
|
97
|
+
*/
|
|
98
|
+
export function useFeatureSelection(loaders, dataset, isRequired, selection, matchOn) {
|
|
99
|
+
const setWarning = useSetWarning();
|
|
100
|
+
const featureQueries = useQueries({
|
|
101
|
+
queries: selection?.map(featureId => ({
|
|
102
|
+
structuralSharing: false,
|
|
103
|
+
placeholderData: null,
|
|
104
|
+
queryKey: [dataset, DataType.OBS_FEATURE_MATRIX, matchOn, featureId, 'useFeatureSelection'],
|
|
105
|
+
// Query function should return an object
|
|
106
|
+
// { data, dataKey } where dataKey is the loaded gene selection.
|
|
107
|
+
queryFn: async (ctx) => {
|
|
108
|
+
const loader = getMatchingLoader(ctx.meta.loaders, ctx.queryKey[0], ctx.queryKey[1], ctx.queryKey[2]);
|
|
109
|
+
if (loader) {
|
|
110
|
+
const implementsGeneSelection = typeof loader.loadGeneSelection === 'function';
|
|
111
|
+
if (implementsGeneSelection) {
|
|
112
|
+
const payload = await loader.loadGeneSelection({ selection: [featureId] });
|
|
113
|
+
if (!payload)
|
|
114
|
+
return null;
|
|
115
|
+
const { data } = payload;
|
|
116
|
+
return { data: data[0], dataKey: selection };
|
|
117
|
+
}
|
|
118
|
+
// Loader does not implement loadGeneSelection.
|
|
119
|
+
const payload = await loader.load();
|
|
120
|
+
if (!payload)
|
|
121
|
+
return null;
|
|
122
|
+
const { data } = payload;
|
|
123
|
+
const { obsIndex, featureIndex, obsFeatureMatrix } = data;
|
|
124
|
+
// Compute expressionData
|
|
125
|
+
const geneIndex = featureIndex.indexOf(featureId);
|
|
126
|
+
const numGenes = featureIndex.length;
|
|
127
|
+
const numCells = obsIndex.length;
|
|
128
|
+
const expressionData = new Float32Array(numCells);
|
|
129
|
+
for (let cellIndex = 0; cellIndex < numCells; cellIndex += 1) {
|
|
130
|
+
expressionData[cellIndex] = obsFeatureMatrix.data[cellIndex * numGenes + geneIndex];
|
|
131
|
+
}
|
|
132
|
+
return { data: expressionData, dataKey: featureId };
|
|
133
|
+
}
|
|
134
|
+
// No loader was found.
|
|
135
|
+
if (isRequired) {
|
|
136
|
+
throw new LoaderNotFoundError(loaders, dataset, DataType.OBS_FEATURE_MATRIX, matchOn);
|
|
137
|
+
}
|
|
138
|
+
else {
|
|
139
|
+
return { data: null, dataKey: null };
|
|
140
|
+
}
|
|
141
|
+
},
|
|
142
|
+
meta: { loaders },
|
|
143
|
+
})) || [],
|
|
144
|
+
});
|
|
145
|
+
const anyLoading = featureQueries.some(q => q.isFetching);
|
|
146
|
+
const anyError = featureQueries.some(q => q.isError);
|
|
147
|
+
// eslint-disable-next-line no-nested-ternary
|
|
148
|
+
const dataStatus = anyLoading ? STATUS.LOADING : (anyError ? STATUS.ERROR : STATUS.SUCCESS);
|
|
149
|
+
const isSuccess = dataStatus === STATUS.SUCCESS;
|
|
150
|
+
const geneData = isSuccess ? featureQueries.map(q => q.data?.data || null) : null;
|
|
151
|
+
const loadedGeneName = isSuccess ? featureQueries.map(q => q.data?.dataKey || null) : null;
|
|
152
|
+
useEffect(() => {
|
|
153
|
+
featureQueries
|
|
154
|
+
.map(q => q.error)
|
|
155
|
+
.filter(e => Boolean(e))
|
|
156
|
+
.forEach((error) => {
|
|
157
|
+
warn(error, setWarning);
|
|
158
|
+
});
|
|
159
|
+
// Deliberate dependency omissions: use indirect dependencies for efficiency.
|
|
160
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
161
|
+
}, [anyError, setWarning]);
|
|
162
|
+
return [geneData, loadedGeneName, dataStatus];
|
|
163
|
+
}
|
|
164
|
+
/**
|
|
165
|
+
* Get the attributes for the expression matrix data type loader,
|
|
166
|
+
* i.e names of cells and genes.
|
|
167
|
+
* Throw warnings if the data is marked as required.
|
|
168
|
+
* Subscribe to loader updates. Should not be used in conjunction (called in the same component)
|
|
169
|
+
* with useExpressionMatrixData.
|
|
170
|
+
* @param {object} loaders The object mapping
|
|
171
|
+
* datasets and data types to loader instances.
|
|
172
|
+
* @param {string} dataset The key for a dataset,
|
|
173
|
+
* used to identify which loader to use.
|
|
174
|
+
* @param {boolean} isRequired Should a warning be thrown if
|
|
175
|
+
* loading is unsuccessful?
|
|
176
|
+
* @returns {object} [attrs] { rows, cols } object containing cell and gene names.
|
|
177
|
+
*/
|
|
178
|
+
export function useObsFeatureMatrixIndices(loaders, dataset, isRequired, matchOn) {
|
|
179
|
+
const setWarning = useSetWarning();
|
|
180
|
+
const placeholderObject = useMemo(() => ({}), []);
|
|
181
|
+
const indicesQuery = useQuery({
|
|
182
|
+
// TODO: only enable once `loaders` is available?
|
|
183
|
+
structuralSharing: false,
|
|
184
|
+
placeholderData: placeholderObject,
|
|
185
|
+
// Include the hook name in the queryKey to prevent the case in which an identical queryKey
|
|
186
|
+
// in a different hook would cause an accidental cache hit.
|
|
187
|
+
queryKey: [dataset, DataType.OBS_FEATURE_MATRIX, matchOn, 'useObsFeatureMatrixIndices'],
|
|
188
|
+
// Query function should return an object
|
|
189
|
+
// { data, dataKey } where dataKey is the loaded gene selection.
|
|
190
|
+
// TODO: use TypeScript to type the return value?
|
|
191
|
+
queryFn: async (ctx) => {
|
|
192
|
+
const loader = getMatchingLoader(ctx.meta.loaders, ctx.queryKey[0], ctx.queryKey[1], ctx.queryKey[2]);
|
|
193
|
+
if (loader) {
|
|
194
|
+
const implementsLoadAttrs = typeof loader.loadAttrs === 'function';
|
|
195
|
+
if (implementsLoadAttrs) {
|
|
196
|
+
// Has loadAttrs function.
|
|
197
|
+
const payload = await loader.loadAttrs();
|
|
198
|
+
if (!payload)
|
|
199
|
+
return placeholderObject;
|
|
200
|
+
const { data: payloadData, url } = payload;
|
|
201
|
+
return {
|
|
202
|
+
data: {
|
|
203
|
+
obsIndex: payloadData.rows,
|
|
204
|
+
featureIndex: payloadData.cols,
|
|
205
|
+
},
|
|
206
|
+
urls: [{ url, name: DataType.OBS_FEATURE_MATRIX }],
|
|
207
|
+
};
|
|
208
|
+
}
|
|
209
|
+
// No loadAttrs function.
|
|
210
|
+
const payload = await loader.load();
|
|
211
|
+
if (!payload)
|
|
212
|
+
return placeholderObject;
|
|
213
|
+
const { data: payloadData, url } = payload;
|
|
214
|
+
return {
|
|
215
|
+
data: {
|
|
216
|
+
obsIndex: payloadData.obsIndex,
|
|
217
|
+
featureIndex: payloadData.featureIndex,
|
|
218
|
+
},
|
|
219
|
+
urls: [{ url, name: DataType.OBS_FEATURE_MATRIX }],
|
|
220
|
+
};
|
|
221
|
+
}
|
|
222
|
+
// No loader was found.
|
|
223
|
+
if (isRequired) {
|
|
224
|
+
// Status: error
|
|
225
|
+
throw new LoaderNotFoundError(loaders, dataset, DataType.OBS_FEATURE_MATRIX, matchOn);
|
|
226
|
+
}
|
|
227
|
+
else {
|
|
228
|
+
// Status: success
|
|
229
|
+
return { data: placeholderObject, dataKey: null };
|
|
230
|
+
}
|
|
231
|
+
},
|
|
232
|
+
meta: { loaders },
|
|
233
|
+
});
|
|
234
|
+
const { data, status, isFetching, error } = indicesQuery;
|
|
235
|
+
const loadedData = data?.data || placeholderObject;
|
|
236
|
+
const dataStatus = isFetching ? STATUS.LOADING : status;
|
|
237
|
+
const urls = data?.urls;
|
|
238
|
+
useEffect(() => {
|
|
239
|
+
if (error) {
|
|
240
|
+
setWarning(error.message);
|
|
241
|
+
}
|
|
242
|
+
}, [error, setWarning]);
|
|
243
|
+
return [loadedData, dataStatus, urls];
|
|
244
|
+
}
|
|
245
|
+
export function useMultiObsLabels(coordinationScopes, obsType, loaders, dataset) {
|
|
246
|
+
const obsLabelsTypes = useMultiCoordinationValues(CoordinationType.OBS_LABELS_TYPE, coordinationScopes);
|
|
247
|
+
const obsLabelsMatchOnObj = useMemo(() => fromEntries(Object.entries(obsLabelsTypes).map(([scope, obsLabelsType]) => ([
|
|
248
|
+
scope,
|
|
249
|
+
{ obsLabelsType, obsType },
|
|
250
|
+
]))), [obsLabelsTypes, obsType]);
|
|
251
|
+
const [obsLabelsData, obsLabelsDataStatus] = useDataTypeMulti(DataType.OBS_LABELS, loaders, dataset, false, {}, {}, obsLabelsMatchOnObj);
|
|
252
|
+
const urls = null; // TODO?
|
|
253
|
+
return [obsLabelsTypes, obsLabelsData, obsLabelsDataStatus, urls];
|
|
254
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A loader error ancestor class containing a default constructor
|
|
3
|
+
* and a stub for the required warnInConsole() method.
|
|
4
|
+
*/
|
|
5
|
+
export default class AbstractLoaderError {
|
|
6
|
+
constructor(message: any);
|
|
7
|
+
message: any;
|
|
8
|
+
warnInConsole(): void;
|
|
9
|
+
}
|
|
10
|
+
//# sourceMappingURL=AbstractLoaderError.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"AbstractLoaderError.d.ts","sourceRoot":"","sources":["../../src/errors/AbstractLoaderError.js"],"names":[],"mappings":"AAAA;;;GAGG;AACH;IACE,0BAEC;IADC,aAAsB;IAIxB,sBAEC;CACF"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A loader error ancestor class containing a default constructor
|
|
3
|
+
* and a stub for the required warnInConsole() method.
|
|
4
|
+
*/
|
|
5
|
+
export default class AbstractLoaderError {
|
|
6
|
+
constructor(message) {
|
|
7
|
+
this.message = message;
|
|
8
|
+
}
|
|
9
|
+
// eslint-disable-next-line class-methods-use-this
|
|
10
|
+
warnInConsole() {
|
|
11
|
+
throw new Error('The warnInConsole() method has not been implemented.');
|
|
12
|
+
}
|
|
13
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export default class DataSourceFetchError extends AbstractLoaderError {
|
|
2
|
+
constructor(source: any, url: any, headers: any);
|
|
3
|
+
source: any;
|
|
4
|
+
url: any;
|
|
5
|
+
headers: any;
|
|
6
|
+
}
|
|
7
|
+
import AbstractLoaderError from "./AbstractLoaderError.js";
|
|
8
|
+
//# sourceMappingURL=DataSourceFetchError.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"DataSourceFetchError.d.ts","sourceRoot":"","sources":["../../src/errors/DataSourceFetchError.js"],"names":[],"mappings":"AAEA;IACE,iDAKC;IAHC,YAAoB;IACpB,SAAc;IACd,aAAsB;CAOzB"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import AbstractLoaderError from './AbstractLoaderError.js';
|
|
2
|
+
export default class DataSourceFetchError extends AbstractLoaderError {
|
|
3
|
+
constructor(source, url, headers) {
|
|
4
|
+
super(`${source} Error HTTP Status fetching from ${url}`);
|
|
5
|
+
this.source = source;
|
|
6
|
+
this.url = url;
|
|
7
|
+
this.headers = headers;
|
|
8
|
+
}
|
|
9
|
+
warnInConsole() {
|
|
10
|
+
const { source, url, headers } = this;
|
|
11
|
+
console.warn(`${source} failed to fetch from ${url} with headers ${JSON.stringify(headers)}`);
|
|
12
|
+
}
|
|
13
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"DatasetNotFoundError.d.ts","sourceRoot":"","sources":["../../src/errors/DatasetNotFoundError.js"],"names":[],"mappings":"AAEA;IAGI,aAAkC;IAElC,gBAA4B;CAe/B"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import AbstractLoaderError from './AbstractLoaderError.js';
|
|
2
|
+
export default class DatasetNotFoundError extends AbstractLoaderError {
|
|
3
|
+
constructor(datasetUid) {
|
|
4
|
+
super(`Error finding dataset for ${datasetUid}. Please check that at least one dataset exists in the view config.`);
|
|
5
|
+
this.name = 'DatasetNotFoundError';
|
|
6
|
+
this.datasetUid = datasetUid;
|
|
7
|
+
}
|
|
8
|
+
warnInConsole() {
|
|
9
|
+
const { datasetUid, } = this;
|
|
10
|
+
if (datasetUid) {
|
|
11
|
+
console.warn(`Unable to find dataset for ${datasetUid}`);
|
|
12
|
+
}
|
|
13
|
+
else {
|
|
14
|
+
console.warn('No dataset uid specified.');
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export default class LoaderNotFoundError extends AbstractLoaderError {
|
|
2
|
+
constructor(loaders: any, dataset: any, fileType: any, viewCoordinationValues: any);
|
|
3
|
+
name: string;
|
|
4
|
+
loaders: any;
|
|
5
|
+
dataset: any;
|
|
6
|
+
fileType: any;
|
|
7
|
+
viewCoordinationValues: any;
|
|
8
|
+
}
|
|
9
|
+
import AbstractLoaderError from "./AbstractLoaderError.js";
|
|
10
|
+
//# sourceMappingURL=LoaderNotFoundError.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"LoaderNotFoundError.d.ts","sourceRoot":"","sources":["../../src/errors/LoaderNotFoundError.js"],"names":[],"mappings":"AAEA;IACE,oFAQC;IANC,aAAiC;IAEjC,aAAsB;IACtB,aAAsB;IACtB,cAAwB;IACxB,4BAAoD;CAavD"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import AbstractLoaderError from './AbstractLoaderError.js';
|
|
2
|
+
export default class LoaderNotFoundError extends AbstractLoaderError {
|
|
3
|
+
constructor(loaders, dataset, fileType, viewCoordinationValues) {
|
|
4
|
+
super(`Error: unable to find matching ${fileType} file in dataset ${dataset}.`);
|
|
5
|
+
this.name = 'LoaderNotFoundError';
|
|
6
|
+
this.loaders = loaders;
|
|
7
|
+
this.dataset = dataset;
|
|
8
|
+
this.fileType = fileType;
|
|
9
|
+
this.viewCoordinationValues = viewCoordinationValues;
|
|
10
|
+
}
|
|
11
|
+
warnInConsole() {
|
|
12
|
+
const { loaders, viewCoordinationValues, } = this;
|
|
13
|
+
console.warn(
|
|
14
|
+
// eslint-disable-next-line prefer-template
|
|
15
|
+
`Expected to match on { ${Object.entries(viewCoordinationValues).map(([k, v]) => k + ': ' + v).join(', ')} }`, loaders);
|
|
16
|
+
}
|
|
17
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export default class LoaderValidationError extends AbstractLoaderError {
|
|
2
|
+
constructor(datasetType: any, datasetFileType: any, datasetUrl: any, reason: any);
|
|
3
|
+
name: string;
|
|
4
|
+
datasetType: any;
|
|
5
|
+
datasetFileType: any;
|
|
6
|
+
datasetUrl: any;
|
|
7
|
+
reason: any;
|
|
8
|
+
}
|
|
9
|
+
import AbstractLoaderError from "./AbstractLoaderError.js";
|
|
10
|
+
//# sourceMappingURL=LoaderValidationError.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"LoaderValidationError.d.ts","sourceRoot":"","sources":["../../src/errors/LoaderValidationError.js"],"names":[],"mappings":"AAEA;IACE,kFAQC;IANC,aAAmC;IAEnC,iBAA8B;IAC9B,qBAAsC;IACtC,gBAA4B;IAC5B,YAAoB;CAYvB"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import AbstractLoaderError from './AbstractLoaderError.js';
|
|
2
|
+
export default class LoaderValidationError extends AbstractLoaderError {
|
|
3
|
+
constructor(datasetType, datasetFileType, datasetUrl, reason) {
|
|
4
|
+
super(`Error while validating ${datasetType}.`);
|
|
5
|
+
this.name = 'LoaderValidationError';
|
|
6
|
+
this.datasetType = datasetType;
|
|
7
|
+
this.datasetFileType = datasetFileType;
|
|
8
|
+
this.datasetUrl = datasetUrl;
|
|
9
|
+
this.reason = reason;
|
|
10
|
+
}
|
|
11
|
+
warnInConsole() {
|
|
12
|
+
const { datasetType, datasetUrl, reason, } = this;
|
|
13
|
+
console.warn(`${datasetType} from ${datasetUrl}: validation failed`, JSON.stringify(reason, null, 2));
|
|
14
|
+
}
|
|
15
|
+
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export { default as AbstractLoaderError } from "./AbstractLoaderError.js";
|
|
2
|
+
export { default as LoaderValidationError } from "./LoaderValidationError.js";
|
|
3
|
+
export { default as LoaderNotFoundError } from "./LoaderNotFoundError.js";
|
|
4
|
+
export { default as DatasetNotFoundError } from "./DatasetNotFoundError.js";
|
|
5
|
+
export { default as DataSourceFetchError } from "./DataSourceFetchError.js";
|
|
6
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/errors/index.js"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export { default as AbstractLoaderError } from './AbstractLoaderError.js';
|
|
2
|
+
export { default as LoaderValidationError } from './LoaderValidationError.js';
|
|
3
|
+
export { default as LoaderNotFoundError } from './LoaderNotFoundError.js';
|
|
4
|
+
export { default as DatasetNotFoundError } from './DatasetNotFoundError.js';
|
|
5
|
+
export { default as DataSourceFetchError } from './DataSourceFetchError.js';
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
export function useVitessceContainer(ref: any): any;
|
|
2
|
+
/**
|
|
3
|
+
* Custom hook, gets the full window dimensions.
|
|
4
|
+
* @returns {array} `[width, height]` where width and height
|
|
5
|
+
* are numbers.
|
|
6
|
+
*/
|
|
7
|
+
export function useWindowDimensions(): array;
|
|
8
|
+
/**
|
|
9
|
+
* Custom hook, subscribes to GRID_RESIZE and window resize events.
|
|
10
|
+
* @returns {array} `[width, height, containerRef]` where width and height
|
|
11
|
+
* are numbers and containerRef is a React ref.
|
|
12
|
+
*/
|
|
13
|
+
export function useGridItemSize(): array;
|
|
14
|
+
/**
|
|
15
|
+
* Custom hook, subscribes to GRID_RESIZE and window resize events.
|
|
16
|
+
* @returns {array} `[width, height, deckRef]` where width and height
|
|
17
|
+
* are numbers and deckRef is a React ref to be used with
|
|
18
|
+
* a <DeckGL/> element (or a forwardRef to one).
|
|
19
|
+
*/
|
|
20
|
+
export function useDeckCanvasSize(): array;
|
|
21
|
+
/**
|
|
22
|
+
* This hook handles a boolean isReady value,
|
|
23
|
+
* which only returns true once every item in the
|
|
24
|
+
* input list has been marked as "ready".
|
|
25
|
+
* @param {string[]} statusValues The items to wait on.
|
|
26
|
+
* @returns {boolean} Whether the status values are all success.
|
|
27
|
+
*/
|
|
28
|
+
export function useReady(statusValues: string[]): boolean;
|
|
29
|
+
/**
|
|
30
|
+
* This hook helps manage a list of URLs.
|
|
31
|
+
* @param {(null|object[])[]} urls Array of (null or array of { url, name }).
|
|
32
|
+
* @returns {array} An array of { url, name } objects (flattened from the input).
|
|
33
|
+
*/
|
|
34
|
+
export function useUrls(urls: (null | object[])[]): array;
|
|
35
|
+
/**
|
|
36
|
+
* Custom hook, subscribes to the width and height of the closest .vitessce-container
|
|
37
|
+
* element and updates upon window resize events.
|
|
38
|
+
* @param {Ref} ref A React ref object within the `.vitessce-container`.
|
|
39
|
+
* @returns {array} `[width, height]` where width and height
|
|
40
|
+
* are numbers.
|
|
41
|
+
*/
|
|
42
|
+
export function useClosestVitessceContainerSize(ref: Ref): array;
|
|
43
|
+
/**
|
|
44
|
+
* Normalize an obsFeatureMatrix to a Uint8Array.
|
|
45
|
+
* @param {object} params
|
|
46
|
+
* @param {object} params.obsFeatureMatrix The obsFeatureMatrix
|
|
47
|
+
* returned by the useObsFeatureMatrix hook.
|
|
48
|
+
* @returns {array} A tuple [obsFeatureMatrix, dataExtent]
|
|
49
|
+
* where obsFeatureMatrix
|
|
50
|
+
* is a Uint8Array with the same shape as
|
|
51
|
+
* params.obsFeatureMatrix.data, and dataExtent is the
|
|
52
|
+
* [min, max] of the original data.
|
|
53
|
+
*/
|
|
54
|
+
export function useUint8ObsFeatureMatrix({ obsFeatureMatrix }: {
|
|
55
|
+
obsFeatureMatrix: object;
|
|
56
|
+
}): array;
|
|
57
|
+
/**
|
|
58
|
+
* Normalize a feature selection (data for selected
|
|
59
|
+
* columns of an obsFeatureMatrix) to a Uint8Array.
|
|
60
|
+
* @param {array|null} expressionData The expressionData
|
|
61
|
+
* returned by the useFeatureSelection hook,
|
|
62
|
+
* where each element corresponds to an
|
|
63
|
+
* array of values for a selected feature.
|
|
64
|
+
* @returns {array} A tuple [normData, extents] where
|
|
65
|
+
* normData is an array of Uint8Arrays (or null), and extents is
|
|
66
|
+
* an array of [min, max] values for each feature (or null).
|
|
67
|
+
*/
|
|
68
|
+
export function useUint8FeatureSelection(expressionData: array | null): array;
|
|
69
|
+
export function useExpressionValueGetter({ instanceObsIndex, matrixObsIndex, expressionData }: {
|
|
70
|
+
instanceObsIndex: any;
|
|
71
|
+
matrixObsIndex: any;
|
|
72
|
+
expressionData: any;
|
|
73
|
+
}): any;
|
|
74
|
+
export function useGetObsMembership(obsSetsMembership: any): any;
|
|
75
|
+
export function useGetObsInfo(obsType: any, obsLabelsTypes: any, obsLabelsData: any, obsSetsMembership: any): any;
|
|
76
|
+
//# sourceMappingURL=hooks.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"hooks.d.ts","sourceRoot":"","sources":["../src/hooks.js"],"names":[],"mappings":"AAkBA,oDAOC;AAED;;;;GAIG;AACH,6CAgBC;AAED;;;;GAIG;AACH,yCAiCC;AAED;;;;;GAKG;AACH,2CAiCC;AAED;;;;;;GAMG;AACH,uCAHW,MAAM,EAAE,GACN,OAAO,CAOnB;AAED;;;;GAIG;AACH,8BAHW,CAAC,IAAI,GAAC,MAAM,EAAE,CAAC,EAAE,SAU3B;AAED;;;;;;GAMG;AACH,iEAuBC;AAED;;;;;;;;;;GAUG;AACH;IAR0B,gBAAgB,EAA/B,MAAM;UAqBhB;AAED;;;;;;;;;;GAUG;AACH,yDARW,QAAM,IAAI,SAuBpB;AAED;;;;QA2BC;AAED,iEAOC;AAED,kHAuBC"}
|