@vitessce/vit-s 3.5.7 → 3.5.8

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.
@@ -0,0 +1,2 @@
1
+ export function FallbackForView(props: any): JSX.Element;
2
+ //# sourceMappingURL=FallbackForView.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"FallbackForView.d.ts","sourceRoot":"","sources":["../src/FallbackForView.js"],"names":[],"mappings":"AAOA,yDAeC"}
@@ -0,0 +1,13 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import React from 'react';
3
+ import { getDebugMode } from '@vitessce/globals';
4
+ // TODO: Improve styling - perhaps style similar to ./TitleInfo.js
5
+ // TODO: Display different info depending on the type of error
6
+ // Reference: https://github.com/bvaughn/react-error-boundary?tab=readme-ov-file#errorboundary-with-fallbackcomponent-prop
7
+ export function FallbackForView(props) {
8
+ const { error,
9
+ // Call resetErrorBoundary() to reset the error boundary and retry the render.
10
+ // resetErrorBoundary,
11
+ } = props;
12
+ return (_jsxs("div", { children: [_jsx("p", { children: "A view-level error occurred." }), getDebugMode() ? (_jsx("pre", { style: { color: 'red' }, children: error.message })) : null] }));
13
+ }
@@ -0,0 +1,2 @@
1
+ export function FallbackForVitS(props: any): JSX.Element;
2
+ //# sourceMappingURL=FallbackForVitS.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"FallbackForVitS.d.ts","sourceRoot":"","sources":["../src/FallbackForVitS.js"],"names":[],"mappings":"AAMA,yDAcC"}
@@ -0,0 +1,12 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import React from 'react';
3
+ // TODO: Improve styling - see ./DebugWindow.js
4
+ // TODO: Display different info depending on the type of error
5
+ // Reference: https://github.com/bvaughn/react-error-boundary?tab=readme-ov-file#errorboundary-with-fallbackcomponent-prop
6
+ export function FallbackForVitS(props) {
7
+ const { error,
8
+ // Call resetErrorBoundary() to reset the error boundary and retry the render.
9
+ // resetErrorBoundary,
10
+ } = props;
11
+ return (_jsxs("div", { children: [_jsx("p", { children: "Error:" }), _jsx("pre", { style: { color: 'red' }, children: error.message })] }));
12
+ }
@@ -0,0 +1,9 @@
1
+ /**
2
+ * This serves as a way to wrap VitS in a React ErrorBoundary.
3
+ * Since there is a lot of logic within the VitS component,
4
+ * we want the ErrorBoundary to be a parent (as opposed to a child)
5
+ * of the VitS component.
6
+ * @param {*} props All props will be passed down to VitS.
7
+ */
8
+ export function VitSContainer(props: any): JSX.Element;
9
+ //# sourceMappingURL=VitSContainer.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"VitSContainer.d.ts","sourceRoot":"","sources":["../src/VitSContainer.js"],"names":[],"mappings":"AAKA;;;;;;GAMG;AACH,qCAFW,GAAC,eAQX"}
@@ -0,0 +1,15 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import React from 'react';
3
+ import { ErrorBoundary } from 'react-error-boundary';
4
+ import { FallbackForVitS } from './FallbackForVitS.js';
5
+ import { VitS } from './VitS.js';
6
+ /**
7
+ * This serves as a way to wrap VitS in a React ErrorBoundary.
8
+ * Since there is a lot of logic within the VitS component,
9
+ * we want the ErrorBoundary to be a parent (as opposed to a child)
10
+ * of the VitS component.
11
+ * @param {*} props All props will be passed down to VitS.
12
+ */
13
+ export function VitSContainer(props) {
14
+ return (_jsx(ErrorBoundary, { FallbackComponent: FallbackForVitS, children: _jsx(VitS, { ...props }) }));
15
+ }
@@ -43,6 +43,7 @@ export function useFeatureLabelsData(loaders: any, dataset: any, isRequired: any
43
43
  export function useImageData(loaders: any, dataset: any, isRequired: any, coordinationSetters: any, initialCoordinationValues: any, matchOn: any): array;
44
44
  export function useGenomicProfilesData(loaders: any, dataset: any, isRequired: any, coordinationSetters: any, initialCoordinationValues: any, matchOn: any): array;
45
45
  export function useNeighborhoodsData(loaders: any, dataset: any, isRequired: any, coordinationSetters: any, initialCoordinationValues: any, matchOn: any): array;
46
+ export function useComparisonMetadata(loaders: any, dataset: any, isRequired: any, coordinationSetters: any, initialCoordinationValues: any, matchOn: any): array;
46
47
  /**
47
48
  * Get data from the expression matrix data type loader for a given gene selection.
48
49
  * Throw warnings if the data is marked as required.
@@ -58,6 +59,27 @@ export function useNeighborhoodsData(loaders: any, dataset: any, isRequired: any
58
59
  * for however many genes are in the selection.
59
60
  */
60
61
  export function useFeatureSelection(loaders: object, dataset: string, isRequired: boolean, selection: boolean, matchOn: any): array;
62
+ /**
63
+ * Utility hook function which can be used to define
64
+ * dataType-specific data hooks which call a loader.loadMulti
65
+ * method to obtain multiple data frames resulting from
66
+ * multiple comparative analyses.
67
+ * @param {object} loaders The object mapping
68
+ * datasets and data types to loader instances.
69
+ * @param {string} dataset The key for a dataset,
70
+ * used to identify which loader to use.
71
+ * @param {boolean} isRequired Should a warning be thrown if
72
+ * loading is unsuccessful?
73
+ * @param {object} matchOn Coordination values used to obtain a matching loader.
74
+ * @param {object} volcanoOptions Options to pass to the loadMulti function of the loader.
75
+ * @param {string} dataType A data type.
76
+ * @returns {array} [{ df, metadata }] Array of dataframes and their metadata, where
77
+ * df is an object in which each column is stored as an array like { col1: arr1, col2: arr2 }.
78
+ */
79
+ export function useComparativeDataType(loaders: object, dataset: string, isRequired: boolean, matchOn: object, volcanoOptions: object, dataType: string): array;
80
+ export function useFeatureStatsData(loaders: any, dataset: any, isRequired: any, matchOn: any, volcanoOptions: any): array;
81
+ export function useFeatureSetStatsData(loaders: any, dataset: any, isRequired: any, matchOn: any, volcanoOptions: any): array;
82
+ export function useObsSetStatsData(loaders: any, dataset: any, isRequired: any, matchOn: any, volcanoOptions: any): array;
61
83
  /**
62
84
  * Get the attributes for the expression matrix data type loader,
63
85
  * i.e names of cells and genes.
@@ -1 +1 @@
1
- {"version":3,"file":"data-hooks.d.ts","sourceRoot":"","sources":["../src/data-hooks.js"],"names":[],"mappings":"AAkBA;;;;;;;;GAQG;AACH,wCAPW,MAAM,WAEN,MAAM,GAEJ,KAAK,CAoBjB;AAED;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,6CAhBW,MAAM,WAEN,MAAM,cAEN,OAAO,uBAEP,MAAM,6BAGN,MAAM,iBAGJ,KAAK,CAajB;AAED,4JASC;AAED,6JASC;AAED,gKASC;AAED,6JASC;AAED,oKASC;AAED,2JASC;AAED,8JASC;AAED,+JASC;AAED,oKASC;AAED,iKASC;AAED,yJASC;AAED,mKASC;AAED,iKASC;AAED;;;;;;;;;;;;;GAaG;AACH,6CAVW,MAAM,WAEN,MAAM,cAEN,OAAO,aAEP,OAAO,iBACL,KAAK,CAiFjB;AAED;;;;;;;;;;;;;GAaG;AACH,oDARW,MAAM,WAEN,MAAM,cAEN,OAAO,iBAEL,MAAM,CA2ElB;AAED,+JAuBC;AAED,8JAuBC;AAED,2HAsBC;AAGD,iIAsBC;AAGD,4GAmBC;AAED,sKA2BC;AAED,4JAyBC"}
1
+ {"version":3,"file":"data-hooks.d.ts","sourceRoot":"","sources":["../src/data-hooks.js"],"names":[],"mappings":"AAkBA;;;;;;;;GAQG;AACH,wCAPW,MAAM,WAEN,MAAM,GAEJ,KAAK,CAoBjB;AAED;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,6CAhBW,MAAM,WAEN,MAAM,cAEN,OAAO,uBAEP,MAAM,6BAGN,MAAM,iBAGJ,KAAK,CAajB;AAED,4JASC;AAED,6JASC;AAED,gKASC;AAED,6JASC;AAED,oKASC;AAED,2JASC;AAED,8JASC;AAED,+JASC;AAED,oKASC;AAED,iKASC;AAED,yJASC;AAED,mKASC;AAED,iKASC;AAED,kKASC;AAED;;;;;;;;;;;;;GAaG;AACH,6CAVW,MAAM,WAEN,MAAM,cAEN,OAAO,aAEP,OAAO,iBACL,KAAK,CAiFjB;AAED;;;;;;;;;;;;;;;;GAgBG;AACH,gDAZW,MAAM,WAEN,MAAM,cAEN,OAAO,WAEP,MAAM,kBACN,MAAM,YACN,MAAM,GACJ,KAAK,CAoEjB;AAED,2HAOC;AAED,8HAOC;AAED,0HAOC;AAED;;;;;;;;;;;;;GAaG;AACH,oDARW,MAAM,WAEN,MAAM,cAEN,OAAO,iBAEL,MAAM,CA2ElB;AAED,+JAuBC;AAED,8JAuBC;AAED,2HAsBC;AAGD,iIAsBC;AAGD,4GAmBC;AAED,sKA2BC;AAED,4JAyBC"}
@@ -92,6 +92,9 @@ export function useGenomicProfilesData(loaders, dataset, isRequired, coordinatio
92
92
  export function useNeighborhoodsData(loaders, dataset, isRequired, coordinationSetters, initialCoordinationValues, matchOn) {
93
93
  return useDataType(DataType.NEIGHBORHOODS, loaders, dataset, isRequired, coordinationSetters, initialCoordinationValues, matchOn);
94
94
  }
95
+ export function useComparisonMetadata(loaders, dataset, isRequired, coordinationSetters, initialCoordinationValues, matchOn) {
96
+ return useDataType(DataType.COMPARISON_METADATA, loaders, dataset, isRequired, coordinationSetters, initialCoordinationValues, matchOn);
97
+ }
95
98
  /**
96
99
  * Get data from the expression matrix data type loader for a given gene selection.
97
100
  * Throw warnings if the data is marked as required.
@@ -174,6 +177,93 @@ export function useFeatureSelection(loaders, dataset, isRequired, selection, mat
174
177
  }, [anyError, setWarning]);
175
178
  return [geneData, loadedGeneName, dataStatus];
176
179
  }
180
+ /**
181
+ * Utility hook function which can be used to define
182
+ * dataType-specific data hooks which call a loader.loadMulti
183
+ * method to obtain multiple data frames resulting from
184
+ * multiple comparative analyses.
185
+ * @param {object} loaders The object mapping
186
+ * datasets and data types to loader instances.
187
+ * @param {string} dataset The key for a dataset,
188
+ * used to identify which loader to use.
189
+ * @param {boolean} isRequired Should a warning be thrown if
190
+ * loading is unsuccessful?
191
+ * @param {object} matchOn Coordination values used to obtain a matching loader.
192
+ * @param {object} volcanoOptions Options to pass to the loadMulti function of the loader.
193
+ * @param {string} dataType A data type.
194
+ * @returns {array} [{ df, metadata }] Array of dataframes and their metadata, where
195
+ * df is an object in which each column is stored as an array like { col1: arr1, col2: arr2 }.
196
+ */
197
+ export function useComparativeDataType(loaders, dataset, isRequired, matchOn, volcanoOptions, dataType) {
198
+ const setWarning = useSetWarning();
199
+ const placeholderObject = useMemo(() => ({}), []);
200
+ const statsQuery = useQuery({
201
+ // TODO: only enable once `loaders` is available?
202
+ structuralSharing: false,
203
+ placeholderData: placeholderObject,
204
+ // Include the hook name in the queryKey to prevent the case in which an identical queryKey
205
+ // in a different hook would cause an accidental cache hit.
206
+ queryKey: [dataset, dataType, matchOn, volcanoOptions, 'useComparativeData'],
207
+ // TODO: use TypeScript to type the return value?
208
+ queryFn: async (ctx) => {
209
+ const loader = getMatchingLoader(ctx.meta.loaders, ctx.queryKey[0], ctx.queryKey[1], ctx.queryKey[2]);
210
+ if (loader) {
211
+ // FeatureStats loader has a special loadMulti function
212
+ // that depends on coordination values such as sampleSetSelection.
213
+ const implementsLoadAttrs = typeof loader.loadMulti === 'function';
214
+ if (implementsLoadAttrs) {
215
+ // Has loadMulti function.
216
+ const payload = await loader.loadMulti(volcanoOptions);
217
+ if (!payload)
218
+ return placeholderObject;
219
+ const { data: payloadData } = payload;
220
+ return {
221
+ data: payloadData,
222
+ urls: null,
223
+ };
224
+ }
225
+ // No loadAttrs function.
226
+ const payload = await loader.load();
227
+ if (!payload)
228
+ return placeholderObject;
229
+ const { data: payloadData } = payload;
230
+ return {
231
+ data: payloadData,
232
+ urls: null,
233
+ };
234
+ }
235
+ // No loader was found.
236
+ if (isRequired) {
237
+ // Status: error
238
+ throw new LoaderNotFoundError(loaders, dataset, dataType, matchOn);
239
+ }
240
+ else {
241
+ // Status: success
242
+ return { data: placeholderObject, dataKey: null };
243
+ }
244
+ },
245
+ meta: { loaders },
246
+ });
247
+ const { data, status, isFetching, error } = statsQuery;
248
+ const loadedData = data?.data || placeholderObject;
249
+ const dataStatus = isFetching ? STATUS.LOADING : status;
250
+ const urls = data?.urls;
251
+ useEffect(() => {
252
+ if (error) {
253
+ setWarning(error.message);
254
+ }
255
+ }, [error, setWarning]);
256
+ return [loadedData, dataStatus, urls];
257
+ }
258
+ export function useFeatureStatsData(loaders, dataset, isRequired, matchOn, volcanoOptions) {
259
+ return useComparativeDataType(loaders, dataset, isRequired, matchOn, volcanoOptions, DataType.FEATURE_STATS);
260
+ }
261
+ export function useFeatureSetStatsData(loaders, dataset, isRequired, matchOn, volcanoOptions) {
262
+ return useComparativeDataType(loaders, dataset, isRequired, matchOn, volcanoOptions, DataType.FEATURE_SET_STATS);
263
+ }
264
+ export function useObsSetStatsData(loaders, dataset, isRequired, matchOn, volcanoOptions) {
265
+ return useComparativeDataType(loaders, dataset, isRequired, matchOn, volcanoOptions, DataType.OBS_SET_STATS);
266
+ }
177
267
  /**
178
268
  * Get the attributes for the expression matrix data type loader,
179
269
  * i.e names of cells and genes.
@@ -96,4 +96,13 @@ export function useGetObsInfo(obsType: any, obsLabelsTypes: any, obsLabelsData:
96
96
  export function useExpandedFeatureLabelsMap(featureType: string, featureLabelsMap: Map<any, any> | null, options: any): {
97
97
  stripCuriePrefixes: boolean;
98
98
  } | null;
99
+ /**
100
+ * Using a loader object's options,
101
+ * return a mapping from group name to column name.
102
+ * @param {*} loader obsSets or sampleSets loader class
103
+ * @param {[boolean]} reverse Optionally, reverse
104
+ * (so, return column name to group name mapping).
105
+ * @returns {Record<string, string>} Mapping from group name to column name.
106
+ */
107
+ export function useColumnNameMapping(loader: any, reverse?: [boolean]): Record<string, string>;
99
108
  //# sourceMappingURL=hooks.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"hooks.d.ts","sourceRoot":"","sources":["../src/hooks.js"],"names":[],"mappings":"AAqBA,oDAOC;AAED;;;;GAIG;AACH,uCAHa,KAAK,CAmBjB;AAED;;;;GAIG;AACH,mCAHa,KAAK,CAoCjB;AAED;;;;;GAKG;AACH,qCAJa,KAAK,CAqCjB;AAED;;;;;;GAMG;AACH,uCAHW,MAAM,EAAE,GACN,OAAO,CAOnB;AAED;;;;GAIG;AACH,8BAHW,CAAC,IAAI,GAAC,MAAM,EAAE,CAAC,EAAE,GACf,KAAK,CAYjB;AAED;;;;;;GAMG;AACH,qDAJW,GAAG,GACD,KAAK,CA0BjB;AAED;;;;;;;;;;GAUG;AACH,+DARG;IAAuB,gBAAgB,EAA/B,MAAM;CAEd,GAAU,KAAK,CAmBjB;AAED;;;;;;;;;;;;;;;GAeG;AACH,yDAbW,YAAY,EAAE,GAAG,IAAI,GAInB;IACZ,QAAW,EAAE,UAAU,EAAE,GAAG,IAAI,CAAC;IACjC,OAAU,EAAE,CAAC,MAAM,EAAE,MAAM,CAAC,EAAE,GAAG,IAAI,CAAC;IACtC,OAAU,EAAE,MAAM,EAAE,CAAA;CACjB,CAwBH;AAED;;;;QA2BC;AAED,iEAOC;AAED,kHA4BC;AAED;;;;;;;;;;GAUG;AACH,yDALW,MAAM,oBACN,gBAAI,IAAI,iBAEN;IAAE,kBAAkB,EAAE,OAAO,CAAA;CAAE,GAAC,IAAI,CAkChD"}
1
+ {"version":3,"file":"hooks.d.ts","sourceRoot":"","sources":["../src/hooks.js"],"names":[],"mappings":"AAqBA,oDAOC;AAED;;;;GAIG;AACH,uCAHa,KAAK,CAmBjB;AAED;;;;GAIG;AACH,mCAHa,KAAK,CAoCjB;AAED;;;;;GAKG;AACH,qCAJa,KAAK,CAqCjB;AAED;;;;;;GAMG;AACH,uCAHW,MAAM,EAAE,GACN,OAAO,CAOnB;AAED;;;;GAIG;AACH,8BAHW,CAAC,IAAI,GAAC,MAAM,EAAE,CAAC,EAAE,GACf,KAAK,CAYjB;AAED;;;;;;GAMG;AACH,qDAJW,GAAG,GACD,KAAK,CA0BjB;AAED;;;;;;;;;;GAUG;AACH,+DARG;IAAuB,gBAAgB,EAA/B,MAAM;CAEd,GAAU,KAAK,CAmBjB;AAED;;;;;;;;;;;;;;;GAeG;AACH,yDAbW,YAAY,EAAE,GAAG,IAAI,GAInB;IACZ,QAAW,EAAE,UAAU,EAAE,GAAG,IAAI,CAAC;IACjC,OAAU,EAAE,CAAC,MAAM,EAAE,MAAM,CAAC,EAAE,GAAG,IAAI,CAAC;IACtC,OAAU,EAAE,MAAM,EAAE,CAAA;CACjB,CAwBH;AAED;;;;QA2BC;AAED,iEAOC;AAED,kHA4BC;AAED;;;;;;;;;;GAUG;AACH,yDALW,MAAM,oBACN,gBAAI,IAAI,iBAEN;IAAE,kBAAkB,EAAE,OAAO,CAAA;CAAE,GAAC,IAAI,CAkChD;AAED;;;;;;;GAOG;AACH,6CALW,GAAC,YACD,CAAC,OAAO,CAAC,GAEP,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAuBlC"}
package/dist-tsc/hooks.js CHANGED
@@ -316,3 +316,31 @@ export function useExpandedFeatureLabelsMap(featureType, featureLabelsMap, optio
316
316
  : STATUS.SUCCESS);
317
317
  return [updatedFeatureLabelsMap, dataStatus];
318
318
  }
