@vitessce/scatterplot-embedding 3.2.1 → 3.3.0

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.
@@ -1,5 +1,5 @@
1
1
  import { i as inflate_1 } from "./pako.esm-68f84e2a.js";
2
- import { B as BaseDecoder } from "./index-64ed3bae.js";
2
+ import { B as BaseDecoder } from "./index-87e09f29.js";
3
3
  import "react";
4
4
  import "@vitessce/vit-s";
5
5
  import "react-dom";
@@ -4462,9 +4462,9 @@ const schemePlasma = [[13, 8, 135], [16, 7, 136], [19, 7, 137], [22, 7, 138], [2
4462
4462
  function rgbSpline(spline) {
4463
4463
  return (colors) => {
4464
4464
  const n2 = colors.length;
4465
- let r2 = new Array(n2);
4466
- let g2 = new Array(n2);
4467
- let b = new Array(n2);
4465
+ const r2 = new Array(n2);
4466
+ const g2 = new Array(n2);
4467
+ const b = new Array(n2);
4468
4468
  let i2;
4469
4469
  let color2;
4470
4470
  for (i2 = 0; i2 < n2; ++i2) {
@@ -4473,10 +4473,10 @@ function rgbSpline(spline) {
4473
4473
  g2[i2] = color2[1] || 0;
4474
4474
  b[i2] = color2[2] || 0;
4475
4475
  }
4476
- r2 = spline(r2);
4477
- g2 = spline(g2);
4478
- b = spline(b);
4479
- return (t2) => [r2(t2), g2(t2), b(t2)];
4476
+ const rFunc = spline(r2);
4477
+ const gFunc = spline(g2);
4478
+ const bFunc = spline(b);
4479
+ return (t2) => [rFunc(t2), gFunc(t2), bFunc(t2)];
4480
4480
  };
4481
4481
  }
4482
4482
  function basis(values2) {
@@ -11068,6 +11068,7 @@ const DataType$2 = {
11068
11068
  const FileType$1 = {
11069
11069
  // Joint file types
11070
11070
  ANNDATA_ZARR: "anndata.zarr",
11071
+ SPATIALDATA_ZARR: "spatialdata.zarr",
11071
11072
  // Atomic file types
11072
11073
  OBS_EMBEDDING_CSV: "obsEmbedding.csv",
11073
11074
  OBS_SPOTS_CSV: "obsSpots.csv",
@@ -11090,6 +11091,16 @@ const FileType$1 = {
11090
11091
  OBS_SEGMENTATIONS_ANNDATA_ZARR: "obsSegmentations.anndata.zarr",
11091
11092
  OBS_LABELS_ANNDATA_ZARR: "obsLabels.anndata.zarr",
11092
11093
  FEATURE_LABELS_ANNDATA_ZARR: "featureLabels.anndata.zarr",
11094
+ // SpatialData
11095
+ IMAGE_SPATIALDATA_ZARR: "image.spatialdata.zarr",
11096
+ LABELS_SPATIALDATA_ZARR: "labels.spatialdata.zarr",
11097
+ SHAPES_SPATIALDATA_ZARR: "shapes.spatialdata.zarr",
11098
+ OBS_FEATURE_MATRIX_SPATIALDATA_ZARR: "obsFeatureMatrix.spatialdata.zarr",
11099
+ OBS_SETS_SPATIALDATA_ZARR: "obsSets.spatialdata.zarr",
11100
+ OBS_SPOTS_SPATIALDATA_ZARR: "obsSpots.spatialdata.zarr",
11101
+ // TODO:
11102
+ // OBS_POINTS_SPATIALDATA_ZARR: 'obsPoints.spatialdata.zarr',
11103
+ // OBS_LOCATIONS_SPATIALDATA_ZARR: 'obsLocations.spatialdata.zarr',
11093
11104
  // MuData
11094
11105
  OBS_FEATURE_MATRIX_MUDATA_ZARR: "obsFeatureMatrix.mudata.zarr",
11095
11106
  OBS_SETS_MUDATA_ZARR: "obsSets.mudata.zarr",
@@ -11891,9 +11902,30 @@ z.object({
11891
11902
  offsetsUrl: z.string().optional(),
11892
11903
  coordinateTransformations: omeCoordinateTransformations.optional()
11893
11904
  });
11894
- z.object({
11905
+ const imageOmeZarrSchema = z.object({
11895
11906
  coordinateTransformations: omeCoordinateTransformations.optional()
11896
11907
  });
11908
+ imageOmeZarrSchema.extend({
11909
+ path: z.string()
11910
+ });
11911
+ z.object({
11912
+ path: z.string()
11913
+ });
11914
+ z.object({
11915
+ path: z.string()
11916
+ });
11917
+ z.object({
11918
+ path: z.string(),
11919
+ tablePath: z.string().optional().describe("The path to a table which annotates the spots. If available but not specified, the spot identifiers may not be aligned with associated tabular data as expected.")
11920
+ });
11921
+ annDataObsFeatureMatrix.extend({
11922
+ region: z.string().describe("The name of a region to use to filter instances (i.e., rows) in the table").optional()
11923
+ });
11924
+ z.object({
11925
+ region: z.string().describe("The name of a region to use to filter instances (i.e., rows) in the table").optional(),
11926
+ tablePath: z.string().optional().describe("The path to a table which contains the index for the set values."),
11927
+ obsSets: annDataObsSets
11928
+ });
11897
11929
  z.object({
11898
11930
  obsIndex: z.string(),
11899
11931
  obsEmbedding: z.array(z.string()).length(2)
@@ -121180,16 +121212,16 @@ function addDecoder(cases, importFn) {
121180
121212
  }
121181
121213
  cases.forEach((c2) => registry$1.set(c2, importFn));
121182
121214
  }
121183
- addDecoder([void 0, 1], () => import("./raw-4ea71ae5.js").then((m2) => m2.default));
121184
- addDecoder(5, () => import("./lzw-194af29e.js").then((m2) => m2.default));
121215
+ addDecoder([void 0, 1], () => import("./raw-12234337.js").then((m2) => m2.default));
121216
+ addDecoder(5, () => import("./lzw-9f579219.js").then((m2) => m2.default));
121185
121217
  addDecoder(6, () => {
121186
121218
  throw new Error("old style JPEG compression is not supported.");
121187
121219
  });
121188
- addDecoder(7, () => import("./jpeg-26d14b38.js").then((m2) => m2.default));
121189
- addDecoder([8, 32946], () => import("./deflate-2d5bfeab.js").then((m2) => m2.default));
121190
- addDecoder(32773, () => import("./packbits-40fe7e7e.js").then((m2) => m2.default));
121191
- addDecoder(34887, () => import("./lerc-925e402e.js").then((m2) => m2.default));
121192
- addDecoder(50001, () => import("./webimage-cd737900.js").then((m2) => m2.default));
121220
+ addDecoder(7, () => import("./jpeg-418390c5.js").then((m2) => m2.default));
121221
+ addDecoder([8, 32946], () => import("./deflate-bd431815.js").then((m2) => m2.default));
121222
+ addDecoder(32773, () => import("./packbits-81f5fada.js").then((m2) => m2.default));
121223
+ addDecoder(34887, () => import("./lerc-f1c20446.js").then((m2) => m2.default));
121224
+ addDecoder(50001, () => import("./webimage-6ef04827.js").then((m2) => m2.default));
121193
121225
  function decodeRowAcc(row, stride) {
121194
121226
  let length2 = row.length - stride;
121195
121227
  let offset5 = 0;
@@ -130089,6 +130121,67 @@ function makeBoundingBox(viewState) {
130089
130121
  viewport.unproject([0, viewport.height])
130090
130122
  ];
130091
130123
  }
130124
+ const TARGETS = [1, 2, 3, 4, 5, 10, 20, 25, 50, 100, 200, 250, 500, 1e3];
130125
+ const MIN_TARGET = TARGETS[0];
130126
+ const MAX_TARGET = TARGETS[TARGETS.length - 1];
130127
+ const SI_PREFIXES = [
130128
+ { symbol: "Y", exponent: 24 },
130129
+ { symbol: "Z", exponent: 21 },
130130
+ { symbol: "E", exponent: 18 },
130131
+ { symbol: "P", exponent: 15 },
130132
+ { symbol: "T", exponent: 12 },
130133
+ { symbol: "G", exponent: 9 },
130134
+ { symbol: "M", exponent: 6 },
130135
+ { symbol: "k", exponent: 3 },
130136
+ { symbol: "h", exponent: 2 },
130137
+ { symbol: "da", exponent: 1 },
130138
+ { symbol: "", exponent: 0 },
130139
+ { symbol: "d", exponent: -1 },
130140
+ { symbol: "c", exponent: -2 },
130141
+ { symbol: "m", exponent: -3 },
130142
+ { symbol: "µ", exponent: -6 },
130143
+ { symbol: "n", exponent: -9 },
130144
+ { symbol: "p", exponent: -12 },
130145
+ { symbol: "f", exponent: -15 },
130146
+ { symbol: "a", exponent: -18 },
130147
+ { symbol: "z", exponent: -21 },
130148
+ { symbol: "y", exponent: -24 }
130149
+ ];
130150
+ function sizeToMeters(size, unit2) {
130151
+ if (!unit2 || unit2 === "m") {
130152
+ return size;
130153
+ }
130154
+ if (unit2.length > 1) {
130155
+ let unitPrefix = unit2.substring(0, unit2.length - 1);
130156
+ if (unitPrefix === "u") {
130157
+ unitPrefix = "µ";
130158
+ }
130159
+ const unitObj = SI_PREFIXES.find((p) => p.symbol === unitPrefix);
130160
+ if (unitObj) {
130161
+ return size * 10 ** unitObj.exponent;
130162
+ }
130163
+ }
130164
+ throw new Error("Received unknown unit");
130165
+ }
130166
+ function snapValue(value) {
130167
+ let magnitude = 0;
130168
+ if (value < MIN_TARGET || value > MAX_TARGET) {
130169
+ magnitude = Math.floor(Math.log10(value));
130170
+ }
130171
+ let snappedUnit = SI_PREFIXES.find(
130172
+ (p) => p.exponent % 3 === 0 && p.exponent <= magnitude
130173
+ );
130174
+ let adjustedValue = value / 10 ** snappedUnit.exponent;
130175
+ if (adjustedValue > 500 && adjustedValue <= 1e3) {
130176
+ snappedUnit = SI_PREFIXES.find(
130177
+ (p) => p.exponent % 3 === 0 && p.exponent <= magnitude + 3
130178
+ );
130179
+ adjustedValue = value / 10 ** snappedUnit.exponent;
130180
+ }
130181
+ const targetNewUnits = TARGETS.find((t2) => t2 > adjustedValue);
130182
+ const targetOrigUnits = targetNewUnits * 10 ** snappedUnit.exponent;
130183
+ return [targetOrigUnits, targetNewUnits, snappedUnit.symbol];
130184
+ }
130092
130185
  const fs$1$1 = `#define SHADER_NAME xr-layer-fragment-shader
130093
130186
 
130094
130187
  precision highp float;
@@ -130856,26 +130949,27 @@ const OverviewLayer = class extends CompositeLayer {
130856
130949
  OverviewLayer.layerName = "OverviewLayer";
130857
130950
  OverviewLayer.defaultProps = defaultProps$3;
130858
130951
  function getPosition$1(boundingBox, position, length2) {
130859
- const viewLength = boundingBox[2][0] - boundingBox[0][0];
130952
+ const viewWidth = boundingBox[2][0] - boundingBox[0][0];
130953
+ const viewHeight = boundingBox[2][1] - boundingBox[0][1];
130860
130954
  switch (position) {
130861
130955
  case "bottom-right": {
130862
- const yCoord = boundingBox[2][1] - (boundingBox[2][1] - boundingBox[0][1]) * length2;
130863
- const xLeftCoord = boundingBox[2][0] - viewLength * length2;
130956
+ const yCoord = boundingBox[2][1] - viewHeight * length2;
130957
+ const xLeftCoord = boundingBox[2][0] - viewWidth * length2;
130864
130958
  return [yCoord, xLeftCoord];
130865
130959
  }
130866
130960
  case "top-right": {
130867
- const yCoord = (boundingBox[2][1] - boundingBox[0][1]) * length2;
130868
- const xLeftCoord = boundingBox[2][0] - viewLength * length2;
130961
+ const yCoord = boundingBox[0][1] + viewHeight * length2;
130962
+ const xLeftCoord = boundingBox[2][0] - viewWidth * length2;
130869
130963
  return [yCoord, xLeftCoord];
130870
130964
  }
130871
130965
  case "top-left": {
130872
- const yCoord = (boundingBox[2][1] - boundingBox[0][1]) * length2;
130873
- const xLeftCoord = viewLength * length2;
130966
+ const yCoord = boundingBox[0][1] + viewHeight * length2;
130967
+ const xLeftCoord = boundingBox[0][0] + viewWidth * length2;
130874
130968
  return [yCoord, xLeftCoord];
130875
130969
  }
130876
130970
  case "bottom-left": {
130877
- const yCoord = boundingBox[2][1] - (boundingBox[2][1] - boundingBox[0][1]) * length2;
130878
- const xLeftCoord = viewLength * length2;
130971
+ const yCoord = boundingBox[2][1] - viewHeight * length2;
130972
+ const xLeftCoord = boundingBox[0][0] + viewWidth * length2;
130879
130973
  return [yCoord, xLeftCoord];
130880
130974
  }
130881
130975
  default: {
@@ -130893,11 +130987,12 @@ const defaultProps$2$1 = {
130893
130987
  unit: { type: "string", value: "", compare: true },
130894
130988
  size: { type: "number", value: 1, compare: true },
130895
130989
  position: { type: "string", value: "bottom-right", compare: true },
130896
- length: { type: "number", value: 0.085, compare: true }
130990
+ length: { type: "number", value: 0.085, compare: true },
130991
+ snap: { type: "boolean", value: false, compare: true }
130897
130992
  };
130898
130993
  const ScaleBarLayer = class extends CompositeLayer {
130899
130994
  renderLayers() {
130900
- const { id, unit: unit2, size, position, viewState, length: length2 } = this.props;
130995
+ const { id, unit: unit2, size, position, viewState, length: length2, snap } = this.props;
130901
130996
  const boundingBox = makeBoundingBox(viewState);
130902
130997
  const { zoom } = viewState;
130903
130998
  const viewLength = boundingBox[2][0] - boundingBox[0][0];
@@ -130906,15 +131001,27 @@ const ScaleBarLayer = class extends CompositeLayer {
130906
131001
  2 ** (-zoom + 1.5),
130907
131002
  (boundingBox[2][1] - boundingBox[0][1]) * 7e-3
130908
131003
  );
130909
- const numUnits = barLength * size;
131004
+ let adjustedBarLength = barLength;
131005
+ let displayNumber = (barLength * size).toPrecision(5);
131006
+ let displayUnit = unit2;
131007
+ if (snap) {
131008
+ const meterSize = sizeToMeters(size, unit2);
131009
+ const numUnits = barLength * meterSize;
131010
+ const [snappedOrigUnits, snappedNewUnits, snappedUnitPrefix] = snapValue(numUnits);
131011
+ adjustedBarLength = snappedOrigUnits / meterSize;
131012
+ displayNumber = snappedNewUnits;
131013
+ displayUnit = `${snappedUnitPrefix}m`;
131014
+ }
130910
131015
  const [yCoord, xLeftCoord] = getPosition$1(boundingBox, position, length2);
131016
+ const xRightCoord = xLeftCoord + barLength;
131017
+ const isLeft = position.endsWith("-left");
130911
131018
  const lengthBar = new LineLayer({
130912
131019
  id: `scale-bar-length-${id}`,
130913
131020
  coordinateSystem: COORDINATE_SYSTEM.CARTESIAN,
130914
131021
  data: [
130915
131022
  [
130916
- [xLeftCoord, yCoord],
130917
- [xLeftCoord + barLength, yCoord]
131023
+ [isLeft ? xLeftCoord : xRightCoord - adjustedBarLength, yCoord],
131024
+ [isLeft ? xLeftCoord + adjustedBarLength : xRightCoord, yCoord]
130918
131025
  ]
130919
131026
  ],
130920
131027
  getSourcePosition: (d) => d[0],
@@ -130927,8 +131034,14 @@ const ScaleBarLayer = class extends CompositeLayer {
130927
131034
  coordinateSystem: COORDINATE_SYSTEM.CARTESIAN,
130928
131035
  data: [
130929
131036
  [
130930
- [xLeftCoord, yCoord - barHeight],
130931
- [xLeftCoord, yCoord + barHeight]
131037
+ [
131038
+ isLeft ? xLeftCoord : xRightCoord - adjustedBarLength,
131039
+ yCoord - barHeight
131040
+ ],
131041
+ [
131042
+ isLeft ? xLeftCoord : xRightCoord - adjustedBarLength,
131043
+ yCoord + barHeight
131044
+ ]
130932
131045
  ]
130933
131046
  ],
130934
131047
  getSourcePosition: (d) => d[0],
@@ -130941,8 +131054,14 @@ const ScaleBarLayer = class extends CompositeLayer {
130941
131054
  coordinateSystem: COORDINATE_SYSTEM.CARTESIAN,
130942
131055
  data: [
130943
131056
  [
130944
- [xLeftCoord + barLength, yCoord - barHeight],
130945
- [xLeftCoord + barLength, yCoord + barHeight]
131057
+ [
131058
+ isLeft ? xLeftCoord + adjustedBarLength : xRightCoord,
131059
+ yCoord - barHeight
131060
+ ],
131061
+ [
131062
+ isLeft ? xLeftCoord + adjustedBarLength : xRightCoord,
131063
+ yCoord + barHeight
131064
+ ]
130946
131065
  ]
130947
131066
  ],
130948
131067
  getSourcePosition: (d) => d[0],
@@ -130955,8 +131074,11 @@ const ScaleBarLayer = class extends CompositeLayer {
130955
131074
  coordinateSystem: COORDINATE_SYSTEM.CARTESIAN,
130956
131075
  data: [
130957
131076
  {
130958
- text: numUnits.toPrecision(5) + unit2,
130959
- position: [xLeftCoord + barLength * 0.5, yCoord + barHeight * 4]
131077
+ text: `${displayNumber}${displayUnit}`,
131078
+ position: [
131079
+ isLeft ? xLeftCoord + barLength * 0.5 : xRightCoord - barLength * 0.5,
131080
+ yCoord + barHeight * 4
131081
+ ]
130960
131082
  }
130961
131083
  ],
130962
131084
  getColor: [220, 220, 220, 255],
@@ -130965,7 +131087,7 @@ const ScaleBarLayer = class extends CompositeLayer {
130965
131087
  sizeUnits: "meters",
130966
131088
  sizeScale: 2 ** -zoom,
130967
131089
  characterSet: [
130968
- ...unit2.split(""),
131090
+ ...displayUnit.split(""),
130969
131091
  ...range(10).map((i2) => String(i2)),
130970
131092
  ".",
130971
131093
  "e",
@@ -145440,9 +145562,9 @@ function Legend(props2) {
145440
145562
  const hasSubLabel = subLabel !== null;
145441
145563
  if (!isSetColor) {
145442
145564
  g2.append("text").attr("text-anchor", hasSubLabel ? "start" : "end").attr("dominant-baseline", "hanging").attr("x", hasSubLabel ? 0 : width).attr("y", 0).text(mainLabel).style("font-size", "10px").style("fill", foregroundColor);
145443
- }
145444
- if (hasSubLabel) {
145445
- g2.append("text").attr("text-anchor", "end").attr("dominant-baseline", "hanging").attr("x", width).attr("y", titleHeight).text(subLabel).style("font-size", "9px").style("fill", foregroundColor);
145565
+ if (hasSubLabel) {
145566
+ g2.append("text").attr("text-anchor", "end").attr("dominant-baseline", "hanging").attr("x", width).attr("y", titleHeight).text(subLabel).style("font-size", "9px").style("fill", foregroundColor);
145567
+ }
145446
145568
  }
145447
145569
  }, [
145448
145570
  width,
package/dist/index.js CHANGED
@@ -1,4 +1,4 @@
1
- import { E } from "./index-64ed3bae.js";
1
+ import { E } from "./index-87e09f29.js";
2
2
  import "react";
3
3
  import "@vitessce/vit-s";
4
4
  import "react-dom";
@@ -1,4 +1,4 @@
1
- import { B as BaseDecoder } from "./index-64ed3bae.js";
1
+ import { B as BaseDecoder } from "./index-87e09f29.js";
2
2
  import "react";
3
3
  import "@vitessce/vit-s";
4
4
  import "react-dom";
@@ -1,5 +1,5 @@
1
1
  import { i as inflate_1 } from "./pako.esm-68f84e2a.js";
2
- import { g as getDefaultExportFromCjs, B as BaseDecoder } from "./index-64ed3bae.js";
2
+ import { g as getDefaultExportFromCjs, B as BaseDecoder } from "./index-87e09f29.js";
3
3
  import "react";
4
4
  import "@vitessce/vit-s";
5
5
  import "react-dom";
@@ -1,4 +1,4 @@
1
- import { B as BaseDecoder } from "./index-64ed3bae.js";
1
+ import { B as BaseDecoder } from "./index-87e09f29.js";
2
2
  import "react";
3
3
  import "@vitessce/vit-s";
4
4
  import "react-dom";
@@ -1,4 +1,4 @@
1
- import { B as BaseDecoder } from "./index-64ed3bae.js";
1
+ import { B as BaseDecoder } from "./index-87e09f29.js";
2
2
  import "react";
3
3
  import "@vitessce/vit-s";
4
4
  import "react-dom";
@@ -1,4 +1,4 @@
1
- import { B as BaseDecoder } from "./index-64ed3bae.js";
1
+ import { B as BaseDecoder } from "./index-87e09f29.js";
2
2
  import "react";
3
3
  import "@vitessce/vit-s";
4
4
  import "react-dom";
@@ -1,4 +1,4 @@
1
- import { B as BaseDecoder } from "./index-64ed3bae.js";
1
+ import { B as BaseDecoder } from "./index-87e09f29.js";
2
2
  import "react";
3
3
  import "@vitessce/vit-s";
4
4
  import "react-dom";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vitessce/scatterplot-embedding",
3
- "version": "3.2.1",
3
+ "version": "3.3.0",
4
4
  "author": "Gehlenborg Lab",
5
5
  "homepage": "http://vitessce.io",
6
6
  "repository": {
@@ -20,12 +20,12 @@
20
20
  "d3-array": "^2.4.0",
21
21
  "lodash-es": "^4.17.21",
22
22
  "react-aria": "^3.28.0",
23
- "@vitessce/constants-internal": "3.2.1",
24
- "@vitessce/legend": "3.2.1",
25
- "@vitessce/scatterplot": "3.2.1",
26
- "@vitessce/sets-utils": "3.2.1",
27
- "@vitessce/utils": "3.2.1",
28
- "@vitessce/vit-s": "3.2.1"
23
+ "@vitessce/constants-internal": "3.3.0",
24
+ "@vitessce/legend": "3.3.0",
25
+ "@vitessce/scatterplot": "3.3.0",
26
+ "@vitessce/sets-utils": "3.3.0",
27
+ "@vitessce/utils": "3.3.0",
28
+ "@vitessce/vit-s": "3.3.0"
29
29
  },
30
30
  "devDependencies": {
31
31
  "react": "^18.0.0",