@vitessce/vit-s 2.0.3 → 3.0.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 (216) hide show
  1. package/dist/index.js +41348 -0
  2. package/dist-tsc/CallbackPublisher.d.ts +18 -0
  3. package/dist-tsc/CallbackPublisher.d.ts.map +1 -0
  4. package/dist-tsc/CallbackPublisher.js +62 -0
  5. package/dist-tsc/LoadingIndicator.d.ts +2 -0
  6. package/dist-tsc/LoadingIndicator.d.ts.map +1 -0
  7. package/dist-tsc/LoadingIndicator.js +26 -0
  8. package/dist-tsc/TitleInfo.d.ts +2 -0
  9. package/dist-tsc/TitleInfo.d.ts.map +1 -0
  10. package/dist-tsc/TitleInfo.js +74 -0
  11. package/dist-tsc/VitS.d.ts +45 -0
  12. package/dist-tsc/VitS.d.ts.map +1 -0
  13. package/dist-tsc/VitS.js +119 -0
  14. package/dist-tsc/VitessceGrid.d.ts +23 -0
  15. package/dist-tsc/VitessceGrid.d.ts.map +1 -0
  16. package/dist-tsc/VitessceGrid.js +60 -0
  17. package/dist-tsc/VitessceGrid.test.d.ts +2 -0
  18. package/dist-tsc/VitessceGrid.test.d.ts.map +1 -0
  19. package/dist-tsc/VitessceGrid.test.js +40 -0
  20. package/dist-tsc/Warning.d.ts +2 -0
  21. package/dist-tsc/Warning.d.ts.map +1 -0
  22. package/dist-tsc/Warning.js +45 -0
  23. package/dist-tsc/classNames.d.ts +8 -0
  24. package/dist-tsc/classNames.d.ts.map +1 -0
  25. package/dist-tsc/classNames.js +8 -0
  26. package/dist-tsc/data/AbstractLoader.d.ts +22 -0
  27. package/dist-tsc/data/AbstractLoader.d.ts.map +1 -0
  28. package/dist-tsc/data/AbstractLoader.js +18 -0
  29. package/dist-tsc/data/AbstractTwoStepLoader.d.ts +6 -0
  30. package/dist-tsc/data/AbstractTwoStepLoader.d.ts.map +1 -0
  31. package/dist-tsc/data/AbstractTwoStepLoader.js +7 -0
  32. package/dist-tsc/data/LoaderResult.d.ts +7 -0
  33. package/dist-tsc/data/LoaderResult.d.ts.map +1 -0
  34. package/dist-tsc/data/LoaderResult.js +7 -0
  35. package/dist-tsc/data/index.d.ts +4 -0
  36. package/dist-tsc/data/index.d.ts.map +1 -0
  37. package/dist-tsc/data/index.js +3 -0
  38. package/dist-tsc/data/loader-registry.d.ts +9 -0
  39. package/dist-tsc/data/loader-registry.d.ts.map +1 -0
  40. package/dist-tsc/data/loader-registry.js +27 -0
  41. package/dist-tsc/data-hook-utils.d.ts +69 -0
  42. package/dist-tsc/data-hook-utils.d.ts.map +1 -0
  43. package/dist-tsc/data-hook-utils.js +173 -0
  44. package/dist-tsc/data-hooks.d.ts +77 -0
  45. package/dist-tsc/data-hooks.d.ts.map +1 -0
  46. package/dist-tsc/data-hooks.js +241 -0
  47. package/dist-tsc/errors/AbstractLoaderError.d.ts +10 -0
  48. package/dist-tsc/errors/AbstractLoaderError.d.ts.map +1 -0
  49. package/dist-tsc/errors/AbstractLoaderError.js +13 -0
  50. package/dist-tsc/errors/DataSourceFetchError.d.ts +8 -0
  51. package/dist-tsc/errors/DataSourceFetchError.d.ts.map +1 -0
  52. package/dist-tsc/errors/DataSourceFetchError.js +13 -0
  53. package/dist-tsc/errors/DatasetNotFoundError.d.ts +6 -0
  54. package/dist-tsc/errors/DatasetNotFoundError.d.ts.map +1 -0
  55. package/dist-tsc/errors/DatasetNotFoundError.js +17 -0
  56. package/dist-tsc/errors/LoaderNotFoundError.d.ts +10 -0
  57. package/dist-tsc/errors/LoaderNotFoundError.d.ts.map +1 -0
  58. package/dist-tsc/errors/LoaderNotFoundError.js +17 -0
  59. package/dist-tsc/errors/LoaderValidationError.d.ts +10 -0
  60. package/dist-tsc/errors/LoaderValidationError.d.ts.map +1 -0
  61. package/dist-tsc/errors/LoaderValidationError.js +15 -0
  62. package/dist-tsc/errors/index.d.ts +6 -0
  63. package/dist-tsc/errors/index.d.ts.map +1 -0
  64. package/dist-tsc/errors/index.js +5 -0
  65. package/dist-tsc/hooks.d.ts +80 -0
  66. package/dist-tsc/hooks.d.ts.map +1 -0
  67. package/dist-tsc/hooks.js +271 -0
  68. package/dist-tsc/index.d.ts +11 -0
  69. package/dist-tsc/index.d.ts.map +1 -0
  70. package/dist-tsc/index.js +10 -17
  71. package/dist-tsc/plugins.test.fixtures.d.ts +61 -0
  72. package/dist-tsc/plugins.test.fixtures.d.ts.map +1 -0
  73. package/dist-tsc/plugins.test.fixtures.js +76 -0
  74. package/dist-tsc/schemas/config-0.1.0.schema.json +84 -0
  75. package/dist-tsc/schemas/config-1.0.0.schema.json +733 -0
  76. package/dist-tsc/schemas/config-1.0.1.schema.json +909 -0
  77. package/dist-tsc/schemas/config-1.0.10.schema.json +969 -0
  78. package/dist-tsc/schemas/config-1.0.11.schema.json +990 -0
  79. package/dist-tsc/schemas/config-1.0.12.schema.json +997 -0
  80. package/dist-tsc/schemas/config-1.0.13.schema.json +1013 -0
  81. package/dist-tsc/schemas/config-1.0.14.schema.json +1048 -0
  82. package/dist-tsc/schemas/config-1.0.15.schema.json +1048 -0
  83. package/dist-tsc/schemas/config-1.0.16.schema.json +1089 -0
  84. package/dist-tsc/schemas/config-1.0.2.schema.json +910 -0
  85. package/dist-tsc/schemas/config-1.0.3.schema.json +910 -0
  86. package/dist-tsc/schemas/config-1.0.4.schema.json +949 -0
  87. package/dist-tsc/schemas/config-1.0.5.schema.json +949 -0
  88. package/dist-tsc/schemas/config-1.0.6.schema.json +949 -0
  89. package/dist-tsc/schemas/config-1.0.7.schema.json +949 -0
  90. package/dist-tsc/schemas/config-1.0.8.schema.json +965 -0
  91. package/dist-tsc/schemas/config-1.0.9.schema.json +965 -0
  92. package/dist-tsc/schemas/obsSets.schema.d.ts +179 -0
  93. package/dist-tsc/schemas/obsSets.schema.d.ts.map +1 -0
  94. package/dist-tsc/schemas/obsSets.schema.js +195 -0
  95. package/dist-tsc/schemas/obsSetsTabular.schema.d.ts +57 -0
  96. package/dist-tsc/schemas/obsSetsTabular.schema.d.ts.map +1 -0
  97. package/dist-tsc/schemas/obsSetsTabular.schema.js +38 -0
  98. package/dist-tsc/schemas/raster.schema.d.ts +239 -0
  99. package/dist-tsc/schemas/raster.schema.d.ts.map +1 -0
  100. package/dist-tsc/schemas/raster.schema.js +120 -0
  101. package/dist-tsc/shared-mui/components.d.ts +2 -0
  102. package/dist-tsc/shared-mui/components.d.ts.map +1 -0
  103. package/dist-tsc/shared-mui/components.js +29 -0
  104. package/dist-tsc/shared-mui/container.d.ts +2 -0
  105. package/dist-tsc/shared-mui/container.d.ts.map +1 -0
  106. package/dist-tsc/shared-mui/container.js +211 -0
  107. package/dist-tsc/shared-mui/styles.d.ts +5 -0
  108. package/dist-tsc/shared-mui/styles.d.ts.map +1 -0
  109. package/dist-tsc/shared-mui/styles.js +109 -0
  110. package/dist-tsc/shared-plot-options/CellColorEncodingOption.d.ts +2 -0
  111. package/dist-tsc/shared-plot-options/CellColorEncodingOption.d.ts.map +1 -0
  112. package/dist-tsc/shared-plot-options/CellColorEncodingOption.js +17 -0
  113. package/dist-tsc/shared-plot-options/OptionSelect.d.ts +2 -0
  114. package/dist-tsc/shared-plot-options/OptionSelect.d.ts.map +1 -0
  115. package/dist-tsc/shared-plot-options/OptionSelect.js +12 -0
  116. package/dist-tsc/shared-plot-options/OptionsContainer.d.ts +2 -0
  117. package/dist-tsc/shared-plot-options/OptionsContainer.d.ts.map +1 -0
  118. package/dist-tsc/shared-plot-options/OptionsContainer.js +9 -0
  119. package/dist-tsc/shared-plot-options/index.d.ts +5 -0
  120. package/dist-tsc/shared-plot-options/index.d.ts.map +1 -0
  121. package/dist-tsc/shared-plot-options/index.js +4 -0
  122. package/dist-tsc/shared-plot-options/styles.d.ts +2 -0
  123. package/dist-tsc/shared-plot-options/styles.d.ts.map +1 -0
  124. package/dist-tsc/shared-plot-options/styles.js +48 -0
  125. package/dist-tsc/state/hooks.d.ts +216 -0
  126. package/dist-tsc/state/hooks.d.ts.map +1 -0
  127. package/dist-tsc/state/hooks.js +575 -0
  128. package/dist-tsc/title-styles.d.ts +2 -0
  129. package/dist-tsc/title-styles.d.ts.map +1 -0
  130. package/dist-tsc/title-styles.js +72 -0
  131. package/dist-tsc/view-config-utils.d.ts +30 -0
  132. package/dist-tsc/view-config-utils.d.ts.map +1 -0
  133. package/dist-tsc/view-config-utils.js +234 -0
  134. package/dist-tsc/view-config-utils.test.d.ts +2 -0
  135. package/dist-tsc/view-config-utils.test.d.ts.map +1 -0
  136. package/dist-tsc/view-config-utils.test.fixtures.d.ts +1049 -0
  137. package/dist-tsc/view-config-utils.test.fixtures.d.ts.map +1 -0
  138. package/dist-tsc/view-config-utils.test.fixtures.js +883 -0
  139. package/dist-tsc/view-config-utils.test.js +209 -0
  140. package/dist-tsc/vitessce-grid-layout/VitessceGridLayout.d.ts +8 -0
  141. package/dist-tsc/vitessce-grid-layout/VitessceGridLayout.d.ts.map +1 -0
  142. package/dist-tsc/vitessce-grid-layout/VitessceGridLayout.js +114 -0
  143. package/dist-tsc/vitessce-grid-layout/VitessceGridLayout.test.d.ts +2 -0
  144. package/dist-tsc/vitessce-grid-layout/VitessceGridLayout.test.d.ts.map +1 -0
  145. package/dist-tsc/vitessce-grid-layout/VitessceGridLayout.test.js +48 -0
  146. package/dist-tsc/vitessce-grid-layout/index.d.ts +2 -0
  147. package/dist-tsc/vitessce-grid-layout/index.d.ts.map +1 -0
  148. package/dist-tsc/vitessce-grid-layout/index.js +1 -0
  149. package/dist-tsc/vitessce-grid-layout/layout-utils.d.ts +15 -0
  150. package/dist-tsc/vitessce-grid-layout/layout-utils.d.ts.map +1 -0
  151. package/dist-tsc/vitessce-grid-layout/layout-utils.js +61 -0
  152. package/dist-tsc/vitessce-grid-layout/layout-utils.test.d.ts +2 -0
  153. package/dist-tsc/vitessce-grid-layout/layout-utils.test.d.ts.map +1 -0
  154. package/dist-tsc/vitessce-grid-layout/layout-utils.test.js +148 -0
  155. package/dist-tsc/vitessce-grid-utils.d.ts +13 -0
  156. package/dist-tsc/vitessce-grid-utils.d.ts.map +1 -0
  157. package/dist-tsc/vitessce-grid-utils.js +141 -0
  158. package/package.json +23 -10
  159. package/src/CallbackPublisher.js +7 -11
  160. package/src/LoadingIndicator.js +1 -2
  161. package/src/TitleInfo.js +12 -85
  162. package/src/VitS.js +72 -50
  163. package/src/VitessceGrid.js +21 -13
  164. package/src/VitessceGrid.test.jsx +16 -7
  165. package/src/Warning.js +2 -2
  166. package/src/data/AbstractLoader.js +2 -25
  167. package/src/data/AbstractTwoStepLoader.js +1 -1
  168. package/src/data/index.js +3 -3
  169. package/src/data/loader-registry.js +22 -13
  170. package/src/data-hook-utils.js +4 -6
  171. package/src/data-hooks.js +4 -4
  172. package/src/errors/DataSourceFetchError.js +1 -1
  173. package/src/errors/DatasetNotFoundError.js +1 -1
  174. package/src/errors/LoaderNotFoundError.js +1 -1
  175. package/src/errors/LoaderValidationError.js +1 -1
  176. package/src/errors/index.js +5 -6
  177. package/src/hooks.js +70 -5
  178. package/src/index.js +21 -46
  179. package/src/schemas/config-1.0.16.schema.json +21 -1
  180. package/src/shared-mui/components.js +10 -8
  181. package/src/shared-mui/container.js +1 -1
  182. package/src/shared-mui/styles.js +5 -2
  183. package/src/shared-plot-options/CellColorEncodingOption.js +3 -4
  184. package/src/shared-plot-options/OptionSelect.js +2 -2
  185. package/src/shared-plot-options/OptionsContainer.js +2 -5
  186. package/src/shared-plot-options/index.js +4 -4
  187. package/src/shared-plot-options/styles.js +1 -1
  188. package/src/state/hooks.js +10 -3
  189. package/src/title-styles.js +73 -0
  190. package/src/view-config-utils.js +46 -98
  191. package/src/view-config-utils.test.jsx +222 -0
  192. package/src/vitessce-grid-layout/VitessceGridLayout.js +51 -30
  193. package/src/vitessce-grid-layout/VitessceGridLayout.test.jsx +17 -9
  194. package/src/vitessce-grid-layout/index.js +1 -1
  195. package/src/vitessce-grid-layout/layout-utils.js +1 -1
  196. package/src/vitessce-grid-layout/layout-utils.test.js +1 -1
  197. package/src/vitessce-grid-utils.js +27 -15
  198. package/dist/index.mjs +0 -84801
  199. package/src/component-registry.js +0 -21
  200. package/src/errors/OptionsValidationError.js +0 -25
  201. package/src/file-options-schemas-legacy.js +0 -139
  202. package/src/file-options-schemas-legacy.test.js +0 -138
  203. package/src/file-options-schemas.js +0 -327
  204. package/src/file-options-schemas.test.js +0 -26
  205. package/src/joint-file-types-legacy.js +0 -298
  206. package/src/joint-file-types-legacy.test.js +0 -412
  207. package/src/joint-file-types.js +0 -171
  208. package/src/joint-file-types.test.js +0 -144
  209. package/src/json-schemas.js +0 -9
  210. package/src/plugins.js +0 -186
  211. package/src/plugins.test.js +0 -42
  212. package/src/schemas/config-1.0.16.schema.test.js +0 -32
  213. package/src/schemas/schema.test-old.js +0 -49
  214. package/src/view-config-upgraders.js +0 -628
  215. package/src/view-config-utils.test.js +0 -95
  216. package/src/view-config-versions.js +0 -68