319
+ /**
320
+ * Using a loader object's options,
321
+ * return a mapping from group name to column name.
322
+ * @param {*} loader obsSets or sampleSets loader class
323
+ * @param {[boolean]} reverse Optionally, reverse
324
+ * (so, return column name to group name mapping).
325
+ * @returns {Record<string, string>} Mapping from group name to column name.
326
+ */
327
+ export function useColumnNameMapping(loader, reverse = false) {
328
+ return useMemo(() => {
329
+ const result = {};
330
+ if (loader?.options) {
331
+ const optionsArray = loader.options.obsSets
332
+ ? loader.options.obsSets
333
+ : loader.options.sampleSets;
334
+ optionsArray.forEach((optionObject) => {
335
+ const { name, path } = optionObject;
336
+ const columnName = path.split('/').at(-1);
337
+ result[name] = columnName;
338
+ });
339
+ }
340
+ if (reverse) {
341
+ return Object.fromEntries(Object.entries(result)
342
+ .map(([k, v]) => ([v, k])));
343
+ }
344
+ return result;
345
+ }, [loader]);
346
+ }
@@ -1,12 +1,13 @@
1
1
  export { VitS } from "./VitS.js";
2
+ export { VitSContainer } from "./VitSContainer.js";
2
3
  export { TitleInfo } from "./TitleInfo.js";
