@vitessce/zarr 2.0.3-beta.0 → 3.0.0
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-4cf9f098.js +12 -0
- package/dist/index-2a8972b1.js +148326 -0
- package/dist/index.js +18 -6
- package/dist/jpeg-e220efb2.js +839 -0
- package/dist/lerc-12b63f0c.js +2013 -0
- package/dist/lzw-68593c7a.js +127 -0
- package/dist/packbits-c500b823.js +29 -0
- package/dist/pako.esm-68f84e2a.js +4022 -0
- package/dist/raw-d95d6509.js +11 -0
- package/dist/webimage-7938b145.js +31 -0
- package/dist-tsc/AnnDataSource.d.ts +60 -0
- package/dist-tsc/AnnDataSource.d.ts.map +1 -0
- package/{dist → dist-tsc}/AnnDataSource.js +3 -7
- package/dist-tsc/AnnDataSource.test.d.ts +2 -0
- package/dist-tsc/AnnDataSource.test.d.ts.map +1 -0
- package/{dist → dist-tsc}/AnnDataSource.test.js +1 -1
- package/dist-tsc/MuDataSource.d.ts +21 -0
- package/dist-tsc/MuDataSource.d.ts.map +1 -0
- package/{dist → dist-tsc}/MuDataSource.js +1 -1
- package/dist-tsc/MuDataSource.test.d.ts +2 -0
- package/dist-tsc/MuDataSource.test.d.ts.map +1 -0
- package/{dist → dist-tsc}/MuDataSource.test.js +5 -5
- package/dist-tsc/ZarrDataSource.d.ts +21 -0
- package/dist-tsc/ZarrDataSource.d.ts.map +1 -0
- package/dist-tsc/anndata-loaders/FeatureLabelsAnndataLoader.d.ts +13 -0
- package/dist-tsc/anndata-loaders/FeatureLabelsAnndataLoader.d.ts.map +1 -0
- package/{dist → dist-tsc}/anndata-loaders/FeatureLabelsAnndataLoader.js +5 -16
- package/dist-tsc/anndata-loaders/ObsEmbeddingAnndataLoader.d.ts +13 -0
- package/dist-tsc/anndata-loaders/ObsEmbeddingAnndataLoader.d.ts.map +1 -0
- package/{dist → dist-tsc}/anndata-loaders/ObsEmbeddingAnndataLoader.js +6 -6
- package/dist-tsc/anndata-loaders/ObsEmbeddingAnndataLoader.test.d.ts +2 -0
- package/dist-tsc/anndata-loaders/ObsEmbeddingAnndataLoader.test.d.ts.map +1 -0
- package/dist-tsc/anndata-loaders/ObsEmbeddingAnndataLoader.test.js +68 -0
- package/dist-tsc/anndata-loaders/ObsFeatureMatrixAnndataLoader.d.ts +94 -0
- package/dist-tsc/anndata-loaders/ObsFeatureMatrixAnndataLoader.d.ts.map +1 -0
- package/{dist → dist-tsc}/anndata-loaders/ObsFeatureMatrixAnndataLoader.js +20 -43
- package/dist-tsc/anndata-loaders/ObsFeatureMatrixAnndataLoader.test.d.ts +2 -0
- package/dist-tsc/anndata-loaders/ObsFeatureMatrixAnndataLoader.test.d.ts.map +1 -0
- package/dist-tsc/anndata-loaders/ObsFeatureMatrixAnndataLoader.test.js +112 -0
- package/dist-tsc/anndata-loaders/ObsLabelsAnndataLoader.d.ts +13 -0
- package/dist-tsc/anndata-loaders/ObsLabelsAnndataLoader.d.ts.map +1 -0
- package/{dist → dist-tsc}/anndata-loaders/ObsLabelsAnndataLoader.js +3 -6
- package/dist-tsc/anndata-loaders/ObsLocationsAnndataLoader.d.ts +13 -0
- package/dist-tsc/anndata-loaders/ObsLocationsAnndataLoader.d.ts.map +1 -0
- package/{dist → dist-tsc}/anndata-loaders/ObsLocationsAnndataLoader.js +3 -6
- package/dist-tsc/anndata-loaders/ObsSegmentationsAnndataLoader.d.ts +13 -0
- package/dist-tsc/anndata-loaders/ObsSegmentationsAnndataLoader.d.ts.map +1 -0
- package/{dist → dist-tsc}/anndata-loaders/ObsSegmentationsAnndataLoader.js +3 -6
- package/dist-tsc/anndata-loaders/ObsSetsAnndataLoader.d.ts +11 -0
- package/dist-tsc/anndata-loaders/ObsSetsAnndataLoader.d.ts.map +1 -0
- package/{dist → dist-tsc}/anndata-loaders/ObsSetsAnndataLoader.js +20 -5
- package/dist-tsc/anndata-loaders/index.d.ts +8 -0
- package/dist-tsc/anndata-loaders/index.d.ts.map +1 -0
- package/{dist → dist-tsc}/anndata-loaders/index.js +7 -7
- package/dist-tsc/genomic-loaders/GenomicProfilesZarrLoader.d.ts +6 -0
- package/dist-tsc/genomic-loaders/GenomicProfilesZarrLoader.d.ts.map +1 -0
- package/dist-tsc/genomic-loaders/index.d.ts +2 -0
- package/dist-tsc/genomic-loaders/index.d.ts.map +1 -0
- package/{dist → dist-tsc}/genomic-loaders/index.js +1 -1
- package/dist-tsc/index.d.ts +8 -0
- package/dist-tsc/index.d.ts.map +1 -0
- package/dist-tsc/index.js +8 -0
- package/dist-tsc/matrix-loaders/MatrixZarrAsObsFeatureMatrix.d.ts +14 -0
- package/dist-tsc/matrix-loaders/MatrixZarrAsObsFeatureMatrix.d.ts.map +1 -0
- package/dist-tsc/matrix-loaders/index.d.ts +2 -0
- package/dist-tsc/matrix-loaders/index.d.ts.map +1 -0
- package/{dist → dist-tsc}/matrix-loaders/index.js +1 -1
- package/dist-tsc/ome-loaders/OmeZarrLoader.d.ts +4 -0
- package/dist-tsc/ome-loaders/OmeZarrLoader.d.ts.map +1 -0
- package/{dist → dist-tsc}/ome-loaders/OmeZarrLoader.js +22 -5
- package/dist-tsc/ome-loaders/index.d.ts +2 -0
- package/dist-tsc/ome-loaders/index.d.ts.map +1 -0
- package/dist-tsc/ome-loaders/index.js +1 -0
- package/dist-tsc/utils.d.ts +2 -0
- package/dist-tsc/utils.d.ts.map +1 -0
- package/package.json +20 -11
- package/src/AnnDataSource.js +270 -0
- package/src/AnnDataSource.test.js +55 -0
- package/src/MuDataSource.js +78 -0
- package/src/MuDataSource.test.js +48 -0
- package/src/ZarrDataSource.js +36 -0
- package/src/anndata-loaders/FeatureLabelsAnndataLoader.js +46 -0
- package/src/anndata-loaders/ObsEmbeddingAnndataLoader.js +43 -0
- package/src/anndata-loaders/ObsEmbeddingAnndataLoader.test.js +79 -0
- package/src/anndata-loaders/ObsFeatureMatrixAnndataLoader.js +377 -0
- package/src/anndata-loaders/ObsFeatureMatrixAnndataLoader.test.js +124 -0
- package/src/anndata-loaders/ObsLabelsAnndataLoader.js +42 -0
- package/src/anndata-loaders/ObsLocationsAnndataLoader.js +40 -0
- package/src/anndata-loaders/ObsSegmentationsAnndataLoader.js +56 -0
- package/src/anndata-loaders/ObsSetsAnndataLoader.js +78 -0
- package/src/anndata-loaders/index.js +7 -0
- package/src/genomic-loaders/GenomicProfilesZarrLoader.js +17 -0
- package/src/genomic-loaders/index.js +1 -0
- package/src/index.js +8 -0
- package/src/matrix-loaders/MatrixZarrAsObsFeatureMatrix.js +36 -0
- package/src/matrix-loaders/index.js +1 -0
- package/src/ome-loaders/OmeZarrLoader.js +115 -0
- package/src/ome-loaders/index.js +1 -0
- package/src/utils.js +5 -0
- package/dist/anndata-loaders/ObsEmbeddingAnndataLoader.test.js +0 -31
- package/dist/anndata-loaders/ObsFeatureMatrixAnndataLoader.test.js +0 -72
- package/dist/ome-loaders/index.js +0 -1
- /package/{dist → dist-tsc}/ZarrDataSource.js +0 -0
- /package/{dist → dist-tsc}/genomic-loaders/GenomicProfilesZarrLoader.js +0 -0
- /package/{dist → dist-tsc}/matrix-loaders/MatrixZarrAsObsFeatureMatrix.js +0 -0
- /package/{dist → dist-tsc}/utils.js +0 -0
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import {
|
|
2
|
+
LoaderResult, AbstractTwoStepLoader, AbstractLoaderError,
|
|
3
|
+
} from '@vitessce/vit-s';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Loader for embedding arrays located in anndata.zarr stores.
|
|
7
|
+
*/
|
|
8
|
+
export default class ObsEmbeddingAnndataLoader extends AbstractTwoStepLoader {
|
|
9
|
+
/**
|
|
10
|
+
* Class method for loading embedding coordinates, such as those from UMAP or t-SNE.
|
|
11
|
+
* @returns {Promise} A promise for an array of columns.
|
|
12
|
+
*/
|
|
13
|
+
loadEmbedding() {
|
|
14
|
+
const { path, dims = [0, 1] } = this.options;
|
|
15
|
+
if (this.embedding) {
|
|
16
|
+
return this.embedding;
|
|
17
|
+
}
|
|
18
|
+
if (!this.embedding) {
|
|
19
|
+
this.embedding = this.dataSource.loadNumericForDims(path, dims);
|
|
20
|
+
return this.embedding;
|
|
21
|
+
}
|
|
22
|
+
this.embedding = Promise.resolve(null);
|
|
23
|
+
return this.embedding;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
async load() {
|
|
27
|
+
const { path } = this.options;
|
|
28
|
+
const superResult = await super.load().catch(reason => Promise.resolve(reason));
|
|
29
|
+
if (superResult instanceof AbstractLoaderError) {
|
|
30
|
+
return Promise.reject(superResult);
|
|
31
|
+
}
|
|
32
|
+
return Promise.all([
|
|
33
|
+
// Pass in the obsEmbedding path,
|
|
34
|
+
// to handle the MuData case where the obsIndex is located at
|
|
35
|
+
// `mod/rna/index` rather than `index`.
|
|
36
|
+
this.dataSource.loadObsIndex(path),
|
|
37
|
+
this.loadEmbedding(),
|
|
38
|
+
]).then(([obsIndex, obsEmbedding]) => Promise.resolve(new LoaderResult(
|
|
39
|
+
{ obsIndex, obsEmbedding },
|
|
40
|
+
null,
|
|
41
|
+
)));
|
|
42
|
+
}
|
|
43
|
+
}
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
/* eslint-disable func-names */
|
|
2
|
+
import { LoaderResult } from '@vitessce/vit-s';
|
|
3
|
+
import ObsEmbeddingAnndataLoader from './ObsEmbeddingAnndataLoader.js';
|
|
4
|
+
import AnnDataSource from '../AnnDataSource.js';
|
|
5
|
+
import MuDataSource from '../MuDataSource.js';
|
|
6
|
+
|
|
7
|
+
const createAnndataLoader = (url) => {
|
|
8
|
+
const config = {
|
|
9
|
+
url,
|
|
10
|
+
fileType: 'obsEmbedding.anndata.zarr',
|
|
11
|
+
options: {
|
|
12
|
+
path: 'obsm/X_umap',
|
|
13
|
+
},
|
|
14
|
+
coordinationValues: {
|
|
15
|
+
embeddingType: 'UMAP',
|
|
16
|
+
},
|
|
17
|
+
};
|
|
18
|
+
const source = new AnnDataSource(config);
|
|
19
|
+
return new ObsEmbeddingAnndataLoader(source, config);
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
const createMudataLoader = (url) => {
|
|
23
|
+
const config = {
|
|
24
|
+
url,
|
|
25
|
+
fileType: 'obsEmbedding.mudata.zarr',
|
|
26
|
+
options: {
|
|
27
|
+
path: 'mod/rna/obsm/X_umap',
|
|
28
|
+
},
|
|
29
|
+
coordinationValues: {
|
|
30
|
+
embeddingType: 'UMAP',
|
|
31
|
+
},
|
|
32
|
+
};
|
|
33
|
+
const source = new MuDataSource(config);
|
|
34
|
+
return new ObsEmbeddingAnndataLoader(source, config);
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
describe('loaders/ObsEmbeddingAnndataLoader for AnnData', () => {
|
|
38
|
+
it('load returns obsIndex and obsEmbedding', async () => {
|
|
39
|
+
const loader = createAnndataLoader(
|
|
40
|
+
'http://localhost:51204/@fixtures/zarr/anndata-0.7/anndata-dense.zarr',
|
|
41
|
+
);
|
|
42
|
+
const result = await loader.load();
|
|
43
|
+
expect(result).toBeInstanceOf(LoaderResult);
|
|
44
|
+
const payload = result.data;
|
|
45
|
+
expect(Object.keys(payload)).toEqual(['obsIndex', 'obsEmbedding']);
|
|
46
|
+
expect(payload.obsIndex).toEqual(['CTG', 'GCA', 'CTG']);
|
|
47
|
+
expect(payload.obsEmbedding.shape).toEqual([2, 3]);
|
|
48
|
+
expect(Array.from(payload.obsEmbedding.data[0])).toEqual([-1, 0, 1]);
|
|
49
|
+
expect(Array.from(payload.obsEmbedding.data[1])).toEqual([-1, 0, 1]);
|
|
50
|
+
});
|
|
51
|
+
|
|
52
|
+
it('load returns obsIndex and obsEmbedding for MuData', async () => {
|
|
53
|
+
const loader = createMudataLoader(
|
|
54
|
+
'http://localhost:51204/@fixtures/zarr/mudata-0.2/mudata-dense.zarr',
|
|
55
|
+
);
|
|
56
|
+
const result = await loader.load();
|
|
57
|
+
expect(result).toBeInstanceOf(LoaderResult);
|
|
58
|
+
const payload = result.data;
|
|
59
|
+
expect(Object.keys(payload)).toEqual(['obsIndex', 'obsEmbedding']);
|
|
60
|
+
expect(payload.obsIndex).toEqual(['CTG', 'GCA', 'CTT', 'AAA']);
|
|
61
|
+
expect(payload.obsEmbedding.shape).toEqual([2, 4]);
|
|
62
|
+
expect(Array.from(payload.obsEmbedding.data[0])).toEqual([-1, 0, 1, 1]);
|
|
63
|
+
expect(Array.from(payload.obsEmbedding.data[1])).toEqual([-1, 0, 1, 2]);
|
|
64
|
+
});
|
|
65
|
+
|
|
66
|
+
it('load returns obsIndex and obsEmbedding for updated MuData', async () => {
|
|
67
|
+
const loader = createMudataLoader(
|
|
68
|
+
'http://localhost:51204/@fixtures/zarr/mudata-0.2/mudata-dense-updated.zarr',
|
|
69
|
+
);
|
|
70
|
+
const result = await loader.load();
|
|
71
|
+
expect(result).toBeInstanceOf(LoaderResult);
|
|
72
|
+
const payload = result.data;
|
|
73
|
+
expect(Object.keys(payload)).toEqual(['obsIndex', 'obsEmbedding']);
|
|
74
|
+
expect(payload.obsIndex).toEqual(['CTG', 'GCA', 'CTT', 'AAA']);
|
|
75
|
+
expect(payload.obsEmbedding.shape).toEqual([2, 4]);
|
|
76
|
+
expect(Array.from(payload.obsEmbedding.data[0])).toEqual([-1, 0, 1, 1]);
|
|
77
|
+
expect(Array.from(payload.obsEmbedding.data[1])).toEqual([-1, 0, 1, 2]);
|
|
78
|
+
});
|
|
79
|
+
});
|
|
@@ -0,0 +1,377 @@
|
|
|
1
|
+
/* eslint-disable no-underscore-dangle */
|
|
2
|
+
import { openArray, slice } from 'zarr';
|
|
3
|
+
import {
|
|
4
|
+
LoaderResult, AbstractTwoStepLoader, AbstractLoaderError,
|
|
5
|
+
} from '@vitessce/vit-s';
|
|
6
|
+
|
|
7
|
+
// Put array of data into an object,
|
|
8
|
+
// to match the expected format of the
|
|
9
|
+
// value returned from the load function.
|
|
10
|
+
const toObject = data => ({ data });
|
|
11
|
+
|
|
12
|
+
const concatenateColumnVectors = (arr) => {
|
|
13
|
+
const numCols = arr.length;
|
|
14
|
+
const numRows = arr[0].length;
|
|
15
|
+
const { BYTES_PER_ELEMENT } = arr[0];
|
|
16
|
+
const view = new DataView(new ArrayBuffer(numCols * numRows * BYTES_PER_ELEMENT));
|
|
17
|
+
const TypedArray = arr[0].constructor;
|
|
18
|
+
const dtype = TypedArray.name.replace('Array', '');
|
|
19
|
+
for (let i = 0; i < numCols; i += 1) {
|
|
20
|
+
for (let j = 0; j < numRows; j += 1) {
|
|
21
|
+
view[`set${dtype}`](BYTES_PER_ELEMENT * (j * numCols + i), arr[i][j], true);
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
return new TypedArray(view.buffer);
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* Loader for converting zarr into the a cell x gene matrix for use in Genes/Heatmap components.
|
|
29
|
+
*/
|
|
30
|
+
export default class ObsFeatureMatrixAnndataLoader extends AbstractTwoStepLoader {
|
|
31
|
+
getOptions() {
|
|
32
|
+
return this.options;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* Class method for loading the genes list from AnnData.var,
|
|
37
|
+
* filtered if a there is a `geneFilterZarr` present in the view config.
|
|
38
|
+
* @returns {Promise} A promise for the zarr array contianing the gene names.
|
|
39
|
+
*/
|
|
40
|
+
async loadFilteredGeneNames() {
|
|
41
|
+
if (this.filteredGeneNames) {
|
|
42
|
+
return this.filteredGeneNames;
|
|
43
|
+
}
|
|
44
|
+
const { path, featureFilterPath: geneFilterZarr, geneAlias } = this.getOptions();
|
|
45
|
+
const getFilterFn = async () => {
|
|
46
|
+
if (!geneFilterZarr) return data => data;
|
|
47
|
+
const geneFilter = await this.dataSource.getFlatArrDecompressed(geneFilterZarr);
|
|
48
|
+
return data => data.filter((_, j) => geneFilter[j]);
|
|
49
|
+
};
|
|
50
|
+
const geneNamesPromise = geneAlias
|
|
51
|
+
? this.dataSource.loadVarAlias(geneAlias, path)
|
|
52
|
+
: this.dataSource.loadVarIndex(path);
|
|
53
|
+
this.filteredGeneNames = Promise.all([
|
|
54
|
+
geneNamesPromise,
|
|
55
|
+
getFilterFn(),
|
|
56
|
+
]).then(([data, filter]) => filter(data));
|
|
57
|
+
return this.filteredGeneNames;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
/**
|
|
61
|
+
* Class method for loading a filtered subset of the genes list
|
|
62
|
+
* @param {String} filterZarr A location in the zarr store to fetch a boolean array from.
|
|
63
|
+
* @returns {Array} A list of filtered genes.
|
|
64
|
+
*/
|
|
65
|
+
async _getFilteredGenes(filterZarr) {
|
|
66
|
+
const filter = await this.dataSource.getFlatArrDecompressed(filterZarr);
|
|
67
|
+
const geneNames = await this.loadFilteredGeneNames();
|
|
68
|
+
const genes = geneNames.filter((_, i) => filter[i]);
|
|
69
|
+
return genes;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
/**
|
|
73
|
+
* Class method for getting the integer indices of a selection of genes within a list.
|
|
74
|
+
* @param {Array} selection A list of gene names.
|
|
75
|
+
* @returns {Array} A list of integer indices.
|
|
76
|
+
*/
|
|
77
|
+
async _getGeneIndices(selection) {
|
|
78
|
+
const geneNames = await this.loadFilteredGeneNames();
|
|
79
|
+
return selection.map(gene => geneNames.indexOf(gene));
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
/**
|
|
83
|
+
* Class method for getting the number of cells i.e entries in `obs`.
|
|
84
|
+
* @returns {Number} The number of cells.
|
|
85
|
+
*/
|
|
86
|
+
async _getNumCells() {
|
|
87
|
+
const { path } = this.getOptions();
|
|
88
|
+
const cells = await this.dataSource.loadObsIndex(path);
|
|
89
|
+
return cells.length;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
/**
|
|
93
|
+
* Class method for getting the number of genes i.e entries in `var`,
|
|
94
|
+
* potentially filtered by `genesFilter`.
|
|
95
|
+
* @returns {Number} The number of genes.
|
|
96
|
+
*/
|
|
97
|
+
async _getNumGenes() {
|
|
98
|
+
const genes = await this.loadFilteredGeneNames();
|
|
99
|
+
return genes.length;
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
/**
|
|
103
|
+
* Class method for opening the sparse matrix arrays in zarr.
|
|
104
|
+
* @returns {Array} A list of promises pointing to the indptr, indices, and data of the matrix.
|
|
105
|
+
*/
|
|
106
|
+
async _openSparseArrays() {
|
|
107
|
+
const { path: matrix } = this.getOptions();
|
|
108
|
+
const { store } = this.dataSource;
|
|
109
|
+
if (this.sparseArrays) {
|
|
110
|
+
return this.sparseArrays;
|
|
111
|
+
}
|
|
112
|
+
this.sparseArrays = Promise.all(
|
|
113
|
+
['indptr', 'indices', 'data'].map(name => openArray({ store, path: `${matrix}/${name}`, mode: 'r' })),
|
|
114
|
+
);
|
|
115
|
+
return this.sparseArrays;
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
/**
|
|
119
|
+
* Class method for loading a gene selection from a CSC matrix.
|
|
120
|
+
* @param {Array} selection A list of gene names whose data should be fetched.
|
|
121
|
+
* @returns {Promise} A Promise.all array of promises containing Uint8Arrays, one per selection.
|
|
122
|
+
*/
|
|
123
|
+
async _loadCSCGeneSelection(selection) {
|
|
124
|
+
const indices = await this._getGeneIndices(selection);
|
|
125
|
+
const [indptrArr, indexArr, cellXGeneArr] = await this._openSparseArrays();
|
|
126
|
+
const numCells = await this._getNumCells();
|
|
127
|
+
const { data: cols } = await indptrArr.getRaw(null);
|
|
128
|
+
// If there is not change in the column indexer, then the data is all zeros
|
|
129
|
+
return Promise.all(
|
|
130
|
+
indices.map(async (index) => {
|
|
131
|
+
const startRowIndex = cols[index];
|
|
132
|
+
const endRowIndex = cols[index + 1];
|
|
133
|
+
const isColumnAllZeros = startRowIndex === endRowIndex;
|
|
134
|
+
const geneData = new Float32Array(numCells).fill(0);
|
|
135
|
+
if (isColumnAllZeros) {
|
|
136
|
+
return geneData;
|
|
137
|
+
}
|
|
138
|
+
const { data: rowIndices } = await indexArr.get([
|
|
139
|
+
slice(startRowIndex, endRowIndex),
|
|
140
|
+
]);
|
|
141
|
+
const { data: cellXGeneData } = await cellXGeneArr.get([
|
|
142
|
+
slice(startRowIndex, endRowIndex),
|
|
143
|
+
]);
|
|
144
|
+
for (let rowIndex = 0; rowIndex < rowIndices.length; rowIndex += 1) {
|
|
145
|
+
geneData[rowIndices[rowIndex]] = cellXGeneData[rowIndex];
|
|
146
|
+
}
|
|
147
|
+
return geneData;
|
|
148
|
+
}),
|
|
149
|
+
);
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
/**
|
|
153
|
+
* Class method for loading a gene selection from a CSR matrix.
|
|
154
|
+
* @param {Array} selection A list of gene names whose data should be fetched.
|
|
155
|
+
* @returns {Promise} A Promise.all array of promises containing Uint8Arrays, one per selection.
|
|
156
|
+
*/
|
|
157
|
+
async _loadCSRGeneSelection(selection) {
|
|
158
|
+
const indices = await this._getGeneIndices(selection);
|
|
159
|
+
const numGenes = await this._getNumGenes();
|
|
160
|
+
const numCells = await this._getNumCells();
|
|
161
|
+
const cellXGene = await this._loadCSRSparseCellXGene();
|
|
162
|
+
return indices.map((index) => {
|
|
163
|
+
const geneData = new Float32Array(numCells).fill(0);
|
|
164
|
+
for (let i = 0; i < numCells; i += 1) {
|
|
165
|
+
geneData[i] = cellXGene[i * numGenes + index];
|
|
166
|
+
}
|
|
167
|
+
return geneData;
|
|
168
|
+
});
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
/**
|
|
172
|
+
* Class method for loading row oriented (CSR) sparse data from zarr.
|
|
173
|
+
*
|
|
174
|
+
* @returns {Object} A { data: Float32Array } contianing the CellXGene matrix.
|
|
175
|
+
*/
|
|
176
|
+
async _loadCSRSparseCellXGene() {
|
|
177
|
+
if (this._sparseMatrix) {
|
|
178
|
+
return this._sparseMatrix;
|
|
179
|
+
}
|
|
180
|
+
this._sparseMatrix = this._openSparseArrays().then(async (sparseArrays) => {
|
|
181
|
+
const { path: matrix } = this.getOptions();
|
|
182
|
+
const { shape } = await this.dataSource.getJson(`${matrix}/.zattrs`);
|
|
183
|
+
const [rows, cols, cellXGene] = await Promise.all(
|
|
184
|
+
sparseArrays.map(async (arr) => {
|
|
185
|
+
const { data } = await arr.getRaw(null);
|
|
186
|
+
return data;
|
|
187
|
+
}),
|
|
188
|
+
);
|
|
189
|
+
const cellXGeneMatrix = new Float32Array(shape[0] * shape[1]).fill(0);
|
|
190
|
+
let row = 0;
|
|
191
|
+
rows.forEach((_, index) => {
|
|
192
|
+
const rowStart = rows[index];
|
|
193
|
+
const rowEnd = rows[index + 1];
|
|
194
|
+
for (let i = rowStart; i < rowEnd; i += 1) {
|
|
195
|
+
const val = cellXGene[i];
|
|
196
|
+
const col = cols[i];
|
|
197
|
+
cellXGeneMatrix[row * shape[1] + col] = val;
|
|
198
|
+
}
|
|
199
|
+
row += 1;
|
|
200
|
+
});
|
|
201
|
+
return cellXGeneMatrix;
|
|
202
|
+
});
|
|
203
|
+
return this._sparseMatrix;
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
/**
|
|
207
|
+
* Class method for loading column oriented (CSC) sparse data from zarr.
|
|
208
|
+
* @returns {Object} A { data: Float32Array } contianing the CellXGene matrix.
|
|
209
|
+
*/
|
|
210
|
+
async _loadCSCSparseCellXGene() {
|
|
211
|
+
if (this._sparseMatrix) {
|
|
212
|
+
return this._sparseMatrix;
|
|
213
|
+
}
|
|
214
|
+
this._sparseMatrix = this._openSparseArrays().then(async (sparseArrays) => {
|
|
215
|
+
const { path: matrix } = this.getOptions();
|
|
216
|
+
const { shape } = await this.dataSource.getJson(`${matrix}/.zattrs`);
|
|
217
|
+
const [cols, rows, cellXGene] = await Promise.all(
|
|
218
|
+
sparseArrays.map(async (arr) => {
|
|
219
|
+
const { data } = await arr.getRaw(null);
|
|
220
|
+
return data;
|
|
221
|
+
}),
|
|
222
|
+
);
|
|
223
|
+
const cellXGeneMatrix = new Float32Array(shape[0] * shape[1]).fill(0);
|
|
224
|
+
let col = 0;
|
|
225
|
+
cols.forEach((_, index) => {
|
|
226
|
+
const colStart = cols[index];
|
|
227
|
+
const colEnd = cols[index + 1];
|
|
228
|
+
for (let i = colStart; i < colEnd; i += 1) {
|
|
229
|
+
const val = cellXGene[i];
|
|
230
|
+
const row = rows[i];
|
|
231
|
+
cellXGeneMatrix[row * shape[1] + col] = val;
|
|
232
|
+
}
|
|
233
|
+
col += 1;
|
|
234
|
+
});
|
|
235
|
+
return cellXGeneMatrix;
|
|
236
|
+
});
|
|
237
|
+
return this._sparseMatrix;
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
/**
|
|
241
|
+
* Class method for loading the cell x gene matrix.
|
|
242
|
+
* @returns {Promise} A promise for the zarr array contianing the cell x gene data.
|
|
243
|
+
*/
|
|
244
|
+
async loadCellXGene() {
|
|
245
|
+
const { store } = this.dataSource;
|
|
246
|
+
if (this.cellXGene) {
|
|
247
|
+
return this.cellXGene;
|
|
248
|
+
}
|
|
249
|
+
const {
|
|
250
|
+
path: matrix,
|
|
251
|
+
initialFeatureFilterPath: matrixGeneFilter,
|
|
252
|
+
} = this.getOptions();
|
|
253
|
+
if (!this._matrixZattrs) {
|
|
254
|
+
this._matrixZattrs = await this.dataSource.getJson(`${matrix}/.zattrs`);
|
|
255
|
+
}
|
|
256
|
+
const encodingType = this._matrixZattrs['encoding-type'];
|
|
257
|
+
if (!matrixGeneFilter) {
|
|
258
|
+
if (encodingType === 'csr_matrix') {
|
|
259
|
+
this.cellXGene = this._loadCSRSparseCellXGene().then(data => toObject(data));
|
|
260
|
+
} else if (encodingType === 'csc_matrix') {
|
|
261
|
+
this.cellXGene = this._loadCSCSparseCellXGene().then(data => toObject(data));
|
|
262
|
+
} else {
|
|
263
|
+
if (!this.arr) {
|
|
264
|
+
this.arr = openArray({ store, path: matrix, mode: 'r' });
|
|
265
|
+
}
|
|
266
|
+
this.cellXGene = this.arr.then(z => z.getRaw(null).then(({ data }) => toObject(data)));
|
|
267
|
+
}
|
|
268
|
+
} else if (encodingType === 'csr_matrix') {
|
|
269
|
+
this.cellXGene = this._loadCSRSparseCellXGene().then(
|
|
270
|
+
async (cellXGene) => {
|
|
271
|
+
const filteredGenes = await this._getFilteredGenes(matrixGeneFilter);
|
|
272
|
+
const numGenesFiltered = filteredGenes.length;
|
|
273
|
+
const geneNames = await this.loadFilteredGeneNames();
|
|
274
|
+
const numGenes = geneNames.length;
|
|
275
|
+
const numCells = await this._getNumCells();
|
|
276
|
+
const cellXGeneMatrixFiltered = new Float32Array(
|
|
277
|
+
numCells * numGenesFiltered,
|
|
278
|
+
).fill(0);
|
|
279
|
+
for (let i = 0; i < numGenesFiltered; i += 1) {
|
|
280
|
+
const index = geneNames.indexOf(filteredGenes[i]);
|
|
281
|
+
for (let j = 0; j < numCells; j += 1) {
|
|
282
|
+
cellXGeneMatrixFiltered[j * numGenesFiltered + i] = cellXGene[j * numGenes + index];
|
|
283
|
+
}
|
|
284
|
+
}
|
|
285
|
+
return toObject(cellXGeneMatrixFiltered);
|
|
286
|
+
},
|
|
287
|
+
);
|
|
288
|
+
} else {
|
|
289
|
+
const genes = await this._getFilteredGenes(matrixGeneFilter);
|
|
290
|
+
this.cellXGene = this.loadGeneSelection({ selection: genes, shouldNormalize: false })
|
|
291
|
+
.then(({ data }) => (toObject(concatenateColumnVectors(data))));
|
|
292
|
+
}
|
|
293
|
+
return this.cellXGene;
|
|
294
|
+
}
|
|
295
|
+
|
|
296
|
+
/**
|
|
297
|
+
* Class method for loading a gene selection.
|
|
298
|
+
* @param {Object} args
|
|
299
|
+
* @param {Array} args.selection A list of gene names whose data should be fetched.
|
|
300
|
+
* @param {Boolean} args.shouldNormalize A list of gene names whose data should be fetched.
|
|
301
|
+
* @returns {Object} { data } containing an array of gene expression data.
|
|
302
|
+
*/
|
|
303
|
+
async loadGeneSelection({ selection, shouldNormalize = true }) {
|
|
304
|
+
const { path: matrix } = this.getOptions();
|
|
305
|
+
const { store } = this.dataSource;
|
|
306
|
+
if (!this._matrixZattrs) {
|
|
307
|
+
this._matrixZattrs = await this.dataSource.getJson(`${matrix}/.zattrs`);
|
|
308
|
+
}
|
|
309
|
+
const encodingType = this._matrixZattrs['encoding-type'];
|
|
310
|
+
let genes;
|
|
311
|
+
if (encodingType === 'csc_matrix') {
|
|
312
|
+
genes = await this._loadCSCGeneSelection(selection);
|
|
313
|
+
} else if (encodingType === 'csr_matrix') {
|
|
314
|
+
genes = await this._loadCSRGeneSelection(selection);
|
|
315
|
+
} else {
|
|
316
|
+
if (!this.arr) {
|
|
317
|
+
this.arr = openArray({ store, path: matrix, mode: 'r' });
|
|
318
|
+
}
|
|
319
|
+
const indices = await this._getGeneIndices(selection);
|
|
320
|
+
// We can index directly into a normal dense array zarr store via `get`.
|
|
321
|
+
genes = await Promise.all(
|
|
322
|
+
indices.map(index => this.arr.then(z => z.get([null, index])).then(({ data }) => data)),
|
|
323
|
+
);
|
|
324
|
+
}
|
|
325
|
+
return { data: genes.map(i => (shouldNormalize ? toObject(i).data : i)), url: null };
|
|
326
|
+
}
|
|
327
|
+
|
|
328
|
+
/**
|
|
329
|
+
* Class method for loading only attributes i.e rows and columns
|
|
330
|
+
* @param {Array} selection A list of gene names whose data should be fetched.
|
|
331
|
+
* @returns {Object} { data: { rows, cols }, url } containing row and col labels for the matrix.
|
|
332
|
+
*/
|
|
333
|
+
loadAttrs() {
|
|
334
|
+
const { path } = this.getOptions();
|
|
335
|
+
return Promise.all([this.dataSource.loadObsIndex(path), this.loadFilteredGeneNames()])
|
|
336
|
+
.then((d) => {
|
|
337
|
+
const [cellNames, geneNames] = d;
|
|
338
|
+
const attrs = { rows: cellNames, cols: geneNames };
|
|
339
|
+
return {
|
|
340
|
+
data: attrs,
|
|
341
|
+
url: null,
|
|
342
|
+
};
|
|
343
|
+
});
|
|
344
|
+
}
|
|
345
|
+
|
|
346
|
+
async loadInitialFilteredGeneNames() {
|
|
347
|
+
const filteredGeneNames = await this.loadFilteredGeneNames();
|
|
348
|
+
const {
|
|
349
|
+
initialFeatureFilterPath: matrixGeneFilterZarr,
|
|
350
|
+
} = this.getOptions();
|
|
351
|
+
// In order to return the correct gene list with the heatmap data,
|
|
352
|
+
// we need to filter the columns of attrs so it matches the cellXGene data.
|
|
353
|
+
if (matrixGeneFilterZarr) {
|
|
354
|
+
const matrixGeneFilter = await this.dataSource.getFlatArrDecompressed(
|
|
355
|
+
matrixGeneFilterZarr,
|
|
356
|
+
);
|
|
357
|
+
return filteredGeneNames.filter((_, i) => matrixGeneFilter[i]);
|
|
358
|
+
}
|
|
359
|
+
return filteredGeneNames;
|
|
360
|
+
}
|
|
361
|
+
|
|
362
|
+
async load() {
|
|
363
|
+
const { path } = this.getOptions();
|
|
364
|
+
const superResult = await super.load().catch(reason => Promise.resolve(reason));
|
|
365
|
+
if (superResult instanceof AbstractLoaderError) {
|
|
366
|
+
return Promise.reject(superResult);
|
|
367
|
+
}
|
|
368
|
+
return Promise.all([
|
|
369
|
+
this.dataSource.loadObsIndex(path),
|
|
370
|
+
this.loadInitialFilteredGeneNames(),
|
|
371
|
+
this.loadCellXGene(),
|
|
372
|
+
]).then(([obsIndex, featureIndex, obsFeatureMatrix]) => Promise.resolve(new LoaderResult(
|
|
373
|
+
{ obsIndex, featureIndex, obsFeatureMatrix },
|
|
374
|
+
null,
|
|
375
|
+
)));
|
|
376
|
+
}
|
|
377
|
+
}
|
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
/* eslint-disable func-names */
|
|
2
|
+
import ObsFeatureMatrixAnndataLoader from './ObsFeatureMatrixAnndataLoader.js';
|
|
3
|
+
import AnnDataSource from '../AnnDataSource.js';
|
|
4
|
+
import MuDataSource from '../MuDataSource.js';
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
const createAnndataLoader = (url) => {
|
|
8
|
+
const config = {
|
|
9
|
+
url,
|
|
10
|
+
fileType: 'obsFeatureMatrix.anndata.zarr',
|
|
11
|
+
options: {
|
|
12
|
+
path: 'X',
|
|
13
|
+
},
|
|
14
|
+
};
|
|
15
|
+
const source = new AnnDataSource(config);
|
|
16
|
+
return new ObsFeatureMatrixAnndataLoader(source, config);
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
const createMudataLoader = (url) => {
|
|
20
|
+
const config = {
|
|
21
|
+
url,
|
|
22
|
+
fileType: 'obsFeatureMatrix.mudata.zarr',
|
|
23
|
+
options: {
|
|
24
|
+
path: 'mod/rna/X',
|
|
25
|
+
},
|
|
26
|
+
};
|
|
27
|
+
const source = new MuDataSource(config);
|
|
28
|
+
return new ObsFeatureMatrixAnndataLoader(source, config);
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
describe('loaders/ObsFeatureMatrixAnndataLoader', () => {
|
|
32
|
+
describe('AnnData v0.7', () => {
|
|
33
|
+
it('loadFilteredGeneNames returns gene names', async () => {
|
|
34
|
+
const loader = createAnndataLoader('http://localhost:51204/@fixtures/zarr/anndata-0.7/anndata-dense.zarr');
|
|
35
|
+
const names = await loader.loadFilteredGeneNames();
|
|
36
|
+
expect(names).toEqual(Array.from({ length: 15 }).map((_, i) => `gene_${i}`));
|
|
37
|
+
});
|
|
38
|
+
|
|
39
|
+
it('loadGeneSelection matches across storage methods', async () => {
|
|
40
|
+
const selection = { selection: ['gene_1', 'gene_5'] };
|
|
41
|
+
const loaderCsr = createAnndataLoader('http://localhost:51204/@fixtures/zarr/anndata-0.7/anndata-csr.zarr');
|
|
42
|
+
const csrSelection = await loaderCsr.loadGeneSelection(selection);
|
|
43
|
+
const loaderDense = createAnndataLoader('http://localhost:51204/@fixtures/zarr/anndata-0.7/anndata-dense.zarr');
|
|
44
|
+
const denseSelection = await loaderDense.loadGeneSelection(selection);
|
|
45
|
+
const loaderCsc = createAnndataLoader('http://localhost:51204/@fixtures/zarr/anndata-0.7/anndata-csc.zarr');
|
|
46
|
+
const cscSelection = await loaderCsc.loadGeneSelection(selection);
|
|
47
|
+
expect(cscSelection).toEqual(denseSelection);
|
|
48
|
+
expect(csrSelection).toEqual(denseSelection);
|
|
49
|
+
});
|
|
50
|
+
|
|
51
|
+
it('loadCellXGene matches across storage methods', async () => {
|
|
52
|
+
const loaderCsr = createAnndataLoader('http://localhost:51204/@fixtures/zarr/anndata-0.7/anndata-csr.zarr');
|
|
53
|
+
const csrMatrix = await loaderCsr.loadCellXGene();
|
|
54
|
+
const loaderDense = createAnndataLoader('http://localhost:51204/@fixtures/zarr/anndata-0.7/anndata-dense.zarr');
|
|
55
|
+
const denseMatrix = await loaderDense.loadCellXGene();
|
|
56
|
+
const loaderCsc = createAnndataLoader('http://localhost:51204/@fixtures/zarr/anndata-0.7/anndata-csc.zarr');
|
|
57
|
+
const cscMatrix = await loaderCsc.loadCellXGene();
|
|
58
|
+
expect(cscMatrix).toEqual(denseMatrix);
|
|
59
|
+
expect(csrMatrix).toEqual(denseMatrix);
|
|
60
|
+
});
|
|
61
|
+
});
|
|
62
|
+
|
|
63
|
+
describe('AnnData v0.8', () => {
|
|
64
|
+
it('loadFilteredGeneNames returns gene names', async () => {
|
|
65
|
+
const loader = createAnndataLoader('http://localhost:51204/@fixtures/zarr/anndata-0.8/anndata-dense.zarr');
|
|
66
|
+
const names = await loader.loadFilteredGeneNames();
|
|
67
|
+
expect(names).toEqual(Array.from({ length: 15 }).map((_, i) => `gene_${i}`));
|
|
68
|
+
});
|
|
69
|
+
|
|
70
|
+
it('loadGeneSelection matches across storage methods', async () => {
|
|
71
|
+
const selection = { selection: ['gene_1', 'gene_5'] };
|
|
72
|
+
const loaderCsr = createAnndataLoader('http://localhost:51204/@fixtures/zarr/anndata-0.8/anndata-csr.zarr');
|
|
73
|
+
const csrSelection = await loaderCsr.loadGeneSelection(selection);
|
|
74
|
+
const loaderDense = createAnndataLoader('http://localhost:51204/@fixtures/zarr/anndata-0.8/anndata-dense.zarr');
|
|
75
|
+
const denseSelection = await loaderDense.loadGeneSelection(selection);
|
|
76
|
+
const loaderCsc = createAnndataLoader('http://localhost:51204/@fixtures/zarr/anndata-0.8/anndata-csc.zarr');
|
|
77
|
+
const cscSelection = await loaderCsc.loadGeneSelection(selection);
|
|
78
|
+
expect(cscSelection).toEqual(denseSelection);
|
|
79
|
+
expect(csrSelection).toEqual(denseSelection);
|
|
80
|
+
});
|
|
81
|
+
|
|
82
|
+
it('loadCellXGene matches across storage methods', async () => {
|
|
83
|
+
const loaderCsr = createAnndataLoader('http://localhost:51204/@fixtures/zarr/anndata-0.8/anndata-csr.zarr');
|
|
84
|
+
const csrMatrix = await loaderCsr.loadCellXGene();
|
|
85
|
+
const loaderDense = createAnndataLoader('http://localhost:51204/@fixtures/zarr/anndata-0.8/anndata-dense.zarr');
|
|
86
|
+
const denseMatrix = await loaderDense.loadCellXGene();
|
|
87
|
+
const loaderCsc = createAnndataLoader('http://localhost:51204/@fixtures/zarr/anndata-0.8/anndata-csc.zarr');
|
|
88
|
+
const cscMatrix = await loaderCsc.loadCellXGene();
|
|
89
|
+
expect(cscMatrix).toEqual(denseMatrix);
|
|
90
|
+
expect(csrMatrix).toEqual(denseMatrix);
|
|
91
|
+
});
|
|
92
|
+
});
|
|
93
|
+
|
|
94
|
+
describe('MuData v0.2', () => {
|
|
95
|
+
it('loadFilteredGeneNames returns gene names', async () => {
|
|
96
|
+
const loader = createMudataLoader('http://localhost:51204/@fixtures/zarr/mudata-0.2/mudata-dense.zarr');
|
|
97
|
+
const names = await loader.loadFilteredGeneNames();
|
|
98
|
+
expect(names).toEqual(Array.from({ length: 15 }).map((_, i) => `gene_${i}`));
|
|
99
|
+
});
|
|
100
|
+
|
|
101
|
+
it('loadGeneSelection matches across storage methods', async () => {
|
|
102
|
+
const selection = { selection: ['gene_1', 'gene_5'] };
|
|
103
|
+
const loaderCsr = createMudataLoader('http://localhost:51204/@fixtures/zarr/mudata-0.2/mudata-csr.zarr');
|
|
104
|
+
const csrSelection = await loaderCsr.loadGeneSelection(selection);
|
|
105
|
+
const loaderDense = createMudataLoader('http://localhost:51204/@fixtures/zarr/mudata-0.2/mudata-dense.zarr');
|
|
106
|
+
const denseSelection = await loaderDense.loadGeneSelection(selection);
|
|
107
|
+
const loaderCsc = createMudataLoader('http://localhost:51204/@fixtures/zarr/mudata-0.2/mudata-csc.zarr');
|
|
108
|
+
const cscSelection = await loaderCsc.loadGeneSelection(selection);
|
|
109
|
+
expect(cscSelection).toEqual(denseSelection);
|
|
110
|
+
expect(csrSelection).toEqual(denseSelection);
|
|
111
|
+
});
|
|
112
|
+
|
|
113
|
+
it('loadCellXGene matches across storage methods', async () => {
|
|
114
|
+
const loaderCsr = createMudataLoader('http://localhost:51204/@fixtures/zarr/mudata-0.2/mudata-csr.zarr');
|
|
115
|
+
const csrMatrix = await loaderCsr.loadCellXGene();
|
|
116
|
+
const loaderDense = createMudataLoader('http://localhost:51204/@fixtures/zarr/mudata-0.2/mudata-dense.zarr');
|
|
117
|
+
const denseMatrix = await loaderDense.loadCellXGene();
|
|
118
|
+
const loaderCsc = createMudataLoader('http://localhost:51204/@fixtures/zarr/mudata-0.2/mudata-csc.zarr');
|
|
119
|
+
const cscMatrix = await loaderCsc.loadCellXGene();
|
|
120
|
+
expect(cscMatrix).toEqual(denseMatrix);
|
|
121
|
+
expect(csrMatrix).toEqual(denseMatrix);
|
|
122
|
+
});
|
|
123
|
+
});
|
|
124
|
+
});
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import {
|
|
2
|
+
LoaderResult, AbstractTwoStepLoader, AbstractLoaderError,
|
|
3
|
+
} from '@vitessce/vit-s';
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Loader for string arrays located in anndata.zarr stores.
|
|
8
|
+
*/
|
|
9
|
+
export default class ObsLabelsAnndataLoader extends AbstractTwoStepLoader {
|
|
10
|
+
/**
|
|
11
|
+
* Class method for loading observation string labels.
|
|
12
|
+
* @returns {Promise} A promise for the array.
|
|
13
|
+
*/
|
|
14
|
+
loadLabels() {
|
|
15
|
+
const { path } = this.options;
|
|
16
|
+
if (this.labels) {
|
|
17
|
+
return this.labels;
|
|
18
|
+
}
|
|
19
|
+
if (!this.labels) {
|
|
20
|
+
// eslint-disable-next-line no-underscore-dangle
|
|
21
|
+
this.labels = this.dataSource._loadColumn(path);
|
|
22
|
+
return this.labels;
|
|
23
|
+
}
|
|
24
|
+
this.labels = Promise.resolve(null);
|
|
25
|
+
return this.labels;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
async load() {
|
|
29
|
+
const { path } = this.options;
|
|
30
|
+
const superResult = await super.load().catch(reason => Promise.resolve(reason));
|
|
31
|
+
if (superResult instanceof AbstractLoaderError) {
|
|
32
|
+
return Promise.reject(superResult);
|
|
33
|
+
}
|
|
34
|
+
return Promise.all([
|
|
35
|
+
this.dataSource.loadObsIndex(path),
|
|
36
|
+
this.loadLabels(),
|
|
37
|
+
]).then(([obsIndex, obsLabels]) => Promise.resolve(new LoaderResult(
|
|
38
|
+
{ obsIndex, obsLabels },
|
|
39
|
+
null,
|
|
40
|
+
)));
|
|
41
|
+
}
|
|
42
|
+
}
|