@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.
Files changed (172) hide show
  1. package/dist/index.mjs +84801 -0
  2. package/{dist → dist-tsc}/index.js +2 -2
  3. package/package.json +7 -7
  4. package/src/CallbackPublisher.js +81 -0
  5. package/src/LoadingIndicator.js +34 -0
  6. package/src/TitleInfo.js +240 -0
  7. package/src/VitS.js +180 -0
  8. package/src/VitessceGrid.js +110 -0
  9. package/src/VitessceGrid.test.jsx +48 -0
  10. package/src/Warning.js +62 -0
  11. package/{dist → src}/classNames.js +0 -0
  12. package/src/component-registry.js +21 -0
  13. package/src/data/AbstractLoader.js +46 -0
  14. package/{dist → src}/data/AbstractTwoStepLoader.js +5 -4
  15. package/src/data/LoaderResult.js +8 -0
  16. package/{dist → src}/data/index.js +0 -0
  17. package/src/data/loader-registry.js +19 -0
  18. package/src/data-hook-utils.js +197 -0
  19. package/src/data-hooks.js +354 -0
  20. package/src/errors/AbstractLoaderError.js +14 -0
  21. package/src/errors/DataSourceFetchError.js +15 -0
  22. package/src/errors/DatasetNotFoundError.js +23 -0
  23. package/src/errors/LoaderNotFoundError.js +24 -0
  24. package/src/errors/LoaderValidationError.js +23 -0
  25. package/src/errors/OptionsValidationError.js +25 -0
  26. package/{dist → src}/errors/index.js +0 -0
  27. package/src/file-options-schemas-legacy.js +139 -0
  28. package/src/file-options-schemas-legacy.test.js +138 -0
  29. package/src/file-options-schemas.js +327 -0
  30. package/src/file-options-schemas.test.js +26 -0
  31. package/src/hooks.js +252 -0
  32. package/src/index.js +101 -0
  33. package/src/joint-file-types-legacy.js +298 -0
  34. package/src/joint-file-types-legacy.test.js +412 -0
  35. package/src/joint-file-types.js +171 -0
  36. package/src/joint-file-types.test.js +144 -0
  37. package/{dist/schemas.js → src/json-schemas.js} +6 -1
  38. package/{dist → src}/plugins.js +102 -70
  39. package/src/plugins.test.fixtures.js +78 -0
  40. package/src/plugins.test.js +42 -0
  41. package/src/schemas/config-0.1.0.schema.json +85 -0
  42. package/src/schemas/config-1.0.0.schema.json +733 -0
  43. package/src/schemas/config-1.0.1.schema.json +909 -0
  44. package/src/schemas/config-1.0.10.schema.json +969 -0
  45. package/src/schemas/config-1.0.11.schema.json +990 -0
  46. package/src/schemas/config-1.0.12.schema.json +997 -0
  47. package/src/schemas/config-1.0.13.schema.json +1013 -0
  48. package/src/schemas/config-1.0.14.schema.json +1048 -0
  49. package/src/schemas/config-1.0.15.schema.json +1048 -0
  50. package/src/schemas/config-1.0.16.schema.json +1069 -0
  51. package/src/schemas/config-1.0.16.schema.test.js +32 -0
  52. package/src/schemas/config-1.0.2.schema.json +911 -0
  53. package/src/schemas/config-1.0.3.schema.json +911 -0
  54. package/src/schemas/config-1.0.4.schema.json +949 -0
  55. package/src/schemas/config-1.0.5.schema.json +949 -0
  56. package/src/schemas/config-1.0.6.schema.json +950 -0
  57. package/src/schemas/config-1.0.7.schema.json +950 -0
  58. package/src/schemas/config-1.0.8.schema.json +966 -0
  59. package/src/schemas/config-1.0.9.schema.json +965 -0
  60. package/src/schemas/fixtures/cellSets.good.json +16 -0
  61. package/src/schemas/fixtures/config-1.0.1.bad.json +1 -0
  62. package/src/schemas/fixtures/config-1.0.1.bad.message.json +11 -0
  63. package/src/schemas/fixtures/config-1.0.1.good.json +37 -0
  64. package/src/schemas/fixtures/config-1.0.2.bad.json +1 -0
  65. package/src/schemas/fixtures/config-1.0.2.bad.message.json +11 -0
  66. package/src/schemas/fixtures/config-1.0.2.good.json +38 -0
  67. package/src/schemas/fixtures/config-1.0.3.bad.json +1 -0
  68. package/src/schemas/fixtures/config-1.0.3.bad.message.json +11 -0
  69. package/src/schemas/fixtures/config-1.0.3.good.json +38 -0
  70. package/src/schemas/fixtures/obsSets.bad.json +1 -0
  71. package/src/schemas/fixtures/obsSets.bad.message.json +11 -0
  72. package/src/schemas/fixtures/obsSets.good.json +16 -0
  73. package/src/schemas/fixtures/obsSetsTabular.bad.json +1 -0
  74. package/src/schemas/fixtures/obsSetsTabular.bad.message.json +11 -0
  75. package/src/schemas/fixtures/obsSetsTabular.good.json +26 -0
  76. package/src/schemas/fixtures/raster.bad.json +1 -0
  77. package/src/schemas/fixtures/raster.bad.message.json +11 -0
  78. package/src/schemas/fixtures/raster.good.json +39 -0
  79. package/src/schemas/obsSets.schema.js +195 -0
  80. package/src/schemas/obsSetsTabular.schema.js +39 -0
  81. package/src/schemas/raster.schema.js +121 -0
  82. package/src/schemas/schema-schema.sh +34 -0
  83. package/{dist → src}/schemas/schema.test-old.js +0 -1
  84. package/src/shared-mui/components.js +79 -0
  85. package/src/shared-mui/container.js +212 -0
  86. package/src/shared-mui/styles.js +110 -0
  87. package/src/shared-plot-options/CellColorEncodingOption.js +43 -0
  88. package/src/shared-plot-options/OptionSelect.js +19 -0
  89. package/src/shared-plot-options/OptionsContainer.js +26 -0
  90. package/{dist → src}/shared-plot-options/index.js +0 -0
  91. package/src/shared-plot-options/styles.js +49 -0
  92. package/src/state/hooks.js +633 -0
  93. package/src/view-config-upgraders.js +628 -0
  94. package/src/view-config-utils.js +315 -0
  95. package/src/view-config-utils.test.fixtures.js +893 -0
  96. package/src/view-config-utils.test.js +95 -0
  97. package/src/view-config-versions.js +68 -0
  98. package/src/vitessce-grid-layout/VitessceGridLayout.js +158 -0
  99. package/src/vitessce-grid-layout/VitessceGridLayout.test.jsx +56 -0
  100. package/{dist → src}/vitessce-grid-layout/index.js +0 -0
  101. package/src/vitessce-grid-layout/layout-utils.js +76 -0
  102. package/src/vitessce-grid-layout/layout-utils.test.js +167 -0
  103. package/src/vitessce-grid-utils.js +160 -0
  104. package/dist/CallbackPublisher.js +0 -68
  105. package/dist/LoadingIndicator.js +0 -27
  106. package/dist/TitleInfo.js +0 -151
  107. package/dist/VitS.js +0 -112
  108. package/dist/VitessceGrid.js +0 -59
  109. package/dist/VitessceGrid.test.js +0 -36
  110. package/dist/Warning.js +0 -45
  111. package/dist/component-registry.js +0 -16
  112. package/dist/data/AbstractLoader.js +0 -35
  113. package/dist/data/LoaderResult.js +0 -7
  114. package/dist/data/loader-registry.js +0 -15
  115. package/dist/data-hook-utils.js +0 -175
  116. package/dist/data-hooks.js +0 -241
  117. package/dist/errors/AbstractLoaderError.js +0 -13
  118. package/dist/errors/DataSourceFetchError.js +0 -13
  119. package/dist/errors/DatasetNotFoundError.js +0 -17
  120. package/dist/errors/LoaderNotFoundError.js +0 -17
  121. package/dist/errors/LoaderValidationError.js +0 -15
  122. package/dist/errors/OptionsValidationError.js +0 -15
  123. package/dist/file-options-schemas-legacy.js +0 -136
  124. package/dist/file-options-schemas-legacy.test.js +0 -126
  125. package/dist/file-options-schemas.js +0 -322
  126. package/dist/file-options-schemas.test.js +0 -23
  127. package/dist/hooks.js +0 -215
  128. package/dist/joint-file-types-legacy.js +0 -278
  129. package/dist/joint-file-types-legacy.test.js +0 -400
  130. package/dist/joint-file-types.js +0 -148
  131. package/dist/joint-file-types.test.js +0 -139
  132. package/dist/plugins.test.fixtures.js +0 -76
  133. package/dist/plugins.test.js +0 -30
  134. package/dist/schemas/config-0.1.0.schema.json +0 -84
  135. package/dist/schemas/config-1.0.0.schema.json +0 -733
  136. package/dist/schemas/config-1.0.1.schema.json +0 -909
  137. package/dist/schemas/config-1.0.10.schema.json +0 -969
  138. package/dist/schemas/config-1.0.11.schema.json +0 -990
  139. package/dist/schemas/config-1.0.12.schema.json +0 -997
  140. package/dist/schemas/config-1.0.13.schema.json +0 -1013
  141. package/dist/schemas/config-1.0.14.schema.json +0 -1048
  142. package/dist/schemas/config-1.0.15.schema.json +0 -1048
  143. package/dist/schemas/config-1.0.15.schema.test.js +0 -22
  144. package/dist/schemas/config-1.0.2.schema.json +0 -910
  145. package/dist/schemas/config-1.0.3.schema.json +0 -910
  146. package/dist/schemas/config-1.0.4.schema.json +0 -949
  147. package/dist/schemas/config-1.0.5.schema.json +0 -949
  148. package/dist/schemas/config-1.0.6.schema.json +0 -949
  149. package/dist/schemas/config-1.0.7.schema.json +0 -949
  150. package/dist/schemas/config-1.0.8.schema.json +0 -965
  151. package/dist/schemas/config-1.0.9.schema.json +0 -965
  152. package/dist/schemas/obsSets.schema.js +0 -195
  153. package/dist/schemas/obsSetsTabular.schema.js +0 -38
  154. package/dist/schemas/raster.schema.js +0 -120
  155. package/dist/shared-mui/components.js +0 -35
  156. package/dist/shared-mui/container.js +0 -211
  157. package/dist/shared-mui/styles.js +0 -73
  158. package/dist/shared-plot-options/CellColorEncodingOption.js +0 -18
  159. package/dist/shared-plot-options/OptionSelect.js +0 -12
  160. package/dist/shared-plot-options/OptionsContainer.js +0 -12
  161. package/dist/shared-plot-options/styles.js +0 -48
  162. package/dist/state/hooks.js +0 -549
  163. package/dist/view-config-upgraders.js +0 -525
  164. package/dist/view-config-utils.js +0 -286
  165. package/dist/view-config-utils.test.fixtures.js +0 -765
  166. package/dist/view-config-utils.test.js +0 -66
  167. package/dist/view-config-versions.js +0 -47
  168. package/dist/vitessce-grid-layout/VitessceGridLayout.js +0 -95
  169. package/dist/vitessce-grid-layout/VitessceGridLayout.test.js +0 -40
  170. package/dist/vitessce-grid-layout/layout-utils.js +0 -60
  171. package/dist/vitessce-grid-layout/layout-utils.test.js +0 -146
  172. package/dist/vitessce-grid-utils.js +0 -140