3
4
  export { PopperMenu } from "./shared-mui/components.js";
4
5
  export { useHasLoader } from "./data-hook-utils.js";
5
6
  export { logConfig } from "./view-config-utils.js";
6
7
  export { createLoaders } from "./vitessce-grid-utils.js";
7
- export { useReady, useUrls, useVitessceContainer, useDeckCanvasSize, useUint8ObsFeatureMatrix, useUint8FeatureSelection, useExpressionValueGetter, useGetObsMembership, useGetObsInfo, useClosestVitessceContainerSize, useWindowDimensions, useGridItemSize, useExpandedFeatureLabelsMap } from "./hooks.js";
8
+ export { useReady, useUrls, useVitessceContainer, useDeckCanvasSize, useUint8ObsFeatureMatrix, useUint8FeatureSelection, useExpressionValueGetter, useGetObsMembership, useGetObsInfo, useClosestVitessceContainerSize, useWindowDimensions, useGridItemSize, useExpandedFeatureLabelsMap, useColumnNameMapping } from "./hooks.js";
8
9
  export { useCoordinationScopes, useCoordinationScopesBy, useInitialCoordination, useCoordination, useComplexCoordination, useComplexCoordinationSecondary, useMultiCoordinationScopes, useMultiCoordinationScopesNonNull, useMultiCoordinationScopesSecondary, useMultiCoordinationScopesSecondaryNonNull, useMultiCoordinationValues, useMultiDatasetCoordination, useDatasetUids, useLoaders, useMergeCoordination, useMatchingLoader, useViewConfigStore, useViewConfigStoreApi, useViewConfig, useSetViewConfig, useComponentHover, useSetComponentHover, useComponentViewInfo, useSetComponentViewInfo, useWarning, useSetWarning, useAuxiliaryCoordination, useComponentLayout, useRemoveImageChannelInMetaCoordinationScopes, useAddImageChannelInMetaCoordinationScopes } from "./state/hooks.js";
