@vitessce/zarr 3.3.9 → 3.3.10

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 (75) hide show
  1. package/dist/{deflate-2f7f502f.js → deflate-b162c7aa.js} +1 -1
  2. package/dist/{index-200d5108.js → index-184aee21.js} +290 -124
  3. package/dist/index.js +1 -1
  4. package/dist/{jpeg-3ff942a5.js → jpeg-dbb0f9d9.js} +1 -1
  5. package/dist/{lerc-762cc666.js → lerc-e45d57dc.js} +1 -1
  6. package/dist/{lzw-97464fce.js → lzw-05e88e18.js} +1 -1
  7. package/dist/{packbits-daaf8f04.js → packbits-922f4592.js} +1 -1
  8. package/dist/{raw-8fdba750.js → raw-a8de9c08.js} +1 -1
  9. package/dist/{webimage-e98ea52f.js → webimage-27013e2d.js} +1 -1
  10. package/dist-tsc/AnnDataSource.d.ts +96 -30
  11. package/dist-tsc/AnnDataSource.d.ts.map +1 -1
  12. package/dist-tsc/AnnDataSource.js +147 -53
  13. package/dist-tsc/MuDataSource.d.ts +1 -1
  14. package/dist-tsc/MuDataSource.d.ts.map +1 -1
  15. package/dist-tsc/SpatialDataShapesSource.d.ts +40 -12
  16. package/dist-tsc/SpatialDataShapesSource.d.ts.map +1 -1
  17. package/dist-tsc/SpatialDataShapesSource.js +58 -27
  18. package/dist-tsc/SpatialDataTableSource.d.ts +35 -14
  19. package/dist-tsc/SpatialDataTableSource.d.ts.map +1 -1
  20. package/dist-tsc/SpatialDataTableSource.js +57 -27
  21. package/dist-tsc/ZarrDataSource.d.ts +22 -11
  22. package/dist-tsc/ZarrDataSource.d.ts.map +1 -1
  23. package/dist-tsc/ZarrDataSource.js +20 -3
  24. package/dist-tsc/anndata-loaders/FeatureLabelsAnndataLoader.d.ts +18 -5
  25. package/dist-tsc/anndata-loaders/FeatureLabelsAnndataLoader.d.ts.map +1 -1
  26. package/dist-tsc/anndata-loaders/FeatureLabelsAnndataLoader.js +12 -4
  27. package/dist-tsc/anndata-loaders/ObsEmbeddingAnndataLoader.d.ts +22 -5
  28. package/dist-tsc/anndata-loaders/ObsEmbeddingAnndataLoader.d.ts.map +1 -1
  29. package/dist-tsc/anndata-loaders/ObsEmbeddingAnndataLoader.js +13 -5
  30. package/dist-tsc/anndata-loaders/ObsFeatureColumnsAnndataLoader.d.ts +9 -2
  31. package/dist-tsc/anndata-loaders/ObsFeatureColumnsAnndataLoader.d.ts.map +1 -1
  32. package/dist-tsc/anndata-loaders/ObsFeatureMatrixAnndataLoader.d.ts +9 -2
  33. package/dist-tsc/anndata-loaders/ObsFeatureMatrixAnndataLoader.d.ts.map +1 -1
  34. package/dist-tsc/anndata-loaders/ObsLabelsAnndataLoader.d.ts +8 -2
  35. package/dist-tsc/anndata-loaders/ObsLabelsAnndataLoader.d.ts.map +1 -1
  36. package/dist-tsc/anndata-loaders/ObsLocationsAnndataLoader.d.ts +8 -2
  37. package/dist-tsc/anndata-loaders/ObsLocationsAnndataLoader.d.ts.map +1 -1
  38. package/dist-tsc/anndata-loaders/ObsPointsAnndataLoader.d.ts +8 -2
  39. package/dist-tsc/anndata-loaders/ObsPointsAnndataLoader.d.ts.map +1 -1
  40. package/dist-tsc/anndata-loaders/ObsSegmentationsAnndataLoader.d.ts +9 -2
  41. package/dist-tsc/anndata-loaders/ObsSegmentationsAnndataLoader.d.ts.map +1 -1
  42. package/dist-tsc/anndata-loaders/ObsSetsAnndataLoader.d.ts +10 -3
  43. package/dist-tsc/anndata-loaders/ObsSetsAnndataLoader.d.ts.map +1 -1
  44. package/dist-tsc/anndata-loaders/ObsSpotsAnndataLoader.d.ts +8 -2
  45. package/dist-tsc/anndata-loaders/ObsSpotsAnndataLoader.d.ts.map +1 -1
  46. package/dist-tsc/anndata-loaders/SampleEdgesAnndataLoader.d.ts +8 -2
  47. package/dist-tsc/anndata-loaders/SampleEdgesAnndataLoader.d.ts.map +1 -1
  48. package/dist-tsc/genomic-loaders/GenomicProfilesZarrLoader.d.ts +3 -1
  49. package/dist-tsc/genomic-loaders/GenomicProfilesZarrLoader.d.ts.map +1 -1
  50. package/dist-tsc/matrix-loaders/MatrixZarrAsObsFeatureMatrix.d.ts +9 -2
  51. package/dist-tsc/matrix-loaders/MatrixZarrAsObsFeatureMatrix.d.ts.map +1 -1
  52. package/dist-tsc/ome-loaders/OmeZarrAsObsSegmentationsLoader.d.ts +10 -1
  53. package/dist-tsc/ome-loaders/OmeZarrAsObsSegmentationsLoader.d.ts.map +1 -1
  54. package/dist-tsc/ome-loaders/OmeZarrLoader.d.ts +12 -2
  55. package/dist-tsc/ome-loaders/OmeZarrLoader.d.ts.map +1 -1
  56. package/dist-tsc/ome-loaders/OmeZarrLoader.js +2 -2
  57. package/dist-tsc/spatialdata-loaders/SpatialDataImageLoader.d.ts +1 -1
  58. package/dist-tsc/spatialdata-loaders/SpatialDataImageLoader.d.ts.map +1 -1
  59. package/dist-tsc/spatialdata-loaders/SpatialDataLabelsLoader.d.ts +1 -1
  60. package/dist-tsc/spatialdata-loaders/SpatialDataLabelsLoader.d.ts.map +1 -1
  61. package/dist-tsc/spatialdata-loaders/SpatialDataObsSetsLoader.d.ts +1 -2
  62. package/dist-tsc/spatialdata-loaders/SpatialDataObsSetsLoader.d.ts.map +1 -1
  63. package/dist-tsc/spatialdata-loaders/SpatialDataObsSpotsLoader.d.ts +8 -2
  64. package/dist-tsc/spatialdata-loaders/SpatialDataObsSpotsLoader.d.ts.map +1 -1
  65. package/dist-tsc/utils.d.ts +14 -2
  66. package/dist-tsc/utils.d.ts.map +1 -1
  67. package/dist-tsc/utils.js +19 -1
  68. package/package.json +16 -10
  69. package/src/AnnDataSource.js +170 -53
  70. package/src/SpatialDataShapesSource.js +61 -28
  71. package/src/SpatialDataTableSource.js +60 -27
  72. package/src/ZarrDataSource.js +20 -3
  73. package/src/anndata-loaders/FeatureLabelsAnndataLoader.js +13 -4
  74. package/src/anndata-loaders/ObsEmbeddingAnndataLoader.js +14 -5
  75. package/src/utils.js +20 -1
