@vitessce/zarr 3.5.6 → 3.5.8

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 (41) hide show
  1. package/dist/index.js +1056 -171
  2. package/dist/zstd-561fda0e.js +778 -0
  3. package/dist-tsc/AnnDataSource.d.ts +10 -4
  4. package/dist-tsc/AnnDataSource.d.ts.map +1 -1
  5. package/dist-tsc/AnnDataSource.js +16 -3
  6. package/dist-tsc/ZarrDataSource.d.ts +3 -4
  7. package/dist-tsc/ZarrDataSource.d.ts.map +1 -1
  8. package/dist-tsc/ZarrDataSource.js +1 -2
  9. package/dist-tsc/anndata-loaders/ComparisonMetadataAnndataLoader.d.ts +20 -0
  10. package/dist-tsc/anndata-loaders/ComparisonMetadataAnndataLoader.d.ts.map +1 -0
  11. package/dist-tsc/anndata-loaders/ComparisonMetadataAnndataLoader.js +29 -0
  12. package/dist-tsc/anndata-loaders/FeatureSetStatsAnndataLoader.d.ts +49 -0
  13. package/dist-tsc/anndata-loaders/FeatureSetStatsAnndataLoader.d.ts.map +1 -0
  14. package/dist-tsc/anndata-loaders/FeatureSetStatsAnndataLoader.js +143 -0
  15. package/dist-tsc/anndata-loaders/FeatureStatsAnndataLoader.d.ts +53 -0
  16. package/dist-tsc/anndata-loaders/FeatureStatsAnndataLoader.d.ts.map +1 -0
  17. package/dist-tsc/anndata-loaders/FeatureStatsAnndataLoader.js +157 -0
  18. package/dist-tsc/anndata-loaders/ObsSetStatsAnndataLoader.d.ts +66 -0
  19. package/dist-tsc/anndata-loaders/ObsSetStatsAnndataLoader.d.ts.map +1 -0
  20. package/dist-tsc/anndata-loaders/ObsSetStatsAnndataLoader.js +183 -0
  21. package/dist-tsc/anndata-loaders/SampleSetsAnndataLoader.d.ts +18 -0
  22. package/dist-tsc/anndata-loaders/SampleSetsAnndataLoader.d.ts.map +1 -0
  23. package/dist-tsc/anndata-loaders/SampleSetsAnndataLoader.js +75 -0
  24. package/dist-tsc/anndata-loaders/comparative-utils.d.ts +19 -0
  25. package/dist-tsc/anndata-loaders/comparative-utils.d.ts.map +1 -0
  26. package/dist-tsc/anndata-loaders/comparative-utils.js +30 -0
  27. package/dist-tsc/anndata-loaders/index.d.ts +5 -0
  28. package/dist-tsc/anndata-loaders/index.js +5 -0
  29. package/dist-tsc/utils.js +2 -1
  30. package/package.json +11 -13
  31. package/src/AnnDataSource.js +18 -4
  32. package/src/ZarrDataSource.js +1 -2
  33. package/src/anndata-loaders/ComparisonMetadataAnndataLoader.js +34 -0
  34. package/src/anndata-loaders/FeatureSetStatsAnndataLoader.js +164 -0
  35. package/src/anndata-loaders/FeatureStatsAnndataLoader.js +177 -0
  36. package/src/anndata-loaders/ObsSetStatsAnndataLoader.js +211 -0
  37. package/src/anndata-loaders/SampleSetsAnndataLoader.js +88 -0
  38. package/src/anndata-loaders/comparative-utils.js +35 -0
  39. package/src/anndata-loaders/index.js +5 -0
  40. package/src/utils.js +2 -2
  41. package/dist/zstd-ec5a40b8.js +0 -808
@@ -1,6 +1,5 @@
1
1
  /** @import { DataSourceParams } from '@vitessce/types' */
2
- /** @import { ByteStringArray } from '@zarrita/typedarray' */
3
- /** @import { TypedArray as ZarrTypedArray, Chunk } from '@zarrita/core' */
2
+ /** @import { TypedArray as ZarrTypedArray, Chunk, ByteStringArray } from 'zarrita' */
4
3
  /**
5
4
  * A base AnnData loader which has all shared methods for more comlpex laoders,
6
5
  * like loading cell names and ids. It inherits from AbstractLoader.
@@ -81,6 +80,13 @@ export default class AnnDataSource extends ZarrDataSource {
81
80
  */
82
81
  loadObsIndex(path?: string | undefined): Promise<string[]>;
83
82
  obsIndex: Promise<string[]> | undefined;
