@vitessce/zarr 3.5.2 → 3.5.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 (108) hide show
  1. package/dist/index.js +20559 -27
  2. package/dist-tsc/anndata-loaders/FeatureLabelsAnndataLoader.d.ts +2 -2
  3. package/dist-tsc/anndata-loaders/FeatureLabelsAnndataLoader.d.ts.map +1 -1
  4. package/dist-tsc/anndata-loaders/FeatureLabelsAnndataLoader.js +1 -1
  5. package/dist-tsc/anndata-loaders/ObsEmbeddingAnndataLoader.d.ts +2 -2
  6. package/dist-tsc/anndata-loaders/ObsEmbeddingAnndataLoader.d.ts.map +1 -1
  7. package/dist-tsc/anndata-loaders/ObsEmbeddingAnndataLoader.js +1 -1
  8. package/dist-tsc/anndata-loaders/ObsEmbeddingAnndataLoader.test.js +1 -1
  9. package/dist-tsc/anndata-loaders/ObsFeatureColumnsAnndataLoader.d.ts +2 -2
  10. package/dist-tsc/anndata-loaders/ObsFeatureColumnsAnndataLoader.d.ts.map +1 -1
  11. package/dist-tsc/anndata-loaders/ObsFeatureColumnsAnndataLoader.js +1 -1
  12. package/dist-tsc/anndata-loaders/ObsFeatureMatrixAnndataLoader.d.ts +2 -2
  13. package/dist-tsc/anndata-loaders/ObsFeatureMatrixAnndataLoader.d.ts.map +1 -1
  14. package/dist-tsc/anndata-loaders/ObsFeatureMatrixAnndataLoader.js +1 -1
  15. package/dist-tsc/anndata-loaders/ObsLabelsAnndataLoader.d.ts +2 -2
  16. package/dist-tsc/anndata-loaders/ObsLabelsAnndataLoader.d.ts.map +1 -1
  17. package/dist-tsc/anndata-loaders/ObsLabelsAnndataLoader.js +1 -1
  18. package/dist-tsc/anndata-loaders/ObsLocationsAnndataLoader.d.ts +2 -2
  19. package/dist-tsc/anndata-loaders/ObsLocationsAnndataLoader.d.ts.map +1 -1
  20. package/dist-tsc/anndata-loaders/ObsLocationsAnndataLoader.js +1 -1
  21. package/dist-tsc/anndata-loaders/ObsPointsAnndataLoader.d.ts +2 -2
  22. package/dist-tsc/anndata-loaders/ObsPointsAnndataLoader.d.ts.map +1 -1
  23. package/dist-tsc/anndata-loaders/ObsPointsAnndataLoader.js +1 -1
  24. package/dist-tsc/anndata-loaders/ObsSegmentationsAnndataLoader.d.ts +2 -2
  25. package/dist-tsc/anndata-loaders/ObsSegmentationsAnndataLoader.d.ts.map +1 -1
  26. package/dist-tsc/anndata-loaders/ObsSegmentationsAnndataLoader.js +2 -2
  27. package/dist-tsc/anndata-loaders/ObsSetsAnndataLoader.d.ts +2 -2
  28. package/dist-tsc/anndata-loaders/ObsSetsAnndataLoader.d.ts.map +1 -1
  29. package/dist-tsc/anndata-loaders/ObsSetsAnndataLoader.js +1 -1
  30. package/dist-tsc/anndata-loaders/ObsSpotsAnndataLoader.d.ts +2 -2
  31. package/dist-tsc/anndata-loaders/ObsSpotsAnndataLoader.d.ts.map +1 -1
  32. package/dist-tsc/anndata-loaders/ObsSpotsAnndataLoader.js +1 -1
  33. package/dist-tsc/anndata-loaders/SampleEdgesAnndataLoader.d.ts +2 -2
  34. package/dist-tsc/anndata-loaders/SampleEdgesAnndataLoader.d.ts.map +1 -1
  35. package/dist-tsc/anndata-loaders/SampleEdgesAnndataLoader.js +1 -1
  36. package/dist-tsc/genomic-loaders/GenomicProfilesZarrLoader.d.ts +1 -1
  37. package/dist-tsc/genomic-loaders/GenomicProfilesZarrLoader.d.ts.map +1 -1
  38. package/dist-tsc/genomic-loaders/GenomicProfilesZarrLoader.js +1 -1
  39. package/dist-tsc/index.d.ts +1 -4
  40. package/dist-tsc/index.js +1 -4
  41. package/dist-tsc/matrix-loaders/MatrixZarrAsObsFeatureMatrix.d.ts +2 -2
  42. package/dist-tsc/matrix-loaders/MatrixZarrAsObsFeatureMatrix.d.ts.map +1 -1
  43. package/dist-tsc/matrix-loaders/MatrixZarrAsObsFeatureMatrix.js +1 -1
  44. package/package.json +9 -11
  45. package/src/anndata-loaders/FeatureLabelsAnndataLoader.js +1 -1
  46. package/src/anndata-loaders/ObsEmbeddingAnndataLoader.js +1 -1
  47. package/src/anndata-loaders/ObsEmbeddingAnndataLoader.test.js +1 -1
  48. package/src/anndata-loaders/ObsFeatureColumnsAnndataLoader.js +1 -1
  49. package/src/anndata-loaders/ObsFeatureMatrixAnndataLoader.js +1 -1
  50. package/src/anndata-loaders/ObsLabelsAnndataLoader.js +1 -1
  51. package/src/anndata-loaders/ObsLocationsAnndataLoader.js +1 -1
  52. package/src/anndata-loaders/ObsPointsAnndataLoader.js +1 -1
  53. package/src/anndata-loaders/ObsSegmentationsAnndataLoader.js +2 -2
  54. package/src/anndata-loaders/ObsSetsAnndataLoader.js +1 -1
  55. package/src/anndata-loaders/ObsSpotsAnndataLoader.js +1 -1
  56. package/src/anndata-loaders/SampleEdgesAnndataLoader.js +1 -1
  57. package/src/genomic-loaders/GenomicProfilesZarrLoader.js +1 -1
  58. package/src/index.js +2 -4
  59. package/src/matrix-loaders/MatrixZarrAsObsFeatureMatrix.js +1 -1
  60. package/dist/deflate-d6c44024.js +0 -12
  61. package/dist/index-315714b8.js +0 -165788
  62. package/dist/jpeg-2118e67e.js +0 -839
  63. package/dist/lerc-48cfdf2b.js +0 -2013
  64. package/dist/lzw-10e7c9ff.js +0 -127
  65. package/dist/packbits-166dac1c.js +0 -29
  66. package/dist/pako.esm-68f84e2a.js +0 -4022
  67. package/dist/raw-155ab7ca.js +0 -11
  68. package/dist/webimage-f1ecb720.js +0 -31
  69. package/dist-tsc/SpatialDataShapesSource.d.ts +0 -75
  70. package/dist-tsc/SpatialDataShapesSource.d.ts.map +0 -1
  71. package/dist-tsc/SpatialDataShapesSource.js +0 -267
  72. package/dist-tsc/SpatialDataTableSource.d.ts +0 -43
  73. package/dist-tsc/SpatialDataTableSource.d.ts.map +0 -1
  74. package/dist-tsc/SpatialDataTableSource.js +0 -119
  75. package/dist-tsc/ome-loaders/OmeZarrAsObsSegmentationsLoader.d.ts +0 -13
  76. package/dist-tsc/ome-loaders/OmeZarrAsObsSegmentationsLoader.d.ts.map +0 -1
  77. package/dist-tsc/ome-loaders/OmeZarrAsObsSegmentationsLoader.js +0 -41
  78. package/dist-tsc/ome-loaders/OmeZarrLoader.d.ts +0 -16
  79. package/dist-tsc/ome-loaders/OmeZarrLoader.d.ts.map +0 -1
  80. package/dist-tsc/ome-loaders/OmeZarrLoader.js +0 -155
  81. package/dist-tsc/ome-loaders/index.d.ts +0 -3
  82. package/dist-tsc/ome-loaders/index.d.ts.map +0 -1
  83. package/dist-tsc/ome-loaders/index.js +0 -2
  84. package/dist-tsc/spatialdata-loaders/SpatialDataImageLoader.d.ts +0 -4
  85. package/dist-tsc/spatialdata-loaders/SpatialDataImageLoader.d.ts.map +0 -1
  86. package/dist-tsc/spatialdata-loaders/SpatialDataImageLoader.js +0 -9
  87. package/dist-tsc/spatialdata-loaders/SpatialDataLabelsLoader.d.ts +0 -4
  88. package/dist-tsc/spatialdata-loaders/SpatialDataLabelsLoader.d.ts.map +0 -1
  89. package/dist-tsc/spatialdata-loaders/SpatialDataLabelsLoader.js +0 -45
  90. package/dist-tsc/spatialdata-loaders/SpatialDataObsSetsLoader.d.ts +0 -9
  91. package/dist-tsc/spatialdata-loaders/SpatialDataObsSetsLoader.d.ts.map +0 -1
  92. package/dist-tsc/spatialdata-loaders/SpatialDataObsSetsLoader.js +0 -10
  93. package/dist-tsc/spatialdata-loaders/SpatialDataObsSpotsLoader.d.ts +0 -24
  94. package/dist-tsc/spatialdata-loaders/SpatialDataObsSpotsLoader.d.ts.map +0 -1
  95. package/dist-tsc/spatialdata-loaders/SpatialDataObsSpotsLoader.js +0 -185
  96. package/dist-tsc/spatialdata-loaders/index.d.ts +0 -5
  97. package/dist-tsc/spatialdata-loaders/index.d.ts.map +0 -1
  98. package/dist-tsc/spatialdata-loaders/index.js +0 -4
  99. package/src/SpatialDataShapesSource.js +0 -292
  100. package/src/SpatialDataTableSource.js +0 -135
  101. package/src/ome-loaders/OmeZarrAsObsSegmentationsLoader.js +0 -49
  102. package/src/ome-loaders/OmeZarrLoader.js +0 -208
  103. package/src/ome-loaders/index.js +0 -2
  104. package/src/spatialdata-loaders/SpatialDataImageLoader.js +0 -11
  105. package/src/spatialdata-loaders/SpatialDataLabelsLoader.js +0 -53
  106. package/src/spatialdata-loaders/SpatialDataObsSetsLoader.js +0 -11
  107. package/src/spatialdata-loaders/SpatialDataObsSpotsLoader.js +0 -228
  108. package/src/spatialdata-loaders/index.js +0 -4
