@vitessce/statistical-plots 3.5.10 → 3.5.11

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 (35) hide show
  1. package/dist/{deflate-ad0dcbe4.js → deflate-b8c6daae.js} +1 -1
  2. package/dist/{index-b8398176.js → index-134a71c6.js} +224 -80
  3. package/dist/index.js +1 -1
  4. package/dist/{jpeg-81bd1053.js → jpeg-1b818d11.js} +1 -1
  5. package/dist/{lerc-b15c3a4c.js → lerc-f38cbdfc.js} +1 -1
  6. package/dist/{lzw-503cb795.js → lzw-1120aba9.js} +1 -1
  7. package/dist/{packbits-40cbad40.js → packbits-2d02b5e3.js} +1 -1
  8. package/dist/{raw-9b8d9daf.js → raw-0887baec.js} +1 -1
  9. package/dist/{webimage-bbc59b4a.js → webimage-533922a5.js} +1 -1
  10. package/dist-tsc/CellSetCompositionBarPlot.d.ts.map +1 -1
  11. package/dist-tsc/CellSetCompositionBarPlot.js +28 -7
  12. package/dist-tsc/CellSetExpressionPlotOptions.d.ts.map +1 -1
  13. package/dist-tsc/CellSetExpressionPlotOptions.js +11 -4
  14. package/dist-tsc/CellSetExpressionPlotSubscriber.d.ts.map +1 -1
  15. package/dist-tsc/CellSetExpressionPlotSubscriber.js +43 -11
  16. package/dist-tsc/DotPlot.d.ts.map +1 -1
  17. package/dist-tsc/DotPlot.js +6 -2
  18. package/dist-tsc/FeatureSetEnrichmentBarPlot.d.ts.map +1 -1
  19. package/dist-tsc/FeatureSetEnrichmentBarPlot.js +7 -6
  20. package/dist-tsc/FeatureSetEnrichmentBarPlotSubscriber.d.ts.map +1 -1
  21. package/dist-tsc/FeatureSetEnrichmentBarPlotSubscriber.js +5 -2
  22. package/dist-tsc/TreemapSubscriber.d.ts.map +1 -1
  23. package/dist-tsc/TreemapSubscriber.js +10 -6
  24. package/dist-tsc/expr-hooks.d.ts.map +1 -1
  25. package/dist-tsc/expr-hooks.test.js +2 -1
  26. package/package.json +7 -7
  27. package/src/CellSetCompositionBarPlot.js +35 -9
  28. package/src/CellSetExpressionPlotOptions.js +39 -2
  29. package/src/CellSetExpressionPlotSubscriber.js +47 -11
  30. package/src/DotPlot.js +4 -2
  31. package/src/FeatureSetEnrichmentBarPlot.js +7 -6
  32. package/src/FeatureSetEnrichmentBarPlotSubscriber.js +5 -2
  33. package/src/TreemapSubscriber.js +20 -7
  34. package/src/expr-hooks.js +0 -1
  35. package/src/expr-hooks.test.js +2 -1
