@vitessce/heatmap 3.8.13 → 3.9.1

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-SxljTded.js";
2
- import { B as BaseDecoder } from "./index-BB2ssozJ.js";
2
+ import { B as BaseDecoder } from "./index-DgJedZPO.js";
3
3
  class DeflateDecoder extends BaseDecoder {
4
4
  decodeBlock(buffer) {
5
5
  return inflate_1(new Uint8Array(buffer)).buffer;
@@ -720,6 +720,17 @@ const DEFAULT_LIGHT2_COLOR = [235, 235, 235];
720
720
  function getDefaultColor(theme) {
721
721
  return theme === "dark" ? DEFAULT_DARK_COLOR : theme === "light" ? DEFAULT_LIGHT_COLOR$3 : DEFAULT_LIGHT2_COLOR;
722
722
  }
723
+ const PALETTE = [
724
+ [68, 119, 170],
725
+ [136, 204, 238],
726
+ [68, 170, 153],
727
+ [17, 119, 51],
728
+ [153, 153, 51],
729
+ [221, 204, 119],
730
+ [204, 102, 119],
731
+ [136, 34, 85],
732
+ [170, 68, 153]
733
+ ];
723
734
  const DEFAULT_GL_OPTIONS = { webgl2: true };
724
735
  function createDefaultUpdateCellsHover(componentName) {
725
736
  return (hoverInfo) => log$5.warn(`${componentName} updateCellsHover: ${hoverInfo.cellId}`);
@@ -9760,6 +9771,7 @@ const CoordinationType$1 = {
9760
9771
  OBS_SET_HIGHLIGHT: "obsSetHighlight",
9761
9772
  OBS_SET_EXPANSION: "obsSetExpansion",
9762
9773
  OBS_SET_COLOR: "obsSetColor",
9774
+ FEATURE_COLOR: "featureColor",
9763
9775
  FEATURE_HIGHLIGHT: "featureHighlight",
9764
9776
  FEATURE_SELECTION: "featureSelection",
9765
9777
  FEATURE_SET_SELECTION: "featureSetSelection",
@@ -10337,6 +10349,8 @@ const COMPONENT_COORDINATION_TYPES = {
10337
10349
  CoordinationType$1.OBS_SET_FILTER,
10338
10350
  CoordinationType$1.OBS_SET_HIGHLIGHT,
10339
10351
  CoordinationType$1.OBS_SET_COLOR,
10352
+ CoordinationType$1.FEATURE_COLOR,
10353
+ CoordinationType$1.FEATURE_FILTER_MODE,
10340
10354
  CoordinationType$1.FEATURE_HIGHLIGHT,
10341
10355
  CoordinationType$1.FEATURE_SELECTION,
10342
10356
  CoordinationType$1.FEATURE_VALUE_COLORMAP,
@@ -10551,6 +10565,8 @@ const COMPONENT_COORDINATION_TYPES = {
10551
10565
  CoordinationType$1.SPATIAL_SPOT_STROKE_WIDTH,
10552
10566
  CoordinationType$1.SPATIAL_LAYER_COLOR,
10553
10567
  CoordinationType$1.OBS_COLOR_ENCODING,
10568
+ CoordinationType$1.FEATURE_COLOR,
10569
+ CoordinationType$1.FEATURE_FILTER_MODE,
10554
10570
  CoordinationType$1.FEATURE_VALUE_COLORMAP,
10555
10571
  CoordinationType$1.FEATURE_VALUE_COLORMAP_RANGE,
10556
10572
  CoordinationType$1.FEATURE_SELECTION,
@@ -11123,7 +11139,9 @@ const obsSegmentationsSpatialdataSchema = z.object({
11123
11139
  const obsPointsSpatialdataSchema = z.object({
11124
11140
  path: z.string().describe("The path to the point data."),
11125
11141
  tablePath: z.string().optional().describe("The path to a table which annotates the points. If available but not specified, the spot identifiers may not be aligned with associated tabular data as expected."),
11126
- coordinateSystem: z.string().optional().describe('The name of a coordinate transformation output used to transform the image. If not provided, the "global" coordinate system is assumed.')
11142
+ coordinateSystem: z.string().optional().describe('The name of a coordinate transformation output used to transform the image. If not provided, the "global" coordinate system is assumed.'),
11143
+ featureIndexColumn: z.string().optional().describe("The name of the column in the table which contains the feature (e.g., gene) indices associated with each point (aligned with the table var.index dataframe column)."),
11144
+ mortonCodeColumn: z.string().optional().describe('The name of the column in the table which contains the Morton codes for each point, used for efficient spatial querying. If not provided, Vitessce will assume the default column name "morton_code_2d".')
11127
11145
  });
11128
11146
  z.object({
11129
11147
  path: z.string(),
@@ -33776,6 +33794,7 @@ function Legend(props) {
33776
33794
  positionRelative = false,
33777
33795
  highContrast = false,
33778
33796
  obsType,
33797
+ isPointsLayer = false,
33779
33798
  // eslint-disable-next-line @typescript-eslint/no-unused-vars
33780
33799
  featureType: _featureType = void 0,
33781
33800
  // Unused but accepted for API compatibility
@@ -33783,6 +33802,9 @@ function Legend(props) {
33783
33802
  considerSelections = true,
33784
33803
  obsColorEncoding,
33785
33804
  featureSelection,
33805
+ featureFilterMode,
33806
+ featureColor,
33807
+ featureIndex,
33786
33808
  featureLabelsMap,
33787
33809
  featureValueColormap,
33788
33810
  featureValueColormapRange,
@@ -33826,15 +33848,95 @@ function Legend(props) {
33826
33848
  debouncedSetRange(rangeValue);
33827
33849
  }
33828
33850
  }, [debouncedSetRange]);
33851
+ const obsLabel = capitalize$2(obsType ?? null);
33829
33852
  const isDarkTheme = theme === "dark";
33830
- const isStaticColor = obsColorEncoding === "spatialChannelColor" || obsColorEncoding === "spatialLayerColor";
33831
- const isSetColor = obsColorEncoding === "cellSetSelection";
33853
+ const isStaticColor = !isPointsLayer && (obsColorEncoding === "spatialChannelColor" || obsColorEncoding === "spatialLayerColor");
33854
+ const isSetColor = !isPointsLayer && obsColorEncoding === "cellSetSelection";
33832
33855
  const layerColor = Array.isArray(spatialLayerColor) && spatialLayerColor.length === 3 ? spatialLayerColor : getDefaultColor(theme ?? "light");
33833
33856
  const channelColor = Array.isArray(spatialChannelColor) && spatialChannelColor.length === 3 ? spatialChannelColor : getDefaultColor(theme ?? "light");
33834
33857
  const staticColor = obsColorEncoding === "spatialChannelColor" ? channelColor : layerColor;
33835
- const visible = visibleProp && (!considerSelections || ["geneSelection", "geneExpression"].includes(obsColorEncoding ?? "") && featureSelection && Array.isArray(featureSelection) && featureSelection.length >= 1 || isSetColor && ((obsSetSelection == null ? void 0 : obsSetSelection.length) ?? 0) > 0 && ((obsSetColor == null ? void 0 : obsSetColor.length) ?? 0) > 0 || isStaticColor);
33858
+ const visible = visibleProp && (!considerSelections || ["geneSelection", "geneExpression"].includes(obsColorEncoding ?? "") && featureSelection && Array.isArray(featureSelection) && featureSelection.length >= 1 || isSetColor && ((obsSetSelection == null ? void 0 : obsSetSelection.length) ?? 0) > 0 && ((obsSetColor == null ? void 0 : obsSetColor.length) ?? 0) > 0 || isStaticColor || isPointsLayer);
33859
+ const pointsLegendElements = [];
33860
+ if (isPointsLayer) {
33861
+ const MAX_NUM_COLORS = 10;
33862
+ const hasFeatureSelection = Array.isArray(featureSelection) && featureSelection.length > 0;
33863
+ const showUnselected = featureFilterMode !== "featureSelection";
33864
+ if (obsColorEncoding === "spatialLayerColor") {
33865
+ if (!hasFeatureSelection) {
33866
+ pointsLegendElements.push({
33867
+ name: obsLabel,
33868
+ color: staticColor
33869
+ });
33870
+ } else {
33871
+ const limitedFeatureSelection = featureSelection.slice(0, MAX_NUM_COLORS);
33872
+ limitedFeatureSelection.forEach((featureName) => {
33873
+ pointsLegendElements.push({
33874
+ name: featureName,
33875
+ color: staticColor
33876
+ });
33877
+ });
33878
+ }
33879
+ } else if (obsColorEncoding === "geneSelection") {
33880
+ if (!hasFeatureSelection) {
33881
+ pointsLegendElements.push({
33882
+ name: obsLabel,
33883
+ color: staticColor
33884
+ });
33885
+ } else {
33886
+ const limitedFeatureSelection = featureSelection.slice(0, MAX_NUM_COLORS);
33887
+ limitedFeatureSelection.forEach((featureName) => {
33888
+ var _a3;
33889
+ const featureColorMatch = Array.isArray(featureColor) ? (_a3 = featureColor.find((fc) => fc.name === featureName)) == null ? void 0 : _a3.color : null;
33890
+ pointsLegendElements.push({
33891
+ name: featureName,
33892
+ // If no color is specified for this feature, use staticColor.
33893
+ color: featureColorMatch ?? staticColor
33894
+ });
33895
+ });
33896
+ }
33897
+ } else if (obsColorEncoding === "randomByFeature") {
33898
+ if (!hasFeatureSelection) {
33899
+ pointsLegendElements.push({
33900
+ name: obsLabel,
33901
+ // For now, using black and white for this.
33902
+ // (It should not match any color in PALETTE)
33903
+ color: isDarkTheme ? [255, 255, 255] : [0, 0, 0]
33904
+ });
33905
+ } else {
33906
+ const limitedFeatureSelection = featureSelection.slice(0, MAX_NUM_COLORS);
33907
+ limitedFeatureSelection.forEach((featureName) => {
33908
+ const varIndex = (featureIndex ?? []).indexOf(featureName);
33909
+ const featureColorMatch = varIndex >= 0 ? PALETTE[varIndex % PALETTE.length] : null;
33910
+ pointsLegendElements.push({
33911
+ name: featureName,
33912
+ // If no color is specified for this feature, use staticColor.
33913
+ color: featureColorMatch ?? staticColor
33914
+ });
33915
+ });
33916
+ }
33917
+ } else if (obsColorEncoding === "random") {
33918
+ pointsLegendElements.push({
33919
+ name: obsLabel,
33920
+ // For now, using black and white for this.
33921
+ // (It should not match any color in PALETTE)
33922
+ color: isDarkTheme ? [255, 255, 255] : [0, 0, 0]
33923
+ });
33924
+ }
33925
+ if (showUnselected) {
33926
+ pointsLegendElements.push({
33927
+ name: "Unselected",
33928
+ color: getDefaultColor(theme ?? "light")
33929
+ });
33930
+ }
33931
+ }
33836
33932
  const levelZeroNames = useMemo(() => Array.from(new Set((obsSetSelection == null ? void 0 : obsSetSelection.map((setPath) => setPath[0])) || [])), [obsSetSelection]);
33837
- const dynamicHeight = isSetColor && obsSetSelection ? levelZeroNames.length * titleHeight + ((obsSetSelection == null ? void 0 : obsSetSelection.length) ?? 0) * (rectHeight + rectMarginY) : height2 + (!pointsVisible && contoursVisible ? 25 : 0);
33933
+ const dynamicHeight = isPointsLayer ? (
33934
+ // Height logic for points layers.
33935
+ pointsLegendElements.length * (rectHeight + rectMarginY) + titleHeight
33936
+ ) : (
33937
+ // Height logic for non-points layers.
33938
+ isSetColor && obsSetSelection ? levelZeroNames.length * titleHeight + ((obsSetSelection == null ? void 0 : obsSetSelection.length) ?? 0) * (rectHeight + rectMarginY) : height2 + (!pointsVisible && contoursVisible ? 25 : 0)
33939
+ );
33838
33940
  const availHeight = maxHeight2 !== null ? Math.max(0, maxHeight2 - 4) : Infinity;
33839
33941
  const needsScroll = Number.isFinite(availHeight) && dynamicHeight > availHeight + 1;
33840
33942
  useEffect(() => {
@@ -33846,8 +33948,8 @@ function Legend(props) {
33846
33948
  svg.selectAll("g").remove();
33847
33949
  svg.attr("width", width2).attr("height", dynamicHeight);
33848
33950
  const g2 = svg.append("g").attr("width", width2).attr("height", dynamicHeight);
33849
- const showInteractiveSlider2 = setFeatureValueColormapRange && ["geneSelection", "geneExpression"].includes(obsColorEncoding ?? "") && pointsVisible && featureValueColormap;
33850
- if (!considerSelections || ["geneSelection", "geneExpression"].includes(obsColorEncoding ?? "")) {
33951
+ const showInteractiveSlider2 = !isPointsLayer && setFeatureValueColormapRange && ["geneSelection", "geneExpression"].includes(obsColorEncoding ?? "") && pointsVisible && featureValueColormap;
33952
+ if (!isPointsLayer && (!considerSelections || ["geneSelection", "geneExpression"].includes(obsColorEncoding ?? ""))) {
33851
33953
  const combinedExtent = combineExtents(extent2 ?? null, featureAggregationStrategy ?? null) || [0, 1];
33852
33954
  const [xMin, xMax] = combinedExtent;
33853
33955
  if (featureValueColormap && pointsVisible) {
@@ -33907,10 +34009,10 @@ function Legend(props) {
33907
34009
  });
33908
34010
  }
33909
34011
  }
33910
- if (isStaticColor) {
34012
+ if (!isPointsLayer && isStaticColor) {
33911
34013
  g2.append("rect").attr("x", 0).attr("y", titleHeight).attr("width", width2 - 4).attr("height", rectHeight).attr("fill", `rgb(${staticColor[0]},${staticColor[1]},${staticColor[2]})`);
33912
34014
  }
33913
- if (isSetColor && obsSetSelection && obsSetColor) {
34015
+ if (!isPointsLayer && isSetColor && obsSetSelection && obsSetColor) {
33914
34016
  const obsSetSelectionByLevelZero = {};
33915
34017
  obsSetSelection.forEach((setPath) => {
33916
34018
  const levelZeroName = setPath[0];
@@ -33932,6 +34034,16 @@ function Legend(props) {
33932
34034
  });
33933
34035
  });
33934
34036
  }
34037
+ if (isPointsLayer) {
34038
+ let y = 0;
34039
+ g2.append("text").attr("text-anchor", "start").attr("dominant-baseline", "hanging").attr("x", 0).attr("y", y).text("Points").style("font-size", "9px").style("fill", foregroundColor);
34040
+ y += titleHeight;
34041
+ pointsLegendElements.forEach(({ name: name2, color: color2 }) => {
34042
+ g2.append("rect").attr("x", 0).attr("y", y).attr("width", rectHeight).attr("height", rectHeight).attr("fill", `rgb(${color2[0]},${color2[1]},${color2[2]})`);
34043
+ g2.append("text").attr("text-anchor", "start").attr("dominant-baseline", "hanging").attr("x", rectHeight + rectMarginX).attr("y", y).text(name2).style("font-size", "9px").style("fill", foregroundColor);
34044
+ y += rectHeight + rectMarginY;
34045
+ });
34046
+ }
33935
34047
  const featureSelectionLabelRaw = featureSelection && featureSelection.length >= 1 && !isStaticColor ? featureSelection.map((geneName) => (featureLabelsMap == null ? void 0 : featureLabelsMap.get(geneName)) || (featureLabelsMap == null ? void 0 : featureLabelsMap.get(cleanFeatureId(geneName))) || geneName) : null;
33936
34048
  let featureSelectionLabelRawStr = "";
33937
34049
  if (featureAggregationStrategy === "first") {
@@ -33958,12 +34070,11 @@ function Legend(props) {
33958
34070
  }
33959
34071
  const combinedMissing = combineMissings(missing ?? null, featureAggregationStrategy ?? null);
33960
34072
  const featureSelectionLabel = combinedMissing ? `${featureSelectionLabelRawStr} (${Math.round(combinedMissing * 100)}% NaN)` : featureSelectionLabelRawStr;
33961
- const obsLabel = capitalize$2(obsType ?? null);
33962
34073
  const featureLabel = considerSelections ? featureSelectionLabel || capitalize$2(featureValueType ?? null) : capitalize$2(featureValueType ?? null);
33963
34074
  const mainLabel = showObsLabel ? obsLabel : featureLabel;
33964
34075
  const subLabel = showObsLabel ? featureLabel : null;
33965
34076
  const hasSubLabel = subLabel !== null;
33966
- if (!isSetColor) {
34077
+ if (!isPointsLayer && !isSetColor) {
33967
34078
  g2.append("text").attr("text-anchor", hasSubLabel ? "start" : "end").attr("dominant-baseline", "hanging").attr("x", hasSubLabel ? 0 : width2 - 4).attr("y", 0).text(mainLabel ?? "").style("font-size", "10px").style("fill", foregroundColor);
33968
34079
  if (hasSubLabel) {
33969
34080
  g2.append("text").attr("text-anchor", "end").attr("dominant-baseline", "hanging").attr("x", width2 - 5).attr("y", titleHeight + rectHeight).text(subLabel ?? "").style("font-size", "9px").style("fill", foregroundColor);
@@ -34002,7 +34113,7 @@ function Legend(props) {
34002
34113
  showObsLabel,
34003
34114
  staticColor
34004
34115
  ]);
34005
- const showInteractiveSlider = setFeatureValueColormapRange && ["geneSelection", "geneExpression"].includes(obsColorEncoding ?? "") && pointsVisible && featureValueColormap;
34116
+ const showInteractiveSlider = !isPointsLayer && setFeatureValueColormapRange && ["geneSelection", "geneExpression"].includes(obsColorEncoding ?? "") && pointsVisible && featureValueColormap;
34006
34117
  const globalExtent = useMemo(() => {
34007
34118
  const combined = combineExtents(extent2 ?? null, featureAggregationStrategy ?? null);
34008
34119
  return combined || [0, 1];
@@ -138072,22 +138183,22 @@ function addDecoder(cases, importFn) {
138072
138183
  }
138073
138184
  cases.forEach((c) => registry$1.set(c, importFn));
138074
138185
  }
138075
- addDecoder([void 0, 1], () => import("./raw-DBEZoTXk.js").then((m) => m.default));
138076
- addDecoder(5, () => import("./lzw-DIDyT49t.js").then((m) => m.default));
138186
+ addDecoder([void 0, 1], () => import("./raw-BY4wlPHH.js").then((m) => m.default));
138187
+ addDecoder(5, () => import("./lzw-Cvt0LkXw.js").then((m) => m.default));
138077
138188
  addDecoder(6, () => {
138078
138189
  throw new Error("old style JPEG compression is not supported.");
138079
138190
  });
138080
- addDecoder(7, () => import("./jpeg-BQH57nGA.js").then((m) => m.default));
138081
- addDecoder([8, 32946], () => import("./deflate-C6kM_d3H.js").then((m) => m.default));
138082
- addDecoder(32773, () => import("./packbits-x4mUZGOp.js").then((m) => m.default));
138191
+ addDecoder(7, () => import("./jpeg-DHh36Lwj.js").then((m) => m.default));
138192
+ addDecoder([8, 32946], () => import("./deflate-CtXZgCAW.js").then((m) => m.default));
138193
+ addDecoder(32773, () => import("./packbits-5TE0g68q.js").then((m) => m.default));
138083
138194
  addDecoder(
138084
138195
  34887,
138085
- () => import("./lerc-Bcypgvlf.js").then(async (m) => {
138196
+ () => import("./lerc-DWs1G17t.js").then(async (m) => {
138086
138197
  await m.zstd.init();
138087
138198
  return m;
138088
138199
  }).then((m) => m.default)
138089
138200
  );
138090
- addDecoder(50001, () => import("./webimage-DNvdSc-_.js").then((m) => m.default));
138201
+ addDecoder(50001, () => import("./webimage-CikUgHwn.js").then((m) => m.default));
138091
138202
  function decodeRowAcc(row, stride) {
138092
138203
  let length2 = row.length - stride;
138093
138204
  let offset2 = 0;
package/dist/index.js CHANGED
@@ -1,4 +1,4 @@
1
- import { a, H } from "./index-BB2ssozJ.js";
1
+ import { a, H } from "./index-DgJedZPO.js";
2
2
  export {
3
3
  a as Heatmap,
4
4
  H as HeatmapSubscriber
@@ -1,4 +1,4 @@
1
- import { B as BaseDecoder } from "./index-BB2ssozJ.js";
1
+ import { B as BaseDecoder } from "./index-DgJedZPO.js";
2
2
  const dctZigZag = new Int32Array([
3
3
  0,
4
4
  1,
@@ -1,5 +1,5 @@
1
1
  import { i as inflate_1 } from "./pako.esm-SxljTded.js";
2
- import { g as getDefaultExportFromCjs, B as BaseDecoder } from "./index-BB2ssozJ.js";
2
+ import { g as getDefaultExportFromCjs, B as BaseDecoder } from "./index-DgJedZPO.js";
3
3
  const LercParameters = {
4
4
  AddCompression: 1
5
5
  };
@@ -1,4 +1,4 @@
1
- import { B as BaseDecoder } from "./index-BB2ssozJ.js";
1
+ import { B as BaseDecoder } from "./index-DgJedZPO.js";
2
2
  const MIN_BITS = 9;
3
3
  const CLEAR_CODE = 256;
4
4
  const EOI_CODE = 257;
@@ -1,4 +1,4 @@
1
- import { B as BaseDecoder } from "./index-BB2ssozJ.js";
1
+ import { B as BaseDecoder } from "./index-DgJedZPO.js";
2
2
  class PackbitsDecoder extends BaseDecoder {
3
3
  decodeBlock(buffer) {
4
4
  const dataView = new DataView(buffer);
@@ -1,4 +1,4 @@
1
- import { B as BaseDecoder } from "./index-BB2ssozJ.js";
1
+ import { B as BaseDecoder } from "./index-DgJedZPO.js";
2
2
  class RawDecoder extends BaseDecoder {
3
3
  decodeBlock(buffer) {
4
4
  return buffer;
@@ -1,4 +1,4 @@
1
- import { B as BaseDecoder } from "./index-BB2ssozJ.js";
1
+ import { B as BaseDecoder } from "./index-DgJedZPO.js";
2
2
  class WebImageDecoder extends BaseDecoder {
3
3
  constructor() {
4
4
  super();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vitessce/heatmap",
3
- "version": "3.8.13",
3
+ "version": "3.9.1",
4
4
  "author": "HIDIVE Lab at HMS",
5
5
  "homepage": "http://vitessce.io",
6
6
  "repository": {
@@ -19,15 +19,15 @@
19
19
  "lodash-es": "^4.17.21",
20
20
  "uuid": "^9.0.0",
21
21
  "react-aria": "^3.28.0",
22
- "@vitessce/styles": "3.8.13",
23
- "@vitessce/constants-internal": "3.8.13",
24
- "@vitessce/gl": "3.8.13",
25
- "@vitessce/sets-utils": "3.8.13",
26
- "@vitessce/tooltip": "3.8.13",
27
- "@vitessce/utils": "3.8.13",
28
- "@vitessce/legend": "3.8.13",
29
- "@vitessce/vit-s": "3.8.13",
30
- "@vitessce/workers": "3.8.13"
22
+ "@vitessce/styles": "3.9.1",
23
+ "@vitessce/gl": "3.9.1",
24
+ "@vitessce/constants-internal": "3.9.1",
25
+ "@vitessce/legend": "3.9.1",
26
+ "@vitessce/sets-utils": "3.9.1",
27
+ "@vitessce/utils": "3.9.1",
28
+ "@vitessce/tooltip": "3.9.1",
29
+ "@vitessce/workers": "3.9.1",
30
+ "@vitessce/vit-s": "3.9.1"
31
31
  },
32
32
  "devDependencies": {
33
33
  "@testing-library/jest-dom": "^6.6.3",