9
- export { useDescription, useImageData, useObsSetsData, useObsEmbeddingData, useFeatureSelection, useObsFeatureMatrixIndices, useSampleSetsData, useSampleEdgesData, useMultiObsLabels, useMultiObsSpots, useMultiObsPoints, useSpotMultiObsSets, useSpotMultiFeatureLabels, useMultiObsSegmentations, useMultiImages, useObsSpotsData, useObsPointsData, useObsLocationsData, useObsSegmentationsData, useNeighborhoodsData, useObsLabelsData, useObsFeatureMatrixData, useFeatureLabelsData, useGenomicProfilesData } from "./data-hooks.js";
10
+ export { useDescription, useImageData, useObsSetsData, useObsEmbeddingData, useFeatureSelection, useObsFeatureMatrixIndices, useSampleSetsData, useSampleEdgesData, useMultiObsLabels, useMultiObsSpots, useMultiObsPoints, useSpotMultiObsSets, useSpotMultiFeatureLabels, useMultiObsSegmentations, useMultiImages, useObsSpotsData, useObsPointsData, useObsLocationsData, useObsSegmentationsData, useNeighborhoodsData, useObsLabelsData, useObsFeatureMatrixData, useFeatureLabelsData, useGenomicProfilesData, useComparisonMetadata, useFeatureStatsData, useFeatureSetStatsData, useObsSetStatsData } from "./data-hooks.js";
10
11
  export { usePointMultiObsLabels, useSpotMultiFeatureSelection, useSpotMultiObsFeatureMatrixIndices, useSegmentationMultiFeatureSelection, useSegmentationMultiObsFeatureMatrixIndices, useSegmentationMultiObsLocations, useSegmentationMultiObsSets } from "./data-hooks-multilevel.js";
