@vitessce/zarr 2.0.2 → 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 (50) hide show
  1. package/dist/deflate.9bff78ef.mjs +12 -0
  2. package/dist/index.ae29d0d3.mjs +139533 -0
  3. package/dist/index.mjs +18 -0
  4. package/dist/jpeg.7d8fcd34.mjs +839 -0
  5. package/dist/lerc.242ab449.mjs +1942 -0
  6. package/dist/lzw.801ba405.mjs +127 -0
  7. package/dist/packbits.300e46d9.mjs +29 -0
  8. package/dist/pako.esm.4b234125.mjs +3940 -0
  9. package/dist/raw.de2b32d2.mjs +11 -0
  10. package/dist/webimage.97478b33.mjs +31 -0
  11. package/{dist → dist-tsc}/index.js +1 -0
  12. package/package.json +11 -11
  13. package/src/AnnDataSource.js +270 -0
  14. package/src/AnnDataSource.test.js +55 -0
  15. package/src/MuDataSource.js +78 -0
  16. package/src/MuDataSource.test.js +48 -0
  17. package/src/ZarrDataSource.js +36 -0
  18. package/src/anndata-loaders/FeatureLabelsAnndataLoader.js +63 -0
  19. package/src/anndata-loaders/ObsEmbeddingAnndataLoader.js +48 -0
  20. package/src/anndata-loaders/ObsEmbeddingAnndataLoader.test.js +79 -0
  21. package/src/anndata-loaders/ObsFeatureMatrixAnndataLoader.js +387 -0
  22. package/src/anndata-loaders/ObsFeatureMatrixAnndataLoader.test.js +124 -0
  23. package/src/anndata-loaders/ObsLabelsAnndataLoader.js +47 -0
  24. package/src/anndata-loaders/ObsLocationsAnndataLoader.js +45 -0
  25. package/src/anndata-loaders/ObsSegmentationsAnndataLoader.js +61 -0
  26. package/src/anndata-loaders/ObsSetsAnndataLoader.js +83 -0
  27. package/{dist → src}/anndata-loaders/index.js +0 -0
  28. package/src/genomic-loaders/GenomicProfilesZarrLoader.js +17 -0
  29. package/{dist → src}/genomic-loaders/index.js +0 -0
  30. package/src/index.js +7 -0
  31. package/src/matrix-loaders/MatrixZarrAsObsFeatureMatrix.js +36 -0
  32. package/{dist → src}/matrix-loaders/index.js +0 -0
  33. package/src/ome-loaders/OmeZarrLoader.js +81 -0
  34. package/{dist → src}/ome-loaders/index.js +0 -0
  35. package/src/utils.js +5 -0
  36. package/dist/AnnDataSource.js +0 -245
  37. package/dist/AnnDataSource.test.js +0 -49
  38. package/dist/ZarrDataSource.js +0 -35
  39. package/dist/anndata-loaders/FeatureLabelsAnndataLoader.js +0 -52
  40. package/dist/anndata-loaders/ObsEmbeddingAnndataLoader.js +0 -36
  41. package/dist/anndata-loaders/ObsEmbeddingAnndataLoader.test.js +0 -31
  42. package/dist/anndata-loaders/ObsFeatureMatrixAnndataLoader.js +0 -363
  43. package/dist/anndata-loaders/ObsFeatureMatrixAnndataLoader.test.js +0 -72
  44. package/dist/anndata-loaders/ObsLabelsAnndataLoader.js +0 -37
  45. package/dist/anndata-loaders/ObsLocationsAnndataLoader.js +0 -36
  46. package/dist/anndata-loaders/ObsSegmentationsAnndataLoader.js +0 -51
  47. package/dist/anndata-loaders/ObsSetsAnndataLoader.js +0 -50
  48. package/dist/genomic-loaders/GenomicProfilesZarrLoader.js +0 -15
  49. package/dist/matrix-loaders/MatrixZarrAsObsFeatureMatrix.js +0 -30
  50. package/dist/ome-loaders/OmeZarrLoader.js +0 -62
