@vitessce/json 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 (89) hide show
  1. package/dist/deflate.40c5a64d.mjs +12 -0
  2. package/dist/index.cd98204c.mjs +146933 -0
  3. package/dist/index.mjs +19 -0
  4. package/dist/jpeg.71d7c24e.mjs +839 -0
  5. package/dist/lerc.1bd33f8e.mjs +1934 -0
  6. package/dist/lzw.55eb0ed4.mjs +127 -0
  7. package/dist/packbits.244c3ff7.mjs +29 -0
  8. package/dist/pako.esm.4b234125.mjs +3940 -0
  9. package/dist/raw.e260117e.mjs +11 -0
  10. package/dist/webimage.9c635930.mjs +31 -0
  11. package/{dist → dist-tsc}/index.js +0 -0
  12. package/package.json +11 -11
  13. package/src/JsonSource.js +21 -0
  14. package/src/index.js +4 -0
  15. package/src/json-loaders/JsonLoader.js +66 -0
  16. package/src/json-loaders/JsonLoader.test.js +28 -0
  17. package/src/json-loaders/ObsSegmentationsJson.js +37 -0
  18. package/src/json-loaders/ObsSetsJson.js +53 -0
  19. package/{dist → src}/json-loaders/ObsSetsJson.test-old.js +0 -1
  20. package/{dist → src}/json-loaders/index.js +0 -0
  21. package/src/legacy-loaders/CellsJsonAsObsEmbedding.js +53 -0
  22. package/src/legacy-loaders/CellsJsonAsObsLabels.js +32 -0
  23. package/src/legacy-loaders/CellsJsonAsObsLocations.js +45 -0
  24. package/src/legacy-loaders/CellsJsonAsObsSegmentations.js +57 -0
  25. package/src/legacy-loaders/CellsJsonLoaders.test.js +68 -0
  26. package/src/legacy-loaders/ClustersJsonAsObsFeatureMatrix.js +55 -0
  27. package/src/legacy-loaders/ClustersJsonLoaders.test.js +33 -0
  28. package/src/legacy-loaders/GenesJsonAsObsFeatureMatrix.js +44 -0
  29. package/src/legacy-loaders/GenesJsonLoaders.test.js +33 -0
  30. package/src/legacy-loaders/MoleculesJsonAsObsLabels.js +39 -0
  31. package/src/legacy-loaders/MoleculesJsonAsObsLocations.js +50 -0
  32. package/src/legacy-loaders/MoleculesJsonLoaders.test.js +46 -0
  33. package/{dist → src}/legacy-loaders/index.js +0 -0
  34. package/src/legacy-loaders/schemas/cells.schema.json +52 -0
  35. package/src/legacy-loaders/schemas/clusters.schema.json +30 -0
  36. package/src/legacy-loaders/schemas/fixtures/cells.bad.json +8 -0
  37. package/src/legacy-loaders/schemas/fixtures/cells.bad.message.json +11 -0
  38. package/src/legacy-loaders/schemas/fixtures/cells.good.json +29 -0
  39. package/src/legacy-loaders/schemas/fixtures/clusters.bad.json +9 -0
  40. package/src/legacy-loaders/schemas/fixtures/clusters.bad.message.json +13 -0
  41. package/src/legacy-loaders/schemas/fixtures/clusters.good.json +9 -0
  42. package/src/legacy-loaders/schemas/fixtures/genes.bad.json +6 -0
  43. package/src/legacy-loaders/schemas/fixtures/genes.bad.message.json +13 -0
  44. package/src/legacy-loaders/schemas/fixtures/genes.good.json +4 -0
  45. package/src/legacy-loaders/schemas/fixtures/molecules.bad.json +7 -0
  46. package/src/legacy-loaders/schemas/fixtures/molecules.bad.message.json +11 -0
  47. package/src/legacy-loaders/schemas/fixtures/molecules.good.json +7 -0
  48. package/src/legacy-loaders/schemas/fixtures/neighborhoods.bad.json +4 -0
  49. package/src/legacy-loaders/schemas/fixtures/neighborhoods.bad.message.json +11 -0
  50. package/src/legacy-loaders/schemas/fixtures/neighborhoods.good.json +4 -0
  51. package/src/legacy-loaders/schemas/genes.schema.json +27 -0
  52. package/src/legacy-loaders/schemas/molecules.schema.json +20 -0
  53. package/src/legacy-loaders/schemas/neighborhoods.schema.json +28 -0
  54. package/src/raster-json-loaders/RasterJsonAsImageLoader.js +45 -0
  55. package/src/raster-json-loaders/RasterJsonAsObsSegmentationsLoader.js +46 -0
  56. package/src/raster-json-loaders/RasterJsonLoader.js +127 -0
  57. package/{dist → src}/raster-json-loaders/index.js +0 -0
  58. package/dist/JsonSource.js +0 -20
  59. package/dist/json-loaders/JsonLoader.js +0 -51
  60. package/dist/json-loaders/JsonLoader.test.js +0 -25
  61. package/dist/json-loaders/ObsSegmentationsJson.js +0 -30
  62. package/dist/json-loaders/ObsSetsJson.js +0 -43
  63. package/dist/json-loaders/ObsSetsJson.test.js +0 -28
  64. package/dist/legacy-loaders/CellsJsonAsObsEmbedding.js +0 -41
  65. package/dist/legacy-loaders/CellsJsonAsObsLabels.js +0 -28
  66. package/dist/legacy-loaders/CellsJsonAsObsLocations.js +0 -39
  67. package/dist/legacy-loaders/CellsJsonAsObsSegmentations.js +0 -55
  68. package/dist/legacy-loaders/CellsJsonLoaders.test.js +0 -66
  69. package/dist/legacy-loaders/ClustersJsonAsObsFeatureMatrix.js +0 -48
  70. package/dist/legacy-loaders/ClustersJsonLoaders.test.js +0 -31
  71. package/dist/legacy-loaders/GenesJsonAsObsFeatureMatrix.js +0 -34
  72. package/dist/legacy-loaders/GenesJsonLoaders.test.js +0 -31
  73. package/dist/legacy-loaders/MoleculesJsonAsObsLabels.js +0 -35
  74. package/dist/legacy-loaders/MoleculesJsonAsObsLocations.js +0 -46
  75. package/dist/legacy-loaders/MoleculesJsonLoaders.test.js +0 -44
  76. package/dist/legacy-loaders/schemas/cells.schema.json +0 -52
  77. package/dist/legacy-loaders/schemas/clusters.schema.json +0 -30
  78. package/dist/legacy-loaders/schemas/fixtures/cells.bad.json +0 -8
  79. package/dist/legacy-loaders/schemas/fixtures/cells.good.json +0 -29
  80. package/dist/legacy-loaders/schemas/fixtures/clusters.good.json +0 -9
  81. package/dist/legacy-loaders/schemas/fixtures/genes.good.json +0 -4
  82. package/dist/legacy-loaders/schemas/fixtures/molecules.good.json +0 -7
  83. package/dist/legacy-loaders/schemas/genes.schema.json +0 -27
  84. package/dist/legacy-loaders/schemas/molecules.schema.json +0 -20
  85. package/dist/legacy-loaders/schemas/neighborhoods.schema.json +0 -28
  86. package/dist/legacy-loaders/schemas/schema.test.js +0 -48
  87. package/dist/raster-json-loaders/RasterJsonAsImageLoader.js +0 -36
  88. package/dist/raster-json-loaders/RasterJsonAsObsSegmentationsLoader.js +0 -37
  89. package/dist/raster-json-loaders/RasterJsonLoader.js +0 -103