83
+ /**
84
+ * Class method for loading the obs index.
85
+ * @param {string|undefined} path Used by subclasses.
86
+ * @returns {Promise<string[]>} An promise for a zarr array
87
+ * containing the indices.
88
+ */
89
+ loadDataFrameIndex(path?: string | undefined): Promise<string[]>;
84
90
  /**
85
91
  * Class method for loading the var index.
86
92
  * @param {string|undefined} path Used by subclasses.
@@ -131,7 +137,7 @@ export default class AnnDataSource extends ZarrDataSource {
131
137
  }>;
132
138
  }
133
139
  import ZarrDataSource from './ZarrDataSource.js';
134
- import type { Chunk } from '@zarrita/core';
135
- import type { TypedArray as ZarrTypedArray } from '@zarrita/core';
140
+ import type { Chunk } from 'zarrita';
141
+ import type { TypedArray as ZarrTypedArray } from 'zarrita';
136
142
  import type { DataSourceParams } from '@vitessce/types';
137
143
  //# sourceMappingURL=AnnDataSource.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"AnnDataSource.d.ts","sourceRoot":"","sources":["../src/AnnDataSource.js"],"names":[],"mappings":"AAMA,0DAA0D;AAC1D,6DAA6D;AAC7D,2EAA2E;AAE3E;;;GAGG;AACH;IACE;;;OAGG;IACH,oBAFW,gBAAgB,EAM1B;IAFC,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,GACJ,OAAO,CAAC,MAAM,GAAG,CAAC,CAAC,CAM/B;IAED;;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C,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;;OA4BlB;CACF;2BAzW0B,qBAAqB;2BAE0B,SAAS;kDAAT,SAAS;sCAD7C,iBAAiB"}
@@ -1,11 +1,11 @@
1
1
  // @ts-check
2
2
  /* eslint-disable no-underscore-dangle */
3
3
  import { open as zarrOpen, get as zarrGet } from 'zarrita';
4
+ import { log } from '@vitessce/globals';
4
5
  import { dirname } from './utils.js';
5
6
  import ZarrDataSource from './ZarrDataSource.js';
6
7
  /** @import { DataSourceParams } from '@vitessce/types' */
7
- /** @import { ByteStringArray } from '@zarrita/typedarray' */
8
- /** @import { TypedArray as ZarrTypedArray, Chunk } from '@zarrita/core' */
8
+ /** @import { TypedArray as ZarrTypedArray, Chunk, ByteStringArray } from 'zarrita' */
9
9
  /**
10
10
  * A base AnnData loader which has all shared methods for more comlpex laoders,
11
11
  * like loading cell names and ids. It inherits from AbstractLoader.
@@ -173,6 +173,19 @@ export default class AnnDataSource extends ZarrDataSource {
173
173
  .then(({ _index }) => this.getFlatArrDecompressed(`/obs/${_index}`));
174
174
  return this.obsIndex;
175
175
  }
176
+ /**
177
+ * Class method for loading the obs index.
178
+ * @param {string|undefined} path Used by subclasses.
179
+ * @returns {Promise<string[]>} An promise for a zarr array
180
+ * containing the indices.
181
+ */
182
+ loadDataFrameIndex(
183
+ // eslint-disable-next-line no-unused-vars
184
+ path = undefined) {
185
+ const dfPath = path ? dirname(path) : '';
186
+ return this.getJson(`${dfPath}/.zattrs`)
187
+ .then(({ _index }) => this.getFlatArrDecompressed(`${dfPath.length > 0 ? '/' : ''}${dfPath}/${_index}`));
188
+ }
176
189
  /**
177
190
  * Class method for loading the var index.
178
191
  * @param {string|undefined} path Used by subclasses.
@@ -289,7 +302,7 @@ export default class AnnDataSource extends ZarrDataSource {
289
302
  val = await this._loadElement(`${path}/${key}`);
290
303
  }
291
304
  catch (e) {
292
- console.error(`Error in _loadDict: could not load ${key}`);
305
+ log.error(`Error in _loadDict: could not load ${key}`);
293
306
  }
294
307
  result[key] = val;
295
308
  }));
@@ -1,5 +1,4 @@
1
- /** @import { Location as ZarrLocation } from '@zarrita/core' */
2
- /** @import { Readable } from '@zarrita/storage' */
1
+ /** @import { Location as ZarrLocation, Readable } from 'zarrita' */
3
2
  /** @import { DataSourceParams } from '@vitessce/types' */
4
3
  /**
5
4
  * A loader ancestor class containing a default constructor
@@ -30,7 +29,7 @@ export default class ZarrDataSource {
30
29
  */
31
30
  getJson(key: string, storeRootParam?: ZarrLocation<Readable> | null): Promise<any>;
32
31
  }
33
- import type { Readable } from '@zarrita/storage';
34
- import type { Location as ZarrLocation } from '@zarrita/core';
32
+ import type { Readable } from 'zarrita';
33
+ import type { Location as ZarrLocation } from 'zarrita';
35
34
  import type { DataSourceParams } from '@vitessce/types';
36
35
  //# sourceMappingURL=ZarrDataSource.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"ZarrDataSource.d.ts","sourceRoot":"","sources":["../src/ZarrDataSource.js"],"names":[],"mappings":"AAIA,gEAAgE;AAChE,mDAAmD;AACnD,0DAA0D;AAE1D;;;GAGG;AACH;IACE;;OAEG;IACH,+DAFW,gBAAgB,GAAG;QAAE,UAAU,CAAC,EAAE,MAAM,CAAA;KAAE,EAWpD;IANG,kCAAgC;IAQpC;;;;OAIG;IACH,mBAHW,MAAM,GACJ,aAAa,QAAQ,CAAC,CAIlC;IAED;;;;;;;;OAQG;IACH,aAPW,MAAM,mBACN,aAAa,QAAQ,CAAC,GAAC,IAAI,GAEzB,OAAO,CAAC,GAAG,CAAC,CAcxB;CACF;8BAnD6B,kBAAkB;8CADF,eAAe;sCAEvB,iBAAiB"}