11
12
  export { CellColorEncodingOption, OptionsContainer, OptionSelect, usePlotOptionsStyles } from "./shared-plot-options/index.js";
12
13
  export { useAsyncFunction, usePageModeView } from "./contexts.js";
package/dist-tsc/index.js CHANGED
@@ -1,10 +1,11 @@
1
1
  export { VitS } from './VitS.js';
2
+ export { VitSContainer } from './VitSContainer.js';
2
3
  export { TitleInfo } from './TitleInfo.js';
3
4
  export { PopperMenu } from './shared-mui/components.js';
4
5
  // For plugin view types:
5
- export { useReady, useUrls, useVitessceContainer, useDeckCanvasSize, useUint8ObsFeatureMatrix, useUint8FeatureSelection, useExpressionValueGetter, useGetObsMembership, useGetObsInfo, useClosestVitessceContainerSize, useWindowDimensions, useGridItemSize, useExpandedFeatureLabelsMap, } from './hooks.js';
6
+ export { useReady, useUrls, useVitessceContainer, useDeckCanvasSize, useUint8ObsFeatureMatrix, useUint8FeatureSelection, useExpressionValueGetter, useGetObsMembership, useGetObsInfo, useClosestVitessceContainerSize, useWindowDimensions, useGridItemSize, useExpandedFeatureLabelsMap, useColumnNameMapping, } from './hooks.js';
6
7
  export { useCoordinationScopes, useCoordinationScopesBy, useInitialCoordination, useCoordination, useComplexCoordination, useComplexCoordinationSecondary, useMultiCoordinationScopes, useMultiCoordinationScopesNonNull, useMultiCoordinationScopesSecondary, useMultiCoordinationScopesSecondaryNonNull, useMultiCoordinationValues, useMultiDatasetCoordination, useDatasetUids, useLoaders, useMergeCoordination, useMatchingLoader, useViewConfigStore, useViewConfigStoreApi, useViewConfig, useSetViewConfig, useComponentHover, useSetComponentHover, useComponentViewInfo, useSetComponentViewInfo, useWarning, useSetWarning, useAuxiliaryCoordination, useComponentLayout, useRemoveImageChannelInMetaCoordinationScopes, useAddImageChannelInMetaCoordinationScopes, } from './state/hooks.js';