@@ -1,51 +0,0 @@
1
- import { LoaderResult, AbstractTwoStepLoader, AbstractLoaderError, obsSegmentationsAnndataSchema, } from '@vitessce/vit-s';
2
- import { DEFAULT_CELLS_LAYER } from '@vitessce/spatial-utils';
3
- /**
4
- * Loader for embedding arrays located in anndata.zarr stores.
5
- */
6
- export default class ObsSegmentationsAnndataLoader extends AbstractTwoStepLoader {
7
- constructor(dataSource, params) {
8
- super(dataSource, params);
9
- this.optionsSchema = obsSegmentationsAnndataSchema;
10
- }
11
- /**
12
- * Class method for loading embedding coordinates, such as those from UMAP or t-SNE.
13
- * @returns {Promise} A promise for an array of columns.
14
- */
15
- loadSegmentations() {
16
- const { path } = this.options;
17
- if (this.segmentations) {
18
- return this.segmentations;
19
- }
20
- if (!this.segmentations) {
21
- this.segmentations = this.dataSource.loadNumeric(path).then(arr => ({
22
- ...arr,
23
- // Bug introduced from DeckGL v8.6.x to v8.8.x:
24
- // Polygon vertices cannot be passed via Uint32Arrays, which is how they load via Zarr.
25
- // For now, a workaround is to cast each vertex to a plain Array.
26
- data: arr.data
27
- .map(poly => poly.map(vertex => Array.from(vertex))),
28
- }));
29
- return this.segmentations;
30
- }
31
- this.segmentations = Promise.resolve(null);
32
- return this.segmentations;
33
- }
34
- async load() {
35
- const superResult = await super.load().catch(reason => Promise.resolve(reason));
36
- if (superResult instanceof AbstractLoaderError) {
37
- return Promise.reject(superResult);
38
- }
39
- const coordinationValues = {
40
- spatialSegmentationLayer: DEFAULT_CELLS_LAYER,
41
- };
42
- return Promise.all([
43
- this.dataSource.loadObsIndex(),
44
- this.loadSegmentations(),
45
- ]).then(([obsIndex, obsSegmentations]) => Promise.resolve(new LoaderResult({
46
- obsIndex,
47
- obsSegmentations,
48
- obsSegmentationsType: 'polygon',
49
- }, coordinationValues)));
50
- }
51
- }
@@ -1,50 +0,0 @@
1
- import { LoaderResult, AbstractTwoStepLoader, AbstractLoaderError, obsSetsAnndataSchema, } from '@vitessce/vit-s';
2
- import { initializeCellSetColor, treeToMembershipMap, dataToCellSetsTree, } from '@vitessce/sets-utils';
3
- /**
4
- * Loader for converting zarr into the cell sets json schema.
5
- */
6
- export default class ObsSetsAnndataLoader extends AbstractTwoStepLoader {
7
- constructor(dataSource, params) {
8
- super(dataSource, params);
9
- this.optionsSchema = obsSetsAnndataSchema;
10
- }
11
- loadCellSetIds() {
12
- const { options } = this;
13
- const cellSetZarrLocation = options.map(({ path }) => path);
14
- return this.dataSource.loadObsColumns(cellSetZarrLocation);
15
- }
16
- loadCellSetScores() {
17
- const { options } = this;
18
- const cellSetScoreZarrLocation = options.map(option => option.scorePath || undefined);
19
- return this.dataSource.loadObsColumns(cellSetScoreZarrLocation);
20
- }
21
- async load() {
22
- const superResult = await super.load().catch(reason => Promise.resolve(reason));
23
- if (superResult instanceof AbstractLoaderError) {
24
- return Promise.reject(superResult);
25
- }
26
- if (!this.cachedResult) {
27
- const { options } = this;
28
- this.cachedResult = Promise.all([
29
- this.dataSource.loadObsIndex(),
30
- this.loadCellSetIds(),
31
- this.loadCellSetScores(),
32
- ]).then(data => [data[0], dataToCellSetsTree(data, options)]);
33
- }
34
- const [obsIndex, obsSets] = await this.cachedResult;
35
- const obsSetsMembership = treeToMembershipMap(obsSets);
36
- const coordinationValues = {};
37
- const { tree } = obsSets;
38
- const newAutoSetSelectionParentName = tree[0].name;
39
- // Create a list of set paths to initally select.
40
- const newAutoSetSelections = tree[0].children.map(node => [
41
- newAutoSetSelectionParentName,
42
- node.name,
43
- ]);
44
- // Create a list of cell set objects with color mappings.
45
- const newAutoSetColors = initializeCellSetColor(obsSets, []);
46
- coordinationValues.obsSetSelection = newAutoSetSelections;
47
- coordinationValues.obsSetColor = newAutoSetColors;
48
- return Promise.resolve(new LoaderResult({ obsIndex, obsSets, obsSetsMembership }, null, coordinationValues));
49
- }
50
- }
@@ -1,15 +0,0 @@
1
- import { AbstractTwoStepLoader, LoaderResult } from '@vitessce/vit-s';
2
- export default class GenomicProfilesZarrLoader extends AbstractTwoStepLoader {
3
- loadAttrs() {
4
- if (this.attrs) {
5
- return this.attrs;
6
- }
7
- this.attrs = this.dataSource.getJson('.zattrs');
8
- return this.attrs;
9
- }
10
- load() {
11
- const { url } = this;
12
- return this.loadAttrs()
13
- .then(attrs => Promise.resolve(new LoaderResult(attrs, url)));
14
- }
15
- }
@@ -1,30 +0,0 @@
1
- import { openArray } from 'zarr';
2
- import { AbstractTwoStepLoader, LoaderResult } from '@vitessce/vit-s';
3
- export default class MatrixZarrAsObsFeatureMatrixLoader extends AbstractTwoStepLoader {
4
- async loadAttrs() {
5
- if (this.attrs) {
6
- return this.attrs;
7
- }
8
- this.attrs = {
9
- data: await this.dataSource.getJson('.zattrs'),
10
- url: null,
11
- };
12
- return this.attrs;
13
- }
14
- loadArr() {
15
- const { store } = this.dataSource;
16
- if (this.arr) {
17
- return this.arr;
18
- }
19
- this.arr = openArray({ store, path: '/', mode: 'r' }).then(z => new Promise((resolve) => {
20
- z.getRaw([null, null])
21
- .then(resolve);
22
- }));
23
- return this.arr;
24
- }
25
- load() {
26
- return Promise
27
- .all([this.loadAttrs(), this.loadArr()])
28
- .then(([attrs, arr]) => Promise.resolve(new LoaderResult({ obsIndex: attrs.data.rows, featureIndex: attrs.data.cols, obsFeatureMatrix: arr }, null)));
29
- }
30
- }
@@ -1,62 +0,0 @@
1
- import { viv } from '@vitessce/gl';
2
- import { initializeRasterLayersAndChannels } from '@vitessce/spatial-utils';
3
- import { AbstractLoaderError, LoaderResult, AbstractTwoStepLoader } from '@vitessce/vit-s';
4
- function hexToRgb(hex) {
5
- const result = /^#?([A-F\d]{2})([A-F\d]{2})([A-F\d]{2})$/i.exec(hex);
6
- return [
7
- parseInt(result[1].toLowerCase(), 16),
8
- parseInt(result[2].toLowerCase(), 16),
9
- parseInt(result[3].toLowerCase(), 16),
10
- ];
11
- }
12
- export default class OmeZarrLoader extends AbstractTwoStepLoader {
13
- async load() {
14
- const payload = await this.dataSource.getJson('.zattrs').catch(reason => Promise.resolve(reason));
15
- if (payload instanceof AbstractLoaderError) {
16
- return Promise.reject(payload);
17
- }
18
- const loader = await viv.loadOmeZarr(this.url, { fetchOptions: this.requestInit, type: 'multiscales' });
19
- const { metadata, data } = loader;
20
- const { omero } = metadata;
21
- if (!omero) {
22
- console.error('Path for image not valid');
23
- return Promise.reject(payload);
24
- }
25
- const { rdefs, channels } = omero;
26
- const t = rdefs.defaultT ?? 0;
27
- const z = rdefs.defaultZ ?? 0;
28
- const filterSelection = (sel) => {
29
- // Remove selection keys for which there is no dimension.
30
- if (data.length > 0) {
31
- const nextSel = {};
32
- // eslint-disable-next-line prefer-destructuring
33
- const labels = data[0].labels;
34
- Object.keys(sel).forEach((key) => {
35
- if (labels.includes(key)) {
36
- nextSel[key] = sel[key];
37
- }
38
- });
39
- return nextSel;
40
- }
41
- return sel;
42
- };
43
- const imagesWithLoaderCreators = [
44
- {
45
- name: omero.name || 'Image',
46
- channels: channels.map((channel, i) => ({
47
- selection: filterSelection({ z, t, c: i }),
48
- slider: [channel.window.start, channel.window.end],
49
- color: hexToRgb(channel.color),
50
- })),
51
- loaderCreator: async () => ({ ...loader, channels: channels.map(c => c.label) }),
52
- },
53
- ];
54
- // TODO: use options for initial selection of channels
55
- // which omit domain/slider ranges.
56
- const [autoImageLayers, imageLayerLoaders, imageLayerMeta,] = await initializeRasterLayersAndChannels(imagesWithLoaderCreators, undefined);
57
- const coordinationValues = {
58
- spatialImageLayer: autoImageLayers,
59
- };
60
- return Promise.resolve(new LoaderResult({ image: { loaders: imageLayerLoaders, meta: imageLayerMeta } }, [], coordinationValues));
61
- }
62
- }