@vitessce/scatterplot-embedding 3.8.7 → 3.8.9

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-DXCCF6LM.js";
2
+ import { B as BaseDecoder } from "./index-DYO3tfis.js";
3
3
  class DeflateDecoder extends BaseDecoder {
4
4
  decodeBlock(buffer) {
5
5
  return inflate_1(new Uint8Array(buffer)).buffer;
@@ -3098,6 +3098,59 @@ const PALETTE = [
3098
3098
  [136, 34, 85],
3099
3099
  [170, 68, 153]
3100
3100
  ];
3101
+ function aggregateFeatureArrays(arrays, strategy) {
3102
+ if (!arrays || arrays.length === 0)
3103
+ return null;
3104
+ let targetArray;
3105
+ if (strategy === "first" || typeof strategy === "number" && strategy === 0) {
3106
+ targetArray = arrays[0];
3107
+ } else if (strategy === "last") {
3108
+ targetArray = arrays[arrays.length - 1];
3109
+ } else if (typeof strategy === "number") {
3110
+ if (strategy >= 0 && strategy < arrays.length) {
3111
+ targetArray = arrays[strategy];
3112
+ } else {
3113
+ throw new Error(`Array index out of bounds: ${strategy}`);
3114
+ }
3115
+ }
3116
+ if (targetArray) {
3117
+ return targetArray;
3118
+ }
3119
+ const numArrays = arrays.length;
3120
+ const firstArrayLength = arrays[0].length;
3121
+ if (arrays.some((arr) => arr.length !== firstArrayLength)) {
3122
+ throw new Error("All arrays must have the same length for aggregation.");
3123
+ }
3124
+ if (strategy === "sum" || strategy === "mean") {
3125
+ const resultArray = new Float64Array(firstArrayLength);
3126
+ for (let i2 = 0; i2 < numArrays; i2++) {
3127
+ const arr = arrays[i2];
3128
+ for (let j = 0; j < firstArrayLength; j++) {
3129
+ resultArray[j] += arr[j];
3130
+ }
3131
+ }
3132
+ if (strategy === "mean") {
3133
+ for (let i2 = 0; i2 < firstArrayLength; i2++) {
3134
+ resultArray[i2] /= numArrays;
3135
+ }
3136
+ }
3137
+ return resultArray;
3138
+ }
3139
+ if (strategy === "difference") {
3140
+ if (numArrays !== 2) {
3141
+ console.warn("Difference strategy requires exactly 2 arrays.");
3142
+ return arrays[0];
3143
+ }
3144
+ const arr0 = arrays[0];
3145
+ const arr1 = arrays[1];
3146
+ const resultArray = new Float64Array(firstArrayLength);
3147
+ for (let i2 = 0; i2 < firstArrayLength; i2++) {
3148
+ resultArray[i2] = arr0[i2] - arr1[i2];
3149
+ }
3150
+ return resultArray;
3151
+ }
3152
+ throw new Error(`Unknown aggregation strategy: ${strategy}`);
3153
+ }
3101
3154
  var util;
3102
3155
  (function(util2) {
3103
3156
  util2.assertEqual = (val) => val;
@@ -123348,22 +123401,22 @@ function addDecoder(cases, importFn) {
123348
123401
  }
123349
123402
  cases.forEach((c2) => registry$1.set(c2, importFn));
123350
123403
  }
123351
- addDecoder([void 0, 1], () => import("./raw-CBdLq0ga.js").then((m2) => m2.default));
123352
- addDecoder(5, () => import("./lzw-Dbo7OpaS.js").then((m2) => m2.default));
123404
+ addDecoder([void 0, 1], () => import("./raw-xM2f2nBA.js").then((m2) => m2.default));
123405
+ addDecoder(5, () => import("./lzw-B2nz96hr.js").then((m2) => m2.default));
123353
123406
  addDecoder(6, () => {
123354
123407
  throw new Error("old style JPEG compression is not supported.");
123355
123408
  });
123356
- addDecoder(7, () => import("./jpeg-UKzKGs1t.js").then((m2) => m2.default));
123357
- addDecoder([8, 32946], () => import("./deflate-Dr6bxD0w.js").then((m2) => m2.default));
123358
- addDecoder(32773, () => import("./packbits-0X-GrQId.js").then((m2) => m2.default));
123409
+ addDecoder(7, () => import("./jpeg-BBSvSY8b.js").then((m2) => m2.default));
123410
+ addDecoder([8, 32946], () => import("./deflate-YIIHzd8y.js").then((m2) => m2.default));
123411
+ addDecoder(32773, () => import("./packbits-JodEChjB.js").then((m2) => m2.default));
123359
123412
  addDecoder(
123360
123413
  34887,
123361
- () => import("./lerc-D62tGpqi.js").then(async (m2) => {
123414
+ () => import("./lerc-DsiDEIic.js").then(async (m2) => {
123362
123415
  await m2.zstd.init();
123363
123416
  return m2;
123364
123417
  }).then((m2) => m2.default)
123365
123418
  );
123366
- addDecoder(50001, () => import("./webimage-C2vUudNG.js").then((m2) => m2.default));
123419
+ addDecoder(50001, () => import("./webimage-Bk5jq0He.js").then((m2) => m2.default));
123367
123420
  function decodeRowAcc(row, stride) {
123368
123421
  let length2 = row.length - stride;
123369
123422
  let offset2 = 0;
@@ -153768,11 +153821,18 @@ function EmbeddingScatterplotSubscriber(props) {
153768
153821
  const getCellIsSelected = useCallback((object2, { index: index2 }) => (cellSelectionSet || /* @__PURE__ */ new Set([])).has(obsEmbeddingIndex[index2]) ? 1 : 0, [cellSelectionSet, obsEmbeddingIndex]);
153769
153822
  const cellRadius = cellRadiusMode === "manual" ? cellRadiusFixed : dynamicCellRadius;
153770
153823
  const cellOpacity = cellOpacityMode === "manual" ? cellOpacityFixed : dynamicCellOpacity;
153824
+ const aggregatedExpressionData = useMemo(() => {
153825
+ if (featureAggregationStrategyToUse != null && expressionData && expressionData.length > 1) {
153826
+ const aggregated = aggregateFeatureArrays(expressionData, featureAggregationStrategyToUse);
153827
+ return [aggregated];
153828
+ }
153829
+ return expressionData;
153830
+ }, [expressionData, featureAggregationStrategyToUse]);
153771
153831
  const {
153772
153832
  normData: uint8ExpressionData,
153773
153833
  extents: expressionExtents,
153774
153834
  missing: expressionMissing
153775
- } = useUint8FeatureSelection(expressionData);
153835
+ } = useUint8FeatureSelection(aggregatedExpressionData);
153776
153836
  const getExpressionValue = useExpressionValueGetter({
153777
153837
  instanceObsIndex: obsEmbeddingIndex,
153778
153838
  matrixObsIndex,
package/dist/index.js CHANGED
@@ -1,4 +1,4 @@
1
- import { D, E } from "./index-DXCCF6LM.js";
1
+ import { D, E } from "./index-DYO3tfis.js";
2
2
  export {
3
3
  D as DualEmbeddingScatterplotSubscriber,
4
4
  E as EmbeddingScatterplotSubscriber
@@ -1,4 +1,4 @@
1
- import { B as BaseDecoder } from "./index-DXCCF6LM.js";
1
+ import { B as BaseDecoder } from "./index-DYO3tfis.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-DXCCF6LM.js";
2
+ import { g as getDefaultExportFromCjs, B as BaseDecoder } from "./index-DYO3tfis.js";
3
3
  const LercParameters = {
4
4
  AddCompression: 1
5
5
  };
@@ -1,4 +1,4 @@
1
- import { B as BaseDecoder } from "./index-DXCCF6LM.js";
1
+ import { B as BaseDecoder } from "./index-DYO3tfis.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-DXCCF6LM.js";
1
+ import { B as BaseDecoder } from "./index-DYO3tfis.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-DXCCF6LM.js";
1
+ import { B as BaseDecoder } from "./index-DYO3tfis.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-DXCCF6LM.js";
1
+ import { B as BaseDecoder } from "./index-DYO3tfis.js";
2
2
  class WebImageDecoder extends BaseDecoder {
3
3
  constructor() {
4
4
  super();
@@ -1 +1 @@
1
- {"version":3,"file":"EmbeddingScatterplotSubscriber.d.ts","sourceRoot":"","sources":["../src/EmbeddingScatterplotSubscriber.js"],"names":[],"mappings":"AA6CA;;;;;;;;;;;;GAYG;AACH,sDAVG;IAAsB,IAAI,EAAlB,MAAM;IACQ,KAAK,EAAnB,MAAM;IACQ,kBAAkB,EAAhC,MAAM;IAEU,mBAAmB;IAErB,KAAK,EAAnB,MAAM;IACQ,kBAAkB,EAAhC,MAAM;CAEhB,eAimBA"}
1
+ {"version":3,"file":"EmbeddingScatterplotSubscriber.d.ts","sourceRoot":"","sources":["../src/EmbeddingScatterplotSubscriber.js"],"names":[],"mappings":"AA6CA;;;;;;;;;;;;GAYG;AACH,sDAVG;IAAsB,IAAI,EAAlB,MAAM;IACQ,KAAK,EAAnB,MAAM;IACQ,kBAAkB,EAAhC,MAAM;IAEU,mBAAmB;IAErB,KAAK,EAAnB,MAAM;IACQ,kBAAkB,EAAhC,MAAM;CAEhB,eA4mBA"}
@@ -5,7 +5,7 @@ import { isEqual } from 'lodash-es';
5
5
  import { circle } from '@turf/circle';
6
6
  import { TitleInfo, useReady, useUrls, useDeckCanvasSize, useUint8FeatureSelection, useExpressionValueGetter, useGetObsInfo, useObsEmbeddingData, useObsSetsData, useFeatureSelection, useObsFeatureMatrixIndices, useFeatureLabelsData, useMultiObsLabels, useSampleSetsData, useSampleEdgesData, useCoordination, useLoaders, useSetComponentHover, useSetComponentViewInfo, useInitialCoordination, useExpandedFeatureLabelsMap, useCoordinationScopes, } from '@vitessce/vit-s';
7
7
  import { setObsSelection, mergeObsSets, getCellSetPolygons, getCellColors, stratifyArrays, } from '@vitessce/sets-utils';
8
- import { pluralize as plur, commaNumber } from '@vitessce/utils';
8
+ import { pluralize as plur, commaNumber, aggregateFeatureArrays } from '@vitessce/utils';
9
9
  import { Scatterplot, ScatterplotTooltipSubscriber, ScatterplotOptions, getPointSizeDevicePixels, getPointOpacity, } from '@vitessce/scatterplot';
10
10
  import { Legend } from '@vitessce/legend';
11
11
  import { ViewType, COMPONENT_COORDINATION_TYPES, ViewHelpMapping } from '@vitessce/constants-internal';
@@ -182,7 +182,17 @@ export function EmbeddingScatterplotSubscriber(props) {
182
182
  const getCellIsSelected = useCallback((object, { index }) => ((cellSelectionSet || new Set([])).has(obsEmbeddingIndex[index]) ? 1.0 : 0.0), [cellSelectionSet, obsEmbeddingIndex]);
183
183
  const cellRadius = (cellRadiusMode === 'manual' ? cellRadiusFixed : dynamicCellRadius);
184
184
  const cellOpacity = (cellOpacityMode === 'manual' ? cellOpacityFixed : dynamicCellOpacity);
185
- const { normData: uint8ExpressionData, extents: expressionExtents, missing: expressionMissing, } = useUint8FeatureSelection(expressionData);
185
+ // Compute aggregated expression data if featureAggregationStrategyToUse is not null
186
+ // and we have multiple features to aggregate.
187
+ const aggregatedExpressionData = useMemo(() => {
188
+ if (featureAggregationStrategyToUse != null && expressionData && expressionData.length > 1) {
189
+ const aggregated = aggregateFeatureArrays(expressionData, featureAggregationStrategyToUse);
190
+ // Return as array with single element to match expressionData structure
191
+ return [aggregated];
192
+ }
193
+ return expressionData;
194
+ }, [expressionData, featureAggregationStrategyToUse]);
195
+ const { normData: uint8ExpressionData, extents: expressionExtents, missing: expressionMissing, } = useUint8FeatureSelection(aggregatedExpressionData);
186
196
  // Set up a getter function for gene expression values, to be used
187
197
  // by the DeckGL layer to obtain values for instanced attributes.
188
198
  const getExpressionValue = useExpressionValueGetter({
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vitessce/scatterplot-embedding",
3
- "version": "3.8.7",
3
+ "version": "3.8.9",
4
4
  "author": "HIDIVE Lab at HMS",
5
5
  "homepage": "http://vitessce.io",
6
6
  "repository": {
@@ -20,13 +20,13 @@
20
20
  "lodash-es": "^4.17.21",
21
21
  "react-aria": "^3.28.0",
22
22
  "@turf/circle": "^7.2.0",
23
- "@vitessce/styles": "3.8.7",
24
- "@vitessce/constants-internal": "3.8.7",
25
- "@vitessce/legend": "3.8.7",
26
- "@vitessce/scatterplot": "3.8.7",
27
- "@vitessce/sets-utils": "3.8.7",
28
- "@vitessce/utils": "3.8.7",
29
- "@vitessce/vit-s": "3.8.7"
23
+ "@vitessce/styles": "3.8.9",
24
+ "@vitessce/constants-internal": "3.8.9",
25
+ "@vitessce/legend": "3.8.9",
26
+ "@vitessce/scatterplot": "3.8.9",
27
+ "@vitessce/sets-utils": "3.8.9",
28
+ "@vitessce/utils": "3.8.9",
29
+ "@vitessce/vit-s": "3.8.9"
30
30
  },
31
31
  "devDependencies": {
32
32
  "react": "18.3.1",
@@ -31,7 +31,7 @@ import {
31
31
  setObsSelection, mergeObsSets, getCellSetPolygons, getCellColors,
32
32
  stratifyArrays,
33
33
  } from '@vitessce/sets-utils';
34
- import { pluralize as plur, commaNumber } from '@vitessce/utils';
34
+ import { pluralize as plur, commaNumber, aggregateFeatureArrays } from '@vitessce/utils';
35
35
  import {
36
36
  Scatterplot, ScatterplotTooltipSubscriber, ScatterplotOptions,
37
37
  getPointSizeDevicePixels,
@@ -365,7 +365,7 @@ export function EmbeddingScatterplotSubscriber(props) {
365
365
  setOriginalViewState({ target: [initialTargetX, initialTargetY, 0], zoom: initialZoom });
366
366
  }
367
367
  }
368
- // eslint-disable-next-line react-hooks/exhaustive-deps
368
+ // eslint-disable-next-line react-hooks/exhaustive-deps
369
369
  }, [xRange, yRange, xExtent, yExtent, numCells,
370
370
  width, height, initialZoom, zoom, initialTargetX, initialTargetY, averageFillDensity]);
371
371
 
@@ -381,11 +381,22 @@ export function EmbeddingScatterplotSubscriber(props) {
381
381
  const cellRadius = (cellRadiusMode === 'manual' ? cellRadiusFixed : dynamicCellRadius);
382
382
  const cellOpacity = (cellOpacityMode === 'manual' ? cellOpacityFixed : dynamicCellOpacity);
383
383
 
384
+ // Compute aggregated expression data if featureAggregationStrategyToUse is not null
385
+ // and we have multiple features to aggregate.
386
+ const aggregatedExpressionData = useMemo(() => {
387
+ if (featureAggregationStrategyToUse != null && expressionData && expressionData.length > 1) {
388
+ const aggregated = aggregateFeatureArrays(expressionData, featureAggregationStrategyToUse);
389
+ // Return as array with single element to match expressionData structure
390
+ return [aggregated];
391
+ }
392
+ return expressionData;
393
+ }, [expressionData, featureAggregationStrategyToUse]);
394
+
384
395
  const {
385
396
  normData: uint8ExpressionData,
386
397
  extents: expressionExtents,
387
398
  missing: expressionMissing,
388
- } = useUint8FeatureSelection(expressionData);
399
+ } = useUint8FeatureSelection(aggregatedExpressionData);
389
400
 
390
401
  // Set up a getter function for gene expression values, to be used
391
402
  // by the DeckGL layer to obtain values for instanced attributes.