@vitessce/vit-s 2.0.3-beta.0 → 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 (184) 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 -117
  108. package/dist/Vitessce.integration.test.js +0 -36
  109. package/dist/Vitessce.js +0 -101
  110. package/dist/VitessceGrid.js +0 -59
  111. package/dist/VitessceGrid.test.js +0 -36
  112. package/dist/Warning.js +0 -45
  113. package/dist/component-registry.js +0 -16
  114. package/dist/data/AbstractLoader.js +0 -35
  115. package/dist/data/LoaderResult.js +0 -7
  116. package/dist/data/loader-registry.js +0 -15
  117. package/dist/data-hook-utils.js +0 -175
  118. package/dist/data-hooks.js +0 -241
  119. package/dist/errors/AbstractLoaderError.js +0 -13
  120. package/dist/errors/DataSourceFetchError.js +0 -13
  121. package/dist/errors/DatasetNotFoundError.js +0 -17
  122. package/dist/errors/LoaderNotFoundError.js +0 -17
  123. package/dist/errors/LoaderValidationError.js +0 -15
  124. package/dist/errors/OptionsValidationError.js +0 -15
  125. package/dist/export-utils.js +0 -70
  126. package/dist/export-utils.test.js +0 -66
  127. package/dist/file-options-schemas-legacy.js +0 -136
  128. package/dist/file-options-schemas-legacy.test.js +0 -126
  129. package/dist/file-options-schemas.js +0 -322
  130. package/dist/file-options-schemas.test.js +0 -23
  131. package/dist/hooks.js +0 -215
  132. package/dist/joint-file-types-legacy.js +0 -278
  133. package/dist/joint-file-types-legacy.test.js +0 -400
  134. package/dist/joint-file-types.js +0 -148
  135. package/dist/joint-file-types.test.js +0 -139
  136. package/dist/loader-registry.js +0 -98
  137. package/dist/plugins.test.fixtures.js +0 -76
  138. package/dist/plugins.test.js +0 -30
  139. package/dist/schemas/PrettyJsonSchema.js +0 -34
  140. package/dist/schemas/config-0.1.0.schema.json +0 -84
  141. package/dist/schemas/config-1.0.0.schema.json +0 -733
  142. package/dist/schemas/config-1.0.1.schema.json +0 -909
  143. package/dist/schemas/config-1.0.10.schema.json +0 -969
  144. package/dist/schemas/config-1.0.11.schema.json +0 -990
  145. package/dist/schemas/config-1.0.12.schema.json +0 -997
  146. package/dist/schemas/config-1.0.13.schema.json +0 -1013
  147. package/dist/schemas/config-1.0.14.schema.json +0 -1048
  148. package/dist/schemas/config-1.0.15.schema.json +0 -1048
  149. package/dist/schemas/config-1.0.15.schema.test.js +0 -22
  150. package/dist/schemas/config-1.0.16.schema.json +0 -1109
  151. package/dist/schemas/config-1.0.16.schema.test.js +0 -22
  152. package/dist/schemas/config-1.0.2.schema.json +0 -910
  153. package/dist/schemas/config-1.0.3.schema.json +0 -910
  154. package/dist/schemas/config-1.0.4.schema.json +0 -949
  155. package/dist/schemas/config-1.0.5.schema.json +0 -949
  156. package/dist/schemas/config-1.0.6.schema.json +0 -949
  157. package/dist/schemas/config-1.0.7.schema.json +0 -949
  158. package/dist/schemas/config-1.0.8.schema.json +0 -965
  159. package/dist/schemas/config-1.0.9.schema.json +0 -965
  160. package/dist/schemas/obs-sets-tabular.schema.js +0 -37
  161. package/dist/schemas/obs-sets.schema.js +0 -194
  162. package/dist/schemas/obsSets.schema.js +0 -195
  163. package/dist/schemas/obsSetsTabular.schema.js +0 -38
  164. package/dist/schemas/raster.schema.js +0 -120
  165. package/dist/schemas/schema.test.js +0 -46
  166. package/dist/schemas-extra.js +0 -3
  167. package/dist/shared-mui/components.js +0 -35
  168. package/dist/shared-mui/container.js +0 -211
  169. package/dist/shared-mui/styles.js +0 -107
  170. package/dist/shared-plot-options/CellColorEncodingOption.js +0 -18
  171. package/dist/shared-plot-options/OptionSelect.js +0 -12
  172. package/dist/shared-plot-options/OptionsContainer.js +0 -12
  173. package/dist/shared-plot-options/styles.js +0 -48
  174. package/dist/state/hooks.js +0 -549
  175. package/dist/view-config-upgraders.js +0 -525
  176. package/dist/view-config-utils.js +0 -286
  177. package/dist/view-config-utils.test.fixtures.js +0 -765
  178. package/dist/view-config-utils.test.js +0 -66
  179. package/dist/view-config-versions.js +0 -47
  180. package/dist/vitessce-grid-layout/VitessceGridLayout.js +0 -95
  181. package/dist/vitessce-grid-layout/VitessceGridLayout.test.js +0 -40
  182. package/dist/vitessce-grid-layout/layout-utils.js +0 -60
  183. package/dist/vitessce-grid-layout/layout-utils.test.js +0 -146
  184. package/dist/vitessce-grid-utils.js +0 -140
