@vitessce/vit-s 2.0.0-beta.0

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.
Files changed (91) hide show
  1. package/LICENSE +21 -0
  2. package/dist/CallbackPublisher.js +68 -0
  3. package/dist/LoadingIndicator.js +27 -0
  4. package/dist/TitleInfo.js +151 -0
  5. package/dist/VitS.js +113 -0
  6. package/dist/Vitessce.integration.test.js +36 -0
  7. package/dist/Vitessce.js +101 -0
  8. package/dist/VitessceGrid.js +55 -0
  9. package/dist/VitessceGrid.test.js +36 -0
  10. package/dist/Warning.js +45 -0
  11. package/dist/classNames.js +8 -0
  12. package/dist/component-registry.js +16 -0
  13. package/dist/data/AbstractLoader.js +35 -0
  14. package/dist/data/AbstractTwoStepLoader.js +7 -0
  15. package/dist/data/LoaderResult.js +7 -0
  16. package/dist/data/index.js +3 -0
  17. package/dist/data/loader-registry.js +15 -0
  18. package/dist/data-hook-utils.js +175 -0
  19. package/dist/data-hooks.js +241 -0
  20. package/dist/errors/AbstractLoaderError.js +13 -0
  21. package/dist/errors/DataSourceFetchError.js +13 -0
  22. package/dist/errors/DatasetNotFoundError.js +17 -0
  23. package/dist/errors/LoaderNotFoundError.js +17 -0
  24. package/dist/errors/LoaderValidationError.js +15 -0
  25. package/dist/errors/OptionsValidationError.js +15 -0
  26. package/dist/errors/index.js +6 -0
  27. package/dist/export-utils.js +70 -0
  28. package/dist/export-utils.test.js +66 -0
  29. package/dist/file-options-schemas-legacy.js +136 -0
  30. package/dist/file-options-schemas-legacy.test.js +126 -0
  31. package/dist/file-options-schemas.js +322 -0
  32. package/dist/file-options-schemas.test.js +23 -0
  33. package/dist/hooks.js +215 -0
  34. package/dist/index.js +18 -0
  35. package/dist/joint-file-types-legacy.js +278 -0
  36. package/dist/joint-file-types-legacy.test.js +400 -0
  37. package/dist/joint-file-types.js +148 -0
  38. package/dist/joint-file-types.test.js +139 -0
  39. package/dist/loader-registry.js +98 -0
  40. package/dist/plugins.js +154 -0
  41. package/dist/plugins.test.fixtures.js +76 -0
  42. package/dist/plugins.test.js +30 -0
  43. package/dist/schemas/PrettyJsonSchema.js +34 -0
  44. package/dist/schemas/config-0.1.0.schema.json +84 -0
  45. package/dist/schemas/config-1.0.0.schema.json +733 -0
  46. package/dist/schemas/config-1.0.1.schema.json +909 -0
  47. package/dist/schemas/config-1.0.10.schema.json +969 -0
  48. package/dist/schemas/config-1.0.11.schema.json +990 -0
  49. package/dist/schemas/config-1.0.12.schema.json +997 -0
  50. package/dist/schemas/config-1.0.13.schema.json +1013 -0
  51. package/dist/schemas/config-1.0.14.schema.json +1048 -0
  52. package/dist/schemas/config-1.0.15.schema.json +1048 -0
  53. package/dist/schemas/config-1.0.15.schema.test.js +22 -0
  54. package/dist/schemas/config-1.0.2.schema.json +910 -0
  55. package/dist/schemas/config-1.0.3.schema.json +910 -0
  56. package/dist/schemas/config-1.0.4.schema.json +949 -0
  57. package/dist/schemas/config-1.0.5.schema.json +949 -0
  58. package/dist/schemas/config-1.0.6.schema.json +949 -0
  59. package/dist/schemas/config-1.0.7.schema.json +949 -0
  60. package/dist/schemas/config-1.0.8.schema.json +965 -0
  61. package/dist/schemas/config-1.0.9.schema.json +965 -0
  62. package/dist/schemas/obsSets.schema.js +195 -0
  63. package/dist/schemas/obsSets.schema.json +194 -0
  64. package/dist/schemas/obsSetsTabular.schema.js +38 -0
  65. package/dist/schemas/obsSetsTabular.schema.json +37 -0
  66. package/dist/schemas/raster.schema.js +120 -0
  67. package/dist/schemas/raster.schema.json +119 -0
  68. package/dist/schemas/schema.test-old.js +50 -0
  69. package/dist/schemas/schema.test.js +46 -0
  70. package/dist/schemas.js +4 -0
  71. package/dist/shared-mui/components.js +35 -0
  72. package/dist/shared-mui/container.js +211 -0
  73. package/dist/shared-mui/styles.js +63 -0
  74. package/dist/shared-plot-options/CellColorEncodingOption.js +18 -0
  75. package/dist/shared-plot-options/OptionSelect.js +12 -0
  76. package/dist/shared-plot-options/OptionsContainer.js +12 -0
  77. package/dist/shared-plot-options/index.js +4 -0
  78. package/dist/shared-plot-options/styles.js +48 -0
  79. package/dist/state/hooks.js +550 -0
  80. package/dist/view-config-upgraders.js +525 -0
  81. package/dist/view-config-utils.js +286 -0
  82. package/dist/view-config-utils.test.fixtures.js +765 -0
  83. package/dist/view-config-utils.test.js +66 -0
  84. package/dist/view-config-versions.js +47 -0
  85. package/dist/vitessce-grid-layout/VitessceGridLayout.js +96 -0
  86. package/dist/vitessce-grid-layout/VitessceGridLayout.test.js +40 -0
  87. package/dist/vitessce-grid-layout/index.js +1 -0
  88. package/dist/vitessce-grid-layout/layout-utils.js +61 -0
  89. package/dist/vitessce-grid-layout/layout-utils.test.js +146 -0
  90. package/dist/vitessce-grid-utils.js +140 -0
  91. package/package.json +43 -0
