@vitessce/csv 3.8.5 → 3.8.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +245 -0
- package/package.json +6 -6
package/dist/index.js
CHANGED
|
@@ -2217,6 +2217,24 @@ const PALETTE = [
|
|
|
2217
2217
|
[136, 34, 85],
|
|
2218
2218
|
[170, 68, 153]
|
|
2219
2219
|
];
|
|
2220
|
+
class VitessceConfigViewHConcat {
|
|
2221
|
+
constructor(views) {
|
|
2222
|
+
this.views = views;
|
|
2223
|
+
}
|
|
2224
|
+
}
|
|
2225
|
+
class VitessceConfigViewVConcat {
|
|
2226
|
+
constructor(views) {
|
|
2227
|
+
this.views = views;
|
|
2228
|
+
}
|
|
2229
|
+
}
|
|
2230
|
+
function hconcat(...views) {
|
|
2231
|
+
const vcvhc = new VitessceConfigViewHConcat(views);
|
|
2232
|
+
return vcvhc;
|
|
2233
|
+
}
|
|
2234
|
+
function vconcat(...views) {
|
|
2235
|
+
const vcvvc = new VitessceConfigViewVConcat(views);
|
|
2236
|
+
return vcvvc;
|
|
2237
|
+
}
|
|
2220
2238
|
class CoordinationLevel {
|
|
2221
2239
|
constructor(value) {
|
|
2222
2240
|
this.value = value;
|
|
@@ -2235,6 +2253,233 @@ class CoordinationLevel {
|
|
|
2235
2253
|
function CL(value) {
|
|
2236
2254
|
return new CoordinationLevel(value);
|
|
2237
2255
|
}
|
|
2256
|
+
class AbstractAutoConfig {
|
|
2257
|
+
constructor(parsedStore) {
|
|
2258
|
+
const { url, fileType, zmetadata } = parsedStore;
|
|
2259
|
+
this.url = url;
|
|
2260
|
+
this.fileType = fileType;
|
|
2261
|
+
this.zmetadata = zmetadata;
|
|
2262
|
+
}
|
|
2263
|
+
// eslint-disable-next-line class-methods-use-this
|
|
2264
|
+
addFiles(vc, dataset) {
|
|
2265
|
+
throw new Error("The addFiles() method has not been implemented.");
|
|
2266
|
+
}
|
|
2267
|
+
// eslint-disable-next-line class-methods-use-this
|
|
2268
|
+
addViews(vc, dataset, layoutOption) {
|
|
2269
|
+
throw new Error("The addViews() method has not been implemented.");
|
|
2270
|
+
}
|
|
2271
|
+
}
|
|
2272
|
+
class AnnDataAutoConfig extends AbstractAutoConfig {
|
|
2273
|
+
getOptions() {
|
|
2274
|
+
const { zmetadata } = this;
|
|
2275
|
+
const options = {
|
|
2276
|
+
obsEmbedding: [],
|
|
2277
|
+
obsSets: []
|
|
2278
|
+
};
|
|
2279
|
+
zmetadata.forEach(({ path, attrs }) => {
|
|
2280
|
+
const lowerPath = path.toLowerCase();
|
|
2281
|
+
const relPath = path.substring(1);
|
|
2282
|
+
if (["/x"].includes(lowerPath)) {
|
|
2283
|
+
options.obsFeatureMatrix = {
|
|
2284
|
+
path: relPath
|
|
2285
|
+
// TODO: Also check the shape of X.
|
|
2286
|
+
// If X is very large, try to initialize initial-filtering properties
|
|
2287
|
+
// (will require that /var contains a boolean column however.)
|
|
2288
|
+
};
|
|
2289
|
+
}
|
|
2290
|
+
if (["/obsm/x_spatial", "/obsm/spatial"].includes(lowerPath)) {
|
|
2291
|
+
options.obsLocations = {
|
|
2292
|
+
path: relPath
|
|
2293
|
+
};
|
|
2294
|
+
}
|
|
2295
|
+
if (["/obsm/x_umap", "/obsm/umap"].includes(lowerPath)) {
|
|
2296
|
+
options.obsEmbedding.push({ path: relPath, embeddingType: "UMAP" });
|
|
2297
|
+
}
|
|
2298
|
+
if (["/obsm/x_tsne", "/obsm/tsne"].includes(lowerPath)) {
|
|
2299
|
+
options.obsEmbedding.push({ path: relPath, embeddingType: "t-SNE" });
|
|
2300
|
+
}
|
|
2301
|
+
if (["/obsm/x_pca", "/obsm/pca"].includes(lowerPath)) {
|
|
2302
|
+
options.obsEmbedding.push({ path: relPath, embeddingType: "PCA" });
|
|
2303
|
+
}
|
|
2304
|
+
const supportedObsSetsPaths = [
|
|
2305
|
+
"cluster",
|
|
2306
|
+
"clusters",
|
|
2307
|
+
"subcluster",
|
|
2308
|
+
"cell_type",
|
|
2309
|
+
"celltype",
|
|
2310
|
+
"leiden",
|
|
2311
|
+
"louvain",
|
|
2312
|
+
"disease",
|
|
2313
|
+
"organism",
|
|
2314
|
+
"self_reported_ethnicity",
|
|
2315
|
+
"tissue",
|
|
2316
|
+
"sex"
|
|
2317
|
+
].map((colname) => `/obs/${colname}`);
|
|
2318
|
+
if (supportedObsSetsPaths.includes(lowerPath)) {
|
|
2319
|
+
const name = relPath.split("/").at(-1);
|
|
2320
|
+
options.obsSets.push({ path: relPath, name });
|
|
2321
|
+
}
|
|
2322
|
+
});
|
|
2323
|
+
return options;
|
|
2324
|
+
}
|
|
2325
|
+
addFiles(vc, dataset) {
|
|
2326
|
+
const { url, fileType } = this;
|
|
2327
|
+
dataset.addFile({
|
|
2328
|
+
url,
|
|
2329
|
+
fileType,
|
|
2330
|
+
options: this.getOptions()
|
|
2331
|
+
// TODO: coordination values?
|
|
2332
|
+
});
|
|
2333
|
+
}
|
|
2334
|
+
// eslint-disable-next-line class-methods-use-this
|
|
2335
|
+
addViews(vc, dataset, layoutOption) {
|
|
2336
|
+
}
|
|
2337
|
+
}
|
|
2338
|
+
class SpatialDataAutoConfig extends AbstractAutoConfig {
|
|
2339
|
+
getOptions() {
|
|
2340
|
+
const { zmetadata } = this;
|
|
2341
|
+
const options = {};
|
|
2342
|
+
const availableElements = zmetadata.filter(({ path }) => {
|
|
2343
|
+
const relPath = path.substring(1);
|
|
2344
|
+
return relPath.match(/^(tables|table|images|labels|shapes|points)\/([^/]*)$/);
|
|
2345
|
+
});
|
|
2346
|
+
availableElements.forEach(({ path, attrs }) => {
|
|
2347
|
+
const relPath = path.substring(1);
|
|
2348
|
+
const firstCoordinateSystem = attrs?.multiscales?.[0]?.coordinateTransformations?.[0]?.output?.name;
|
|
2349
|
+
if (relPath.match(/^(images)\/([^/]*)$/)) {
|
|
2350
|
+
options.image = {
|
|
2351
|
+
path: relPath,
|
|
2352
|
+
coordinateSystem: firstCoordinateSystem
|
|
2353
|
+
// TODO: support a fileUid property in the schema?
|
|
2354
|
+
};
|
|
2355
|
+
}
|
|
2356
|
+
if (relPath.match(/^(labels)\/([^/]*)$/)) {
|
|
2357
|
+
options.obsSegmentations = {
|
|
2358
|
+
path: relPath,
|
|
2359
|
+
coordinateSystem: firstCoordinateSystem
|
|
2360
|
+
// TODO: support a fileUid property in the schema?
|
|
2361
|
+
};
|
|
2362
|
+
}
|
|
2363
|
+
if (relPath.match(/^(shapes)\/([^/]*)$/)) {
|
|
2364
|
+
options.obsSpots = {
|
|
2365
|
+
path: relPath,
|
|
2366
|
+
coordinateSystem: firstCoordinateSystem
|
|
2367
|
+
};
|
|
2368
|
+
}
|
|
2369
|
+
if (relPath.match(/^(points)\/([^/]*)$/)) {
|
|
2370
|
+
options.obsPoints = {
|
|
2371
|
+
path: relPath,
|
|
2372
|
+
coordinateSystem: firstCoordinateSystem
|
|
2373
|
+
};
|
|
2374
|
+
}
|
|
2375
|
+
if (relPath.match(/^(tables|table)\/([^/]*)$/)) {
|
|
2376
|
+
const tableEls = zmetadata.filter(({ path: subpath }) => subpath.startsWith(path));
|
|
2377
|
+
const hasX = tableEls.find((el) => el.path === `${path}/X`);
|
|
2378
|
+
if (hasX) {
|
|
2379
|
+
options.obsFeatureMatrix = {
|
|
2380
|
+
path: hasX.path.substring(1)
|
|
2381
|
+
// region: null,
|
|
2382
|
+
};
|
|
2383
|
+
}
|
|
2384
|
+
const hasObs = tableEls.find((el) => el.path === `${path}/obs`);
|
|
2385
|
+
if (hasObs) {
|
|
2386
|
+
const columnOrder = hasObs.attrs?.["column-order"];
|
|
2387
|
+
options.obsSets = {
|
|
2388
|
+
// region: null,
|
|
2389
|
+
tablePath: relPath,
|
|
2390
|
+
obsSets: columnOrder.map((c) => ({
|
|
2391
|
+
// TODO: determine whether this column is string/categorical.
|
|
2392
|
+
// TODO: determine whether this column contains too many
|
|
2393
|
+
// categories to make sense to consider a cell set.
|
|
2394
|
+
path: `${hasObs.path.substring(1)}/${c}`,
|
|
2395
|
+
name: c
|
|
2396
|
+
}))
|
|
2397
|
+
};
|
|
2398
|
+
}
|
|
2399
|
+
}
|
|
2400
|
+
});
|
|
2401
|
+
return options;
|
|
2402
|
+
}
|
|
2403
|
+
addFiles(vc, dataset) {
|
|
2404
|
+
const { url, fileType } = this;
|
|
2405
|
+
dataset.addFile({
|
|
2406
|
+
url,
|
|
2407
|
+
fileType,
|
|
2408
|
+
options: this.getOptions()
|
|
2409
|
+
// TODO: coordination values?
|
|
2410
|
+
});
|
|
2411
|
+
}
|
|
2412
|
+
// eslint-disable-next-line class-methods-use-this
|
|
2413
|
+
addViews(vc, dataset, layoutOption) {
|
|
2414
|
+
const options = this.getOptions();
|
|
2415
|
+
const spatialView = vc.addView(dataset, "spatialBeta");
|
|
2416
|
+
const lcView = vc.addView(dataset, "layerControllerBeta");
|
|
2417
|
+
const controlViews = [lcView];
|
|
2418
|
+
if (options.obsSets) {
|
|
2419
|
+
const obsSets = vc.addView(dataset, "obsSets");
|
|
2420
|
+
controlViews.push(obsSets);
|
|
2421
|
+
}
|
|
2422
|
+
if (options.obsFeatureMatrix) {
|
|
2423
|
+
const featureList = vc.addView(dataset, "featureList");
|
|
2424
|
+
controlViews.push(featureList);
|
|
2425
|
+
}
|
|
2426
|
+
vc.layout(hconcat(spatialView, vconcat(...controlViews)));
|
|
2427
|
+
}
|
|
2428
|
+
}
|
|
2429
|
+
class OmeAutoConfig extends AbstractAutoConfig {
|
|
2430
|
+
addFiles(vc, dataset) {
|
|
2431
|
+
const { url, fileType } = this;
|
|
2432
|
+
dataset.addFile({
|
|
2433
|
+
url,
|
|
2434
|
+
fileType
|
|
2435
|
+
// TODO: options?
|
|
2436
|
+
// TODO: coordination values?
|
|
2437
|
+
});
|
|
2438
|
+
}
|
|
2439
|
+
// eslint-disable-next-line class-methods-use-this
|
|
2440
|
+
addViews(vc, dataset, layoutOption) {
|
|
2441
|
+
const spatialView = vc.addView(dataset, "spatialBeta");
|
|
2442
|
+
const lcView = vc.addView(dataset, "layerControllerBeta");
|
|
2443
|
+
vc.layout(hconcat(spatialView, lcView));
|
|
2444
|
+
}
|
|
2445
|
+
}
|
|
2446
|
+
({
|
|
2447
|
+
[FileType$1.IMAGE_OME_TIFF]: [".ome.tif", ".ome.tiff", ".ome.tf2", ".ome.tf8"],
|
|
2448
|
+
[FileType$1.IMAGE_OME_ZARR]: [".ome.zarr"],
|
|
2449
|
+
[FileType$1.IMAGE_OME_ZARR_ZIP]: [".ome.zarr.zip"],
|
|
2450
|
+
[FileType$1.ANNDATA_ZARR]: [".ad.zarr", ".h5ad.zarr", ".adata.zarr", ".anndata.zarr"],
|
|
2451
|
+
[FileType$1.ANNDATA_ZARR_ZIP]: [".ad.zarr.zip", ".h5ad.zarr.zip", ".adata.zarr.zip", ".anndata.zarr.zip"],
|
|
2452
|
+
// TODO: how to handle h5ad-based AnnData (since needs reference JSON file).
|
|
2453
|
+
// Perhaps just assume one H5AD+one JSON (or .ref.json) file correspond to each other?
|
|
2454
|
+
[FileType$1.SPATIALDATA_ZARR]: [".sd.zarr", ".sdata.zarr", ".spatialdata.zarr"],
|
|
2455
|
+
[FileType$1.SPATIALDATA_ZARR_ZIP]: [".sd.zarr.zip", ".sdata.zarr.zip", ".spatialdata.zarr.zip"]
|
|
2456
|
+
});
|
|
2457
|
+
({
|
|
2458
|
+
// OME-TIFF
|
|
2459
|
+
[FileType$1.IMAGE_OME_TIFF]: OmeAutoConfig,
|
|
2460
|
+
[FileType$1.OBS_SEGMENTATIONS_OME_TIFF]: OmeAutoConfig,
|
|
2461
|
+
// OME-Zarr
|
|
2462
|
+
[FileType$1.IMAGE_OME_ZARR]: OmeAutoConfig,
|
|
2463
|
+
[FileType$1.IMAGE_OME_ZARR_ZIP]: OmeAutoConfig,
|
|
2464
|
+
[FileType$1.OBS_SEGMENTATIONS_OME_ZARR]: OmeAutoConfig,
|
|
2465
|
+
[FileType$1.OBS_SEGMENTATIONS_OME_ZARR_ZIP]: OmeAutoConfig,
|
|
2466
|
+
// AnnData
|
|
2467
|
+
[FileType$1.ANNDATA_ZARR]: AnnDataAutoConfig,
|
|
2468
|
+
[FileType$1.ANNDATA_ZARR_ZIP]: AnnDataAutoConfig,
|
|
2469
|
+
// SpatialData
|
|
2470
|
+
[FileType$1.SPATIALDATA_ZARR]: SpatialDataAutoConfig,
|
|
2471
|
+
[FileType$1.SPATIALDATA_ZARR_ZIP]: SpatialDataAutoConfig
|
|
2472
|
+
});
|
|
2473
|
+
[
|
|
2474
|
+
FileType$1.ANNDATA_ZARR,
|
|
2475
|
+
FileType$1.ANNDATA_ZARR_ZIP,
|
|
2476
|
+
FileType$1.SPATIALDATA_ZARR,
|
|
2477
|
+
FileType$1.SPATIALDATA_ZARR_ZIP,
|
|
2478
|
+
FileType$1.IMAGE_OME_ZARR,
|
|
2479
|
+
FileType$1.IMAGE_OME_ZARR_ZIP,
|
|
2480
|
+
FileType$1.OBS_SEGMENTATIONS_OME_ZARR,
|
|
2481
|
+
FileType$1.OBS_SEGMENTATIONS_OME_ZARR_ZIP
|
|
2482
|
+
];
|
|
2238
2483
|
class ObsSpotsCsvLoader extends CsvLoader {
|
|
2239
2484
|
loadFromCache(data) {
|
|
2240
2485
|
if (this.cachedResult) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vitessce/csv",
|
|
3
|
-
"version": "3.8.
|
|
3
|
+
"version": "3.8.6",
|
|
4
4
|
"author": "HIDIVE Lab at HMS",
|
|
5
5
|
"homepage": "http://vitessce.io",
|
|
6
6
|
"repository": {
|
|
@@ -18,11 +18,11 @@
|
|
|
18
18
|
"dependencies": {
|
|
19
19
|
"d3-array": "^2.4.0",
|
|
20
20
|
"d3-dsv": "^1.1.1",
|
|
21
|
-
"@vitessce/constants-internal": "3.8.
|
|
22
|
-
"@vitessce/sets-utils": "3.8.
|
|
23
|
-
"@vitessce/abstract": "3.8.
|
|
24
|
-
"@vitessce/error": "3.8.
|
|
25
|
-
"@vitessce/config": "3.8.
|
|
21
|
+
"@vitessce/constants-internal": "3.8.6",
|
|
22
|
+
"@vitessce/sets-utils": "3.8.6",
|
|
23
|
+
"@vitessce/abstract": "3.8.6",
|
|
24
|
+
"@vitessce/error": "3.8.6",
|
|
25
|
+
"@vitessce/config": "3.8.6"
|
|
26
26
|
},
|
|
27
27
|
"scripts": {
|
|
28
28
|
"bundle": "pnpm exec vite build -c ../../../scripts/vite.config.mjs",
|