@vitessce/zarr 3.3.4 → 3.3.6
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.
- package/dist/{deflate-2848c853.js → deflate-a5b3ac82.js} +1 -1
- package/dist/{index-7834bb8a.js → index-64325dc0.js} +72 -20
- package/dist/index.js +8 -7
- package/dist/{jpeg-9b2ac1f0.js → jpeg-d7680a9e.js} +1 -1
- package/dist/{lerc-d9d48dd9.js → lerc-e1ef6468.js} +1 -1
- package/dist/{lzw-9a4d61c2.js → lzw-b8d50e5c.js} +1 -1
- package/dist/{packbits-ced63ad0.js → packbits-d21ec38d.js} +1 -1
- package/dist/{raw-519d52dc.js → raw-bc2c5642.js} +1 -1
- package/dist/{webimage-2bcf7043.js → webimage-71c5dd88.js} +1 -1
- package/dist-tsc/anndata-loaders/ObsFeatureColumnsAnndataLoader.d.ts +19 -0
- package/dist-tsc/anndata-loaders/ObsFeatureColumnsAnndataLoader.d.ts.map +1 -0
- package/dist-tsc/anndata-loaders/ObsFeatureColumnsAnndataLoader.js +46 -0
- package/dist-tsc/anndata-loaders/index.d.ts +1 -0
- package/dist-tsc/anndata-loaders/index.js +1 -0
- package/dist-tsc/utils.d.ts +1 -0
- package/dist-tsc/utils.d.ts.map +1 -1
- package/dist-tsc/utils.js +4 -0
- package/package.json +10 -10
- package/src/anndata-loaders/ObsFeatureColumnsAnndataLoader.js +57 -0
- package/src/anndata-loaders/index.js +1 -0
- package/src/utils.js +5 -0
|
@@ -1507,6 +1507,10 @@ function dirname$1(path) {
|
|
|
1507
1507
|
arr.pop();
|
|
1508
1508
|
return arr.join("/");
|
|
1509
1509
|
}
|
|
1510
|
+
function basename(path) {
|
|
1511
|
+
const arr = path.split("/");
|
|
1512
|
+
return arr.at(-1);
|
|
1513
|
+
}
|
|
1510
1514
|
class AnnDataSource extends ZarrDataSource {
|
|
1511
1515
|
constructor(...args) {
|
|
1512
1516
|
super(...args);
|
|
@@ -2386,6 +2390,7 @@ const FileType$1 = {
|
|
|
2386
2390
|
OBS_SEGMENTATIONS_OME_ZARR: "obsSegmentations.ome-zarr",
|
|
2387
2391
|
// AnnData
|
|
2388
2392
|
OBS_FEATURE_MATRIX_ANNDATA_ZARR: "obsFeatureMatrix.anndata.zarr",
|
|
2393
|
+
OBS_FEATURE_COLUMNS_ANNDATA_ZARR: "obsFeatureColumns.anndata.zarr",
|
|
2389
2394
|
OBS_SETS_ANNDATA_ZARR: "obsSets.anndata.zarr",
|
|
2390
2395
|
OBS_EMBEDDING_ANNDATA_ZARR: "obsEmbedding.anndata.zarr",
|
|
2391
2396
|
OBS_SPOTS_ANNDATA_ZARR: "obsSpots.anndata.zarr",
|
|
@@ -2949,9 +2954,6 @@ var pluralizeExports = pluralize.exports;
|
|
|
2949
2954
|
const plur = /* @__PURE__ */ getDefaultExportFromCjs(pluralizeExports);
|
|
2950
2955
|
plur.addPluralRule("glomerulus", "glomeruli");
|
|
2951
2956
|
plur.addPluralRule("interstitium", "interstitia");
|
|
2952
|
-
function fromEntries(iterable) {
|
|
2953
|
-
return [...iterable].reduce((obj, { 0: key, 1: val }) => Object.assign(obj, { [key]: val }), {});
|
|
2954
|
-
}
|
|
2955
2957
|
function capitalize(word) {
|
|
2956
2958
|
return word ? word.charAt(0).toUpperCase() + word.slice(1) : "";
|
|
2957
2959
|
}
|
|
@@ -120976,7 +120978,8 @@ const AXIS_TITLE_TEXT_SIZE = 15;
|
|
|
120976
120978
|
const AXIS_MARGIN = 3;
|
|
120977
120979
|
const THEME_TO_TEXT_COLOR = {
|
|
120978
120980
|
dark: [224, 224, 224],
|
|
120979
|
-
light: [64, 64, 64]
|
|
120981
|
+
light: [64, 64, 64],
|
|
120982
|
+
light2: [64, 64, 64]
|
|
120980
120983
|
};
|
|
120981
120984
|
const AXIS_FONT_FAMILY = "-apple-system, 'Helvetica Neue', Arial, sans-serif";
|
|
120982
120985
|
const PIXELATED_TEXTURE_PARAMETERS = {
|
|
@@ -122079,16 +122082,16 @@ function addDecoder(cases, importFn) {
|
|
|
122079
122082
|
}
|
|
122080
122083
|
cases.forEach((c) => registry$1.set(c, importFn));
|
|
122081
122084
|
}
|
|
122082
|
-
addDecoder([void 0, 1], () => import("./raw-
|
|
122083
|
-
addDecoder(5, () => import("./lzw-
|
|
122085
|
+
addDecoder([void 0, 1], () => import("./raw-bc2c5642.js").then((m) => m.default));
|
|
122086
|
+
addDecoder(5, () => import("./lzw-b8d50e5c.js").then((m) => m.default));
|
|
122084
122087
|
addDecoder(6, () => {
|
|
122085
122088
|
throw new Error("old style JPEG compression is not supported.");
|
|
122086
122089
|
});
|
|
122087
|
-
addDecoder(7, () => import("./jpeg-
|
|
122088
|
-
addDecoder([8, 32946], () => import("./deflate-
|
|
122089
|
-
addDecoder(32773, () => import("./packbits-
|
|
122090
|
-
addDecoder(34887, () => import("./lerc-
|
|
122091
|
-
addDecoder(50001, () => import("./webimage-
|
|
122090
|
+
addDecoder(7, () => import("./jpeg-d7680a9e.js").then((m) => m.default));
|
|
122091
|
+
addDecoder([8, 32946], () => import("./deflate-a5b3ac82.js").then((m) => m.default));
|
|
122092
|
+
addDecoder(32773, () => import("./packbits-d21ec38d.js").then((m) => m.default));
|
|
122093
|
+
addDecoder(34887, () => import("./lerc-e1ef6468.js").then((m) => m.default));
|
|
122094
|
+
addDecoder(50001, () => import("./webimage-71c5dd88.js").then((m) => m.default));
|
|
122092
122095
|
function decodeRowAcc(row, stride) {
|
|
122093
122096
|
let length2 = row.length - stride;
|
|
122094
122097
|
let offset = 0;
|
|
@@ -133634,7 +133637,7 @@ class BitmaskLayer2 extends XRLayer {
|
|
|
133634
133637
|
} = this.state;
|
|
133635
133638
|
if (textures && model) {
|
|
133636
133639
|
const scaleFactor = 1 / 2 ** (maxZoom - zoom);
|
|
133637
|
-
const colors = fromEntries(range$5(MAX_CHANNELS).map((i2) => [`color${i2}`, getColor(channelColors[i2])]));
|
|
133640
|
+
const colors = Object.fromEntries(range$5(MAX_CHANNELS).map((i2) => [`color${i2}`, getColor(channelColors[i2])]));
|
|
133638
133641
|
model.setUniforms(Object.assign({}, uniforms, {
|
|
133639
133642
|
...colors,
|
|
133640
133643
|
// Bitmask image channel data textures
|
|
@@ -133791,7 +133794,7 @@ function filterSelection(loader, selection) {
|
|
|
133791
133794
|
}
|
|
133792
133795
|
const data = Array.isArray(loader) ? loader[loader.length - 1] : loader;
|
|
133793
133796
|
const { labels } = data;
|
|
133794
|
-
return fromEntries(Object.entries(selection).filter(([key]) => labels.includes(key)));
|
|
133797
|
+
return Object.fromEntries(Object.entries(selection).filter(([key]) => labels.includes(key)));
|
|
133795
133798
|
}
|
|
133796
133799
|
async function getSingleSelectionStats2D({ loader, selection }) {
|
|
133797
133800
|
const data = Array.isArray(loader) ? loader[loader.length - 1] : loader;
|
|
@@ -141560,7 +141563,7 @@ function configSchemaToVersion(zodSchema) {
|
|
|
141560
141563
|
return zodSchema.shape.version._def.value;
|
|
141561
141564
|
}
|
|
141562
141565
|
({
|
|
141563
|
-
...fromEntries(SCHEMA_HANDLERS.map(([zodSchema]) => {
|
|
141566
|
+
...Object.fromEntries(SCHEMA_HANDLERS.map(([zodSchema]) => {
|
|
141564
141567
|
const version2 = configSchemaToVersion(zodSchema);
|
|
141565
141568
|
return [version2, zodSchema];
|
|
141566
141569
|
})),
|
|
@@ -141636,6 +141639,9 @@ const annDataObsSets = z.array(z.object({
|
|
|
141636
141639
|
]),
|
|
141637
141640
|
scorePath: z.string().optional().describe("The location in the AnnData store for the set confidence scores, like 'obs/celltype_prediction_score.'")
|
|
141638
141641
|
}));
|
|
141642
|
+
z.array(z.object({
|
|
141643
|
+
path: z.string()
|
|
141644
|
+
}));
|
|
141639
141645
|
const annDataObsSpots = annDataObsm;
|
|
141640
141646
|
const annDataObsPoints = annDataObsm;
|
|
141641
141647
|
const annDataObsLocations = annDataObsm;
|
|
@@ -148652,6 +148658,51 @@ class FeatureLabelsAnndataLoader extends AbstractTwoStepLoader {
|
|
|
148652
148658
|
)));
|
|
148653
148659
|
}
|
|
148654
148660
|
}
|
|
148661
|
+
class ObsFeatureColumnsAnndataLoader extends AbstractTwoStepLoader {
|
|
148662
|
+
/**
|
|
148663
|
+
* Class method for loading embedding coordinates, such as those from UMAP or t-SNE.
|
|
148664
|
+
* @returns {Promise} A promise for an array of columns.
|
|
148665
|
+
*/
|
|
148666
|
+
async loadObsFeatureColumns() {
|
|
148667
|
+
const { options } = this;
|
|
148668
|
+
if (this.obsFeatureColumns) {
|
|
148669
|
+
return this.obsFeatureColumns;
|
|
148670
|
+
}
|
|
148671
|
+
if (!this.obsFeatureColumns) {
|
|
148672
|
+
const colPaths = options.map(({ path }) => path);
|
|
148673
|
+
const firstPath = colPaths[0];
|
|
148674
|
+
const obsIndex = await this.dataSource.loadObsIndex(firstPath);
|
|
148675
|
+
const featureIndex = colPaths.map((colPath) => basename(colPath));
|
|
148676
|
+
const shape = [obsIndex.length, featureIndex.length];
|
|
148677
|
+
const out = new Float32Array(shape[0] * shape[1]);
|
|
148678
|
+
const data = await Promise.all(
|
|
148679
|
+
colPaths.map((colPath) => this.dataSource.loadNumeric(colPath))
|
|
148680
|
+
);
|
|
148681
|
+
data.forEach((colData, featureI) => {
|
|
148682
|
+
obsIndex.forEach((obsId, obsI) => {
|
|
148683
|
+
out[obsI * shape[1] + featureI] = colData.data[obsI];
|
|
148684
|
+
});
|
|
148685
|
+
});
|
|
148686
|
+
const obsFeatureMatrix = { data: out };
|
|
148687
|
+
this.obsFeatureColumns = { obsIndex, featureIndex, obsFeatureMatrix };
|
|
148688
|
+
return this.obsFeatureColumns;
|
|
148689
|
+
}
|
|
148690
|
+
this.obsFeatureColumns = Promise.resolve(null);
|
|
148691
|
+
return this.obsFeatureColumns;
|
|
148692
|
+
}
|
|
148693
|
+
async load() {
|
|
148694
|
+
const superResult = await super.load().catch((reason) => Promise.resolve(reason));
|
|
148695
|
+
if (superResult instanceof AbstractLoaderError) {
|
|
148696
|
+
return Promise.reject(superResult);
|
|
148697
|
+
}
|
|
148698
|
+
return Promise.all([
|
|
148699
|
+
this.loadObsFeatureColumns()
|
|
148700
|
+
]).then(([{ obsIndex, obsFeatureMatrix, featureIndex }]) => Promise.resolve(new LoaderResult(
|
|
148701
|
+
{ obsIndex, obsFeatureMatrix, featureIndex },
|
|
148702
|
+
null
|
|
148703
|
+
)));
|
|
148704
|
+
}
|
|
148705
|
+
}
|
|
148655
148706
|
class ImageWrapper {
|
|
148656
148707
|
constructor(vivLoader, options) {
|
|
148657
148708
|
__publicField(this, "vivLoader");
|
|
@@ -149277,10 +149328,11 @@ export {
|
|
|
149277
149328
|
ObsSegmentationsAnndataLoader as h,
|
|
149278
149329
|
ObsSetsAnndataLoader as i,
|
|
149279
149330
|
ObsLabelsAnndataLoader as j,
|
|
149280
|
-
|
|
149281
|
-
|
|
149282
|
-
|
|
149283
|
-
|
|
149284
|
-
|
|
149285
|
-
|
|
149331
|
+
ObsFeatureColumnsAnndataLoader as k,
|
|
149332
|
+
OmeZarrLoader as l,
|
|
149333
|
+
OmeZarrAsObsSegmentationsLoader as m,
|
|
149334
|
+
SpatialDataImageLoader as n,
|
|
149335
|
+
SpatialDataLabelsLoader as o,
|
|
149336
|
+
SpatialDataObsSpotsLoader as p,
|
|
149337
|
+
SpatialDataObsSetsLoader as q
|
|
149286
149338
|
};
|
package/dist/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { A, F, G, b, M, c, O, j, f, e, h, i, d, l,
|
|
1
|
+
import { A, F, G, b, M, c, k, O, j, f, e, h, i, d, m, l, n, o, q, p, a, S, Z } from "./index-64325dc0.js";
|
|
2
2
|
import "@vitessce/vit-s";
|
|
3
3
|
import "react";
|
|
4
4
|
export {
|
|
@@ -8,6 +8,7 @@ export {
|
|
|
8
8
|
b as MatrixZarrAsObsFeatureMatrixLoader,
|
|
9
9
|
M as MuDataSource,
|
|
10
10
|
c as ObsEmbeddingAnndataLoader,
|
|
11
|
+
k as ObsFeatureColumnsAnndataLoader,
|
|
11
12
|
O as ObsFeatureMatrixAnndataLoader,
|
|
12
13
|
j as ObsLabelsAnndataLoader,
|
|
13
14
|
f as ObsLocationsAnndataLoader,
|
|
@@ -15,12 +16,12 @@ export {
|
|
|
15
16
|
h as ObsSegmentationsAnndataLoader,
|
|
16
17
|
i as ObsSetsAnndataLoader,
|
|
17
18
|
d as ObsSpotsAnndataLoader,
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
19
|
+
m as OmeZarrAsObsSegmentationsLoader,
|
|
20
|
+
l as OmeZarrLoader,
|
|
21
|
+
n as SpatialDataImageLoader,
|
|
22
|
+
o as SpatialDataLabelsLoader,
|
|
23
|
+
q as SpatialDataObsSetsLoader,
|
|
24
|
+
p as SpatialDataObsSpotsLoader,
|
|
24
25
|
a as SpatialDataShapesSource,
|
|
25
26
|
S as SpatialDataTableSource,
|
|
26
27
|
Z as ZarrDataSource
|
|
@@ -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-
|
|
2
|
+
import { g as getDefaultExportFromCjs, B as BaseDecoder } from "./index-64325dc0.js";
|
|
3
3
|
import "@vitessce/vit-s";
|
|
4
4
|
import "react";
|
|
5
5
|
const LercParameters = {
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Loader for embedding arrays located in anndata.zarr stores.
|
|
3
|
+
*/
|
|
4
|
+
export default class ObsFeatureColumnsAnndataLoader {
|
|
5
|
+
/**
|
|
6
|
+
* Class method for loading embedding coordinates, such as those from UMAP or t-SNE.
|
|
7
|
+
* @returns {Promise} A promise for an array of columns.
|
|
8
|
+
*/
|
|
9
|
+
loadObsFeatureColumns(): Promise<any>;
|
|
10
|
+
obsFeatureColumns: Promise<null> | {
|
|
11
|
+
obsIndex: any;
|
|
12
|
+
featureIndex: any;
|
|
13
|
+
obsFeatureMatrix: {
|
|
14
|
+
data: Float32Array;
|
|
15
|
+
};
|
|
16
|
+
} | undefined;
|
|
17
|
+
load(): Promise<any>;
|
|
18
|
+
}
|
|
19
|
+
//# sourceMappingURL=ObsFeatureColumnsAnndataLoader.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ObsFeatureColumnsAnndataLoader.d.ts","sourceRoot":"","sources":["../../src/anndata-loaders/ObsFeatureColumnsAnndataLoader.js"],"names":[],"mappings":"AAKA;;GAEG;AACH;IACE;;;OAGG;IACH,sCA4BC;IANG;;;;;;kBAAqE;IAQzE,qBAYC;CACF"}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { LoaderResult, AbstractTwoStepLoader, AbstractLoaderError, } from '@vitessce/vit-s';
|
|
2
|
+
import { basename } from '../utils.js';
|
|
3
|
+
/**
|
|
4
|
+
* Loader for embedding arrays located in anndata.zarr stores.
|
|
5
|
+
*/
|
|
6
|
+
export default class ObsFeatureColumnsAnndataLoader extends AbstractTwoStepLoader {
|
|
7
|
+
/**
|
|
8
|
+
* Class method for loading embedding coordinates, such as those from UMAP or t-SNE.
|
|
9
|
+
* @returns {Promise} A promise for an array of columns.
|
|
10
|
+
*/
|
|
11
|
+
async loadObsFeatureColumns() {
|
|
12
|
+
const { options } = this;
|
|
13
|
+
if (this.obsFeatureColumns) {
|
|
14
|
+
return this.obsFeatureColumns;
|
|
15
|
+
}
|
|
16
|
+
if (!this.obsFeatureColumns) {
|
|
17
|
+
const colPaths = options.map(({ path }) => path);
|
|
18
|
+
const firstPath = colPaths[0];
|
|
19
|
+
const obsIndex = await this.dataSource.loadObsIndex(firstPath);
|
|
20
|
+
const featureIndex = colPaths.map(colPath => basename(colPath));
|
|
21
|
+
const shape = [obsIndex.length, featureIndex.length];
|
|
22
|
+
const out = new Float32Array(shape[0] * shape[1]);
|
|
23
|
+
const data = await Promise.all(colPaths.map(colPath => this.dataSource.loadNumeric(colPath)));
|
|
24
|
+
data.forEach((colData, featureI) => {
|
|
25
|
+
obsIndex.forEach((obsId, obsI) => {
|
|
26
|
+
out[obsI * shape[1] + featureI] = colData.data[obsI];
|
|
27
|
+
});
|
|
28
|
+
});
|
|
29
|
+
const obsFeatureMatrix = { data: out };
|
|
30
|
+
this.obsFeatureColumns = { obsIndex, featureIndex, obsFeatureMatrix };
|
|
31
|
+
return this.obsFeatureColumns;
|
|
32
|
+
}
|
|
33
|
+
this.obsFeatureColumns = Promise.resolve(null);
|
|
34
|
+
return this.obsFeatureColumns;
|
|
35
|
+
}
|
|
36
|
+
async load() {
|
|
37
|
+
const superResult = await super.load().catch(reason => Promise.resolve(reason));
|
|
38
|
+
if (superResult instanceof AbstractLoaderError) {
|
|
39
|
+
return Promise.reject(superResult);
|
|
40
|
+
}
|
|
41
|
+
return Promise.all([
|
|
42
|
+
this.loadObsFeatureColumns(),
|
|
43
|
+
]).then(([{ obsIndex, obsFeatureMatrix, featureIndex }]) => Promise
|
|
44
|
+
.resolve(new LoaderResult({ obsIndex, obsFeatureMatrix, featureIndex }, null)));
|
|
45
|
+
}
|
|
46
|
+
}
|
|
@@ -7,4 +7,5 @@ export { default as ObsSegmentationsAnndataLoader } from "./ObsSegmentationsAnnd
|
|
|
7
7
|
export { default as ObsSetsAnndataLoader } from "./ObsSetsAnndataLoader.js";
|
|
8
8
|
export { default as ObsLabelsAnndataLoader } from "./ObsLabelsAnndataLoader.js";
|
|
9
9
|
export { default as FeatureLabelsAnndataLoader } from "./FeatureLabelsAnndataLoader.js";
|
|
10
|
+
export { default as ObsFeatureColumnsAnndataLoader } from "./ObsFeatureColumnsAnndataLoader.js";
|
|
10
11
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -7,3 +7,4 @@ export { default as ObsSegmentationsAnndataLoader } from './ObsSegmentationsAnnd
|
|
|
7
7
|
export { default as ObsSetsAnndataLoader } from './ObsSetsAnndataLoader.js';
|
|
8
8
|
export { default as ObsLabelsAnndataLoader } from './ObsLabelsAnndataLoader.js';
|
|
9
9
|
export { default as FeatureLabelsAnndataLoader } from './FeatureLabelsAnndataLoader.js';
|
|
10
|
+
export { default as ObsFeatureColumnsAnndataLoader } from './ObsFeatureColumnsAnndataLoader.js';
|
package/dist-tsc/utils.d.ts
CHANGED
package/dist-tsc/utils.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../src/utils.js"],"names":[],"mappings":"AAAA,wCAIC"}
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../src/utils.js"],"names":[],"mappings":"AAAA,wCAIC;AAED,yCAGC"}
|
package/dist-tsc/utils.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vitessce/zarr",
|
|
3
|
-
"version": "3.3.
|
|
3
|
+
"version": "3.3.6",
|
|
4
4
|
"author": "Gehlenborg Lab",
|
|
5
5
|
"homepage": "http://vitessce.io",
|
|
6
6
|
"repository": {
|
|
@@ -19,15 +19,15 @@
|
|
|
19
19
|
"d3-array": "^2.4.0",
|
|
20
20
|
"lodash-es": "^4.17.21",
|
|
21
21
|
"zarrita": "0.4.0-next.4",
|
|
22
|
-
"@vitessce/constants-internal": "3.3.
|
|
23
|
-
"@vitessce/sets-utils": "3.3.
|
|
24
|
-
"@vitessce/
|
|
25
|
-
"@vitessce/spatial-utils": "3.3.
|
|
26
|
-
"@vitessce/
|
|
27
|
-
"@vitessce/
|
|
28
|
-
"@vitessce/vit-s": "3.3.
|
|
29
|
-
"@vitessce/zarr-utils": "3.3.
|
|
30
|
-
"@vitessce/config": "3.3.
|
|
22
|
+
"@vitessce/constants-internal": "3.3.6",
|
|
23
|
+
"@vitessce/sets-utils": "3.3.6",
|
|
24
|
+
"@vitessce/image-utils": "3.3.6",
|
|
25
|
+
"@vitessce/spatial-utils": "3.3.6",
|
|
26
|
+
"@vitessce/utils": "3.3.6",
|
|
27
|
+
"@vitessce/gl": "3.3.6",
|
|
28
|
+
"@vitessce/vit-s": "3.3.6",
|
|
29
|
+
"@vitessce/zarr-utils": "3.3.6",
|
|
30
|
+
"@vitessce/config": "3.3.6"
|
|
31
31
|
},
|
|
32
32
|
"scripts": {
|
|
33
33
|
"bundle": "pnpm exec vite build -c ../../../scripts/vite.config.js",
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import {
|
|
2
|
+
LoaderResult, AbstractTwoStepLoader, AbstractLoaderError,
|
|
3
|
+
} from '@vitessce/vit-s';
|
|
4
|
+
import { basename } from '../utils.js';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Loader for embedding arrays located in anndata.zarr stores.
|
|
8
|
+
*/
|
|
9
|
+
export default class ObsFeatureColumnsAnndataLoader extends AbstractTwoStepLoader {
|
|
10
|
+
/**
|
|
11
|
+
* Class method for loading embedding coordinates, such as those from UMAP or t-SNE.
|
|
12
|
+
* @returns {Promise} A promise for an array of columns.
|
|
13
|
+
*/
|
|
14
|
+
async loadObsFeatureColumns() {
|
|
15
|
+
const { options } = this;
|
|
16
|
+
if (this.obsFeatureColumns) {
|
|
17
|
+
return this.obsFeatureColumns;
|
|
18
|
+
}
|
|
19
|
+
if (!this.obsFeatureColumns) {
|
|
20
|
+
const colPaths = options.map(({ path }) => path);
|
|
21
|
+
const firstPath = colPaths[0];
|
|
22
|
+
const obsIndex = await this.dataSource.loadObsIndex(firstPath);
|
|
23
|
+
const featureIndex = colPaths.map(colPath => basename(colPath));
|
|
24
|
+
const shape = [obsIndex.length, featureIndex.length];
|
|
25
|
+
const out = new Float32Array(shape[0] * shape[1]);
|
|
26
|
+
|
|
27
|
+
const data = await Promise.all(
|
|
28
|
+
colPaths.map(colPath => this.dataSource.loadNumeric(colPath)),
|
|
29
|
+
);
|
|
30
|
+
data.forEach((colData, featureI) => {
|
|
31
|
+
obsIndex.forEach((obsId, obsI) => {
|
|
32
|
+
out[obsI * shape[1] + featureI] = colData.data[obsI];
|
|
33
|
+
});
|
|
34
|
+
});
|
|
35
|
+
const obsFeatureMatrix = { data: out };
|
|
36
|
+
this.obsFeatureColumns = { obsIndex, featureIndex, obsFeatureMatrix };
|
|
37
|
+
|
|
38
|
+
return this.obsFeatureColumns;
|
|
39
|
+
}
|
|
40
|
+
this.obsFeatureColumns = Promise.resolve(null);
|
|
41
|
+
return this.obsFeatureColumns;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
async load() {
|
|
45
|
+
const superResult = await super.load().catch(reason => Promise.resolve(reason));
|
|
46
|
+
if (superResult instanceof AbstractLoaderError) {
|
|
47
|
+
return Promise.reject(superResult);
|
|
48
|
+
}
|
|
49
|
+
return Promise.all([
|
|
50
|
+
this.loadObsFeatureColumns(),
|
|
51
|
+
]).then(([{ obsIndex, obsFeatureMatrix, featureIndex }]) => Promise
|
|
52
|
+
.resolve(new LoaderResult(
|
|
53
|
+
{ obsIndex, obsFeatureMatrix, featureIndex },
|
|
54
|
+
null,
|
|
55
|
+
)));
|
|
56
|
+
}
|
|
57
|
+
}
|
|
@@ -7,3 +7,4 @@ export { default as ObsSegmentationsAnndataLoader } from './ObsSegmentationsAnnd
|
|
|
7
7
|
export { default as ObsSetsAnndataLoader } from './ObsSetsAnndataLoader.js';
|
|
8
8
|
export { default as ObsLabelsAnndataLoader } from './ObsLabelsAnndataLoader.js';
|
|
9
9
|
export { default as FeatureLabelsAnndataLoader } from './FeatureLabelsAnndataLoader.js';
|
|
10
|
+
export { default as ObsFeatureColumnsAnndataLoader } from './ObsFeatureColumnsAnndataLoader.js';
|