7
- export { useDescription, useImageData, useObsSetsData, useObsEmbeddingData, useFeatureSelection, useObsFeatureMatrixIndices, useSampleSetsData, useSampleEdgesData, useMultiObsLabels, useMultiObsSpots, useMultiObsPoints, useSpotMultiObsSets, useSpotMultiFeatureLabels, useMultiObsSegmentations, useMultiImages, useObsSpotsData, useObsPointsData, useObsLocationsData, useObsSegmentationsData, useNeighborhoodsData, useObsLabelsData, useObsFeatureMatrixData, useFeatureLabelsData, useGenomicProfilesData, } from './data-hooks.js';
8
+ export { useDescription, useImageData, useObsSetsData, useObsEmbeddingData, useFeatureSelection, useObsFeatureMatrixIndices, useSampleSetsData, useSampleEdgesData, useMultiObsLabels, useMultiObsSpots, useMultiObsPoints, useSpotMultiObsSets, useSpotMultiFeatureLabels, useMultiObsSegmentations, useMultiImages, useObsSpotsData, useObsPointsData, useObsLocationsData, useObsSegmentationsData, useNeighborhoodsData, useObsLabelsData, useObsFeatureMatrixData, useFeatureLabelsData, useGenomicProfilesData, useComparisonMetadata, useFeatureStatsData, useFeatureSetStatsData, useObsSetStatsData, } from './data-hooks.js';
8
9
  export { usePointMultiObsLabels, useSpotMultiFeatureSelection, useSpotMultiObsFeatureMatrixIndices, useSegmentationMultiFeatureSelection, useSegmentationMultiObsFeatureMatrixIndices, useSegmentationMultiObsLocations, useSegmentationMultiObsSets, } from './data-hooks-multilevel.js';
9
10
  export { useHasLoader, } from './data-hook-utils.js';
10
11
  export { CellColorEncodingOption, OptionsContainer, OptionSelect, usePlotOptionsStyles, } from './shared-plot-options/index.js';
@@ -1 +1 @@
1
- {"version":3,"file":"VitessceGridLayout.d.ts","sourceRoot":"","sources":["../../src/vitessce-grid-layout/VitessceGridLayout.js"],"names":[],"mappings":"AAgBA,oDAmMC"}
1
+ {"version":3,"file":"VitessceGridLayout.d.ts","sourceRoot":"","sources":["../../src/vitessce-grid-layout/VitessceGridLayout.js"],"names":[],"mappings":"AAkBA,oDAuMC"}
@@ -2,8 +2,10 @@ import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-run
2
2
  import React, { useState, useMemo, useCallback } from 'react';
3
3
  import { Responsive, WidthProvider } from 'react-grid-layout-with-lodash';
4
4
  import { isEqual } from 'lodash-es';
5
+ import { ErrorBoundary } from 'react-error-boundary';
5
6
  import { getMaxRows, resolveLayout } from './layout-utils.js';
6
7
  import { PageModeViewContext } from '../contexts.js';
8
+ import { FallbackForView } from '../FallbackForView.js';
7
9
  const ResponsiveGridLayout = WidthProvider(Responsive);
8
10
  class ResponsiveHeightGridLayout extends ResponsiveGridLayout {
9
11
  componentDidUpdate(prevProps) {
@@ -102,9 +104,9 @@ export function VitessceGridLayout(props) {
102
104
  const gridComponentsValues = Object.values(gridComponents);
103
105
  const contextValue = Object.fromEntries(gridComponentsValues.map((v) => {
104
106
  const Component = getComponent(v.component);
105
- return [v.uid, () => (_jsx("div", { style: { display: 'flex', flexDirection: 'column', height: '100%' }, children: _jsx(Component, { ...v.props, uuid: v.uid, coordinationScopes: v.coordinationScopes, coordinationScopesBy: v.coordinationScopesBy, theme: theme, removeGridComponent: null,
106
- // Props used by LinkControllerSubscriber:
107
- viewTypes: viewTypes, fileTypes: fileTypes, coordinationTypes: coordinationTypes, stores: stores }) }, v.uid))];
107
+ return [v.uid, () => (_jsx("div", { style: { display: 'flex', flexDirection: 'column', height: '100%' }, children: _jsx(ErrorBoundary, { FallbackComponent: FallbackForView, children: _jsx(Component, { ...v.props, uuid: v.uid, coordinationScopes: v.coordinationScopes, coordinationScopesBy: v.coordinationScopesBy, theme: theme, removeGridComponent: null,
108
+ // Props used by LinkControllerSubscriber:
109
+ viewTypes: viewTypes, fileTypes: fileTypes, coordinationTypes: coordinationTypes, stores: stores }) }) }, v.uid))];
108
110
  }));
109
111
  // Not pageMode, so no children to render.
110
112
  // We render the grid components based on the layout information.
@@ -113,9 +115,9 @@ export function VitessceGridLayout(props) {
113
115
  const removeGridComponent = () => {
114
116
  onRemoveComponent(v.uid);
115
117
  };
116
- return (_jsx("div", { children: _jsx(Component, { ...v.props, uuid: v.uid, coordinationScopes: v.coordinationScopes, coordinationScopesBy: v.coordinationScopesBy, theme: theme, removeGridComponent: removeGridComponent,
117
- // Props used by LinkControllerSubscriber:
118
- viewTypes: viewTypes, fileTypes: fileTypes, coordinationTypes: coordinationTypes, stores: stores }) }, v.uid));
118
+ return (_jsx("div", { children: _jsx(ErrorBoundary, { FallbackComponent: FallbackForView, children: _jsx(Component, { ...v.props, uuid: v.uid, coordinationScopes: v.coordinationScopes, coordinationScopesBy: v.coordinationScopesBy, theme: theme, removeGridComponent: removeGridComponent,
119
+ // Props used by LinkControllerSubscriber:
120
+ viewTypes: viewTypes, fileTypes: fileTypes, coordinationTypes: coordinationTypes, stores: stores }) }) }, v.uid));
119
121
  }), contextValue];
120
122
  }, [gridComponents, getComponent, onRemoveComponent, theme]);