1
+ {"version":3,"file":"ZarrDataSource.d.ts","sourceRoot":"","sources":["../src/ZarrDataSource.js"],"names":[],"mappings":"AAIA,oEAAoE;AACpE,0DAA0D;AAE1D;;;GAGG;AACH;IACE;;OAEG;IACH,+DAFW,gBAAgB,GAAG;QAAE,UAAU,CAAC,EAAE,MAAM,CAAA;KAAE,EAWpD;IANG,kCAAgC;IAQpC;;;;OAIG;IACH,mBAHW,MAAM,GACJ,aAAa,QAAQ,CAAC,CAIlC;IAED;;;;;;;;OAQG;IACH,aAPW,MAAM,mBACN,aAAa,QAAQ,CAAC,GAAC,IAAI,GAEzB,OAAO,CAAC,GAAG,CAAC,CAcxB;CACF;8BAnDuD,SAAS;8CAAT,SAAS;sCAC3B,iBAAiB"}
@@ -1,8 +1,7 @@
1
1
  // @ts-check
2
2
  import { zarrOpenRoot } from '@vitessce/zarr-utils';
3
3
  import { open as zarrOpen, root as zarrRoot } from 'zarrita';
4
- /** @import { Location as ZarrLocation } from '@zarrita/core' */
5
- /** @import { Readable } from '@zarrita/storage' */
4
+ /** @import { Location as ZarrLocation, Readable } from 'zarrita' */
6
5
  /** @import { DataSourceParams } from '@vitessce/types' */
