@vitessce/zarr 3.8.4 → 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.
Files changed (2) hide show
  1. package/dist/index.js +246 -0
  2. package/package.json +11 -11
package/dist/index.js CHANGED
@@ -5156,6 +5156,7 @@ const CoordinationType$1 = {
5156
5156
  CoordinationType$1.FEATURE_SELECTION,
5157
5157
  CoordinationType$1.FEATURE_VALUE_COLORMAP,
5158
5158
  CoordinationType$1.FEATURE_VALUE_COLORMAP_RANGE,
5159
+ CoordinationType$1.FEATURE_AGGREGATION_STRATEGY,
5159
5160
  // TODO: CoordinationType.FEATURE_COLOR_ENCODING,
5160
5161
  // TODO: CoordinationType.ADDITIONAL_FEATURE_SETS,
5161
5162
  CoordinationType$1.TOOLTIPS_VISIBLE,
@@ -5657,6 +5658,24 @@ const PALETTE = [
5657
5658
  [136, 34, 85],
5658
5659
  [170, 68, 153]
5659
5660
  ];
5661
+ class VitessceConfigViewHConcat {
5662
+ constructor(views) {
5663
+ this.views = views;
5664
+ }
5665
+ }
5666
+ class VitessceConfigViewVConcat {
5667
+ constructor(views) {
5668
+ this.views = views;
5669
+ }
5670
+ }
5671
+ function hconcat(...views) {
5672
+ const vcvhc = new VitessceConfigViewHConcat(views);
5673
+ return vcvhc;
5674
+ }
5675
+ function vconcat(...views) {
5676
+ const vcvvc = new VitessceConfigViewVConcat(views);
5677
+ return vcvvc;
5678
+ }
5660
5679
  class CoordinationLevel {
5661
5680
  constructor(value) {
5662
5681
  this.value = value;
@@ -5675,6 +5694,233 @@ class CoordinationLevel {
5675
5694
  function CL(value) {
5676
5695
  return new CoordinationLevel(value);
5677
5696
  }
5697
+ class AbstractAutoConfig {
5698
+ constructor(parsedStore) {
5699
+ const { url, fileType, zmetadata } = parsedStore;
5700
+ this.url = url;
5701
+ this.fileType = fileType;
5702
+ this.zmetadata = zmetadata;
5703
+ }
5704
+ // eslint-disable-next-line class-methods-use-this
5705
+ addFiles(vc, dataset) {
5706
+ throw new Error("The addFiles() method has not been implemented.");
5707
+ }
5708
+ // eslint-disable-next-line class-methods-use-this
5709
+ addViews(vc, dataset, layoutOption) {
5710
+ throw new Error("The addViews() method has not been implemented.");
5711
+ }
5712
+ }
5713
+ class AnnDataAutoConfig extends AbstractAutoConfig {
5714
+ getOptions() {
5715
+ const { zmetadata } = this;
5716
+ const options = {
5717
+ obsEmbedding: [],
5718
+ obsSets: []
5719
+ };
5720
+ zmetadata.forEach(({ path, attrs }) => {
5721
+ const lowerPath = path.toLowerCase();
5722
+ const relPath = path.substring(1);
5723
+ if (["/x"].includes(lowerPath)) {
5724
+ options.obsFeatureMatrix = {
5725
+ path: relPath
5726
+ // TODO: Also check the shape of X.
5727
+ // If X is very large, try to initialize initial-filtering properties
5728
+ // (will require that /var contains a boolean column however.)
5729
+ };
5730
+ }
5731
+ if (["/obsm/x_spatial", "/obsm/spatial"].includes(lowerPath)) {
5732
+ options.obsLocations = {
5733
+ path: relPath
5734
+ };
5735
+ }
5736
+ if (["/obsm/x_umap", "/obsm/umap"].includes(lowerPath)) {
5737
+ options.obsEmbedding.push({ path: relPath, embeddingType: "UMAP" });
5738
+ }
5739
+ if (["/obsm/x_tsne", "/obsm/tsne"].includes(lowerPath)) {
5740
+ options.obsEmbedding.push({ path: relPath, embeddingType: "t-SNE" });
5741
+ }
5742
+ if (["/obsm/x_pca", "/obsm/pca"].includes(lowerPath)) {
5743
+ options.obsEmbedding.push({ path: relPath, embeddingType: "PCA" });
5744
+ }
5745
+ const supportedObsSetsPaths = [
5746
+ "cluster",
5747
+ "clusters",
5748
+ "subcluster",
5749
+ "cell_type",
5750
+ "celltype",
5751
+ "leiden",
5752
+ "louvain",
5753
+ "disease",
5754
+ "organism",
5755
+ "self_reported_ethnicity",
5756
+ "tissue",
5757
+ "sex"
5758
+ ].map((colname) => `/obs/${colname}`);
5759
+ if (supportedObsSetsPaths.includes(lowerPath)) {
5760
+ const name = relPath.split("/").at(-1);
5761
+ options.obsSets.push({ path: relPath, name });
5762
+ }
5763
+ });
5764
+ return options;
5765
+ }
5766
+ addFiles(vc, dataset) {
5767
+ const { url, fileType } = this;
5768
+ dataset.addFile({
5769
+ url,
5770
+ fileType,
5771
+ options: this.getOptions()
5772
+ // TODO: coordination values?
5773
+ });
5774
+ }
5775
+ // eslint-disable-next-line class-methods-use-this
5776
+ addViews(vc, dataset, layoutOption) {
5777
+ }
5778
+ }
5779
+ class SpatialDataAutoConfig extends AbstractAutoConfig {
5780
+ getOptions() {
5781
+ const { zmetadata } = this;
5782
+ const options = {};
5783
+ const availableElements = zmetadata.filter(({ path }) => {
5784
+ const relPath = path.substring(1);
5785
+ return relPath.match(/^(tables|table|images|labels|shapes|points)\/([^/]*)$/);
5786
+ });
5787
+ availableElements.forEach(({ path, attrs }) => {
5788
+ const relPath = path.substring(1);
5789
+ const firstCoordinateSystem = attrs?.multiscales?.[0]?.coordinateTransformations?.[0]?.output?.name;
5790
+ if (relPath.match(/^(images)\/([^/]*)$/)) {
5791
+ options.image = {
5792
+ path: relPath,
5793
+ coordinateSystem: firstCoordinateSystem
5794
+ // TODO: support a fileUid property in the schema?
5795
+ };
5796
+ }
5797
+ if (relPath.match(/^(labels)\/([^/]*)$/)) {
5798
+ options.obsSegmentations = {
5799
+ path: relPath,
5800
+ coordinateSystem: firstCoordinateSystem
5801
+ // TODO: support a fileUid property in the schema?
5802
+ };
5803
+ }
5804
+ if (relPath.match(/^(shapes)\/([^/]*)$/)) {
5805
+ options.obsSpots = {
5806
+ path: relPath,
5807
+ coordinateSystem: firstCoordinateSystem
5808
+ };
5809
+ }
5810
+ if (relPath.match(/^(points)\/([^/]*)$/)) {
5811
+ options.obsPoints = {
5812
+ path: relPath,
5813
+ coordinateSystem: firstCoordinateSystem
5814
+ };
5815
+ }
5816
+ if (relPath.match(/^(tables|table)\/([^/]*)$/)) {
5817
+ const tableEls = zmetadata.filter(({ path: subpath }) => subpath.startsWith(path));
5818
+ const hasX = tableEls.find((el) => el.path === `${path}/X`);
5819
+ if (hasX) {
5820
+ options.obsFeatureMatrix = {
5821
+ path: hasX.path.substring(1)
5822
+ // region: null,
5823
+ };
5824
+ }
5825
+ const hasObs = tableEls.find((el) => el.path === `${path}/obs`);
5826
+ if (hasObs) {
5827
+ const columnOrder = hasObs.attrs?.["column-order"];
5828
+ options.obsSets = {
5829
+ // region: null,
5830
+ tablePath: relPath,
5831
+ obsSets: columnOrder.map((c) => ({
5832
+ // TODO: determine whether this column is string/categorical.
5833
+ // TODO: determine whether this column contains too many
5834
+ // categories to make sense to consider a cell set.
5835
+ path: `${hasObs.path.substring(1)}/${c}`,
5836
+ name: c
5837
+ }))
5838
+ };
5839
+ }
5840
+ }
5841
+ });
5842
+ return options;
5843
+ }
5844
+ addFiles(vc, dataset) {
5845
+ const { url, fileType } = this;
5846
+ dataset.addFile({
5847
+ url,
5848
+ fileType,
5849
+ options: this.getOptions()
5850
+ // TODO: coordination values?
5851
+ });
5852
+ }
5853
+ // eslint-disable-next-line class-methods-use-this
5854
+ addViews(vc, dataset, layoutOption) {
5855
+ const options = this.getOptions();
5856
+ const spatialView = vc.addView(dataset, "spatialBeta");
5857
+ const lcView = vc.addView(dataset, "layerControllerBeta");
5858
+ const controlViews = [lcView];
5859
+ if (options.obsSets) {
5860
+ const obsSets = vc.addView(dataset, "obsSets");
5861
+ controlViews.push(obsSets);
5862
+ }
5863
+ if (options.obsFeatureMatrix) {
5864
+ const featureList = vc.addView(dataset, "featureList");
5865
+ controlViews.push(featureList);
5866
+ }
5867
+ vc.layout(hconcat(spatialView, vconcat(...controlViews)));
5868
+ }
5869
+ }
5870
+ class OmeAutoConfig extends AbstractAutoConfig {
5871
+ addFiles(vc, dataset) {
5872
+ const { url, fileType } = this;
5873
+ dataset.addFile({
5874
+ url,
5875
+ fileType
5876
+ // TODO: options?
5877
+ // TODO: coordination values?
5878
+ });
5879
+ }
5880
+ // eslint-disable-next-line class-methods-use-this
5881
+ addViews(vc, dataset, layoutOption) {
5882
+ const spatialView = vc.addView(dataset, "spatialBeta");
5883
+ const lcView = vc.addView(dataset, "layerControllerBeta");
5884
+ vc.layout(hconcat(spatialView, lcView));
5885
+ }
5886
+ }
5887
+ ({
5888
+ [FileType$1.IMAGE_OME_TIFF]: [".ome.tif", ".ome.tiff", ".ome.tf2", ".ome.tf8"],
5889
+ [FileType$1.IMAGE_OME_ZARR]: [".ome.zarr"],
5890
+ [FileType$1.IMAGE_OME_ZARR_ZIP]: [".ome.zarr.zip"],
5891
+ [FileType$1.ANNDATA_ZARR]: [".ad.zarr", ".h5ad.zarr", ".adata.zarr", ".anndata.zarr"],
5892
+ [FileType$1.ANNDATA_ZARR_ZIP]: [".ad.zarr.zip", ".h5ad.zarr.zip", ".adata.zarr.zip", ".anndata.zarr.zip"],
5893
+ // TODO: how to handle h5ad-based AnnData (since needs reference JSON file).
5894
+ // Perhaps just assume one H5AD+one JSON (or .ref.json) file correspond to each other?
5895
+ [FileType$1.SPATIALDATA_ZARR]: [".sd.zarr", ".sdata.zarr", ".spatialdata.zarr"],
5896
+ [FileType$1.SPATIALDATA_ZARR_ZIP]: [".sd.zarr.zip", ".sdata.zarr.zip", ".spatialdata.zarr.zip"]
5897
+ });
5898
+ ({
5899
+ // OME-TIFF
5900
+ [FileType$1.IMAGE_OME_TIFF]: OmeAutoConfig,
5901
+ [FileType$1.OBS_SEGMENTATIONS_OME_TIFF]: OmeAutoConfig,
5902
+ // OME-Zarr
5903
+ [FileType$1.IMAGE_OME_ZARR]: OmeAutoConfig,
5904
+ [FileType$1.IMAGE_OME_ZARR_ZIP]: OmeAutoConfig,
5905
+ [FileType$1.OBS_SEGMENTATIONS_OME_ZARR]: OmeAutoConfig,
5906
+ [FileType$1.OBS_SEGMENTATIONS_OME_ZARR_ZIP]: OmeAutoConfig,
5907
+ // AnnData
5908
+ [FileType$1.ANNDATA_ZARR]: AnnDataAutoConfig,
5909
+ [FileType$1.ANNDATA_ZARR_ZIP]: AnnDataAutoConfig,
5910
+ // SpatialData
5911
+ [FileType$1.SPATIALDATA_ZARR]: SpatialDataAutoConfig,
5912
+ [FileType$1.SPATIALDATA_ZARR_ZIP]: SpatialDataAutoConfig
5913
+ });
5914
+ [
5915
+ FileType$1.ANNDATA_ZARR,
5916
+ FileType$1.ANNDATA_ZARR_ZIP,
5917
+ FileType$1.SPATIALDATA_ZARR,
5918
+ FileType$1.SPATIALDATA_ZARR_ZIP,
5919
+ FileType$1.IMAGE_OME_ZARR,
5920
+ FileType$1.IMAGE_OME_ZARR_ZIP,
5921
+ FileType$1.OBS_SEGMENTATIONS_OME_ZARR,
5922
+ FileType$1.OBS_SEGMENTATIONS_OME_ZARR_ZIP
5923
+ ];
5678
5924
  class ObsSpotsAnndataLoader extends AbstractTwoStepLoader {
5679
5925
  /**
5680
5926
  * Class method for loading embedding coordinates, such as those from UMAP or t-SNE.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vitessce/zarr",
3
- "version": "3.8.4",
3
+ "version": "3.8.6",
4
4
  "author": "HIDIVE Lab at HMS",
5
5
  "homepage": "http://vitessce.io",
6
6
  "repository": {
@@ -22,18 +22,18 @@
22
22
  "apache-arrow": "^17.0.0",
23
23
  "parquet-wasm": "^0.6.1",
24
24
  "ol": "^10.2.1",
25
- "@vitessce/abstract": "3.8.4",
26
- "@vitessce/error": "3.8.4",
27
- "@vitessce/constants-internal": "3.8.4",
28
- "@vitessce/sets-utils": "3.8.4",
29
- "@vitessce/image-utils": "3.8.4",
30
- "@vitessce/utils": "3.8.4",
31
- "@vitessce/zarr-utils": "3.8.4",
32
- "@vitessce/config": "3.8.4",
33
- "@vitessce/globals": "3.8.4"
25
+ "@vitessce/abstract": "3.8.6",
26
+ "@vitessce/error": "3.8.6",
27
+ "@vitessce/constants-internal": "3.8.6",
28
+ "@vitessce/sets-utils": "3.8.6",
29
+ "@vitessce/image-utils": "3.8.6",
30
+ "@vitessce/utils": "3.8.6",
31
+ "@vitessce/zarr-utils": "3.8.6",
32
+ "@vitessce/config": "3.8.6",
33
+ "@vitessce/globals": "3.8.6"
34
34
  },
35
35
  "devDependencies": {
36
- "@vitessce/types": "3.8.4"
36
+ "@vitessce/types": "3.8.6"
37
37
  },
38
38
  "scripts": {
39
39
  "bundle": "pnpm exec vite build -c ../../../scripts/vite.config.mjs",