@@ -1215,6 +1215,7 @@ const CoordinationType$1 = {
1215
1215
  FEATURE_VALUE_COLORMAP: "featureValueColormap",
1216
1216
  FEATURE_VALUE_TRANSFORM: "featureValueTransform",
1217
1217
  FEATURE_VALUE_COLORMAP_RANGE: "featureValueColormapRange",
1218
+ FEATURE_AGGREGATION_STRATEGY: "featureAggregationStrategy",
1218
1219
  OBS_COLOR_ENCODING: "obsColorEncoding",
1219
1220
  SPATIAL_IMAGE_LAYER: "spatialImageLayer",
1220
1221
  SPATIAL_SEGMENTATION_LAYER: "spatialSegmentationLayer",
@@ -1357,6 +1358,7 @@ const COMPONENT_COORDINATION_TYPES = {
1357
1358
  CoordinationType$1.FEATURE_SELECTION,
1358
1359
  CoordinationType$1.FEATURE_VALUE_COLORMAP,
1359
1360
  CoordinationType$1.FEATURE_VALUE_COLORMAP_RANGE,
1361
+ CoordinationType$1.FEATURE_AGGREGATION_STRATEGY,
1360
1362
  CoordinationType$1.OBS_COLOR_ENCODING,
1361
1363
  CoordinationType$1.ADDITIONAL_OBS_SETS,
1362
1364
  CoordinationType$1.TOOLTIPS_VISIBLE,
@@ -1400,6 +1402,7 @@ const COMPONENT_COORDINATION_TYPES = {
1400
1402
  CoordinationType$1.FEATURE_SELECTION,
1401
1403
  CoordinationType$1.FEATURE_VALUE_COLORMAP,
1402
1404
  CoordinationType$1.FEATURE_VALUE_COLORMAP_RANGE,
1405
+ CoordinationType$1.FEATURE_AGGREGATION_STRATEGY,
1403
1406
  CoordinationType$1.OBS_COLOR_ENCODING,
1404
1407
  CoordinationType$1.ADDITIONAL_OBS_SETS,
1405
1408
  CoordinationType$1.TOOLTIPS_VISIBLE,
@@ -1479,6 +1482,7 @@ const COMPONENT_COORDINATION_TYPES = {
1479
1482
  CoordinationType$1.FEATURE_SELECTION,
1480
1483
  CoordinationType$1.FEATURE_VALUE_COLORMAP,
1481
1484
  CoordinationType$1.FEATURE_VALUE_COLORMAP_RANGE,
1485
+ CoordinationType$1.FEATURE_AGGREGATION_STRATEGY,
1482
1486
  CoordinationType$1.OBS_COLOR_ENCODING,
1483
1487
  CoordinationType$1.ADDITIONAL_OBS_SETS,
1484
1488
  CoordinationType$1.MOLECULE_HIGHLIGHT,
@@ -1516,6 +1520,7 @@ const COMPONENT_COORDINATION_TYPES = {
1516
1520
  CoordinationType$1.FEATURE_SELECTION,
1517
1521
  CoordinationType$1.FEATURE_VALUE_COLORMAP,
1518
1522
  CoordinationType$1.FEATURE_VALUE_COLORMAP_RANGE,
1523
+ CoordinationType$1.FEATURE_AGGREGATION_STRATEGY,
1519
1524
  CoordinationType$1.OBS_COLOR_ENCODING,
1520
1525
  CoordinationType$1.ADDITIONAL_OBS_SETS,
1521
1526
  CoordinationType$1.MOLECULE_HIGHLIGHT,
@@ -1629,6 +1634,7 @@ const COMPONENT_COORDINATION_TYPES = {
1629
1634
  CoordinationType$1.FEATURE_SELECTION,
1630
1635
  CoordinationType$1.FEATURE_VALUE_TRANSFORM,
1631
1636
  CoordinationType$1.FEATURE_VALUE_TRANSFORM_COEFFICIENT,
1637
+ CoordinationType$1.FEATURE_AGGREGATION_STRATEGY,
1632
1638
  CoordinationType$1.OBS_SET_SELECTION,
1633
1639
  CoordinationType$1.OBS_SET_FILTER,
1634
1640
  CoordinationType$1.OBS_SET_HIGHLIGHT,
@@ -1644,6 +1650,7 @@ const COMPONENT_COORDINATION_TYPES = {
1644
1650
  CoordinationType$1.FEATURE_TYPE,
1645
1651
  CoordinationType$1.FEATURE_VALUE_TYPE,
1646
1652
  CoordinationType$1.FEATURE_SELECTION,
1653
+ CoordinationType$1.FEATURE_AGGREGATION_STRATEGY,
1647
1654
  CoordinationType$1.ADDITIONAL_OBS_SETS,
1648
1655
  CoordinationType$1.OBS_SET_COLOR,
1649
1656
  CoordinationType$1.OBS_COLOR_ENCODING,
@@ -1722,6 +1729,7 @@ const COMPONENT_COORDINATION_TYPES = {
1722
1729
  CoordinationType$1.FEATURE_VALUE_COLORMAP,
1723
1730
  CoordinationType$1.FEATURE_VALUE_COLORMAP_RANGE,
1724
1731
  CoordinationType$1.FEATURE_SELECTION,
1732
+ CoordinationType$1.FEATURE_AGGREGATION_STRATEGY,
1725
1733
  CoordinationType$1.TOOLTIPS_VISIBLE,
1726
1734
  CoordinationType$1.TOOLTIP_CROSSHAIRS_VISIBLE,
1727
1735
  CoordinationType$1.LEGEND_VISIBLE,
@@ -1762,6 +1770,7 @@ const COMPONENT_COORDINATION_TYPES = {
1762
1770
  CoordinationType$1.FEATURE_VALUE_TRANSFORM_COEFFICIENT,
1763
1771
  CoordinationType$1.FEATURE_VALUE_POSITIVITY_THRESHOLD,
1764
1772
  CoordinationType$1.FEATURE_VALUE_COLORMAP,
1773
+ CoordinationType$1.FEATURE_AGGREGATION_STRATEGY,
1765
1774
  CoordinationType$1.OBS_SET_SELECTION,
1766
1775
  CoordinationType$1.OBS_SET_FILTER,
1767
1776
  CoordinationType$1.OBS_SET_HIGHLIGHT,
@@ -1790,6 +1799,7 @@ const COMPONENT_COORDINATION_TYPES = {
1790
1799
  CoordinationType$1.FEATURE_SELECTION,
1791
1800
  CoordinationType$1.FEATURE_VALUE_TRANSFORM,
1792
1801
  CoordinationType$1.FEATURE_VALUE_TRANSFORM_COEFFICIENT,
1802
+ CoordinationType$1.FEATURE_AGGREGATION_STRATEGY,
1793
1803
  CoordinationType$1.OBS_SET_SELECTION,
1794
1804
  CoordinationType$1.OBS_SET_HIGHLIGHT,
1795
1805
  CoordinationType$1.OBS_HIGHLIGHT,
@@ -1894,6 +1904,7 @@ const COMPONENT_COORDINATION_TYPES = {
1894
1904
  CoordinationType$1.OBS_TYPE,
1895
1905
  CoordinationType$1.SAMPLE_TYPE,
1896
1906
  CoordinationType$1.FEATURE_SELECTION,
1907
+ CoordinationType$1.FEATURE_AGGREGATION_STRATEGY,
1897
1908
  CoordinationType$1.SAMPLE_SET_SELECTION,
1898
1909
  CoordinationType$1.SAMPLE_SET_FILTER,
1899
1910
  CoordinationType$1.OBS_SET_SELECTION,
@@ -12420,6 +12431,7 @@ z.object({
12420
12431
  termColumn: z.string().optional(),
12421
12432
  pValueColumn: z.string(),
12422
12433
  pValueAdjusted: z.boolean().optional(),
12434
+ featureSetLibrary: z.string().optional().describe("Optionally, provide a feature set library name. By default, Reactome_2022."),
12423
12435
  analysisType: z.string().optional().describe("Optionally, provide an analysis_type name. By default, pertpy_hypergeometric.")
12424
12436
  });
12425
12437
  z.object({
@@ -12430,7 +12442,6 @@ z.object({
12430
12442
  foldChangeColumn: z.string().describe("The log-fold change is then calculated between this expected sample and the expected sample with no active covariates from the intercept section."),
12431
12443
  foldChangeTransformation: z.enum(["log2"]).optional(),
12432
12444
  isCredibleEffectColumn: z.string().describe("Column which annotates effects as being credible or not (boolean)."),
12433
- covariateColumn: z.string().describe("Column which defines the covariate used in the analysis."),
12434
12445
  analysisType: z.string().optional().describe("Optionally, provide an analysis_type name. By default, sccoda_df.")
12435
12446
  });
12436
12447
  const annDataObsLabels = annDataObs;
@@ -19488,12 +19499,38 @@ function stratifyExpressionData(sampleEdges, sampleSets, sampleSetSelection, exp
19488
19499
  }
19489
19500
  return [null, null];
19490
19501
  }
19491
- function aggregateStratifiedExpressionData(stratifiedResult, geneSelection) {
19502
+ function aggregateStratifiedExpressionData(stratifiedResult, geneSelection, featureAggregationStrategy) {
19492
19503
  const result = new InternMap$1([], JSON.stringify);
19493
19504
  Array.from(stratifiedResult.entries()).forEach(([cellSetKey, firstLevelInternMap]) => {
19494
19505
  result.set(cellSetKey, new InternMap$1([], JSON.stringify));
19495
19506
  Array.from(firstLevelInternMap.entries()).forEach(([sampleSetKey, secondLevelInternMap]) => {
19496
- const values2 = secondLevelInternMap.get(geneSelection[0]);
19507
+ let values2;
19508
+ if (featureAggregationStrategy === "first") {
19509
+ values2 = secondLevelInternMap.get(geneSelection[0]);
19510
+ } else if (featureAggregationStrategy === "last") {
19511
+ values2 = secondLevelInternMap.get(geneSelection.at(-1));
19512
+ } else if (typeof featureAggregationStrategy === "number") {
19513
+ const i2 = featureAggregationStrategy;
19514
+ if (i2 >= 0 && i2 < geneSelection.length) {
19515
+ values2 = secondLevelInternMap.get(geneSelection[i2]);
19516
+ } else {
19517
+ throw new Error("Feature index used for featureAggregationStrategy is invalid.");
19518
+ }
19519
+ } else if (featureAggregationStrategy === "sum" || featureAggregationStrategy === "mean") {
19520
+ const subarrays = geneSelection.map((geneId) => secondLevelInternMap.get(geneId));
19521
+ values2 = subarrays.reduce((acc, curr) => acc.map((val, idx) => val + curr[idx]));
19522
+ if (featureAggregationStrategy === "mean") {
19523
+ const N2 = geneSelection.length;
19524
+ values2 = values2.map((val) => val / N2);
19525
+ }
19526
+ } else if (featureAggregationStrategy === "difference") {
19527
+ if (geneSelection.length === 2) {
19528
+ const subarrays = geneSelection.map((geneId) => secondLevelInternMap.get(geneId));
19529
+ values2 = subarrays.reduce((acc, curr) => acc.map((val, idx) => val - curr[idx]));
19530
+ } else {
19531
+ throw new Error("Expected exactly two selected features when featureAggregationStrategy is difference.");
19532
+ }
19533
+ }
19497
19534
  result.get(cellSetKey).set(sampleSetKey, values2);
19498
19535
  });
19499
19536
  });
@@ -120439,7 +120476,7 @@ function clipExtent(x02, y02, x12, y12) {
120439
120476
  return clipStream;
120440
120477
  };
120441
120478
  }
120442
- function extent$1() {
120479
+ function extent$2() {
120443
120480
  var x02 = 0, y02 = 0, x12 = 960, y12 = 500, cache2, cacheStream, clip2;
120444
120481
  return clip2 = {
120445
120482
  stream: function(stream2) {
@@ -121846,7 +121883,7 @@ const d3Geo$1 = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.definePrope
121846
121883
  geoBounds: bounds$1,
121847
121884
  geoCentroid: centroid$4,
121848
121885
  geoCircle: circle$5,
121849
- geoClipExtent: extent$1,
121886
+ geoClipExtent: extent$2,
121850
121887
  geoConicConformal: conicConformal,
121851
121888
  geoConicConformalRaw: conicConformalRaw$1,
121852
121889
  geoConicEqualArea: conicEqualArea,
@@ -145162,8 +145199,15 @@ class SelectionLayer extends CompositeLayer {
145162
145199
  if (!nodePolygonContainsSelectedPolygon && !nodePolygonWithinSelectedPolygon && !nodePolygonOverlapsSelectedPolgyon) {
145163
145200
  return true;
145164
145201
  }
145165
- if (node.data && booleanPointInPolygon$1(point$a([].slice.call(getObsCoords(node.data))), selectedPolygon)) {
145166
- pickingInfos.push(node.data);
145202
+ if (node.data) {
145203
+ let current2 = node;
145204
+ while (current2) {
145205
+ const pointCoords = [].slice.call(getObsCoords(current2.data));
145206
+ if (booleanPointInPolygon$1(point$a(pointCoords), selectedPolygon)) {
145207
+ pickingInfos.push(current2.data);
145208
+ }
145209
+ current2 = current2.next;
145210
+ }
145167
145211
  }
145168
145212
  return false;
145169
145213
  });
@@ -146341,16 +146385,16 @@ function addDecoder(cases2, importFn) {
146341
146385
  }
146342
146386
  cases2.forEach((c2) => registry$1.set(c2, importFn));
146343
146387
  }
146344
- addDecoder([void 0, 1], () => import("./raw-9b8d9daf.js").then((m2) => m2.default));
146345
- addDecoder(5, () => import("./lzw-503cb795.js").then((m2) => m2.default));
146388
+ addDecoder([void 0, 1], () => import("./raw-0887baec.js").then((m2) => m2.default));
146389
+ addDecoder(5, () => import("./lzw-1120aba9.js").then((m2) => m2.default));
146346
146390
  addDecoder(6, () => {
146347
146391
  throw new Error("old style JPEG compression is not supported.");
146348
146392
  });
146349
- addDecoder(7, () => import("./jpeg-81bd1053.js").then((m2) => m2.default));
146350
- addDecoder([8, 32946], () => import("./deflate-ad0dcbe4.js").then((m2) => m2.default));
146351
- addDecoder(32773, () => import("./packbits-40cbad40.js").then((m2) => m2.default));
146352
- addDecoder(34887, () => import("./lerc-b15c3a4c.js").then((m2) => m2.default));
146353
- addDecoder(50001, () => import("./webimage-bbc59b4a.js").then((m2) => m2.default));
146393
+ addDecoder(7, () => import("./jpeg-1b818d11.js").then((m2) => m2.default));
146394
+ addDecoder([8, 32946], () => import("./deflate-b8c6daae.js").then((m2) => m2.default));
146395
+ addDecoder(32773, () => import("./packbits-2d02b5e3.js").then((m2) => m2.default));
146396
+ addDecoder(34887, () => import("./lerc-f38cbdfc.js").then((m2) => m2.default));
146397
+ addDecoder(50001, () => import("./webimage-533922a5.js").then((m2) => m2.default));
146354
146398
  function decodeRowAcc(row, stride) {
146355
146399
  let length2 = row.length - stride;
146356
146400
  let offset5 = 0;
@@ -156492,7 +156536,7 @@ function deviation$1(values2, valueof) {
156492
156536
  const v2 = variance$1(values2, valueof);
156493
156537
  return v2 ? Math.sqrt(v2) : v2;
156494
156538
  }
156495
- function d3_extent(values2, valueof) {
156539
+ function extent$1(values2, valueof) {
156496
156540
  let min2;
156497
156541
  let max2;
156498
156542
  if (valueof === void 0) {
@@ -156713,7 +156757,7 @@ function sturges(values2) {
156713
156757
  return Math.ceil(Math.log(count$1(values2)) / Math.LN2) + 1;
156714
156758
  }
156715
156759
  function bin$3() {
156716
- var value2 = identity$c, domain2 = d3_extent, threshold2 = sturges;
156760
+ var value2 = identity$c, domain2 = extent$1, threshold2 = sturges;
156717
156761
  function histogram(data2) {
156718
156762
  if (!Array.isArray(data2))
156719
156763
  data2 = Array.from(data2);
@@ -156724,11 +156768,11 @@ function bin$3() {
156724
156768
  var xz = domain2(values2), x02 = xz[0], x12 = xz[1], tz = threshold2(values2, x02, x12);
156725
156769
  if (!Array.isArray(tz)) {
156726
156770
  const max2 = x12, tn2 = +tz;
156727
- if (domain2 === d3_extent)
156771
+ if (domain2 === extent$1)
156728
156772
  [x02, x12] = nice$3(x02, x12, tn2);
156729
156773
  tz = ticks(x02, x12, tn2);
156730
156774
  if (tz[tz.length - 1] >= x12) {
156731
- if (max2 >= x12 && domain2 === d3_extent) {
156775
+ if (max2 >= x12 && domain2 === extent$1) {
156732
156776
  const step = tickIncrement(x02, x12, tn2);
156733
156777
  if (isFinite(step)) {
156734
156778
  if (step > 0) {
@@ -156873,7 +156917,7 @@ function sum$2(values2, valueof) {
156873
156917
  return sum2;
156874
156918
  }
156875
156919
  function normalize$4(arr) {
156876
- const [min2, max2] = d3_extent(arr);
156920
+ const [min2, max2] = extent$1(arr);
156877
156921
  const ratio = 255 / (max2 - min2);
156878
156922
  const data2 = new Uint8Array(arr.map((i2) => Math.floor((i2 - min2) * ratio)));
156879
156923
  return data2;
@@ -157495,6 +157539,7 @@ class ContourLayerWithText extends ContourLayer {
157495
157539
  }
157496
157540
  ContourLayerWithText.layerName = "ContourLayerWithText";
157497
157541
  ContourLayerWithText.defaultProps = defaultProps;
157542
+ const FEATURE_AGGREGATION_STRATEGIES = ["first", "last", "sum", "mean"];
157498
157543
  function CellSetExpressionPlotOptions(props) {
157499
157544
  const {
157500
157545
  featureValueTransform,
@@ -157505,16 +157550,21 @@ function CellSetExpressionPlotOptions(props) {
157505
157550
  featureValuePositivityThreshold,
157506
157551
  setFeatureValuePositivityThreshold,
157507
157552
  featureValueColormap,
157508
- setFeatureValueColormap
157553
+ setFeatureValueColormap,
157554
+ featureAggregationStrategy,
157555
+ setFeatureAggregationStrategy
157509
157556
  } = props;
157510
157557
  const cellSetExpressionPlotOptionsId = $bdb11010cef70236$export$f680877a34711e37();
157511
157558
  const classes = usePlotOptionsStyles();
157512
157559
  function handleFeatureValueColormapChange(event2) {
157513
157560
  setFeatureValueColormap(event2.target.value);
157514
157561
  }
157515
- const handleTransformChange = (event2) => {
157562
+ function handleTransformChange(event2) {
157516
157563
  setFeatureValueTransform(event2.target.value === "" ? null : event2.target.value);
157517
- };
157564
+ }
157565
+ function handleFeatureAggregationStrategyChange(event2) {
157566
+ setFeatureAggregationStrategy(event2.target.value);
157567
+ }
157518
157568
  function handlePositivityThresholdChange(event2, value2) {
157519
157569
  setFeatureValuePositivityThreshold(value2);
157520
157570
  }
@@ -157589,6 +157639,27 @@ function CellSetExpressionPlotOptions(props) {
157589
157639
  }
157590
157640
  ) })
157591
157641
  ] }),
157642
+ setFeatureAggregationStrategy ? /* @__PURE__ */ jsxRuntimeExports.jsxs(TableRow$1, { children: [
157643
+ /* @__PURE__ */ jsxRuntimeExports.jsx(TableCell$1, { className: classes.labelCell, variant: "head", scope: "row", children: /* @__PURE__ */ jsxRuntimeExports.jsx(
157644
+ "label",
157645
+ {
157646
+ htmlFor: `feature-aggregation-strategy-${cellSetExpressionPlotOptionsId}`,
157647
+ children: "Feature Aggregation Strategy"
157648
+ }
157649
+ ) }),
157650
+ /* @__PURE__ */ jsxRuntimeExports.jsx(TableCell$1, { className: classes.inputCell, variant: "body", children: /* @__PURE__ */ jsxRuntimeExports.jsx(
157651
+ OptionSelect,
157652
+ {
157653
+ className: classes.select,
157654
+ value: featureAggregationStrategy ?? "first",
157655
+ onChange: handleFeatureAggregationStrategyChange,
157656
+ inputProps: {
157657
+ id: `feature-aggregation-strategy-${cellSetExpressionPlotOptionsId}`
157658
+ },
157659
+ children: FEATURE_AGGREGATION_STRATEGIES.map((opt) => /* @__PURE__ */ jsxRuntimeExports.jsx("option", { value: opt, children: capitalize$2(opt) }, opt))
157660
+ }
157661
+ ) })
157662
+ ] }) : null,
157592
157663
  setFeatureValuePositivityThreshold ? /* @__PURE__ */ jsxRuntimeExports.jsxs(TableRow$1, { children: [
157593
157664
  /* @__PURE__ */ jsxRuntimeExports.jsx(TableCell$1, { className: classes.labelCell, children: "Positivity Threshold" }),
157594
157665
  /* @__PURE__ */ jsxRuntimeExports.jsx(TableCell$1, { className: classes.inputCell, children: /* @__PURE__ */ jsxRuntimeExports.jsx(
@@ -167022,7 +167093,30 @@ function histogramStratifiedExpressionData(summarizedResult, binCount, yMinProp)
167022
167093
  // d3.scaleLinear without a range set
167023
167094
  };
167024
167095
  }
167025
- function useExpressionByCellSet(sampleEdges, sampleSets, sampleSetSelection, expressionData, obsIndex, cellSets, additionalCellSets, geneSelection, cellSetSelection, cellSetColor, featureValueTransform, featureValueTransformCoefficient, theme, yMinProp) {
167096
+ const DEFAULT_FEATURE_AGGREGATION_STRATEGY = "first";
167097
+ function featureSummary(geneSelection, featureAggregationStrategy) {
167098
+ if (featureAggregationStrategy === "first") {
167099
+ return geneSelection == null ? void 0 : geneSelection[0];
167100
+ }
167101
+ if (featureAggregationStrategy === "last") {
167102
+ return geneSelection == null ? void 0 : geneSelection.at(-1);
167103
+ }
167104
+ if (typeof featureAggregationStrategy === "number") {
167105
+ const i2 = featureAggregationStrategy;
167106
+ return geneSelection == null ? void 0 : geneSelection[i2];
167107
+ }
167108
+ if (featureAggregationStrategy === "sum") {
167109
+ return geneSelection == null ? void 0 : geneSelection.join(" + ");
167110
+ }
167111
+ if (featureAggregationStrategy === "mean") {
167112
+ return `Mean of ${geneSelection == null ? void 0 : geneSelection.join(", ")}`;
167113
+ }
167114
+ if (featureAggregationStrategy === "difference") {
167115
+ return geneSelection == null ? void 0 : geneSelection.join(" - ");
167116
+ }
167117
+ return "";
167118
+ }
167119
+ function useExpressionByCellSet(sampleEdges, sampleSets, sampleSetSelection, expressionData, obsIndex, cellSets, additionalCellSets, geneSelection, cellSetSelection, cellSetColor, featureValueTransform, featureValueTransformCoefficient, theme, yMinProp, featureAggregationStrategy) {
167026
167120
  const mergedCellSets = useMemo(
167027
167121
  () => mergeObsSets(cellSets, additionalCellSets),
167028
167122
  [cellSets, additionalCellSets]
@@ -167044,7 +167138,8 @@ function useExpressionByCellSet(sampleEdges, sampleSets, sampleSetSelection, exp
167044
167138
  if (stratifiedData) {
167045
167139
  const aggregateData = aggregateStratifiedExpressionData(
167046
167140
  stratifiedData,
167047
- geneSelection
167141
+ geneSelection,
167142
+ featureAggregationStrategy
167048
167143
  );
167049
167144
  const summarizedData = summarizeStratifiedExpressionData(
167050
167145
  aggregateData,
@@ -167071,7 +167166,8 @@ function useExpressionByCellSet(sampleEdges, sampleSets, sampleSetSelection, exp
167071
167166
  yMinProp,
167072
167167
  sampleEdges,
167073
167168
  sampleSets,
167074
- sampleSetSelection
167169
+ sampleSetSelection,
167170
+ featureAggregationStrategy
167075
167171
  ]);
167076
167172
  const setArr = useMemo(() => mergedCellSets && cellSetSelection && cellSetColor ? treeToSetSizesBySetNames(
167077
167173
  mergedCellSets,
@@ -167112,11 +167208,13 @@ function CellSetExpressionPlotSubscriber(props) {
167112
167208
  additionalObsSets: additionalCellSets,
167113
167209
  sampleType,
167114
167210
  sampleSetSelection,
167115
- sampleSetColor
167211
+ sampleSetColor,
167212
+ featureAggregationStrategy
167116
167213
  }, {
167117
167214
  setFeatureValueTransform,
167118
167215
  setFeatureValueTransformCoefficient,
167119
- setSampleSetColor
167216
+ setSampleSetColor,
167217
+ setFeatureAggregationStrategy
167120
167218
  }] = useCoordination(
167121
167219
  COMPONENT_COORDINATION_TYPES[ViewType$1.OBS_SET_FEATURE_VALUE_DISTRIBUTION],
167122
167220
  coordinationScopes
@@ -167189,6 +167287,7 @@ function CellSetExpressionPlotSubscriber(props) {
167189
167287
  sampleSetsUrls,
167190
167288
  sampleEdgesUrls
167191
167289
  ]);
167290
+ const featureAggregationStrategyToUse = featureAggregationStrategy ?? DEFAULT_FEATURE_AGGREGATION_STRATEGY;
167192
167291
  const [histogramData, setArr, exprMax] = useExpressionByCellSet(
167193
167292
  sampleEdges,
167194
167293
  sampleSets,
@@ -167203,13 +167302,20 @@ function CellSetExpressionPlotSubscriber(props) {
167203
167302
  featureValueTransform,
167204
167303
  featureValueTransformCoefficient,
167205
167304
  theme,
167206
- yMin
167305
+ yMin,
167306
+ featureAggregationStrategyToUse
167207
167307
  );
167208
- const firstGeneSelected = geneSelection && geneSelection.length >= 1 ? (featureLabelsMap == null ? void 0 : featureLabelsMap.get(geneSelection[0])) || (featureLabelsMap == null ? void 0 : featureLabelsMap.get(cleanFeatureId(geneSelection[0]))) || geneSelection[0] : null;
167308
+ const featureSuffix = useMemo(() => {
167309
+ const cleanedGeneSelection = geneSelection == null ? void 0 : geneSelection.map((geneName) => (featureLabelsMap == null ? void 0 : featureLabelsMap.get(geneName)) || (featureLabelsMap == null ? void 0 : featureLabelsMap.get(cleanFeatureId(geneName))) || geneName);
167310
+ if (Array.isArray(cleanedGeneSelection)) {
167311
+ return featureSummary(cleanedGeneSelection, featureAggregationStrategyToUse);
167312
+ }
167313
+ return null;
167314
+ }, [geneSelection, featureAggregationStrategyToUse]);
167209
167315
  const selectedTransformName = (_a3 = transformOptions.find(
167210
167316
  (o2) => o2.value === featureValueTransform
167211
167317
  )) == null ? void 0 : _a3.name;
167212
- const titleSuffix = firstGeneSelected ? ` (${firstGeneSelected})` : "";
167318
+ const titleSuffix = featureSuffix ? ` (${featureSuffix})` : "";
167213
167319
  return /* @__PURE__ */ jsxRuntimeExports.jsx(
167214
167320
  TitleInfo,
167215
167321
  {
@@ -167228,7 +167334,9 @@ function CellSetExpressionPlotSubscriber(props) {
167228
167334
  setFeatureValueTransform,
167229
167335
  featureValueTransformCoefficient,
167230
167336
  setFeatureValueTransformCoefficient,
167231
- transformOptions
167337
+ transformOptions,
167338
+ featureAggregationStrategy,
167339
+ setFeatureAggregationStrategy
167232
167340
  }
167233
167341
  ),
167234
167342
  children: /* @__PURE__ */ jsxRuntimeExports.jsx("div", { ref: containerRef, className: classes.vegaContainer, children: histogramData ? /* @__PURE__ */ jsxRuntimeExports.jsx(
@@ -219572,7 +219680,8 @@ function DotPlot(props) {
219572
219680
  featureType,
219573
219681
  featureValueType,
219574
219682
  featureValueTransformName,
219575
- featureValueColormap,
219683
+ // TODO: re-enable featureValueColormap coordination
219684
+ // featureValueColormap,
219576
219685
  obsSetSelection,
219577
219686
  obsSetColor
219578
219687
  } = props;
@@ -219634,7 +219743,8 @@ function DotPlot(props) {
219634
219743
  type: "quantitative",
219635
219744
  title: meanTransform,
219636
219745
  scale: {
219637
- scheme: featureValueColormap
219746
+ // scheme: featureValueColormap,
219747
+ scheme: "greys"
219638
219748
  },
219639
219749
  legend: {
219640
219750
  direction: "horizontal",
@@ -220603,8 +220713,6 @@ function TreemapSubscriber(props) {
220603
220713
  () => mergeObsSets(sampleSets, null),
220604
220714
  [sampleSets]
220605
220715
  );
220606
- const obsCount = (obsIndex == null ? void 0 : obsIndex.length) || 0;
220607
- const sampleCount = (sampleIndex == null ? void 0 : sampleIndex.length) || 0;
220608
220716
  const [obsCounts, sampleCounts] = useMemo(() => {
220609
220717
  var _a3, _b2;
220610
220718
  const obsResult = new InternMap$1([], JSON.stringify);
@@ -220631,7 +220739,7 @@ function TreemapSubscriber(props) {
220631
220739
  const sampleSetSize = (_a4 = sampleSetSizes == null ? void 0 : sampleSetSizes.find((d) => isEqual$2(d.setNamePath, sampleSetKey))) == null ? void 0 : _a4.size;
220632
220740
  sampleResult.set(sampleSetKey, sampleSetSize || 0);
220633
220741
  });
220634
- if (mergedObsSets && obsSetSelection) {
220742
+ if (mergedObsSets && obsSetSelection && obsIndex) {
220635
220743
  const sampleIdToSetMap = sampleSets && sampleSetSelection ? treeToSelectedSetMap(sampleSets, sampleSetSelection) : null;
220636
220744
  const cellIdToSetMap = treeToSelectedSetMap(mergedObsSets, obsSetSelection);
220637
220745
  for (let i2 = 0; i2 < obsIndex.length; i2 += 1) {
@@ -220659,22 +220767,30 @@ function TreemapSubscriber(props) {
220659
220767
  mergedObsSets,
220660
220768
  obsSetSelection,
220661
220769
  mergedSampleSets,
220662
- sampleSetSelection
220770
+ sampleSetSelection,
220771
+ obsIndex
220663
220772
  // TODO: consider filtering-related coordination values
220664
220773
  ]);
220774
+ const totalObsCount = (obsIndex == null ? void 0 : obsIndex.length) || 0;
220775
+ const totalSampleCount = (sampleIndex == null ? void 0 : sampleIndex.length) || 0;
220776
+ const selectedObsCount = obsCounts.reduce((a2, h2) => a2 + h2.value, 0);
220777
+ const selectedSampleCount = sampleCounts.reduce((a2, h2) => a2 + h2.value, 0);
220778
+ const unselectedObsCount = totalObsCount - selectedObsCount;
220779
+ const unselectedSampleCount = totalSampleCount - selectedSampleCount;
220665
220780
  const onNodeClick = useCallback((obsSetPath) => {
220666
220781
  setObsSetSelection([obsSetPath]);
220667
220782
  }, [setObsSetSelection]);
220668
- return /* @__PURE__ */ jsxRuntimeExports.jsx(
220783
+ return /* @__PURE__ */ jsxRuntimeExports.jsxs(
220669
220784
  TitleInfo,
220670
220785
  {
220671
220786
  title: `Treemap of ${capitalize$2(pluralize(obsType, 2))}`,
220672
- info: `${commaNumber(obsCount)} ${pluralize(obsType, obsCount)} from ${commaNumber(sampleCount)} ${pluralize(sampleType, sampleCount)}`,
220787
+ info: `${commaNumber(selectedObsCount)} ${pluralize(obsType, selectedObsCount)} from ${commaNumber(selectedSampleCount)} ${pluralize(sampleType, selectedSampleCount)}`,
220673
220788
  removeGridComponent,
220674
220789
  urls,
220675
220790
  theme,
220676
220791
  isReady,
220677
220792
  helpText,
220793
+ withPadding: false,
220678
220794
  options: /* @__PURE__ */ jsxRuntimeExports.jsx(
220679
220795
  TreemapOptions,
220680
220796
  {
@@ -220686,25 +220802,28 @@ function TreemapSubscriber(props) {
220686
220802
  setHierarchyLevels
220687
220803
  }
220688
220804
  ),
220689
- children: /* @__PURE__ */ jsxRuntimeExports.jsx("div", { ref: containerRef, className: classes.vegaContainer, children: /* @__PURE__ */ jsxRuntimeExports.jsx(
220690
- Treemap,
220691
- {
220692
- obsCounts,
220693
- sampleCounts,
220694
- obsColorEncoding,
220695
- hierarchyLevels: hierarchyLevels || DEFAULT_HIERARCHY_LEVELS,
220696
- theme,
220697
- width: width2,
220698
- height: height2,
220699
- obsType,
220700
- sampleType,
220701
- obsSetColor,
220702
- sampleSetColor,
220703
- obsSetSelection,
220704
- sampleSetSelection,
220705
- onNodeClick
220706
- }
220707
- ) })
220805
+ children: [
220806
+ /* @__PURE__ */ jsxRuntimeExports.jsx("div", { ref: containerRef, className: classes.vegaContainer, children: /* @__PURE__ */ jsxRuntimeExports.jsx(
220807
+ Treemap,
220808
+ {
220809
+ obsCounts,
220810
+ sampleCounts,
220811
+ obsColorEncoding,
220812
+ hierarchyLevels: hierarchyLevels || DEFAULT_HIERARCHY_LEVELS,
220813
+ theme,
220814
+ width: width2,
220815
+ height: Math.max(height2 * (selectedObsCount / totalObsCount), 40),
220816
+ obsType,
220817
+ sampleType,
220818
+ obsSetColor,
220819
+ sampleSetColor,
220820
+ obsSetSelection,
220821
+ sampleSetSelection,
220822
+ onNodeClick
220823
+ }
220824
+ ) }),
220825
+ /* @__PURE__ */ jsxRuntimeExports.jsx("div", { style: { position: "absolute", right: "2px", bottom: "2px", fontSize: "10px" }, children: unselectedObsCount > 0 ? /* @__PURE__ */ jsxRuntimeExports.jsx("span", { children: `${commaNumber(unselectedObsCount)} ${pluralize(obsType, unselectedObsCount)} from ${commaNumber(unselectedSampleCount)} ${pluralize(sampleType, unselectedSampleCount)} currently omitted` }) : null })
220826
+ ]
220708
220827
  }
220709
220828
  );
220710
220829
  }
@@ -220745,13 +220864,13 @@ function VolcanoPlot(props) {
220745
220864
  if (!computedData) {
220746
220865
  return [null, null];
220747
220866
  }
220748
- let xExtentResult = d3_extent(
220749
- computedData.flatMap((d) => d3_extent(d.df.logFoldChange))
220867
+ let xExtentResult = extent$1(
220868
+ computedData.flatMap((d) => extent$1(d.df.logFoldChange))
220750
220869
  );
220751
220870
  const xAbsMax = Math.max(Math.abs(xExtentResult[0]), Math.abs(xExtentResult[1]));
220752
220871
  xExtentResult = [-xAbsMax, xAbsMax];
220753
- const yExtentResult = d3_extent(
220754
- computedData.flatMap((d) => d3_extent(d.df.minusLog10p.filter((v2) => Number.isFinite(v2))))
220872
+ const yExtentResult = extent$1(
220873
+ computedData.flatMap((d) => extent$1(d.df.minusLog10p.filter((v2) => Number.isFinite(v2))))
220755
220874
  );
220756
220875
  return [xExtentResult, yExtentResult];
220757
220876
  }, [computedData]);
@@ -221113,14 +221232,15 @@ function VolcanoPlotSubscriber(props) {
221113
221232
  }
221114
221233
  );
221115
221234
  }
221235
+ const MAX_BAR_SIZE = 40;
221116
221236
  function CellSetCompositionBarPlot(props) {
221117
221237
  const {
221118
221238
  data: data2,
221119
221239
  theme,
221120
221240
  width: width2,
221121
- height: height2,
221241
+ height: heightProp,
221122
221242
  marginRight = 200,
221123
- marginBottom = 120,
221243
+ marginBottom = 60,
221124
221244
  keyLength = 36,
221125
221245
  obsType,
221126
221246
  onBarSelect,
@@ -221131,25 +221251,25 @@ function CellSetCompositionBarPlot(props) {
221131
221251
  obsSetColor,
221132
221252
  sampleSetColor
221133
221253
  } = props;
221254
+ const height2 = Array.isArray(obsSetSelection) && (heightProp - marginBottom) / obsSetSelection.length >= MAX_BAR_SIZE ? MAX_BAR_SIZE * obsSetSelection.length + marginBottom : heightProp;
221134
221255
  const [obsSetColorScale, sampleSetColorScale] = useMemo(() => [
221135
221256
  getColorScale(obsSetSelection, obsSetColor, theme),
221136
221257
  getColorScale(sampleSetSelection, sampleSetColor, theme)
221137
221258
  ], [obsSetSelection, sampleSetSelection, sampleSetColor, obsSetColor, theme]);
221138
221259
  const computedData = useMemo(() => {
221139
- var _a3, _b2, _c, _d, _e2, _f, _g;
221260
+ var _a3, _b2, _c, _d, _e2, _f;
221140
221261
  if (Array.isArray(data2) && data2.length === 1) {
221141
221262
  const { df, metadata: metadata2 } = data2[0];
221142
221263
  const referenceCellType = (_a3 = metadata2 == null ? void 0 : metadata2.analysis_params) == null ? void 0 : _a3.reference_cell_type;
221264
+ const covariateValue = (_b2 = metadata2 == null ? void 0 : metadata2.analysis_params) == null ? void 0 : _b2.covariate_value;
221143
221265
  const coordinationValues = metadata2 == null ? void 0 : metadata2.coordination_values;
221144
- const obsSetColumnName = (_c = (_b2 = coordinationValues == null ? void 0 : coordinationValues.obsSetSelection) == null ? void 0 : _b2[0]) == null ? void 0 : _c[0];
221266
+ const obsSetColumnName = (_d = (_c = coordinationValues == null ? void 0 : coordinationValues.obsSetSelection) == null ? void 0 : _c[0]) == null ? void 0 : _d[0];
221145
221267
  const obsSetGroupName = obsSetsColumnNameMappingReversed == null ? void 0 : obsSetsColumnNameMappingReversed[obsSetColumnName];
221146
- const sampleSetColumnName = (_e2 = (_d = coordinationValues == null ? void 0 : coordinationValues.sampleSetFilter) == null ? void 0 : _d[0]) == null ? void 0 : _e2[0];
221268
+ const sampleSetColumnName = (_f = (_e2 = coordinationValues == null ? void 0 : coordinationValues.sampleSetFilter) == null ? void 0 : _e2[0]) == null ? void 0 : _f[0];
221147
221269
  const sampleSetGroupName = sampleSetsColumnNameMappingReversed == null ? void 0 : sampleSetsColumnNameMappingReversed[sampleSetColumnName];
221148
- const covariatePrefix = `${sampleSetColumnName}T.`;
221149
- const firstCovariateValue = (_g = (_f = df.covariate) == null ? void 0 : _f[0]) == null ? void 0 : _g.substring(covariatePrefix.length);
221150
- const firstCovariateSetPath = [sampleSetGroupName, firstCovariateValue];
221270
+ const covariateSetPath = [sampleSetGroupName, covariateValue];
221151
221271
  let shouldSwapFoldChangeDirection = false;
221152
- if (isEqual$2(firstCovariateSetPath, sampleSetSelection[0])) {
221272
+ if (isEqual$2(covariateSetPath, sampleSetSelection[0])) {
221153
221273
  shouldSwapFoldChangeDirection = true;
221154
221274
  }
221155
221275
  return df.obsSetId.map((obsSetId, i2) => {
@@ -221206,6 +221326,22 @@ function CellSetCompositionBarPlot(props) {
221206
221326
  domain: [true, false],
221207
221327
  range: [2, 0.5]
221208
221328
  };
221329
+ const xExtent = useMemo(() => {
221330
+ if (computedData) {
221331
+ const [min2, max2] = extent$1(computedData.map((d) => d.logFoldChange));
221332
+ const buffer2 = 1.05;
221333
+ const minAbs = Math.abs(min2) * buffer2;
221334
+ const maxAbs = Math.abs(max2) * buffer2;
221335
+ if (minAbs > maxAbs) {
221336
+ return [-minAbs, minAbs];
221337
+ }
221338
+ return [-maxAbs, maxAbs];
221339
+ }
221340
+ return void 0;
221341
+ }, [computedData]);
221342
+ const xScale = {
221343
+ domain: xExtent
221344
+ };
221209
221345
  const spec = {
221210
221346
  mark: { type: "bar", stroke: "black", cursor: "pointer" },
221211
221347
  params: [
@@ -221240,7 +221376,8 @@ function CellSetCompositionBarPlot(props) {
221240
221376
  // TODO: support using intercept+effect here based on user-selected options?
221241
221377
  field: "logFoldChange",
221242
221378
  type: "quantitative",
221243
- title: "Log fold-change"
221379
+ title: "Log fold-change",
221380
+ scale: xScale
221244
221381
  },
221245
221382
  color: {
221246
221383
  field: "key",
@@ -221256,7 +221393,8 @@ function CellSetCompositionBarPlot(props) {
221256
221393
  strokeWidth: {
221257
221394
  field: "isReferenceSet",
221258
221395
  type: "nominal",
221259
- scale: strokeWidthScale
221396
+ scale: strokeWidthScale,
221397
+ legend: null
221260
221398
  },
221261
221399
  tooltip: {
221262
221400
  field: "effectExpectedSample",
@@ -221421,7 +221559,7 @@ function FeatureSetEnrichmentBarPlot(props) {
221421
221559
  theme,
221422
221560
  width: width2,
221423
221561
  height: height2,
221424
- marginRight = 200,
221562
+ marginRight = 300,
221425
221563
  marginBottom = 120,
221426
221564
  keyLength = 36,
221427
221565
  featureType,
@@ -221478,7 +221616,7 @@ function FeatureSetEnrichmentBarPlot(props) {
221478
221616
  }
221479
221617
  return [...a2, h2];
221480
221618
  }, []);
221481
- const MAX_ROWS = 25;
221619
+ const MAX_ROWS = 50;
221482
221620
  result = result.slice(0, MAX_ROWS);
221483
221621
  return result;
221484
221622
  }
@@ -221509,7 +221647,7 @@ function FeatureSetEnrichmentBarPlot(props) {
221509
221647
  select: {
221510
221648
  type: "point",
221511
221649
  on: "click[event.shiftKey === false]",
221512
- fields: ["name"],
221650
+ fields: ["name", "term"],
221513
221651
  empty: "none"
221514
221652
  }
221515
221653
  },
@@ -221518,7 +221656,7 @@ function FeatureSetEnrichmentBarPlot(props) {
221518
221656
  select: {
221519
221657
  type: "point",
221520
221658
  on: "click[event.shiftKey]",
221521
- fields: ["name"],
221659
+ fields: ["name", "term"],
221522
221660
  empty: "none"
221523
221661
  }
221524
221662
  }
@@ -221565,10 +221703,11 @@ function FeatureSetEnrichmentBarPlot(props) {
221565
221703
  config: VEGA_THEMES[theme]
221566
221704
  };
221567
221705
  const handleSignal = (name2, value2) => {
221706
+ var _a3, _b2;
221568
221707
  if (name2 === "bar_select") {
221569
- onBarSelect(value2.obsSetPath);
221708
+ onBarSelect((_a3 = value2.name) == null ? void 0 : _a3[0], (_b2 = value2.term) == null ? void 0 : _b2[0]);
221570
221709
  } else if (name2 === "shift_bar_select") {
221571
- onBarSelect(value2.obsSetPath, true);
221710
+ onBarSelect(value2.name, value2.term, true);
221572
221711
  }
221573
221712
  };
221574
221713
  const signalListeners = { bar_select: handleSignal, shift_bar_select: handleSignal };
@@ -221601,7 +221740,7 @@ function FeatureSetEnrichmentBarPlotSubscriber(props) {
221601
221740
  } = props;
221602
221741
  const classes = useStyles$1();
221603
221742
  const loaders = useLoaders();
221604
- useAsyncFunction(AsyncFunctionType.TRANSFORM_FEATURE);
221743
+ const transformFeature = useAsyncFunction(AsyncFunctionType.TRANSFORM_FEATURE);
221605
221744
  const [{
221606
221745
  dataset,
221607
221746
  obsType,
@@ -221678,6 +221817,11 @@ function FeatureSetEnrichmentBarPlotSubscriber(props) {
221678
221817
  featureSetStatsStatus
221679
221818
  ]);
221680
221819
  const onBarSelect = useCallback(async (featureSetName, featureSetTerm, isShiftDown = false) => {
221820
+ const kgNode = { nodeType: "pathway", term: featureSetTerm };
221821
+ const targetFeatureType = featureType;
221822
+ const targetsInPathway = await transformFeature(kgNode, targetFeatureType);
221823
+ const featureIds = targetsInPathway.filter((d, i2) => i2 < 10).map((d) => d.label);
221824
+ setFeatureSelection(featureIds);
221681
221825
  }, [setFeatureSelection]);
221682
221826
  return /* @__PURE__ */ jsxRuntimeExports.jsx(
221683
221827
  TitleInfo,