@@ -1,525 +0,0 @@
1
- /* eslint-disable camelcase */
2
- import uuidv4 from 'uuid/v4';
3
- import cloneDeep from 'lodash/cloneDeep';
4
- import { getNextScope, capitalize } from '@vitessce/utils';
5
- /**
6
- * A helper function for the `upgrade()` function,
7
- * which helps convert `props.view` (for scatterplot and spatial),
8
- * into new coordination scopes, setting their values
9
- * in the coordination space and returning the new scope mappings.
10
- * This function does mutate the `coordinationSpace` parameter.
11
- * @param {string} prefix The coordination type prefix,
12
- * either 'embedding' or 'spatial'.
13
- * @param {object} view The view prop object containing
14
- * the properties `.target` and `.zoom`.
15
- * @param {object} coordinationSpace The coordination space.
16
- * @returns {object} The new coordination scope names.
17
- */
18
- function upgradeReplaceViewProp(prefix, view, coordinationSpace) {
19
- const prevZScopes = Object.keys(coordinationSpace[`${prefix}Zoom`]);
20
- const prevTXScopes = Object.keys(coordinationSpace[`${prefix}TargetX`]);
21
- const prevTYScopes = Object.keys(coordinationSpace[`${prefix}TargetY`]);
22
- const nextZScope = getNextScope(prevZScopes);
23
- const nextTXScope = getNextScope(prevTXScopes);
24
- const nextTYScope = getNextScope(prevTYScopes);
25
- const { zoom, target: [targetX, targetY] } = view;
26
- // eslint-disable-next-line no-param-reassign
27
- coordinationSpace[`${prefix}Zoom`][nextZScope] = zoom;
28
- // eslint-disable-next-line no-param-reassign
29
- coordinationSpace[`${prefix}TargetX`][nextTXScope] = targetX;
30
- // eslint-disable-next-line no-param-reassign
31
- coordinationSpace[`${prefix}TargetY`][nextTYScope] = targetY;
32
- return {
33
- [`${prefix}Zoom`]: nextZScope,
34
- [`${prefix}TargetX`]: nextTXScope,
35
- [`${prefix}TargetY`]: nextTYScope,
36
- };
37
- }
38
- /**
39
- * Convert an older view config to a newer view config.
40
- * @param {object} config A v0.1.0 "legacy" view config.
41
- * @returns {object} A v1.0.0 "upgraded" view config.
42
- */
43
- export function upgradeFrom0_1_0(config, datasetUid = null) {
44
- const coordinationSpace = {
45
- embeddingType: {},
46
- embeddingZoom: {},
47
- embeddingTargetX: {},
48
- embeddingTargetY: {},
49
- spatialZoom: {},
50
- spatialTargetX: {},
51
- spatialTargetY: {},
52
- };
53
- const layout = [];
54
- config.staticLayout.forEach((componentDef) => {
55
- let newComponentDef = {
56
- ...componentDef,
57
- coordinationScopes: {},
58
- };
59
- if (componentDef.component === 'scatterplot') {
60
- // Need to set up the coordinationSpace
61
- // with embeddingType to replace scatterplot
62
- // component prop "mapping".
63
- if (componentDef.props.mapping) {
64
- coordinationSpace.embeddingType[componentDef.props.mapping] = componentDef.props.mapping;
65
- newComponentDef = {
66
- ...newComponentDef,
67
- coordinationScopes: {
68
- ...newComponentDef.coordinationScopes,
69
- embeddingType: componentDef.props.mapping,
70
- },
71
- };
72
- }
73
- // Need to set up the coordinationSpace
74
- // with embeddingZoom / embeddingTargetX/Y to replace scatterplot
75
- // component prop "view" ({ zoom, target }).
76
- if (componentDef.props.view) {
77
- // Note that the below function does mutate the coordinationSpace param.
78
- const newScopeValues = upgradeReplaceViewProp('embedding', componentDef.props.view, coordinationSpace);
79
- newComponentDef = {
80
- ...newComponentDef,
81
- coordinationScopes: {
82
- ...newComponentDef.coordinationScopes,
83
- ...newScopeValues,
84
- },
85
- };
86
- }
87
- }
88
- if (componentDef.component === 'spatial') {
89
- // Need to set up the coordinationSpace
90
- // with spatialZoom / spatialTargetX/Y to replace spatial
91
- // component prop "view" ({ zoom, target }).
92
- if (componentDef?.props?.view) {
93
- // Note that the below function does mutate the coordinationSpace param.
94
- const newScopeValues = upgradeReplaceViewProp('spatial', componentDef.props.view, coordinationSpace);
95
- newComponentDef = {
96
- ...newComponentDef,
97
- coordinationScopes: {
98
- ...newComponentDef.coordinationScopes,
99
- ...newScopeValues,
100
- },
101
- };
102
- }
103
- }
104
- layout.push(newComponentDef);
105
- });
106
- const lcDef = layout.find(c => c.component === 'layerController');
107
- const spatialDef = layout.find(c => c.component === 'spatial');
108
- if (lcDef && spatialDef.coordinationScopes) {
109
- lcDef.coordinationScopes = spatialDef.coordinationScopes;
110
- }
111
- // Use a random dataset ID when initializing automatically,
112
- // so that it changes with each new v0.1.0 view config.
113
- // However, check if the `datasetUid` parameter was passed,
114
- // which allows for unit testing.
115
- const newDatasetUid = datasetUid || uuidv4();
116
- return {
117
- version: '1.0.1',
118
- name: config.name,
119
- description: config.description,
120
- public: config.public,
121
- datasets: [
122
- {
123
- uid: newDatasetUid,
124
- name: newDatasetUid,
125
- files: config.layers.map(layer => ({
126
- type: layer.type.toLowerCase(),
127
- fileType: layer.fileType,
128
- url: layer.url,
129
- })),
130
- },
131
- ],
132
- initStrategy: 'auto',
133
- coordinationSpace,
134
- layout,
135
- };
136
- }
137
- export function upgradeFrom1_0_0(config) {
138
- const newConfig = cloneDeep(config);
139
- const { coordinationSpace } = newConfig;
140
- function replaceLayerType(layerType) {
141
- // Layer type could be one of a few things, bitmask or raster at the moment.
142
- const isRaster = layerType === 'raster';
143
- coordinationSpace[`spatial${capitalize(layerType)}Layer${isRaster ? 's' : ''}`] = {};
144
- Object.entries(coordinationSpace.spatialLayers).forEach(([scope, layers]) => {
145
- if (Array.isArray(layers) && layers.find(layer => layer.type === layerType)) {
146
- const typedLayers = layers
147
- .filter(layer => layer.type === layerType)
148
- .map((layer) => {
149
- const newLayer = { ...layer };
150
- delete newLayer.type;
151
- return newLayer;
152
- });
153
- coordinationSpace[`spatial${capitalize(layerType)}Layer${isRaster ? 's' : ''}`][scope] = isRaster ? typedLayers : typedLayers[0];
154
- }
155
- else {
156
- coordinationSpace[`spatial${capitalize(layerType)}Layer${isRaster ? 's' : ''}`][scope] = null;
157
- }
158
- });
159
- }
160
- if (coordinationSpace.spatialLayers) {
161
- replaceLayerType('raster');
162
- replaceLayerType('cells');
163
- replaceLayerType('molecules');
164
- replaceLayerType('neighborhoods');
165
- delete coordinationSpace.spatialLayers;
166
- }
167
- const layout = newConfig.layout.map((component) => {
168
- const newComponent = { ...component };
169
- function replaceCoordinationScope(layerType) {
170
- const isRaster = layerType === 'raster';
171
- if (['spatial', 'layerController'].includes(newComponent.component)
172
- || (newComponent.component === 'description' && isRaster)) {
173
- newComponent.coordinationScopes[`spatial${capitalize(layerType)}Layer${isRaster ? 's' : ''}`] = newComponent
174
- .coordinationScopes.spatialLayers;
175
- }
176
- }
177
- if (newComponent.coordinationScopes && newComponent.coordinationScopes.spatialLayers) {
178
- replaceCoordinationScope('raster');
179
- replaceCoordinationScope('cells');
180
- replaceCoordinationScope('molecules');
181
- replaceCoordinationScope('neighborhoods');
182
- delete newComponent.coordinationScopes.spatialLayers;
183
- }
184
- return newComponent;
185
- });
186
- return {
187
- ...newConfig,
188
- coordinationSpace,
189
- layout,
190
- version: '1.0.1',
191
- };
192
- }
193
- export function upgradeFrom1_0_1(config) {
194
- // Need to add the globalDisable3d prop to any layer controller views,
195
- // to match the previous lack of 3D auto-detection behavior.
196
- const layout = config.layout.map((component) => {
197
- const newComponent = { ...component };
198
- if (newComponent.component === 'layerController') {
199
- newComponent.props = {
200
- ...newComponent.props,
201
- globalDisable3d: true,
202
- };
203
- }
204
- return newComponent;
205
- });
206
- // Enforce bitmask or raster as spatial raster layer type, defaulting
207
- // to raster layer if it is not one of bitmask or raster from the old config.
208
- const newConfig = cloneDeep(config);
209
- Object.keys((newConfig?.coordinationSpace?.spatialRasterLayers || {})).forEach((key) => {
210
- if (newConfig.coordinationSpace.spatialRasterLayers[key]) {
211
- newConfig.coordinationSpace.spatialRasterLayers[key].forEach((layer, index) => {
212
- newConfig.coordinationSpace.spatialRasterLayers[key][index].type = ['bitmask', 'raster'].includes(layer.type) ? layer.type : 'raster';
213
- });
214
- }
215
- });
216
- return {
217
- ...newConfig,
218
- layout,
219
- version: '1.0.2',
220
- };
221
- }
222
- export function upgradeFrom1_0_2(config) {
223
- // Need to add the globalDisable3d prop to any layer controller views,
224
- // to match the previous lack of 3D auto-detection behavior.
225
- const layout = config.layout.map((component) => {
226
- const newComponent = { ...component };
227
- if (newComponent.component === 'layerController') {
228
- newComponent.props = {
229
- ...newComponent.props,
230
- disableChannelsIfRgbDetected: true,
231
- };
232
- }
233
- return newComponent;
234
- });
235
- // Enforce bitmask or raster as spatial raster layer type, defaulting
236
- // to raster layer if it is not one of bitmask or raster from the old config.
237
- const newConfig = cloneDeep(config);
238
- return {
239
- ...newConfig,
240
- layout,
241
- version: '1.0.3',
242
- };
243
- }
244
- export function upgradeFrom1_0_3(config) {
245
- const newConfig = cloneDeep(config);
246
- return {
247
- ...newConfig,
248
- version: '1.0.4',
249
- };
250
- }
251
- // Added in version 1.0.5:
252
- // - Support for an array of strings in the setName property within options array items
253
- // for the anndata-cell-sets.zarr file type.
254
- export function upgradeFrom1_0_4(config) {
255
- const newConfig = cloneDeep(config);
256
- return {
257
- ...newConfig,
258
- version: '1.0.5',
259
- };
260
- }
261
- // Added in version 1.0.6:
262
- // - Support for the scoreName property within options array items
263
- // for the anndata-cell-sets.zarr file type.
264
- export function upgradeFrom1_0_5(config) {
265
- const newConfig = cloneDeep(config);
266
- return {
267
- ...newConfig,
268
- version: '1.0.6',
269
- };
270
- }
271
- // Added in version 1.0.7:
272
- // - Support for aliasing the gene identifiers using a different var dataframe column
273
- // via a new `geneAlias` option for the `anndata-expression-matrix.zarr` fileType.
274
- export function upgradeFrom1_0_6(config) {
275
- const newConfig = cloneDeep(config);
276
- return {
277
- ...newConfig,
278
- version: '1.0.7',
279
- };
280
- }
281
- // Added in version 1.0.8:
282
- // - Support for multiple `dataset` coordination scopes and
283
- // dataset-specific coordination scope mappings for all
284
- // other coordination types.
285
- export function upgradeFrom1_0_7(config) {
286
- const newConfig = cloneDeep(config);
287
- return {
288
- ...newConfig,
289
- version: '1.0.8',
290
- };
291
- }
292
- // Added in version 1.0.9:
293
- // - Support for plugin coordination types.
294
- export function upgradeFrom1_0_8(config) {
295
- const newConfig = cloneDeep(config);
296
- return {
297
- ...newConfig,
298
- version: '1.0.9',
299
- };
300
- }
301
- // Added in version 1.0.10:
302
- // - Support for the optional 'uid' property for views.
303
- export function upgradeFrom1_0_9(config) {
304
- const newConfig = cloneDeep(config);
305
- return {
306
- ...newConfig,
307
- version: '1.0.10',
308
- };
309
- }
310
- // Added in version 1.0.11:
311
- // - Changes to spatial layer coordination type names.
312
- // - Cell -> Obs, Gene -> Feature in coordination type names.
313
- export function upgradeFrom1_0_10(config) {
314
- const coordinationSpace = { ...config.coordinationSpace };
315
- const scopeAnalogies = {
316
- // Spatial layer types
317
- spatialRasterLayers: 'spatialImageLayer',
318
- spatialCellsLayer: 'spatialSegmentationLayer',
319
- spatialMoleculesLayer: 'spatialPointLayer',
320
- spatialNeighborhoodsLayer: 'spatialNeighborhoodLayer',
321
- // Other types
322
- cellFilter: 'obsFilter',
323
- cellHighlight: 'obsHighlight',
324
- cellSelection: 'obsSelection',
325
- cellSetSelection: 'obsSetSelection',
326
- cellSetHighlight: 'obsSetHighlight',
327
- cellSetColor: 'obsSetColor',
328
- geneFilter: 'featureFilter',
329
- geneHighlight: 'featureHighlight',
330
- geneSelection: 'featureSelection',
331
- geneExpressionColormap: 'featureValueColormap',
332
- geneExpressionColormapRange: 'featureValueColormapRange',
333
- cellColorEncoding: 'obsColorEncoding',
334
- additionalCellSets: 'additionalObsSets',
335
- embeddingCellSetPolygonsVisible: 'embeddingObsSetPolygonsVisible',
336
- embeddingCellSetLabelsVisible: 'embeddingObsSetLabelsVisible',
337
- embeddingCellSetLabelSize: 'embeddingObsSetLabelSize',
338
- embeddingCellRadius: 'embeddingObsRadius',
339
- embeddingCellRadiusMode: 'embeddingObsRadiusMode',
340
- embeddingCellOpacity: 'embeddingObsOpacity',
341
- embeddingCellOpacityMode: 'embeddingObsOpacityMode',
342
- };
343
- Object.entries(scopeAnalogies).forEach(([oldKey, newKey]) => {
344
- if (coordinationSpace[oldKey]) {
345
- coordinationSpace[newKey] = coordinationSpace[oldKey];
346
- delete coordinationSpace[oldKey];
347
- }
348
- });
349
- const layout = config.layout.map((component) => {
350
- const newComponent = { ...component };
351
- const { coordinationScopes = {} } = newComponent;
352
- Object.entries(scopeAnalogies).forEach(([oldKey, newKey]) => {
353
- if (coordinationScopes[oldKey]) {
354
- coordinationScopes[newKey] = coordinationScopes[oldKey];
355
- delete coordinationScopes[oldKey];
356
- }
357
- });
358
- return {
359
- ...newComponent,
360
- coordinationScopes,
361
- };
362
- });
363
- return {
364
- ...config,
365
- coordinationSpace,
366
- layout,
367
- version: '1.0.11',
368
- };
369
- }
370
- // Added in version 1.0.12:
371
- // - Added a fileType-to-dataType mapping
372
- // so that datasets[].files[].type is no longer required.
373
- export function upgradeFrom1_0_11(config) {
374
- const newConfig = cloneDeep(config);
375
- const { datasets, coordinationSpace, } = newConfig;
376
- if (coordinationSpace.embeddingType) {
377
- // This array may contain more embedding types than
378
- // the cells.json file actually contains, but the tradeoff is that
379
- // we do not have to load the cells.json file to double check what
380
- // embedding types are actually present. CellsJsonAsObsEmbedding
381
- // will just load the embedding as null if it is not present.
382
- const embeddingTypes = Object.values(coordinationSpace.embeddingType);
383
- datasets.forEach((dataset, i) => {
384
- const { files } = dataset;
385
- files.forEach((fileDef, j) => {
386
- const { fileType } = fileDef;
387
- if (fileType === 'cells.json') {
388
- datasets[i].files[j].options = {
389
- embeddingTypes,
390
- };
391
- }
392
- });
393
- });
394
- }
395
- return {
396
- ...newConfig,
397
- datasets,
398
- version: '1.0.12',
399
- };
400
- }
401
- // Added in version 1.0.13:
402
- // - Adds the property `coordinationValues` for
403
- // view config file definitions but is not yet
404
- // used to do file matching/lookups.
405
- export function upgradeFrom1_0_12(config) {
406
- const newConfig = cloneDeep(config);
407
- // Set up coordination scopes for anndata-cells.zarr's options.factors
408
- // in the coordination space, and create a new coordinationScopes.obsLabelsType array
409
- // for each component in the layout.
410
- const { datasets, coordinationSpace, layout } = newConfig;
411
- const datasetUidToObsLabelsTypeScopes = {};
412
- datasets.forEach((dataset) => {
413
- const { files, uid } = dataset;
414
- files.forEach((fileDef) => {
415
- const { fileType, options = {} } = fileDef;
416
- if (fileType === 'anndata-cells.zarr') {
417
- const { factors } = options;
418
- if (factors) {
419
- const obsLabelsTypeScopes = [];
420
- factors.forEach((olt) => {
421
- const nextScope = getNextScope(Object.keys(coordinationSpace?.obsLabelsType || {}));
422
- coordinationSpace.obsLabelsType = {
423
- ...coordinationSpace.obsLabelsType,
424
- // Need to remove the obs/ prefix.
425
- [nextScope]: olt.split('/').at(-1),
426
- };
427
- obsLabelsTypeScopes.push(nextScope);
428
- });
429
- datasetUidToObsLabelsTypeScopes[uid] = obsLabelsTypeScopes;
430
- }
431
- }
432
- });
433
- });
434
- function getDatasetUidForView(viewDef) {
435
- if (viewDef.coordinationScopes?.dataset) {
436
- return coordinationSpace.dataset[viewDef.coordinationScopes.dataset];
437
- }
438
- if (datasets.length > 0) {
439
- return datasets[0].uid;
440
- }
441
- return null;
442
- }
443
- const newLayout = layout.map((viewDef) => {
444
- const viewDatasetUid = getDatasetUidForView(datasets, coordinationSpace, viewDef);
445
- const datasetObsLabelsTypeScopes = datasetUidToObsLabelsTypeScopes[viewDatasetUid];
446
- if (datasetObsLabelsTypeScopes) {
447
- return {
448
- ...viewDef,
449
- coordinationScopes: {
450
- ...viewDef.coordinationScopes,
451
- obsLabelsType: datasetObsLabelsTypeScopes,
452
- },
453
- };
454
- }
455
- return viewDef;
456
- });
457
- return {
458
- ...newConfig,
459
- coordinationSpace,
460
- layout: newLayout,
461
- version: '1.0.13',
462
- };
463
- }
464
- // Added in version 1.0.14:
465
- // - Adds the coordination types
466
- // gatingFeatureSelectionX,
467
- // gatingFeatureSelectionY,
468
- // featureValueTransformCoefficient.
469
- export function upgradeFrom1_0_13(config) {
470
- const newConfig = cloneDeep(config);
471
- return {
472
- ...newConfig,
473
- version: '1.0.14',
474
- };
475
- }
476
- // Added in version 1.0.15:
477
- // - Changes the following view names:
478
- // - genes -> featureList
479
- // - cellSets -> obsSets
480
- // - cellSetSizes -> obsSetSizes
481
- // - cellSetExpression -> obsSetFeatureValueDistribution
482
- // - expressionHistogram -> featureValueHistogram
483
- // - Deprecates the props:
484
- // - variablesLabelOverride
485
- // - observationsLabelOverride
486
- export function upgradeFrom1_0_14(config) {
487
- const newConfig = cloneDeep(config);
488
- const { layout } = newConfig;
489
- const viewTypeAnalogies = {
490
- genes: 'featureList',
491
- cellSets: 'obsSets',
492
- cellSetSizes: 'obsSetSizes',
493
- cellSetExpression: 'obsSetFeatureValueDistribution',
494
- expressionHistogram: 'featureValueHistogram',
495
- };
496
- // Handle the view type renaming.
497
- const newLayout = layout.map((viewDef) => {
498
- // Replace the old component name with the new one.
499
- if (viewTypeAnalogies[viewDef.component]) {
500
- return {
501
- ...viewDef,
502
- component: viewTypeAnalogies[viewDef.component],
503
- };
504
- }
505
- return viewDef;
506
- });
507
- const propAnalogies = {
508
- variablesLabelOverride: 'featureType',
509
- observationsLabelOverride: 'obsType',
510
- };
511
- // Warn about the prop usage.
512
- newLayout.forEach((viewDef) => {
513
- // Iterate over each old prop key.
514
- Object.entries(propAnalogies).forEach(([oldProp, newType]) => {
515
- if (viewDef.props?.[oldProp]) {
516
- console.warn(`Warning: the '${oldProp}' prop on the ${viewDef.component} view is deprecated. Please use the '${newType}' coordination type instead.`);
517
- }
518
- });
519
- });
520
- return {
521
- ...newConfig,
522
- version: '1.0.15',
523
- layout: newLayout,
524
- };
525
- }