@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.
- package/dist/index.js +1056 -171
- package/dist/zstd-561fda0e.js +778 -0
- package/dist-tsc/AnnDataSource.d.ts +10 -4
- package/dist-tsc/AnnDataSource.d.ts.map +1 -1
- package/dist-tsc/AnnDataSource.js +16 -3
- package/dist-tsc/ZarrDataSource.d.ts +3 -4
- package/dist-tsc/ZarrDataSource.d.ts.map +1 -1
- package/dist-tsc/ZarrDataSource.js +1 -2
- package/dist-tsc/anndata-loaders/ComparisonMetadataAnndataLoader.d.ts +20 -0
- package/dist-tsc/anndata-loaders/ComparisonMetadataAnndataLoader.d.ts.map +1 -0
- package/dist-tsc/anndata-loaders/ComparisonMetadataAnndataLoader.js +29 -0
- package/dist-tsc/anndata-loaders/FeatureSetStatsAnndataLoader.d.ts +49 -0
- package/dist-tsc/anndata-loaders/FeatureSetStatsAnndataLoader.d.ts.map +1 -0
- package/dist-tsc/anndata-loaders/FeatureSetStatsAnndataLoader.js +143 -0
- package/dist-tsc/anndata-loaders/FeatureStatsAnndataLoader.d.ts +53 -0
- package/dist-tsc/anndata-loaders/FeatureStatsAnndataLoader.d.ts.map +1 -0
- package/dist-tsc/anndata-loaders/FeatureStatsAnndataLoader.js +157 -0
- package/dist-tsc/anndata-loaders/ObsSetStatsAnndataLoader.d.ts +66 -0
- package/dist-tsc/anndata-loaders/ObsSetStatsAnndataLoader.d.ts.map +1 -0
- package/dist-tsc/anndata-loaders/ObsSetStatsAnndataLoader.js +183 -0
- package/dist-tsc/anndata-loaders/SampleSetsAnndataLoader.d.ts +18 -0
- package/dist-tsc/anndata-loaders/SampleSetsAnndataLoader.d.ts.map +1 -0
- package/dist-tsc/anndata-loaders/SampleSetsAnndataLoader.js +75 -0
- package/dist-tsc/anndata-loaders/comparative-utils.d.ts +19 -0
- package/dist-tsc/anndata-loaders/comparative-utils.d.ts.map +1 -0
- package/dist-tsc/anndata-loaders/comparative-utils.js +30 -0
- package/dist-tsc/anndata-loaders/index.d.ts +5 -0
- package/dist-tsc/anndata-loaders/index.js +5 -0
- package/dist-tsc/utils.js +2 -1
- package/package.json +11 -13
- package/src/AnnDataSource.js +18 -4
- package/src/ZarrDataSource.js +1 -2
- package/src/anndata-loaders/ComparisonMetadataAnndataLoader.js +34 -0
- package/src/anndata-loaders/FeatureSetStatsAnndataLoader.js +164 -0
- package/src/anndata-loaders/FeatureStatsAnndataLoader.js +177 -0
- package/src/anndata-loaders/ObsSetStatsAnndataLoader.js +211 -0
- package/src/anndata-loaders/SampleSetsAnndataLoader.js +88 -0
- package/src/anndata-loaders/comparative-utils.js +35 -0
- package/src/anndata-loaders/index.js +5 -0
- package/src/utils.js +2 -2
- package/dist/zstd-ec5a40b8.js +0 -808
package/dist/index.js
CHANGED
|
@@ -26,7 +26,7 @@ var __privateMethod = (obj, member, method) => {
|
|
|
26
26
|
__accessCheck(obj, member, "access private method");
|
|
27
27
|
return method;
|
|
28
28
|
};
|
|
29
|
-
var _bytes, _encoder, _data,
|
|
29
|
+
var _bytes, _encoder, _data, _stride, _TypedArray, _BYTES_PER_ELEMENT, _shape, _endian, _encoder_config, _decoder_config, _order, _inverseOrder, _shape2, _strides, _metadata, _metadata2, _a, _b, _overrides, _use_suffix_request, _merge_init, merge_init_fn, _overrides2, _refs, _opts, _overrides3;
|
|
30
30
|
class NodeNotFoundError extends Error {
|
|
31
31
|
constructor(context, options = {}) {
|
|
32
32
|
super(`Node not found: ${context}`, options);
|
|
@@ -59,11 +59,9 @@ class BoolArray {
|
|
|
59
59
|
get byteLength() {
|
|
60
60
|
return __privateGet(this, _bytes).byteLength;
|
|
61
61
|
}
|
|
62
|
-
/** @type {ArrayBuffer} */
|
|
63
62
|
get buffer() {
|
|
64
63
|
return __privateGet(this, _bytes).buffer;
|
|
65
64
|
}
|
|
66
|
-
/** @type {number} */
|
|
67
65
|
get length() {
|
|
68
66
|
return __privateGet(this, _bytes).length;
|
|
69
67
|
}
|
|
@@ -114,11 +112,9 @@ class ByteStringArray {
|
|
|
114
112
|
get byteLength() {
|
|
115
113
|
return this._data.byteLength;
|
|
116
114
|
}
|
|
117
|
-
/** @type {ArrayBuffer} */
|
|
118
115
|
get buffer() {
|
|
119
116
|
return this._data.buffer;
|
|
120
117
|
}
|
|
121
|
-
/** @type {number} */
|
|
122
118
|
get length() {
|
|
123
119
|
return this.byteLength / this.BYTES_PER_ELEMENT;
|
|
124
120
|
}
|
|
@@ -175,11 +171,9 @@ const _UnicodeStringArray = class {
|
|
|
175
171
|
get byteOffset() {
|
|
176
172
|
return __privateGet(this, _data).byteOffset;
|
|
177
173
|
}
|
|
178
|
-
/** @type {ArrayBuffer} */
|
|
179
174
|
get buffer() {
|
|
180
175
|
return __privateGet(this, _data).buffer;
|
|
181
176
|
}
|
|
182
|
-
/** @type {number} */
|
|
183
177
|
get length() {
|
|
184
178
|
return __privateGet(this, _data).length / this.chars;
|
|
185
179
|
}
|
|
@@ -230,53 +224,43 @@ function byteswap_inplace(view, bytes_per_element2) {
|
|
|
230
224
|
}
|
|
231
225
|
}
|
|
232
226
|
}
|
|
233
|
-
const CONSTRUCTORS = {
|
|
234
|
-
int8: Int8Array,
|
|
235
|
-
int16: Int16Array,
|
|
236
|
-
int32: Int32Array,
|
|
237
|
-
int64: globalThis.BigInt64Array,
|
|
238
|
-
uint8: Uint8Array,
|
|
239
|
-
uint16: Uint16Array,
|
|
240
|
-
uint32: Uint32Array,
|
|
241
|
-
uint64: globalThis.BigUint64Array,
|
|
242
|
-
float32: Float32Array,
|
|
243
|
-
float64: Float64Array,
|
|
244
|
-
bool: BoolArray
|
|
245
|
-
};
|
|
246
|
-
const V2_STRING_REGEX = /v2:([US])(\d+)/;
|
|
247
227
|
function get_ctr(data_type) {
|
|
248
228
|
if (data_type === "v2:object") {
|
|
249
229
|
return globalThis.Array;
|
|
250
230
|
}
|
|
251
|
-
let match = data_type.match(
|
|
231
|
+
let match = data_type.match(/v2:([US])(\d+)/);
|
|
252
232
|
if (match) {
|
|
253
233
|
let [, kind, chars] = match;
|
|
254
234
|
return (kind === "U" ? UnicodeStringArray : ByteStringArray).bind(null, Number(chars));
|
|
255
235
|
}
|
|
256
|
-
let ctr =
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
236
|
+
let ctr = {
|
|
237
|
+
int8: Int8Array,
|
|
238
|
+
int16: Int16Array,
|
|
239
|
+
int32: Int32Array,
|
|
240
|
+
int64: globalThis.BigInt64Array,
|
|
241
|
+
uint8: Uint8Array,
|
|
242
|
+
uint16: Uint16Array,
|
|
243
|
+
uint32: Uint32Array,
|
|
244
|
+
uint64: globalThis.BigUint64Array,
|
|
245
|
+
float16: globalThis.Float16Array,
|
|
246
|
+
float32: Float32Array,
|
|
247
|
+
float64: Float64Array,
|
|
248
|
+
bool: BoolArray
|
|
249
|
+
}[data_type];
|
|
250
|
+
assert$1(ctr, `Unknown or unsupported data_type: ${data_type}`);
|
|
260
251
|
return ctr;
|
|
261
252
|
}
|
|
262
253
|
function get_strides(shape, order) {
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
const ndim = shape.length;
|
|
267
|
-
const stride = globalThis.Array(ndim);
|
|
268
|
-
for (let i = ndim - 1, step = 1; i >= 0; i--) {
|
|
269
|
-
stride[i] = step;
|
|
270
|
-
step *= shape[i];
|
|
254
|
+
const rank = shape.length;
|
|
255
|
+
if (typeof order === "string") {
|
|
256
|
+
order = order === "C" ? Array.from({ length: rank }, (_, i) => i) : Array.from({ length: rank }, (_, i) => rank - 1 - i);
|
|
271
257
|
}
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
stride[i] = step;
|
|
279
|
-
step *= shape[i];
|
|
258
|
+
assert$1(rank === order.length, "Order length must match the number of dimensions.");
|
|
259
|
+
let step = 1;
|
|
260
|
+
let stride = new Array(rank);
|
|
261
|
+
for (let i = order.length - 1; i >= 0; i--) {
|
|
262
|
+
stride[order[i]] = step;
|
|
263
|
+
step *= shape[order[i]];
|
|
280
264
|
}
|
|
281
265
|
return stride;
|
|
282
266
|
}
|
|
@@ -291,20 +275,12 @@ function create_chunk_key_encoder({ name, configuration }) {
|
|
|
291
275
|
}
|
|
292
276
|
throw new Error(`Unknown chunk key encoding: ${name}`);
|
|
293
277
|
}
|
|
294
|
-
function get_array_order(codecs) {
|
|
295
|
-
var _a2;
|
|
296
|
-
const maybe_transpose_codec = codecs.find((c) => c.name === "transpose");
|
|
297
|
-
return ((_a2 = maybe_transpose_codec == null ? void 0 : maybe_transpose_codec.configuration) == null ? void 0 : _a2.order) === "F" ? "F" : "C";
|
|
298
|
-
}
|
|
299
|
-
const endian_regex = /^([<|>])(.*)$/;
|
|
300
278
|
function coerce_dtype(dtype) {
|
|
301
279
|
if (dtype === "|O") {
|
|
302
280
|
return { data_type: "v2:object" };
|
|
303
281
|
}
|
|
304
|
-
let match = dtype.match(
|
|
305
|
-
|
|
306
|
-
throw new Error(`Invalid dtype: ${dtype}`);
|
|
307
|
-
}
|
|
282
|
+
let match = dtype.match(/^([<|>])(.*)$/);
|
|
283
|
+
assert$1(match, `Invalid dtype: ${dtype}`);
|
|
308
284
|
let [, endian, rest] = match;
|
|
309
285
|
let data_type = {
|
|
310
286
|
b1: "bool",
|
|
@@ -316,12 +292,11 @@ function coerce_dtype(dtype) {
|
|
|
316
292
|
u4: "uint32",
|
|
317
293
|
i8: "int64",
|
|
318
294
|
u8: "uint64",
|
|
295
|
+
f2: "float16",
|
|
319
296
|
f4: "float32",
|
|
320
297
|
f8: "float64"
|
|
321
298
|
}[rest] ?? (rest.startsWith("S") || rest.startsWith("U") ? `v2:${rest}` : void 0);
|
|
322
|
-
|
|
323
|
-
throw new Error(`Unsupported or unknown dtype: ${dtype}`);
|
|
324
|
-
}
|
|
299
|
+
assert$1(data_type, `Unsupported or unknown dtype: ${dtype}`);
|
|
325
300
|
if (endian === "|") {
|
|
326
301
|
return { data_type };
|
|
327
302
|
}
|
|
@@ -399,6 +374,40 @@ function ensure_correct_scalar(metadata) {
|
|
|
399
374
|
}
|
|
400
375
|
return metadata.fill_value;
|
|
401
376
|
}
|
|
377
|
+
function rethrow_unless(error, ...errors) {
|
|
378
|
+
if (!errors.some((ErrorClass) => error instanceof ErrorClass)) {
|
|
379
|
+
throw error;
|
|
380
|
+
}
|
|
381
|
+
}
|
|
382
|
+
function assert$1(expression, msg = "") {
|
|
383
|
+
if (!expression) {
|
|
384
|
+
throw new Error(msg);
|
|
385
|
+
}
|
|
386
|
+
}
|
|
387
|
+
class BitroundCodec {
|
|
388
|
+
constructor(configuration, _meta) {
|
|
389
|
+
__publicField(this, "kind", "array_to_array");
|
|
390
|
+
assert$1(configuration.keepbits >= 0, "keepbits must be zero or positive");
|
|
391
|
+
}
|
|
392
|
+
static fromConfig(configuration, meta) {
|
|
393
|
+
return new BitroundCodec(configuration, meta);
|
|
394
|
+
}
|
|
395
|
+
/**
|
|
396
|
+
* Encode a chunk of data with bit-rounding.
|
|
397
|
+
* @param _arr - The chunk to encode
|
|
398
|
+
*/
|
|
399
|
+
encode(_arr) {
|
|
400
|
+
throw new Error("`BitroundCodec.encode` is not implemented. Please open an issue at https://github.com/manzt/zarrita.js/issues.");
|
|
401
|
+
}
|
|
402
|
+
/**
|
|
403
|
+
* Decode a chunk of data (no-op).
|
|
404
|
+
* @param arr - The chunk to decode
|
|
405
|
+
* @returns The decoded chunk
|
|
406
|
+
*/
|
|
407
|
+
decode(arr) {
|
|
408
|
+
return arr;
|
|
409
|
+
}
|
|
410
|
+
}
|
|
402
411
|
const LITTLE_ENDIAN_OS = system_is_little_endian();
|
|
403
412
|
function system_is_little_endian() {
|
|
404
413
|
const a = new Uint32Array([305419896]);
|
|
@@ -414,7 +423,7 @@ function bytes_per_element(TypedArray) {
|
|
|
414
423
|
const _BytesCodec = class {
|
|
415
424
|
constructor(configuration, meta) {
|
|
416
425
|
__publicField(this, "kind", "array_to_bytes");
|
|
417
|
-
__privateAdd(this,
|
|
426
|
+
__privateAdd(this, _stride, void 0);
|
|
418
427
|
__privateAdd(this, _TypedArray, void 0);
|
|
419
428
|
__privateAdd(this, _BYTES_PER_ELEMENT, void 0);
|
|
420
429
|
__privateAdd(this, _shape, void 0);
|
|
@@ -422,7 +431,7 @@ const _BytesCodec = class {
|
|
|
422
431
|
__privateSet(this, _endian, configuration == null ? void 0 : configuration.endian);
|
|
423
432
|
__privateSet(this, _TypedArray, get_ctr(meta.data_type));
|
|
424
433
|
__privateSet(this, _shape, meta.shape);
|
|
425
|
-
__privateSet(this,
|
|
434
|
+
__privateSet(this, _stride, get_strides(meta.shape, "C"));
|
|
426
435
|
const sample = new (__privateGet(this, _TypedArray))(0);
|
|
427
436
|
__privateSet(this, _BYTES_PER_ELEMENT, sample.BYTES_PER_ELEMENT);
|
|
428
437
|
}
|
|
@@ -443,12 +452,12 @@ const _BytesCodec = class {
|
|
|
443
452
|
return {
|
|
444
453
|
data: new (__privateGet(this, _TypedArray))(bytes.buffer, bytes.byteOffset, bytes.byteLength / __privateGet(this, _BYTES_PER_ELEMENT)),
|
|
445
454
|
shape: __privateGet(this, _shape),
|
|
446
|
-
stride: __privateGet(this,
|
|
455
|
+
stride: __privateGet(this, _stride)
|
|
447
456
|
};
|
|
448
457
|
}
|
|
449
458
|
};
|
|
450
459
|
let BytesCodec = _BytesCodec;
|
|
451
|
-
|
|
460
|
+
_stride = new WeakMap();
|
|
452
461
|
_TypedArray = new WeakMap();
|
|
453
462
|
_BYTES_PER_ELEMENT = new WeakMap();
|
|
454
463
|
_shape = new WeakMap();
|
|
@@ -468,15 +477,9 @@ class Crc32cCodec {
|
|
|
468
477
|
}
|
|
469
478
|
}
|
|
470
479
|
function throw_on_nan_replacer(_key, value) {
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
if (value === Number.POSITIVE_INFINITY) {
|
|
475
|
-
throw new Error("JsonCodec allow_nan is false but Infinity was encountered during encoding.");
|
|
476
|
-
}
|
|
477
|
-
if (value === Number.NEGATIVE_INFINITY) {
|
|
478
|
-
throw new Error("JsonCodec allow_nan is false but -Infinity was encountered during encoding.");
|
|
479
|
-
}
|
|
480
|
+
assert$1(!Number.isNaN(value), "JsonCodec allow_nan is false but NaN was encountered during encoding.");
|
|
481
|
+
assert$1(value !== Number.POSITIVE_INFINITY, "JsonCodec allow_nan is false but Infinity was encountered during encoding.");
|
|
482
|
+
assert$1(value !== Number.NEGATIVE_INFINITY, "JsonCodec allow_nan is false but -Infinity was encountered during encoding.");
|
|
480
483
|
return value;
|
|
481
484
|
}
|
|
482
485
|
function sort_keys_replacer(_key, value) {
|
|
@@ -518,13 +521,9 @@ const _JsonCodec = class {
|
|
|
518
521
|
}
|
|
519
522
|
encode(buf) {
|
|
520
523
|
const { indent, encoding, ensure_ascii, check_circular, allow_nan, sort_keys } = __privateGet(this, _encoder_config);
|
|
521
|
-
|
|
522
|
-
throw new Error("JsonCodec does not yet support non-utf-8 encoding.");
|
|
523
|
-
}
|
|
524
|
+
assert$1(encoding === "utf-8", "JsonCodec does not yet support non-utf-8 encoding.");
|
|
524
525
|
const replacer_functions = [];
|
|
525
|
-
|
|
526
|
-
throw new Error("JsonCodec does not yet support skipping the check for circular references during encoding.");
|
|
527
|
-
}
|
|
526
|
+
assert$1(check_circular, "JsonCodec does not yet support skipping the check for circular references during encoding.");
|
|
528
527
|
if (!allow_nan) {
|
|
529
528
|
replacer_functions.push(throw_on_nan_replacer);
|
|
530
529
|
}
|
|
@@ -556,15 +555,11 @@ const _JsonCodec = class {
|
|
|
556
555
|
}
|
|
557
556
|
decode(bytes) {
|
|
558
557
|
const { strict } = __privateGet(this, _decoder_config);
|
|
559
|
-
|
|
560
|
-
throw new Error("JsonCodec does not yet support non-strict decoding.");
|
|
561
|
-
}
|
|
558
|
+
assert$1(strict, "JsonCodec does not yet support non-strict decoding.");
|
|
562
559
|
const items = json_decode_object(bytes);
|
|
563
560
|
const shape = items.pop();
|
|
564
561
|
items.pop();
|
|
565
|
-
|
|
566
|
-
throw new Error("0D not implemented for JsonCodec.");
|
|
567
|
-
}
|
|
562
|
+
assert$1(shape, "0D not implemented for JsonCodec.");
|
|
568
563
|
const stride = get_strides(shape, "C");
|
|
569
564
|
const data = items;
|
|
570
565
|
return { data, shape, stride };
|
|
@@ -631,39 +626,72 @@ function convert_array_order(src, target) {
|
|
|
631
626
|
}
|
|
632
627
|
return out;
|
|
633
628
|
}
|
|
634
|
-
function get_order(
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
return arr.stride.every((s, i) => s === row_major_strides[i]) ? "C" : "F";
|
|
629
|
+
function get_order(chunk) {
|
|
630
|
+
let rank = chunk.shape.length;
|
|
631
|
+
assert$1(rank === chunk.stride.length, "Shape and stride must have the same length.");
|
|
632
|
+
return chunk.stride.map((s, i) => ({ stride: s, index: i })).sort((a, b) => b.stride - a.stride).map((entry) => entry.index);
|
|
639
633
|
}
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
634
|
+
function matches_order(chunk, target) {
|
|
635
|
+
let source = get_order(chunk);
|
|
636
|
+
assert$1(source.length === target.length, "Orders must match");
|
|
637
|
+
return source.every((dim, i) => dim === target[i]);
|
|
638
|
+
}
|
|
639
|
+
const _TransposeCodec = class {
|
|
640
|
+
constructor(configuration, meta) {
|
|
643
641
|
__publicField(this, "kind", "array_to_array");
|
|
644
|
-
this
|
|
642
|
+
__privateAdd(this, _order, void 0);
|
|
643
|
+
__privateAdd(this, _inverseOrder, void 0);
|
|
644
|
+
let value = configuration.order ?? "C";
|
|
645
|
+
let rank = meta.shape.length;
|
|
646
|
+
let order = new Array(rank);
|
|
647
|
+
let inverseOrder = new Array(rank);
|
|
648
|
+
if (value === "C") {
|
|
649
|
+
for (let i = 0; i < rank; ++i) {
|
|
650
|
+
order[i] = i;
|
|
651
|
+
inverseOrder[i] = i;
|
|
652
|
+
}
|
|
653
|
+
} else if (value === "F") {
|
|
654
|
+
for (let i = 0; i < rank; ++i) {
|
|
655
|
+
order[i] = rank - i - 1;
|
|
656
|
+
inverseOrder[i] = rank - i - 1;
|
|
657
|
+
}
|
|
658
|
+
} else {
|
|
659
|
+
order = value;
|
|
660
|
+
order.forEach((x, i) => {
|
|
661
|
+
assert$1(inverseOrder[x] === void 0, `Invalid permutation: ${JSON.stringify(value)}`);
|
|
662
|
+
inverseOrder[x] = i;
|
|
663
|
+
});
|
|
664
|
+
}
|
|
665
|
+
__privateSet(this, _order, order);
|
|
666
|
+
__privateSet(this, _inverseOrder, inverseOrder);
|
|
645
667
|
}
|
|
646
|
-
static fromConfig(configuration) {
|
|
647
|
-
return new
|
|
668
|
+
static fromConfig(configuration, meta) {
|
|
669
|
+
return new _TransposeCodec(configuration, meta);
|
|
648
670
|
}
|
|
649
671
|
encode(arr) {
|
|
650
|
-
|
|
651
|
-
if (get_order(arr) === ((_a2 = this.configuration) == null ? void 0 : _a2.order)) {
|
|
672
|
+
if (matches_order(arr, __privateGet(this, _inverseOrder))) {
|
|
652
673
|
return arr;
|
|
653
674
|
}
|
|
654
|
-
return convert_array_order(arr, (
|
|
675
|
+
return convert_array_order(arr, __privateGet(this, _inverseOrder));
|
|
655
676
|
}
|
|
656
677
|
decode(arr) {
|
|
657
|
-
return
|
|
678
|
+
return {
|
|
679
|
+
data: arr.data,
|
|
680
|
+
shape: arr.shape,
|
|
681
|
+
stride: get_strides(arr.shape, __privateGet(this, _order))
|
|
682
|
+
};
|
|
658
683
|
}
|
|
659
|
-
}
|
|
684
|
+
};
|
|
685
|
+
let TransposeCodec = _TransposeCodec;
|
|
686
|
+
_order = new WeakMap();
|
|
687
|
+
_inverseOrder = new WeakMap();
|
|
660
688
|
const _VLenUTF8 = class {
|
|
661
689
|
constructor(shape) {
|
|
662
690
|
__publicField(this, "kind", "array_to_bytes");
|
|
663
691
|
__privateAdd(this, _shape2, void 0);
|
|
664
|
-
__privateAdd(this,
|
|
692
|
+
__privateAdd(this, _strides, void 0);
|
|
665
693
|
__privateSet(this, _shape2, shape);
|
|
666
|
-
__privateSet(this,
|
|
694
|
+
__privateSet(this, _strides, get_strides(shape, "C"));
|
|
667
695
|
}
|
|
668
696
|
static fromConfig(_, meta) {
|
|
669
697
|
return new _VLenUTF8(meta.shape);
|
|
@@ -682,14 +710,14 @@ const _VLenUTF8 = class {
|
|
|
682
710
|
data[i] = decoder.decode(bytes.buffer.slice(pos, pos + item_length));
|
|
683
711
|
pos += item_length;
|
|
684
712
|
}
|
|
685
|
-
return { data, shape: __privateGet(this, _shape2), stride: __privateGet(this,
|
|
713
|
+
return { data, shape: __privateGet(this, _shape2), stride: __privateGet(this, _strides) };
|
|
686
714
|
}
|
|
687
715
|
};
|
|
688
716
|
let VLenUTF8 = _VLenUTF8;
|
|
689
717
|
_shape2 = new WeakMap();
|
|
690
|
-
|
|
718
|
+
_strides = new WeakMap();
|
|
691
719
|
function create_default_registry() {
|
|
692
|
-
return (/* @__PURE__ */ new Map()).set("blosc", () => import("./blosc-537fd004.js").then((m) => m.default)).set("gzip", () => import("./gzip-6a24f0fe.js").then((m) => m.default)).set("lz4", () => import("./lz4-bbd18009.js").then((m) => m.default)).set("zlib", () => import("./zlib-175cd38d.js").then((m) => m.default)).set("zstd", () => import("./zstd-
|
|
720
|
+
return (/* @__PURE__ */ new Map()).set("blosc", () => import("./blosc-537fd004.js").then((m) => m.default)).set("gzip", () => import("./gzip-6a24f0fe.js").then((m) => m.default)).set("lz4", () => import("./lz4-bbd18009.js").then((m) => m.default)).set("zlib", () => import("./zlib-175cd38d.js").then((m) => m.default)).set("zstd", () => import("./zstd-561fda0e.js").then((m) => m.default)).set("transpose", () => TransposeCodec).set("bytes", () => BytesCodec).set("crc32c", () => Crc32cCodec).set("vlen-utf8", () => VLenUTF8).set("json2", () => JsonCodec).set("bitround", () => BitroundCodec);
|
|
693
721
|
}
|
|
694
722
|
const registry = create_default_registry();
|
|
695
723
|
function create_codec_pipeline(chunk_metadata) {
|
|
@@ -725,9 +753,7 @@ async function load_codecs(chunk_meta) {
|
|
|
725
753
|
let promises = chunk_meta.codecs.map(async (meta) => {
|
|
726
754
|
var _a2;
|
|
727
755
|
let Codec = await ((_a2 = registry.get(meta.name)) == null ? void 0 : _a2());
|
|
728
|
-
|
|
729
|
-
throw new Error(`Unknown codec: ${meta.name}`);
|
|
730
|
-
}
|
|
756
|
+
assert$1(Codec, `Unknown codec: ${meta.name}`);
|
|
731
757
|
return { Codec, meta };
|
|
732
758
|
});
|
|
733
759
|
let array_to_array = [];
|
|
@@ -747,9 +773,7 @@ async function load_codecs(chunk_meta) {
|
|
|
747
773
|
}
|
|
748
774
|
}
|
|
749
775
|
if (!array_to_bytes) {
|
|
750
|
-
|
|
751
|
-
throw new Error(`Cannot encode ${chunk_meta.data_type} to bytes without a codec`);
|
|
752
|
-
}
|
|
776
|
+
assert$1(is_typed_array_like_meta(chunk_meta), `Cannot encode ${chunk_meta.data_type} to bytes without a codec`);
|
|
753
777
|
array_to_bytes = BytesCodec.fromConfig({ endian: "little" }, chunk_meta);
|
|
754
778
|
}
|
|
755
779
|
return { array_to_array, array_to_bytes, bytes_to_bytes };
|
|
@@ -759,9 +783,7 @@ function is_typed_array_like_meta(meta) {
|
|
|
759
783
|
}
|
|
760
784
|
const MAX_BIG_UINT = 18446744073709551615n;
|
|
761
785
|
function create_sharded_chunk_getter(location, shard_shape, encode_shard_key, sharding_config) {
|
|
762
|
-
|
|
763
|
-
throw new Error("Store does not support range requests");
|
|
764
|
-
}
|
|
786
|
+
assert$1(location.store.getRange, "Store does not support range requests");
|
|
765
787
|
let get_range = location.store.getRange.bind(location.store);
|
|
766
788
|
let index_shape = shard_shape.map((d, i) => d / sharding_config.chunk_shape[i]);
|
|
767
789
|
let index_codec = create_codec_pipeline({
|
|
@@ -827,6 +849,11 @@ class Group extends Location {
|
|
|
827
849
|
}
|
|
828
850
|
}
|
|
829
851
|
_metadata = new WeakMap();
|
|
852
|
+
function get_array_order(codecs) {
|
|
853
|
+
var _a2;
|
|
854
|
+
const maybe_transpose_codec = codecs.find((c) => c.name === "transpose");
|
|
855
|
+
return ((_a2 = maybe_transpose_codec == null ? void 0 : maybe_transpose_codec.configuration) == null ? void 0 : _a2.order) ?? "C";
|
|
856
|
+
}
|
|
830
857
|
const CONTEXT_MARKER = Symbol("zarrita.context");
|
|
831
858
|
function get_context(obj) {
|
|
832
859
|
return obj[CONTEXT_MARKER];
|
|
@@ -849,8 +876,8 @@ function create_context(location, metadata) {
|
|
|
849
876
|
shape: configuration.chunk_shape,
|
|
850
877
|
codecs: configuration.codecs
|
|
851
878
|
}),
|
|
852
|
-
get_strides(shape
|
|
853
|
-
return get_strides(shape,
|
|
879
|
+
get_strides(shape) {
|
|
880
|
+
return get_strides(shape, native_order2);
|
|
854
881
|
},
|
|
855
882
|
get_chunk_bytes: create_sharded_chunk_getter(location, metadata.chunk_grid.configuration.chunk_shape, shared_context.encode_chunk_key, configuration)
|
|
856
883
|
};
|
|
@@ -865,8 +892,8 @@ function create_context(location, metadata) {
|
|
|
865
892
|
shape: metadata.chunk_grid.configuration.chunk_shape,
|
|
866
893
|
codecs: metadata.codecs
|
|
867
894
|
}),
|
|
868
|
-
get_strides(shape
|
|
869
|
-
return get_strides(shape,
|
|
895
|
+
get_strides(shape) {
|
|
896
|
+
return get_strides(shape, native_order);
|
|
870
897
|
},
|
|
871
898
|
async get_chunk_bytes(chunk_coords, options) {
|
|
872
899
|
let chunk_key = shared_context.encode_chunk_key(chunk_coords);
|
|
@@ -969,9 +996,8 @@ async function open_v2(location, options = {}) {
|
|
|
969
996
|
if (options.kind === "group")
|
|
970
997
|
return open_group_v2(loc, attrs);
|
|
971
998
|
return open_array_v2(loc, attrs).catch((err) => {
|
|
972
|
-
|
|
973
|
-
|
|
974
|
-
throw err;
|
|
999
|
+
rethrow_unless(err, NodeNotFoundError);
|
|
1000
|
+
return open_group_v2(loc, attrs);
|
|
975
1001
|
});
|
|
976
1002
|
}
|
|
977
1003
|
async function open_array_v2(location, attrs) {
|
|
@@ -1029,10 +1055,8 @@ async function open(location, options = {}) {
|
|
|
1029
1055
|
let open_primary = version_max === "v2" ? open.v2 : open.v3;
|
|
1030
1056
|
let open_secondary = version_max === "v2" ? open.v3 : open.v2;
|
|
1031
1057
|
return open_primary(location, options).catch((err) => {
|
|
1032
|
-
|
|
1033
|
-
|
|
1034
|
-
}
|
|
1035
|
-
throw err;
|
|
1058
|
+
rethrow_unless(err, NodeNotFoundError);
|
|
1059
|
+
return open_secondary(location, options);
|
|
1036
1060
|
});
|
|
1037
1061
|
}
|
|
1038
1062
|
open.v2 = open_v2;
|
|
@@ -1270,7 +1294,7 @@ async function get$2(arr, selection, opts2, setter2) {
|
|
|
1270
1294
|
shape: arr.shape,
|
|
1271
1295
|
chunk_shape: arr.chunks
|
|
1272
1296
|
});
|
|
1273
|
-
let out = setter2.prepare(new context.TypedArray(indexer.shape.reduce((a, b) => a * b, 1)), indexer.shape, context.get_strides(indexer.shape
|
|
1297
|
+
let out = setter2.prepare(new context.TypedArray(indexer.shape.reduce((a, b) => a * b, 1)), indexer.shape, context.get_strides(indexer.shape));
|
|
1274
1298
|
let queue = ((_a2 = opts2.create_queue) == null ? void 0 : _a2.call(opts2)) ?? create_queue();
|
|
1275
1299
|
for (const { chunk_coords, mapping } of indexer) {
|
|
1276
1300
|
queue.add(async () => {
|
|
@@ -1468,6 +1492,10 @@ function merge_init(storeOverrides, requestOverrides) {
|
|
|
1468
1492
|
}
|
|
1469
1493
|
};
|
|
1470
1494
|
}
|
|
1495
|
+
function assert(expression, msg = "") {
|
|
1496
|
+
if (!expression)
|
|
1497
|
+
throw new Error(msg);
|
|
1498
|
+
}
|
|
1471
1499
|
function resolve(root2, path) {
|
|
1472
1500
|
const base = typeof root2 === "string" ? new URL(root2) : root2;
|
|
1473
1501
|
if (!base.pathname.endsWith("/")) {
|
|
@@ -1478,7 +1506,7 @@ function resolve(root2, path) {
|
|
|
1478
1506
|
return resolved;
|
|
1479
1507
|
}
|
|
1480
1508
|
async function handle_response(response) {
|
|
1481
|
-
if (response.status === 404
|
|
1509
|
+
if (response.status === 404) {
|
|
1482
1510
|
return void 0;
|
|
1483
1511
|
}
|
|
1484
1512
|
if (response.status === 200 || response.status === 206) {
|
|
@@ -2413,9 +2441,7 @@ class HTTPRangeReader {
|
|
|
2413
2441
|
...__privateGet(this, _overrides2),
|
|
2414
2442
|
method: "HEAD"
|
|
2415
2443
|
});
|
|
2416
|
-
|
|
2417
|
-
throw new Error(`failed http request ${this.url}, status: ${req.status}: ${req.statusText}`);
|
|
2418
|
-
}
|
|
2444
|
+
assert(req.ok, `failed http request ${this.url}, status: ${req.status}: ${req.statusText}`);
|
|
2419
2445
|
this.length = Number(req.headers.get("content-length"));
|
|
2420
2446
|
if (Number.isNaN(this.length)) {
|
|
2421
2447
|
throw Error("could not get length");
|
|
@@ -2428,9 +2454,7 @@ class HTTPRangeReader {
|
|
|
2428
2454
|
return new Uint8Array(0);
|
|
2429
2455
|
}
|
|
2430
2456
|
const req = await fetch_range(this.url, offset, size, __privateGet(this, _overrides2));
|
|
2431
|
-
|
|
2432
|
-
throw new Error(`failed http request ${this.url}, status: ${req.status} offset: ${offset} size: ${size}: ${req.statusText}`);
|
|
2433
|
-
}
|
|
2457
|
+
assert(req.ok, `failed http request ${this.url}, status: ${req.status} offset: ${offset} size: ${size}: ${req.statusText}`);
|
|
2434
2458
|
return new Uint8Array(await req.arrayBuffer());
|
|
2435
2459
|
}
|
|
2436
2460
|
}
|
|
@@ -2720,6 +2744,315 @@ _refs = new WeakMap();
|
|
|
2720
2744
|
_opts = new WeakMap();
|
|
2721
2745
|
_overrides3 = new WeakMap();
|
|
2722
2746
|
const ReferenceStore$1 = ReferenceStore;
|
|
2747
|
+
var commonjsGlobal = typeof globalThis !== "undefined" ? globalThis : typeof window !== "undefined" ? window : typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : {};
|
|
2748
|
+
function getDefaultExportFromCjs(x) {
|
|
2749
|
+
return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, "default") ? x["default"] : x;
|
|
2750
|
+
}
|
|
2751
|
+
function getAugmentedNamespace(n) {
|
|
2752
|
+
if (n.__esModule)
|
|
2753
|
+
return n;
|
|
2754
|
+
var f = n.default;
|
|
2755
|
+
if (typeof f == "function") {
|
|
2756
|
+
var a = function a2() {
|
|
2757
|
+
if (this instanceof a2) {
|
|
2758
|
+
var args = [null];
|
|
2759
|
+
args.push.apply(args, arguments);
|
|
2760
|
+
var Ctor = Function.bind.apply(f, args);
|
|
2761
|
+
return new Ctor();
|
|
2762
|
+
}
|
|
2763
|
+
return f.apply(this, arguments);
|
|
2764
|
+
};
|
|
2765
|
+
a.prototype = f.prototype;
|
|
2766
|
+
} else
|
|
2767
|
+
a = {};
|
|
2768
|
+
Object.defineProperty(a, "__esModule", { value: true });
|
|
2769
|
+
Object.keys(n).forEach(function(k) {
|
|
2770
|
+
var d = Object.getOwnPropertyDescriptor(n, k);
|
|
2771
|
+
Object.defineProperty(a, k, d.get ? d : {
|
|
2772
|
+
enumerable: true,
|
|
2773
|
+
get: function() {
|
|
2774
|
+
return n[k];
|
|
2775
|
+
}
|
|
2776
|
+
});
|
|
2777
|
+
});
|
|
2778
|
+
return a;
|
|
2779
|
+
}
|
|
2780
|
+
var loglevel = { exports: {} };
|
|
2781
|
+
(function(module2) {
|
|
2782
|
+
(function(root2, definition) {
|
|
2783
|
+
if (module2.exports) {
|
|
2784
|
+
module2.exports = definition();
|
|
2785
|
+
} else {
|
|
2786
|
+
root2.log = definition();
|
|
2787
|
+
}
|
|
2788
|
+
})(commonjsGlobal, function() {
|
|
2789
|
+
var noop = function() {
|
|
2790
|
+
};
|
|
2791
|
+
var undefinedType2 = "undefined";
|
|
2792
|
+
var isIE = typeof window !== undefinedType2 && typeof window.navigator !== undefinedType2 && /Trident\/|MSIE /.test(window.navigator.userAgent);
|
|
2793
|
+
var logMethods = [
|
|
2794
|
+
"trace",
|
|
2795
|
+
"debug",
|
|
2796
|
+
"info",
|
|
2797
|
+
"warn",
|
|
2798
|
+
"error"
|
|
2799
|
+
];
|
|
2800
|
+
var _loggersByName = {};
|
|
2801
|
+
var defaultLogger = null;
|
|
2802
|
+
function bindMethod(obj, methodName) {
|
|
2803
|
+
var method = obj[methodName];
|
|
2804
|
+
if (typeof method.bind === "function") {
|
|
2805
|
+
return method.bind(obj);
|
|
2806
|
+
} else {
|
|
2807
|
+
try {
|
|
2808
|
+
return Function.prototype.bind.call(method, obj);
|
|
2809
|
+
} catch (e) {
|
|
2810
|
+
return function() {
|
|
2811
|
+
return Function.prototype.apply.apply(method, [obj, arguments]);
|
|
2812
|
+
};
|
|
2813
|
+
}
|
|
2814
|
+
}
|
|
2815
|
+
}
|
|
2816
|
+
function traceForIE() {
|
|
2817
|
+
if (console.log) {
|
|
2818
|
+
if (console.log.apply) {
|
|
2819
|
+
console.log.apply(console, arguments);
|
|
2820
|
+
} else {
|
|
2821
|
+
Function.prototype.apply.apply(console.log, [console, arguments]);
|
|
2822
|
+
}
|
|
2823
|
+
}
|
|
2824
|
+
if (console.trace)
|
|
2825
|
+
console.trace();
|
|
2826
|
+
}
|
|
2827
|
+
function realMethod(methodName) {
|
|
2828
|
+
if (methodName === "debug") {
|
|
2829
|
+
methodName = "log";
|
|
2830
|
+
}
|
|
2831
|
+
if (typeof console === undefinedType2) {
|
|
2832
|
+
return false;
|
|
2833
|
+
} else if (methodName === "trace" && isIE) {
|
|
2834
|
+
return traceForIE;
|
|
2835
|
+
} else if (console[methodName] !== void 0) {
|
|
2836
|
+
return bindMethod(console, methodName);
|
|
2837
|
+
} else if (console.log !== void 0) {
|
|
2838
|
+
return bindMethod(console, "log");
|
|
2839
|
+
} else {
|
|
2840
|
+
return noop;
|
|
2841
|
+
}
|
|
2842
|
+
}
|
|
2843
|
+
function replaceLoggingMethods() {
|
|
2844
|
+
var level = this.getLevel();
|
|
2845
|
+
for (var i = 0; i < logMethods.length; i++) {
|
|
2846
|
+
var methodName = logMethods[i];
|
|
2847
|
+
this[methodName] = i < level ? noop : this.methodFactory(methodName, level, this.name);
|
|
2848
|
+
}
|
|
2849
|
+
this.log = this.debug;
|
|
2850
|
+
if (typeof console === undefinedType2 && level < this.levels.SILENT) {
|
|
2851
|
+
return "No console available for logging";
|
|
2852
|
+
}
|
|
2853
|
+
}
|
|
2854
|
+
function enableLoggingWhenConsoleArrives(methodName) {
|
|
2855
|
+
return function() {
|
|
2856
|
+
if (typeof console !== undefinedType2) {
|
|
2857
|
+
replaceLoggingMethods.call(this);
|
|
2858
|
+
this[methodName].apply(this, arguments);
|
|
2859
|
+
}
|
|
2860
|
+
};
|
|
2861
|
+
}
|
|
2862
|
+
function defaultMethodFactory(methodName, _level, _loggerName) {
|
|
2863
|
+
return realMethod(methodName) || enableLoggingWhenConsoleArrives.apply(this, arguments);
|
|
2864
|
+
}
|
|
2865
|
+
function Logger(name, factory) {
|
|
2866
|
+
var self2 = this;
|
|
2867
|
+
var inheritedLevel;
|
|
2868
|
+
var defaultLevel;
|
|
2869
|
+
var userLevel;
|
|
2870
|
+
var storageKey = "loglevel";
|
|
2871
|
+
if (typeof name === "string") {
|
|
2872
|
+
storageKey += ":" + name;
|
|
2873
|
+
} else if (typeof name === "symbol") {
|
|
2874
|
+
storageKey = void 0;
|
|
2875
|
+
}
|
|
2876
|
+
function persistLevelIfPossible(levelNum) {
|
|
2877
|
+
var levelName = (logMethods[levelNum] || "silent").toUpperCase();
|
|
2878
|
+
if (typeof window === undefinedType2 || !storageKey)
|
|
2879
|
+
return;
|
|
2880
|
+
try {
|
|
2881
|
+
window.localStorage[storageKey] = levelName;
|
|
2882
|
+
return;
|
|
2883
|
+
} catch (ignore) {
|
|
2884
|
+
}
|
|
2885
|
+
try {
|
|
2886
|
+
window.document.cookie = encodeURIComponent(storageKey) + "=" + levelName + ";";
|
|
2887
|
+
} catch (ignore) {
|
|
2888
|
+
}
|
|
2889
|
+
}
|
|
2890
|
+
function getPersistedLevel() {
|
|
2891
|
+
var storedLevel;
|
|
2892
|
+
if (typeof window === undefinedType2 || !storageKey)
|
|
2893
|
+
return;
|
|
2894
|
+
try {
|
|
2895
|
+
storedLevel = window.localStorage[storageKey];
|
|
2896
|
+
} catch (ignore) {
|
|
2897
|
+
}
|
|
2898
|
+
if (typeof storedLevel === undefinedType2) {
|
|
2899
|
+
try {
|
|
2900
|
+
var cookie = window.document.cookie;
|
|
2901
|
+
var cookieName = encodeURIComponent(storageKey);
|
|
2902
|
+
var location = cookie.indexOf(cookieName + "=");
|
|
2903
|
+
if (location !== -1) {
|
|
2904
|
+
storedLevel = /^([^;]+)/.exec(
|
|
2905
|
+
cookie.slice(location + cookieName.length + 1)
|
|
2906
|
+
)[1];
|
|
2907
|
+
}
|
|
2908
|
+
} catch (ignore) {
|
|
2909
|
+
}
|
|
2910
|
+
}
|
|
2911
|
+
if (self2.levels[storedLevel] === void 0) {
|
|
2912
|
+
storedLevel = void 0;
|
|
2913
|
+
}
|
|
2914
|
+
return storedLevel;
|
|
2915
|
+
}
|
|
2916
|
+
function clearPersistedLevel() {
|
|
2917
|
+
if (typeof window === undefinedType2 || !storageKey)
|
|
2918
|
+
return;
|
|
2919
|
+
try {
|
|
2920
|
+
window.localStorage.removeItem(storageKey);
|
|
2921
|
+
} catch (ignore) {
|
|
2922
|
+
}
|
|
2923
|
+
try {
|
|
2924
|
+
window.document.cookie = encodeURIComponent(storageKey) + "=; expires=Thu, 01 Jan 1970 00:00:00 UTC";
|
|
2925
|
+
} catch (ignore) {
|
|
2926
|
+
}
|
|
2927
|
+
}
|
|
2928
|
+
function normalizeLevel(input) {
|
|
2929
|
+
var level = input;
|
|
2930
|
+
if (typeof level === "string" && self2.levels[level.toUpperCase()] !== void 0) {
|
|
2931
|
+
level = self2.levels[level.toUpperCase()];
|
|
2932
|
+
}
|
|
2933
|
+
if (typeof level === "number" && level >= 0 && level <= self2.levels.SILENT) {
|
|
2934
|
+
return level;
|
|
2935
|
+
} else {
|
|
2936
|
+
throw new TypeError("log.setLevel() called with invalid level: " + input);
|
|
2937
|
+
}
|
|
2938
|
+
}
|
|
2939
|
+
self2.name = name;
|
|
2940
|
+
self2.levels = {
|
|
2941
|
+
"TRACE": 0,
|
|
2942
|
+
"DEBUG": 1,
|
|
2943
|
+
"INFO": 2,
|
|
2944
|
+
"WARN": 3,
|
|
2945
|
+
"ERROR": 4,
|
|
2946
|
+
"SILENT": 5
|
|
2947
|
+
};
|
|
2948
|
+
self2.methodFactory = factory || defaultMethodFactory;
|
|
2949
|
+
self2.getLevel = function() {
|
|
2950
|
+
if (userLevel != null) {
|
|
2951
|
+
return userLevel;
|
|
2952
|
+
} else if (defaultLevel != null) {
|
|
2953
|
+
return defaultLevel;
|
|
2954
|
+
} else {
|
|
2955
|
+
return inheritedLevel;
|
|
2956
|
+
}
|
|
2957
|
+
};
|
|
2958
|
+
self2.setLevel = function(level, persist) {
|
|
2959
|
+
userLevel = normalizeLevel(level);
|
|
2960
|
+
if (persist !== false) {
|
|
2961
|
+
persistLevelIfPossible(userLevel);
|
|
2962
|
+
}
|
|
2963
|
+
return replaceLoggingMethods.call(self2);
|
|
2964
|
+
};
|
|
2965
|
+
self2.setDefaultLevel = function(level) {
|
|
2966
|
+
defaultLevel = normalizeLevel(level);
|
|
2967
|
+
if (!getPersistedLevel()) {
|
|
2968
|
+
self2.setLevel(level, false);
|
|
2969
|
+
}
|
|
2970
|
+
};
|
|
2971
|
+
self2.resetLevel = function() {
|
|
2972
|
+
userLevel = null;
|
|
2973
|
+
clearPersistedLevel();
|
|
2974
|
+
replaceLoggingMethods.call(self2);
|
|
2975
|
+
};
|
|
2976
|
+
self2.enableAll = function(persist) {
|
|
2977
|
+
self2.setLevel(self2.levels.TRACE, persist);
|
|
2978
|
+
};
|
|
2979
|
+
self2.disableAll = function(persist) {
|
|
2980
|
+
self2.setLevel(self2.levels.SILENT, persist);
|
|
2981
|
+
};
|
|
2982
|
+
self2.rebuild = function() {
|
|
2983
|
+
if (defaultLogger !== self2) {
|
|
2984
|
+
inheritedLevel = normalizeLevel(defaultLogger.getLevel());
|
|
2985
|
+
}
|
|
2986
|
+
replaceLoggingMethods.call(self2);
|
|
2987
|
+
if (defaultLogger === self2) {
|
|
2988
|
+
for (var childName in _loggersByName) {
|
|
2989
|
+
_loggersByName[childName].rebuild();
|
|
2990
|
+
}
|
|
2991
|
+
}
|
|
2992
|
+
};
|
|
2993
|
+
inheritedLevel = normalizeLevel(
|
|
2994
|
+
defaultLogger ? defaultLogger.getLevel() : "WARN"
|
|
2995
|
+
);
|
|
2996
|
+
var initialLevel = getPersistedLevel();
|
|
2997
|
+
if (initialLevel != null) {
|
|
2998
|
+
userLevel = normalizeLevel(initialLevel);
|
|
2999
|
+
}
|
|
3000
|
+
replaceLoggingMethods.call(self2);
|
|
3001
|
+
}
|
|
3002
|
+
defaultLogger = new Logger();
|
|
3003
|
+
defaultLogger.getLogger = function getLogger(name) {
|
|
3004
|
+
if (typeof name !== "symbol" && typeof name !== "string" || name === "") {
|
|
3005
|
+
throw new TypeError("You must supply a name when creating a logger.");
|
|
3006
|
+
}
|
|
3007
|
+
var logger = _loggersByName[name];
|
|
3008
|
+
if (!logger) {
|
|
3009
|
+
logger = _loggersByName[name] = new Logger(
|
|
3010
|
+
name,
|
|
3011
|
+
defaultLogger.methodFactory
|
|
3012
|
+
);
|
|
3013
|
+
}
|
|
3014
|
+
return logger;
|
|
3015
|
+
};
|
|
3016
|
+
var _log = typeof window !== undefinedType2 ? window.log : void 0;
|
|
3017
|
+
defaultLogger.noConflict = function() {
|
|
3018
|
+
if (typeof window !== undefinedType2 && window.log === defaultLogger) {
|
|
3019
|
+
window.log = _log;
|
|
3020
|
+
}
|
|
3021
|
+
return defaultLogger;
|
|
3022
|
+
};
|
|
3023
|
+
defaultLogger.getLoggers = function getLoggers() {
|
|
3024
|
+
return _loggersByName;
|
|
3025
|
+
};
|
|
3026
|
+
defaultLogger["default"] = defaultLogger;
|
|
3027
|
+
return defaultLogger;
|
|
3028
|
+
});
|
|
3029
|
+
})(loglevel);
|
|
3030
|
+
var loglevelExports = loglevel.exports;
|
|
3031
|
+
const log = /* @__PURE__ */ getDefaultExportFromCjs(loglevelExports);
|
|
3032
|
+
const DEFAULT_DEBUG_MODE = false;
|
|
3033
|
+
let GLOBAL_DEBUG_MODE = DEFAULT_DEBUG_MODE;
|
|
3034
|
+
function getDebugMode() {
|
|
3035
|
+
return GLOBAL_DEBUG_MODE;
|
|
3036
|
+
}
|
|
3037
|
+
class RelaxedFetchStore extends FetchStore$1 {
|
|
3038
|
+
// This allows returning `undefined` for 403 responses,
|
|
3039
|
+
// as opposed to completely erroring.
|
|
3040
|
+
// Needed due to https://github.com/manzt/zarrita.js/pull/212
|
|
3041
|
+
// In the future, perhaps we could contribute a way to pass a
|
|
3042
|
+
// custom error handling function or additional options
|
|
3043
|
+
// to the zarrita FetchStore so that a subclass is not required.
|
|
3044
|
+
async get(key, options = {}) {
|
|
3045
|
+
var _a2;
|
|
3046
|
+
try {
|
|
3047
|
+
return await super.get(key, options);
|
|
3048
|
+
} catch (e) {
|
|
3049
|
+
if (((_a2 = e == null ? void 0 : e.message) == null ? void 0 : _a2.startsWith("Unexpected response status 403")) && !getDebugMode()) {
|
|
3050
|
+
return void 0;
|
|
3051
|
+
}
|
|
3052
|
+
throw e;
|
|
3053
|
+
}
|
|
3054
|
+
}
|
|
3055
|
+
}
|
|
2723
3056
|
function zarrOpenRoot(url, fileType, opts2) {
|
|
2724
3057
|
let store;
|
|
2725
3058
|
if (fileType && fileType.endsWith(".zip")) {
|
|
@@ -2741,7 +3074,7 @@ function zarrOpenRoot(url, fileType, opts2) {
|
|
|
2741
3074
|
));
|
|
2742
3075
|
store = ReferenceStore$1.fromSpec(referenceSpecPromise, { target: url, overrides: opts2 == null ? void 0 : opts2.requestInit });
|
|
2743
3076
|
} else {
|
|
2744
|
-
store = new
|
|
3077
|
+
store = new RelaxedFetchStore(url, { overrides: opts2 == null ? void 0 : opts2.requestInit });
|
|
2745
3078
|
}
|
|
2746
3079
|
return root$2(store);
|
|
2747
3080
|
}
|
|
@@ -2794,7 +3127,7 @@ function basename(path) {
|
|
|
2794
3127
|
const arr = path.split("/");
|
|
2795
3128
|
const result = arr.at(-1);
|
|
2796
3129
|
if (!result) {
|
|
2797
|
-
|
|
3130
|
+
log.error("basename of path is empty", path);
|
|
2798
3131
|
return "";
|
|
2799
3132
|
}
|
|
2800
3133
|
return result;
|
|
@@ -2987,6 +3320,16 @@ class AnnDataSource extends ZarrDataSource {
|
|
|
2987
3320
|
this.obsIndex = this.getJson("obs/.zattrs").then(({ _index }) => this.getFlatArrDecompressed(`/obs/${_index}`));
|
|
2988
3321
|
return this.obsIndex;
|
|
2989
3322
|
}
|
|
3323
|
+
/**
|
|
3324
|
+
* Class method for loading the obs index.
|
|
3325
|
+
* @param {string|undefined} path Used by subclasses.
|
|
3326
|
+
* @returns {Promise<string[]>} An promise for a zarr array
|
|
3327
|
+
* containing the indices.
|
|
3328
|
+
*/
|
|
3329
|
+
loadDataFrameIndex(path = void 0) {
|
|
3330
|
+
const dfPath = path ? dirname(path) : "";
|
|
3331
|
+
return this.getJson(`${dfPath}/.zattrs`).then(({ _index }) => this.getFlatArrDecompressed(`${dfPath.length > 0 ? "/" : ""}${dfPath}/${_index}`));
|
|
3332
|
+
}
|
|
2990
3333
|
/**
|
|
2991
3334
|
* Class method for loading the var index.
|
|
2992
3335
|
* @param {string|undefined} path Used by subclasses.
|
|
@@ -3104,7 +3447,7 @@ class AnnDataSource extends ZarrDataSource {
|
|
|
3104
3447
|
try {
|
|
3105
3448
|
val = await this._loadElement(`${path}/${key}`);
|
|
3106
3449
|
} catch (e) {
|
|
3107
|
-
|
|
3450
|
+
log.error(`Error in _loadDict: could not load ${key}`);
|
|
3108
3451
|
}
|
|
3109
3452
|
result[key] = val;
|
|
3110
3453
|
}));
|
|
@@ -3697,9 +4040,15 @@ const ViewType$1 = {
|
|
|
3697
4040
|
FEATURE_VALUE_HISTOGRAM: "featureValueHistogram",
|
|
3698
4041
|
DOT_PLOT: "dotPlot",
|
|
3699
4042
|
FEATURE_BAR_PLOT: "featureBarPlot",
|
|
4043
|
+
VOLCANO_PLOT: "volcanoPlot",
|
|
4044
|
+
OBS_SET_COMPOSITION_BAR_PLOT: "obsSetCompositionBarPlot",
|
|
4045
|
+
FEATURE_SET_ENRICHMENT_BAR_PLOT: "featureSetEnrichmentBarPlot",
|
|
3700
4046
|
BIOMARKER_SELECT: "biomarkerSelect",
|
|
4047
|
+
COMPARATIVE_HEADING: "comparativeHeading",
|
|
3701
4048
|
LINK_CONTROLLER: "linkController",
|
|
3702
|
-
|
|
4049
|
+
NEUROGLANCER: "neuroglancer",
|
|
4050
|
+
DUAL_SCATTERPLOT: "dualScatterplot",
|
|
4051
|
+
TREEMAP: "treemap"
|
|
3703
4052
|
};
|
|
3704
4053
|
const DataType$1 = {
|
|
3705
4054
|
OBS_LABELS: "obsLabels",
|
|
@@ -3715,7 +4064,11 @@ const DataType$1 = {
|
|
|
3715
4064
|
OBS_POINTS: "obsPoints",
|
|
3716
4065
|
OBS_LOCATIONS: "obsLocations",
|
|
3717
4066
|
SAMPLE_SETS: "sampleSets",
|
|
3718
|
-
SAMPLE_EDGES: "sampleEdges"
|
|
4067
|
+
SAMPLE_EDGES: "sampleEdges",
|
|
4068
|
+
COMPARISON_METADATA: "comparisonMetadata",
|
|
4069
|
+
FEATURE_STATS: "featureStats",
|
|
4070
|
+
FEATURE_SET_STATS: "featureSetStats",
|
|
4071
|
+
OBS_SET_STATS: "obsSetStats"
|
|
3719
4072
|
};
|
|
3720
4073
|
const FileType$1 = {
|
|
3721
4074
|
// Joint file types
|
|
@@ -3753,6 +4106,11 @@ const FileType$1 = {
|
|
|
3753
4106
|
OBS_LABELS_ANNDATA_ZARR: "obsLabels.anndata.zarr",
|
|
3754
4107
|
FEATURE_LABELS_ANNDATA_ZARR: "featureLabels.anndata.zarr",
|
|
3755
4108
|
SAMPLE_EDGES_ANNDATA_ZARR: "sampleEdges.anndata.zarr",
|
|
4109
|
+
SAMPLE_SETS_ANNDATA_ZARR: "sampleSets.anndata.zarr",
|
|
4110
|
+
COMPARISON_METADATA_ANNDATA_ZARR: "comparisonMetadata.anndata.zarr",
|
|
4111
|
+
COMPARATIVE_FEATURE_STATS_ANNDATA_ZARR: "comparativeFeatureStats.anndata.zarr",
|
|
4112
|
+
COMPARATIVE_FEATURE_SET_STATS_ANNDATA_ZARR: "comparativeFeatureSetStats.anndata.zarr",
|
|
4113
|
+
COMPARATIVE_OBS_SET_STATS_ANNDATA_ZARR: "comparativeObsSetStats.anndata.zarr",
|
|
3756
4114
|
// AnnData - zipped
|
|
3757
4115
|
OBS_FEATURE_MATRIX_ANNDATA_ZARR_ZIP: "obsFeatureMatrix.anndata.zarr.zip",
|
|
3758
4116
|
OBS_FEATURE_COLUMNS_ANNDATA_ZARR_ZIP: "obsFeatureColumns.anndata.zarr.zip",
|
|
@@ -3765,6 +4123,11 @@ const FileType$1 = {
|
|
|
3765
4123
|
OBS_LABELS_ANNDATA_ZARR_ZIP: "obsLabels.anndata.zarr.zip",
|
|
3766
4124
|
FEATURE_LABELS_ANNDATA_ZARR_ZIP: "featureLabels.anndata.zarr.zip",
|
|
3767
4125
|
SAMPLE_EDGES_ANNDATA_ZARR_ZIP: "sampleEdges.anndata.zarr.zip",
|
|
4126
|
+
SAMPLE_SETS_ANNDATA_ZARR_ZIP: "sampleSets.anndata.zarr.zip",
|
|
4127
|
+
COMPARISON_METADATA_ANNDATA_ZARR_ZIP: "comparisonMetadata.anndata.zarr.zip",
|
|
4128
|
+
COMPARATIVE_FEATURE_STATS_ANNDATA_ZARR_ZIP: "comparativeFeatureStats.anndata.zarr.zip",
|
|
4129
|
+
COMPARATIVE_FEATURE_SET_STATS_ANNDATA_ZARR_ZIP: "comparativeFeatureSetStats.anndata.zarr.zip",
|
|
4130
|
+
COMPARATIVE_OBS_SET_STATS_ANNDATA_ZARR_ZIP: "comparativeObsSetStats.anndata.zarr.zip",
|
|
3768
4131
|
// AnnData - h5ad via reference spec
|
|
3769
4132
|
OBS_FEATURE_MATRIX_ANNDATA_H5AD: "obsFeatureMatrix.anndata.h5ad",
|
|
3770
4133
|
OBS_FEATURE_COLUMNS_ANNDATA_H5AD: "obsFeatureColumns.anndata.h5ad",
|
|
@@ -3777,6 +4140,11 @@ const FileType$1 = {
|
|
|
3777
4140
|
OBS_LABELS_ANNDATA_H5AD: "obsLabels.anndata.h5ad",
|
|
3778
4141
|
FEATURE_LABELS_ANNDATA_H5AD: "featureLabels.anndata.h5ad",
|
|
3779
4142
|
SAMPLE_EDGES_ANNDATA_H5AD: "sampleEdges.anndata.h5ad",
|
|
4143
|
+
SAMPLE_SETS_ANNDATA_H5AD: "sampleSets.anndata.h5ad",
|
|
4144
|
+
COMPARISON_METADATA_ANNDATA_H5AD: "comparisonMetadata.anndata.h5ad",
|
|
4145
|
+
COMPARATIVE_FEATURE_STATS_ANNDATA_H5AD: "comparativeFeatureStats.anndata.h5ad",
|
|
4146
|
+
COMPARATIVE_FEATURE_SET_STATS_ANNDATA_H5AD: "comparativeFeatureSetStats.anndata.h5ad",
|
|
4147
|
+
COMPARATIVE_OBS_SET_STATS_ANNDATA_H5AD: "comparativeObsSetStats.anndata.h5ad",
|
|
3780
4148
|
// SpatialData
|
|
3781
4149
|
IMAGE_SPATIALDATA_ZARR: "image.spatialdata.zarr",
|
|
3782
4150
|
LABELS_SPATIALDATA_ZARR: "labels.spatialdata.zarr",
|
|
@@ -3968,12 +4336,20 @@ const CoordinationType$1 = {
|
|
|
3968
4336
|
SAMPLE_SET_FILTER: "sampleSetFilter",
|
|
3969
4337
|
SAMPLE_FILTER_MODE: "sampleFilterMode",
|
|
3970
4338
|
SAMPLE_SET_COLOR: "sampleSetColor",
|
|
4339
|
+
SAMPLE_HIGHLIGHT: "sampleHighlight",
|
|
3971
4340
|
EMBEDDING_POINTS_VISIBLE: "embeddingPointsVisible",
|
|
3972
4341
|
EMBEDDING_CONTOURS_VISIBLE: "embeddingContoursVisible",
|
|
3973
4342
|
EMBEDDING_CONTOURS_FILLED: "embeddingContoursFilled",
|
|
3974
4343
|
EMBEDDING_CONTOUR_PERCENTILES: "embeddingContourPercentiles",
|
|
3975
4344
|
CONTOUR_COLOR_ENCODING: "contourColorEncoding",
|
|
3976
|
-
CONTOUR_COLOR: "contourColor"
|
|
4345
|
+
CONTOUR_COLOR: "contourColor",
|
|
4346
|
+
// For volcano plot:
|
|
4347
|
+
FEATURE_POINT_SIGNIFICANCE_THRESHOLD: "featurePointSignificanceThreshold",
|
|
4348
|
+
FEATURE_LABEL_SIGNIFICANCE_THRESHOLD: "featureLabelSignificanceThreshold",
|
|
4349
|
+
FEATURE_POINT_FOLD_CHANGE_THRESHOLD: "featurePointFoldChangeThreshold",
|
|
4350
|
+
FEATURE_LABEL_FOLD_CHANGE_THRESHOLD: "featureLabelFoldChangeThreshold",
|
|
4351
|
+
// Treemap
|
|
4352
|
+
HIERARCHY_LEVELS: "hierarchyLevels"
|
|
3977
4353
|
};
|
|
3978
4354
|
const DEFAULT_CELLS_LAYER = {
|
|
3979
4355
|
opacity: 1,
|
|
@@ -3981,39 +4357,6 @@ const DEFAULT_CELLS_LAYER = {
|
|
|
3981
4357
|
visible: true,
|
|
3982
4358
|
stroked: false
|
|
3983
4359
|
};
|
|
3984
|
-
var commonjsGlobal = typeof globalThis !== "undefined" ? globalThis : typeof window !== "undefined" ? window : typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : {};
|
|
3985
|
-
function getDefaultExportFromCjs(x) {
|
|
3986
|
-
return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, "default") ? x["default"] : x;
|
|
3987
|
-
}
|
|
3988
|
-
function getAugmentedNamespace(n) {
|
|
3989
|
-
if (n.__esModule)
|
|
3990
|
-
return n;
|
|
3991
|
-
var f = n.default;
|
|
3992
|
-
if (typeof f == "function") {
|
|
3993
|
-
var a = function a2() {
|
|
3994
|
-
if (this instanceof a2) {
|
|
3995
|
-
var args = [null];
|
|
3996
|
-
args.push.apply(args, arguments);
|
|
3997
|
-
var Ctor = Function.bind.apply(f, args);
|
|
3998
|
-
return new Ctor();
|
|
3999
|
-
}
|
|
4000
|
-
return f.apply(this, arguments);
|
|
4001
|
-
};
|
|
4002
|
-
a.prototype = f.prototype;
|
|
4003
|
-
} else
|
|
4004
|
-
a = {};
|
|
4005
|
-
Object.defineProperty(a, "__esModule", { value: true });
|
|
4006
|
-
Object.keys(n).forEach(function(k) {
|
|
4007
|
-
var d = Object.getOwnPropertyDescriptor(n, k);
|
|
4008
|
-
Object.defineProperty(a, k, d.get ? d : {
|
|
4009
|
-
enumerable: true,
|
|
4010
|
-
get: function() {
|
|
4011
|
-
return n[k];
|
|
4012
|
-
}
|
|
4013
|
-
});
|
|
4014
|
-
});
|
|
4015
|
-
return a;
|
|
4016
|
-
}
|
|
4017
4360
|
function commonjsRequire(path) {
|
|
4018
4361
|
throw new Error('Could not dynamically require "' + path + '". Please configure the dynamicRequireTargets or/and ignoreDynamicRequires option of @rollup/plugin-commonjs appropriately for this require call to work.');
|
|
4019
4362
|
}
|
|
@@ -10907,7 +11250,7 @@ function upgradeFrom1_0_14(config2) {
|
|
|
10907
11250
|
Object.entries(propAnalogies).forEach(([oldProp, newType]) => {
|
|
10908
11251
|
var _a2;
|
|
10909
11252
|
if ((_a2 = viewDef.props) == null ? void 0 : _a2[oldProp]) {
|
|
10910
|
-
|
|
11253
|
+
log.warn(`Warning: the '${oldProp}' prop on the ${viewDef.component} view is deprecated. Please use the '${newType}' coordination type instead.`);
|
|
10911
11254
|
}
|
|
10912
11255
|
});
|
|
10913
11256
|
});
|
|
@@ -10930,7 +11273,7 @@ function upgradeFrom1_0_15(config2) {
|
|
|
10930
11273
|
Object.entries(coordinationScopes).forEach(([coordinationType, coordinationScope]) => {
|
|
10931
11274
|
if (!Array.isArray(coordinationScope) && typeof coordinationScope === "object") {
|
|
10932
11275
|
if (coordinationType === "dataset") {
|
|
10933
|
-
|
|
11276
|
+
log.error("Expected coordinationScopes.dataset value to be either string or string[], but got object.");
|
|
10934
11277
|
}
|
|
10935
11278
|
coordinationScopesBy.dataset[coordinationType] = coordinationScope;
|
|
10936
11279
|
} else if (Array.isArray(coordinationScope) || typeof coordinationScope === "string") {
|
|
@@ -13289,7 +13632,7 @@ function makeConstantWithDeprecationMessage(currObj, oldObj) {
|
|
|
13289
13632
|
const oldKeys = Object.keys(oldObj);
|
|
13290
13633
|
const propKey = String(prop);
|
|
13291
13634
|
if (oldKeys.includes(propKey)) {
|
|
13292
|
-
|
|
13635
|
+
log.warn(`Notice about the constant mapping ${propKey}: '${oldObj[propKey][0]}':
|
|
13293
13636
|
${oldObj[propKey][1]}`);
|
|
13294
13637
|
return oldObj[propKey];
|
|
13295
13638
|
}
|
|
@@ -13368,6 +13711,42 @@ const annDataConvenienceObsEmbeddingItem = z.object({
|
|
|
13368
13711
|
dims: z.array(z.number()).optional(),
|
|
13369
13712
|
embeddingType: z.string()
|
|
13370
13713
|
});
|
|
13714
|
+
z.object({
|
|
13715
|
+
path: z.string().describe("Path to the comparison metadata, such as /uns/comparison_metadata")
|
|
13716
|
+
});
|
|
13717
|
+
z.object({
|
|
13718
|
+
// TODO: implement a featureStats.anndata.zarr loader
|
|
13719
|
+
// which does not depend on comparisonMetadata
|
|
13720
|
+
// (instead, would point directly to the root of
|
|
13721
|
+
// the dataframe containing a set of diff exp results)
|
|
13722
|
+
// path: z.string().describe('Path to the dataframe containing the results.'),
|
|
13723
|
+
metadataPath: z.string().describe("Path to the comparison metadata."),
|
|
13724
|
+
indexColumn: z.string().optional().describe("Provide a column to use for the feature index, if different than the default dataframe index."),
|
|
13725
|
+
pValueColumn: z.string(),
|
|
13726
|
+
foldChangeColumn: z.string(),
|
|
13727
|
+
pValueTransformation: z.enum(["minuslog10"]).optional(),
|
|
13728
|
+
pValueAdjusted: z.boolean().optional(),
|
|
13729
|
+
foldChangeTransformation: z.enum(["log2"]).optional()
|
|
13730
|
+
});
|
|
13731
|
+
z.object({
|
|
13732
|
+
metadataPath: z.string().describe("Path to the comparison metadata."),
|
|
13733
|
+
indexColumn: z.string().optional().describe("Provide a column to use for the feature set index, if different than the default dataframe index."),
|
|
13734
|
+
termColumn: z.string().optional(),
|
|
13735
|
+
pValueColumn: z.string(),
|
|
13736
|
+
pValueAdjusted: z.boolean().optional(),
|
|
13737
|
+
analysisType: z.string().optional().describe("Optionally, provide an analysis_type name. By default, pertpy_hypergeometric.")
|
|
13738
|
+
});
|
|
13739
|
+
z.object({
|
|
13740
|
+
metadataPath: z.string().describe("Path to the comparison metadata."),
|
|
13741
|
+
indexColumn: z.string().optional().describe("Provide a column to use for the obs set index, if different than the default dataframe index."),
|
|
13742
|
+
interceptExpectedSampleColumn: z.string().describe("If we had a new sample (with no active covariates) with a total number of cells equal to the mean sampling depth of the dataset, then this distribution over the cell types would be most likely."),
|
|
13743
|
+
effectExpectedSampleColumn: z.string().describe("If we had a new sample (with no active covariates) with a total number of cells equal to the mean sampling depth of the dataset, then this distribution over the cell types would be most likely."),
|
|
13744
|
+
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."),
|
|
13745
|
+
foldChangeTransformation: z.enum(["log2"]).optional(),
|
|
13746
|
+
isCredibleEffectColumn: z.string().describe("Column which annotates effects as being credible or not (boolean)."),
|
|
13747
|
+
covariateColumn: z.string().describe("Column which defines the covariate used in the analysis."),
|
|
13748
|
+
analysisType: z.string().optional().describe("Optionally, provide an analysis_type name. By default, sccoda_df.")
|
|
13749
|
+
});
|
|
13371
13750
|
const annDataObsLabels = annDataObs;
|
|
13372
13751
|
const annDataFeatureLabels = annDataObs;
|
|
13373
13752
|
const annDataSampleEdges = annDataObs;
|
|
@@ -13387,6 +13766,9 @@ const annDataObsSetsArr = z.array(z.object({
|
|
|
13387
13766
|
z.object({
|
|
13388
13767
|
obsSets: annDataObsSetsArr
|
|
13389
13768
|
});
|
|
13769
|
+
z.object({
|
|
13770
|
+
sampleSets: annDataObsSetsArr
|
|
13771
|
+
});
|
|
13390
13772
|
const annDataObsFeatureColumnsArr = z.array(z.object({
|
|
13391
13773
|
path: z.string()
|
|
13392
13774
|
}));
|
|
@@ -20540,6 +20922,504 @@ class SampleEdgesAnndataLoader extends AbstractTwoStepLoader {
|
|
|
20540
20922
|
});
|
|
20541
20923
|
}
|
|
20542
20924
|
}
|
|
20925
|
+
class SampleSetsAnndataLoader extends AbstractTwoStepLoader {
|
|
20926
|
+
loadObsIndices() {
|
|
20927
|
+
var _a2;
|
|
20928
|
+
const { options } = this;
|
|
20929
|
+
const obsIndexPromises = (_a2 = options.sampleSets) == null ? void 0 : _a2.map(({ path }) => path).map((pathOrPaths) => {
|
|
20930
|
+
if (Array.isArray(pathOrPaths)) {
|
|
20931
|
+
if (pathOrPaths.length > 0) {
|
|
20932
|
+
return this.dataSource.loadDataFrameIndex(pathOrPaths[0]);
|
|
20933
|
+
}
|
|
20934
|
+
return this.dataSource.loadDataFrameIndex();
|
|
20935
|
+
}
|
|
20936
|
+
return this.dataSource.loadDataFrameIndex(pathOrPaths);
|
|
20937
|
+
});
|
|
20938
|
+
return Promise.all(obsIndexPromises);
|
|
20939
|
+
}
|
|
20940
|
+
loadCellSetIds() {
|
|
20941
|
+
var _a2;
|
|
20942
|
+
const { options } = this;
|
|
20943
|
+
const cellSetZarrLocation = (_a2 = options.sampleSets) == null ? void 0 : _a2.map(({ path }) => path);
|
|
20944
|
+
return this.dataSource.loadObsColumns(cellSetZarrLocation);
|
|
20945
|
+
}
|
|
20946
|
+
loadCellSetScores() {
|
|
20947
|
+
var _a2;
|
|
20948
|
+
const { options } = this;
|
|
20949
|
+
const cellSetScoreZarrLocation = (_a2 = options.sampleSets) == null ? void 0 : _a2.map((option) => option.scorePath || void 0);
|
|
20950
|
+
return this.dataSource.loadObsColumns(cellSetScoreZarrLocation);
|
|
20951
|
+
}
|
|
20952
|
+
async load() {
|
|
20953
|
+
const superResult = await super.load().catch((reason) => Promise.resolve(reason));
|
|
20954
|
+
if (superResult instanceof AbstractLoaderError) {
|
|
20955
|
+
return Promise.reject(superResult);
|
|
20956
|
+
}
|
|
20957
|
+
if (!this.cachedResult) {
|
|
20958
|
+
const { options } = this;
|
|
20959
|
+
this.cachedResult = Promise.all([
|
|
20960
|
+
this.dataSource.loadDataFrameIndex(),
|
|
20961
|
+
this.loadObsIndices(),
|
|
20962
|
+
this.loadCellSetIds(),
|
|
20963
|
+
this.loadCellSetScores()
|
|
20964
|
+
]).then((data) => [
|
|
20965
|
+
data[0],
|
|
20966
|
+
dataToCellSetsTree([data[1], data[2], data[3]], options.sampleSets)
|
|
20967
|
+
]);
|
|
20968
|
+
}
|
|
20969
|
+
const [obsIndex, obsSets] = await this.cachedResult;
|
|
20970
|
+
const obsSetsMembership = treeToMembershipMap(obsSets);
|
|
20971
|
+
const coordinationValues = {};
|
|
20972
|
+
const { tree } = obsSets;
|
|
20973
|
+
const newAutoSetSelectionParentName = tree[0].name;
|
|
20974
|
+
tree[0].children.map((node) => [
|
|
20975
|
+
newAutoSetSelectionParentName,
|
|
20976
|
+
node.name
|
|
20977
|
+
]);
|
|
20978
|
+
const newAutoSetColors = initializeCellSetColor(obsSets, []);
|
|
20979
|
+
coordinationValues.sampleSetColor = newAutoSetColors;
|
|
20980
|
+
return Promise.resolve(
|
|
20981
|
+
new LoaderResult({
|
|
20982
|
+
sampleIndex: obsIndex,
|
|
20983
|
+
sampleSets: obsSets,
|
|
20984
|
+
sampleSetsMembership: obsSetsMembership
|
|
20985
|
+
}, null, coordinationValues)
|
|
20986
|
+
);
|
|
20987
|
+
}
|
|
20988
|
+
}
|
|
20989
|
+
function isEqualPathPair(pathPairA, pathPairB) {
|
|
20990
|
+
return isEqual(pathPairA[0], pathPairB[0]) && isEqual(pathPairA[1], pathPairB[1]) || isEqual(pathPairA[0], pathPairB[1]) && isEqual(pathPairA[1], pathPairB[0]);
|
|
20991
|
+
}
|
|
20992
|
+
async function loadComparisonMetadata(dataSource, metadataPath) {
|
|
20993
|
+
const metadata = JSON.parse(await dataSource._loadString(metadataPath));
|
|
20994
|
+
if (!(metadata.schema_version === "0.0.1" || metadata.schema_version === "0.0.2")) {
|
|
20995
|
+
throw new Error("Unsupported comparison_metadata schema version.");
|
|
20996
|
+
}
|
|
20997
|
+
return metadata;
|
|
20998
|
+
}
|
|
20999
|
+
class ComparisonMetadataAnndataLoader extends AbstractTwoStepLoader {
|
|
21000
|
+
/**
|
|
21001
|
+
*
|
|
21002
|
+
* @returns {Promise<LoaderResult<ComparisonMetadata>>}
|
|
21003
|
+
*/
|
|
21004
|
+
async load() {
|
|
21005
|
+
const { path } = this.options;
|
|
21006
|
+
const superResult = await super.load().catch((reason) => Promise.resolve(reason));
|
|
21007
|
+
if (superResult instanceof AbstractLoaderError) {
|
|
21008
|
+
return Promise.reject(superResult);
|
|
21009
|
+
}
|
|
21010
|
+
const metadata = await loadComparisonMetadata(this.dataSource, path);
|
|
21011
|
+
return Promise.resolve(new LoaderResult(
|
|
21012
|
+
{
|
|
21013
|
+
// Should a more complex class be wrapping this
|
|
21014
|
+
// JSON object to help with downstream querying?
|
|
21015
|
+
comparisonMetadata: metadata
|
|
21016
|
+
},
|
|
21017
|
+
null
|
|
21018
|
+
));
|
|
21019
|
+
}
|
|
21020
|
+
}
|
|
21021
|
+
let FeatureStatsAnndataLoader$1 = class FeatureStatsAnndataLoader extends AbstractTwoStepLoader {
|
|
21022
|
+
/**
|
|
21023
|
+
* Class method for loading feature string labels.
|
|
21024
|
+
* @returns {Promise<any>} A promise for the array.
|
|
21025
|
+
*/
|
|
21026
|
+
async loadSignificances(dfPath) {
|
|
21027
|
+
const { pValueColumn, pValueTransformation } = this.options;
|
|
21028
|
+
const values = await this.dataSource.loadNumeric(`${dfPath}/${pValueColumn}`);
|
|
21029
|
+
if (pValueTransformation === "minuslog10") {
|
|
21030
|
+
values.data = values.data.map((val) => 10 ** -val);
|
|
21031
|
+
}
|
|
21032
|
+
return values.data;
|
|
21033
|
+
}
|
|
21034
|
+
/**
|
|
21035
|
+
* Class method for loading feature string labels.
|
|
21036
|
+
* @returns {Promise<any>} A promise for the array.
|
|
21037
|
+
*/
|
|
21038
|
+
async loadFoldChanges(dfPath) {
|
|
21039
|
+
const { foldChangeColumn, foldChangeTransformation } = this.options;
|
|
21040
|
+
const values = await this.dataSource.loadNumeric(`${dfPath}/${foldChangeColumn}`);
|
|
21041
|
+
if (foldChangeTransformation === "log2") {
|
|
21042
|
+
values.data = values.data.map((val) => 2 ** val);
|
|
21043
|
+
}
|
|
21044
|
+
return values.data;
|
|
21045
|
+
}
|
|
21046
|
+
async loadFeatureNames(dfPath) {
|
|
21047
|
+
const { indexColumn } = this.options;
|
|
21048
|
+
if (indexColumn) {
|
|
21049
|
+
return this.dataSource._loadColumn(`${dfPath}/${indexColumn}`);
|
|
21050
|
+
}
|
|
21051
|
+
return this.dataSource.loadDataFrameIndex(dfPath);
|
|
21052
|
+
}
|
|
21053
|
+
async loadDataFrame(dfPath) {
|
|
21054
|
+
const [
|
|
21055
|
+
featureId,
|
|
21056
|
+
featureFoldChange,
|
|
21057
|
+
featureSignificance
|
|
21058
|
+
] = await Promise.all([
|
|
21059
|
+
this.loadFeatureNames(dfPath),
|
|
21060
|
+
this.loadFoldChanges(dfPath),
|
|
21061
|
+
this.loadSignificances(dfPath)
|
|
21062
|
+
]);
|
|
21063
|
+
return {
|
|
21064
|
+
featureId,
|
|
21065
|
+
featureFoldChange,
|
|
21066
|
+
featureSignificance
|
|
21067
|
+
};
|
|
21068
|
+
}
|
|
21069
|
+
/**
|
|
21070
|
+
*
|
|
21071
|
+
* @returns {Promise<StatsMeta[]>}
|
|
21072
|
+
*/
|
|
21073
|
+
async loadMetadata() {
|
|
21074
|
+
const { metadataPath } = this.options;
|
|
21075
|
+
if (this.metadata) {
|
|
21076
|
+
return this.metadata;
|
|
21077
|
+
}
|
|
21078
|
+
if (!this.metadata) {
|
|
21079
|
+
this.metadata = await loadComparisonMetadata(this.dataSource, metadataPath);
|
|
21080
|
+
return this.metadata;
|
|
21081
|
+
}
|
|
21082
|
+
return this.metadata;
|
|
21083
|
+
}
|
|
21084
|
+
/**
|
|
21085
|
+
* Load data from multiple dataframes, merged.
|
|
21086
|
+
* @param {object} volcanoOptions
|
|
21087
|
+
* @param {string[]|null} [volcanoOptions.sampleFacet]
|
|
21088
|
+
* @param {string[]|null} [volcanoOptions.obsSetFacet]
|
|
21089
|
+
* @param {number|null} [volcanoOptions.topK]
|
|
21090
|
+
* @param {string[][]|null} [volcanoOptions.sampleSetSelection]
|
|
21091
|
+
* @returns {Promise<LoaderResult<FeatureStatsData>>}
|
|
21092
|
+
*/
|
|
21093
|
+
async loadMulti(volcanoOptions) {
|
|
21094
|
+
const { analysisType: targetAnalysisType = "rank_genes_groups" } = this.options;
|
|
21095
|
+
const { sampleSetSelection, obsSetSelection } = volcanoOptions || {};
|
|
21096
|
+
const rawObsSetSelection = obsSetSelection;
|
|
21097
|
+
const rawSampleSetSelection = sampleSetSelection;
|
|
21098
|
+
if (sampleSetSelection) {
|
|
21099
|
+
if (sampleSetSelection.length !== 2) {
|
|
21100
|
+
return Promise.reject(new Error("Expected exactly two sample sets for volcano plot."));
|
|
21101
|
+
}
|
|
21102
|
+
}
|
|
21103
|
+
if (!obsSetSelection) {
|
|
21104
|
+
return Promise.reject(new Error("Expected obsSetSelection to be present."));
|
|
21105
|
+
}
|
|
21106
|
+
const metadata = await this.loadMetadata();
|
|
21107
|
+
const matchingComparisons = [];
|
|
21108
|
+
Object.values(metadata.comparisons).forEach((comparisonGroupObject) => {
|
|
21109
|
+
const { results } = comparisonGroupObject;
|
|
21110
|
+
results.forEach((resultObject) => {
|
|
21111
|
+
const {
|
|
21112
|
+
analysis_type,
|
|
21113
|
+
// analysis_params,
|
|
21114
|
+
coordination_values
|
|
21115
|
+
// path,
|
|
21116
|
+
} = resultObject;
|
|
21117
|
+
if (analysis_type === targetAnalysisType) {
|
|
21118
|
+
if (sampleSetSelection) {
|
|
21119
|
+
rawObsSetSelection.forEach((obsSetPath) => {
|
|
21120
|
+
if (isEqual([obsSetPath], coordination_values.obsSetFilter)) {
|
|
21121
|
+
if (isEqualPathPair(rawSampleSetSelection, coordination_values.sampleSetFilter)) {
|
|
21122
|
+
matchingComparisons.push(resultObject);
|
|
21123
|
+
}
|
|
21124
|
+
}
|
|
21125
|
+
});
|
|
21126
|
+
} else if (obsSetSelection) {
|
|
21127
|
+
rawObsSetSelection.forEach((obsSetPath) => {
|
|
21128
|
+
if (isEqual([obsSetPath], coordination_values.obsSetSelection)) {
|
|
21129
|
+
matchingComparisons.push(resultObject);
|
|
21130
|
+
}
|
|
21131
|
+
});
|
|
21132
|
+
}
|
|
21133
|
+
}
|
|
21134
|
+
});
|
|
21135
|
+
});
|
|
21136
|
+
const result = await Promise.all(matchingComparisons.map(async (comparisonObject) => {
|
|
21137
|
+
const df = await this.loadDataFrame(comparisonObject.path);
|
|
21138
|
+
return {
|
|
21139
|
+
df,
|
|
21140
|
+
metadata: comparisonObject
|
|
21141
|
+
};
|
|
21142
|
+
}));
|
|
21143
|
+
return new LoaderResult({ featureStats: result }, null);
|
|
21144
|
+
}
|
|
21145
|
+
// eslint-disable-next-line class-methods-use-this
|
|
21146
|
+
async load() {
|
|
21147
|
+
throw new Error("The load() method is not implemented for FeatureStatsAnndataLoader.");
|
|
21148
|
+
}
|
|
21149
|
+
};
|
|
21150
|
+
class FeatureStatsAnndataLoader2 extends AbstractTwoStepLoader {
|
|
21151
|
+
/**
|
|
21152
|
+
* Class method for loading feature string labels.
|
|
21153
|
+
* @returns {Promise<any>} A promise for the array.
|
|
21154
|
+
*/
|
|
21155
|
+
async loadSignificances(dfPath) {
|
|
21156
|
+
const { pValueColumn } = this.options;
|
|
21157
|
+
const values = await this.dataSource.loadNumeric(`${dfPath}/${pValueColumn}`);
|
|
21158
|
+
return values.data;
|
|
21159
|
+
}
|
|
21160
|
+
async loadFeatureSetNames(dfPath) {
|
|
21161
|
+
const { indexColumn } = this.options;
|
|
21162
|
+
if (indexColumn) {
|
|
21163
|
+
return this.dataSource._loadColumn(`${dfPath}/${indexColumn}`);
|
|
21164
|
+
}
|
|
21165
|
+
return this.dataSource.loadDataFrameIndex(dfPath);
|
|
21166
|
+
}
|
|
21167
|
+
async loadFeatureSetTerms(dfPath) {
|
|
21168
|
+
const { termColumn } = this.options;
|
|
21169
|
+
return this.dataSource._loadColumn(`${dfPath}/${termColumn}`);
|
|
21170
|
+
}
|
|
21171
|
+
async loadDataFrame(dfPath) {
|
|
21172
|
+
const [
|
|
21173
|
+
featureSetName,
|
|
21174
|
+
featureSetTerm,
|
|
21175
|
+
featureSetSignificance
|
|
21176
|
+
] = await Promise.all([
|
|
21177
|
+
this.loadFeatureSetNames(dfPath),
|
|
21178
|
+
this.loadFeatureSetTerms(dfPath),
|
|
21179
|
+
this.loadSignificances(dfPath)
|
|
21180
|
+
]);
|
|
21181
|
+
return {
|
|
21182
|
+
featureSetName,
|
|
21183
|
+
featureSetTerm,
|
|
21184
|
+
featureSetSignificance
|
|
21185
|
+
};
|
|
21186
|
+
}
|
|
21187
|
+
/**
|
|
21188
|
+
*
|
|
21189
|
+
* @returns {Promise<StatsMeta[]>}
|
|
21190
|
+
*/
|
|
21191
|
+
async loadMetadata() {
|
|
21192
|
+
const { metadataPath } = this.options;
|
|
21193
|
+
if (this.metadata) {
|
|
21194
|
+
return this.metadata;
|
|
21195
|
+
}
|
|
21196
|
+
if (!this.metadata) {
|
|
21197
|
+
this.metadata = await loadComparisonMetadata(this.dataSource, metadataPath);
|
|
21198
|
+
return this.metadata;
|
|
21199
|
+
}
|
|
21200
|
+
return this.metadata;
|
|
21201
|
+
}
|
|
21202
|
+
/**
|
|
21203
|
+
* Load data from multiple dataframes, merged.
|
|
21204
|
+
* @param {object} volcanoOptions
|
|
21205
|
+
* @param {string[]|null} [volcanoOptions.sampleFacet]
|
|
21206
|
+
* @param {string[]|null} [volcanoOptions.obsSetFacet]
|
|
21207
|
+
* @param {number|null} [volcanoOptions.topK]
|
|
21208
|
+
* @param {string[][]|null} [volcanoOptions.sampleSetSelection]
|
|
21209
|
+
* @returns {Promise<LoaderResult<FeatureStatsData>>}
|
|
21210
|
+
*/
|
|
21211
|
+
async loadMulti(volcanoOptions) {
|
|
21212
|
+
const { analysisType: targetAnalysisType = "pertpy_hypergeometric" } = this.options;
|
|
21213
|
+
const { sampleSetSelection, obsSetSelection } = volcanoOptions || {};
|
|
21214
|
+
const rawObsSetSelection = obsSetSelection;
|
|
21215
|
+
const rawSampleSetSelection = sampleSetSelection;
|
|
21216
|
+
if (sampleSetSelection) {
|
|
21217
|
+
if (sampleSetSelection.length !== 2) {
|
|
21218
|
+
return Promise.reject(new Error("Expected exactly two sample sets for volcano plot."));
|
|
21219
|
+
}
|
|
21220
|
+
}
|
|
21221
|
+
if (!obsSetSelection) {
|
|
21222
|
+
return Promise.reject(new Error("Expected obsSetSelection to be present."));
|
|
21223
|
+
}
|
|
21224
|
+
const metadata = await this.loadMetadata();
|
|
21225
|
+
const matchingComparisons = [];
|
|
21226
|
+
Object.values(metadata.comparisons).forEach((comparisonGroupObject) => {
|
|
21227
|
+
const { results } = comparisonGroupObject;
|
|
21228
|
+
results.forEach((resultObject) => {
|
|
21229
|
+
const {
|
|
21230
|
+
analysis_type,
|
|
21231
|
+
// analysis_params,
|
|
21232
|
+
coordination_values
|
|
21233
|
+
// path,
|
|
21234
|
+
} = resultObject;
|
|
21235
|
+
if (analysis_type === targetAnalysisType) {
|
|
21236
|
+
if (sampleSetSelection) {
|
|
21237
|
+
rawObsSetSelection.forEach((obsSetPath) => {
|
|
21238
|
+
if (isEqual([obsSetPath], coordination_values.obsSetFilter)) {
|
|
21239
|
+
if (isEqualPathPair(rawSampleSetSelection, coordination_values.sampleSetFilter)) {
|
|
21240
|
+
matchingComparisons.push(resultObject);
|
|
21241
|
+
}
|
|
21242
|
+
}
|
|
21243
|
+
});
|
|
21244
|
+
} else if (obsSetSelection) {
|
|
21245
|
+
rawObsSetSelection.forEach((obsSetPath) => {
|
|
21246
|
+
if (isEqual([obsSetPath], coordination_values.obsSetSelection)) {
|
|
21247
|
+
matchingComparisons.push(resultObject);
|
|
21248
|
+
}
|
|
21249
|
+
});
|
|
21250
|
+
}
|
|
21251
|
+
}
|
|
21252
|
+
});
|
|
21253
|
+
});
|
|
21254
|
+
const result = await Promise.all(matchingComparisons.map(async (comparisonObject) => {
|
|
21255
|
+
const df = await this.loadDataFrame(comparisonObject.path);
|
|
21256
|
+
return {
|
|
21257
|
+
df,
|
|
21258
|
+
metadata: comparisonObject
|
|
21259
|
+
};
|
|
21260
|
+
}));
|
|
21261
|
+
return new LoaderResult({ featureSetStats: result }, null);
|
|
21262
|
+
}
|
|
21263
|
+
// eslint-disable-next-line class-methods-use-this
|
|
21264
|
+
async load() {
|
|
21265
|
+
throw new Error("The load() method is not implemented for FeatureSetStatsAnndataLoader.");
|
|
21266
|
+
}
|
|
21267
|
+
}
|
|
21268
|
+
class ObsSetStatsAnndataLoader extends AbstractTwoStepLoader {
|
|
21269
|
+
/**
|
|
21270
|
+
* Class method for loading feature string labels.
|
|
21271
|
+
* @returns {Promise<any>} A promise for the array.
|
|
21272
|
+
*/
|
|
21273
|
+
async loadInterceptValues(dfPath) {
|
|
21274
|
+
const { interceptExpectedSampleColumn } = this.options;
|
|
21275
|
+
const values = await this.dataSource.loadNumeric(`${dfPath}/${interceptExpectedSampleColumn}`);
|
|
21276
|
+
return values.data;
|
|
21277
|
+
}
|
|
21278
|
+
/**
|
|
21279
|
+
* Class method for loading feature string labels.
|
|
21280
|
+
* @returns {Promise<any>} A promise for the array.
|
|
21281
|
+
*/
|
|
21282
|
+
async loadEffectValues(dfPath) {
|
|
21283
|
+
const { effectExpectedSampleColumn } = this.options;
|
|
21284
|
+
const values = await this.dataSource.loadNumeric(`${dfPath}/${effectExpectedSampleColumn}`);
|
|
21285
|
+
return values.data;
|
|
21286
|
+
}
|
|
21287
|
+
/**
|
|
21288
|
+
* Class method for loading feature string labels.
|
|
21289
|
+
* @returns {Promise<any>} A promise for the array.
|
|
21290
|
+
*/
|
|
21291
|
+
async loadIsCredible(dfPath) {
|
|
21292
|
+
const { isCredibleEffectColumn } = this.options;
|
|
21293
|
+
const values = await this.dataSource.loadNumeric(`${dfPath}/${isCredibleEffectColumn}`);
|
|
21294
|
+
return Array.from(values.data);
|
|
21295
|
+
}
|
|
21296
|
+
/**
|
|
21297
|
+
* Class method for loading feature string labels.
|
|
21298
|
+
* @returns {Promise<any>} A promise for the array.
|
|
21299
|
+
*/
|
|
21300
|
+
async loadFoldChanges(dfPath) {
|
|
21301
|
+
const { foldChangeColumn, foldChangeTransformation } = this.options;
|
|
21302
|
+
const values = await this.dataSource.loadNumeric(`${dfPath}/${foldChangeColumn}`);
|
|
21303
|
+
if (foldChangeTransformation === "log2") {
|
|
21304
|
+
values.data = values.data.map((val) => 2 ** val);
|
|
21305
|
+
}
|
|
21306
|
+
return values.data;
|
|
21307
|
+
}
|
|
21308
|
+
async loadCovariate(dfPath) {
|
|
21309
|
+
const { covariateColumn } = this.options;
|
|
21310
|
+
return this.dataSource._loadColumn(`${dfPath}/${covariateColumn}`);
|
|
21311
|
+
}
|
|
21312
|
+
async loadObsSetNames(dfPath) {
|
|
21313
|
+
const { indexColumn } = this.options;
|
|
21314
|
+
if (indexColumn) {
|
|
21315
|
+
return this.dataSource._loadColumn(`${dfPath}/${indexColumn}`);
|
|
21316
|
+
}
|
|
21317
|
+
return this.dataSource.loadDataFrameIndex(dfPath);
|
|
21318
|
+
}
|
|
21319
|
+
async loadDataFrame(dfPath) {
|
|
21320
|
+
const [
|
|
21321
|
+
obsSetId,
|
|
21322
|
+
obsSetFoldChange,
|
|
21323
|
+
interceptExpectedSample,
|
|
21324
|
+
effectExpectedSample,
|
|
21325
|
+
isCredibleEffect,
|
|
21326
|
+
// TODO: rather than passing this down,
|
|
21327
|
+
// do the fold change direction swapping in the loader
|
|
21328
|
+
// (as opposed to in the view).
|
|
21329
|
+
// TODO: also, see https://github.com/keller-mark/compasce/issues/30
|
|
21330
|
+
// which would allow not loading this column altogether.
|
|
21331
|
+
covariate
|
|
21332
|
+
] = await Promise.all([
|
|
21333
|
+
this.loadObsSetNames(dfPath),
|
|
21334
|
+
this.loadFoldChanges(dfPath),
|
|
21335
|
+
this.loadInterceptValues(dfPath),
|
|
21336
|
+
this.loadEffectValues(dfPath),
|
|
21337
|
+
this.loadIsCredible(dfPath),
|
|
21338
|
+
this.loadCovariate(dfPath)
|
|
21339
|
+
]);
|
|
21340
|
+
return {
|
|
21341
|
+
obsSetId,
|
|
21342
|
+
obsSetFoldChange,
|
|
21343
|
+
interceptExpectedSample,
|
|
21344
|
+
effectExpectedSample,
|
|
21345
|
+
isCredibleEffect,
|
|
21346
|
+
covariate
|
|
21347
|
+
};
|
|
21348
|
+
}
|
|
21349
|
+
/**
|
|
21350
|
+
*
|
|
21351
|
+
* @returns {Promise<StatsMeta[]>}
|
|
21352
|
+
*/
|
|
21353
|
+
async loadMetadata() {
|
|
21354
|
+
const { metadataPath } = this.options;
|
|
21355
|
+
if (this.metadata) {
|
|
21356
|
+
return this.metadata;
|
|
21357
|
+
}
|
|
21358
|
+
if (!this.metadata) {
|
|
21359
|
+
this.metadata = await loadComparisonMetadata(this.dataSource, metadataPath);
|
|
21360
|
+
return this.metadata;
|
|
21361
|
+
}
|
|
21362
|
+
return this.metadata;
|
|
21363
|
+
}
|
|
21364
|
+
/**
|
|
21365
|
+
* Load data from multiple dataframes, merged.
|
|
21366
|
+
* @param {object} volcanoOptions
|
|
21367
|
+
* @param {string[]|null} [volcanoOptions.sampleFacet]
|
|
21368
|
+
* @param {string[]|null} [volcanoOptions.obsSetFacet]
|
|
21369
|
+
* @param {number|null} [volcanoOptions.topK]
|
|
21370
|
+
* @param {string[][]|null} [volcanoOptions.sampleSetSelection]
|
|
21371
|
+
* @returns {Promise<LoaderResult<ObsSetStatsData>>}
|
|
21372
|
+
*/
|
|
21373
|
+
async loadMulti(volcanoOptions) {
|
|
21374
|
+
const { analysisType: targetAnalysisType = "sccoda_df" } = this.options;
|
|
21375
|
+
const { sampleSetSelection, obsSetSelection } = volcanoOptions || {};
|
|
21376
|
+
const rawObsSetSelection = obsSetSelection;
|
|
21377
|
+
const rawSampleSetSelection = sampleSetSelection;
|
|
21378
|
+
if (!sampleSetSelection || (sampleSetSelection == null ? void 0 : sampleSetSelection.length) !== 2) {
|
|
21379
|
+
return Promise.reject(new Error("Expected exactly two sample sets for cell type composition analysis plot."));
|
|
21380
|
+
}
|
|
21381
|
+
if (!obsSetSelection) {
|
|
21382
|
+
return Promise.reject(new Error("Expected obsSetSelection to be present."));
|
|
21383
|
+
}
|
|
21384
|
+
const metadata = await this.loadMetadata();
|
|
21385
|
+
const rawObsSetGroups = Array.from(
|
|
21386
|
+
new Set(rawObsSetSelection.map((setPath) => setPath == null ? void 0 : setPath[0]))
|
|
21387
|
+
);
|
|
21388
|
+
const matchingComparisons = [];
|
|
21389
|
+
Object.values(metadata.comparisons).forEach((comparisonGroupObject) => {
|
|
21390
|
+
const { results } = comparisonGroupObject;
|
|
21391
|
+
results.forEach((resultObject) => {
|
|
21392
|
+
const {
|
|
21393
|
+
analysis_type,
|
|
21394
|
+
// analysis_params,
|
|
21395
|
+
coordination_values
|
|
21396
|
+
// path,
|
|
21397
|
+
} = resultObject;
|
|
21398
|
+
if (analysis_type === targetAnalysisType) {
|
|
21399
|
+
if (sampleSetSelection) {
|
|
21400
|
+
if (isEqual([rawObsSetGroups], coordination_values.obsSetSelection)) {
|
|
21401
|
+
if (isEqualPathPair(rawSampleSetSelection, coordination_values.sampleSetFilter)) {
|
|
21402
|
+
matchingComparisons.push(resultObject);
|
|
21403
|
+
}
|
|
21404
|
+
}
|
|
21405
|
+
}
|
|
21406
|
+
}
|
|
21407
|
+
});
|
|
21408
|
+
});
|
|
21409
|
+
const result = await Promise.all(matchingComparisons.map(async (comparisonObject) => {
|
|
21410
|
+
const df = await this.loadDataFrame(comparisonObject.path);
|
|
21411
|
+
return {
|
|
21412
|
+
df,
|
|
21413
|
+
metadata: comparisonObject
|
|
21414
|
+
};
|
|
21415
|
+
}));
|
|
21416
|
+
return new LoaderResult({ obsSetStats: result }, null);
|
|
21417
|
+
}
|
|
21418
|
+
// eslint-disable-next-line class-methods-use-this
|
|
21419
|
+
async load() {
|
|
21420
|
+
throw new Error("The load() method is not implemented for ObsSetStatsAnndataLoader.");
|
|
21421
|
+
}
|
|
21422
|
+
}
|
|
20543
21423
|
class GenomicProfilesZarrLoader extends AbstractTwoStepLoader {
|
|
20544
21424
|
loadAttrs() {
|
|
20545
21425
|
if (this.attrs) {
|
|
@@ -20560,7 +21440,10 @@ class GenomicProfilesZarrLoader extends AbstractTwoStepLoader {
|
|
|
20560
21440
|
}
|
|
20561
21441
|
export {
|
|
20562
21442
|
AnnDataSource,
|
|
21443
|
+
ComparisonMetadataAnndataLoader,
|
|
20563
21444
|
FeatureLabelsAnndataLoader,
|
|
21445
|
+
FeatureStatsAnndataLoader2 as FeatureSetStatsAnndataLoader,
|
|
21446
|
+
FeatureStatsAnndataLoader$1 as FeatureStatsAnndataLoader,
|
|
20564
21447
|
GenomicProfilesZarrLoader,
|
|
20565
21448
|
MatrixZarrAsObsFeatureMatrixLoader,
|
|
20566
21449
|
MuDataSource,
|
|
@@ -20571,9 +21454,11 @@ export {
|
|
|
20571
21454
|
ObsLocationsAnndataLoader,
|
|
20572
21455
|
ObsPointsAnndataLoader,
|
|
20573
21456
|
ObsSegmentationsAnndataLoader,
|
|
21457
|
+
ObsSetStatsAnndataLoader,
|
|
20574
21458
|
ObsSetsAnndataLoader,
|
|
20575
21459
|
ObsSpotsAnndataLoader,
|
|
20576
21460
|
SampleEdgesAnndataLoader,
|
|
21461
|
+
SampleSetsAnndataLoader,
|
|
20577
21462
|
ZarrDataSource,
|
|
20578
21463
|
basename,
|
|
20579
21464
|
dirname
|