@vitessce/vit-s 2.0.2 → 2.0.3
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.mjs +84801 -0
- package/{dist → dist-tsc}/index.js +2 -2
- package/package.json +7 -7
- package/src/CallbackPublisher.js +81 -0
- package/src/LoadingIndicator.js +34 -0
- package/src/TitleInfo.js +240 -0
- package/src/VitS.js +180 -0
- package/src/VitessceGrid.js +110 -0
- package/src/VitessceGrid.test.jsx +48 -0
- package/src/Warning.js +62 -0
- package/{dist → src}/classNames.js +0 -0
- package/src/component-registry.js +21 -0
- package/src/data/AbstractLoader.js +46 -0
- package/{dist → src}/data/AbstractTwoStepLoader.js +5 -4
- package/src/data/LoaderResult.js +8 -0
- package/{dist → src}/data/index.js +0 -0
- package/src/data/loader-registry.js +19 -0
- package/src/data-hook-utils.js +197 -0
- package/src/data-hooks.js +354 -0
- package/src/errors/AbstractLoaderError.js +14 -0
- package/src/errors/DataSourceFetchError.js +15 -0
- package/src/errors/DatasetNotFoundError.js +23 -0
- package/src/errors/LoaderNotFoundError.js +24 -0
- package/src/errors/LoaderValidationError.js +23 -0
- package/src/errors/OptionsValidationError.js +25 -0
- package/{dist → src}/errors/index.js +0 -0
- package/src/file-options-schemas-legacy.js +139 -0
- package/src/file-options-schemas-legacy.test.js +138 -0
- package/src/file-options-schemas.js +327 -0
- package/src/file-options-schemas.test.js +26 -0
- package/src/hooks.js +252 -0
- package/src/index.js +101 -0
- package/src/joint-file-types-legacy.js +298 -0
- package/src/joint-file-types-legacy.test.js +412 -0
- package/src/joint-file-types.js +171 -0
- package/src/joint-file-types.test.js +144 -0
- package/{dist/schemas.js → src/json-schemas.js} +6 -1
- package/{dist → src}/plugins.js +102 -70
- package/src/plugins.test.fixtures.js +78 -0
- package/src/plugins.test.js +42 -0
- package/src/schemas/config-0.1.0.schema.json +85 -0
- package/src/schemas/config-1.0.0.schema.json +733 -0
- package/src/schemas/config-1.0.1.schema.json +909 -0
- package/src/schemas/config-1.0.10.schema.json +969 -0
- package/src/schemas/config-1.0.11.schema.json +990 -0
- package/src/schemas/config-1.0.12.schema.json +997 -0
- package/src/schemas/config-1.0.13.schema.json +1013 -0
- package/src/schemas/config-1.0.14.schema.json +1048 -0
- package/src/schemas/config-1.0.15.schema.json +1048 -0
- package/src/schemas/config-1.0.16.schema.json +1069 -0
- package/src/schemas/config-1.0.16.schema.test.js +32 -0
- package/src/schemas/config-1.0.2.schema.json +911 -0
- package/src/schemas/config-1.0.3.schema.json +911 -0
- package/src/schemas/config-1.0.4.schema.json +949 -0
- package/src/schemas/config-1.0.5.schema.json +949 -0
- package/src/schemas/config-1.0.6.schema.json +950 -0
- package/src/schemas/config-1.0.7.schema.json +950 -0
- package/src/schemas/config-1.0.8.schema.json +966 -0
- package/src/schemas/config-1.0.9.schema.json +965 -0
- package/src/schemas/fixtures/cellSets.good.json +16 -0
- package/src/schemas/fixtures/config-1.0.1.bad.json +1 -0
- package/src/schemas/fixtures/config-1.0.1.bad.message.json +11 -0
- package/src/schemas/fixtures/config-1.0.1.good.json +37 -0
- package/src/schemas/fixtures/config-1.0.2.bad.json +1 -0
- package/src/schemas/fixtures/config-1.0.2.bad.message.json +11 -0
- package/src/schemas/fixtures/config-1.0.2.good.json +38 -0
- package/src/schemas/fixtures/config-1.0.3.bad.json +1 -0
- package/src/schemas/fixtures/config-1.0.3.bad.message.json +11 -0
- package/src/schemas/fixtures/config-1.0.3.good.json +38 -0
- package/src/schemas/fixtures/obsSets.bad.json +1 -0
- package/src/schemas/fixtures/obsSets.bad.message.json +11 -0
- package/src/schemas/fixtures/obsSets.good.json +16 -0
- package/src/schemas/fixtures/obsSetsTabular.bad.json +1 -0
- package/src/schemas/fixtures/obsSetsTabular.bad.message.json +11 -0
- package/src/schemas/fixtures/obsSetsTabular.good.json +26 -0
- package/src/schemas/fixtures/raster.bad.json +1 -0
- package/src/schemas/fixtures/raster.bad.message.json +11 -0
- package/src/schemas/fixtures/raster.good.json +39 -0
- package/src/schemas/obsSets.schema.js +195 -0
- package/src/schemas/obsSetsTabular.schema.js +39 -0
- package/src/schemas/raster.schema.js +121 -0
- package/src/schemas/schema-schema.sh +34 -0
- package/{dist → src}/schemas/schema.test-old.js +0 -1
- package/src/shared-mui/components.js +79 -0
- package/src/shared-mui/container.js +212 -0
- package/src/shared-mui/styles.js +110 -0
- package/src/shared-plot-options/CellColorEncodingOption.js +43 -0
- package/src/shared-plot-options/OptionSelect.js +19 -0
- package/src/shared-plot-options/OptionsContainer.js +26 -0
- package/{dist → src}/shared-plot-options/index.js +0 -0
- package/src/shared-plot-options/styles.js +49 -0
- package/src/state/hooks.js +633 -0
- package/src/view-config-upgraders.js +628 -0
- package/src/view-config-utils.js +315 -0
- package/src/view-config-utils.test.fixtures.js +893 -0
- package/src/view-config-utils.test.js +95 -0
- package/src/view-config-versions.js +68 -0
- package/src/vitessce-grid-layout/VitessceGridLayout.js +158 -0
- package/src/vitessce-grid-layout/VitessceGridLayout.test.jsx +56 -0
- package/{dist → src}/vitessce-grid-layout/index.js +0 -0
- package/src/vitessce-grid-layout/layout-utils.js +76 -0
- package/src/vitessce-grid-layout/layout-utils.test.js +167 -0
- package/src/vitessce-grid-utils.js +160 -0
- package/dist/CallbackPublisher.js +0 -68
- package/dist/LoadingIndicator.js +0 -27
- package/dist/TitleInfo.js +0 -151
- package/dist/VitS.js +0 -112
- package/dist/VitessceGrid.js +0 -59
- package/dist/VitessceGrid.test.js +0 -36
- package/dist/Warning.js +0 -45
- package/dist/component-registry.js +0 -16
- package/dist/data/AbstractLoader.js +0 -35
- package/dist/data/LoaderResult.js +0 -7
- package/dist/data/loader-registry.js +0 -15
- package/dist/data-hook-utils.js +0 -175
- package/dist/data-hooks.js +0 -241
- package/dist/errors/AbstractLoaderError.js +0 -13
- package/dist/errors/DataSourceFetchError.js +0 -13
- package/dist/errors/DatasetNotFoundError.js +0 -17
- package/dist/errors/LoaderNotFoundError.js +0 -17
- package/dist/errors/LoaderValidationError.js +0 -15
- package/dist/errors/OptionsValidationError.js +0 -15
- package/dist/file-options-schemas-legacy.js +0 -136
- package/dist/file-options-schemas-legacy.test.js +0 -126
- package/dist/file-options-schemas.js +0 -322
- package/dist/file-options-schemas.test.js +0 -23
- package/dist/hooks.js +0 -215
- package/dist/joint-file-types-legacy.js +0 -278
- package/dist/joint-file-types-legacy.test.js +0 -400
- package/dist/joint-file-types.js +0 -148
- package/dist/joint-file-types.test.js +0 -139
- package/dist/plugins.test.fixtures.js +0 -76
- package/dist/plugins.test.js +0 -30
- package/dist/schemas/config-0.1.0.schema.json +0 -84
- package/dist/schemas/config-1.0.0.schema.json +0 -733
- package/dist/schemas/config-1.0.1.schema.json +0 -909
- package/dist/schemas/config-1.0.10.schema.json +0 -969
- package/dist/schemas/config-1.0.11.schema.json +0 -990
- package/dist/schemas/config-1.0.12.schema.json +0 -997
- package/dist/schemas/config-1.0.13.schema.json +0 -1013
- package/dist/schemas/config-1.0.14.schema.json +0 -1048
- package/dist/schemas/config-1.0.15.schema.json +0 -1048
- package/dist/schemas/config-1.0.15.schema.test.js +0 -22
- package/dist/schemas/config-1.0.2.schema.json +0 -910
- package/dist/schemas/config-1.0.3.schema.json +0 -910
- package/dist/schemas/config-1.0.4.schema.json +0 -949
- package/dist/schemas/config-1.0.5.schema.json +0 -949
- package/dist/schemas/config-1.0.6.schema.json +0 -949
- package/dist/schemas/config-1.0.7.schema.json +0 -949
- package/dist/schemas/config-1.0.8.schema.json +0 -965
- package/dist/schemas/config-1.0.9.schema.json +0 -965
- package/dist/schemas/obsSets.schema.js +0 -195
- package/dist/schemas/obsSetsTabular.schema.js +0 -38
- package/dist/schemas/raster.schema.js +0 -120
- package/dist/shared-mui/components.js +0 -35
- package/dist/shared-mui/container.js +0 -211
- package/dist/shared-mui/styles.js +0 -73
- package/dist/shared-plot-options/CellColorEncodingOption.js +0 -18
- package/dist/shared-plot-options/OptionSelect.js +0 -12
- package/dist/shared-plot-options/OptionsContainer.js +0 -12
- package/dist/shared-plot-options/styles.js +0 -48
- package/dist/state/hooks.js +0 -549
- package/dist/view-config-upgraders.js +0 -525
- package/dist/view-config-utils.js +0 -286
- package/dist/view-config-utils.test.fixtures.js +0 -765
- package/dist/view-config-utils.test.js +0 -66
- package/dist/view-config-versions.js +0 -47
- package/dist/vitessce-grid-layout/VitessceGridLayout.js +0 -95
- package/dist/vitessce-grid-layout/VitessceGridLayout.test.js +0 -40
- package/dist/vitessce-grid-layout/layout-utils.js +0 -60
- package/dist/vitessce-grid-layout/layout-utils.test.js +0 -146
- package/dist/vitessce-grid-utils.js +0 -140
package/dist/hooks.js
DELETED
|
@@ -1,215 +0,0 @@
|
|
|
1
|
-
import { useRef, useState, useEffect, useCallback, useMemo, } from 'react';
|
|
2
|
-
import debounce from 'lodash/debounce';
|
|
3
|
-
import every from 'lodash/every';
|
|
4
|
-
import { capitalize, fromEntries } from '@vitessce/utils';
|
|
5
|
-
import { useGridResize, useEmitGridResize } from './state/hooks';
|
|
6
|
-
import { VITESSCE_CONTAINER } from './classNames';
|
|
7
|
-
function getWindowDimensions() {
|
|
8
|
-
const { innerWidth: width, innerHeight: height } = window;
|
|
9
|
-
return {
|
|
10
|
-
width,
|
|
11
|
-
height,
|
|
12
|
-
};
|
|
13
|
-
}
|
|
14
|
-
export function useVitessceContainer(ref) {
|
|
15
|
-
return useCallback(() => {
|
|
16
|
-
if (ref.current) {
|
|
17
|
-
return ref.current.closest(`.${VITESSCE_CONTAINER}`);
|
|
18
|
-
}
|
|
19
|
-
return null;
|
|
20
|
-
}, [ref]);
|
|
21
|
-
}
|
|
22
|
-
/**
|
|
23
|
-
* Custom hook, gets the full window dimensions.
|
|
24
|
-
* @returns {array} `[width, height]` where width and height
|
|
25
|
-
* are numbers.
|
|
26
|
-
*/
|
|
27
|
-
export function useWindowDimensions() {
|
|
28
|
-
const [windowDimensions, setWindowDimensions] = useState(getWindowDimensions());
|
|
29
|
-
useEffect(() => {
|
|
30
|
-
function handleResize() {
|
|
31
|
-
setWindowDimensions(getWindowDimensions());
|
|
32
|
-
}
|
|
33
|
-
const onResizeDebounced = debounce(handleResize, 100, { trailing: true });
|
|
34
|
-
window.addEventListener('resize', onResizeDebounced);
|
|
35
|
-
return () => window.removeEventListener('resize', onResizeDebounced);
|
|
36
|
-
}, []);
|
|
37
|
-
return windowDimensions;
|
|
38
|
-
}
|
|
39
|
-
/**
|
|
40
|
-
* Custom hook, subscribes to GRID_RESIZE and window resize events.
|
|
41
|
-
* @returns {array} `[width, height, containerRef]` where width and height
|
|
42
|
-
* are numbers and containerRef is a React ref.
|
|
43
|
-
*/
|
|
44
|
-
export function useGridItemSize() {
|
|
45
|
-
const containerRef = useRef();
|
|
46
|
-
const [height, setHeight] = useState();
|
|
47
|
-
const [width, setWidth] = useState();
|
|
48
|
-
const resizeCount = useGridResize();
|
|
49
|
-
const incrementResizeCount = useEmitGridResize();
|
|
50
|
-
// On window resize events, increment the grid resize count.
|
|
51
|
-
useEffect(() => {
|
|
52
|
-
function onWindowResize() {
|
|
53
|
-
incrementResizeCount();
|
|
54
|
-
}
|
|
55
|
-
const onResizeDebounced = debounce(onWindowResize, 100, { trailing: true });
|
|
56
|
-
window.addEventListener('resize', onResizeDebounced);
|
|
57
|
-
onWindowResize();
|
|
58
|
-
return () => {
|
|
59
|
-
window.removeEventListener('resize', onResizeDebounced);
|
|
60
|
-
};
|
|
61
|
-
}, [incrementResizeCount]);
|
|
62
|
-
// On new grid resize counts, re-compute the component
|
|
63
|
-
// width/height.
|
|
64
|
-
useEffect(() => {
|
|
65
|
-
if (!containerRef.current)
|
|
66
|
-
return;
|
|
67
|
-
const container = containerRef.current;
|
|
68
|
-
const containerRect = container.getBoundingClientRect();
|
|
69
|
-
setHeight(containerRect.height);
|
|
70
|
-
setWidth(containerRect.width);
|
|
71
|
-
}, [resizeCount]);
|
|
72
|
-
return [width, height, containerRef];
|
|
73
|
-
}
|
|
74
|
-
/**
|
|
75
|
-
* Custom hook, subscribes to GRID_RESIZE and window resize events.
|
|
76
|
-
* @returns {array} `[width, height, deckRef]` where width and height
|
|
77
|
-
* are numbers and deckRef is a React ref to be used with
|
|
78
|
-
* a <DeckGL/> element (or a forwardRef to one).
|
|
79
|
-
*/
|
|
80
|
-
export function useDeckCanvasSize() {
|
|
81
|
-
const deckRef = useRef();
|
|
82
|
-
const [height, setHeight] = useState();
|
|
83
|
-
const [width, setWidth] = useState();
|
|
84
|
-
const resizeCount = useGridResize();
|
|
85
|
-
const incrementResizeCount = useEmitGridResize();
|
|
86
|
-
// On window resize events, increment the grid resize count.
|
|
87
|
-
useEffect(() => {
|
|
88
|
-
function onWindowResize() {
|
|
89
|
-
incrementResizeCount();
|
|
90
|
-
}
|
|
91
|
-
const onResizeDebounced = debounce(onWindowResize, 100, { trailing: true });
|
|
92
|
-
window.addEventListener('resize', onResizeDebounced);
|
|
93
|
-
onWindowResize();
|
|
94
|
-
return () => {
|
|
95
|
-
window.removeEventListener('resize', onResizeDebounced);
|
|
96
|
-
};
|
|
97
|
-
}, [incrementResizeCount]);
|
|
98
|
-
// On new grid resize counts, re-compute the DeckGL canvas
|
|
99
|
-
// width/height.
|
|
100
|
-
useEffect(() => {
|
|
101
|
-
if (!deckRef.current)
|
|
102
|
-
return;
|
|
103
|
-
const { canvas } = deckRef.current.deck;
|
|
104
|
-
const canvasRect = canvas.getBoundingClientRect();
|
|
105
|
-
setHeight(canvasRect.height);
|
|
106
|
-
setWidth(canvasRect.width);
|
|
107
|
-
}, [resizeCount]);
|
|
108
|
-
return [width, height, deckRef];
|
|
109
|
-
}
|
|
110
|
-
/**
|
|
111
|
-
* This hook handles a boolean isReady value,
|
|
112
|
-
* which only returns true once every item in the
|
|
113
|
-
* input list has been marked as "ready".
|
|
114
|
-
* @param {string[]} statusValues The items to wait on.
|
|
115
|
-
* @returns {boolean} Whether the status values are all success.
|
|
116
|
-
*/
|
|
117
|
-
export function useReady(statusValues) {
|
|
118
|
-
return useMemo(() => every(statusValues, val => val === 'success'), statusValues);
|
|
119
|
-
}
|
|
120
|
-
/**
|
|
121
|
-
* This hook helps manage a list of URLs.
|
|
122
|
-
* @param {object} loaders The loaders dependency.
|
|
123
|
-
* @param {string} dataset The dataset UID dependency.
|
|
124
|
-
* @returns {array} An array
|
|
125
|
-
* [urls, addUrl]
|
|
126
|
-
* where urls is the array of URL objects,
|
|
127
|
-
* and addUrl is a function for adding a URL to the array.
|
|
128
|
-
*/
|
|
129
|
-
export function useUrls(loaders, dataset) {
|
|
130
|
-
const [urls, setUrls] = useState([]);
|
|
131
|
-
const addUrl = useCallback((url, name) => {
|
|
132
|
-
if (url) {
|
|
133
|
-
setUrls(prev => ([...prev, { url, name }]));
|
|
134
|
-
}
|
|
135
|
-
}, [setUrls]);
|
|
136
|
-
useEffect(() => {
|
|
137
|
-
setUrls([]);
|
|
138
|
-
}, [loaders, dataset]);
|
|
139
|
-
return [urls, addUrl];
|
|
140
|
-
}
|
|
141
|
-
/**
|
|
142
|
-
* Custom hook, subscribes to the width and height of the closest .vitessce-container
|
|
143
|
-
* element and updates upon window resize events.
|
|
144
|
-
* @param {Ref} ref A React ref object within the `.vitessce-container`.
|
|
145
|
-
* @returns {array} `[width, height]` where width and height
|
|
146
|
-
* are numbers.
|
|
147
|
-
*/
|
|
148
|
-
export function useClosestVitessceContainerSize(ref) {
|
|
149
|
-
const [height, setHeight] = useState();
|
|
150
|
-
const [width, setWidth] = useState();
|
|
151
|
-
useEffect(() => {
|
|
152
|
-
function onWindowResize() {
|
|
153
|
-
if (ref.current) {
|
|
154
|
-
const { clientHeight: componentHeight, clientWidth: componentWidth, } = ref.current.closest(`.${VITESSCE_CONTAINER}`);
|
|
155
|
-
setWidth(componentWidth);
|
|
156
|
-
setHeight(componentHeight);
|
|
157
|
-
}
|
|
158
|
-
}
|
|
159
|
-
const onResizeDebounced = debounce(onWindowResize, 100, { trailing: true });
|
|
160
|
-
window.addEventListener('resize', onResizeDebounced);
|
|
161
|
-
onWindowResize();
|
|
162
|
-
return () => {
|
|
163
|
-
window.removeEventListener('resize', onResizeDebounced);
|
|
164
|
-
};
|
|
165
|
-
}, [ref]);
|
|
166
|
-
return [width, height];
|
|
167
|
-
}
|
|
168
|
-
export function useExpressionValueGetter({ instanceObsIndex, matrixObsIndex, expressionData }) {
|
|
169
|
-
// Get a mapping from cell ID to row index in the gene expression matrix.
|
|
170
|
-
// Since the two obsIndices (instanceObsIndex = the obsIndex from obsEmbedding)
|
|
171
|
-
// may be ordered differently (matrixObsIndex = the obsIndex from obsFeatureMatrix),
|
|
172
|
-
// we need a way to look up an obsFeatureMatrix obsIndex index
|
|
173
|
-
// given an obsEmbedding obsIndex index.
|
|
174
|
-
const toMatrixIndexMap = useMemo(() => {
|
|
175
|
-
if (instanceObsIndex && matrixObsIndex) {
|
|
176
|
-
const matrixIndexMap = new Map(matrixObsIndex.map((key, i) => ([key, i])));
|
|
177
|
-
return instanceObsIndex.map(key => matrixIndexMap.get(key));
|
|
178
|
-
}
|
|
179
|
-
return null;
|
|
180
|
-
}, [instanceObsIndex, matrixObsIndex]);
|
|
181
|
-
// Set up a getter function for gene expression values, to be used
|
|
182
|
-
// by the DeckGL layer to obtain values for instanced attributes.
|
|
183
|
-
const getExpressionValue = useCallback((entry, { index: instanceIndex }) => {
|
|
184
|
-
if (toMatrixIndexMap && expressionData && expressionData[0]) {
|
|
185
|
-
const rowIndex = toMatrixIndexMap[instanceIndex];
|
|
186
|
-
const val = expressionData[0][rowIndex];
|
|
187
|
-
return val;
|
|
188
|
-
}
|
|
189
|
-
return 0;
|
|
190
|
-
}, [toMatrixIndexMap, expressionData]);
|
|
191
|
-
return getExpressionValue;
|
|
192
|
-
}
|
|
193
|
-
export function useGetObsInfo(obsType, obsLabelsTypes, obsLabelsData, obsSetsMembership) {
|
|
194
|
-
return useCallback((obsId) => {
|
|
195
|
-
if (obsId) {
|
|
196
|
-
const obsMembership = obsSetsMembership?.get(obsId) || [];
|
|
197
|
-
return {
|
|
198
|
-
[`${capitalize(obsType)} ID`]: obsId,
|
|
199
|
-
...fromEntries(obsMembership.flatMap(path => path.slice(1).map((pathEl, elLevel) => ([
|
|
200
|
-
`${path[0]}${path.length > 2 ? ` L${elLevel + 1}` : ''}`,
|
|
201
|
-
pathEl,
|
|
202
|
-
])))),
|
|
203
|
-
...fromEntries(Object.entries(obsLabelsTypes).map(([scopeKey, obsLabelsType]) => ([
|
|
204
|
-
obsLabelsType,
|
|
205
|
-
obsLabelsData?.[scopeKey]?.obsLabels?.[
|
|
206
|
-
// TODO: Maybe all loaders that return obsIndex should also return an obsIndexMap
|
|
207
|
-
// with keys: obsId, values: obsIdx
|
|
208
|
-
// which would avoid the indexOf calls.
|
|
209
|
-
obsLabelsData?.[scopeKey]?.obsIndex?.indexOf(obsId)],
|
|
210
|
-
])).filter(([obsLabelsType]) => Boolean(obsLabelsType))),
|
|
211
|
-
};
|
|
212
|
-
}
|
|
213
|
-
return null;
|
|
214
|
-
}, [obsType, obsLabelsTypes, obsLabelsData, obsSetsMembership]);
|
|
215
|
-
}
|
|
@@ -1,278 +0,0 @@
|
|
|
1
|
-
import { FileType } from '@vitessce/constants-internal';
|
|
2
|
-
import { validateOptions, emptySchema, } from './file-options-schemas';
|
|
3
|
-
import { cellsJsonSchema, anndataCellsZarrSchema, anndataCellSetsZarrSchema, anndataExpressionMatrixZarrSchema, } from './file-options-schemas-legacy';
|
|
4
|
-
export function expandMoleculesJson(fileDef) {
|
|
5
|
-
validateOptions(emptySchema, fileDef.options);
|
|
6
|
-
const baseFileDef = {
|
|
7
|
-
...fileDef,
|
|
8
|
-
coordinationValues: {
|
|
9
|
-
obsType: fileDef.coordinationValues?.obsType || 'molecule',
|
|
10
|
-
},
|
|
11
|
-
};
|
|
12
|
-
delete baseFileDef.type;
|
|
13
|
-
return [
|
|
14
|
-
{
|
|
15
|
-
...baseFileDef,
|
|
16
|
-
fileType: FileType.OBS_LOCATIONS_MOLECULES_JSON,
|
|
17
|
-
},
|
|
18
|
-
{
|
|
19
|
-
...baseFileDef,
|
|
20
|
-
fileType: FileType.OBS_LABELS_MOLECULES_JSON,
|
|
21
|
-
},
|
|
22
|
-
];
|
|
23
|
-
}
|
|
24
|
-
export function expandExpressionMatrixZarr(fileDef) {
|
|
25
|
-
validateOptions(emptySchema, fileDef.options);
|
|
26
|
-
const baseFileDef = {
|
|
27
|
-
...fileDef,
|
|
28
|
-
coordinationValues: {
|
|
29
|
-
obsType: fileDef.coordinationValues?.obsType || 'cell',
|
|
30
|
-
featureType: fileDef.coordinationValues?.featureType || 'gene',
|
|
31
|
-
featureValueType: fileDef.coordinationValues?.featureValueType || 'expression',
|
|
32
|
-
},
|
|
33
|
-
};
|
|
34
|
-
delete baseFileDef.type;
|
|
35
|
-
return [
|
|
36
|
-
{
|
|
37
|
-
...baseFileDef,
|
|
38
|
-
fileType: FileType.OBS_FEATURE_MATRIX_EXPRESSION_MATRIX_ZARR,
|
|
39
|
-
},
|
|
40
|
-
];
|
|
41
|
-
}
|
|
42
|
-
export function expandRasterJson(fileDef) {
|
|
43
|
-
// Validation already happens in the RasterJsonLoader.
|
|
44
|
-
const baseFileDef = { ...fileDef };
|
|
45
|
-
delete baseFileDef.type;
|
|
46
|
-
return [
|
|
47
|
-
{
|
|
48
|
-
...baseFileDef,
|
|
49
|
-
fileType: FileType.IMAGE_RASTER_JSON,
|
|
50
|
-
},
|
|
51
|
-
{
|
|
52
|
-
...baseFileDef,
|
|
53
|
-
fileType: FileType.OBS_SEGMENTATIONS_RASTER_JSON,
|
|
54
|
-
coordinationValues: {
|
|
55
|
-
obsType: baseFileDef.coordinationValues?.obsType || 'cell',
|
|
56
|
-
},
|
|
57
|
-
},
|
|
58
|
-
];
|
|
59
|
-
}
|
|
60
|
-
export function expandRasterOmeZarr(fileDef) {
|
|
61
|
-
validateOptions(emptySchema, fileDef.options);
|
|
62
|
-
const baseFileDef = { ...fileDef };
|
|
63
|
-
delete baseFileDef.type;
|
|
64
|
-
return [
|
|
65
|
-
{
|
|
66
|
-
...baseFileDef,
|
|
67
|
-
fileType: FileType.IMAGE_OME_ZARR,
|
|
68
|
-
},
|
|
69
|
-
];
|
|
70
|
-
}
|
|
71
|
-
export function expandCellSetsJson(fileDef) {
|
|
72
|
-
validateOptions(emptySchema, fileDef.options);
|
|
73
|
-
const baseFileDef = { ...fileDef };
|
|
74
|
-
delete baseFileDef.type;
|
|
75
|
-
return [
|
|
76
|
-
{
|
|
77
|
-
...baseFileDef,
|
|
78
|
-
fileType: FileType.OBS_SETS_CELL_SETS_JSON,
|
|
79
|
-
coordinationValues: {
|
|
80
|
-
obsType: baseFileDef.coordinationValues?.obsType || 'cell',
|
|
81
|
-
},
|
|
82
|
-
},
|
|
83
|
-
];
|
|
84
|
-
}
|
|
85
|
-
export function expandCellsJson(fileDef) {
|
|
86
|
-
validateOptions(cellsJsonSchema, fileDef.options);
|
|
87
|
-
const baseFileDef = {
|
|
88
|
-
...fileDef,
|
|
89
|
-
coordinationValues: {
|
|
90
|
-
obsType: fileDef.coordinationValues?.obsType || 'cell',
|
|
91
|
-
featureType: fileDef.coordinationValues?.featureType || 'gene',
|
|
92
|
-
},
|
|
93
|
-
};
|
|
94
|
-
delete baseFileDef.type;
|
|
95
|
-
delete baseFileDef.options;
|
|
96
|
-
return [
|
|
97
|
-
{
|
|
98
|
-
...baseFileDef,
|
|
99
|
-
fileType: FileType.OBS_SEGMENTATIONS_CELLS_JSON,
|
|
100
|
-
coordinationValues: {
|
|
101
|
-
obsType: baseFileDef.coordinationValues.obsType,
|
|
102
|
-
},
|
|
103
|
-
},
|
|
104
|
-
{
|
|
105
|
-
...baseFileDef,
|
|
106
|
-
fileType: FileType.OBS_LOCATIONS_CELLS_JSON,
|
|
107
|
-
coordinationValues: {
|
|
108
|
-
obsType: baseFileDef.coordinationValues.obsType,
|
|
109
|
-
},
|
|
110
|
-
},
|
|
111
|
-
...(fileDef.options?.embeddingTypes ? fileDef.options.embeddingTypes.map(et => ({
|
|
112
|
-
...baseFileDef,
|
|
113
|
-
fileType: FileType.OBS_EMBEDDING_CELLS_JSON,
|
|
114
|
-
coordinationValues: {
|
|
115
|
-
obsType: baseFileDef.coordinationValues.obsType,
|
|
116
|
-
embeddingType: et,
|
|
117
|
-
},
|
|
118
|
-
})) : []),
|
|
119
|
-
...(fileDef.options?.obsLabelsTypes ? fileDef.options.obsLabelsTypes.map(key => ({
|
|
120
|
-
...baseFileDef,
|
|
121
|
-
fileType: FileType.OBS_LABELS_CELLS_JSON,
|
|
122
|
-
coordinationValues: {
|
|
123
|
-
obsType: baseFileDef.coordinationValues.obsType,
|
|
124
|
-
obsLabelsType: key,
|
|
125
|
-
},
|
|
126
|
-
})) : []),
|
|
127
|
-
];
|
|
128
|
-
}
|
|
129
|
-
export function expandClustersJson(fileDef) {
|
|
130
|
-
validateOptions(emptySchema, fileDef.options);
|
|
131
|
-
const baseFileDef = {
|
|
132
|
-
...fileDef,
|
|
133
|
-
coordinationValues: {
|
|
134
|
-
obsType: fileDef.coordinationValues?.obsType || 'cell',
|
|
135
|
-
featureType: fileDef.coordinationValues?.featureType || 'gene',
|
|
136
|
-
featureValueType: fileDef.coordinationValues?.featureValueType || 'expression',
|
|
137
|
-
},
|
|
138
|
-
};
|
|
139
|
-
delete baseFileDef.type;
|
|
140
|
-
return [
|
|
141
|
-
{
|
|
142
|
-
...baseFileDef,
|
|
143
|
-
fileType: FileType.OBS_FEATURE_MATRIX_CLUSTERS_JSON,
|
|
144
|
-
},
|
|
145
|
-
];
|
|
146
|
-
}
|
|
147
|
-
export function expandGenesJson(fileDef) {
|
|
148
|
-
validateOptions(emptySchema, fileDef.options);
|
|
149
|
-
const baseFileDef = {
|
|
150
|
-
...fileDef,
|
|
151
|
-
coordinationValues: {
|
|
152
|
-
obsType: fileDef.coordinationValues?.obsType || 'cell',
|
|
153
|
-
featureType: fileDef.coordinationValues?.featureType || 'gene',
|
|
154
|
-
featureValueType: fileDef.coordinationValues?.featureValueType || 'expression',
|
|
155
|
-
},
|
|
156
|
-
};
|
|
157
|
-
delete baseFileDef.type;
|
|
158
|
-
return [
|
|
159
|
-
{
|
|
160
|
-
...baseFileDef,
|
|
161
|
-
fileType: FileType.OBS_FEATURE_MATRIX_GENES_JSON,
|
|
162
|
-
},
|
|
163
|
-
];
|
|
164
|
-
}
|
|
165
|
-
function getAnndataBaseFileDef(fileDef) {
|
|
166
|
-
return {
|
|
167
|
-
url: fileDef.url,
|
|
168
|
-
requestInit: fileDef.requestInit,
|
|
169
|
-
coordinationValues: {
|
|
170
|
-
...fileDef.coordinationValues,
|
|
171
|
-
obsType: fileDef.coordinationValues?.obsType || 'cell',
|
|
172
|
-
featureType: fileDef.coordinationValues?.featureType || 'gene',
|
|
173
|
-
featureValueType: fileDef.coordinationValues?.featureValueType || 'expression',
|
|
174
|
-
},
|
|
175
|
-
};
|
|
176
|
-
}
|
|
177
|
-
export function expandAnndataCellsZarr(fileDef) {
|
|
178
|
-
validateOptions(anndataCellsZarrSchema, fileDef.options);
|
|
179
|
-
const baseFileDef = getAnndataBaseFileDef(fileDef);
|
|
180
|
-
const { options = {} } = fileDef;
|
|
181
|
-
const embeddingTypes = options.mappings ? Object.keys(options.mappings) : [];
|
|
182
|
-
const obsLabelsTypes = options.factors ? options.factors : [];
|
|
183
|
-
return [
|
|
184
|
-
...(options.poly ? [{
|
|
185
|
-
...baseFileDef,
|
|
186
|
-
fileType: FileType.OBS_SEGMENTATIONS_ANNDATA_ZARR,
|
|
187
|
-
options: {
|
|
188
|
-
path: options.poly,
|
|
189
|
-
},
|
|
190
|
-
coordinationValues: {
|
|
191
|
-
obsType: baseFileDef.coordinationValues.obsType,
|
|
192
|
-
},
|
|
193
|
-
}] : []),
|
|
194
|
-
...(options.xy ? [{
|
|
195
|
-
...baseFileDef,
|
|
196
|
-
fileType: FileType.OBS_LOCATIONS_ANNDATA_ZARR,
|
|
197
|
-
options: {
|
|
198
|
-
path: options.xy,
|
|
199
|
-
},
|
|
200
|
-
coordinationValues: {
|
|
201
|
-
obsType: baseFileDef.coordinationValues.obsType,
|
|
202
|
-
},
|
|
203
|
-
}] : []),
|
|
204
|
-
...embeddingTypes.map(et => ({
|
|
205
|
-
...baseFileDef,
|
|
206
|
-
fileType: FileType.OBS_EMBEDDING_ANNDATA_ZARR,
|
|
207
|
-
options: {
|
|
208
|
-
path: options.mappings[et].key,
|
|
209
|
-
dims: options.mappings[et].dims,
|
|
210
|
-
},
|
|
211
|
-
coordinationValues: {
|
|
212
|
-
obsType: baseFileDef.coordinationValues.obsType,
|
|
213
|
-
embeddingType: et,
|
|
214
|
-
},
|
|
215
|
-
})),
|
|
216
|
-
...obsLabelsTypes.map(olt => ({
|
|
217
|
-
...baseFileDef,
|
|
218
|
-
fileType: FileType.OBS_LABELS_ANNDATA_ZARR,
|
|
219
|
-
options: {
|
|
220
|
-
path: olt,
|
|
221
|
-
},
|
|
222
|
-
coordinationValues: {
|
|
223
|
-
obsType: baseFileDef.coordinationValues.obsType,
|
|
224
|
-
obsLabelsType: olt.split('/').at(-1),
|
|
225
|
-
},
|
|
226
|
-
})),
|
|
227
|
-
];
|
|
228
|
-
}
|
|
229
|
-
export function expandAnndataCellSetsZarr(fileDef) {
|
|
230
|
-
validateOptions(anndataCellSetsZarrSchema, fileDef.options);
|
|
231
|
-
const baseFileDef = getAnndataBaseFileDef(fileDef);
|
|
232
|
-
const { options = [] } = fileDef;
|
|
233
|
-
return [
|
|
234
|
-
{
|
|
235
|
-
...baseFileDef,
|
|
236
|
-
fileType: FileType.OBS_SETS_ANNDATA_ZARR,
|
|
237
|
-
options: options.map(option => ({
|
|
238
|
-
name: option.groupName,
|
|
239
|
-
path: option.setName,
|
|
240
|
-
scorePath: option.scoreName,
|
|
241
|
-
})),
|
|
242
|
-
coordinationValues: {
|
|
243
|
-
obsType: baseFileDef.coordinationValues.obsType,
|
|
244
|
-
},
|
|
245
|
-
},
|
|
246
|
-
];
|
|
247
|
-
}
|
|
248
|
-
export function expandAnndataExpressionMatrixZarr(fileDef) {
|
|
249
|
-
validateOptions(anndataExpressionMatrixZarrSchema, fileDef.options);
|
|
250
|
-
const baseFileDef = getAnndataBaseFileDef(fileDef);
|
|
251
|
-
const { options = {} } = fileDef;
|
|
252
|
-
return [
|
|
253
|
-
...(options.geneAlias ? [{
|
|
254
|
-
...baseFileDef,
|
|
255
|
-
fileType: FileType.FEATURE_LABELS_ANNDATA_ZARR,
|
|
256
|
-
options: {
|
|
257
|
-
path: options.geneAlias,
|
|
258
|
-
},
|
|
259
|
-
coordinationValues: {
|
|
260
|
-
featureType: baseFileDef.coordinationValues.featureType,
|
|
261
|
-
},
|
|
262
|
-
}] : []),
|
|
263
|
-
{
|
|
264
|
-
...baseFileDef,
|
|
265
|
-
fileType: FileType.OBS_FEATURE_MATRIX_ANNDATA_ZARR,
|
|
266
|
-
options: {
|
|
267
|
-
path: options.matrix,
|
|
268
|
-
featureFilterPath: options.geneFilter,
|
|
269
|
-
initialFeatureFilterPath: options.matrixGeneFilter,
|
|
270
|
-
},
|
|
271
|
-
coordinationValues: {
|
|
272
|
-
obsType: baseFileDef.coordinationValues.obsType,
|
|
273
|
-
featureType: baseFileDef.coordinationValues.featureType,
|
|
274
|
-
featureValueType: baseFileDef.coordinationValues.featureValueType,
|
|
275
|
-
},
|
|
276
|
-
},
|
|
277
|
-
];
|
|
278
|
-
}
|