@@ -0,0 +1,278 @@
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
+ }
@@ -0,0 +1,400 @@
1
+ import { expandExpressionMatrixZarr, expandRasterJson, expandRasterOmeZarr, expandGenesJson, expandClustersJson, expandCellsJson, expandMoleculesJson, expandAnndataCellsZarr, expandAnndataCellSetsZarr, expandAnndataExpressionMatrixZarr, } from './joint-file-types-legacy';
2
+ describe('src/app/joint-file-types-legacy.js', () => {
3
+ describe('expandExpressionMatrixZarr', () => {
4
+ it('expands expression-matrix.zarr', () => {
5
+ expect(expandExpressionMatrixZarr({
6
+ fileType: 'expression-matrix.zarr',
7
+ url: 'http://localhost:8000/expression-matrix.zarr',
8
+ })).toEqual([
9
+ {
10
+ fileType: 'obsFeatureMatrix.expression-matrix.zarr',
11
+ url: 'http://localhost:8000/expression-matrix.zarr',
12
+ coordinationValues: {
13
+ obsType: 'cell',
14
+ featureType: 'gene',
15
+ featureValueType: 'expression',
16
+ },
17
+ },
18
+ ]);
19
+ });
20
+ });
21
+ describe('expandRasterJson', () => {
22
+ it('expands raster.json', () => {
23
+ expect(expandRasterJson({
24
+ fileType: 'raster.json',
25
+ url: 'http://localhost:8000/raster.json',
26
+ })).toEqual([
27
+ {
28
+ fileType: 'image.raster.json',
29
+ url: 'http://localhost:8000/raster.json',
30
+ },
31
+ {
32
+ fileType: 'obsSegmentations.raster.json',
33
+ url: 'http://localhost:8000/raster.json',
34
+ coordinationValues: {
35
+ obsType: 'cell',
36
+ },
37
+ },
38
+ ]);
39
+ });
40
+ });
41
+ describe('expandRasterOmeZarr', () => {
42
+ it('expands raster.ome-zarr', () => {
43
+ expect(expandRasterOmeZarr({
44
+ fileType: 'raster.ome-zarr',
45
+ url: 'http://localhost:8000/raster.zarr',
46
+ })).toEqual([
47
+ {
48
+ fileType: 'image.ome-zarr',
49
+ url: 'http://localhost:8000/raster.zarr',
50
+ },
51
+ ]);
52
+ });
53
+ });
54
+ describe('expandClustersJson', () => {
55
+ it('expands clusters.json', () => {
56
+ expect(expandClustersJson({
57
+ fileType: 'clusters.json',
58
+ url: 'http://localhost:8000/clusters.json',
59
+ })).toEqual([
60
+ {
61
+ fileType: 'obsFeatureMatrix.clusters.json',
62
+ url: 'http://localhost:8000/clusters.json',
63
+ coordinationValues: {
64
+ obsType: 'cell',
65
+ featureType: 'gene',
66
+ featureValueType: 'expression',
67
+ },
68
+ },
69
+ ]);
70
+ });
71
+ });
72
+ describe('expandGenesJson', () => {
73
+ it('expands', () => {
74
+ expect(expandGenesJson({
75
+ fileType: 'genes.json',
76
+ url: 'http://localhost:8000/genes.json',
77
+ })).toEqual([
78
+ {
79
+ fileType: 'obsFeatureMatrix.genes.json',
80
+ url: 'http://localhost:8000/genes.json',
81
+ coordinationValues: {
82
+ obsType: 'cell',
83
+ featureType: 'gene',
84
+ featureValueType: 'expression',
85
+ },
86
+ },
87
+ ]);
88
+ });
89
+ });
90
+ describe('expandMoleculesJson', () => {
91
+ it('expands when there are no options', () => {
92
+ expect(expandMoleculesJson({
93
+ fileType: 'molecules.json',
94
+ url: 'http://localhost:8000/molecules.json',
95
+ })).toEqual([
96
+ {
97
+ fileType: 'obsLocations.molecules.json',
98
+ url: 'http://localhost:8000/molecules.json',
99
+ coordinationValues: {
100
+ obsType: 'molecule',
101
+ },
102
+ },
103
+ {
104
+ fileType: 'obsLabels.molecules.json',
105
+ url: 'http://localhost:8000/molecules.json',
106
+ coordinationValues: {
107
+ obsType: 'molecule',
108
+ },
109
+ },
110
+ ]);
111
+ });
112
+ });
113
+ describe('expandCellsJson', () => {
114
+ it('expands when there are no options', () => {
115
+ expect(expandCellsJson({
116
+ fileType: 'cells.json',
117
+ url: 'http://localhost:8000/cells.json',
118
+ })).toEqual([
119
+ {
120
+ fileType: 'obsSegmentations.cells.json',
121
+ url: 'http://localhost:8000/cells.json',
122
+ coordinationValues: {
123
+ obsType: 'cell',
124
+ },
125
+ },
126
+ {
127
+ fileType: 'obsLocations.cells.json',
128
+ url: 'http://localhost:8000/cells.json',
129
+ coordinationValues: {
130
+ obsType: 'cell',
131
+ },
132
+ },
133
+ ]);
134
+ });
135
+ it('expands when there is an array of embedding types', () => {
136
+ expect(expandCellsJson({
137
+ fileType: 'cells.json',
138
+ url: 'http://localhost:8000/cells.json',
139
+ options: {
140
+ embeddingTypes: ['UMAP', 't-SNE'],
141
+ obsLabelsTypes: ['cluster', 'subcluster'],
142
+ },
143
+ })).toEqual([
144
+ {
145
+ fileType: 'obsSegmentations.cells.json',
146
+ url: 'http://localhost:8000/cells.json',
147
+ coordinationValues: {
148
+ obsType: 'cell',
149
+ },
150
+ },
151
+ {
152
+ fileType: 'obsLocations.cells.json',
153
+ url: 'http://localhost:8000/cells.json',
154
+ coordinationValues: {
155
+ obsType: 'cell',
156
+ },
157
+ },
158
+ {
159
+ fileType: 'obsEmbedding.cells.json',
160
+ url: 'http://localhost:8000/cells.json',
161
+ coordinationValues: {
162
+ obsType: 'cell',
163
+ embeddingType: 'UMAP',
164
+ },
165
+ },
166
+ {
167
+ fileType: 'obsEmbedding.cells.json',
168
+ url: 'http://localhost:8000/cells.json',
169
+ coordinationValues: {
170
+ obsType: 'cell',
171
+ embeddingType: 't-SNE',
172
+ },
173
+ },
174
+ {
175
+ fileType: 'obsLabels.cells.json',
176
+ url: 'http://localhost:8000/cells.json',
177
+ coordinationValues: {
178
+ obsType: 'cell',
179
+ obsLabelsType: 'cluster',
180
+ },
181
+ },
182
+ {
183
+ fileType: 'obsLabels.cells.json',
184
+ url: 'http://localhost:8000/cells.json',
185
+ coordinationValues: {
186
+ obsType: 'cell',
187
+ obsLabelsType: 'subcluster',
188
+ },
189
+ },
190
+ ]);
191
+ });
192
+ });
193
+ // cells
194
+ describe('expandAnndataCellsZarr', () => {
195
+ it('fails to expand when there are no options', () => {
196
+ expect(() => expandAnndataCellsZarr({
197
+ fileType: 'anndata-cells.zarr',
198
+ url: 'http://localhost:8000/anndata.zarr',
199
+ })).toThrow();
200
+ });
201
+ it('expands when there are lots of options', () => {
202
+ expect(expandAnndataCellsZarr({
203
+ fileType: 'anndata-cells.zarr',
204
+ url: 'http://localhost:8000/anndata.zarr',
205
+ options: {
206
+ mappings: {
207
+ 't-SNE': {
208
+ key: 'obsm/tsne',
209
+ },
210
+ PCA: {
211
+ dims: [2, 3],
212
+ key: 'obsm/pca',
213
+ },
214
+ },
215
+ xy: 'obsm/locations',
216
+ poly: 'obsm/segmentations',
217
+ factors: [
218
+ 'obs/cluster',
219
+ 'obs/subcluster',
220
+ ],
221
+ },
222
+ })).toEqual([
223
+ {
224
+ fileType: 'obsSegmentations.anndata.zarr',
225
+ url: 'http://localhost:8000/anndata.zarr',
226
+ options: {
227
+ path: 'obsm/segmentations',
228
+ },
229
+ coordinationValues: {
230
+ obsType: 'cell',
231
+ },
232
+ },
233
+ {
234
+ fileType: 'obsLocations.anndata.zarr',
235
+ url: 'http://localhost:8000/anndata.zarr',
236
+ options: {
237
+ path: 'obsm/locations',
238
+ },
239
+ coordinationValues: {
240
+ obsType: 'cell',
241
+ },
242
+ },
243
+ {
244
+ fileType: 'obsEmbedding.anndata.zarr',
245
+ url: 'http://localhost:8000/anndata.zarr',
246
+ options: {
247
+ path: 'obsm/tsne',
248
+ },
249
+ coordinationValues: {
250
+ obsType: 'cell',
251
+ embeddingType: 't-SNE',
252
+ },
253
+ },
254
+ {
255
+ fileType: 'obsEmbedding.anndata.zarr',
256
+ url: 'http://localhost:8000/anndata.zarr',
257
+ options: {
258
+ path: 'obsm/pca',
259
+ dims: [2, 3],
260
+ },
261
+ coordinationValues: {
262
+ obsType: 'cell',
263
+ embeddingType: 'PCA',
264
+ },
265
+ },
266
+ {
267
+ fileType: 'obsLabels.anndata.zarr',
268
+ url: 'http://localhost:8000/anndata.zarr',
269
+ options: {
270
+ path: 'obs/cluster',
271
+ },
272
+ coordinationValues: {
273
+ obsType: 'cell',
274
+ obsLabelsType: 'cluster',
275
+ },
276
+ },
277
+ {
278
+ fileType: 'obsLabels.anndata.zarr',
279
+ url: 'http://localhost:8000/anndata.zarr',
280
+ options: {
281
+ path: 'obs/subcluster',
282
+ },
283
+ coordinationValues: {
284
+ obsType: 'cell',
285
+ obsLabelsType: 'subcluster',
286
+ },
287
+ },
288
+ ]);
289
+ });
290
+ });
291
+ // cell sets
292
+ describe('expandAnndataCellSetsZarr', () => {
293
+ it('expands both flat and hierarchical cell sets', () => {
294
+ expect(expandAnndataCellSetsZarr({
295
+ fileType: 'anndata-cell-sets.zarr',
296
+ url: 'http://localhost:8000/anndata.zarr',
297
+ options: [
298
+ {
299
+ groupName: 'Leiden clustering',
300
+ setName: 'obs/leiden',
301
+ },
302
+ {
303
+ groupName: 'Predicted cell types',
304
+ setName: 'obs/pred_types',
305
+ scoreName: 'obs/pred_scores',
306
+ },
307
+ {
308
+ groupName: 'Cell type annotations',
309
+ setName: ['obs/l1', 'obs/l2', 'obs/l3'],
310
+ },
311
+ ],
312
+ })).toEqual([
313
+ {
314
+ fileType: 'obsSets.anndata.zarr',
315
+ url: 'http://localhost:8000/anndata.zarr',
316
+ options: [
317
+ {
318
+ name: 'Leiden clustering',
319
+ path: 'obs/leiden',
320
+ },
321
+ {
322
+ name: 'Predicted cell types',
323
+ path: 'obs/pred_types',
324
+ scorePath: 'obs/pred_scores',
325
+ },
326
+ {
327
+ name: 'Cell type annotations',
328
+ path: ['obs/l1', 'obs/l2', 'obs/l3'],
329
+ },
330
+ ],
331
+ coordinationValues: {
332
+ obsType: 'cell',
333
+ },
334
+ },
335
+ ]);
336
+ });
337
+ // expression-matrix
338
+ describe('expandAnndataExpressionMatrixZarr', () => {
339
+ it('expands when there are no options', () => {
340
+ expect(expandAnndataExpressionMatrixZarr({
341
+ fileType: 'anndata-expression-matrix.zarr',
342
+ url: 'http://localhost:8000/anndata.zarr',
343
+ options: {
344
+ matrix: 'X',
345
+ },
346
+ })).toEqual([
347
+ {
348
+ fileType: 'obsFeatureMatrix.anndata.zarr',
349
+ url: 'http://localhost:8000/anndata.zarr',
350
+ options: {
351
+ path: 'X',
352
+ },
353
+ coordinationValues: {
354
+ obsType: 'cell',
355
+ featureType: 'gene',
356
+ featureValueType: 'expression',
357
+ },
358
+ },
359
+ ]);
360
+ });
361
+ it('expands when there are lots of options', () => {
362
+ expect(expandAnndataExpressionMatrixZarr({
363
+ fileType: 'anndata-expression-matrix.zarr',
364
+ url: 'http://localhost:8000/anndata.zarr',
365
+ options: {
366
+ matrix: 'obsm/hvg_subset',
367
+ geneAlias: 'var/gene_symbol',
368
+ geneFilter: 'var/in_hvg_subset',
369
+ matrixGeneFilter: 'var/highly_variable',
370
+ },
371
+ })).toEqual([
372
+ {
373
+ fileType: 'featureLabels.anndata.zarr',
374
+ url: 'http://localhost:8000/anndata.zarr',
375
+ options: {
376
+ path: 'var/gene_symbol',
377
+ },
378
+ coordinationValues: {
379
+ featureType: 'gene',
380
+ },
381
+ },
382
+ {
383
+ fileType: 'obsFeatureMatrix.anndata.zarr',
384
+ url: 'http://localhost:8000/anndata.zarr',
385
+ options: {
386
+ path: 'obsm/hvg_subset',
387
+ featureFilterPath: 'var/in_hvg_subset',
388
+ initialFeatureFilterPath: 'var/highly_variable',
389
+ },
390
+ coordinationValues: {
391
+ obsType: 'cell',
392
+ featureType: 'gene',
393
+ featureValueType: 'expression',
394
+ },
395
+ },
396
+ ]);
397
+ });
398
+ });
399
+ });
400
+ });