@@ -1,21 +0,0 @@
1
- import { getPluginViewType, getPluginViewTypes } from './plugins';
2
-
3
- // TODO(monorepo): this code can be simplified
4
- const registry = {};
5
-
6
- export function getComponent(name) {
7
- let component = registry[name];
8
- if (component === undefined) {
9
- component = getPluginViewType(name);
10
- if (component === undefined) {
11
- throw new Error(
12
- `Could not find definition for "${name}" in the core registry nor the plugin registry.`,
13
- );
14
- }
15
- }
16
- return component;
17
- }
18
-
19
- export function getViewTypes() {
20
- return [...Object.keys(registry), ...getPluginViewTypes()];
21
- }
@@ -1,25 +0,0 @@
1
- import AbstractLoaderError from './AbstractLoaderError';
2
-
3
- export default class OptionsValidationError extends AbstractLoaderError {
4
- constructor(fileType, url, options, reason) {
5
- super(`Error while validating file definition options: ${fileType} from ${url}.`);
6
- this.name = 'OptionsValidationError';
7
-
8
- this.fileType = fileType;
9
- this.url = url;
10
- this.options = options;
11
- this.reason = reason;
12
- }
13
-
14
- warnInConsole() {
15
- const {
16
- options, reason,
17
- } = this;
18
- console.warn(
19
- 'Received options\n',
20
- JSON.stringify(options, null, 2),
21
- 'JSON schema validation failure reason\n',
22
- JSON.stringify(reason, null, 2),
23
- );
24
- }
25
- }
@@ -1,139 +0,0 @@
1
- export const cellsJsonSchema = {
2
- $schema: 'http://json-schema.org/draft-07/schema#',
3
- $id: 'https://github.com/vitessce/vitessce/#cells-json-options',
4
- title: 'cells.json options',
5
- oneOf: [
6
- { type: 'null' },
7
- {
8
- type: 'object',
9
- additionalProperties: false,
10
- required: [],
11
- properties: {
12
- obsLabelsTypes: {
13
- type: 'array',
14
- items: { type: 'string' },
15
- },
16
- embeddingTypes: {
17
- type: 'array',
18
- items: { type: 'string' },
19
- },
20
- },
21
- },
22
- ],
23
- };
24
-
25
- export const anndataCellsZarrSchema = {
26
- $schema: 'http://json-schema.org/draft-07/schema#',
27
- $id: 'https://github.com/vitessce/vitessce/#anndata-cells-zarr-options',
28
- title: 'anndata-cells.zarr options',
29
- type: 'object',
30
- minProperties: 1,
31
- additionalProperties: false,
32
- required: [],
33
- properties: {
34
- xy: {
35
- type: 'string',
36
- description: "The location in the AnnData store of cell centroids, like 'obsm/X_centroids.'",
37
- },
38
- poly: {
39
- type: 'string',
40
- description: "The location in the AnnData store of cell polygon outlines, like 'obsm/X_polygons.'",
41
- },
42
- factors: {
43
- type: 'array',
44
- description: "List of locations in the AnnData store of cell sets, like 'obs/louvain'",
45
- items: {
46
- type: 'string',
47
- },
48
- },
49
- mappings: {
50
- patternProperties: {
51
- '.': {
52
- type: 'object',
53
- description: "An object containing key-values for mappings like { UMAP: { key: 'obsm/X_umap', dims: [0, 1] } }.",
54
- additionalProperties: false,
55
- required: ['key'],
56
- properties: {
57
- key: {
58
- type: 'string',
59
- description: "Where to look in the AnnData store for this mapping, like 'obsm/X_umap.'",
60
- },
61
- dims: {
62
- type: 'array',
63
- description: 'Which indices of the obsm object to take for a scatterplot, allowing for, for example, different PCs from obsm/X_pca',
64
- minItems: 2,
65
- maxItems: 2,
66
- items: { type: 'number' },
67
- },
68
- },
69
- },
70
- },
71
- },
72
- },
73
- };
74
-
75
- export const anndataCellSetsZarrSchema = {
76
- $schema: 'http://json-schema.org/draft-07/schema#',
77
- $id: 'https://github.com/vitessce/vitessce/#anndata-cell-sets-zarr-options',
78
- title: 'anndata-cell-sets.zarr options',
79
- type: 'array',
80
- items: {
81
- type: 'object',
82
- additionalProperties: false,
83
- required: ['groupName', 'setName'],
84
- properties: {
85
- groupName: {
86
- type: 'string',
87
- description: "The display name for the set, like 'Cell Type' or 'Louvain.'",
88
- },
89
- setName: {
90
- oneOf: [
91
- {
92
- type: 'string',
93
- description: "The location in the AnnData store for the set, like 'obs/louvain' or 'obs/celltype.'",
94
- },
95
- {
96
- type: 'array',
97
- items: { type: 'string' },
98
- description: 'An array of locations in the AnnData store for a hierarchy of set names, from coarse to fine levels.',
99
- },
100
- ],
101
- },
102
- scoreName: {
103
- oneOf: [
104
- {
105
- type: 'string',
106
- description: "The location in the AnnData store for the set confidence scores, like 'obs/celltype_prediction_score.'",
107
- },
108
- ],
109
- },
110
- },
111
- },
112
- };
113
-
114
- export const anndataExpressionMatrixZarrSchema = {
115
- $schema: 'http://json-schema.org/draft-07/schema#',
116
- $id: 'https://github.com/vitessce/vitessce/#anndata-expression-matrix-zarr-options',
117
- title: 'anndata-expression-matrix.zarr options',
118
- type: 'object',
119
- additionalProperties: false,
120
- required: ['matrix'],
121
- properties: {
122
- matrix: {
123
- type: 'string',
124
- description: "The location in the AnnData store of the cell x gene matrix, like 'obsm/hvg_subset.' or 'X'",
125
- },
126
- geneFilter: {
127
- type: 'string',
128
- description: "The location in the AnnData store of a filter for the genes if using a subset of the data, like 'var.highly_variable.' if the matrix comes from 'obsm/hvg_subset.'",
129
- },
130
- matrixGeneFilter: {
131
- type: 'string',
132
- description: "The location in the AnnData store of a filter for the matrix data (used in heatmap and histogram), like 'var.highly_variable.''",
133
- },
134
- geneAlias: {
135
- type: 'string',
136
- description: 'The location in the AnnData store of a different list of names for gene list component, other than the `var` index',
137
- },
138
- },
139
- };
@@ -1,138 +0,0 @@
1
- import {
2
- expandExpressionMatrixZarr,
3
- expandRasterOmeZarr,
4
- expandGenesJson,
5
- expandCellsJson,
6
- expandCellSetsJson,
7
- expandMoleculesJson,
8
- expandAnndataCellsZarr,
9
- expandAnndataCellSetsZarr,
10
- expandAnndataExpressionMatrixZarr,
11
- expandClustersJson,
12
- } from './joint-file-types-legacy';
13
-
14
- describe('src/app/file-options-schemas-legacy.js', () => {
15
- describe('Options validation for joint file type expansion functions', () => {
16
- it('cells.json with extra options fails validation', () => {
17
- expect(() => expandCellsJson({
18
- fileType: 'cells.json',
19
- url: 'http://localhost:8000/cells.json',
20
- options: {
21
- badKey: 'test',
22
- embeddingTypes: ['UMAP', 't-SNE'],
23
- obsLabelsTypes: ['cluster', 'subcluster'],
24
- },
25
- })).toThrow();
26
- });
27
- it('molecules.json with any options fails validation', () => {
28
- expect(() => expandMoleculesJson({
29
- fileType: 'molecules.json',
30
- url: 'http://localhost:8000/molecules.json',
31
- options: {},
32
- })).toThrow();
33
- });
34
- it('expression-matrix.zarr with any options fails validation', () => {
35
- expect(() => expandExpressionMatrixZarr({
36
- fileType: 'expression-matrix.zarr',
37
- url: 'http://localhost:8000/expression-matrix.zarr',
38
- options: {},
39
- })).toThrow();
40
- });
41
- it('raster.ome-zarr with any options fails validation', () => {
42
- expect(() => expandRasterOmeZarr({
43
- fileType: 'raster.ome-zarr',
44
- url: 'http://localhost:8000/raster.ome-zarr',
45
- options: {},
46
- })).toThrow();
47
- });
48
- it('cell-sets.json with any options fails validation', () => {
49
- expect(() => expandCellSetsJson({
50
- fileType: 'cell-sets.json',
51
- url: 'http://localhost:8000/cell-sets.json',
52
- options: {},
53
- })).toThrow();
54
- });
55
- it('clusters.json with any options fails validation', () => {
56
- expect(() => expandClustersJson({
57
- fileType: 'clusters.json',
58
- url: 'http://localhost:8000/clusters.json',
59
- options: {},
60
- })).toThrow();
61
- });
62
- it('genes.json with any options fails validation', () => {
63
- expect(() => expandGenesJson({
64
- fileType: 'genes.json',
65
- url: 'http://localhost:8000/genes.json',
66
- options: {},
67
- })).toThrow();
68
- });
69
- it('anndata-cells.zarr with extra options fails validation', () => {
70
- expect(() => expandAnndataCellsZarr({
71
- fileType: 'anndata-cells.zarr',
72
- url: 'http://localhost:8000/anndata-cells.zarr',
73
- options: {
74
- poly: 'obsm/poly',
75
- xy: 'obsm/xy',
76
- bad: 'bad',
77
- },
78
- })).toThrow();
79
- });
80
- it('anndata-cells.zarr with invalid options fails validation', () => {
81
- expect(() => expandAnndataCellsZarr({
82
- fileType: 'anndata-cells.zarr',
83
- url: 'http://localhost:8000/anndata-cells.zarr',
84
- options: {
85
- poly: 'obsm/poly',
86
- xy: 'obsm/xy',
87
- mappings: {
88
- UMAP: ['bad'],
89
- },
90
- },
91
- })).toThrow();
92
- });
93
- it('anndata-cell-sets.zarr with invalid options fails validation', () => {
94
- expect(() => expandAnndataCellSetsZarr({
95
- fileType: 'anndata-cell-sets.zarr',
96
- url: 'http://localhost:8000/anndata-cell-sets.zarr',
97
- options: {},
98
- })).toThrow();
99
- });
100
- it('anndata-cell-sets.zarr with extra options fails validation', () => {
101
- expect(() => expandAnndataCellSetsZarr({
102
- fileType: 'anndata-cell-sets.zarr',
103
- url: 'http://localhost:8000/anndata-cell-sets.zarr',
104
- options: [
105
- {
106
- groupName: 'Cell Type Annotations',
107
- setName: 'obs/cell_type',
108
- scoreName: 'obs/score',
109
- bad: 'bad',
110
- },
111
- ],
112
- })).toThrow();
113
- });
114
- it('anndata-expression-matrix.zarr with invalid options fails validation', () => {
115
- expect(() => expandAnndataExpressionMatrixZarr({
116
- fileType: 'anndata-expression-matrix.zarr',
117
- url: 'http://localhost:8000/anndata-expression-matrix.zarr',
118
- options: {
119
- matrix: 'good',
120
- geneAlias: 1,
121
- },
122
- })).toThrow();
123
- });
124
- it('anndata-expression-matrix.zarr with extra options fails validation', () => {
125
- expect(() => expandAnndataExpressionMatrixZarr({
126
- fileType: 'anndata-expression-matrix.zarr',
127
- url: 'http://localhost:8000/anndata-expression-matrix.zarr',
128
- options: {
129
- matrix: 'good',
130
- geneAlias: 'good',
131
- geneFilter: 'good',
132
- matrixGeneFilter: 'good',
133
- bad: 'bad',
134
- },
135
- })).toThrow();
136
- });
137
- });
138
- });
@@ -1,327 +0,0 @@
1
- import Ajv from 'ajv';
2
-
3
- export function validateOptions(optionsSchema, options) {
4
- const validate = new Ajv().compile(optionsSchema);
5
- const valid = validate(options || null);
6
- if (!valid) {
7
- console.warn(JSON.stringify(validate.errors, null, 2));
8
- throw new Error(`File definition options failed schema validation (${optionsSchema.title})`);
9
- }
10
- return true;
11
- }
12
-
13
- export const emptySchema = {
14
- $schema: 'http://json-schema.org/draft-07/schema#',
15
- $id: 'https://github.com/vitessce/vitessce/#empty-options',
16
- title: 'Empty options',
17
- oneOf: [
18
- { type: 'null' },
19
- ],
20
- };
21
-
22
- const sharedDefinitions = {
23
- annDataObs: {
24
- type: 'object',
25
- additionalProperties: false,
26
- required: ['path'],
27
- properties: {
28
- path: { type: 'string' },
29
- },
30
- },
31
- annDataObsm: {
32
- type: 'object',
33
- additionalProperties: false,
34
- required: ['path'],
35
- properties: {
36
- path: { type: 'string' },
37
- dims: {
38
- type: 'array',
39
- description: 'Which indices of the obsm object to take for a scatterplot, allowing for, for example, different PCs from obsm/X_pca',
40
- items: { type: 'number' },
41
- },
42
- },
43
- },
44
- annDataConvenienceObsLabelsItem: {
45
- type: 'object',
46
- additionalProperties: false,
47
- required: ['path', 'obsLabelsType'],
48
- properties: {
49
- path: { type: 'string' },
50
- obsLabelsType: { type: 'string' },
51
- },
52
- },
53
- annDataConvenienceFeatureLabelsItem: {
54
- type: 'object',
55
- additionalProperties: false,
56
- required: ['path', 'featureLabelsType'],
57
- properties: {
58
- path: { type: 'string' },
59
- featureLabelsType: { type: 'string' },
60
- },
61
- },
62
- annDataConvenienceObsEmbeddingItem: {
63
- type: 'object',
64
- additionalProperties: false,
65
- required: ['path', 'embeddingType'],
66
- properties: {
67
- path: { type: 'string' },
68
- dims: {
69
- type: 'array',
70
- description: 'Which indices of the obsm object to take for a scatterplot, allowing for, for example, different PCs from obsm/X_pca',
71
- items: { type: 'number' },
72
- },
73
- embeddingType: { type: 'string' },
74
- },
75
- },
76
- annDataObsLabels: { $ref: '#/definitions/annDataObs' },
77
- annDataFeatureLabels: { $ref: '#/definitions/annDataObs' },
78
- annDataObsFeatureMatrix: {
79
- type: 'object',
80
- description: 'Options for the obsFeatureMatrix.anndata.zarr file type.',
81
- additionalProperties: false,
82
- required: ['path'],
83
- properties: {
84
- path: { type: 'string' },
85
- featureFilterPath: {
86
- type: 'string',
87
- description: 'If the feature index should be filtered, put a boolean column here (analogous to the previous geneFilter option). e.g., var/in_obsm_X_small_matrix',
88
- },
89
- initialFeatureFilterPath: {
90
- type: 'string',
91
- description: 'If only a subset of the matrix should be loaded initially, put a boolean column along the feature axis here (analogous to the previous matrixGeneFilter option). e.g., var/highly_variable',
92
- },
93
- },
94
- },
95
- annDataObsSets: {
96
- type: 'array',
97
- description: 'Options for the obsSets.anndata.zarr file type.',
98
- items: {
99
- type: 'object',
100
- additionalProperties: false,
101
- required: ['name', 'path'],
102
- properties: {
103
- name: {
104
- type: 'string',
105
- description: "The display name for the set, like 'Cell Type' or 'Louvain.'",
106
- },
107
- path: {
108
- oneOf: [
109
- {
110
- type: 'string',
111
- description: "The location in the AnnData store for the set, like 'obs/louvain' or 'obs/celltype.'",
112
- },
113
- {
114
- type: 'array',
115
- items: { type: 'string' },
116
- description: 'An array of locations in the AnnData store for a hierarchy of set names, from coarse to fine levels.',
117
- },
118
- ],
119
- },
120
- scorePath: {
121
- oneOf: [
122
- {
123
- type: 'string',
124
- description: "The location in the AnnData store for the set confidence scores, like 'obs/celltype_prediction_score.'",
125
- },
126
- ],
127
- },
128
- },
129
- },
130
- },
131
- annDataObsLocations: { $ref: '#/definitions/annDataObsm' },
132
- annDataObsEmbedding: { $ref: '#/definitions/annDataObsm' },
133
- annDataObsSegmentations: { $ref: '#/definitions/annDataObs' },
134
- };
135
-
136
- /**
137
- * Options schemas for atomic file types.
138
- */
139
- // AnnData
140
- export const obsEmbeddingAnndataSchema = {
141
- $schema: 'http://json-schema.org/draft-07/schema#',
142
- $id: 'https://github.com/vitessce/vitessce/#obsEmbedding-anndata-zarr-options',
143
- title: 'obsEmbedding.anndata.zarr options',
144
- definitions: sharedDefinitions,
145
- $ref: '#/definitions/annDataObsEmbedding',
146
- };
147
- export const obsLocationsAnndataSchema = {
148
- $schema: 'http://json-schema.org/draft-07/schema#',
149
- $id: 'https://github.com/vitessce/vitessce/#obsLocations-anndata-zarr-options',
150
- title: 'obsLocations.anndata.zarr options',
151
- definitions: sharedDefinitions,
152
- $ref: '#/definitions/annDataObsLocations',
153
- };
154
- export const obsSegmentationsAnndataSchema = {
155
- $schema: 'http://json-schema.org/draft-07/schema#',
156
- $id: 'https://github.com/vitessce/vitessce/#obsSegmentations-anndata-zarr-options',
157
- title: 'obsSegmentations.anndata.zarr options',
158
- definitions: sharedDefinitions,
159
- $ref: '#/definitions/annDataObsSegmentations',
160
- };
161
- export const obsSetsAnndataSchema = {
162
- $schema: 'http://json-schema.org/draft-07/schema#',
163
- $id: 'https://github.com/vitessce/vitessce/#obsSets-anndata-zarr-options',
164
- title: 'obsSets.anndata.zarr options',
165
- definitions: sharedDefinitions,
166
- $ref: '#/definitions/annDataObsSets',
167
- };
168
- export const obsFeatureMatrixAnndataSchema = {
169
- $schema: 'http://json-schema.org/draft-07/schema#',
170
- $id: 'https://github.com/vitessce/vitessce/#obsFeatureMatrix-anndata-zarr-options',
171
- title: 'obsFeatureMatrix.anndata.zarr options',
172
- definitions: sharedDefinitions,
173
- $ref: '#/definitions/annDataObsFeatureMatrix',
174
- };
175
- export const obsLabelsAnndataSchema = {
176
- $schema: 'http://json-schema.org/draft-07/schema#',
177
- $id: 'https://github.com/vitessce/vitessce/#obsLabels-anndata-zarr-options',
178
- title: 'obsLabels.anndata.zarr options',
179
- definitions: sharedDefinitions,
180
- $ref: '#/definitions/annDataObsLabels',
181
- };
182
- export const featureLabelsAnndataSchema = {
183
- $schema: 'http://json-schema.org/draft-07/schema#',
184
- $id: 'https://github.com/vitessce/vitessce/#featureLabels-anndata-zarr-options',
185
- title: 'featureLabels.anndata.zarr options',
186
- definitions: sharedDefinitions,
187
- $ref: '#/definitions/annDataFeatureLabels',
188
- };
189
- // CSV
190
- export const obsEmbeddingCsvSchema = {
191
- $schema: 'http://json-schema.org/draft-07/schema#',
192
- $id: 'https://github.com/vitessce/vitessce/#obsEmbedding-csv-options',
193
- title: 'obsEmbedding.csv options',
194
- type: 'object',
195
- required: ['obsIndex', 'obsEmbedding'],
196
- properties: {
197
- obsIndex: { type: 'string' },
198
- obsEmbedding: {
199
- type: 'array',
200
- items: { type: 'string' },
201
- minItems: 2,
202
- maxItems: 2,
203
- },
204
- },
205
- };
206
- export const obsLocationsCsvSchema = {
207
- $schema: 'http://json-schema.org/draft-07/schema#',
208
- $id: 'https://github.com/vitessce/vitessce/#obsLocations-csv-options',
209
- title: 'obsLocations.csv options',
210
- type: 'object',
211
- required: ['obsIndex', 'obsLocations'],
212
- properties: {
213
- obsIndex: { type: 'string' },
214
- obsLocations: {
215
- type: 'array',
216
- items: { type: 'string' },
217
- minItems: 2,
218
- maxItems: 2,
219
- },
220
- },
221
- };
222
- export const obsLabelsCsvSchema = {
223
- $schema: 'http://json-schema.org/draft-07/schema#',
224
- $id: 'https://github.com/vitessce/vitessce/#obsLabels-csv-options',
225
- title: 'obsLabels.csv options',
226
- type: 'object',
227
- required: ['obsIndex', 'obsLabels'],
228
- properties: {
229
- obsIndex: { type: 'string' },
230
- obsLabels: { type: 'string' },
231
- },
232
- };
233
- export const featureLabelsCsvSchema = {
234
- $schema: 'http://json-schema.org/draft-07/schema#',
235
- $id: 'https://github.com/vitessce/vitessce/#featureLabels-csv-options',
236
- title: 'featureLabels.csv options',
237
- type: 'object',
238
- required: ['featureIndex', 'featureLabels'],
239
- properties: {
240
- featureIndex: { type: 'string' },
241
- featureLabels: { type: 'string' },
242
- },
243
- };
244
- export const obsSetsCsvSchema = {
245
- $schema: 'http://json-schema.org/draft-07/schema#',
246
- $id: 'https://github.com/vitessce/vitessce/#obsLabels-csv-options',
247
- title: 'obsLabels.csv options',
248
- type: 'object',
249
- additionalProperties: false,
250
- required: ['obsIndex', 'obsSets'],
251
- properties: {
252
- obsIndex: { type: 'string' },
253
- obsSets: {
254
- type: 'array',
255
- items: {
256
- type: 'object',
257
- additionalProperties: false,
258
- required: ['name', 'column'],
259
- properties: {
260
- name: {
261
- type: 'string',
262
- description: "The display name for the set, like 'Cell Type' or 'Louvain'",
263
- },
264
- column: {
265
- oneOf: [
266
- {
267
- type: 'string',
268
- description: "The column for the set, like 'cell_type'",
269
- },
270
- {
271
- type: 'array',
272
- items: { type: 'string' },
273
- description: 'An array of columns for a hierarchy of set names, from coarse to fine levels.',
274
- },
275
- ],
276
- },
277
- scoreColumn: {
278
- oneOf: [
279
- {
280
- type: 'string',
281
- description: "The column for the set confidence scores, like 'celltype_prediction_score'",
282
- },
283
- ],
284
- },
285
- },
286
- },
287
- },
288
- },
289
- };
290
-
291
- /**
292
- * Options schemas for joint file types.
293
- */
294
- export const anndataZarrSchema = {
295
- $schema: 'http://json-schema.org/draft-07/schema#',
296
- $id: 'https://github.com/vitessce/vitessce/#anndata-zarr-options',
297
- title: 'anndata.zarr options',
298
- definitions: sharedDefinitions,
299
- type: 'object',
300
- minProperties: 1,
301
- additionalProperties: false,
302
- required: [],
303
- properties: {
304
- obsLabels: {
305
- oneOf: [
306
- { $ref: '#/definitions/annDataObsLabels' },
307
- { type: 'array', items: { $ref: '#/definitions/annDataConvenienceObsLabelsItem' } },
308
- ],
309
- },
310
- featureLabels: {
311
- oneOf: [
312
- { $ref: '#/definitions/annDataFeatureLabels' },
313
- { type: 'array', items: { $ref: '#/definitions/annDataConvenienceFeatureLabelsItem' } },
314
- ],
315
- },
316
- obsFeatureMatrix: { $ref: '#/definitions/annDataObsFeatureMatrix' },
317
- obsSets: { $ref: '#/definitions/annDataObsSets' },
318
- obsLocations: { $ref: '#/definitions/annDataObsLocations' },
319
- obsSegmentations: { $ref: '#/definitions/annDataObsSegmentations' },
320
- obsEmbedding: {
321
- oneOf: [
322
- { $ref: '#/definitions/annDataObsEmbedding' },
323
- { type: 'array', items: { $ref: '#/definitions/annDataConvenienceObsEmbeddingItem' } },
324
- ],
325
- },
326
- },
327
- };
@@ -1,26 +0,0 @@
1
- import {
2
- expandAnndataZarr,
3
- } from './joint-file-types';
4
-
5
- describe('src/app/file-options-schemas.js', () => {
6
- describe('Options validation for joint file type expansion functions', () => {
7
- it('anndata.zarr with invalid options fails validation', () => {
8
- expect(() => expandAnndataZarr({
9
- fileType: 'anndata.zarr',
10
- url: 'http://localhost:8000/anndata.zarr',
11
- options: {
12
- obsFeatureMatrix: 1,
13
- },
14
- })).toThrow();
15
- });
16
- it('anndata.zarr with extra options fails validation', () => {
17
- expect(() => expandAnndataZarr({
18
- fileType: 'anndata.zarr',
19
- url: 'http://localhost:8000/anndata.zarr',
20
- options: {
21
- bad: 'bad',
22
- },
23
- })).toThrow();
24
- });
25
- });
26
- });