@@ -1,11 +0,0 @@
1
- import { B as BaseDecoder } from "./index-315714b8.js";
2
- import "@vitessce/vit-s";
3
- import "react";
4
- class RawDecoder extends BaseDecoder {
5
- decodeBlock(buffer) {
6
- return buffer;
7
- }
8
- }
9
- export {
10
- RawDecoder as default
11
- };
@@ -1,31 +0,0 @@
1
- import { B as BaseDecoder } from "./index-315714b8.js";
2
- import "@vitessce/vit-s";
3
- import "react";
4
- class WebImageDecoder extends BaseDecoder {
5
- constructor() {
6
- super();
7
- if (typeof createImageBitmap === "undefined") {
8
- throw new Error("Cannot decode WebImage as `createImageBitmap` is not available");
9
- } else if (typeof document === "undefined" && typeof OffscreenCanvas === "undefined") {
10
- throw new Error("Cannot decode WebImage as neither `document` nor `OffscreenCanvas` is not available");
11
- }
12
- }
13
- async decode(fileDirectory, buffer) {
14
- const blob = new Blob([buffer]);
15
- const imageBitmap = await createImageBitmap(blob);
16
- let canvas;
17
- if (typeof document !== "undefined") {
18
- canvas = document.createElement("canvas");
19
- canvas.width = imageBitmap.width;
20
- canvas.height = imageBitmap.height;
21
- } else {
22
- canvas = new OffscreenCanvas(imageBitmap.width, imageBitmap.height);
23
- }
24
- const ctx = canvas.getContext("2d");
25
- ctx.drawImage(imageBitmap, 0, 0);
26
- return ctx.getImageData(0, 0, imageBitmap.width, imageBitmap.height).data.buffer;
27
- }
28
- }
29
- export {
30
- WebImageDecoder as default
31
- };
@@ -1,75 +0,0 @@
1
- /**
2
- *
3
- * @param {string|undefined} arrPath
4
- * @returns
5
- */
6
- export function getIndexPath(arrPath: string | undefined): string;
7
- /**
8
- *
9
- * @param {string|undefined} arrPath
10
- * @returns
11
- */
12
- export function getVarPath(arrPath: string | undefined): string;
13
- /**
14
- *
15
- * @param {string|undefined} arrPath
16
- * @returns
17
- */
18
- export function getParquetPath(arrPath: string | undefined): string;
19
- /**
20
- *
21
- * @param {string|undefined} arrPath
22
- * @returns
23
- */
24
- export function getAttrsPath(arrPath: string | undefined): string;
25
- export default class SpatialDataShapesSource extends AnnDataSource {
26
- /** @type {{ [k: string]: Promise<string[]> }} */
27
- obsIndices: {
28
- [k: string]: Promise<string[]>;
29
- };
30
- /** @type {{ [k: string]: Promise<string[]> }} */
31
- varIndices: {
32
- [k: string]: Promise<string[]>;
33
- };
34
- /** @type {{ [k: string]: string[] }} */
35
- varAliases: {
36
- [k: string]: string[];
37
- };
38
- /**
39
- *
40
- * @param {string} tablePath
41
- * @returns
42
- */
43
- loadSpatialDataAttrs(tablePath: string): Promise<{
44
- [k: string]: string | string[] | null;
45
- }>;
46
- /**
47
- *
48
- * @param {string} path A path to within shapes.
49
- * @returns {Promise<"0.1"|"0.2">} The format version.
50
- */
51
- getFormatVersion(path: string): Promise<"0.1" | "0.2">;
52
- /**
53
- *
54
- * @param {string} path A path to an array within shapes.
55
- * @returns
56
- */
57
- loadParquetTable(path: string): Promise<import("apache-arrow").Table<any>>;
58
- parquetTable: import("apache-arrow").Table<any> | undefined;
59
- /**
60
- * Class method for loading the obs index.
61
- * @param {string|undefined} path
62
- * @param {string|undefined} tablePath
63
- * @returns {Promise<string[]>} An promise for a zarr array containing the indices.
64
- */
65
- loadObsIndex(path?: string | undefined, tablePath?: string | undefined): Promise<string[]>;
66
- /**
67
- * Class method for loading the var alias.
68
- * @param {string} varPath
69
- * @param {string} matrixPath
70
- * @returns {Promise<string[]>} An promise for a zarr array containing the aliased names.
71
- */
72
- loadVarAlias(varPath: string, matrixPath: string): Promise<string[]>;
73
- }
74
- import AnnDataSource from './AnnDataSource.js';
75
- //# sourceMappingURL=SpatialDataShapesSource.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"SpatialDataShapesSource.d.ts","sourceRoot":"","sources":["../src/SpatialDataShapesSource.js"],"names":[],"mappings":"AAyDA;;;;GAIG;AACH,sCAHW,MAAM,GAAC,SAAS,UAK1B;AAED;;;;GAIG;AACH,oCAHW,MAAM,GAAC,SAAS,UAK1B;AAED;;;;GAIG;AACH,wCAHW,MAAM,GAAC,SAAS,UAK1B;AAED;;;;GAIG;AACH,sCAHW,MAAM,GAAC,SAAS,UAK1B;AAGD;IAOI,iDAAiD;IACjD,YADW;QAAE,CAAC,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC,CAAA;KAAE,CACzB;IACpB,iDAAiD;IACjD,YADW;QAAE,CAAC,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC,CAAA;KAAE,CACzB;IACpB,wCAAwC;IACxC,YADW;QAAE,CAAC,CAAC,EAAE,MAAM,GAAG,MAAM,EAAE,CAAA;KAAE,CAChB;IAGtB;;;;OAIG;IACH,gCAHW,MAAM;;OAKhB;IAED;;;;OAIG;IACH,uBAHW,MAAM,GACJ,OAAO,CAAC,KAAK,GAAC,KAAK,CAAC,CAWhC;IAED;;;;OAIG;IACH,uBAHW,MAAM,8CAmBhB;IAFC,4DAA8B;IAIhC;;;;;OAKG;IACH,oBAJW,MAAM,GAAC,SAAS,cAChB,MAAM,GAAC,SAAS,GACd,OAAO,CAAC,MAAM,EAAE,CAAC,CA2B7B;IAqFD;;;;;OAKG;IACH,sBAJW,MAAM,cACN,MAAM,GACJ,OAAO,CAAC,MAAM,EAAE,CAAC,CAa7B;CACF;0BA7RyB,oBAAoB"}
@@ -1,267 +0,0 @@
1
- // @ts-check
2
- /* eslint-disable no-underscore-dangle */
3
- /* eslint-disable import/no-unresolved */
4
- /* eslint-disable no-undef */
5
- import { tableFromIPC } from 'apache-arrow';
6
- import WKB from 'ol/format/WKB.js';
7
- import AnnDataSource from './AnnDataSource.js';
8
- import { basename } from './utils.js';
9
- /** @import { DataSourceParams } from '@vitessce/types' */
10
- /** @import { TypedArray as ZarrTypedArray, Chunk } from '@zarrita/core' */
11
- async function getReadParquet() {
12
- // Reference: https://observablehq.com/@kylebarron/geoparquet-on-the-web
13
- // TODO: host somewhere we control, like cdn.vitessce.io?
14
- // @ts-ignore
15
- const module = await import(/* webpackIgnore: true */ 'https://unpkg.com/parquet-wasm@0.6.1/esm/parquet_wasm.js');
16
- await module.default();
17
- // We cannot use regulary dynamic import here because it breaks NextJS builds
18
- // due to pointing to a remote URL.
19
- // I could not figure out a NextJS webpack configuration to resolve it.
20
- // The following becomes inlined by Vite in library mode
21
- // eliminating the benefit of dynamic import.
22
- // Reference: https://github.com/vitejs/vite/issues/4454
23
- // const responsePromise = await fetch(
24
- // new URL('parquet-wasm/esm/parquet_wasm_bg.wasm', import.meta.url).href
25
- // );
26
- // const responsePromise = await fetch('https://unpkg.com/parquet-wasm@0.6.1/esm/parquet_wasm_bg.wasm');
27
- // const wasmBuffer = await responsePromise.arrayBuffer();
28
- // module.initSync(wasmBuffer);
29
- // Another issue is that when we import parquet-wasm JS from node_modules,
30
- // running module.default there is a MIME type issue because the Vite dev
31
- // server does not serve the .wasm with a MIME type of application/wasm.
32
- // I can't seem to get a custom Vite plugin that sets the MIME type in
33
- // request headers to work.
34
- return module.readParquet;
35
- }
36
- // If the array path starts with table/something/rest
37
- // capture table/something.
38
- const regex = /^shapes\/([^/]*)\/(.*)$/;
39
- /**
40
- *
41
- * @param {string|undefined} arrPath
42
- * @returns
43
- */
44
- function getShapesPrefix(arrPath) {
45
- if (arrPath) {
46
- const matches = arrPath.match(regex);
47
- if (matches && matches.length === 3) {
48
- return `shapes/${matches[1]}/`;
49
- }
50
- }
51
- return '';
52
- }
53
- /**
54
- *
55
- * @param {string|undefined} arrPath
56
- * @returns
57
- */
58
- export function getIndexPath(arrPath) {
59
- return `${getShapesPrefix(arrPath)}Index`;
60
- }
61
- /**
62
- *
63
- * @param {string|undefined} arrPath
64
- * @returns
65
- */
66
- export function getVarPath(arrPath) {
67
- return `${getShapesPrefix(arrPath)}var`;
68
- }
69
- /**
70
- *
71
- * @param {string|undefined} arrPath
72
- * @returns
73
- */
74
- export function getParquetPath(arrPath) {
75
- return `${getShapesPrefix(arrPath)}shapes.parquet`;
76
- }
77
- /**
78
- *
79
- * @param {string|undefined} arrPath
80
- * @returns
81
- */
82
- export function getAttrsPath(arrPath) {
83
- return `${getShapesPrefix(arrPath)}.zattrs`;
84
- }
85
- export default class SpatialDataShapesSource extends AnnDataSource {
86
- /**
87
- *
88
- * @param {DataSourceParams} params
89
- */
90
- constructor(params) {
91
- super(params);
92
- /** @type {{ [k: string]: Promise<string[]> }} */
93
- this.obsIndices = {};
94
- /** @type {{ [k: string]: Promise<string[]> }} */
95
- this.varIndices = {};
96
- /** @type {{ [k: string]: string[] }} */
97
- this.varAliases = {};
98
- }
99
- /**
100
- *
101
- * @param {string} tablePath
102
- * @returns
103
- */
104
- async loadSpatialDataAttrs(tablePath) {
105
- return this._loadDict(`${tablePath}/uns/spatialdata_attrs`, ['instance_key', 'region', 'region_key']);
106
- }
107
- /**
108
- *
109
- * @param {string} path A path to within shapes.
110
- * @returns {Promise<"0.1"|"0.2">} The format version.
111
- */
112
- async getFormatVersion(path) {
113
- const zattrs = await this.getJson(getAttrsPath(path));
114
- const formatVersion = zattrs.spatialdata_attrs.version;
115
- if (!(formatVersion === '0.1' || formatVersion === '0.2')) {
116
- throw new Error(`Unexpected version for shapes spatialdata_attrs: ${formatVersion}`);
117
- }
118
- return formatVersion;
119
- }
120
- /**
121
- *
122
- * @param {string} path A path to an array within shapes.
123
- * @returns
124
- */
125
- async loadParquetTable(path) {
126
- if (this.parquetTable) {
127
- // Return cached table if present.
128
- return this.parquetTable;
129
- }
130
- const readParquet = await getReadParquet();
131
- const parquetPath = getParquetPath(path);
132
- const parquetBytes = await this.storeRoot.store.get(`/${parquetPath}`);
133
- if (!parquetBytes) {
134
- throw new Error('Failed to load parquet data from store.');
135
- }
136
- const wasmTable = readParquet(parquetBytes);
137
- // TODO: use streaming?
138
- const arrowTable = tableFromIPC(wasmTable.intoIPCStream());
139
- this.parquetTable = arrowTable;
140
- return this.parquetTable;
141
- }
142
- /**
143
- * Class method for loading the obs index.
144
- * @param {string|undefined} path
145
- * @param {string|undefined} tablePath
146
- * @returns {Promise<string[]>} An promise for a zarr array containing the indices.
147
- */
148
- async loadObsIndex(path = undefined, tablePath = undefined) {
149
- let indexPath = getIndexPath(path);
150
- if (tablePath) {
151
- // TODO: given a path to the shapes,
152
- // is there a better way to know which table annotates it
153
- // (without the manually-specified table path)?
154
- // Reference: https://github.com/scverse/spatialdata/issues/298#issuecomment-1718161329
155
- const obsPath = `${tablePath}/obs`;
156
- const { _index } = await this.getJson(`${obsPath}/.zattrs`);
157
- indexPath = `${obsPath}/${_index}`;
158
- const { instance_key: instanceKey,
159
- // TODO: filter table index by region and element type.
160
- // region_key: regionKey,
161
- // region,
162
- } = await this.loadSpatialDataAttrs(tablePath);
163
- indexPath = `${obsPath}/${instanceKey}`;
164
- }
165
- if (indexPath in this.obsIndices) {
166
- return this.obsIndices[indexPath];
167
- }
168
- // TODO: support loading from parquet if no tablePath was provided.
169
- this.obsIndices[indexPath] = this._loadColumn(indexPath);
170
- return this.obsIndices[indexPath];
171
- }
172
- /**
173
- * Class method for loading general numeric arrays.
174
- * @param {string} path A string like obsm.X_pca.
175
- * @returns {Promise<Chunk<any>>} A promise for a zarr array containing the data.
176
- */
177
- async loadNumeric(path) {
178
- const formatVersion = await this.getFormatVersion(path);
179
- if (formatVersion === '0.1') {
180
- return super.loadNumeric(path);
181
- }
182
- const arrowTable = await this.loadParquetTable(path);
183
- const columnArr = arrowTable.getChild(basename(path))?.toArray();
184
- return {
185
- shape: [columnArr.length],
186
- // TODO: support other kinds of TypedArrays via @vitessce/arrow-utils.
187
- data: new Float32Array(columnArr),
188
- stride: [1],
189
- };
190
- }
191
- /**
192
- * Class method for loading specific columns of numeric arrays.
193
- * @param {string} path A string like obsm.X_pca.
194
- * @param {[number, number]} dims The column indices to load.
195
- * @returns {Promise<{
196
- * data: [ZarrTypedArray<any>, ZarrTypedArray<any>],
197
- * shape: [number, number],
198
- * }>} A promise for a zarr array containing the data.
199
- */
200
- async loadNumericForDims(path, dims) {
201
- const formatVersion = await this.getFormatVersion(path);
202
- if (formatVersion === '0.1') {
203
- return super.loadNumericForDims(path, dims);
204
- }
205
- let columnName = basename(path);
206
- if (columnName === 'coords') {
207
- // The "geometry" column was previously called "coords" in version 0.1.
208
- columnName = 'geometry';
209
- }
210
- const arrowTable = await this.loadParquetTable(path);
211
- if (columnName === 'geometry' && dims[0] === 0 && dims[1] === 1) {
212
- const geometryColumn = arrowTable.getChild(columnName);
213
- if (!geometryColumn) {
214
- throw new Error(`Column ${columnName} not found in parquet table`);
215
- }
216
- if (geometryColumn.type.toString() !== 'Binary') {
217
- throw new Error(`Expected geometry column to have Binary type (WKB) but got ${geometryColumn.type.toString()}`);
218
- }
219
- // From GeoPandas.to_parquet docs:
220
- // "By default, all geometry columns present are serialized to WKB format in the file"
221
- // Reference: https://geopandas.org/en/stable/docs/reference/api/geopandas.GeoDataFrame.to_parquet.html
222
- // TODO: support geoarrow serialization schemes in addition to WKB.
223
- const wkb = new WKB();
224
- const points = geometryColumn.toArray()
225
- // @ts-ignore
226
- .map((/** @type {Uint8Array} */ geom) => wkb.readGeometry(geom).getFlatCoordinates());
227
- return {
228
- shape: [2, points.length],
229
- data: [
230
- new Float32Array(points.map((/** @type {[number, number]} */ p) => p[0])),
231
- new Float32Array(points.map((/** @type {[number, number]} */ p) => p[1])),
232
- ],
233
- };
234
- }
235
- throw new Error('Unexpected column name for loading 2D array from parquet, currently only geometry is supported');
236
- }
237
- /**
238
- * Class method for loading the var index.
239
- * @param {string|undefined} path
240
- * @returns {Promise<string[]>} An promise for a zarr array containing the indices.
241
- */
242
- loadVarIndex(path = undefined) {
243
- const varPath = getVarPath(path);
244
- if (varPath in this.varIndices) {
245
- return this.varIndices[varPath];
246
- }
247
- this.varIndices[varPath] = this.getJson(`${varPath}/.zattrs`)
248
- .then(({ _index }) => this.getFlatArrDecompressed(`${varPath}/${_index}`));
249
- return this.varIndices[varPath];
250
- }
251
- /**
252
- * Class method for loading the var alias.
253
- * @param {string} varPath
254
- * @param {string} matrixPath
255
- * @returns {Promise<string[]>} An promise for a zarr array containing the aliased names.
256
- */
257
- async loadVarAlias(varPath, matrixPath) {
258
- if (varPath in this.varAliases) {
259
- return this.varAliases[varPath];
260
- }
261
- const [varAliasData] = await this.loadVarColumns([varPath]);
262
- this.varAliases[varPath] = /** @type {string[]} */ (varAliasData);
263
- const index = await this.loadVarIndex(matrixPath);
264
- this.varAliases[varPath] = this.varAliases[varPath].map((val, ind) => (val ? val.concat(` (${index[ind]})`) : index[ind]));
265
- return this.varAliases[varPath];
266
- }
267
- }
@@ -1,43 +0,0 @@
1
- /**
2
- *
3
- * @param {string|undefined} arrPath
4
- * @returns
5
- */
6
- export function getObsPath(arrPath: string | undefined): string;
7
- /**
8
- *
9
- * @param {string|undefined} arrPath
10
- * @returns
11
- */
12
- export function getVarPath(arrPath: string | undefined): string;
13
- export default class SpatialDataTableSource extends AnnDataSource {
14
- /** @type {{ [k: string]: Promise<string[]> }} */
15
- obsIndices: {
16
- [k: string]: Promise<string[]>;
17
- };
18
- /** @type {{ [k: string]: Promise<string[]> }} */
19
- varIndices: {
20
- [k: string]: Promise<string[]>;
21
- };
22
- /** @type {{ [k: string]: string[] }} */
23
- varAliases: {
24
- [k: string]: string[];
25
- };
26
- /**
27
- *
28
- * @param {string} tablePath
29
- * @returns
30
- */
31
- loadSpatialDataAttrs(tablePath: string): Promise<{
32
- [k: string]: string | string[] | null;
33
- }>;
34
- /**
35
- * Class method for loading the var alias.
36
- * @param {string} varPath
37
- * @param {string} matrixPath
38
- * @returns {Promise<string[]>} An promise for a zarr array containing the aliased names.
39
- */
40
- loadVarAlias(varPath: string, matrixPath: string): Promise<string[]>;
41
- }
42
- import AnnDataSource from './AnnDataSource.js';
43
- //# sourceMappingURL=SpatialDataTableSource.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"SpatialDataTableSource.d.ts","sourceRoot":"","sources":["../src/SpatialDataTableSource.js"],"names":[],"mappings":"AAiCA;;;;GAIG;AACH,oCAHW,MAAM,GAAC,SAAS,UAK1B;AAED;;;;GAIG;AACH,oCAHW,MAAM,GAAC,SAAS,UAK1B;AAED;IAOI,iDAAiD;IACjD,YADW;QAAE,CAAC,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC,CAAA;KAAE,CACzB;IACpB,iDAAiD;IACjD,YADW;QAAE,CAAC,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC,CAAA;KAAE,CACzB;IACpB,wCAAwC;IACxC,YADW;QAAE,CAAC,CAAC,EAAE,MAAM,GAAG,MAAM,EAAE,CAAA;KAAE,CAChB;IAGtB;;;;OAIG;IACH,gCAHW,MAAM;;OAKhB;IA2CD;;;;;OAKG;IACH,sBAJW,MAAM,cACN,MAAM,GACJ,OAAO,CAAC,MAAM,EAAE,CAAC,CAa7B;CACF;0BApIyB,oBAAoB"}
@@ -1,119 +0,0 @@
1
- // @ts-check
2
- /* eslint-disable no-underscore-dangle */
3
- import AnnDataSource from './AnnDataSource.js';
4
- /** @import { DataSourceParams } from '@vitessce/types' */
5
- // If the array path starts with table/something/rest
6
- // capture table/something.
7
- const pluralRegex = /^tables\/([^/]*)\/(.*)$/;
8
- const singularRegex = /^table\/([^/]*)\/(.*)$/;
9
- /**
10
- *
11
- * @param {string|undefined} arrPath
12
- * @returns
13
- */
14
- function getTablePrefix(arrPath) {
15
- if (arrPath) {
16
- // First try the plural "tables/{something}"
17
- const pluralMatches = arrPath.match(pluralRegex);
18
- if (pluralMatches && pluralMatches.length === 3) {
19
- return `tables/${pluralMatches[1]}/`;
20
- }
21
- const singularMatches = arrPath.match(singularRegex);
22
- if (singularMatches && singularMatches.length === 3) {
23
- return `table/${singularMatches[1]}/`;
24
- }
25
- }
26
- // TODO: what to do here when there are multiple tables?
27
- // ObsSetsAnndataLoader will need to pass a path to loadObsIndex().
28
- return 'table/table/';
29
- }
30
- /**
31
- *
32
- * @param {string|undefined} arrPath
33
- * @returns
34
- */
35
- export function getObsPath(arrPath) {
36
- return `${getTablePrefix(arrPath)}obs`;
37
- }
38
- /**
39
- *
40
- * @param {string|undefined} arrPath
41
- * @returns
42
- */
43
- export function getVarPath(arrPath) {
44
- return `${getTablePrefix(arrPath)}var`;
45
- }
46
- export default class SpatialDataTableSource extends AnnDataSource {
47
- /**
48
- *
49
- * @param {DataSourceParams} params
50
- */
51
- constructor(params) {
52
- super(params);
53
- /** @type {{ [k: string]: Promise<string[]> }} */
54
- this.obsIndices = {};
55
- /** @type {{ [k: string]: Promise<string[]> }} */
56
- this.varIndices = {};
57
- /** @type {{ [k: string]: string[] }} */
58
- this.varAliases = {};
59
- }
60
- /**
61
- *
62
- * @param {string} tablePath
63
- * @returns
64
- */
65
- async loadSpatialDataAttrs(tablePath) {
66
- return this._loadDict(`${tablePath}uns/spatialdata_attrs`, ['instance_key', 'region', 'region_key']);
67
- }
68
- /**
69
- * Class method for loading the obs index.
70
- * @param {string|undefined} path
71
- * @returns {Promise<string[]>} An promise for a zarr array containing the indices.
72
- */
73
- async loadObsIndex(path = undefined) {
74
- const obsPath = getObsPath(path);
75
- const { _index } = await this.getJson(`${obsPath}/.zattrs`);
76
- let indexPath = `${obsPath}/${_index}`;
77
- const { instance_key: instanceKey,
78
- // TODO: filter table index by region and element type.
79
- // region_key: regionKey,
80
- // region,
81
- } = await this.loadSpatialDataAttrs(getTablePrefix(path));
82
- indexPath = `${obsPath}/${instanceKey}`;
83
- if (indexPath in this.obsIndices) {
84
- return this.obsIndices[indexPath];
85
- }
86
- this.obsIndices[indexPath] = this._loadColumn(indexPath);
87
- return this.obsIndices[indexPath];
88
- }
89
- /**
90
- * Class method for loading the var index.
91
- * @param {string|undefined} path
92
- * @returns {Promise<string[]>} An promise for a zarr array containing the indices.
93
- */
94
- loadVarIndex(path = undefined) {
95
- const varPath = getVarPath(path);
96
- if (varPath in this.varIndices) {
97
- return this.varIndices[varPath];
98
- }
99
- this.varIndices[varPath] = this.getJson(`${varPath}/.zattrs`)
100
- .then(({ _index }) => this.getFlatArrDecompressed(`${varPath}/${_index}`));
101
- return this.varIndices[varPath];
102
- }
103
- /**
104
- * Class method for loading the var alias.
105
- * @param {string} varPath
106
- * @param {string} matrixPath
107
- * @returns {Promise<string[]>} An promise for a zarr array containing the aliased names.
108
- */
109
- async loadVarAlias(varPath, matrixPath) {
110
- if (varPath in this.varAliases) {
111
- return this.varAliases[varPath];
112
- }
113
- const [varAliasData] = await this.loadVarColumns([varPath]);
114
- this.varAliases[varPath] = /** @type {string[]} */ (varAliasData);
115
- const index = await this.loadVarIndex(matrixPath);
116
- this.varAliases[varPath] = this.varAliases[varPath].map((val, ind) => (val ? val.concat(` (${index[ind]})`) : index[ind]));
117
- return this.varAliases[varPath];
118
- }
119
- }
@@ -1,13 +0,0 @@
1
- export default class OmeZarrAsObsSegmentationsLoader extends OmeZarrLoader {
2
- load(): Promise<LoaderResult<{
3
- obsSegmentationsType: string;
4
- obsSegmentations: {
5
- loaders: any;
6
- meta: any;
7
- instance: import("@vitessce/image-utils").ImageWrapper;
8
- };
9
- }>>;
10
- }
11
- import OmeZarrLoader from './OmeZarrLoader.js';
12
- import { LoaderResult } from '@vitessce/vit-s';
13
- //# sourceMappingURL=OmeZarrAsObsSegmentationsLoader.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"OmeZarrAsObsSegmentationsLoader.d.ts","sourceRoot":"","sources":["../../src/ome-loaders/OmeZarrAsObsSegmentationsLoader.js"],"names":[],"mappings":"AAIA;IACE;;;;;;;QA0CC;CACF;0BA9CyB,oBAAoB;6BADjB,iBAAiB"}
@@ -1,41 +0,0 @@
1
- import { CoordinationLevel as CL } from '@vitessce/config';
2
- import { LoaderResult } from '@vitessce/vit-s';
3
- import OmeZarrLoader from './OmeZarrLoader.js';
4
- export default class OmeZarrAsObsSegmentationsLoader extends OmeZarrLoader {
5
- async load() {
6
- const { obsTypesFromChannelNames } = this.options || {};
7
- const result = await super.load();
8
- const imageWrapper = result.data.image.instance;
9
- const channelObjects = imageWrapper.getChannelObjects();
10
- const channelCoordination = channelObjects.slice(0, 5).map((channelObj, i) => ({
11
- spatialTargetC: i,
12
- spatialChannelColor: (channelObj.defaultColor || channelObj.autoDefaultColor).slice(0, 3),
13
- spatialChannelVisible: true,
14
- spatialChannelOpacity: 1.0,
15
- spatialChannelWindow: channelObj.defaultWindow || null,
16
- // featureType: 'feature',
17
- // featureValueType: 'value',
18
- obsColorEncoding: 'spatialChannelColor',
19
- spatialSegmentationFilled: true,
20
- spatialSegmentationStrokeWidth: 1.0,
21
- obsHighlight: null,
22
- ...(obsTypesFromChannelNames ? { obsType: channelObj.name } : {}),
23
- }));
24
- const coordinationValues = {
25
- spatialTargetZ: imageWrapper.getDefaultTargetZ(),
26
- spatialTargetT: imageWrapper.getDefaultTargetT(),
27
- segmentationLayer: CL([
28
- {
29
- fileUid: this.coordinationValues?.fileUid || null,
30
- spatialLayerOpacity: 1.0,
31
- spatialLayerVisible: true,
32
- segmentationChannel: CL(channelCoordination),
33
- },
34
- ]),
35
- };
36
- return Promise.resolve(new LoaderResult({
37
- obsSegmentationsType: 'bitmask',
38
- obsSegmentations: result.data.image,
39
- }, result.url, coordinationValues));
40
- }
41
- }
@@ -1,16 +0,0 @@
1
- export default class OmeZarrLoader extends AbstractTwoStepLoader<any> {
2
- constructor(dataSource: any, params: any);
3
- storeRoot: any;
4
- load(): Promise<LoaderResult<{
5
- image: {
6
- loaders: any;
7
- meta: any;
8
- instance: ImageWrapper;
9
- };
10
- featureIndex: string[];
11
- }>>;
12
- }
13
- import { AbstractTwoStepLoader } from '@vitessce/vit-s';
14
- import { ImageWrapper } from '@vitessce/image-utils';
15
- import { LoaderResult } from '@vitessce/vit-s';
16
- //# sourceMappingURL=OmeZarrLoader.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"OmeZarrLoader.d.ts","sourceRoot":"","sources":["../../src/ome-loaders/OmeZarrLoader.js"],"names":[],"mappings":"AAmBA;IACE,0CAGC;IADC,eAA0C;IAG5C;;;;;;;QAqLC;CACF;sCAhMM,iBAAiB;6BALjB,uBAAuB;6BAKvB,iBAAiB"}