7
6
  /**
8
7
  * A loader ancestor class containing a default constructor
@@ -0,0 +1,20 @@
1
+ /** @import AnnDataSource from '../AnnDataSource.js' */
2
+ /** @import { ComparisonMetadata } from '@vitessce/types' */
3
+ /**
4
+ * Loader for string arrays located in anndata.zarr stores.
5
+ * @template {AnnDataSource} DataSourceType
6
+ * @extends {AbstractTwoStepLoader<DataSourceType>}
7
+ */
8
+ export default class ComparisonMetadataAnndataLoader<DataSourceType extends AnnDataSource> extends AbstractTwoStepLoader<DataSourceType> {
9
+ constructor(dataSource: DataSourceType, params: import("@vitessce/types").LoaderParams);
10
+ /**
11
+ *
12
+ * @returns {Promise<LoaderResult<ComparisonMetadata>>}
13
+ */
14
+ load(): Promise<LoaderResult<ComparisonMetadata>>;
15
+ }
16
+ import type AnnDataSource from '../AnnDataSource.js';
17
+ import { AbstractTwoStepLoader } from '@vitessce/abstract';
18
+ import { LoaderResult } from '@vitessce/abstract';
19
+ import type { ComparisonMetadata } from '@vitessce/types';
20
+ //# sourceMappingURL=ComparisonMetadataAnndataLoader.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ComparisonMetadataAnndataLoader.d.ts","sourceRoot":"","sources":["../../src/anndata-loaders/ComparisonMetadataAnndataLoader.js"],"names":[],"mappings":"AAIA,uDAAuD;AACvD,4DAA4D;AAE5D;;;;GAIG;AACH,qDAH6B,cAAc,SAA9B,aAAe;;IAI1B;;;OAGG;IACH,QAFa,OAAO,CAAC,YAAY,CAAC,kBAAkB,CAAC,CAAC,CAiBrD;CACF;+BA7B8B,qBAAqB;sCAHqB,oBAAoB;6BAApB,oBAAoB;wCAIrD,iBAAiB"}
@@ -0,0 +1,29 @@
1
+ // @ts-check
2
+ import { LoaderResult, AbstractTwoStepLoader, AbstractLoaderError } from '@vitessce/abstract';
3
+ import { loadComparisonMetadata } from './comparative-utils.js';
4
+ /** @import AnnDataSource from '../AnnDataSource.js' */
5
+ /** @import { ComparisonMetadata } from '@vitessce/types' */
6
+ /**
7
+ * Loader for string arrays located in anndata.zarr stores.
8
+ * @template {AnnDataSource} DataSourceType
9
+ * @extends {AbstractTwoStepLoader<DataSourceType>}
10
+ */
11
+ export default class ComparisonMetadataAnndataLoader extends AbstractTwoStepLoader {
12
+ /**
13
+ *
14
+ * @returns {Promise<LoaderResult<ComparisonMetadata>>}
15
+ */
16
+ async load() {
17
+ const { path } = this.options;
18
+ const superResult = await super.load().catch(reason => Promise.resolve(reason));
19
+ if (superResult instanceof AbstractLoaderError) {
20
+ return Promise.reject(superResult);
21
+ }
22
+ const metadata = await loadComparisonMetadata(this.dataSource, path);
23
+ return Promise.resolve(new LoaderResult({
24
+ // Should a more complex class be wrapping this
25
+ // JSON object to help with downstream querying?
26
+ comparisonMetadata: metadata,
27
+ }, null));
28
+ }
29
+ }
@@ -0,0 +1,49 @@
1
+ /** @import AnnDataSource from '../AnnDataSource.js' */
2
+ /** @import { FeatureStatsData } from '@vitessce/types' */
3
+ /**
4
+ * Loader for string arrays located in anndata.zarr stores.
5
+ * @template {AnnDataSource} DataSourceType
6
+ * @extends {AbstractTwoStepLoader<DataSourceType>}
7
+ */
8
+ export default class FeatureStatsAnndataLoader<DataSourceType extends AnnDataSource> extends AbstractTwoStepLoader<DataSourceType> {
9
+ constructor(dataSource: DataSourceType, params: import("@vitessce/types").LoaderParams);
10
+ /**
11
+ * Class method for loading feature string labels.
12
+ * @returns {Promise<any>} A promise for the array.
13
+ */
14
+ loadSignificances(dfPath: any): Promise<any>;
15
+ loadFeatureSetNames(dfPath: any): Promise<string[]>;
16
+ loadFeatureSetTerms(dfPath: any): Promise<string[]>;
17
+ loadDataFrame(dfPath: any): Promise<{
18
+ featureSetName: string[];
19
+ featureSetTerm: string[];
20
+ featureSetSignificance: any;
21
+ }>;
22
+ /**
23
+ *
24
+ * @returns {Promise<StatsMeta[]>}
25
+ */
26
+ loadMetadata(): Promise<StatsMeta[]>;
27
+ metadata: any;
28
+ /**
29
+ * Load data from multiple dataframes, merged.
30
+ * @param {object} volcanoOptions
31
+ * @param {string[]|null} [volcanoOptions.sampleFacet]
32
+ * @param {string[]|null} [volcanoOptions.obsSetFacet]
33
+ * @param {number|null} [volcanoOptions.topK]
34
+ * @param {string[][]|null} [volcanoOptions.sampleSetSelection]
35
+ * @returns {Promise<LoaderResult<FeatureStatsData>>}
36
+ */
37
+ loadMulti(volcanoOptions: {
38
+ sampleFacet?: string[] | null | undefined;
39
+ obsSetFacet?: string[] | null | undefined;
40
+ topK?: number | null | undefined;
41
+ sampleSetSelection?: string[][] | null | undefined;
42
+ }): Promise<LoaderResult<FeatureStatsData>>;
43
+ load(): Promise<void>;
44
+ }
45
+ import type AnnDataSource from '../AnnDataSource.js';
46
+ import { AbstractTwoStepLoader } from '@vitessce/abstract';
47
+ import { LoaderResult } from '@vitessce/abstract';
48
+ import type { FeatureStatsData } from '@vitessce/types';
49
+ //# sourceMappingURL=FeatureSetStatsAnndataLoader.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"FeatureSetStatsAnndataLoader.d.ts","sourceRoot":"","sources":["../../src/anndata-loaders/FeatureSetStatsAnndataLoader.js"],"names":[],"mappings":"AAMA,uDAAuD;AACvD,0DAA0D;AAG1D;;;;GAIG;AACH,+CAH6B,cAAc,SAA9B,aAAe;;IAI1B;;;OAGG;IACH,gCAFa,OAAO,CAAC,GAAG,CAAC,CAQxB;IAED,oDAOC;IAED,oDAGC;IAED;;;;OAeC;IAED;;;OAGG;IACH,gBAFa,OAAO,CAAC,SAAS,EAAE,CAAC,CAYhC;IAJG,cAA2E;IAO/E;;;;;;;;OAQG;IACH,0BANG;QAAuC,WAAW;QACX,WAAW;QACb,IAAI;QACA,kBAAkB;KAC3D,GAAU,OAAO,CAAC,YAAY,CAAC,gBAAgB,CAAC,CAAC,CA0EnD;IAGD,sBAEC;CACF;+BA7J8B,qBAAqB;sCAJA,oBAAoB;6BAApB,oBAAoB;sCAKlC,iBAAiB"}
@@ -0,0 +1,143 @@
1
+ /* eslint-disable no-underscore-dangle */
2
+ /* eslint-disable camelcase */
3
+ import { LoaderResult, AbstractTwoStepLoader } from '@vitessce/abstract';
4
+ import { isEqual } from 'lodash-es';
5
+ import { isEqualPathPair, loadComparisonMetadata } from './comparative-utils.js';
6
+ /** @import AnnDataSource from '../AnnDataSource.js' */
7
+ /** @import { FeatureStatsData } from '@vitessce/types' */
8
+ /**
9
+ * Loader for string arrays located in anndata.zarr stores.
10
+ * @template {AnnDataSource} DataSourceType
11
+ * @extends {AbstractTwoStepLoader<DataSourceType>}
12
+ */
13
+ export default class FeatureStatsAnndataLoader extends AbstractTwoStepLoader {
14
+ /**
15
+ * Class method for loading feature string labels.
16
+ * @returns {Promise<any>} A promise for the array.
17
+ */
18
+ async loadSignificances(dfPath) {
19
+ const { pValueColumn } = this.options;
20
+ // Check the options to determine whether the significance values are pre-transformed
21
+ // or if we still need to compute minus log10 here.
22
+ const values = await this.dataSource.loadNumeric(`${dfPath}/${pValueColumn}`);
23
+ return values.data;
24
+ }
25
+ async loadFeatureSetNames(dfPath) {
26
+ const { indexColumn } = this.options;
27
+ if (indexColumn) {
28
+ return this.dataSource._loadColumn(`${dfPath}/${indexColumn}`);
29
+ }
30
+ // Use the default dataframe index column in this case.
31
+ return this.dataSource.loadDataFrameIndex(dfPath);
32
+ }
33
+ async loadFeatureSetTerms(dfPath) {
34
+ const { termColumn } = this.options;
35
+ return this.dataSource._loadColumn(`${dfPath}/${termColumn}`);
36
+ }
37
+ async loadDataFrame(dfPath) {
38
+ const [featureSetName, featureSetTerm, featureSetSignificance,] = await Promise.all([
39
+ this.loadFeatureSetNames(dfPath),
40
+ this.loadFeatureSetTerms(dfPath),
41
+ this.loadSignificances(dfPath),
42
+ ]);
43
+ return {
44
+ featureSetName,
45
+ featureSetTerm,
46
+ featureSetSignificance,
47
+ };
48
+ }
49
+ /**
50
+ *
51
+ * @returns {Promise<StatsMeta[]>}
52
+ */
53
+ async loadMetadata() {
54
+ const { metadataPath } = this.options;
55
+ if (this.metadata) {
56
+ return this.metadata;
57
+ }
58
+ if (!this.metadata) {
59
+ this.metadata = await loadComparisonMetadata(this.dataSource, metadataPath);
60
+ return this.metadata;
61
+ }
62
+ return this.metadata;
63
+ }
64
+ /**
65
+ * Load data from multiple dataframes, merged.
66
+ * @param {object} volcanoOptions
67
+ * @param {string[]|null} [volcanoOptions.sampleFacet]
68
+ * @param {string[]|null} [volcanoOptions.obsSetFacet]
69
+ * @param {number|null} [volcanoOptions.topK]
70
+ * @param {string[][]|null} [volcanoOptions.sampleSetSelection]
71
+ * @returns {Promise<LoaderResult<FeatureStatsData>>}
72
+ */
73
+ async loadMulti(volcanoOptions) {
74
+ const { analysisType: targetAnalysisType = 'pertpy_hypergeometric' } = this.options;
75
+ const { sampleSetSelection, obsSetSelection } = volcanoOptions || {};
76
+ // TODO: should this also depend on a "featureSetType" such as "pathway"
77
+ // or an ontology id/name such as "GO" vs. "CHEMBL"?
78
+ // We expect these set paths to have already been transformed
79
+ // to use the "raw" column names,
80
+ // according to the mappings defined in obsSets and sampleSets loader options.
81
+ // The values in the comparison_metadata have the "raw" column names.
82
+ const rawObsSetSelection = obsSetSelection;
83
+ const rawSampleSetSelection = sampleSetSelection;
84
+ if (sampleSetSelection) {
85
+ if (sampleSetSelection.length !== 2) {
86
+ return Promise.reject(new Error('Expected exactly two sample sets for volcano plot.'));
87
+ }
88
+ }
89
+ if (!obsSetSelection) {
90
+ return Promise.reject(new Error('Expected obsSetSelection to be present.'));
91
+ }
92
+ const metadata = await this.loadMetadata();
93
+ // Match metadata against to get paths to dataframe(s) of interest.
94
+ const matchingComparisons = [];
95
+ Object.values(metadata.comparisons).forEach((comparisonGroupObject) => {
96
+ const { results } = comparisonGroupObject;
97
+ results.forEach((resultObject) => {
98
+ const { analysis_type,
99
+ // analysis_params,
100
+ coordination_values,
101
+ // path,
102
+ } = resultObject;
103
+ if (analysis_type === targetAnalysisType) {
104
+ // This is a diff. exp. result.
105
+ if (sampleSetSelection) {
106
+ // Comparing two sample groups.
107
+ rawObsSetSelection.forEach((obsSetPath) => {
108
+ if (isEqual([obsSetPath], coordination_values.obsSetFilter)) {
109
+ // The obsSetSelection matches.
110
+ // Now check whether the sampleSetSelection matches.
111
+ if (isEqualPathPair(rawSampleSetSelection, coordination_values.sampleSetFilter)) {
112
+ matchingComparisons.push(resultObject);
113
+ }
114
+ }
115
+ });
116
+ }
117
+ else if (obsSetSelection) {
118
+ // Comparing no sample groups but have selected cell type(s) of interest.
119
+ rawObsSetSelection.forEach((obsSetPath) => {
120
+ if (isEqual([obsSetPath], coordination_values.obsSetSelection)) {
121
+ matchingComparisons.push(resultObject);
122
+ }
123
+ });
124
+ }
125
+ }
126
+ });
127
+ });
128
+ // Using this matchingComparisons list,
129
+ // load the relevant columns of each matching dataframe and concatenate them together.
130
+ const result = await Promise.all(matchingComparisons.map(async (comparisonObject) => {
131
+ const df = await this.loadDataFrame(comparisonObject.path);
132
+ return {
133
+ df,
134
+ metadata: comparisonObject,
135
+ };
136
+ }));
137
+ return new LoaderResult({ featureSetStats: result }, null);
138
+ }
139
+ // eslint-disable-next-line class-methods-use-this
140
+ async load() {
141
+ throw new Error('The load() method is not implemented for FeatureSetStatsAnndataLoader.');
142
+ }
143
+ }
@@ -0,0 +1,53 @@
1
+ /** @import AnnDataSource from '../AnnDataSource.js' */
2
+ /** @import { FeatureStatsData } from '@vitessce/types' */
3
+ /**
4
+ * Loader for string arrays located in anndata.zarr stores.
5
+ * @template {AnnDataSource} DataSourceType
6
+ * @extends {AbstractTwoStepLoader<DataSourceType>}
7
+ */
8
+ export default class FeatureStatsAnndataLoader<DataSourceType extends AnnDataSource> extends AbstractTwoStepLoader<DataSourceType> {
9
+ constructor(dataSource: DataSourceType, params: import("@vitessce/types").LoaderParams);
10
+ /**
11
+ * Class method for loading feature string labels.
12
+ * @returns {Promise<any>} A promise for the array.
13
+ */
14
+ loadSignificances(dfPath: any): Promise<any>;
15
+ /**
16
+ * Class method for loading feature string labels.
17
+ * @returns {Promise<any>} A promise for the array.
18
+ */
19
+ loadFoldChanges(dfPath: any): Promise<any>;
20
+ loadFeatureNames(dfPath: any): Promise<string[]>;
21
+ loadDataFrame(dfPath: any): Promise<{
22
+ featureId: string[];
23
+ featureFoldChange: any;
24
+ featureSignificance: any;
25
+ }>;
26
+ /**
27
+ *
28
+ * @returns {Promise<StatsMeta[]>}
29
+ */
30
+ loadMetadata(): Promise<StatsMeta[]>;
31
+ metadata: any;
32
+ /**
33
+ * Load data from multiple dataframes, merged.
34
+ * @param {object} volcanoOptions
35
+ * @param {string[]|null} [volcanoOptions.sampleFacet]
36
+ * @param {string[]|null} [volcanoOptions.obsSetFacet]
37
+ * @param {number|null} [volcanoOptions.topK]
38
+ * @param {string[][]|null} [volcanoOptions.sampleSetSelection]
39
+ * @returns {Promise<LoaderResult<FeatureStatsData>>}
40
+ */
41
+ loadMulti(volcanoOptions: {
42
+ sampleFacet?: string[] | null | undefined;
43
+ obsSetFacet?: string[] | null | undefined;
44
+ topK?: number | null | undefined;
45
+ sampleSetSelection?: string[][] | null | undefined;
46
+ }): Promise<LoaderResult<FeatureStatsData>>;
47
+ load(): Promise<void>;
48
+ }
49
+ import type AnnDataSource from '../AnnDataSource.js';
50
+ import { AbstractTwoStepLoader } from '@vitessce/abstract';
51
+ import { LoaderResult } from '@vitessce/abstract';
52
+ import type { FeatureStatsData } from '@vitessce/types';
53
+ //# sourceMappingURL=FeatureStatsAnndataLoader.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"FeatureStatsAnndataLoader.d.ts","sourceRoot":"","sources":["../../src/anndata-loaders/FeatureStatsAnndataLoader.js"],"names":[],"mappings":"AAMA,uDAAuD;AACvD,0DAA0D;AAG1D;;;;GAIG;AACH,+CAH6B,cAAc,SAA9B,aAAe;;IAI1B;;;OAGG;IACH,gCAFa,OAAO,CAAC,GAAG,CAAC,CAaxB;IAED;;;OAGG;IACH,8BAFa,OAAO,CAAC,GAAG,CAAC,CAYxB;IAED,iDAOC;IAED;;;;OAeC;IAED;;;OAGG;IACH,gBAFa,OAAO,CAAC,SAAS,EAAE,CAAC,CAYhC;IAJG,cAA2E;IAO/E;;;;;;;;OAQG;IACH,0BANG;QAAuC,WAAW;QACX,WAAW;QACb,IAAI;QACA,kBAAkB;KAC3D,GAAU,OAAO,CAAC,YAAY,CAAC,gBAAgB,CAAC,CAAC,CAuEnD;IAGD,sBAEC;CACF;+BA1K8B,qBAAqB;sCAJA,oBAAoB;6BAApB,oBAAoB;sCAKlC,iBAAiB"}
@@ -0,0 +1,157 @@
1
+ /* eslint-disable no-underscore-dangle */
2
+ /* eslint-disable camelcase */
3
+ import { LoaderResult, AbstractTwoStepLoader } from '@vitessce/abstract';
4
+ import { isEqual } from 'lodash-es';
5
+ import { isEqualPathPair, loadComparisonMetadata } from './comparative-utils.js';
6
+ /** @import AnnDataSource from '../AnnDataSource.js' */
7
+ /** @import { FeatureStatsData } from '@vitessce/types' */
8
+ /**
9
+ * Loader for string arrays located in anndata.zarr stores.
10
+ * @template {AnnDataSource} DataSourceType
11
+ * @extends {AbstractTwoStepLoader<DataSourceType>}
12
+ */
13
+ export default class FeatureStatsAnndataLoader extends AbstractTwoStepLoader {
14
+ /**
15
+ * Class method for loading feature string labels.
16
+ * @returns {Promise<any>} A promise for the array.
17
+ */
18
+ async loadSignificances(dfPath) {
19
+ const { pValueColumn, pValueTransformation } = this.options;
20
+ // Check the options to determine whether the significance values are pre-transformed
21
+ // or if we still need to compute minus log10 here.
22
+ const values = await this.dataSource.loadNumeric(`${dfPath}/${pValueColumn}`);
23
+ if (pValueTransformation === 'minuslog10') {
24
+ // Invert the transformation, to return the plain p-values.
25
+ // The view will do the -Math.log10 transformation if needed.
26
+ values.data = values.data.map(val => (10 ** -val));
27
+ }
28
+ return values.data;
29
+ }
30
+ /**
31
+ * Class method for loading feature string labels.
32
+ * @returns {Promise<any>} A promise for the array.
33
+ */
34
+ async loadFoldChanges(dfPath) {
35
+ const { foldChangeColumn, foldChangeTransformation } = this.options;
36
+ // Check the options to determine whether the significance values are pre-transformed
37
+ // or if we still need to compute log2 here.
38
+ const values = await this.dataSource.loadNumeric(`${dfPath}/${foldChangeColumn}`);
39
+ // Invert the transformation
40
+ if (foldChangeTransformation === 'log2') {
41
+ values.data = values.data.map(val => (2 ** val));
42
+ }
43
+ return values.data;
44
+ }
45
+ async loadFeatureNames(dfPath) {
46
+ const { indexColumn } = this.options;
47
+ if (indexColumn) {
48
+ return this.dataSource._loadColumn(`${dfPath}/${indexColumn}`);
49
+ }
50
+ // Use the default dataframe index column in this case.
51
+ return this.dataSource.loadDataFrameIndex(dfPath);
52
+ }
53
+ async loadDataFrame(dfPath) {
54
+ const [featureId, featureFoldChange, featureSignificance,] = await Promise.all([
55
+ this.loadFeatureNames(dfPath),
56
+ this.loadFoldChanges(dfPath),
57
+ this.loadSignificances(dfPath),
58
+ ]);
59
+ return {
60
+ featureId,
61
+ featureFoldChange,
62
+ featureSignificance,
63
+ };
64
+ }
65
+ /**
66
+ *
67
+ * @returns {Promise<StatsMeta[]>}
68
+ */
69
+ async loadMetadata() {
70
+ const { metadataPath } = this.options;
71
+ if (this.metadata) {
72
+ return this.metadata;
73
+ }
74
+ if (!this.metadata) {
75
+ this.metadata = await loadComparisonMetadata(this.dataSource, metadataPath);
76
+ return this.metadata;
77
+ }
78
+ return this.metadata;
79
+ }
80
+ /**
81
+ * Load data from multiple dataframes, merged.
82
+ * @param {object} volcanoOptions
83
+ * @param {string[]|null} [volcanoOptions.sampleFacet]
84
+ * @param {string[]|null} [volcanoOptions.obsSetFacet]
85
+ * @param {number|null} [volcanoOptions.topK]
86
+ * @param {string[][]|null} [volcanoOptions.sampleSetSelection]
87
+ * @returns {Promise<LoaderResult<FeatureStatsData>>}
88
+ */
89
+ async loadMulti(volcanoOptions) {
90
+ const { analysisType: targetAnalysisType = 'rank_genes_groups' } = this.options;
91
+ const { sampleSetSelection, obsSetSelection } = volcanoOptions || {};
92
+ // We expect these set paths to have already been transformed
93
+ // to use the "raw" column names,
94
+ // according to the mappings defined in obsSets and sampleSets loader options.
95
+ // The values in the comparison_metadata have the "raw" column names.
96
+ const rawObsSetSelection = obsSetSelection;
97
+ const rawSampleSetSelection = sampleSetSelection;
98
+ if (sampleSetSelection) {
99
+ if (sampleSetSelection.length !== 2) {
100
+ return Promise.reject(new Error('Expected exactly two sample sets for volcano plot.'));
101
+ }
102
+ }
103
+ if (!obsSetSelection) {
104
+ return Promise.reject(new Error('Expected obsSetSelection to be present.'));
105
+ }
106
+ const metadata = await this.loadMetadata();
107
+ // Match metadata against to get paths to dataframe(s) of interest.
108
+ const matchingComparisons = [];
109
+ Object.values(metadata.comparisons).forEach((comparisonGroupObject) => {
110
+ const { results } = comparisonGroupObject;
111
+ results.forEach((resultObject) => {
112
+ const { analysis_type,
113
+ // analysis_params,
114
+ coordination_values,
115
+ // path,
116
+ } = resultObject;
117
+ if (analysis_type === targetAnalysisType) {
118
+ // This is a diff. exp. result.
119
+ if (sampleSetSelection) {
120
+ // Comparing two sample groups.
121
+ rawObsSetSelection.forEach((obsSetPath) => {
122
+ if (isEqual([obsSetPath], coordination_values.obsSetFilter)) {
123
+ // The obsSetSelection matches.
124
+ // Now check whether the sampleSetSelection matches.
125
+ if (isEqualPathPair(rawSampleSetSelection, coordination_values.sampleSetFilter)) {
126
+ matchingComparisons.push(resultObject);
127
+ }
128
+ }
129
+ });
130
+ }
131
+ else if (obsSetSelection) {
132
+ // Comparing no sample groups but have selected cell type(s) of interest.
133
+ rawObsSetSelection.forEach((obsSetPath) => {
134
+ if (isEqual([obsSetPath], coordination_values.obsSetSelection)) {
135
+ matchingComparisons.push(resultObject);
136
+ }
137
+ });
138
+ }
139
+ }
140
+ });
141
+ });
142
+ // Using this matchingComparisons list,
143
+ // load the relevant columns of each matching dataframe and concatenate them together.
144
+ const result = await Promise.all(matchingComparisons.map(async (comparisonObject) => {
145
+ const df = await this.loadDataFrame(comparisonObject.path);
146
+ return {
147
+ df,
148
+ metadata: comparisonObject,
149
+ };
150
+ }));
151
+ return new LoaderResult({ featureStats: result }, null);
152
+ }
153
+ // eslint-disable-next-line class-methods-use-this
154
+ async load() {
155
+ throw new Error('The load() method is not implemented for FeatureStatsAnndataLoader.');
156
+ }
157
+ }
@@ -0,0 +1,66 @@
1
+ /** @import AnnDataSource from '../AnnDataSource.js' */
2
+ /** @import { ObsSetStatsData } from '@vitessce/types' */
3
+ /**
4
+ * Loader for string arrays located in anndata.zarr stores.
5
+ * @template {AnnDataSource} DataSourceType
6
+ * @extends {AbstractTwoStepLoader<DataSourceType>}
7
+ */
8
+ export default class ObsSetStatsAnndataLoader<DataSourceType extends AnnDataSource> extends AbstractTwoStepLoader<DataSourceType> {
9
+ constructor(dataSource: DataSourceType, params: import("@vitessce/types").LoaderParams);
10
+ /**
11
+ * Class method for loading feature string labels.
12
+ * @returns {Promise<any>} A promise for the array.
13
+ */
14
+ loadInterceptValues(dfPath: any): Promise<any>;
15
+ /**
16
+ * Class method for loading feature string labels.
17
+ * @returns {Promise<any>} A promise for the array.
18
+ */
19
+ loadEffectValues(dfPath: any): Promise<any>;
20
+ /**
21
+ * Class method for loading feature string labels.
22
+ * @returns {Promise<any>} A promise for the array.
23
+ */
24
+ loadIsCredible(dfPath: any): Promise<any>;
25
+ /**
26
+ * Class method for loading feature string labels.
27
+ * @returns {Promise<any>} A promise for the array.
28
+ */
29
+ loadFoldChanges(dfPath: any): Promise<any>;
30
+ loadCovariate(dfPath: any): Promise<string[]>;
31
+ loadObsSetNames(dfPath: any): Promise<string[]>;
32
+ loadDataFrame(dfPath: any): Promise<{
33
+ obsSetId: string[];
34
+ obsSetFoldChange: any;
35
+ interceptExpectedSample: any;
36
+ effectExpectedSample: any;
37
+ isCredibleEffect: any;
38
+ covariate: string[];
39
+ }>;
40
+ /**
41
+ *
42
+ * @returns {Promise<StatsMeta[]>}
43
+ */
44
+ loadMetadata(): Promise<StatsMeta[]>;
45
+ metadata: any;
46
+ /**
47
+ * Load data from multiple dataframes, merged.
48
+ * @param {object} volcanoOptions
49
+ * @param {string[]|null} [volcanoOptions.sampleFacet]
50
+ * @param {string[]|null} [volcanoOptions.obsSetFacet]
51
+ * @param {number|null} [volcanoOptions.topK]
52
+ * @param {string[][]|null} [volcanoOptions.sampleSetSelection]
53
+ * @returns {Promise<LoaderResult<ObsSetStatsData>>}
54
+ */
55
+ loadMulti(volcanoOptions: {
56
+ sampleFacet?: string[] | null | undefined;
57
+ obsSetFacet?: string[] | null | undefined;
58
+ topK?: number | null | undefined;
59
+ sampleSetSelection?: string[][] | null | undefined;
60
+ }): Promise<LoaderResult<isEqual>>;
61
+ load(): Promise<void>;
62
+ }
63
+ import type AnnDataSource from '../AnnDataSource.js';
64
+ import { AbstractTwoStepLoader } from '@vitessce/abstract';
65
+ import { LoaderResult } from '@vitessce/abstract';
66
+ //# sourceMappingURL=ObsSetStatsAnndataLoader.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ObsSetStatsAnndataLoader.d.ts","sourceRoot":"","sources":["../../src/anndata-loaders/ObsSetStatsAnndataLoader.js"],"names":[],"mappings":"AAMA,uDAAuD;AACvD,yDAAyD;AAGzD;;;;GAIG;AACH,8CAH6B,cAAc,SAA9B,aAAe;;IAI1B;;;OAGG;IACH,kCAFa,OAAO,CAAC,GAAG,CAAC,CAQxB;IAED;;;OAGG;IACH,+BAFa,OAAO,CAAC,GAAG,CAAC,CAQxB;IAED;;;OAGG;IACH,6BAFa,OAAO,CAAC,GAAG,CAAC,CAQxB;IAED;;;OAGG;IACH,8BAFa,OAAO,CAAC,GAAG,CAAC,CAYxB;IAED,8CAGC;IAED,gDAOC;IAED;;;;;;;OA6BC;IAED;;;OAGG;IACH,gBAFa,OAAO,CAAC,SAAS,EAAE,CAAC,CAYhC;IAJG,cAA2E;IAO/E;;;;;;;;OAQG;IACH,0BANG;QAAuC,WAAW;QACX,WAAW;QACb,IAAI;QACA,kBAAkB;KAC3D,GAAU,OAAO,CAAC,YAAY,CAAC,OAAe,CAAC,CAAC,CAmElD;IAGD,sBAEC;CACF;+BA5M8B,qBAAqB;sCAJA,oBAAoB;6BAApB,oBAAoB"}