@vitessce/sets-utils 3.6.17 → 3.7.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.
Files changed (2) hide show
  1. package/dist/index.js +39 -48
  2. package/package.json +5 -5
package/dist/index.js CHANGED
@@ -120,7 +120,7 @@ function toFinite(value) {
120
120
  return value === 0 ? value : 0;
121
121
  }
122
122
  value = toNumber(value);
123
- if (value === INFINITY || value === -Infinity) {
123
+ if (value === INFINITY || value === -INFINITY) {
124
124
  var sign = value < 0 ? -1 : 1;
125
125
  return sign * MAX_INTEGER;
126
126
  }
@@ -1197,7 +1197,12 @@ function getAugmentedNamespace(n) {
1197
1197
  var f = n.default;
1198
1198
  if (typeof f == "function") {
1199
1199
  var a = function a2() {
1200
- if (this instanceof a2) {
1200
+ var isInstance = false;
1201
+ try {
1202
+ isInstance = this instanceof a2;
1203
+ } catch {
1204
+ }
1205
+ if (isInstance) {
1201
1206
  return Reflect.construct(f, arguments, this.constructor);
1202
1207
  }
1203
1208
  return f.apply(this, arguments);
@@ -6593,13 +6598,12 @@ function upgradeFrom0_1_0(config, datasetUid = null) {
6593
6598
  };
6594
6599
  const layout = [];
6595
6600
  config.staticLayout.forEach((componentDef) => {
6596
- var _a, _b, _c;
6597
6601
  let newComponentDef = {
6598
6602
  ...componentDef,
6599
6603
  coordinationScopes: {}
6600
6604
  };
6601
6605
  if (componentDef.component === "scatterplot") {
6602
- if (((_a = componentDef.props) == null ? void 0 : _a.mapping) && typeof componentDef.props.mapping === "string") {
6606
+ if (componentDef.props?.mapping && typeof componentDef.props.mapping === "string") {
6603
6607
  coordinationSpace.embeddingType[componentDef.props.mapping] = componentDef.props.mapping;
6604
6608
  newComponentDef = {
6605
6609
  ...newComponentDef,
@@ -6609,7 +6613,7 @@ function upgradeFrom0_1_0(config, datasetUid = null) {
6609
6613
  }
6610
6614
  };
6611
6615
  }
6612
- if ((_b = componentDef.props) == null ? void 0 : _b.view) {
6616
+ if (componentDef.props?.view) {
6613
6617
  const newScopeValues = upgradeReplaceViewProp("embedding", componentDef.props.view, coordinationSpace);
6614
6618
  newComponentDef = {
6615
6619
  ...newComponentDef,
@@ -6621,7 +6625,7 @@ function upgradeFrom0_1_0(config, datasetUid = null) {
6621
6625
  }
6622
6626
  }
6623
6627
  if (componentDef.component === "spatial") {
6624
- if ((_c = componentDef == null ? void 0 : componentDef.props) == null ? void 0 : _c.view) {
6628
+ if (componentDef?.props?.view) {
6625
6629
  const newScopeValues = upgradeReplaceViewProp("spatial", componentDef.props.view, coordinationSpace);
6626
6630
  newComponentDef = {
6627
6631
  ...newComponentDef,
@@ -6711,7 +6715,6 @@ function upgradeFrom1_0_0(config) {
6711
6715
  };
6712
6716
  }
6713
6717
  function upgradeFrom1_0_1(config) {
6714
- var _a;
6715
6718
  const layout = config.layout.map((component) => {
6716
6719
  const newComponent = { ...component };
6717
6720
  if (newComponent.component === "layerController") {
@@ -6723,9 +6726,8 @@ function upgradeFrom1_0_1(config) {
6723
6726
  return newComponent;
6724
6727
  });
6725
6728
  const newConfig = cloneDeep(config);
6726
- Object.keys(((_a = newConfig == null ? void 0 : newConfig.coordinationSpace) == null ? void 0 : _a.spatialRasterLayers) || {}).forEach((key) => {
6727
- var _a2, _b;
6728
- if ((_b = (_a2 = newConfig.coordinationSpace) == null ? void 0 : _a2.spatialRasterLayers) == null ? void 0 : _b[key]) {
6729
+ Object.keys(newConfig?.coordinationSpace?.spatialRasterLayers || {}).forEach((key) => {
6730
+ if (newConfig.coordinationSpace?.spatialRasterLayers?.[key]) {
6729
6731
  newConfig.coordinationSpace.spatialRasterLayers[key].forEach((layer, index) => {
6730
6732
  if (newConfig.coordinationSpace) {
6731
6733
  newConfig.coordinationSpace.spatialRasterLayers[key][index].type = ["bitmask", "raster"].includes(layer.type) ? layer.type : "raster";
@@ -6866,7 +6868,7 @@ function upgradeFrom1_0_10(config) {
6866
6868
  function upgradeFrom1_0_11(config) {
6867
6869
  const newConfig = cloneDeep(config);
6868
6870
  const { datasets, coordinationSpace } = newConfig;
6869
- if (coordinationSpace == null ? void 0 : coordinationSpace.embeddingType) {
6871
+ if (coordinationSpace?.embeddingType) {
6870
6872
  const embeddingTypes = Object.values(coordinationSpace.embeddingType);
6871
6873
  datasets.forEach((dataset, i) => {
6872
6874
  const { files } = dataset;
@@ -6899,7 +6901,7 @@ function upgradeFrom1_0_12(config) {
6899
6901
  if (options && "factors" in options && Array.isArray(options.factors)) {
6900
6902
  const obsLabelsTypeScopes = [];
6901
6903
  options.factors.forEach((olt) => {
6902
- const nextScope = getNextScope(Object.keys((coordinationSpace == null ? void 0 : coordinationSpace.obsLabelsType) || {}));
6904
+ const nextScope = getNextScope(Object.keys(coordinationSpace?.obsLabelsType || {}));
6903
6905
  newCoordinationSpace.obsLabelsType = {
6904
6906
  ...newCoordinationSpace.obsLabelsType,
6905
6907
  // Need to remove the obs/ prefix.
@@ -6913,8 +6915,7 @@ function upgradeFrom1_0_12(config) {
6913
6915
  });
6914
6916
  });
6915
6917
  function getDatasetUidForView(viewDef) {
6916
- var _a, _b;
6917
- if (((_a = viewDef.coordinationScopes) == null ? void 0 : _a.dataset) && typeof ((_b = viewDef.coordinationScopes) == null ? void 0 : _b.dataset) === "string") {
6918
+ if (viewDef.coordinationScopes?.dataset && typeof viewDef.coordinationScopes?.dataset === "string") {
6918
6919
  return newCoordinationSpace.dataset[viewDef.coordinationScopes.dataset];
6919
6920
  }
6920
6921
  if (datasets.length > 0) {
@@ -6977,8 +6978,7 @@ function upgradeFrom1_0_14(config) {
6977
6978
  };
6978
6979
  newLayout.forEach((viewDef) => {
6979
6980
  Object.entries(propAnalogies).forEach(([oldProp, newType]) => {
6980
- var _a;
6981
- if ((_a = viewDef.props) == null ? void 0 : _a[oldProp]) {
6981
+ if (viewDef.props?.[oldProp]) {
6982
6982
  log.warn(`Warning: the '${oldProp}' prop on the ${viewDef.component} view is deprecated. Please use the '${newType}' coordination type instead.`);
6983
6983
  }
6984
6984
  });
@@ -6995,7 +6995,7 @@ function upgradeFrom1_0_15(config) {
6995
6995
  const newLayout = layout.map((view) => {
6996
6996
  const { coordinationScopes } = view;
6997
6997
  const newCoordinationScopes = {};
6998
- if ((coordinationScopes == null ? void 0 : coordinationScopes.dataset) && Array.isArray(coordinationScopes.dataset)) {
6998
+ if (coordinationScopes?.dataset && Array.isArray(coordinationScopes.dataset)) {
6999
6999
  const coordinationScopesBy = {
7000
7000
  dataset: {}
7001
7001
  };
@@ -11818,7 +11818,7 @@ function getNextNumberedNodeName(nodes, prefix, suffix) {
11818
11818
  }
11819
11819
  function setObsSelection(cellSelection, additionalCellSets, cellSetColor, setCellSetSelection, setAdditionalCellSets, setCellSetColor, setCellColorEncoding, prefix = "Selection ", suffix = "") {
11820
11820
  const CELL_SELECTIONS_LEVEL_ZERO_NAME = "My Selections";
11821
- const selectionsLevelZeroNode = additionalCellSets == null ? void 0 : additionalCellSets.tree.find(
11821
+ const selectionsLevelZeroNode = additionalCellSets?.tree.find(
11822
11822
  (n) => n.name === CELL_SELECTIONS_LEVEL_ZERO_NAME
11823
11823
  );
11824
11824
  const nextAdditionalCellSets = {
@@ -11826,7 +11826,7 @@ function setObsSelection(cellSelection, additionalCellSets, cellSetColor, setCel
11826
11826
  datatype: SETS_DATATYPE_OBS,
11827
11827
  tree: [...additionalCellSets ? additionalCellSets.tree : []]
11828
11828
  };
11829
- const nextName = getNextNumberedNodeName(selectionsLevelZeroNode == null ? void 0 : selectionsLevelZeroNode.children, prefix, suffix);
11829
+ const nextName = getNextNumberedNodeName(selectionsLevelZeroNode?.children, prefix, suffix);
11830
11830
  let colorIndex = 0;
11831
11831
  if (selectionsLevelZeroNode) {
11832
11832
  colorIndex = selectionsLevelZeroNode.children.length;
@@ -11893,12 +11893,11 @@ function nodeToHeight(currNode, level = 0) {
11893
11893
  return Math.max(...childrenHeights, newLevel);
11894
11894
  }
11895
11895
  function getNodeLength(currNode) {
11896
- var _a;
11897
11896
  if (!currNode) {
11898
11897
  return 0;
11899
11898
  }
11900
11899
  if (!currNode.children) {
11901
- return ((_a = currNode.set) == null ? void 0 : _a.length) || 0;
11900
+ return currNode.set?.length || 0;
11902
11901
  }
11903
11902
  return currNode.children.reduce((acc, curr) => acc + getNodeLength(curr), 0);
11904
11903
  }
@@ -12035,8 +12034,7 @@ function treeExport(currTree, datatype) {
12035
12034
  function treeExportLevelZeroNode(currTree, nodePath, datatype, cellSetColors, theme) {
12036
12035
  const node = treeFindNodeByNamePath(currTree, nodePath);
12037
12036
  const nodeWithColors = nodeTransformAll(node, () => true, (n, nPath) => {
12038
- var _a;
12039
- const nodeColor = ((_a = cellSetColors == null ? void 0 : cellSetColors.find((c) => isEqual(c.path, nPath))) == null ? void 0 : _a.color) ?? getDefaultColor(theme);
12037
+ const nodeColor = cellSetColors?.find((c) => isEqual(c.path, nPath))?.color ?? getDefaultColor(theme);
12040
12038
  return {
12041
12039
  ...n,
12042
12040
  color: nodeColor.slice(0, 3)
@@ -12063,14 +12061,13 @@ function treeInitialize(datatype) {
12063
12061
  };
12064
12062
  }
12065
12063
  function nodeToRenderProps(node, path, cellSetColor) {
12066
- var _a;
12067
12064
  const level = path.length - 1;
12068
12065
  return {
12069
12066
  title: node.name,
12070
12067
  nodeKey: pathToKey(path),
12071
12068
  path,
12072
12069
  size: getNodeLength(node),
12073
- color: (_a = cellSetColor == null ? void 0 : cellSetColor.find((d) => isEqual(d.path, path))) == null ? void 0 : _a.color,
12070
+ color: cellSetColor?.find((d) => isEqual(d.path, path))?.color,
12074
12071
  level,
12075
12072
  isLeaf: (!node.children || node.children.length === 0) && Boolean(node.set),
12076
12073
  height: nodeToHeight(node)
@@ -12086,11 +12083,10 @@ function colorMixWithUncertainty(originalColor, p, mixingColor = [128, 128, 128]
12086
12083
  function treeToCellColorsBySetNames(currTree, selectedNamePaths, cellSetColor, theme) {
12087
12084
  let cellColorsArray = [];
12088
12085
  selectedNamePaths.forEach((setNamePath) => {
12089
- var _a;
12090
12086
  const node = treeFindNodeByNamePath(currTree, setNamePath);
12091
12087
  if (node) {
12092
12088
  const nodeSet = nodeToSet(node);
12093
- const nodeColor = ((_a = cellSetColor == null ? void 0 : cellSetColor.find((d) => isEqual(d.path, setNamePath))) == null ? void 0 : _a.color) || getDefaultColor(theme);
12089
+ const nodeColor = cellSetColor?.find((d) => isEqual(d.path, setNamePath))?.color || getDefaultColor(theme);
12094
12090
  cellColorsArray = [
12095
12091
  ...cellColorsArray,
12096
12092
  ...nodeSet.map(([cellId, prob]) => [
@@ -12125,11 +12121,11 @@ function treeToSelectedSetMap(currTree, selectedNamePaths) {
12125
12121
  }
12126
12122
  function treeToCellSetColorIndicesBySetNames(currTree, selectedNamePaths, cellSetColor) {
12127
12123
  let cellColorsArray = [];
12128
- selectedNamePaths == null ? void 0 : selectedNamePaths.forEach((setNamePath) => {
12124
+ selectedNamePaths?.forEach((setNamePath) => {
12129
12125
  const node = treeFindNodeByNamePath(currTree, setNamePath);
12130
12126
  if (node) {
12131
12127
  const nodeSet = nodeToSet(node);
12132
- const nodeColorIndex = cellSetColor == null ? void 0 : cellSetColor.findIndex((d) => isEqual(d.path, setNamePath));
12128
+ const nodeColorIndex = cellSetColor?.findIndex((d) => isEqual(d.path, setNamePath));
12133
12129
  cellColorsArray = [
12134
12130
  ...cellColorsArray,
12135
12131
  ...nodeSet.map(([cellId]) => [
@@ -12142,14 +12138,13 @@ function treeToCellSetColorIndicesBySetNames(currTree, selectedNamePaths, cellSe
12142
12138
  return new Map(cellColorsArray);
12143
12139
  }
12144
12140
  function treeToObjectsBySetNames(currTree, selectedNamePaths, setColor, theme) {
12145
- var _a;
12146
12141
  let cellsArray = [];
12147
12142
  for (let i = 0; i < selectedNamePaths.length; i += 1) {
12148
12143
  const setNamePath = selectedNamePaths[i];
12149
12144
  const node = treeFindNodeByNamePath(currTree, setNamePath);
12150
12145
  if (node) {
12151
12146
  const nodeSet = nodeToSet(node);
12152
- const nodeColor = ((_a = setColor == null ? void 0 : setColor.find((d) => isEqual(d.path, setNamePath))) == null ? void 0 : _a.color) || getDefaultColor(theme);
12147
+ const nodeColor = setColor?.find((d) => isEqual(d.path, setNamePath))?.color || getDefaultColor(theme);
12153
12148
  cellsArray = cellsArray.concat(nodeSet.map(([cellId]) => ({
12154
12149
  obsId: cellId,
12155
12150
  name: node.name,
@@ -12163,11 +12158,10 @@ function treeToCellPolygonsBySetNames(currTree, obsIndex, obsEmbedding, selected
12163
12158
  const obsIndexMap = new Map(obsIndex.map((key, i) => [key, i]));
12164
12159
  const cellSetPolygons = [];
12165
12160
  selectedNamePaths.forEach((setNamePath) => {
12166
- var _a;
12167
12161
  const node = treeFindNodeByNamePath(currTree, setNamePath);
12168
12162
  if (node) {
12169
12163
  const nodeSet = nodeToSet(node);
12170
- const nodeColor = ((_a = cellSetColor == null ? void 0 : cellSetColor.find((d) => isEqual(d.path, setNamePath))) == null ? void 0 : _a.color) || getDefaultColor(theme);
12164
+ const nodeColor = cellSetColor?.find((d) => isEqual(d.path, setNamePath))?.color || getDefaultColor(theme);
12171
12165
  const cellPositions = nodeSet.map(([cellId]) => {
12172
12166
  const cellIdx = obsIndexMap.get(cellId);
12173
12167
  return [
@@ -12200,11 +12194,10 @@ function treeToSetSizesBySetNames(currTree, allNamePaths, selectedNamePaths, set
12200
12194
  const sizes = [];
12201
12195
  const contains = (path, paths) => paths.some((p) => isEqual(p, path));
12202
12196
  allNamePaths.forEach((clusterPath) => {
12203
- var _a;
12204
12197
  const node = treeFindNodeByNamePath(currTree, clusterPath);
12205
12198
  if (node) {
12206
12199
  const nodeSet = nodeToSet(node);
12207
- const nodeColor = ((_a = setColor == null ? void 0 : setColor.find((d) => isEqual(d.path, clusterPath))) == null ? void 0 : _a.color) || getDefaultColor(theme);
12200
+ const nodeColor = setColor?.find((d) => isEqual(d.path, clusterPath))?.color || getDefaultColor(theme);
12208
12201
  const nodeProps = {
12209
12202
  key: generateKey(),
12210
12203
  name: node.name,
@@ -12432,7 +12425,7 @@ function findLongestCommonPath(arrOfPaths, cellSetSelection) {
12432
12425
  }
12433
12426
  function filterPathsByExpansionAndSelection(mergedCellSets, hierarchy, cellSetExpansion, cellSetSelection) {
12434
12427
  const paths = getPaths({ children: mergedCellSets.tree });
12435
- const contains = (allPaths, path) => allPaths == null ? void 0 : allPaths.some((p) => isEqual(p, path));
12428
+ const contains = (allPaths, path) => allPaths?.some((p) => isEqual(p, path));
12436
12429
  return paths.filter((clusterPath) => {
12437
12430
  if (contains(cellSetExpansion, clusterPath)) return false;
12438
12431
  if (!contains(cellSetSelection, clusterPath)) {
@@ -18097,11 +18090,10 @@ function stratifyArrays(sampleEdges, sampleIdToObsIdsMap, sampleSets, sampleSetS
18097
18090
  cellSetKeys.forEach((cellSetKey) => {
18098
18091
  result.set(cellSetKey, new InternMap([], JSON.stringify));
18099
18092
  sampleSetKeys.forEach((sampleSetKey) => {
18100
- var _a, _b;
18101
18093
  result.get(cellSetKey).set(sampleSetKey, new InternMap([], JSON.stringify));
18102
- const sampleIdsInSampleSet = (_a = sampleSetInfo && sampleSetKey ? sampleSetInfo == null ? void 0 : sampleSetInfo.find((n) => isEqual(n.path, sampleSetKey)) : null) == null ? void 0 : _a.ids;
18103
- const obsIdsInSampleSet = sampleIdsInSampleSet ? sampleIdsInSampleSet.flatMap((sampleId) => (sampleIdToObsIdsMap == null ? void 0 : sampleIdToObsIdsMap.get(sampleId)) || []) : null;
18104
- const obsIdsInCellSet = (_b = cellSetInfo && cellSetKey ? cellSetInfo == null ? void 0 : cellSetInfo.find((n) => isEqual(n.path, cellSetKey)) : null) == null ? void 0 : _b.ids;
18094
+ const sampleIdsInSampleSet = (sampleSetInfo && sampleSetKey ? sampleSetInfo?.find((n) => isEqual(n.path, sampleSetKey)) : null)?.ids;
18095
+ const obsIdsInSampleSet = sampleIdsInSampleSet ? sampleIdsInSampleSet.flatMap((sampleId) => sampleIdToObsIdsMap?.get(sampleId) || []) : null;
18096
+ const obsIdsInCellSet = (cellSetInfo && cellSetKey ? cellSetInfo?.find((n) => isEqual(n.path, cellSetKey)) : null)?.ids;
18105
18097
  let subObsIndex = obsIndex;
18106
18098
  if (obsIdsInSampleSet && obsIdsInCellSet) {
18107
18099
  subObsIndex = Array.from(
@@ -18126,9 +18118,9 @@ function stratifyArrays(sampleEdges, sampleIdToObsIdsMap, sampleSets, sampleSetS
18126
18118
  let cellCount = 0;
18127
18119
  for (let i = 0; i < obsIndex.length; i += 1) {
18128
18120
  const obsId = obsIndex[i];
18129
- const cellSet = (cellIdToSetMap == null ? void 0 : cellIdToSetMap.get(obsId)) || null;
18130
- const sampleId = sampleEdges == null ? void 0 : sampleEdges.get(obsId);
18131
- const sampleSet = sampleId ? (sampleIdToSetMap == null ? void 0 : sampleIdToSetMap.get(sampleId)) || null : null;
18121
+ const cellSet = cellIdToSetMap?.get(obsId) || null;
18122
+ const sampleId = sampleEdges?.get(obsId);
18123
+ const sampleSet = sampleId ? sampleIdToSetMap?.get(sampleId) || null : null;
18132
18124
  if (hasSampleSetSelection && !sampleSet || hasCellSetSelection && !cellSet) {
18133
18125
  continue;
18134
18126
  }
@@ -18191,14 +18183,13 @@ function stratifyExpressionData(sampleEdges, sampleSets, sampleSetSelection, exp
18191
18183
  let exprMax = -Infinity;
18192
18184
  for (let i = 0; i < obsIndex.length; i += 1) {
18193
18185
  const obsId = obsIndex[i];
18194
- const cellSet = cellIdToSetMap == null ? void 0 : cellIdToSetMap.get(obsId);
18195
- const sampleId = sampleEdges == null ? void 0 : sampleEdges.get(obsId);
18196
- const sampleSet = sampleId && hasSampleSetSelection ? sampleIdToSetMap == null ? void 0 : sampleIdToSetMap.get(sampleId) : null;
18186
+ const cellSet = cellIdToSetMap?.get(obsId);
18187
+ const sampleId = sampleEdges?.get(obsId);
18188
+ const sampleSet = sampleId && hasSampleSetSelection ? sampleIdToSetMap?.get(sampleId) : null;
18197
18189
  if (hasSampleSetSelection && !sampleSet) {
18198
18190
  continue;
18199
18191
  }
18200
18192
  geneKeys.forEach((geneKey, geneI) => {
18201
- var _a, _b, _c;
18202
18193
  const value = expressionData[geneI][i];
18203
18194
  const transformFunction = getValueTransformFunction(
18204
18195
  featureValueTransform,
@@ -18206,7 +18197,7 @@ function stratifyExpressionData(sampleEdges, sampleSets, sampleSetSelection, exp
18206
18197
  );
18207
18198
  const transformedValue = transformFunction(value);
18208
18199
  exprMax = Math.max(transformedValue, exprMax);
18209
- (_c = (_b = (_a = result.get(cellSet)) == null ? void 0 : _a.get(sampleSet)) == null ? void 0 : _b.get(geneKey)) == null ? void 0 : _c.push(transformedValue);
18200
+ result.get(cellSet)?.get(sampleSet)?.get(geneKey)?.push(transformedValue);
18210
18201
  });
18211
18202
  }
18212
18203
  return [result, exprMax];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vitessce/sets-utils",
3
- "version": "3.6.17",
3
+ "version": "3.7.0",
4
4
  "author": "HIDIVE Lab at HMS",
5
5
  "homepage": "http://vitessce.io",
6
6
  "repository": {
@@ -25,12 +25,12 @@
25
25
  "lodash-es": "^4.17.21",
26
26
  "tinycolor2": "^1.4.1",
27
27
  "uuid": "^9.0.0",
28
- "@vitessce/schemas": "3.6.17",
29
- "@vitessce/utils": "3.6.17",
30
- "@vitessce/globals": "3.6.17"
28
+ "@vitessce/schemas": "3.7.0",
29
+ "@vitessce/utils": "3.7.0",
30
+ "@vitessce/globals": "3.7.0"
31
31
  },
32
32
  "scripts": {
33
- "bundle": "pnpm exec vite build -c ../../../scripts/vite.config.js",
33
+ "bundle": "pnpm exec vite build -c ../../../scripts/vite.config.mjs",
34
34
  "test": "pnpm exec vitest --run"
35
35
  },
36
36
  "module": "dist/index.js",