121
123
  return (pageMode
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vitessce/vit-s",
3
- "version": "3.5.7",
3
+ "version": "3.5.8",
4
4
  "author": "HIDIVE Lab at HMS",
5
5
  "homepage": "http://vitessce.io",
6
6
  "repository": {
@@ -29,14 +29,15 @@
29
29
  "uuid": "^9.0.0",
30
30
  "zustand": "^3.5.10",
31
31
  "react-aria": "^3.28.0",
32
- "@vitessce/abstract": "3.5.7",
33
- "@vitessce/constants-internal": "3.5.7",
34
- "@vitessce/plugins": "3.5.7",
35
- "@vitessce/schemas": "3.5.7",
36
- "@vitessce/utils": "3.5.7",
37
- "@vitessce/sets-utils": "3.5.7",
38
- "@vitessce/config": "3.5.7",
39
- "@vitessce/globals": "3.5.7"
32
+ "react-error-boundary": "^5.0.0",
33
+ "@vitessce/abstract": "3.5.8",
34
+ "@vitessce/constants-internal": "3.5.8",
35
+ "@vitessce/plugins": "3.5.8",
36
+ "@vitessce/schemas": "3.5.8",
37
+ "@vitessce/utils": "3.5.8",
38
+ "@vitessce/sets-utils": "3.5.8",
39
+ "@vitessce/config": "3.5.8",
40
+ "@vitessce/globals": "3.5.8"
40
41
  },
41
42
  "devDependencies": {
42
43
  "@testing-library/jest-dom": "^5.16.4",
@@ -44,7 +45,7 @@
44
45
  "react": "^18.0.0",
45
46
  "vite": "^4.3.0",
46
47
  "vitest": "^0.32.2",
47
- "@vitessce/types": "3.5.7"
48
+ "@vitessce/types": "3.5.8"
48
49
  },
49
50
  "peerDependencies": {
50
51
  "react": "^16.8.0 || ^17.0.0 || ^18.0.0"
@@ -0,0 +1,23 @@
1
+ import React from 'react';
2
+ import { getDebugMode } from '@vitessce/globals';
3
+
4
+ // TODO: Improve styling - perhaps style similar to ./TitleInfo.js
5
+ // TODO: Display different info depending on the type of error
6
+
7
+ // Reference: https://github.com/bvaughn/react-error-boundary?tab=readme-ov-file#errorboundary-with-fallbackcomponent-prop
8
+ export function FallbackForView(props) {
9
+ const {
10
+ error,
11
+ // Call resetErrorBoundary() to reset the error boundary and retry the render.
12
+ // resetErrorBoundary,
13
+ } = props;
14
+
15
+ return (
16
+ <div>
17
+ <p>A view-level error occurred.</p>
18
+ {getDebugMode() ? (
19
+ <pre style={{ color: 'red' }}>{error.message}</pre>
20
+ ) : null}
21
+ </div>
22
+ );
23
+ }
@@ -0,0 +1,21 @@
1
+ import React from 'react';
2
+
3
+ // TODO: Improve styling - see ./DebugWindow.js
4
+ // TODO: Display different info depending on the type of error
5
+
6
+ // Reference: https://github.com/bvaughn/react-error-boundary?tab=readme-ov-file#errorboundary-with-fallbackcomponent-prop
7
+ export function FallbackForVitS(props) {
8
+ const {
9
+ error,
10
+ // Call resetErrorBoundary() to reset the error boundary and retry the render.
11
+ // resetErrorBoundary,
12
+ } = props;
13
+
14
+
15
+ return (
16
+ <div>
17
+ <p>Error:</p>
18
+ <pre style={{ color: 'red' }}>{error.message}</pre>
19
+ </div>
20
+ );
21
+ }
@@ -0,0 +1,19 @@
1
+ import React from 'react';
2
+ import { ErrorBoundary } from 'react-error-boundary';
3
+ import { FallbackForVitS } from './FallbackForVitS.js';
4
+ import { VitS } from './VitS.js';
5
+
6
+ /**
7
+ * This serves as a way to wrap VitS in a React ErrorBoundary.
8
+ * Since there is a lot of logic within the VitS component,
9
+ * we want the ErrorBoundary to be a parent (as opposed to a child)
10
+ * of the VitS component.
11
+ * @param {*} props All props will be passed down to VitS.
12
+ */
13
+ export function VitSContainer(props) {
14
+ return (
15
+ <ErrorBoundary FallbackComponent={FallbackForVitS}>
16
+ <VitS {...props} />
17
+ </ErrorBoundary>
18
+ );
19
+ }
package/src/data-hooks.js CHANGED
@@ -219,6 +219,17 @@ export function useNeighborhoodsData(
219
219
  );
220
220
  }
221
221
 
222
+ export function useComparisonMetadata(
223
+ loaders, dataset, isRequired,
224
+ coordinationSetters, initialCoordinationValues, matchOn,
225
+ ) {
226
+ return useDataType(
227
+ DataType.COMPARISON_METADATA,
228
+ loaders, dataset, isRequired,
229
+ coordinationSetters, initialCoordinationValues, matchOn,
230
+ );
231
+ }
232
+
222
233
  /**
223
234
  * Get data from the expression matrix data type loader for a given gene selection.
224
235
  * Throw warnings if the data is marked as required.
@@ -313,6 +324,117 @@ export function useFeatureSelection(
313
324
  return [geneData, loadedGeneName, dataStatus];
314
325
  }
315
326
 
327
+ /**
328
+ * Utility hook function which can be used to define
329
+ * dataType-specific data hooks which call a loader.loadMulti
330
+ * method to obtain multiple data frames resulting from
331
+ * multiple comparative analyses.
332
+ * @param {object} loaders The object mapping
333
+ * datasets and data types to loader instances.
334
+ * @param {string} dataset The key for a dataset,
335
+ * used to identify which loader to use.
336
+ * @param {boolean} isRequired Should a warning be thrown if
337
+ * loading is unsuccessful?
338
+ * @param {object} matchOn Coordination values used to obtain a matching loader.
339
+ * @param {object} volcanoOptions Options to pass to the loadMulti function of the loader.
340
+ * @param {string} dataType A data type.
341
+ * @returns {array} [{ df, metadata }] Array of dataframes and their metadata, where
342
+ * df is an object in which each column is stored as an array like { col1: arr1, col2: arr2 }.
343
+ */
344
+ export function useComparativeDataType(
345
+ loaders, dataset, isRequired, matchOn, volcanoOptions, dataType,
346
+ ) {
347
+ const setWarning = useSetWarning();
348
+ const placeholderObject = useMemo(() => ({}), []);
349
+ const statsQuery = useQuery({
350
+ // TODO: only enable once `loaders` is available?
351
+ structuralSharing: false,
352
+ placeholderData: placeholderObject,
353
+ // Include the hook name in the queryKey to prevent the case in which an identical queryKey
354
+ // in a different hook would cause an accidental cache hit.
355
+ queryKey: [dataset, dataType, matchOn, volcanoOptions, 'useComparativeData'],
356
+ // TODO: use TypeScript to type the return value?
357
+ queryFn: async (ctx) => {
358
+ const loader = getMatchingLoader(
359
+ ctx.meta.loaders, ctx.queryKey[0], ctx.queryKey[1], ctx.queryKey[2],
360
+ );
361
+ if (loader) {
362
+ // FeatureStats loader has a special loadMulti function
363
+ // that depends on coordination values such as sampleSetSelection.
364
+ const implementsLoadAttrs = typeof loader.loadMulti === 'function';
365
+ if (implementsLoadAttrs) {
366
+ // Has loadMulti function.
367
+ const payload = await loader.loadMulti(volcanoOptions);
368
+ if (!payload) return placeholderObject;
369
+ const { data: payloadData } = payload;
370
+
371
+ return {
372
+ data: payloadData,
373
+ urls: null,
374
+ };
375
+ }
376
+ // No loadAttrs function.
377
+ const payload = await loader.load();
378
+ if (!payload) return placeholderObject;
379
+ const { data: payloadData } = payload;
380
+ return {
381
+ data: payloadData,
382
+ urls: null,
383
+ };
384
+ }
385
+ // No loader was found.
386
+ if (isRequired) {
387
+ // Status: error
388
+ throw new LoaderNotFoundError(loaders, dataset, dataType, matchOn);
389
+ } else {
390
+ // Status: success
391
+ return { data: placeholderObject, dataKey: null };
392
+ }
393
+ },
394
+ meta: { loaders },
395
+ });
396
+ const { data, status, isFetching, error } = statsQuery;
397
+ const loadedData = data?.data || placeholderObject;
398
+
399
+ const dataStatus = isFetching ? STATUS.LOADING : status;
400
+ const urls = data?.urls;
401
+
402
+ useEffect(() => {
403
+ if (error) {
404
+ setWarning(error.message);
405
+ }
406
+ }, [error, setWarning]);
407
+
408
+ return [loadedData, dataStatus, urls];
409
+ }
410
+
411
+ export function useFeatureStatsData(
412
+ loaders, dataset, isRequired, matchOn, volcanoOptions,
413
+ ) {
414
+ return useComparativeDataType(
415
+ loaders, dataset, isRequired, matchOn, volcanoOptions,
416
+ DataType.FEATURE_STATS,
417
+ );
418
+ }
419
+
420
+ export function useFeatureSetStatsData(
421
+ loaders, dataset, isRequired, matchOn, volcanoOptions,
422
+ ) {
423
+ return useComparativeDataType(
424
+ loaders, dataset, isRequired, matchOn, volcanoOptions,
425
+ DataType.FEATURE_SET_STATS,
426
+ );
427
+ }
428
+
429
+ export function useObsSetStatsData(
430
+ loaders, dataset, isRequired, matchOn, volcanoOptions,
431
+ ) {
432
+ return useComparativeDataType(
433
+ loaders, dataset, isRequired, matchOn, volcanoOptions,
434
+ DataType.OBS_SET_STATS,
435
+ );
436
+ }
437
+
316
438
  /**
317
439
  * Get the attributes for the expression matrix data type loader,
318
440
  * i.e names of cells and genes.
package/src/hooks.js CHANGED
@@ -370,3 +370,34 @@ export function useExpandedFeatureLabelsMap(featureType, featureLabelsMap, optio
370
370
  );
371
371
  return [updatedFeatureLabelsMap, dataStatus];
372
372
  }
373
+
374
+ /**
375
+ * Using a loader object's options,
376
+ * return a mapping from group name to column name.
377
+ * @param {*} loader obsSets or sampleSets loader class
378
+ * @param {[boolean]} reverse Optionally, reverse
379
+ * (so, return column name to group name mapping).
380
+ * @returns {Record<string, string>} Mapping from group name to column name.
381
+ */
382
+ export function useColumnNameMapping(loader, reverse = false) {
383
+ return useMemo(() => {
384
+ const result = {};
385
+ if (loader?.options) {
386
+ const optionsArray = loader.options.obsSets
387
+ ? loader.options.obsSets
388
+ : loader.options.sampleSets;
389
+ optionsArray.forEach((optionObject) => {
390
+ const { name, path } = optionObject;
391
+ const columnName = path.split('/').at(-1);
392
+ result[name] = columnName;
393
+ });
394
+ }
395
+ if (reverse) {
396
+ return Object.fromEntries(
397
+ Object.entries(result)
398
+ .map(([k, v]) => ([v, k])),
399
+ );
400
+ }
401
+ return result;
402
+ }, [loader]);
403
+ }