package/dist/index.js CHANGED
@@ -1,4 +1,4 @@
1
- import { A, F, G, b, M, c, k, O, j, f, e, h, i, d, n, m, l, o, p, r, q, a, S, Z } from "./index-200d5108.js";
1
+ import { A, F, G, b, M, c, k, O, j, f, e, h, i, d, n, m, l, o, p, r, q, a, S, Z } from "./index-184aee21.js";
2
2
  import "@vitessce/vit-s";
3
3
  import "react";
4
4
  export {
@@ -1,4 +1,4 @@
1
- import { B as BaseDecoder } from "./index-200d5108.js";
1
+ import { B as BaseDecoder } from "./index-184aee21.js";
2
2
  import "@vitessce/vit-s";
3
3
  import "react";
4
4
  const dctZigZag = new Int32Array([
@@ -1,5 +1,5 @@
1
1
  import { i as inflate_1 } from "./pako.esm-68f84e2a.js";
2
- import { g as getDefaultExportFromCjs, B as BaseDecoder } from "./index-200d5108.js";
2
+ import { g as getDefaultExportFromCjs, B as BaseDecoder } from "./index-184aee21.js";
3
3
  import "@vitessce/vit-s";
4
4
  import "react";
5
5
  const LercParameters = {
@@ -1,4 +1,4 @@
1
- import { B as BaseDecoder } from "./index-200d5108.js";
1
+ import { B as BaseDecoder } from "./index-184aee21.js";
2
2
  import "@vitessce/vit-s";
3
3
  import "react";
4
4
  const MIN_BITS = 9;
@@ -1,4 +1,4 @@
1
- import { B as BaseDecoder } from "./index-200d5108.js";
1
+ import { B as BaseDecoder } from "./index-184aee21.js";
2
2
  import "@vitessce/vit-s";
3
3
  import "react";
4
4
  class PackbitsDecoder extends BaseDecoder {
@@ -1,4 +1,4 @@
1
- import { B as BaseDecoder } from "./index-200d5108.js";
1
+ import { B as BaseDecoder } from "./index-184aee21.js";
2
2
  import "@vitessce/vit-s";
3
3
  import "react";
4
4
  class RawDecoder extends BaseDecoder {
@@ -1,4 +1,4 @@
1
- import { B as BaseDecoder } from "./index-200d5108.js";
1
+ import { B as BaseDecoder } from "./index-184aee21.js";
2
2
  import "@vitessce/vit-s";
3
3
  import "react";
4
4
  class WebImageDecoder extends BaseDecoder {
@@ -1,65 +1,131 @@
1
+ /** @import { DataSourceParams } from '@vitessce/types' */
2
+ /** @import { ByteStringArray } from '@zarrita/typedarray' */
3
+ /** @import { TypedArray as ZarrTypedArray, Chunk } from '@zarrita/core' */
1
4
  /**
2
5
  * A base AnnData loader which has all shared methods for more comlpex laoders,
3
6
  * like loading cell names and ids. It inherits from AbstractLoader.
4
7
  */
5
8
  export default class AnnDataSource extends ZarrDataSource {
6
- constructor(...args: any[]);
7
- /** @type {Map<string, Promise<string[]>} */
8
- promises: Map<string, Promise<string[]>>;
9
- loadObsColumns(paths: any): Promise<any>;
10
- loadVarColumns(paths: any): Promise<any>;
9
+ /** @type {Map<string, Promise<(undefined | string[] | string[][])>>} */
10
+ promises: Map<string, Promise<(undefined | string[] | string[][])>>;
11
+ /**
12
+ *
13
+ * @param {string[]} paths Paths to multiple string-valued columns
14
+ * within the obs dataframe.
15
+ * @returns {Promise<(undefined | string[] | string[][])[]>} Returns
16
+ * each column as an array of strings,
17
+ * ordered the same as the paths.
18
+ */
19
+ loadObsColumns(paths: string[]): Promise<(undefined | string[] | string[][])[]>;
20
+ /**
21
+ *
22
+ * @param {string[]} paths Paths to multiple string-valued columns
23
+ * within the var dataframe.
24
+ * @returns {Promise<(undefined | string[] | string[][])[]>} Returns
25
+ * each column as an array of strings,
26
+ * ordered the same as the paths.
27
+ */
28
+ loadVarColumns(paths: string[]): Promise<(undefined | string[] | string[][])[]>;
11
29
  /**
12
30
  * Class method for loading obs variables.
13
31
  * Takes the location as an argument because this is shared across objects,
14
32
  * which have different ways of specifying location.
15
- * @param {string[]} paths An array of strings like "obs/leiden" or "obs/bulk_labels."
16
- * @returns {Promise} A promise for an array of ids with one per cell.
33
+ * @param {string[] | string[][]} paths An array of strings like
34
+ * "obs/leiden" or "obs/bulk_labels."
35
+ * @returns {Promise<(undefined | string[] | string[][])[]>} A promise
36
+ * for an array of ids with one per cell.
17
37
  */
18
- _loadColumns(paths: string[]): Promise<any>;
19
- _loadColumn(path: any): Promise<any[]>;
38
+ _loadColumns(paths: string[] | string[][]): Promise<(undefined | string[] | string[][])[]>;
39
+ /**
40
+ *
41
+ * @param {string} path
42
+ * @returns
43
+ */
44
+ _loadColumn(path: string): Promise<string[]>;
20
45
  /**
21
46
  * Class method for loading general numeric arrays.
22
47
  * @param {string} path A string like obsm.X_pca.
23
- * @returns {Promise} A promise for a zarr array containing the data.
48
+ * @returns {Promise<Chunk<any>>} A promise for a zarr array containing the data.
24
49
  */
25
- loadNumeric(path: string): Promise<any>;
50
+ loadNumeric(path: string): Promise<Chunk<any>>;
26
51
  /**
27
52
  * Class method for loading specific columns of numeric arrays.
28
53
  * @param {string} path A string like obsm.X_pca.
29
- * @param {number[]} dims The column indices to load.
30
- * @returns {Promise} A promise for a zarr array containing the data.
54
+ * @param {[number, number]} dims The column indices to load.
55
+ * @returns {Promise<{
56
+ * data: [ZarrTypedArray<any>, ZarrTypedArray<any>],
57
+ * shape: [number, number],
58
+ * }>} A promise for a zarr array containing the data.
31
59
  */
32
- loadNumericForDims(path: string, dims: number[]): Promise<any>;
60
+ loadNumericForDims(path: string, dims: [number, number]): Promise<{
61
+ data: [any[] | Int8Array | Int16Array | Int32Array | BigInt64Array | Uint8Array | Uint16Array | Uint32Array | BigUint64Array | Float32Array | Float64Array | import("@zarrita/typedarray").BoolArray | import("@zarrita/typedarray").UnicodeStringArray | ByteStringArray, any[] | Int8Array | Int16Array | Int32Array | BigInt64Array | Uint8Array | Uint16Array | Uint32Array | BigUint64Array | Float32Array | Float64Array | import("@zarrita/typedarray").BoolArray | import("@zarrita/typedarray").UnicodeStringArray | ByteStringArray];
62
+ shape: [number, number];
63
+ }>;
33
64
  /**
34
65
  * A common method for loading flattened data
35
66
  * i.e that which has shape [n] where n is a natural number.
36
67
  * @param {string} path A path to a flat array location, like obs/_index
37
- * @returns {Array} The data from the zarr array.
68
+ * @returns {Promise<string[]>} The data from the zarr array.
38
69
  */
39
- getFlatArrDecompressed(path: string): any[];
70
+ getFlatArrDecompressed(path: string): Promise<string[]>;
40
71
  /**
41
72
  * Class method for loading the obs index.
42
- * @returns {Promise} An promise for a zarr array containing the indices.
73
+ * @param {string|undefined} path Used by subclasses.
74
+ * @returns {Promise<string[]>} An promise for a zarr array
75
+ * containing the indices.
43
76
  */
44
- loadObsIndex(): Promise<any>;
45
- obsIndex: Promise<any[]> | undefined;
77
+ loadObsIndex(path?: string | undefined): Promise<string[]>;
78
+ obsIndex: Promise<string[]> | undefined;
46
79
  /**
47
80
  * Class method for loading the var index.
48
- * @returns {Promise} An promise for a zarr array containing the indices.
81
+ * @param {string|undefined} path Used by subclasses.
82
+ * @returns {Promise<string[]>} An promise for a zarr array containing the indices.
49
83
  */
50
- loadVarIndex(): Promise<any>;
51
- varIndex: Promise<any[]> | undefined;
84
+ loadVarIndex(path?: string | undefined): Promise<string[]>;
85
+ varIndex: Promise<string[]> | undefined;
52
86
  /**
53
87
  * Class method for loading the var alias.
54
- * @returns {Promise} An promise for a zarr array containing the aliased names.
88
+ * @param {string} varPath
89
+ * @param {string|undefined} matrixPath
90
+ * @returns {Promise<string[]>} An promise for a zarr array containing the aliased names.
55
91
  */
56
- loadVarAlias(varPath: any): Promise<any>;
92
+ loadVarAlias(varPath: string, matrixPath?: string | undefined): Promise<string[]>;
57
93
  varAlias: any;
58
- _loadAttrs(path: any): Promise<any>;
59
- _loadString(path: any): Promise<any>;
60
- _loadStringArray(path: any): Promise<any[]>;
61
- _loadElement(path: any): Promise<any>;
62
- _loadDict(path: any, keys: any): Promise<{}>;
94
+ /**
95
+ *
96
+ * @param {string} path
97
+ * @returns {Promise<object>}
98
+ */
99
+ _loadAttrs(path: string): Promise<object>;
100
+ /**
101
+ *
102
+ * @param {string} path
103
+ * @returns {Promise<string>}
104
+ */
105
+ _loadString(path: string): Promise<string>;
106
+ /**
107
+ *
108
+ * @param {string} path
109
+ * @returns {Promise<string[]>}
110
+ */
111
+ _loadStringArray(path: string): Promise<string[]>;
112
+ /**
113
+ *
114
+ * @param {string} path
115
+ * @returns
116
+ */
117
+ _loadElement(path: string): Promise<string | string[] | null>;
118
+ /**
119
+ *
120
+ * @param {string} path
121
+ * @param {string[]} keys
122
+ * @returns
123
+ */
124
+ _loadDict(path: string, keys: string[]): Promise<{
125
+ [k: string]: string | string[] | null;
126
+ }>;
63
127
  }
64
- import ZarrDataSource from "./ZarrDataSource.js";
128
+ import ZarrDataSource from './ZarrDataSource.js';
129
+ import type { Chunk } from '@zarrita/core';
130
+ import type { ByteStringArray } from '@zarrita/typedarray';
65
131
  //# sourceMappingURL=AnnDataSource.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"AnnDataSource.d.ts","sourceRoot":"","sources":["../src/AnnDataSource.js"],"names":[],"mappings":"AAKA;;;GAGG;AACH;IACE,4BAIC;IAFC,4CAA4C;IAC5C,UADW,IAAI,MAAM,EAAE,QAAQ,MAAM,EAAE,CAAC,CAAA,CACf;IAG3B,yCAEC;IAED,yCAEC;IAED;;;;;;OAMG;IACH,oBAHW,MAAM,EAAE,gBA0BlB;IAED,uCAkCC;IAED;;;;OAIG;IACH,kBAHW,MAAM,gBAOhB;IAED;;;;;OAKG;IACH,yBAJW,MAAM,QACN,MAAM,EAAE,gBAclB;IAED;;;;;OAKG;IACH,6BAHW,MAAM,SAYhB;IAED;;;OAGG;IACH,6BAMC;IAFC,qCAA+G;IAIjH;;;OAGG;IACH,6BAMC;IAFC,qCAA+G;IAIjH;;;OAGG;IACH,yCAUC;IAJC,cAEC;IAIH,oCAEC;IAED,qCAWC;IAED,4CAOC;IAGD,sCASC;IAED,6CAYC;CACF"}
1
+ {"version":3,"file":"AnnDataSource.d.ts","sourceRoot":"","sources":["../src/AnnDataSource.js"],"names":[],"mappings":"AAMA,0DAA0D;AAC1D,6DAA6D;AAC7D,2EAA2E;AAE3E;;;GAGG;AACH;IAOI,wEAAwE;IACxE,UADW,GAAG,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,SAAS,GAAG,MAAM,EAAE,GAAG,MAAM,EAAE,EAAE,CAAC,CAAC,CAAC,CAC3C;IAG3B;;;;;;;OAOG;IACH,sBANW,MAAM,EAAE,GAEN,OAAO,CAAC,CAAC,SAAS,GAAG,MAAM,EAAE,GAAG,MAAM,EAAE,EAAE,CAAC,EAAE,CAAC,CAM1D;IAED;;;;;;;OAOG;IACH,sBANW,MAAM,EAAE,GAEN,OAAO,CAAC,CAAC,SAAS,GAAG,MAAM,EAAE,GAAG,MAAM,EAAE,EAAE,CAAC,EAAE,CAAC,CAM1D;IAED;;;;;;;;OAQG;IACH,oBALW,MAAM,EAAE,GAAG,MAAM,EAAE,EAAE,GAEnB,OAAO,CAAC,CAAC,SAAS,GAAG,MAAM,EAAE,GAAG,MAAM,EAAE,EAAE,CAAC,EAAE,CAAC,CA2B1D;IAED;;;;OAIG;IACH,kBAHW,MAAM,qBAmDhB;IAED;;;;OAIG;IACH,kBAHW,MAAM,uBAOhB;IAED;;;;;;;;OAQG;IACH,yBAPW,MAAM,QACN,CAAC,MAAM,EAAE,MAAM,CAAC;;eAGhB,CAAC,MAAM,EAAE,MAAM,CAAC;OAgB1B;IAED;;;;;OAKG;IACH,6BAHW,MAAM,GACJ,OAAO,CAAC,MAAM,EAAE,CAAC,CAW7B;IAED;;;;;OAKG;IACH,oBAJW,MAAM,GAAC,SAAS,GACd,OAAO,CAAC,MAAM,EAAE,CAAC,CAa7B;IAHC,wCACsE;IAIxE;;;;OAIG;IACH,oBAHW,MAAM,GAAC,SAAS,GACd,OAAO,CAAC,MAAM,EAAE,CAAC,CAY7B;IAHC,wCACsE;IAIxE;;;;;OAKG;IACH,sBAJW,MAAM,eACN,MAAM,GAAC,SAAS,GACd,OAAO,CAAC,MAAM,EAAE,CAAC,CAiB7B;IALC,cAGC;IAIH;;;;OAIG;IACH,iBAHW,MAAM,GACJ,OAAO,CAAC,MAAM,CAAC,CAI3B;IAED;;;;OAIG;IACH,kBAHW,MAAM,GACJ,OAAO,CAAC,MAAM,CAAC,CAoB3B;IAED;;;;OAIG;IACH,uBAHW,MAAM,GACJ,OAAO,CAAC,MAAM,EAAE,CAAC,CAa7B;IAED;;;;OAIG;IACH,mBAHW,MAAM,qCAehB;IAED;;;;;OAKG;IACH,gBAJW,MAAM,QACN,MAAM,EAAE;;OAuBlB;CACF;2BAvV0B,qBAAqB;2BAIS,eAAe;qCADnC,qBAAqB"}
@@ -1,20 +1,44 @@
1
+ // @ts-check
1
2
  /* eslint-disable no-underscore-dangle */
2
3
  import { open as zarrOpen, get as zarrGet } from 'zarrita';
3
4
  import { dirname } from './utils.js';
4
5
  import ZarrDataSource from './ZarrDataSource.js';
6
+ /** @import { DataSourceParams } from '@vitessce/types' */
7
+ /** @import { ByteStringArray } from '@zarrita/typedarray' */
8
+ /** @import { TypedArray as ZarrTypedArray, Chunk } from '@zarrita/core' */
5
9
  /**
6
10
  * A base AnnData loader which has all shared methods for more comlpex laoders,
7
11
  * like loading cell names and ids. It inherits from AbstractLoader.
8
12
  */
9
13
  export default class AnnDataSource extends ZarrDataSource {
10
- constructor(...args) {
11
- super(...args);
12
- /** @type {Map<string, Promise<string[]>} */
14
+ /**
15
+ *
16
+ * @param {DataSourceParams} params
17
+ */
18
+ constructor(params) {
19
+ super(params);
20
+ /** @type {Map<string, Promise<(undefined | string[] | string[][])>>} */
13
21
  this.promises = new Map();
14
22
  }
23
+ /**
24
+ *
25
+ * @param {string[]} paths Paths to multiple string-valued columns
26
+ * within the obs dataframe.
27
+ * @returns {Promise<(undefined | string[] | string[][])[]>} Returns
28
+ * each column as an array of strings,
29
+ * ordered the same as the paths.
30
+ */
15
31
  loadObsColumns(paths) {
16
32
  return this._loadColumns(paths);
17
33
  }
34
+ /**
35
+ *
36
+ * @param {string[]} paths Paths to multiple string-valued columns
37
+ * within the var dataframe.
38
+ * @returns {Promise<(undefined | string[] | string[][])[]>} Returns
39
+ * each column as an array of strings,
40
+ * ordered the same as the paths.
41
+ */
18
42
  loadVarColumns(paths) {
19
43
  return this._loadColumns(paths);
20
44
  }
@@ -22,11 +46,14 @@ export default class AnnDataSource extends ZarrDataSource {
22
46
  * Class method for loading obs variables.
23
47
  * Takes the location as an argument because this is shared across objects,
24
48
  * which have different ways of specifying location.
25
- * @param {string[]} paths An array of strings like "obs/leiden" or "obs/bulk_labels."
26
- * @returns {Promise} A promise for an array of ids with one per cell.
49
+ * @param {string[] | string[][]} paths An array of strings like
50
+ * "obs/leiden" or "obs/bulk_labels."
51
+ * @returns {Promise<(undefined | string[] | string[][])[]>} A promise
52
+ * for an array of ids with one per cell.
27
53
  */
28
54
  _loadColumns(paths) {
29
55
  const promises = paths.map((path) => {
56
+ /** @type {(a: string) => Promise<string[]>} */
30
57
  const getCol = (col) => {
31
58
  if (!this.promises.has(col)) {
32
59
  const obsPromise = this._loadColumn(col).catch((err) => {
@@ -37,7 +64,7 @@ export default class AnnDataSource extends ZarrDataSource {
37
64
  });
38
65
  this.promises.set(col, obsPromise);
39
66
  }
40
- return this.promises.get(col);
67
+ return /** @type {Promise<string[]>} */ (this.promises.get(col));
41
68
  };
42
69
  if (!path) {
43
70
  return Promise.resolve(undefined);
@@ -49,32 +76,39 @@ export default class AnnDataSource extends ZarrDataSource {
49
76
  });
50
77
  return Promise.all(promises);
51
78
  }
79
+ /**
80
+ *
81
+ * @param {string} path
82
+ * @returns
83
+ */
52
84
  async _loadColumn(path) {
53
85
  const { storeRoot } = this;
54
86
  const prefix = dirname(path);
55
87
  const { categories, 'encoding-type': encodingType } = await this.getJson(`${path}/.zattrs`);
88
+ /** @type {string[]} */
56
89
  let categoriesValues;
57
- let codes;
90
+ /** @type {undefined | string} */
91
+ let codesPath;
58
92
  if (categories) {
59
- const { dtype } = await zarrOpen(storeRoot.resolve(`/${prefix}/${categories}`));
93
+ const { dtype } = await zarrOpen(storeRoot.resolve(`/${prefix}/${categories}`), { kind: 'array' });
60
94
  if (dtype === 'v2:object') {
61
95
  categoriesValues = await this.getFlatArrDecompressed(`/${prefix}/${categories}`);
62
96
  }
63
97
  }
64
98
  else if (encodingType === 'categorical') {
65
- const { dtype } = await zarrOpen(storeRoot.resolve(`/${path}/categories`));
99
+ const { dtype } = await zarrOpen(storeRoot.resolve(`/${path}/categories`), { kind: 'array' });
66
100
  if (dtype === 'v2:object') {
67
101
  categoriesValues = await this.getFlatArrDecompressed(`/${path}/categories`);
68
102
  }
69
- codes = `/${path}/codes`;
103
+ codesPath = `/${path}/codes`;
70
104
  }
71
105
  else {
72
- const { dtype } = await zarrOpen(storeRoot.resolve(`/${path}`));
106
+ const { dtype } = await zarrOpen(storeRoot.resolve(`/${path}`), { kind: 'array' });
73
107
  if (dtype === 'v2:object') {
74
108
  return this.getFlatArrDecompressed(path);
75
109
  }
76
110
  }
77
- const arr = await zarrOpen(storeRoot.resolve(codes || path), { kind: 'array' });
111
+ const arr = await zarrOpen(storeRoot.resolve(codesPath || path), { kind: 'array' });
78
112
  const values = await zarrGet(arr, [null]);
79
113
  const { data } = values;
80
114
  const mappedValues = Array.from(data).map(i => (!categoriesValues ? String(i) : categoriesValues[i]));
@@ -83,7 +117,7 @@ export default class AnnDataSource extends ZarrDataSource {
83
117
  /**
84
118
  * Class method for loading general numeric arrays.
85
119
  * @param {string} path A string like obsm.X_pca.
86
- * @returns {Promise} A promise for a zarr array containing the data.
120
+ * @returns {Promise<Chunk<any>>} A promise for a zarr array containing the data.
87
121
  */
88
122
  loadNumeric(path) {
89
123
  const { storeRoot } = this;
@@ -93,14 +127,17 @@ export default class AnnDataSource extends ZarrDataSource {
93
127
  /**
94
128
  * Class method for loading specific columns of numeric arrays.
95
129
  * @param {string} path A string like obsm.X_pca.
96
- * @param {number[]} dims The column indices to load.
97
- * @returns {Promise} A promise for a zarr array containing the data.
130
+ * @param {[number, number]} dims The column indices to load.
131
+ * @returns {Promise<{
132
+ * data: [ZarrTypedArray<any>, ZarrTypedArray<any>],
133
+ * shape: [number, number],
134
+ * }>} A promise for a zarr array containing the data.
98
135
  */
99
136
  loadNumericForDims(path, dims) {
100
137
  const { storeRoot } = this;
101
138
  const arr = zarrOpen(storeRoot.resolve(path), { kind: 'array' });
102
139
  return Promise.all(dims.map(dim => arr.then(loadedArr => zarrGet(loadedArr, [null, dim])))).then(cols => ({
103
- data: cols.map(col => col.data),
140
+ data: /** @type {[ZarrTypedArray<any>, ZarrTypedArray<any>]} */ (cols.map(col => col.data)),
104
141
  shape: [dims.length, cols[0].shape[0]],
105
142
  }));
106
143
  }
@@ -108,7 +145,7 @@ export default class AnnDataSource extends ZarrDataSource {
108
145
  * A common method for loading flattened data
109
146
  * i.e that which has shape [n] where n is a natural number.
110
147
  * @param {string} path A path to a flat array location, like obs/_index
111
- * @returns {Array} The data from the zarr array.
148
+ * @returns {Promise<string[]>} The data from the zarr array.
112
149
  */
113
150
  async getFlatArrDecompressed(path) {
114
151
  const { storeRoot } = this;
@@ -118,85 +155,142 @@ export default class AnnDataSource extends ZarrDataSource {
118
155
  if (data.data?.[Symbol.iterator]) {
119
156
  return Array.from(data.data);
120
157
  }
121
- return data.data;
158
+ return /** @type {string[]} */ (data.data);
122
159
  }
123
160
  /**
124
161
  * Class method for loading the obs index.
125
- * @returns {Promise} An promise for a zarr array containing the indices.
162
+ * @param {string|undefined} path Used by subclasses.
163
+ * @returns {Promise<string[]>} An promise for a zarr array
164
+ * containing the indices.
126
165
  */
127
- loadObsIndex() {
166
+ loadObsIndex(
167
+ // eslint-disable-next-line no-unused-vars
168
+ path = undefined) {
128
169
  if (this.obsIndex) {
129
170
  return this.obsIndex;
130
171
  }
131
- this.obsIndex = this.getJson('obs/.zattrs').then(({ _index }) => this.getFlatArrDecompressed(`/obs/${_index}`));
172
+ this.obsIndex = this.getJson('obs/.zattrs')
173
+ .then(({ _index }) => this.getFlatArrDecompressed(`/obs/${_index}`));
132
174
  return this.obsIndex;
133
175
  }
134
176
  /**
135
177
  * Class method for loading the var index.
136
- * @returns {Promise} An promise for a zarr array containing the indices.
178
+ * @param {string|undefined} path Used by subclasses.
179
+ * @returns {Promise<string[]>} An promise for a zarr array containing the indices.
137
180
  */
138
- loadVarIndex() {
181
+ loadVarIndex(
182
+ // eslint-disable-next-line no-unused-vars
183
+ path = undefined) {
139
184
  if (this.varIndex) {
140
185
  return this.varIndex;
141
186
  }
142
- this.varIndex = this.getJson('var/.zattrs').then(({ _index }) => this.getFlatArrDecompressed(`/var/${_index}`));
187
+ this.varIndex = this.getJson('var/.zattrs')
188
+ .then(({ _index }) => this.getFlatArrDecompressed(`/var/${_index}`));
143
189
  return this.varIndex;
144
190
  }
145
191
  /**
146
192
  * Class method for loading the var alias.
147
- * @returns {Promise} An promise for a zarr array containing the aliased names.
193
+ * @param {string} varPath
194
+ * @param {string|undefined} matrixPath
195
+ * @returns {Promise<string[]>} An promise for a zarr array containing the aliased names.
148
196
  */
149
- async loadVarAlias(varPath) {
197
+ async loadVarAlias(varPath,
198
+ // eslint-disable-next-line no-unused-vars
199
+ matrixPath = undefined) {
150
200
  if (this.varAlias) {
151
201
  return this.varAlias;
152
202
  }
153
203
  [this.varAlias] = await this.loadVarColumns([varPath]);
154
204
  const index = await this.loadVarIndex();
155
- this.varAlias = this.varAlias.map((val, ind) => (val ? val.concat(` (${index[ind]})`) : index[ind]));
205
+ this.varAlias = this.varAlias.map(
206
+ /** @type {(val: string, ind: number) => string} */
207
+ (val, ind) => (val ? val.concat(` (${index[ind]})`) : index[ind]));
156
208
  return this.varAlias;
157
209
  }
210
+ /**
211
+ *
212
+ * @param {string} path
213
+ * @returns {Promise<object>}
214
+ */
158
215
  async _loadAttrs(path) {
159
216
  return this.getJson(`${path}/.zattrs`);
160
217
  }
218
+ /**
219
+ *
220
+ * @param {string} path
221
+ * @returns {Promise<string>}
222
+ */
161
223
  async _loadString(path) {
162
224
  const { storeRoot } = this;
163
- const { 'encoding-type': encodingType, 'encoding-version': encodingVersion } = await this._loadAttrs(path);
164
- if (encodingType === 'string' && encodingVersion === '0.2.0') {
165
- const arr = await zarrOpen(storeRoot.resolve(path), { kind: 'array' });
166
- // TODO: Use zarrGet once it supports zero-dimensional array access.
167
- const { data } = await arr.getChunk([]);
168
- return data.get(0);
225
+ const zattrs = await this._loadAttrs(path);
226
+ if ('encoding-type' in zattrs && 'encoding-version' in zattrs) {
227
+ const { 'encoding-type': encodingType, 'encoding-version': encodingVersion, } = zattrs;
228
+ if (encodingType === 'string' && encodingVersion === '0.2.0') {
229
+ const arr = await zarrOpen(storeRoot.resolve(path), { kind: 'array' });
230
+ // TODO: Use zarrGet once it supports zero-dimensional array access.
231
+ const { data } = /** @type {{ data: ByteStringArray }} */ (await arr.getChunk([]));
232
+ return data.get(0);
233
+ }
234
+ throw new Error(`Unsupported encoding type ${encodingType} and version ${encodingVersion} in AnnDataSource._loadString`);
169
235
  }
170
- throw new Error(`Unsupported encoding type ${encodingType} and version ${encodingVersion} in AnnDataSource._loadString`);
236
+ throw new Error('Keys for encoding-type or encoding-version not found in AnnDataSource._loadString');
171
237
  }
238
+ /**
239
+ *
240
+ * @param {string} path
241
+ * @returns {Promise<string[]>}
242
+ */
172
243
  async _loadStringArray(path) {
173
- const { 'encoding-type': encodingType, 'encoding-version': encodingVersion } = await this._loadAttrs(path);
174
- if (encodingType === 'string-array' && encodingVersion === '0.2.0') {
175
- return this.getFlatArrDecompressed(path);
244
+ const zattrs = await this._loadAttrs(path);
245
+ if ('encoding-type' in zattrs && 'encoding-version' in zattrs) {
246
+ const { 'encoding-type': encodingType, 'encoding-version': encodingVersion } = zattrs;
247
+ if (encodingType === 'string-array' && encodingVersion === '0.2.0') {
248
+ return this.getFlatArrDecompressed(path);
249
+ }
250
+ throw new Error(`Unsupported encoding type ${encodingType} and version ${encodingVersion} in AnnDataSource._loadStringArray`);
176
251
  }
177
- throw new Error(`Unsupported encoding type ${encodingType} and version ${encodingVersion} in AnnDataSource._loadStringArray`);
252
+ throw new Error('Keys for encoding-type or encoding-version not found in AnnDataSource._loadString');
178
253
  }
254
+ /**
255
+ *
256
+ * @param {string} path
257
+ * @returns
258
+ */
179
259
  async _loadElement(path) {
180
- const { 'encoding-type': encodingType } = await this._loadAttrs(path);
181
- if (encodingType === 'string') {
182
- return this._loadString(path);
183
- }
184
- if (encodingType === 'string-array') {
185
- return this._loadStringArray(path);
260
+ const zattrs = await this._loadAttrs(path);
261
+ if ('encoding-type' in zattrs) {
262
+ const { 'encoding-type': encodingType } = zattrs;
263
+ if (encodingType === 'string') {
264
+ return this._loadString(path);
265
+ }
266
+ if (encodingType === 'string-array') {
267
+ return this._loadStringArray(path);
268
+ }
186
269
  }
187
270
  // TODO: support more elements
188
271
  return null;
189
272
  }
273
+ /**
274
+ *
275
+ * @param {string} path
276
+ * @param {string[]} keys
277
+ * @returns
278
+ */
190
279
  async _loadDict(path, keys) {
191
- const { 'encoding-type': encodingType, 'encoding-version': encodingVersion } = await this._loadAttrs(path);
192
- if (encodingType === 'dict' && encodingVersion === '0.1.0') {
193
- const result = {};
194
- await Promise.all(keys.map(async (key) => {
195
- const val = await this._loadElement(`${path}/${key}`);
196
- result[key] = val;
197
- }));
198
- return result;
280
+ const zattrs = await this._loadAttrs(path);
281
+ if ('encoding-type' in zattrs && 'encoding-version' in zattrs) {
282
+ const { 'encoding-type': encodingType, 'encoding-version': encodingVersion, } = zattrs;
283
+ if (encodingType === 'dict' && encodingVersion === '0.1.0') {
284
+ /** @type {{ [k: string]: string|string[]|null }} */
285
+ const result = {};
286
+ await Promise.all(keys.map(async (key) => {
287
+ const val = await this._loadElement(`${path}/${key}`);
288
+ result[key] = val;
289
+ }));
290
+ return result;
291
+ }
292
+ throw new Error(`Unsupported encoding type ${encodingType} and version ${encodingVersion} in AnnDataSource._loadDict`);
199
293
  }
200
- throw new Error(`Unsupported encoding type ${encodingType} and version ${encodingVersion} in AnnDataSource._loadDict`);
294
+ throw new Error('Keys for encoding-type or encoding-version not found in AnnDataSource._loadString');
201
295
  }
202
296
  }
@@ -17,5 +17,5 @@ export default class MuDataSource extends AnnDataSource {
17
17
  */
18
18
  loadVarAlias(varPath: any, matrixPath: any): Promise<any>;
19
19
  }
20
- import AnnDataSource from "./AnnDataSource.js";
20
+ import AnnDataSource from './AnnDataSource.js';
21
21
  //# sourceMappingURL=MuDataSource.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"MuDataSource.d.ts","sourceRoot":"","sources":["../src/MuDataSource.js"],"names":[],"mappings":"AAeA,iDAEC;AAED,iDAEC;AAED;IACE;;;OAGG;IACH,wCAWC;IAED;;;OAGG;IACH,wCAWC;IAED;;;OAGG;IACH,0DAcC;CACF"}
1
+ {"version":3,"file":"MuDataSource.d.ts","sourceRoot":"","sources":["../src/MuDataSource.js"],"names":[],"mappings":"AAeA,iDAEC;AAED,iDAEC;AAED;IACE;;;OAGG;IACH,wCAWC;IAED;;;OAGG;IACH,wCAWC;IAED;;;OAGG;IACH,0DAcC;CACF;0BA7EyB,oBAAoB"}
@@ -1,22 +1,50 @@
1
- export function getIndexPath(arrPath: any): string;
2
- export function getVarPath(arrPath: any): string;
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;
3
13
  export default class SpatialDataShapesSource extends AnnDataSource {
4
- loadSpatialDataAttrs(tablePath: any): Promise<{}>;
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
+ };
5
26
  /**
6
- * Class method for loading the obs index.
7
- * @returns {Promise} An promise for a zarr array containing the indices.
27
+ *
28
+ * @param {string} tablePath
29
+ * @returns
8
30
  */
9
- loadObsIndex(path?: null, tablePath?: null): Promise<any>;
31
+ loadSpatialDataAttrs(tablePath: string): Promise<{
32
+ [k: string]: string | string[] | null;
33
+ }>;
10
34
  /**
11
- * Class method for loading the var index.
12
- * @returns {Promise} An promise for a zarr array containing the indices.
35
+ * Class method for loading the obs index.
36
+ * @param {string|undefined} path
37
+ * @param {string|undefined} tablePath
38
+ * @returns {Promise<string[]>} An promise for a zarr array containing the indices.
13
39
  */
14
- loadVarIndex(path?: null): Promise<any>;
40
+ loadObsIndex(path?: string | undefined, tablePath?: string | undefined): Promise<string[]>;
15
41
  /**
16
42
  * Class method for loading the var alias.
17
- * @returns {Promise} An promise for a zarr array containing the aliased names.
43
+ * @param {string} varPath
44
+ * @param {string} matrixPath
45
+ * @returns {Promise<string[]>} An promise for a zarr array containing the aliased names.
18
46
  */
19
- loadVarAlias(varPath: any, matrixPath: any): Promise<any>;
47
+ loadVarAlias(varPath: string, matrixPath: string): Promise<string[]>;
20
48
  }
21
- import AnnDataSource from "./AnnDataSource.js";
49
+ import AnnDataSource from './AnnDataSource.js';
22
50
  //# sourceMappingURL=SpatialDataShapesSource.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"SpatialDataShapesSource.d.ts","sourceRoot":"","sources":["../src/SpatialDataShapesSource.js"],"names":[],"mappings":"AAgBA,mDAEC;AAED,iDAEC;AAGD;IACE,kDAEC;IAED;;;OAGG;IACH,0DA8BC;IAED;;;OAGG;IACH,wCAWC;IAED;;;OAGG;IACH,0DAcC;CACF"}
1
+ {"version":3,"file":"SpatialDataShapesSource.d.ts","sourceRoot":"","sources":["../src/SpatialDataShapesSource.js"],"names":[],"mappings":"AAyBA;;;;GAIG;AACH,sCAHW,MAAM,GAAC,SAAS,UAK1B;AAED;;;;GAIG;AACH,oCAHW,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;;;;;OAKG;IACH,oBAJW,MAAM,GAAC,SAAS,cAChB,MAAM,GAAC,SAAS,GACd,OAAO,CAAC,MAAM,EAAE,CAAC,CA4B7B;IAiBD;;;;;OAKG;IACH,sBAJW,MAAM,cACN,MAAM,GACJ,OAAO,CAAC,MAAM,EAAE,CAAC,CAa7B;CACF;0BArIyB,oBAAoB"}