@@ -1,400 +0,0 @@
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
- });
@@ -1,148 +0,0 @@
1
- import { FileType } from '@vitessce/constants-internal';
2
- import { validateOptions, anndataZarrSchema, } from './file-options-schemas';
3
- import { expandMoleculesJson, expandExpressionMatrixZarr, expandRasterJson, expandRasterOmeZarr, expandCellSetsJson, expandCellsJson, expandClustersJson, expandGenesJson, expandAnndataCellsZarr, expandAnndataCellSetsZarr, expandAnndataExpressionMatrixZarr, } from './joint-file-types-legacy';
4
- export function expandAnndataZarr(fileDef) {
5
- validateOptions(anndataZarrSchema, fileDef.options);
6
- const baseFileDef = {
7
- url: fileDef.url,
8
- requestInit: fileDef.requestInit,
9
- coordinationValues: {
10
- ...fileDef.coordinationValues,
11
- obsType: fileDef.coordinationValues?.obsType || 'cell',
12
- featureType: fileDef.coordinationValues?.featureType || 'gene',
13
- featureValueType: fileDef.coordinationValues?.featureValueType || 'expression',
14
- },
15
- };
16
- const { options = {} } = fileDef;
17
- return [
18
- // obsFeatureMatrix
19
- ...(options.obsFeatureMatrix ? [{
20
- ...baseFileDef,
21
- fileType: FileType.OBS_FEATURE_MATRIX_ANNDATA_ZARR,
22
- options: options.obsFeatureMatrix,
23
- coordinationValues: {
24
- obsType: baseFileDef.coordinationValues.obsType,
25
- featureType: baseFileDef.coordinationValues.featureType,
26
- featureValueType: baseFileDef.coordinationValues.featureValueType,
27
- },
28
- }] : []),
29
- // obsSets
30
- ...(options.obsSets ? [{
31
- ...baseFileDef,
32
- fileType: FileType.OBS_SETS_ANNDATA_ZARR,
33
- options: options.obsSets,
34
- coordinationValues: {
35
- obsType: baseFileDef.coordinationValues.obsType,
36
- },
37
- }] : []),
38
- // obsLocations
39
- ...(options.obsLocations ? [{
40
- ...baseFileDef,
41
- fileType: FileType.OBS_LOCATIONS_ANNDATA_ZARR,
42
- options: options.obsLocations,
43
- coordinationValues: {
44
- obsType: baseFileDef.coordinationValues.obsType,
45
- },
46
- }] : []),
47
- // obsSegmentations
48
- ...(options.obsSegmentations ? [{
49
- ...baseFileDef,
50
- fileType: FileType.OBS_SEGMENTATIONS_ANNDATA_ZARR,
51
- options: options.obsSegmentations,
52
- coordinationValues: {
53
- obsType: baseFileDef.coordinationValues.obsType,
54
- },
55
- }] : []),
56
- // obsEmbedding
57
- // eslint-disable-next-line no-nested-ternary
58
- ...(options.obsEmbedding ? (Array.isArray(options.obsEmbedding) ? options.obsEmbedding.map(oe => ({
59
- // obsEmbedding was an array, process each element.
60
- ...baseFileDef,
61
- fileType: FileType.OBS_EMBEDDING_ANNDATA_ZARR,
62
- options: {
63
- path: oe.path,
64
- dims: oe.dims,
65
- },
66
- coordinationValues: {
67
- obsType: baseFileDef.coordinationValues.obsType,
68
- // Move embedding type property out of options and into coordinationValues.
69
- embeddingType: oe.embeddingType,
70
- },
71
- })) : [{
72
- // obsEmbedding was an object.
73
- ...baseFileDef,
74
- fileType: FileType.OBS_EMBEDDING_ANNDATA_ZARR,
75
- options: options.obsEmbedding,
76
- coordinationValues: {
77
- obsType: baseFileDef.coordinationValues.obsType,
78
- embeddingType: baseFileDef.coordinationValues.embeddingType,
79
- },
80
- }]) : []),
81
- // obsLabels
82
- // eslint-disable-next-line no-nested-ternary
83
- ...(options.obsLabels ? (Array.isArray(options.obsLabels) ? options.obsLabels.map(ol => ({
84
- // obsLabels was an array, process each element.
85
- ...baseFileDef,
86
- fileType: FileType.OBS_LABELS_ANNDATA_ZARR,
87
- options: {
88
- path: ol.path,
89
- },
90
- coordinationValues: {
91
- obsType: baseFileDef.coordinationValues.obsType,
92
- // Move obsLabels type property out of options and into coordinationValues.
93
- obsLabelsType: ol.obsLabelsType,
94
- },
95
- })) : [{
96
- // obsLabels was an object.
97
- ...baseFileDef,
98
- fileType: FileType.OBS_LABELS_ANNDATA_ZARR,
99
- options: options.obsLabels,
100
- coordinationValues: {
101
- obsType: baseFileDef.coordinationValues.obsType,
102
- obsLabelsType: baseFileDef.coordinationValues.obsLabelsType,
103
- },
104
- }]) : []),
105
- // featureLabels
106
- // eslint-disable-next-line no-nested-ternary
107
- ...(options.featureLabels ? (Array.isArray(options.featureLabels) ? options.featureLabels.map(fl => ({
108
- // featureLabels was an array, process each element.
109
- ...baseFileDef,
110
- fileType: FileType.FEATURE_LABELS_ANNDATA_ZARR,
111
- options: {
112
- path: fl.path,
113
- },
114
- coordinationValues: {
115
- featureType: baseFileDef.coordinationValues.featureType,
116
- // Move featureLabels type property out of options and into coordinationValues.
117
- featureLabelsType: fl.featureLabelsType,
118
- },
119
- })) : [{
120
- // featureLabels was an object.
121
- ...baseFileDef,
122
- fileType: FileType.FEATURE_LABELS_ANNDATA_ZARR,
123
- options: options.featureLabels,
124
- coordinationValues: {
125
- featureType: baseFileDef.coordinationValues.featureType,
126
- featureLabelsType: baseFileDef.coordinationValues.featureLabelsType,
127
- },
128
- }]) : []),
129
- ];
130
- }
131
- /**
132
- * Built-in joint file type
133
- * expansion functions.
134
- */
135
- export const JOINT_FILE_TYPES = {
136
- [FileType.ANNDATA_ZARR]: expandAnndataZarr,
137
- [FileType.ANNDATA_CELLS_ZARR]: expandAnndataCellsZarr,
138
- [FileType.ANNDATA_CELL_SETS_ZARR]: expandAnndataCellSetsZarr,
139
- [FileType.ANNDATA_EXPRESSION_MATRIX_ZARR]: expandAnndataExpressionMatrixZarr,
140
- [FileType.EXPRESSION_MATRIX_ZARR]: expandExpressionMatrixZarr,
141
- [FileType.RASTER_JSON]: expandRasterJson,
142
- [FileType.RASTER_OME_ZARR]: expandRasterOmeZarr,
143
- [FileType.CELL_SETS_JSON]: expandCellSetsJson,
144
- [FileType.CLUSTERS_JSON]: expandClustersJson,
145
- [FileType.GENES_JSON]: expandGenesJson,
146
- [FileType.CELLS_JSON]: expandCellsJson,
147
- [FileType.MOLECULES_JSON]: expandMoleculesJson,
148
- };
@@ -1,139 +0,0 @@
1
- import { FileType, FILE_TYPE_DATA_TYPE_MAPPING } from '@vitessce/constants-internal';
2
- import { JOINT_FILE_TYPES, expandAnndataZarr, } from './joint-file-types';
3
- describe('src/app/joint-file-types.js', () => {
4
- describe('FileType-to-DataType mappings', () => {
5
- it('every file type is mapped to either a data type or a joint file type expansion function', () => {
6
- const fileTypes = Object.values(FileType).sort();
7
- const mappedFileTypes = [
8
- ...Object.keys(FILE_TYPE_DATA_TYPE_MAPPING),
9
- ...Object.keys(JOINT_FILE_TYPES),
10
- ].sort();
11
- expect(fileTypes.length).toEqual(mappedFileTypes.length);
12
- expect(fileTypes).toEqual(mappedFileTypes);
13
- });
14
- });
15
- describe('expandAnndataZarr', () => {
16
- it('fails to expand when there are no options', () => {
17
- expect(() => expandAnndataZarr({
18
- fileType: 'anndata.zarr',
19
- url: 'http://localhost:8000/anndata.zarr',
20
- })).toThrow();
21
- });
22
- it('expands when there is an obsEmbedding object', () => {
23
- expect(expandAnndataZarr({
24
- fileType: 'anndata.zarr',
25
- url: 'http://localhost:8000/anndata.zarr',
26
- options: {
27
- obsLabels: {
28
- path: 'obs/spot_name',
29
- },
30
- featureLabels: {
31
- path: 'var/gene_symbol',
32
- },
33
- obsEmbedding: {
34
- path: 'obsm/pca',
35
- dims: [2, 4],
36
- },
37
- },
38
- coordinationValues: {
39
- obsType: 'spot',
40
- featureType: 'transcript',
41
- obsLabelsType: 'spotName',
42
- featureLabelsType: 'geneSymbol',
43
- embeddingType: 'PCA',
44
- },
45
- })).toEqual([
46
- {
47
- fileType: 'obsEmbedding.anndata.zarr',
48
- url: 'http://localhost:8000/anndata.zarr',
49
- options: {
50
- path: 'obsm/pca',
51
- dims: [2, 4],
52
- },
53
- coordinationValues: {
54
- obsType: 'spot',
55
- embeddingType: 'PCA',
56
- },
57
- },
58
- {
59
- fileType: 'obsLabels.anndata.zarr',
60
- url: 'http://localhost:8000/anndata.zarr',
61
- options: {
62
- path: 'obs/spot_name',
63
- },
64
- coordinationValues: {
65
- obsType: 'spot',
66
- obsLabelsType: 'spotName',
67
- },
68
- },
69
- {
70
- fileType: 'featureLabels.anndata.zarr',
71
- url: 'http://localhost:8000/anndata.zarr',
72
- options: {
73
- path: 'var/gene_symbol',
74
- },
75
- coordinationValues: {
76
- featureType: 'transcript',
77
- featureLabelsType: 'geneSymbol',
78
- },
79
- },
80
- ]);
81
- });
82
- it('expands when there is an obsEmbedding array of objects', () => {
83
- expect(expandAnndataZarr({
84
- fileType: 'anndata.zarr',
85
- url: 'http://localhost:8000/anndata.zarr',
86
- options: {
87
- obsLocations: {
88
- path: 'obsm/xy',
89
- },
90
- obsEmbedding: [
91
- {
92
- path: 'obsm/pca',
93
- dims: [2, 4],
94
- embeddingType: 'PCA',
95
- },
96
- {
97
- path: 'obsm/umap',
98
- embeddingType: 'UMAP',
99
- },
100
- ],
101
- },
102
- })).toEqual([
103
- {
104
- fileType: 'obsLocations.anndata.zarr',
105
- url: 'http://localhost:8000/anndata.zarr',
106
- options: {
107
- path: 'obsm/xy',
108
- },
109
- coordinationValues: {
110
- obsType: 'cell',
111
- },
112
- },
113
- {
114
- fileType: 'obsEmbedding.anndata.zarr',
115
- url: 'http://localhost:8000/anndata.zarr',
116
- options: {
117
- path: 'obsm/pca',
118
- dims: [2, 4],
119
- },
120
- coordinationValues: {
121
- obsType: 'cell',
122
- embeddingType: 'PCA',
123
- },
124
- },
125
- {
126
- fileType: 'obsEmbedding.anndata.zarr',
127
- url: 'http://localhost:8000/anndata.zarr',
128
- options: {
129
- path: 'obsm/umap',
130
- },
131
- coordinationValues: {
132
- obsType: 'cell',
133
- embeddingType: 'UMAP',
134
- },
135
- },
136
- ]);
137
- });
138
- });
139
- });