@@ -0,0 +1,44 @@
1
+ import { AbstractLoaderError, LoaderResult } from '@vitessce/vit-s';
2
+ import genesSchema from './schemas/genes.schema.json';
3
+ import JsonLoader from '../json-loaders/JsonLoader';
4
+
5
+ export default class GenesJsonAsObsFeatureMatrixLoader extends JsonLoader {
6
+ constructor(dataSource, params) {
7
+ super(dataSource, params);
8
+
9
+ this.schema = genesSchema;
10
+ }
11
+
12
+ loadFromCache(data) {
13
+ if (this.cachedResult) {
14
+ return this.cachedResult;
15
+ }
16
+ const cols = Object.keys(data);
17
+ const rows = (cols.length > 0 ? Object.keys(data[cols[0]].cells) : []);
18
+
19
+ const normalizedFlatMatrix = rows
20
+ .flatMap(cellId => cols.map(
21
+ geneId => (data[geneId].cells[cellId] / data[geneId].max) * 255,
22
+ ));
23
+ // Need to wrap the NestedArray to mock the HTTPStore-based array
24
+ // which returns promises.
25
+ const featureIndex = cols;
26
+ const obsIndex = rows;
27
+ const obsFeatureMatrix = { data: Uint8Array.from(normalizedFlatMatrix) };
28
+ this.cachedResult = { obsIndex, featureIndex, obsFeatureMatrix };
29
+ return this.cachedResult;
30
+ }
31
+
32
+ async load() {
33
+ const payload = await super.load().catch(reason => Promise.resolve(reason));
34
+ if (payload instanceof AbstractLoaderError) {
35
+ return Promise.reject(payload);
36
+ }
37
+ const { data, url } = payload;
38
+ const result = this.loadFromCache(data);
39
+ return Promise.resolve(new LoaderResult(
40
+ result,
41
+ url,
42
+ ));
43
+ }
44
+ }
@@ -0,0 +1,33 @@
1
+ import { LoaderResult } from '@vitessce/vit-s';
2
+ import GenesJsonAsObsFeatureMatrixLoader from './GenesJsonAsObsFeatureMatrix';
3
+ import JsonSource from '../JsonSource';
4
+
5
+ const createLoader = (ClassDef, config, url) => {
6
+ const configWithUrl = {
7
+ ...config,
8
+ url,
9
+ };
10
+ const source = new JsonSource(configWithUrl);
11
+ return new ClassDef(source, configWithUrl);
12
+ };
13
+
14
+ describe('loaders/genes-json-loaders', () => {
15
+ describe('GenesJsonAsObsFeatureMatrixLoader', () => {
16
+ it('can load obsFeatureMatrix', async () => {
17
+ const loader = createLoader(GenesJsonAsObsFeatureMatrixLoader, {
18
+ fileType: 'obsFeatureMatrix.genes.json',
19
+ }, 'http://localhost:51204/@fixtures/json-legacy/genes.good.json');
20
+ const result = await loader.load();
21
+ expect(result).toBeInstanceOf(LoaderResult);
22
+ const payload = result.data;
23
+ expect(Object.keys(payload)).toEqual(['obsIndex', 'featureIndex', 'obsFeatureMatrix']);
24
+ expect(payload.obsIndex).toEqual(['778', '1409', '3642']);
25
+ expect(payload.featureIndex).toEqual(['Gad2', 'Slc32a1']);
26
+ expect(Array.from(payload.obsFeatureMatrix.data)).toEqual([
27
+ 93, 213,
28
+ 42, 135,
29
+ 255, 255,
30
+ ]);
31
+ });
32
+ });
33
+ });
@@ -0,0 +1,39 @@
1
+ import range from 'lodash/range';
2
+ import sum from 'lodash/sum';
3
+ import { AbstractLoaderError, LoaderResult } from '@vitessce/vit-s';
4
+ import moleculesSchema from './schemas/molecules.schema.json';
5
+ import JsonLoader from '../json-loaders/JsonLoader';
6
+
7
+ export default class MoleculesJsonAsObsLabelsLoader extends JsonLoader {
8
+ constructor(dataSource, params) {
9
+ super(dataSource, params);
10
+
11
+ this.schema = moleculesSchema;
12
+ }
13
+
14
+ loadFromCache(data) {
15
+ if (this.cachedResult) {
16
+ return this.cachedResult;
17
+ }
18
+ const obsIndex = range(sum(Object.values(data).map(v => v.length))).map(i => String(i));
19
+ let obsLabels = [];
20
+ Object.entries(data).forEach(([gene, locations]) => {
21
+ obsLabels = [
22
+ ...obsLabels,
23
+ ...range(locations.length).map(() => gene),
24
+ ];
25
+ });
26
+ this.cachedResult = { obsIndex, obsLabels };
27
+ return this.cachedResult;
28
+ }
29
+
30
+ async load() {
31
+ const payload = await super.load().catch(reason => Promise.resolve(reason));
32
+ if (payload instanceof AbstractLoaderError) {
33
+ return Promise.reject(payload);
34
+ }
35
+ const { data, url } = payload;
36
+ const result = this.loadFromCache(data);
37
+ return Promise.resolve(new LoaderResult(result, url));
38
+ }
39
+ }
@@ -0,0 +1,50 @@
1
+ import range from 'lodash/range';
2
+ import sum from 'lodash/sum';
3
+ import { AbstractLoaderError, LoaderResult } from '@vitessce/vit-s';
4
+ import { DEFAULT_MOLECULES_LAYER } from '@vitessce/spatial-utils';
5
+ import moleculesSchema from './schemas/molecules.schema.json';
6
+ import JsonLoader from '../json-loaders/JsonLoader';
7
+
8
+ export default class MoleculesJsonAsObsLocationsLoader extends JsonLoader {
9
+ constructor(dataSource, params) {
10
+ super(dataSource, params);
11
+
12
+ this.schema = moleculesSchema;
13
+ }
14
+
15
+ loadFromCache(data) {
16
+ if (this.cachedResult) {
17
+ return this.cachedResult;
18
+ }
19
+ const moleculesValues = Object.values(data);
20
+ const obsIndex = range(sum(moleculesValues.map(v => v.length))).map(i => String(i));
21
+ const obsLocationsX = new Float32Array(obsIndex.length);
22
+ const obsLocationsY = new Float32Array(obsIndex.length);
23
+ let startAt = 0;
24
+ moleculesValues.forEach((locations) => {
25
+ obsLocationsX.set(locations.map(l => l[0]), startAt);
26
+ obsLocationsY.set(locations.map(l => l[1]), startAt);
27
+ startAt += locations.length;
28
+ });
29
+ const obsLocations = {
30
+ data: [obsLocationsX, obsLocationsY],
31
+ shape: [2, obsLocationsX.length],
32
+ };
33
+ this.cachedResult = { obsIndex, obsLocations };
34
+ return this.cachedResult;
35
+ }
36
+
37
+ async load() {
38
+ const payload = await super.load().catch(reason => Promise.resolve(reason));
39
+ if (payload instanceof AbstractLoaderError) {
40
+ return Promise.reject(payload);
41
+ }
42
+ const { data, url } = payload;
43
+ const result = this.loadFromCache(data);
44
+ const coordinationValues = {
45
+ // TODO: do this for anndata segmentation loader
46
+ spatialPointLayer: DEFAULT_MOLECULES_LAYER,
47
+ };
48
+ return Promise.resolve(new LoaderResult(result, url, coordinationValues));
49
+ }
50
+ }
@@ -0,0 +1,46 @@
1
+ import { LoaderResult } from '@vitessce/vit-s';
2
+ import MoleculesJsonAsObsLocationsLoader from './MoleculesJsonAsObsLocations';
3
+ import MoleculesJsonAsObsLabelsLoader from './MoleculesJsonAsObsLabels';
4
+ import JsonSource from '../JsonSource';
5
+
6
+ const createLoader = (ClassDef, config, url) => {
7
+ const configWithUrl = {
8
+ ...config,
9
+ url,
10
+ };
11
+ const source = new JsonSource(configWithUrl);
12
+ return new ClassDef(source, configWithUrl);
13
+ };
14
+
15
+ describe('loaders/molecules-json-loaders', () => {
16
+ describe('MoleculesJsonAsObsLocationsLoader', () => {
17
+ it('can load obsLocations', async () => {
18
+ const loader = createLoader(MoleculesJsonAsObsLocationsLoader, {
19
+ fileType: 'obsLocations.molecules.json',
20
+ }, 'http://localhost:51204/@fixtures/json-legacy/molecules.good.json');
21
+ const result = await loader.load();
22
+ expect(result).toBeInstanceOf(LoaderResult);
23
+ const payload = result.data;
24
+ expect(Object.keys(payload)).toEqual(['obsIndex', 'obsLocations']);
25
+ expect(payload.obsIndex).toEqual(['0', '1', '2']);
26
+ expect(Array.from(payload.obsLocations.data[0])).toEqual([27008.0, 8315.0, 18683.0]);
27
+ expect(Array.from(payload.obsLocations.data[1])).toEqual([949.0, 22747.0, 19476.0]);
28
+ });
29
+ });
30
+ describe('MoleculesJsonAsObsLabelsLoader', () => {
31
+ it('can load obsLabels', async () => {
32
+ const loader = createLoader(MoleculesJsonAsObsLabelsLoader, {
33
+ fileType: 'obsLabels.molecules.json',
34
+ coordinationValues: {
35
+ obsLabelsType: 'gene',
36
+ },
37
+ }, 'http://localhost:51204/@fixtures/json-legacy/molecules.good.json');
38
+ const result = await loader.load();
39
+ expect(result).toBeInstanceOf(LoaderResult);
40
+ const payload = result.data;
41
+ expect(Object.keys(payload)).toEqual(['obsIndex', 'obsLabels']);
42
+ expect(payload.obsIndex).toEqual(['0', '1', '2']);
43
+ expect(payload.obsLabels).toEqual(['Klk6_Hybridization5', 'Klk6_Hybridization5', 'Klk6_Hybridization5']);
44
+ });
45
+ });
46
+ });
File without changes
@@ -0,0 +1,52 @@
1
+ {
2
+ "$schema": "http://json-schema.org/draft-07/schema#",
3
+ "$id": "https://github.com/vitessce/vitessce/#cells",
4
+ "title": "Vitessce cell data",
5
+ "type": "object",
6
+ "definitions": {
7
+ "coord": {
8
+ "type": "array",
9
+ "minItems": 2,
10
+ "maxItems": 2,
11
+ "items": { "type": "number" }
12
+ },
13
+ "positiveFloatValues": {
14
+ "type": "object",
15
+ "patternProperties": {
16
+ ".": {
17
+ "type": "number",
18
+ "minimum": 0
19
+ }
20
+ }
21
+ },
22
+ "stringValues": {
23
+ "type": "object",
24
+ "patternProperties": {
25
+ ".": {
26
+ "type": "string"
27
+ }
28
+ }
29
+ }
30
+ },
31
+ "patternProperties": {
32
+ ".": {
33
+ "additionalProperties": false,
34
+ "required": [],
35
+ "properties": {
36
+ "mappings": {
37
+ "type": "object",
38
+ "patternProperties": {
39
+ ".": { "$ref": "#/definitions/coord" }
40
+ }
41
+ },
42
+ "xy": { "$ref": "#/definitions/coord" },
43
+ "genes": { "$ref": "#/definitions/positiveFloatValues" },
44
+ "factors": { "$ref": "#/definitions/stringValues" },
45
+ "poly": {
46
+ "type": "array",
47
+ "items": { "$ref": "#/definitions/coord" }
48
+ }
49
+ }
50
+ }
51
+ }
52
+ }
@@ -0,0 +1,30 @@
1
+ {
2
+ "$schema": "http://json-schema.org/draft-07/schema#",
3
+ "$id": "https://github.com/vitessce/vitessce/#clusters",
4
+ "title": "Vitessce cluster data",
5
+ "type": "object",
6
+ "definitions": {
7
+ "stringArray": {
8
+ "type": "array",
9
+ "items": { "type": "string" }
10
+ },
11
+ "matrix": {
12
+ "type": "array",
13
+ "items": {
14
+ "type": "array",
15
+ "items": {
16
+ "type": "number",
17
+ "minimum": 0,
18
+ "maximum": 1
19
+ }
20
+ }
21
+ }
22
+ },
23
+ "additionalProperties": false,
24
+ "required": ["rows", "cols", "matrix"],
25
+ "properties": {
26
+ "rows": { "$ref": "#/definitions/stringArray" },
27
+ "cols": { "$ref": "#/definitions/stringArray" },
28
+ "matrix": { "$ref": "#/definitions/matrix" }
29
+ }
30
+ }
@@ -0,0 +1,8 @@
1
+ {
2
+ "778": {
3
+ "tsne": [
4
+ -58.13238525390625,
5
+ "not a number"
6
+ ]
7
+ }
8
+ }
@@ -0,0 +1,11 @@
1
+ [
2
+ {
3
+ "dataPath": "['778']",
4
+ "keyword": "additionalProperties",
5
+ "message": "should NOT have additional properties",
6
+ "params": {
7
+ "additionalProperty": "tsne"
8
+ },
9
+ "schemaPath": "#/patternProperties/./additionalProperties"
10
+ }
11
+ ]
@@ -0,0 +1,29 @@
1
+ {
2
+ "778": {
3
+ "mappings": {
4
+ "t-SNE": [
5
+ -58.13238525390625,
6
+ 5.219181060791016
7
+ ],
8
+ "PCA": [
9
+ 1, 2
10
+ ]
11
+ },
12
+ "factors": {
13
+ "cluster": "Inhibitory CP"
14
+ },
15
+ "genes": {
16
+ "Gad2": 35,
17
+ "Slc32a1": 41
18
+ },
19
+ "xy": [
20
+ 18171.230942376023,
21
+ 24590.795274569497
22
+ ],
23
+ "poly": [
24
+ [1,2],
25
+ [3,4],
26
+ [5,6]
27
+ ]
28
+ }
29
+ }
@@ -0,0 +1,9 @@
1
+ {
2
+ "rows": ["Lamp5", "Sox10", "Crhbp"],
3
+ "cols": ["3572", "1904", "1670"],
4
+ "matrix": [
5
+ [123, 456, 789],
6
+ [12, 45, 78],
7
+ ["x", 4, 7]
8
+ ]
9
+ }
@@ -0,0 +1,13 @@
1
+ [
2
+ {
3
+ "dataPath": ".matrix[0][0]",
4
+ "keyword": "maximum",
5
+ "message": "should be <= 1",
6
+ "params": {
7
+ "comparison": "<=",
8
+ "exclusive": false,
9
+ "limit": 1
10
+ },
11
+ "schemaPath": "#/definitions/matrix/items/items/maximum"
12
+ }
13
+ ]
@@ -0,0 +1,9 @@
1
+ {
2
+ "rows": ["Lamp5", "Sox10", "Crhbp"],
3
+ "cols": ["3572", "1904", "1670"],
4
+ "matrix": [
5
+ [0.123, 0.456, 0.789],
6
+ [0.12, 0.45, 0.78],
7
+ [0.1, 0.4, 0.7]
8
+ ]
9
+ }
@@ -0,0 +1,6 @@
1
+ {
2
+ "gene-id": {
3
+ "cells": {"cell-id": -999},
4
+ "max": 1
5
+ }
6
+ }
@@ -0,0 +1,13 @@
1
+ [
2
+ {
3
+ "dataPath": "['gene-id'].cells['cell-id']",
4
+ "keyword": "minimum",
5
+ "message": "should be >= 0",
6
+ "params": {
7
+ "comparison": ">=",
8
+ "exclusive": false,
9
+ "limit": 0
10
+ },
11
+ "schemaPath": "#/definitions/positiveFloatValues/patternProperties/./minimum"
12
+ }
13
+ ]
@@ -0,0 +1,4 @@
1
+ {
2
+ "Gad2": {"max": 95, "cells": {"778": 35, "1409": 16, "3642": 95}},
3
+ "Slc32a1": {"max": 49, "cells": {"778": 41, "1409": 26, "3642": 49}}
4
+ }
@@ -0,0 +1,7 @@
1
+ {
2
+ "Klk6_Hybridization5":[
3
+ [27008.0, 949.0],
4
+ [8315.0, 22747.0],
5
+ [1, 2, 3, 4, 5]
6
+ ]
7
+ }
@@ -0,0 +1,11 @@
1
+ [
2
+ {
3
+ "dataPath": "['Klk6_Hybridization5'][2]",
4
+ "keyword": "maxItems",
5
+ "message": "should NOT have more than 2 items",
6
+ "params": {
7
+ "limit": 2
8
+ },
9
+ "schemaPath": "#/definitions/coord/maxItems"
10
+ }
11
+ ]
@@ -0,0 +1,7 @@
1
+ {
2
+ "Klk6_Hybridization5":[
3
+ [27008.0, 949.0],
4
+ [8315.0, 22747.0],
5
+ [18683.0, 19476.0]
6
+ ]
7
+ }
@@ -0,0 +1,4 @@
1
+ {
2
+ "4031::4028::4008": {"poly": [[-43.9, 394.39], [-45.25, 409.18]]},
3
+ "4031::4008::4014": {"poly": [[-43.9, 394.39], [-2.07, 390.45]]}
4
+ }
@@ -0,0 +1,11 @@
1
+ [
2
+ {
3
+ "dataPath": "['4031::4028::4008'].poly",
4
+ "keyword": "minItems",
5
+ "message": "should NOT have fewer than 3 items",
6
+ "params": {
7
+ "limit": 3
8
+ },
9
+ "schemaPath": "#/patternProperties/./properties/poly/minItems"
10
+ }
11
+ ]
@@ -0,0 +1,4 @@
1
+ {
2
+ "4031::4028::4008": {"poly": [[-43.9, 394.39], [-45.25, 409.18], [-2.07, 390.45]]},
3
+ "4031::4008::4014": {"poly": [[-43.9, 394.39], [-2.07, 390.45], [-17.6, 376.96]]}
4
+ }
@@ -0,0 +1,27 @@
1
+ {
2
+ "$schema": "http://json-schema.org/draft-07/schema#",
3
+ "$id": "https://github.com/vitessce/vitessce/#genes",
4
+ "title": "Vitessce gene data",
5
+ "type": "object",
6
+ "definitions": {
7
+ "positiveFloatValues": {
8
+ "type": "object",
9
+ "patternProperties": {
10
+ ".": {
11
+ "type": "number",
12
+ "minimum": 0
13
+ }
14
+ }
15
+ }
16
+ },
17
+ "patternProperties": {
18
+ ".": {
19
+ "additionalProperties": false,
20
+ "required": ["max", "cells"],
21
+ "properties": {
22
+ "max": { "type": "number" },
23
+ "cells": { "$ref": "#/definitions/positiveFloatValues" }
24
+ }
25
+ }
26
+ }
27
+ }
@@ -0,0 +1,20 @@
1
+ {
2
+ "$schema": "http://json-schema.org/draft-07/schema#",
3
+ "$id": "https://github.com/vitessce/vitessce/#molecules",
4
+ "title": "Vitessce molecule data",
5
+ "type": "object",
6
+ "definitions": {
7
+ "coord": {
8
+ "type": "array",
9
+ "maxItems": 2,
10
+ "minItems": 2,
11
+ "items": { "type": "number" }
12
+ }
13
+ },
14
+ "patternProperties": {
15
+ ".": {
16
+ "type": "array",
17
+ "items": { "$ref": "#/definitions/coord" }
18
+ }
19
+ }
20
+ }
@@ -0,0 +1,28 @@
1
+ {
2
+ "$schema": "http://json-schema.org/draft-07/schema#",
3
+ "$id": "https://github.com/vitessce/vitessce/#neighborhoods",
4
+ "title": "Vitessce neighborhood data",
5
+ "type": "object",
6
+ "definitions": {
7
+ "coord": {
8
+ "type": "array",
9
+ "maxItems": 2,
10
+ "minItems": 2,
11
+ "items": { "type": "number" }
12
+ }
13
+ },
14
+ "patternProperties": {
15
+ ".": {
16
+ "additionalProperties": false,
17
+ "required": ["poly"],
18
+ "properties": {
19
+ "poly": {
20
+ "type": "array",
21
+ "maxItems": 3,
22
+ "minItems": 3,
23
+ "items": { "$ref": "#/definitions/coord" }
24
+ }
25
+ }
26
+ }
27
+ }
28
+ }
@@ -0,0 +1,45 @@
1
+ import { AbstractLoaderError, LoaderResult } from '@vitessce/vit-s';
2
+ import RasterLoader from './RasterJsonLoader';
3
+
4
+ export default class RasterJsonAsImageLoader extends RasterLoader {
5
+ async load() {
6
+ const loaderResult = await super.load().catch(reason => Promise.resolve(reason));
7
+ if (loaderResult instanceof AbstractLoaderError) {
8
+ return Promise.reject(loaderResult);
9
+ }
10
+ const { data = {}, url: urls, coordinationValues } = loaderResult;
11
+ const { loaders: allLoaders = [], meta: allMeta = [] } = data;
12
+
13
+ const loaders = [];
14
+ const meta = [];
15
+
16
+ // Only include non-bitmask items.
17
+ allMeta.forEach((layer, i) => {
18
+ if (!layer?.metadata?.isBitmask) {
19
+ loaders.push(allLoaders[i]);
20
+ meta.push(allMeta[i]);
21
+ }
22
+ });
23
+
24
+ if (!coordinationValues?.spatialImageLayer) {
25
+ console.warn('Could not initialize coordinationValues.spatialImageLayer in RasterJsonAsImageLoader. This may be an indicator that the image could not be loaded.');
26
+ }
27
+
28
+ return new LoaderResult(
29
+ {
30
+ image: (loaders.length > 0 && meta.length > 0 ? { loaders, meta } : null),
31
+ },
32
+ urls,
33
+ {
34
+ // Filter coordinationValues, keeping only non-bitmask layers.
35
+ spatialImageLayer: coordinationValues?.spatialImageLayer?.filter(l => l.type !== 'bitmask')
36
+ // Re-index since we removed the bitmask layers,
37
+ // so the indices may have gaps.
38
+ .map(layer => ({
39
+ ...layer,
40
+ index: meta.findIndex(metaItem => metaItem.name === allMeta[layer.index].name),
41
+ })),
42
+ },
43
+ );
44
+ }
45
+ }
@@ -0,0 +1,46 @@
1
+ import { AbstractLoaderError, LoaderResult } from '@vitessce/vit-s';
2
+ import RasterLoader from './RasterJsonLoader';
3
+
4
+ export default class RasterJsonAsObsSegmentationsLoader extends RasterLoader {
5
+ async load() {
6
+ const loaderResult = await super.load().catch(reason => Promise.resolve(reason));
7
+ if (loaderResult instanceof AbstractLoaderError) {
8
+ return Promise.reject(loaderResult);
9
+ }
10
+ const { data = {}, url: urls, coordinationValues } = loaderResult;
11
+ const { loaders: allLoaders = [], meta: allMeta = [] } = data;
12
+
13
+ const loaders = [];
14
+ const meta = [];
15
+
16
+ // Only include bitmask items.
17
+ allMeta.forEach((layer, i) => {
18
+ if (layer?.metadata?.isBitmask) {
19
+ loaders.push(allLoaders[i]);
20
+ meta.push(allMeta[i]);
21
+ }
22
+ });
23
+
24
+ if (!coordinationValues?.spatialImageLayer) {
25
+ console.warn('Could not initialize coordinationValues.spatialImageLayer in RasterJsonAsObsSegmentationsLoader. This may be an indicator that the image could not be loaded.');
26
+ }
27
+
28
+ return new LoaderResult(
29
+ {
30
+ obsSegmentationsType: 'bitmask',
31
+ obsSegmentations: (loaders.length > 0 && meta.length > 0 ? { loaders, meta } : null),
32
+ },
33
+ urls,
34
+ {
35
+ // Filter coordinationValues, keeping only bitmask layers.
36
+ spatialSegmentationLayer: coordinationValues?.spatialImageLayer?.filter(l => l.type === 'bitmask')
37
+ // Re-index since we removed the bitmask layers,
38
+ // so the indices may have gaps.
39
+ .map(layer => ({
40
+ ...layer,
41
+ index: meta.findIndex(metaItem => metaItem.name === allMeta[layer.index].name),
42
+ })),
43
+ },
44
+ );
45
+ }
46
+ }