@vitessce/zarr 3.5.10 → 3.5.11
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/index.js +66 -40
- package/dist-tsc/AnnDataSource.d.ts +2 -4
- package/dist-tsc/AnnDataSource.d.ts.map +1 -1
- package/dist-tsc/AnnDataSource.js +30 -16
- package/dist-tsc/anndata-loaders/FeatureSetStatsAnndataLoader.d.ts +2 -2
- package/dist-tsc/anndata-loaders/FeatureSetStatsAnndataLoader.d.ts.map +1 -1
- package/dist-tsc/anndata-loaders/FeatureSetStatsAnndataLoader.js +30 -9
- package/dist-tsc/anndata-loaders/FeatureStatsAnndataLoader.d.ts.map +1 -1
- package/dist-tsc/anndata-loaders/FeatureStatsAnndataLoader.js +9 -2
- package/dist-tsc/anndata-loaders/ObsSetStatsAnndataLoader.d.ts +0 -2
- package/dist-tsc/anndata-loaders/ObsSetStatsAnndataLoader.d.ts.map +1 -1
- package/dist-tsc/anndata-loaders/ObsSetStatsAnndataLoader.js +11 -12
- package/dist-tsc/anndata-loaders/ObsSetsAnndataLoader.d.ts +3 -1
- package/dist-tsc/anndata-loaders/ObsSetsAnndataLoader.d.ts.map +1 -1
- package/dist-tsc/anndata-loaders/ObsSetsAnndataLoader.js +7 -1
- package/package.json +10 -10
- package/src/AnnDataSource.js +32 -16
- package/src/anndata-loaders/FeatureSetStatsAnndataLoader.js +36 -7
- package/src/anndata-loaders/FeatureStatsAnndataLoader.js +9 -2
- package/src/anndata-loaders/ObsSetStatsAnndataLoader.js +9 -12
- package/src/anndata-loaders/ObsSetsAnndataLoader.js +8 -1
package/dist/index.js
CHANGED
|
@@ -3132,6 +3132,15 @@ function basename(path) {
|
|
|
3132
3132
|
}
|
|
3133
3133
|
return result;
|
|
3134
3134
|
}
|
|
3135
|
+
function prependSlash(path) {
|
|
3136
|
+
if (typeof path === "string" && path.length >= 1) {
|
|
3137
|
+
if (path.charAt(0) === "/") {
|
|
3138
|
+
return path;
|
|
3139
|
+
}
|
|
3140
|
+
return `/${path}`;
|
|
3141
|
+
}
|
|
3142
|
+
return path;
|
|
3143
|
+
}
|
|
3135
3144
|
class AnnDataSource extends ZarrDataSource {
|
|
3136
3145
|
/**
|
|
3137
3146
|
*
|
|
@@ -3199,42 +3208,46 @@ class AnnDataSource extends ZarrDataSource {
|
|
|
3199
3208
|
}
|
|
3200
3209
|
/**
|
|
3201
3210
|
*
|
|
3202
|
-
* @param {string}
|
|
3211
|
+
* @param {string} pathOrig
|
|
3203
3212
|
* @returns
|
|
3204
3213
|
*/
|
|
3205
|
-
async _loadColumn(
|
|
3214
|
+
async _loadColumn(pathOrig) {
|
|
3206
3215
|
const { storeRoot } = this;
|
|
3207
|
-
const
|
|
3216
|
+
const path = prependSlash(pathOrig);
|
|
3217
|
+
const prefixOrig = dirname(path);
|
|
3218
|
+
const prefix = prependSlash(prefixOrig);
|
|
3208
3219
|
const { categories, "encoding-type": encodingType } = await this.getJson(`${path}/.zattrs`);
|
|
3209
3220
|
let categoriesValues;
|
|
3210
3221
|
let codesPath;
|
|
3211
3222
|
if (categories) {
|
|
3212
3223
|
const { dtype } = await open(
|
|
3213
|
-
storeRoot.resolve(
|
|
3224
|
+
storeRoot.resolve(`${prefix}/${categories}`),
|
|
3214
3225
|
{ kind: "array" }
|
|
3215
3226
|
);
|
|
3216
|
-
if (dtype === "v2:object") {
|
|
3227
|
+
if (dtype === "v2:object" || dtype === "|O") {
|
|
3217
3228
|
categoriesValues = await this.getFlatArrDecompressed(
|
|
3218
|
-
|
|
3229
|
+
`${prefix}/${categories}`
|
|
3219
3230
|
);
|
|
3220
3231
|
}
|
|
3221
3232
|
} else if (encodingType === "categorical") {
|
|
3222
3233
|
const { dtype } = await open(
|
|
3223
|
-
storeRoot.resolve(
|
|
3234
|
+
storeRoot.resolve(`${path}/categories`),
|
|
3224
3235
|
{ kind: "array" }
|
|
3225
3236
|
);
|
|
3226
|
-
if (dtype === "v2:object") {
|
|
3237
|
+
if (dtype === "v2:object" || dtype === "|O") {
|
|
3227
3238
|
categoriesValues = await this.getFlatArrDecompressed(
|
|
3228
|
-
|
|
3239
|
+
`${path}/categories`
|
|
3229
3240
|
);
|
|
3230
3241
|
}
|
|
3231
|
-
codesPath =
|
|
3242
|
+
codesPath = `${path}/codes`;
|
|
3243
|
+
} else if (encodingType === "string-array") {
|
|
3244
|
+
return this.getFlatArrDecompressed(path);
|
|
3232
3245
|
} else {
|
|
3233
3246
|
const { dtype } = await open(
|
|
3234
|
-
storeRoot.resolve(
|
|
3247
|
+
storeRoot.resolve(path),
|
|
3235
3248
|
{ kind: "array" }
|
|
3236
3249
|
);
|
|
3237
|
-
if (dtype === "v2:object") {
|
|
3250
|
+
if (dtype === "v2:object" || dtype === "|O") {
|
|
3238
3251
|
return this.getFlatArrDecompressed(path);
|
|
3239
3252
|
}
|
|
3240
3253
|
}
|
|
@@ -3317,7 +3330,7 @@ class AnnDataSource extends ZarrDataSource {
|
|
|
3317
3330
|
if (this.obsIndex) {
|
|
3318
3331
|
return this.obsIndex;
|
|
3319
3332
|
}
|
|
3320
|
-
this.obsIndex = this.getJson("obs/.zattrs").then(({ _index }) => this.
|
|
3333
|
+
this.obsIndex = this.getJson("obs/.zattrs").then(({ _index }) => this._loadColumn(`/obs/${_index}`));
|
|
3321
3334
|
return this.obsIndex;
|
|
3322
3335
|
}
|
|
3323
3336
|
/**
|
|
@@ -3328,7 +3341,7 @@ class AnnDataSource extends ZarrDataSource {
|
|
|
3328
3341
|
*/
|
|
3329
3342
|
loadDataFrameIndex(path = void 0) {
|
|
3330
3343
|
const dfPath = path ? dirname(path) : "";
|
|
3331
|
-
return this.getJson(`${dfPath}/.zattrs`).then(({ _index }) => this.
|
|
3344
|
+
return this.getJson(`${dfPath}/.zattrs`).then(({ _index }) => this._loadColumn(`${dfPath.length > 0 ? "/" : ""}${dfPath}/${_index}`));
|
|
3332
3345
|
}
|
|
3333
3346
|
/**
|
|
3334
3347
|
* Class method for loading the var index.
|
|
@@ -3339,7 +3352,7 @@ class AnnDataSource extends ZarrDataSource {
|
|
|
3339
3352
|
if (this.varIndex) {
|
|
3340
3353
|
return this.varIndex;
|
|
3341
3354
|
}
|
|
3342
|
-
this.varIndex = this.getJson("var/.zattrs").then(({ _index }) => this.
|
|
3355
|
+
this.varIndex = this.getJson("var/.zattrs").then(({ _index }) => this._loadColumn(`/var/${_index}`));
|
|
3343
3356
|
return this.varIndex;
|
|
3344
3357
|
}
|
|
3345
3358
|
/**
|
|
@@ -4268,6 +4281,7 @@ const CoordinationType$1 = {
|
|
|
4268
4281
|
FEATURE_VALUE_COLORMAP: "featureValueColormap",
|
|
4269
4282
|
FEATURE_VALUE_TRANSFORM: "featureValueTransform",
|
|
4270
4283
|
FEATURE_VALUE_COLORMAP_RANGE: "featureValueColormapRange",
|
|
4284
|
+
FEATURE_AGGREGATION_STRATEGY: "featureAggregationStrategy",
|
|
4271
4285
|
OBS_COLOR_ENCODING: "obsColorEncoding",
|
|
4272
4286
|
SPATIAL_IMAGE_LAYER: "spatialImageLayer",
|
|
4273
4287
|
SPATIAL_SEGMENTATION_LAYER: "spatialSegmentationLayer",
|
|
@@ -13736,6 +13750,7 @@ z.object({
|
|
|
13736
13750
|
termColumn: z.string().optional(),
|
|
13737
13751
|
pValueColumn: z.string(),
|
|
13738
13752
|
pValueAdjusted: z.boolean().optional(),
|
|
13753
|
+
featureSetLibrary: z.string().optional().describe("Optionally, provide a feature set library name. By default, Reactome_2022."),
|
|
13739
13754
|
analysisType: z.string().optional().describe("Optionally, provide an analysis_type name. By default, pertpy_hypergeometric.")
|
|
13740
13755
|
});
|
|
13741
13756
|
z.object({
|
|
@@ -13746,7 +13761,6 @@ z.object({
|
|
|
13746
13761
|
foldChangeColumn: z.string().describe("The log-fold change is then calculated between this expected sample and the expected sample with no active covariates from the intercept section."),
|
|
13747
13762
|
foldChangeTransformation: z.enum(["log2"]).optional(),
|
|
13748
13763
|
isCredibleEffectColumn: z.string().describe("Column which annotates effects as being credible or not (boolean)."),
|
|
13749
|
-
covariateColumn: z.string().describe("Column which defines the covariate used in the analysis."),
|
|
13750
13764
|
analysisType: z.string().optional().describe("Optionally, provide an analysis_type name. By default, sccoda_df.")
|
|
13751
13765
|
});
|
|
13752
13766
|
const annDataObsLabels = annDataObs;
|
|
@@ -20712,6 +20726,11 @@ function interpolateSequentialMulti(range2) {
|
|
|
20712
20726
|
interpolateRgbBasis(schemeRdBu);
|
|
20713
20727
|
interpolateSequentialMulti(schemePlasma);
|
|
20714
20728
|
class ObsSetsAnndataLoader extends AbstractTwoStepLoader {
|
|
20729
|
+
constructor(dataSource, params) {
|
|
20730
|
+
super(dataSource, params);
|
|
20731
|
+
this.region = null;
|
|
20732
|
+
this.tablePath = null;
|
|
20733
|
+
}
|
|
20715
20734
|
loadObsIndices() {
|
|
20716
20735
|
var _a2;
|
|
20717
20736
|
const { options } = this;
|
|
@@ -20746,7 +20765,7 @@ class ObsSetsAnndataLoader extends AbstractTwoStepLoader {
|
|
|
20746
20765
|
if (!this.cachedResult) {
|
|
20747
20766
|
const { options } = this;
|
|
20748
20767
|
this.cachedResult = Promise.all([
|
|
20749
|
-
this.dataSource.loadObsIndex(),
|
|
20768
|
+
this.dataSource.loadObsIndex(this.tablePath),
|
|
20750
20769
|
this.loadObsIndices(),
|
|
20751
20770
|
this.loadCellSetIds(),
|
|
20752
20771
|
this.loadCellSetScores()
|
|
@@ -21099,11 +21118,11 @@ let FeatureStatsAnndataLoader$1 = class FeatureStatsAnndataLoader extends Abstra
|
|
|
21099
21118
|
const rawSampleSetSelection = sampleSetSelection;
|
|
21100
21119
|
if (sampleSetSelection) {
|
|
21101
21120
|
if (sampleSetSelection.length !== 2) {
|
|
21102
|
-
return
|
|
21121
|
+
return null;
|
|
21103
21122
|
}
|
|
21104
21123
|
}
|
|
21105
21124
|
if (!obsSetSelection) {
|
|
21106
|
-
return
|
|
21125
|
+
return null;
|
|
21107
21126
|
}
|
|
21108
21127
|
const metadata = await this.loadMetadata();
|
|
21109
21128
|
const matchingComparisons = [];
|
|
@@ -21180,9 +21199,21 @@ class FeatureStatsAnndataLoader2 extends AbstractTwoStepLoader {
|
|
|
21180
21199
|
this.loadFeatureSetTerms(dfPath),
|
|
21181
21200
|
this.loadSignificances(dfPath)
|
|
21182
21201
|
]);
|
|
21202
|
+
const cleanName = (s) => {
|
|
21203
|
+
if (s.includes("R-HSA-")) {
|
|
21204
|
+
return s.substring(0, s.indexOf("R-HSA-") - 1);
|
|
21205
|
+
}
|
|
21206
|
+
return s;
|
|
21207
|
+
};
|
|
21208
|
+
const cleanTerm = (s) => {
|
|
21209
|
+
if (s.includes("R-HSA-")) {
|
|
21210
|
+
return `REACTOME:${s.substring(s.indexOf("R-HSA-"))}`;
|
|
21211
|
+
}
|
|
21212
|
+
return s;
|
|
21213
|
+
};
|
|
21183
21214
|
return {
|
|
21184
|
-
featureSetName,
|
|
21185
|
-
featureSetTerm,
|
|
21215
|
+
featureSetName: featureSetName.map((s) => cleanName(s)),
|
|
21216
|
+
featureSetTerm: featureSetTerm.map((s) => cleanTerm(s)),
|
|
21186
21217
|
featureSetSignificance
|
|
21187
21218
|
};
|
|
21188
21219
|
}
|
|
@@ -21211,30 +21242,34 @@ class FeatureStatsAnndataLoader2 extends AbstractTwoStepLoader {
|
|
|
21211
21242
|
* @returns {Promise<LoaderResult<FeatureStatsData>>}
|
|
21212
21243
|
*/
|
|
21213
21244
|
async loadMulti(volcanoOptions) {
|
|
21214
|
-
const {
|
|
21245
|
+
const {
|
|
21246
|
+
analysisType: targetAnalysisType = "pertpy_hypergeometric",
|
|
21247
|
+
featureSetLibrary: targetFeatureSetLibrary = "Reactome_2022"
|
|
21248
|
+
} = this.options;
|
|
21215
21249
|
const { sampleSetSelection, obsSetSelection } = volcanoOptions || {};
|
|
21216
21250
|
const rawObsSetSelection = obsSetSelection;
|
|
21217
21251
|
const rawSampleSetSelection = sampleSetSelection;
|
|
21218
21252
|
if (sampleSetSelection) {
|
|
21219
21253
|
if (sampleSetSelection.length !== 2) {
|
|
21220
|
-
return
|
|
21254
|
+
return null;
|
|
21221
21255
|
}
|
|
21222
21256
|
}
|
|
21223
21257
|
if (!obsSetSelection) {
|
|
21224
|
-
return
|
|
21258
|
+
return null;
|
|
21225
21259
|
}
|
|
21226
21260
|
const metadata = await this.loadMetadata();
|
|
21227
21261
|
const matchingComparisons = [];
|
|
21228
21262
|
Object.values(metadata.comparisons).forEach((comparisonGroupObject) => {
|
|
21229
21263
|
const { results } = comparisonGroupObject;
|
|
21230
21264
|
results.forEach((resultObject) => {
|
|
21265
|
+
var _a2;
|
|
21231
21266
|
const {
|
|
21232
21267
|
analysis_type,
|
|
21233
|
-
|
|
21268
|
+
analysis_params,
|
|
21234
21269
|
coordination_values
|
|
21235
21270
|
// path,
|
|
21236
21271
|
} = resultObject;
|
|
21237
|
-
if (analysis_type === targetAnalysisType) {
|
|
21272
|
+
if (analysis_type === targetAnalysisType && ((_a2 = analysis_params == null ? void 0 : analysis_params.pertpy_hypergeometric) == null ? void 0 : _a2.enrichr_library_name) === targetFeatureSetLibrary) {
|
|
21238
21273
|
if (sampleSetSelection) {
|
|
21239
21274
|
rawObsSetSelection.forEach((obsSetPath) => {
|
|
21240
21275
|
if (isEqual([obsSetPath], coordination_values.obsSetFilter)) {
|
|
@@ -21307,10 +21342,6 @@ class ObsSetStatsAnndataLoader extends AbstractTwoStepLoader {
|
|
|
21307
21342
|
}
|
|
21308
21343
|
return values.data;
|
|
21309
21344
|
}
|
|
21310
|
-
async loadCovariate(dfPath) {
|
|
21311
|
-
const { covariateColumn } = this.options;
|
|
21312
|
-
return this.dataSource._loadColumn(`${dfPath}/${covariateColumn}`);
|
|
21313
|
-
}
|
|
21314
21345
|
async loadObsSetNames(dfPath) {
|
|
21315
21346
|
const { indexColumn } = this.options;
|
|
21316
21347
|
if (indexColumn) {
|
|
@@ -21324,28 +21355,23 @@ class ObsSetStatsAnndataLoader extends AbstractTwoStepLoader {
|
|
|
21324
21355
|
obsSetFoldChange,
|
|
21325
21356
|
interceptExpectedSample,
|
|
21326
21357
|
effectExpectedSample,
|
|
21327
|
-
isCredibleEffect
|
|
21358
|
+
isCredibleEffect
|
|
21328
21359
|
// TODO: rather than passing this down,
|
|
21329
21360
|
// do the fold change direction swapping in the loader
|
|
21330
21361
|
// (as opposed to in the view).
|
|
21331
|
-
// TODO: also, see https://github.com/keller-mark/compasce/issues/30
|
|
21332
|
-
// which would allow not loading this column altogether.
|
|
21333
|
-
covariate
|
|
21334
21362
|
] = await Promise.all([
|
|
21335
21363
|
this.loadObsSetNames(dfPath),
|
|
21336
21364
|
this.loadFoldChanges(dfPath),
|
|
21337
21365
|
this.loadInterceptValues(dfPath),
|
|
21338
21366
|
this.loadEffectValues(dfPath),
|
|
21339
|
-
this.loadIsCredible(dfPath)
|
|
21340
|
-
this.loadCovariate(dfPath)
|
|
21367
|
+
this.loadIsCredible(dfPath)
|
|
21341
21368
|
]);
|
|
21342
21369
|
return {
|
|
21343
21370
|
obsSetId,
|
|
21344
21371
|
obsSetFoldChange,
|
|
21345
21372
|
interceptExpectedSample,
|
|
21346
21373
|
effectExpectedSample,
|
|
21347
|
-
isCredibleEffect
|
|
21348
|
-
covariate
|
|
21374
|
+
isCredibleEffect
|
|
21349
21375
|
};
|
|
21350
21376
|
}
|
|
21351
21377
|
/**
|
|
@@ -21378,10 +21404,10 @@ class ObsSetStatsAnndataLoader extends AbstractTwoStepLoader {
|
|
|
21378
21404
|
const rawObsSetSelection = obsSetSelection;
|
|
21379
21405
|
const rawSampleSetSelection = sampleSetSelection;
|
|
21380
21406
|
if (!sampleSetSelection || (sampleSetSelection == null ? void 0 : sampleSetSelection.length) !== 2) {
|
|
21381
|
-
return
|
|
21407
|
+
return null;
|
|
21382
21408
|
}
|
|
21383
21409
|
if (!obsSetSelection) {
|
|
21384
|
-
return
|
|
21410
|
+
return null;
|
|
21385
21411
|
}
|
|
21386
21412
|
const metadata = await this.loadMetadata();
|
|
21387
21413
|
const rawObsSetGroups = Array.from(
|
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
/** @import { DataSourceParams } from '@vitessce/types' */
|
|
2
|
-
/** @import { TypedArray as ZarrTypedArray, Chunk, ByteStringArray } from 'zarrita' */
|
|
3
1
|
/**
|
|
4
2
|
* A base AnnData loader which has all shared methods for more comlpex laoders,
|
|
5
3
|
* like loading cell names and ids. It inherits from AbstractLoader.
|
|
@@ -42,10 +40,10 @@ export default class AnnDataSource extends ZarrDataSource {
|
|
|
42
40
|
_loadColumns(paths: string[] | string[][]): Promise<(undefined | string[] | string[][])[]>;
|
|
43
41
|
/**
|
|
44
42
|
*
|
|
45
|
-
* @param {string}
|
|
43
|
+
* @param {string} pathOrig
|
|
46
44
|
* @returns
|
|
47
45
|
*/
|
|
48
|
-
_loadColumn(
|
|
46
|
+
_loadColumn(pathOrig: string): Promise<string[]>;
|
|
49
47
|
/**
|
|
50
48
|
* Class method for loading general numeric arrays.
|
|
51
49
|
* @param {string} path A string like obsm.X_pca.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AnnDataSource.d.ts","sourceRoot":"","sources":["../src/AnnDataSource.js"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"AnnDataSource.d.ts","sourceRoot":"","sources":["../src/AnnDataSource.js"],"names":[],"mappings":"AAoBA;;;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,sBAHW,MAAM,qBAwDhB;IAED;;;;OAIG;IACH,kBAHW,MAAM,GACJ,OAAO,CAAC,MAAM,GAAG,CAAC,CAAC,CAM/B;IAED;;;;;;;;OAQG;IACH,yBAPW,MAAM,QACN,CAAC,MAAM,EAAE,MAAM,CAAC,GACd,OAAO,CAAC;QACpB,IAAO,EAAE,CAAC,eAAe,GAAG,CAAC,EAAE,eAAe,GAAG,CAAC,CAAC,CAAC;QACpD,KAAQ,EAAE,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;KACxB,CAAC,CAeJ;IAED;;;;;OAKG;IACH,6BAHW,MAAM,GACJ,OAAO,CAAC,MAAM,EAAE,CAAC,CAW7B;IAED;;;;;OAKG;IACH,oBAJW,MAAM,GAAC,SAAS,GACd,OAAO,CAAC,MAAM,EAAE,CAAC,CAa7B;IAHC,wCAC2D;IAI7D;;;;;OAKG;IACH,0BAJW,MAAM,GAAC,SAAS,GACd,OAAO,CAAC,MAAM,EAAE,CAAC,CAU7B;IAED;;;;OAIG;IACH,oBAHW,MAAM,GAAC,SAAS,GACd,OAAO,CAAC,MAAM,EAAE,CAAC,CAY7B;IAHC,wCAC2D;IAI7D;;;;;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;2BA1X0B,qBAAqB;2BAE0B,SAAS;kDAAT,SAAS;sCAD7C,iBAAiB"}
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
// @ts-check
|
|
2
1
|
/* eslint-disable no-underscore-dangle */
|
|
3
2
|
import { open as zarrOpen, get as zarrGet } from 'zarrita';
|
|
4
3
|
import { log } from '@vitessce/globals';
|
|
@@ -6,6 +5,16 @@ import { dirname } from './utils.js';
|
|
|
6
5
|
import ZarrDataSource from './ZarrDataSource.js';
|
|
7
6
|
/** @import { DataSourceParams } from '@vitessce/types' */
|
|
8
7
|
/** @import { TypedArray as ZarrTypedArray, Chunk, ByteStringArray } from 'zarrita' */
|
|
8
|
+
function prependSlash(path) {
|
|
9
|
+
if (typeof path === 'string' && path.length >= 1) {
|
|
10
|
+
if (path.charAt(0) === '/') {
|
|
11
|
+
// No prepending needed.
|
|
12
|
+
return path;
|
|
13
|
+
}
|
|
14
|
+
return `/${path}`;
|
|
15
|
+
}
|
|
16
|
+
return path;
|
|
17
|
+
}
|
|
9
18
|
/**
|
|
10
19
|
* A base AnnData loader which has all shared methods for more comlpex laoders,
|
|
11
20
|
* like loading cell names and ids. It inherits from AbstractLoader.
|
|
@@ -78,33 +87,38 @@ export default class AnnDataSource extends ZarrDataSource {
|
|
|
78
87
|
}
|
|
79
88
|
/**
|
|
80
89
|
*
|
|
81
|
-
* @param {string}
|
|
90
|
+
* @param {string} pathOrig
|
|
82
91
|
* @returns
|
|
83
92
|
*/
|
|
84
|
-
async _loadColumn(
|
|
93
|
+
async _loadColumn(pathOrig) {
|
|
85
94
|
const { storeRoot } = this;
|
|
86
|
-
const
|
|
95
|
+
const path = prependSlash(pathOrig);
|
|
96
|
+
const prefixOrig = dirname(path);
|
|
97
|
+
const prefix = prependSlash(prefixOrig);
|
|
87
98
|
const { categories, 'encoding-type': encodingType } = await this.getJson(`${path}/.zattrs`);
|
|
88
99
|
/** @type {string[]} */
|
|
89
100
|
let categoriesValues;
|
|
90
101
|
/** @type {undefined | string} */
|
|
91
102
|
let codesPath;
|
|
92
103
|
if (categories) {
|
|
93
|
-
const { dtype } = await zarrOpen(storeRoot.resolve(
|
|
94
|
-
if (dtype === 'v2:object') {
|
|
95
|
-
categoriesValues = await this.getFlatArrDecompressed(
|
|
104
|
+
const { dtype } = await zarrOpen(storeRoot.resolve(`${prefix}/${categories}`), { kind: 'array' });
|
|
105
|
+
if (dtype === 'v2:object' || dtype === '|O') {
|
|
106
|
+
categoriesValues = await this.getFlatArrDecompressed(`${prefix}/${categories}`);
|
|
96
107
|
}
|
|
97
108
|
}
|
|
98
109
|
else if (encodingType === 'categorical') {
|
|
99
|
-
const { dtype } = await zarrOpen(storeRoot.resolve(
|
|
100
|
-
if (dtype === 'v2:object') {
|
|
101
|
-
categoriesValues = await this.getFlatArrDecompressed(
|
|
110
|
+
const { dtype } = await zarrOpen(storeRoot.resolve(`${path}/categories`), { kind: 'array' });
|
|
111
|
+
if (dtype === 'v2:object' || dtype === '|O') {
|
|
112
|
+
categoriesValues = await this.getFlatArrDecompressed(`${path}/categories`);
|
|
102
113
|
}
|
|
103
|
-
codesPath =
|
|
114
|
+
codesPath = `${path}/codes`;
|
|
115
|
+
}
|
|
116
|
+
else if (encodingType === 'string-array') {
|
|
117
|
+
return this.getFlatArrDecompressed(path);
|
|
104
118
|
}
|
|
105
119
|
else {
|
|
106
|
-
const { dtype } = await zarrOpen(storeRoot.resolve(
|
|
107
|
-
if (dtype === 'v2:object') {
|
|
120
|
+
const { dtype } = await zarrOpen(storeRoot.resolve(path), { kind: 'array' });
|
|
121
|
+
if (dtype === 'v2:object' || dtype === '|O') {
|
|
108
122
|
return this.getFlatArrDecompressed(path);
|
|
109
123
|
}
|
|
110
124
|
}
|
|
@@ -170,7 +184,7 @@ export default class AnnDataSource extends ZarrDataSource {
|
|
|
170
184
|
return this.obsIndex;
|
|
171
185
|
}
|
|
172
186
|
this.obsIndex = this.getJson('obs/.zattrs')
|
|
173
|
-
.then(({ _index }) => this.
|
|
187
|
+
.then(({ _index }) => this._loadColumn(`/obs/${_index}`));
|
|
174
188
|
return this.obsIndex;
|
|
175
189
|
}
|
|
176
190
|
/**
|
|
@@ -184,7 +198,7 @@ export default class AnnDataSource extends ZarrDataSource {
|
|
|
184
198
|
path = undefined) {
|
|
185
199
|
const dfPath = path ? dirname(path) : '';
|
|
186
200
|
return this.getJson(`${dfPath}/.zattrs`)
|
|
187
|
-
.then(({ _index }) => this.
|
|
201
|
+
.then(({ _index }) => this._loadColumn(`${dfPath.length > 0 ? '/' : ''}${dfPath}/${_index}`));
|
|
188
202
|
}
|
|
189
203
|
/**
|
|
190
204
|
* Class method for loading the var index.
|
|
@@ -198,7 +212,7 @@ export default class AnnDataSource extends ZarrDataSource {
|
|
|
198
212
|
return this.varIndex;
|
|
199
213
|
}
|
|
200
214
|
this.varIndex = this.getJson('var/.zattrs')
|
|
201
|
-
.then(({ _index }) => this.
|
|
215
|
+
.then(({ _index }) => this._loadColumn(`/var/${_index}`));
|
|
202
216
|
return this.varIndex;
|
|
203
217
|
}
|
|
204
218
|
/**
|
|
@@ -15,8 +15,8 @@ export default class FeatureStatsAnndataLoader<DataSourceType extends AnnDataSou
|
|
|
15
15
|
loadFeatureSetNames(dfPath: any): Promise<string[]>;
|
|
16
16
|
loadFeatureSetTerms(dfPath: any): Promise<string[]>;
|
|
17
17
|
loadDataFrame(dfPath: any): Promise<{
|
|
18
|
-
featureSetName:
|
|
19
|
-
featureSetTerm:
|
|
18
|
+
featureSetName: any[];
|
|
19
|
+
featureSetTerm: any[];
|
|
20
20
|
featureSetSignificance: any;
|
|
21
21
|
}>;
|
|
22
22
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FeatureSetStatsAnndataLoader.d.ts","sourceRoot":"","sources":["../../src/anndata-loaders/FeatureSetStatsAnndataLoader.js"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"FeatureSetStatsAnndataLoader.d.ts","sourceRoot":"","sources":["../../src/anndata-loaders/FeatureSetStatsAnndataLoader.js"],"names":[],"mappings":"AAOA,uDAAuD;AACvD,0DAA0D;AAG1D;;;;GAIG;AACH,+CAH6B,cAAc,SAA9B,aAAe;;IAI1B;;;OAGG;IACH,gCAFa,OAAO,CAAC,GAAG,CAAC,CAQxB;IAED,oDAOC;IAED,oDAGC;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,gBAAgB,CAAC,CAAC,CAwFnD;IAGD,sBAEC;CACF;+BAzL8B,qBAAqB;sCALA,oBAAoB;6BAApB,oBAAoB;sCAMlC,iBAAiB"}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
/* eslint-disable no-underscore-dangle */
|
|
2
2
|
/* eslint-disable camelcase */
|
|
3
3
|
import { LoaderResult, AbstractTwoStepLoader } from '@vitessce/abstract';
|
|
4
|
+
import { getDebugMode } from '@vitessce/globals';
|
|
4
5
|
import { isEqual } from 'lodash-es';
|
|
5
6
|
import { isEqualPathPair, loadComparisonMetadata } from './comparative-utils.js';
|
|
6
7
|
/** @import AnnDataSource from '../AnnDataSource.js' */
|
|
@@ -40,9 +41,22 @@ export default class FeatureStatsAnndataLoader extends AbstractTwoStepLoader {
|
|
|
40
41
|
this.loadFeatureSetTerms(dfPath),
|
|
41
42
|
this.loadSignificances(dfPath),
|
|
42
43
|
]);
|
|
44
|
+
// TODO: this is temporary until KPMP data has been re-processed.
|
|
45
|
+
const cleanName = (s) => {
|
|
46
|
+
if (s.includes('R-HSA-')) {
|
|
47
|
+
return s.substring(0, s.indexOf('R-HSA-') - 1);
|
|
48
|
+
}
|
|
49
|
+
return s;
|
|
50
|
+
};
|
|
51
|
+
const cleanTerm = (s) => {
|
|
52
|
+
if (s.includes('R-HSA-')) {
|
|
53
|
+
return `REACTOME:${s.substring(s.indexOf('R-HSA-'))}`;
|
|
54
|
+
}
|
|
55
|
+
return s;
|
|
56
|
+
};
|
|
43
57
|
return {
|
|
44
|
-
featureSetName,
|
|
45
|
-
featureSetTerm,
|
|
58
|
+
featureSetName: featureSetName.map(s => cleanName(s)),
|
|
59
|
+
featureSetTerm: featureSetTerm.map(s => cleanTerm(s)),
|
|
46
60
|
featureSetSignificance,
|
|
47
61
|
};
|
|
48
62
|
}
|
|
@@ -71,7 +85,7 @@ export default class FeatureStatsAnndataLoader extends AbstractTwoStepLoader {
|
|
|
71
85
|
* @returns {Promise<LoaderResult<FeatureStatsData>>}
|
|
72
86
|
*/
|
|
73
87
|
async loadMulti(volcanoOptions) {
|
|
74
|
-
const { analysisType: targetAnalysisType = 'pertpy_hypergeometric' } = this.options;
|
|
88
|
+
const { analysisType: targetAnalysisType = 'pertpy_hypergeometric', featureSetLibrary: targetFeatureSetLibrary = 'Reactome_2022', } = this.options;
|
|
75
89
|
const { sampleSetSelection, obsSetSelection } = volcanoOptions || {};
|
|
76
90
|
// TODO: should this also depend on a "featureSetType" such as "pathway"
|
|
77
91
|
// or an ontology id/name such as "GO" vs. "CHEMBL"?
|
|
@@ -83,11 +97,17 @@ export default class FeatureStatsAnndataLoader extends AbstractTwoStepLoader {
|
|
|
83
97
|
const rawSampleSetSelection = sampleSetSelection;
|
|
84
98
|
if (sampleSetSelection) {
|
|
85
99
|
if (sampleSetSelection.length !== 2) {
|
|
86
|
-
|
|
100
|
+
if (getDebugMode()) {
|
|
101
|
+
return Promise.reject(new Error('Expected exactly two sample sets for volcano plot.'));
|
|
102
|
+
}
|
|
103
|
+
return null;
|
|
87
104
|
}
|
|
88
105
|
}
|
|
89
106
|
if (!obsSetSelection) {
|
|
90
|
-
|
|
107
|
+
if (getDebugMode()) {
|
|
108
|
+
return Promise.reject(new Error('Expected obsSetSelection to be present.'));
|
|
109
|
+
}
|
|
110
|
+
return null;
|
|
91
111
|
}
|
|
92
112
|
const metadata = await this.loadMetadata();
|
|
93
113
|
// Match metadata against to get paths to dataframe(s) of interest.
|
|
@@ -95,12 +115,13 @@ export default class FeatureStatsAnndataLoader extends AbstractTwoStepLoader {
|
|
|
95
115
|
Object.values(metadata.comparisons).forEach((comparisonGroupObject) => {
|
|
96
116
|
const { results } = comparisonGroupObject;
|
|
97
117
|
results.forEach((resultObject) => {
|
|
98
|
-
const { analysis_type,
|
|
99
|
-
// analysis_params,
|
|
100
|
-
coordination_values,
|
|
118
|
+
const { analysis_type, analysis_params, coordination_values,
|
|
101
119
|
// path,
|
|
102
120
|
} = resultObject;
|
|
103
|
-
if (analysis_type === targetAnalysisType
|
|
121
|
+
if (analysis_type === targetAnalysisType
|
|
122
|
+
&& (analysis_params
|
|
123
|
+
?.pertpy_hypergeometric
|
|
124
|
+
?.enrichr_library_name === targetFeatureSetLibrary)) {
|
|
104
125
|
// This is a diff. exp. result.
|
|
105
126
|
if (sampleSetSelection) {
|
|
106
127
|
// Comparing two sample groups.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FeatureStatsAnndataLoader.d.ts","sourceRoot":"","sources":["../../src/anndata-loaders/FeatureStatsAnndataLoader.js"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"FeatureStatsAnndataLoader.d.ts","sourceRoot":"","sources":["../../src/anndata-loaders/FeatureStatsAnndataLoader.js"],"names":[],"mappings":"AAOA,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,CA6EnD;IAGD,sBAEC;CACF;+BAhL8B,qBAAqB;sCALA,oBAAoB;6BAApB,oBAAoB;sCAMlC,iBAAiB"}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
/* eslint-disable no-underscore-dangle */
|
|
2
2
|
/* eslint-disable camelcase */
|
|
3
3
|
import { LoaderResult, AbstractTwoStepLoader } from '@vitessce/abstract';
|
|
4
|
+
import { getDebugMode } from '@vitessce/globals';
|
|
4
5
|
import { isEqual } from 'lodash-es';
|
|
5
6
|
import { isEqualPathPair, loadComparisonMetadata } from './comparative-utils.js';
|
|
6
7
|
/** @import AnnDataSource from '../AnnDataSource.js' */
|
|
@@ -97,11 +98,17 @@ export default class FeatureStatsAnndataLoader extends AbstractTwoStepLoader {
|
|
|
97
98
|
const rawSampleSetSelection = sampleSetSelection;
|
|
98
99
|
if (sampleSetSelection) {
|
|
99
100
|
if (sampleSetSelection.length !== 2) {
|
|
100
|
-
|
|
101
|
+
if (getDebugMode()) {
|
|
102
|
+
return Promise.reject(new Error('Expected exactly two sample sets for volcano plot.'));
|
|
103
|
+
}
|
|
104
|
+
return null;
|
|
101
105
|
}
|
|
102
106
|
}
|
|
103
107
|
if (!obsSetSelection) {
|
|
104
|
-
|
|
108
|
+
if (getDebugMode()) {
|
|
109
|
+
return Promise.reject(new Error('Expected obsSetSelection to be present.'));
|
|
110
|
+
}
|
|
111
|
+
return null;
|
|
105
112
|
}
|
|
106
113
|
const metadata = await this.loadMetadata();
|
|
107
114
|
// Match metadata against to get paths to dataframe(s) of interest.
|
|
@@ -27,7 +27,6 @@ export default class ObsSetStatsAnndataLoader<DataSourceType extends AnnDataSour
|
|
|
27
27
|
* @returns {Promise<any>} A promise for the array.
|
|
28
28
|
*/
|
|
29
29
|
loadFoldChanges(dfPath: any): Promise<any>;
|
|
30
|
-
loadCovariate(dfPath: any): Promise<string[]>;
|
|
31
30
|
loadObsSetNames(dfPath: any): Promise<string[]>;
|
|
32
31
|
loadDataFrame(dfPath: any): Promise<{
|
|
33
32
|
obsSetId: string[];
|
|
@@ -35,7 +34,6 @@ export default class ObsSetStatsAnndataLoader<DataSourceType extends AnnDataSour
|
|
|
35
34
|
interceptExpectedSample: any;
|
|
36
35
|
effectExpectedSample: any;
|
|
37
36
|
isCredibleEffect: any;
|
|
38
|
-
covariate: string[];
|
|
39
37
|
}>;
|
|
40
38
|
/**
|
|
41
39
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ObsSetStatsAnndataLoader.d.ts","sourceRoot":"","sources":["../../src/anndata-loaders/ObsSetStatsAnndataLoader.js"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"ObsSetStatsAnndataLoader.d.ts","sourceRoot":"","sources":["../../src/anndata-loaders/ObsSetStatsAnndataLoader.js"],"names":[],"mappings":"AAOA,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,gDAOC;IAED;;;;;;OAwBC;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,CAyElD;IAGD,sBAEC;CACF;+BAxM8B,qBAAqB;sCALA,oBAAoB;6BAApB,oBAAoB"}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
/* eslint-disable no-underscore-dangle */
|
|
2
2
|
/* eslint-disable camelcase */
|
|
3
3
|
import { LoaderResult, AbstractTwoStepLoader } from '@vitessce/abstract';
|
|
4
|
+
import { getDebugMode } from '@vitessce/globals';
|
|
4
5
|
import { isEqual } from 'lodash-es';
|
|
5
6
|
import { isEqualPathPair, loadComparisonMetadata } from './comparative-utils.js';
|
|
6
7
|
/** @import AnnDataSource from '../AnnDataSource.js' */
|
|
@@ -59,10 +60,6 @@ export default class ObsSetStatsAnndataLoader extends AbstractTwoStepLoader {
|
|
|
59
60
|
}
|
|
60
61
|
return values.data;
|
|
61
62
|
}
|
|
62
|
-
async loadCovariate(dfPath) {
|
|
63
|
-
const { covariateColumn } = this.options;
|
|
64
|
-
return this.dataSource._loadColumn(`${dfPath}/${covariateColumn}`);
|
|
65
|
-
}
|
|
66
63
|
async loadObsSetNames(dfPath) {
|
|
67
64
|
const { indexColumn } = this.options;
|
|
68
65
|
if (indexColumn) {
|
|
@@ -72,19 +69,16 @@ export default class ObsSetStatsAnndataLoader extends AbstractTwoStepLoader {
|
|
|
72
69
|
return this.dataSource.loadDataFrameIndex(dfPath);
|
|
73
70
|
}
|
|
74
71
|
async loadDataFrame(dfPath) {
|
|
75
|
-
const [obsSetId, obsSetFoldChange, interceptExpectedSample, effectExpectedSample, isCredibleEffect,
|
|
72
|
+
const [obsSetId, obsSetFoldChange, interceptExpectedSample, effectExpectedSample, isCredibleEffect,
|
|
76
73
|
// TODO: rather than passing this down,
|
|
77
74
|
// do the fold change direction swapping in the loader
|
|
78
75
|
// (as opposed to in the view).
|
|
79
|
-
|
|
80
|
-
// which would allow not loading this column altogether.
|
|
81
|
-
covariate,] = await Promise.all([
|
|
76
|
+
] = await Promise.all([
|
|
82
77
|
this.loadObsSetNames(dfPath),
|
|
83
78
|
this.loadFoldChanges(dfPath),
|
|
84
79
|
this.loadInterceptValues(dfPath),
|
|
85
80
|
this.loadEffectValues(dfPath),
|
|
86
81
|
this.loadIsCredible(dfPath),
|
|
87
|
-
this.loadCovariate(dfPath),
|
|
88
82
|
]);
|
|
89
83
|
return {
|
|
90
84
|
obsSetId,
|
|
@@ -92,7 +86,6 @@ export default class ObsSetStatsAnndataLoader extends AbstractTwoStepLoader {
|
|
|
92
86
|
interceptExpectedSample,
|
|
93
87
|
effectExpectedSample,
|
|
94
88
|
isCredibleEffect,
|
|
95
|
-
covariate,
|
|
96
89
|
};
|
|
97
90
|
}
|
|
98
91
|
/**
|
|
@@ -129,10 +122,16 @@ export default class ObsSetStatsAnndataLoader extends AbstractTwoStepLoader {
|
|
|
129
122
|
const rawObsSetSelection = obsSetSelection;
|
|
130
123
|
const rawSampleSetSelection = sampleSetSelection;
|
|
131
124
|
if (!sampleSetSelection || sampleSetSelection?.length !== 2) {
|
|
132
|
-
|
|
125
|
+
if (getDebugMode()) {
|
|
126
|
+
return Promise.reject(new Error('Expected exactly two sample sets for cell type composition analysis plot.'));
|
|
127
|
+
}
|
|
128
|
+
return null;
|
|
133
129
|
}
|
|
134
130
|
if (!obsSetSelection) {
|
|
135
|
-
|
|
131
|
+
if (getDebugMode()) {
|
|
132
|
+
return Promise.reject(new Error('Expected obsSetSelection to be present.'));
|
|
133
|
+
}
|
|
134
|
+
return null;
|
|
136
135
|
}
|
|
137
136
|
const metadata = await this.loadMetadata();
|
|
138
137
|
// For cell type composition analysis,
|
|
@@ -2,7 +2,9 @@
|
|
|
2
2
|
* Loader for converting zarr into the cell sets json schema.
|
|
3
3
|
*/
|
|
4
4
|
export default class ObsSetsAnndataLoader extends AbstractTwoStepLoader<any> {
|
|
5
|
-
constructor(dataSource: any, params:
|
|
5
|
+
constructor(dataSource: any, params: any);
|
|
6
|
+
region: any;
|
|
7
|
+
tablePath: any;
|
|
6
8
|
loadObsIndices(): Promise<any[]>;
|
|
7
9
|
loadCellSetIds(): any;
|
|
8
10
|
loadCellSetScores(): any;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ObsSetsAnndataLoader.d.ts","sourceRoot":"","sources":["../../src/anndata-loaders/ObsSetsAnndataLoader.js"],"names":[],"mappings":"AAUA;;GAEG;AACH
|
|
1
|
+
{"version":3,"file":"ObsSetsAnndataLoader.d.ts","sourceRoot":"","sources":["../../src/anndata-loaders/ObsSetsAnndataLoader.js"],"names":[],"mappings":"AAUA;;GAEG;AACH;IACE,0CAKC;IAFC,YAAkB;IAClB,eAAqB;IAGvB,iCAkBC;IAED,sBAIC;IAED,yBAIC;IAED;;;;QA+BC;IAxBG,yCAK4F;CAoBjG;sCAnFM,oBAAoB;6BAApB,oBAAoB"}
|
|
@@ -4,6 +4,12 @@ import { initializeCellSetColor, treeToMembershipMap, dataToCellSetsTree, } from
|
|
|
4
4
|
* Loader for converting zarr into the cell sets json schema.
|
|
5
5
|
*/
|
|
6
6
|
export default class ObsSetsAnndataLoader extends AbstractTwoStepLoader {
|
|
7
|
+
constructor(dataSource, params) {
|
|
8
|
+
super(dataSource, params);
|
|
9
|
+
// These are used by the subclass SpatialDataObsSetsLoader.
|
|
10
|
+
this.region = null;
|
|
11
|
+
this.tablePath = null;
|
|
12
|
+
}
|
|
7
13
|
loadObsIndices() {
|
|
8
14
|
const { options } = this;
|
|
9
15
|
const obsIndexPromises = options
|
|
@@ -41,7 +47,7 @@ export default class ObsSetsAnndataLoader extends AbstractTwoStepLoader {
|
|
|
41
47
|
if (!this.cachedResult) {
|
|
42
48
|
const { options } = this;
|
|
43
49
|
this.cachedResult = Promise.all([
|
|
44
|
-
this.dataSource.loadObsIndex(),
|
|
50
|
+
this.dataSource.loadObsIndex(this.tablePath),
|
|
45
51
|
this.loadObsIndices(),
|
|
46
52
|
this.loadCellSetIds(),
|
|
47
53
|
this.loadCellSetScores(),
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vitessce/zarr",
|
|
3
|
-
"version": "3.5.
|
|
3
|
+
"version": "3.5.11",
|
|
4
4
|
"author": "HIDIVE Lab at HMS",
|
|
5
5
|
"homepage": "http://vitessce.io",
|
|
6
6
|
"repository": {
|
|
@@ -22,17 +22,17 @@
|
|
|
22
22
|
"apache-arrow": "^17.0.0",
|
|
23
23
|
"parquet-wasm": "^0.6.1",
|
|
24
24
|
"ol": "^10.2.1",
|
|
25
|
-
"@vitessce/abstract": "3.5.
|
|
26
|
-
"@vitessce/constants-internal": "3.5.
|
|
27
|
-
"@vitessce/sets-utils": "3.5.
|
|
28
|
-
"@vitessce/image-utils": "3.5.
|
|
29
|
-
"@vitessce/utils": "3.5.
|
|
30
|
-
"@vitessce/
|
|
31
|
-
"@vitessce/
|
|
32
|
-
"@vitessce/globals": "3.5.
|
|
25
|
+
"@vitessce/abstract": "3.5.11",
|
|
26
|
+
"@vitessce/constants-internal": "3.5.11",
|
|
27
|
+
"@vitessce/sets-utils": "3.5.11",
|
|
28
|
+
"@vitessce/image-utils": "3.5.11",
|
|
29
|
+
"@vitessce/utils": "3.5.11",
|
|
30
|
+
"@vitessce/config": "3.5.11",
|
|
31
|
+
"@vitessce/zarr-utils": "3.5.11",
|
|
32
|
+
"@vitessce/globals": "3.5.11"
|
|
33
33
|
},
|
|
34
34
|
"devDependencies": {
|
|
35
|
-
"@vitessce/types": "3.5.
|
|
35
|
+
"@vitessce/types": "3.5.11"
|
|
36
36
|
},
|
|
37
37
|
"scripts": {
|
|
38
38
|
"bundle": "pnpm exec vite build -c ../../../scripts/vite.config.js",
|
package/src/AnnDataSource.js
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
// @ts-check
|
|
2
1
|
/* eslint-disable no-underscore-dangle */
|
|
3
2
|
import { open as zarrOpen, get as zarrGet } from 'zarrita';
|
|
4
3
|
import { log } from '@vitessce/globals';
|
|
@@ -7,6 +6,18 @@ import ZarrDataSource from './ZarrDataSource.js';
|
|
|
7
6
|
/** @import { DataSourceParams } from '@vitessce/types' */
|
|
8
7
|
/** @import { TypedArray as ZarrTypedArray, Chunk, ByteStringArray } from 'zarrita' */
|
|
9
8
|
|
|
9
|
+
|
|
10
|
+
function prependSlash(path) {
|
|
11
|
+
if (typeof path === 'string' && path.length >= 1) {
|
|
12
|
+
if (path.charAt(0) === '/') {
|
|
13
|
+
// No prepending needed.
|
|
14
|
+
return path;
|
|
15
|
+
}
|
|
16
|
+
return `/${path}`;
|
|
17
|
+
}
|
|
18
|
+
return path;
|
|
19
|
+
}
|
|
20
|
+
|
|
10
21
|
/**
|
|
11
22
|
* A base AnnData loader which has all shared methods for more comlpex laoders,
|
|
12
23
|
* like loading cell names and ids. It inherits from AbstractLoader.
|
|
@@ -83,12 +94,14 @@ export default class AnnDataSource extends ZarrDataSource {
|
|
|
83
94
|
|
|
84
95
|
/**
|
|
85
96
|
*
|
|
86
|
-
* @param {string}
|
|
97
|
+
* @param {string} pathOrig
|
|
87
98
|
* @returns
|
|
88
99
|
*/
|
|
89
|
-
async _loadColumn(
|
|
100
|
+
async _loadColumn(pathOrig) {
|
|
90
101
|
const { storeRoot } = this;
|
|
91
|
-
const
|
|
102
|
+
const path = prependSlash(pathOrig);
|
|
103
|
+
const prefixOrig = dirname(path);
|
|
104
|
+
const prefix = prependSlash(prefixOrig);
|
|
92
105
|
const { categories, 'encoding-type': encodingType } = await this.getJson(`${path}/.zattrs`);
|
|
93
106
|
/** @type {string[]} */
|
|
94
107
|
let categoriesValues;
|
|
@@ -96,31 +109,34 @@ export default class AnnDataSource extends ZarrDataSource {
|
|
|
96
109
|
let codesPath;
|
|
97
110
|
if (categories) {
|
|
98
111
|
const { dtype } = await zarrOpen(
|
|
99
|
-
storeRoot.resolve(
|
|
112
|
+
storeRoot.resolve(`${prefix}/${categories}`),
|
|
100
113
|
{ kind: 'array' },
|
|
101
114
|
);
|
|
102
|
-
if (dtype === 'v2:object') {
|
|
115
|
+
if (dtype === 'v2:object' || dtype === '|O') {
|
|
103
116
|
categoriesValues = await this.getFlatArrDecompressed(
|
|
104
|
-
|
|
117
|
+
`${prefix}/${categories}`,
|
|
105
118
|
);
|
|
106
119
|
}
|
|
107
120
|
} else if (encodingType === 'categorical') {
|
|
108
121
|
const { dtype } = await zarrOpen(
|
|
109
|
-
storeRoot.resolve(
|
|
122
|
+
storeRoot.resolve(`${path}/categories`),
|
|
110
123
|
{ kind: 'array' },
|
|
111
124
|
);
|
|
112
|
-
|
|
125
|
+
|
|
126
|
+
if (dtype === 'v2:object' || dtype === '|O') {
|
|
113
127
|
categoriesValues = await this.getFlatArrDecompressed(
|
|
114
|
-
|
|
128
|
+
`${path}/categories`,
|
|
115
129
|
);
|
|
116
130
|
}
|
|
117
|
-
codesPath =
|
|
131
|
+
codesPath = `${path}/codes`;
|
|
132
|
+
} else if (encodingType === 'string-array') {
|
|
133
|
+
return this.getFlatArrDecompressed(path);
|
|
118
134
|
} else {
|
|
119
135
|
const { dtype } = await zarrOpen(
|
|
120
|
-
storeRoot.resolve(
|
|
136
|
+
storeRoot.resolve(path),
|
|
121
137
|
{ kind: 'array' },
|
|
122
138
|
);
|
|
123
|
-
if (dtype === 'v2:object') {
|
|
139
|
+
if (dtype === 'v2:object' || dtype === '|O') {
|
|
124
140
|
return this.getFlatArrDecompressed(path);
|
|
125
141
|
}
|
|
126
142
|
}
|
|
@@ -202,7 +218,7 @@ export default class AnnDataSource extends ZarrDataSource {
|
|
|
202
218
|
return this.obsIndex;
|
|
203
219
|
}
|
|
204
220
|
this.obsIndex = this.getJson('obs/.zattrs')
|
|
205
|
-
.then(({ _index }) => this.
|
|
221
|
+
.then(({ _index }) => this._loadColumn(`/obs/${_index}`));
|
|
206
222
|
return this.obsIndex;
|
|
207
223
|
}
|
|
208
224
|
|
|
@@ -218,7 +234,7 @@ export default class AnnDataSource extends ZarrDataSource {
|
|
|
218
234
|
) {
|
|
219
235
|
const dfPath = path ? dirname(path) : '';
|
|
220
236
|
return this.getJson(`${dfPath}/.zattrs`)
|
|
221
|
-
.then(({ _index }) => this.
|
|
237
|
+
.then(({ _index }) => this._loadColumn(`${dfPath.length > 0 ? '/' : ''}${dfPath}/${_index}`));
|
|
222
238
|
}
|
|
223
239
|
|
|
224
240
|
/**
|
|
@@ -234,7 +250,7 @@ export default class AnnDataSource extends ZarrDataSource {
|
|
|
234
250
|
return this.varIndex;
|
|
235
251
|
}
|
|
236
252
|
this.varIndex = this.getJson('var/.zattrs')
|
|
237
|
-
.then(({ _index }) => this.
|
|
253
|
+
.then(({ _index }) => this._loadColumn(`/var/${_index}`));
|
|
238
254
|
return this.varIndex;
|
|
239
255
|
}
|
|
240
256
|
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
/* eslint-disable no-underscore-dangle */
|
|
2
2
|
/* eslint-disable camelcase */
|
|
3
3
|
import { LoaderResult, AbstractTwoStepLoader } from '@vitessce/abstract';
|
|
4
|
+
import { getDebugMode } from '@vitessce/globals';
|
|
4
5
|
import { isEqual } from 'lodash-es';
|
|
5
6
|
import { isEqualPathPair, loadComparisonMetadata } from './comparative-utils.js';
|
|
6
7
|
|
|
@@ -50,9 +51,23 @@ export default class FeatureStatsAnndataLoader extends AbstractTwoStepLoader {
|
|
|
50
51
|
this.loadFeatureSetTerms(dfPath),
|
|
51
52
|
this.loadSignificances(dfPath),
|
|
52
53
|
]);
|
|
54
|
+
|
|
55
|
+
// TODO: this is temporary until KPMP data has been re-processed.
|
|
56
|
+
const cleanName = (s) => {
|
|
57
|
+
if (s.includes('R-HSA-')) {
|
|
58
|
+
return s.substring(0, s.indexOf('R-HSA-') - 1);
|
|
59
|
+
}
|
|
60
|
+
return s;
|
|
61
|
+
};
|
|
62
|
+
const cleanTerm = (s) => {
|
|
63
|
+
if (s.includes('R-HSA-')) {
|
|
64
|
+
return `REACTOME:${s.substring(s.indexOf('R-HSA-'))}`;
|
|
65
|
+
}
|
|
66
|
+
return s;
|
|
67
|
+
};
|
|
53
68
|
return {
|
|
54
|
-
featureSetName,
|
|
55
|
-
featureSetTerm,
|
|
69
|
+
featureSetName: featureSetName.map(s => cleanName(s)),
|
|
70
|
+
featureSetTerm: featureSetTerm.map(s => cleanTerm(s)),
|
|
56
71
|
featureSetSignificance,
|
|
57
72
|
};
|
|
58
73
|
}
|
|
@@ -84,7 +99,10 @@ export default class FeatureStatsAnndataLoader extends AbstractTwoStepLoader {
|
|
|
84
99
|
* @returns {Promise<LoaderResult<FeatureStatsData>>}
|
|
85
100
|
*/
|
|
86
101
|
async loadMulti(volcanoOptions) {
|
|
87
|
-
const {
|
|
102
|
+
const {
|
|
103
|
+
analysisType: targetAnalysisType = 'pertpy_hypergeometric',
|
|
104
|
+
featureSetLibrary: targetFeatureSetLibrary = 'Reactome_2022',
|
|
105
|
+
} = this.options;
|
|
88
106
|
const { sampleSetSelection, obsSetSelection } = volcanoOptions || {};
|
|
89
107
|
|
|
90
108
|
// TODO: should this also depend on a "featureSetType" such as "pathway"
|
|
@@ -99,12 +117,18 @@ export default class FeatureStatsAnndataLoader extends AbstractTwoStepLoader {
|
|
|
99
117
|
|
|
100
118
|
if (sampleSetSelection) {
|
|
101
119
|
if (sampleSetSelection.length !== 2) {
|
|
102
|
-
|
|
120
|
+
if (getDebugMode()) {
|
|
121
|
+
return Promise.reject(new Error('Expected exactly two sample sets for volcano plot.'));
|
|
122
|
+
}
|
|
123
|
+
return null;
|
|
103
124
|
}
|
|
104
125
|
}
|
|
105
126
|
|
|
106
127
|
if (!obsSetSelection) {
|
|
107
|
-
|
|
128
|
+
if (getDebugMode()) {
|
|
129
|
+
return Promise.reject(new Error('Expected obsSetSelection to be present.'));
|
|
130
|
+
}
|
|
131
|
+
return null;
|
|
108
132
|
}
|
|
109
133
|
|
|
110
134
|
const metadata = await this.loadMetadata();
|
|
@@ -116,11 +140,16 @@ export default class FeatureStatsAnndataLoader extends AbstractTwoStepLoader {
|
|
|
116
140
|
results.forEach((resultObject) => {
|
|
117
141
|
const {
|
|
118
142
|
analysis_type,
|
|
119
|
-
|
|
143
|
+
analysis_params,
|
|
120
144
|
coordination_values,
|
|
121
145
|
// path,
|
|
122
146
|
} = resultObject;
|
|
123
|
-
if (
|
|
147
|
+
if (
|
|
148
|
+
analysis_type === targetAnalysisType
|
|
149
|
+
&& (analysis_params
|
|
150
|
+
?.pertpy_hypergeometric
|
|
151
|
+
?.enrichr_library_name === targetFeatureSetLibrary)
|
|
152
|
+
) {
|
|
124
153
|
// This is a diff. exp. result.
|
|
125
154
|
if (sampleSetSelection) {
|
|
126
155
|
// Comparing two sample groups.
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
/* eslint-disable no-underscore-dangle */
|
|
2
2
|
/* eslint-disable camelcase */
|
|
3
3
|
import { LoaderResult, AbstractTwoStepLoader } from '@vitessce/abstract';
|
|
4
|
+
import { getDebugMode } from '@vitessce/globals';
|
|
4
5
|
import { isEqual } from 'lodash-es';
|
|
5
6
|
import { isEqualPathPair, loadComparisonMetadata } from './comparative-utils.js';
|
|
6
7
|
|
|
@@ -112,12 +113,18 @@ export default class FeatureStatsAnndataLoader extends AbstractTwoStepLoader {
|
|
|
112
113
|
|
|
113
114
|
if (sampleSetSelection) {
|
|
114
115
|
if (sampleSetSelection.length !== 2) {
|
|
115
|
-
|
|
116
|
+
if (getDebugMode()) {
|
|
117
|
+
return Promise.reject(new Error('Expected exactly two sample sets for volcano plot.'));
|
|
118
|
+
}
|
|
119
|
+
return null;
|
|
116
120
|
}
|
|
117
121
|
}
|
|
118
122
|
|
|
119
123
|
if (!obsSetSelection) {
|
|
120
|
-
|
|
124
|
+
if (getDebugMode()) {
|
|
125
|
+
return Promise.reject(new Error('Expected obsSetSelection to be present.'));
|
|
126
|
+
}
|
|
127
|
+
return null;
|
|
121
128
|
}
|
|
122
129
|
|
|
123
130
|
const metadata = await this.loadMetadata();
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
/* eslint-disable no-underscore-dangle */
|
|
2
2
|
/* eslint-disable camelcase */
|
|
3
3
|
import { LoaderResult, AbstractTwoStepLoader } from '@vitessce/abstract';
|
|
4
|
+
import { getDebugMode } from '@vitessce/globals';
|
|
4
5
|
import { isEqual } from 'lodash-es';
|
|
5
6
|
import { isEqualPathPair, loadComparisonMetadata } from './comparative-utils.js';
|
|
6
7
|
|
|
@@ -66,11 +67,6 @@ export default class ObsSetStatsAnndataLoader extends AbstractTwoStepLoader {
|
|
|
66
67
|
return values.data;
|
|
67
68
|
}
|
|
68
69
|
|
|
69
|
-
async loadCovariate(dfPath) {
|
|
70
|
-
const { covariateColumn } = this.options;
|
|
71
|
-
return this.dataSource._loadColumn(`${dfPath}/${covariateColumn}`);
|
|
72
|
-
}
|
|
73
|
-
|
|
74
70
|
async loadObsSetNames(dfPath) {
|
|
75
71
|
const { indexColumn } = this.options;
|
|
76
72
|
if (indexColumn) {
|
|
@@ -90,16 +86,12 @@ export default class ObsSetStatsAnndataLoader extends AbstractTwoStepLoader {
|
|
|
90
86
|
// TODO: rather than passing this down,
|
|
91
87
|
// do the fold change direction swapping in the loader
|
|
92
88
|
// (as opposed to in the view).
|
|
93
|
-
// TODO: also, see https://github.com/keller-mark/compasce/issues/30
|
|
94
|
-
// which would allow not loading this column altogether.
|
|
95
|
-
covariate,
|
|
96
89
|
] = await Promise.all([
|
|
97
90
|
this.loadObsSetNames(dfPath),
|
|
98
91
|
this.loadFoldChanges(dfPath),
|
|
99
92
|
this.loadInterceptValues(dfPath),
|
|
100
93
|
this.loadEffectValues(dfPath),
|
|
101
94
|
this.loadIsCredible(dfPath),
|
|
102
|
-
this.loadCovariate(dfPath),
|
|
103
95
|
]);
|
|
104
96
|
return {
|
|
105
97
|
obsSetId,
|
|
@@ -107,7 +99,6 @@ export default class ObsSetStatsAnndataLoader extends AbstractTwoStepLoader {
|
|
|
107
99
|
interceptExpectedSample,
|
|
108
100
|
effectExpectedSample,
|
|
109
101
|
isCredibleEffect,
|
|
110
|
-
covariate,
|
|
111
102
|
};
|
|
112
103
|
}
|
|
113
104
|
|
|
@@ -149,11 +140,17 @@ export default class ObsSetStatsAnndataLoader extends AbstractTwoStepLoader {
|
|
|
149
140
|
const rawSampleSetSelection = sampleSetSelection;
|
|
150
141
|
|
|
151
142
|
if (!sampleSetSelection || sampleSetSelection?.length !== 2) {
|
|
152
|
-
|
|
143
|
+
if (getDebugMode()) {
|
|
144
|
+
return Promise.reject(new Error('Expected exactly two sample sets for cell type composition analysis plot.'));
|
|
145
|
+
}
|
|
146
|
+
return null;
|
|
153
147
|
}
|
|
154
148
|
|
|
155
149
|
if (!obsSetSelection) {
|
|
156
|
-
|
|
150
|
+
if (getDebugMode()) {
|
|
151
|
+
return Promise.reject(new Error('Expected obsSetSelection to be present.'));
|
|
152
|
+
}
|
|
153
|
+
return null;
|
|
157
154
|
}
|
|
158
155
|
|
|
159
156
|
const metadata = await this.loadMetadata();
|
|
@@ -12,6 +12,13 @@ import {
|
|
|
12
12
|
* Loader for converting zarr into the cell sets json schema.
|
|
13
13
|
*/
|
|
14
14
|
export default class ObsSetsAnndataLoader extends AbstractTwoStepLoader {
|
|
15
|
+
constructor(dataSource, params) {
|
|
16
|
+
super(dataSource, params);
|
|
17
|
+
// These are used by the subclass SpatialDataObsSetsLoader.
|
|
18
|
+
this.region = null;
|
|
19
|
+
this.tablePath = null;
|
|
20
|
+
}
|
|
21
|
+
|
|
15
22
|
loadObsIndices() {
|
|
16
23
|
const { options } = this;
|
|
17
24
|
const obsIndexPromises = options
|
|
@@ -52,7 +59,7 @@ export default class ObsSetsAnndataLoader extends AbstractTwoStepLoader {
|
|
|
52
59
|
if (!this.cachedResult) {
|
|
53
60
|
const { options } = this;
|
|
54
61
|
this.cachedResult = Promise.all([
|
|
55
|
-
this.dataSource.loadObsIndex(),
|
|
62
|
+
this.dataSource.loadObsIndex(this.tablePath),
|
|
56
63
|
this.loadObsIndices(),
|
|
57
64
|
this.loadCellSetIds(),
|
|
58
65
|
this.loadCellSetScores(),
|