@vitessce/statistical-plots 3.5.6 → 3.5.7

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.
@@ -960,7 +960,8 @@ const ViewType$1 = {
960
960
  FEATURE_BAR_PLOT: "featureBarPlot",
961
961
  BIOMARKER_SELECT: "biomarkerSelect",
962
962
  LINK_CONTROLLER: "linkController",
963
- DUAL_SCATTERPLOT: "dualScatterplot"
963
+ DUAL_SCATTERPLOT: "dualScatterplot",
964
+ TREEMAP: "treemap"
964
965
  };
965
966
  const DataType$2 = {
966
967
  OBS_LABELS: "obsLabels",
@@ -1014,6 +1015,7 @@ const FileType$1 = {
1014
1015
  OBS_LABELS_ANNDATA_ZARR: "obsLabels.anndata.zarr",
1015
1016
  FEATURE_LABELS_ANNDATA_ZARR: "featureLabels.anndata.zarr",
1016
1017
  SAMPLE_EDGES_ANNDATA_ZARR: "sampleEdges.anndata.zarr",
1018
+ SAMPLE_SETS_ANNDATA_ZARR: "sampleSets.anndata.zarr",
1017
1019
  // AnnData - zipped
1018
1020
  OBS_FEATURE_MATRIX_ANNDATA_ZARR_ZIP: "obsFeatureMatrix.anndata.zarr.zip",
1019
1021
  OBS_FEATURE_COLUMNS_ANNDATA_ZARR_ZIP: "obsFeatureColumns.anndata.zarr.zip",
@@ -1026,6 +1028,7 @@ const FileType$1 = {
1026
1028
  OBS_LABELS_ANNDATA_ZARR_ZIP: "obsLabels.anndata.zarr.zip",
1027
1029
  FEATURE_LABELS_ANNDATA_ZARR_ZIP: "featureLabels.anndata.zarr.zip",
1028
1030
  SAMPLE_EDGES_ANNDATA_ZARR_ZIP: "sampleEdges.anndata.zarr.zip",
1031
+ SAMPLE_SETS_ANNDATA_ZARR_ZIP: "sampleSets.anndata.zarr.zip",
1029
1032
  // AnnData - h5ad via reference spec
1030
1033
  OBS_FEATURE_MATRIX_ANNDATA_H5AD: "obsFeatureMatrix.anndata.h5ad",
1031
1034
  OBS_FEATURE_COLUMNS_ANNDATA_H5AD: "obsFeatureColumns.anndata.h5ad",
@@ -1038,6 +1041,7 @@ const FileType$1 = {
1038
1041
  OBS_LABELS_ANNDATA_H5AD: "obsLabels.anndata.h5ad",
1039
1042
  FEATURE_LABELS_ANNDATA_H5AD: "featureLabels.anndata.h5ad",
1040
1043
  SAMPLE_EDGES_ANNDATA_H5AD: "sampleEdges.anndata.h5ad",
1044
+ SAMPLE_SETS_ANNDATA_H5AD: "sampleSets.anndata.h5ad",
1041
1045
  // SpatialData
1042
1046
  IMAGE_SPATIALDATA_ZARR: "image.spatialdata.zarr",
1043
1047
  LABELS_SPATIALDATA_ZARR: "labels.spatialdata.zarr",
@@ -1229,12 +1233,15 @@ const CoordinationType$1 = {
1229
1233
  SAMPLE_SET_FILTER: "sampleSetFilter",
1230
1234
  SAMPLE_FILTER_MODE: "sampleFilterMode",
1231
1235
  SAMPLE_SET_COLOR: "sampleSetColor",
1236
+ SAMPLE_HIGHLIGHT: "sampleHighlight",
1232
1237
  EMBEDDING_POINTS_VISIBLE: "embeddingPointsVisible",
1233
1238
  EMBEDDING_CONTOURS_VISIBLE: "embeddingContoursVisible",
1234
1239
  EMBEDDING_CONTOURS_FILLED: "embeddingContoursFilled",
1235
1240
  EMBEDDING_CONTOUR_PERCENTILES: "embeddingContourPercentiles",
1236
1241
  CONTOUR_COLOR_ENCODING: "contourColorEncoding",
1237
- CONTOUR_COLOR: "contourColor"
1242
+ CONTOUR_COLOR: "contourColor",
1243
+ // Treemap
1244
+ HIERARCHY_LEVELS: "hierarchyLevels"
1238
1245
  };
1239
1246
  const ViewHelpMapping = {
1240
1247
  SCATTERPLOT: "The scatterplot displays two-dimensional (pre-computed) dimensionality reduction results (such as from t-SNE or UMAP). Each point on the scatterplot represents an observation (e.g., cell).",
@@ -1251,7 +1258,8 @@ const ViewHelpMapping = {
1251
1258
  OBS_SET_FEATURE_VALUE_DISTRIBUTION: "The observation set feature value distribution view displays a violin plot with values (e.g., expression values) per set (e.g., cell type) for the selected feature (e.g., gene).",
1252
1259
  FEATURE_VALUE_HISTOGRAM: "The feature value histogram displays the distribution of values (e.g., expression) for the selected feature (e.g., gene).",
1253
1260
  DOT_PLOT: "The dot plot displays summary information about expression of the selected features (e.g., genes) for each selected observation set (e.g., cell type).",
1254
- FEATURE_BAR_PLOT: "The feature bar plot displays one bar per observation (e.g., cell) along the x-axis, where the value of a selected feature (e.g., gene) is encoded along the y-axis."
1261
+ FEATURE_BAR_PLOT: "The feature bar plot displays one bar per observation (e.g., cell) along the x-axis, where the value of a selected feature (e.g., gene) is encoded along the y-axis.",
1262
+ TREEMAP: "The treemap provides an overview of the current state of sample-level or cell-level selection and filtering."
1255
1263
  };
1256
1264
  const COMPONENT_COORDINATION_TYPES = {
1257
1265
  [ViewType$1.SCATTERPLOT]: [
@@ -1731,6 +1739,32 @@ const COMPONENT_COORDINATION_TYPES = {
1731
1739
  CoordinationType$1.OBS_SET_SELECTION,
1732
1740
  CoordinationType$1.OBS_SET_FILTER
1733
1741
  // TODO: create coordination types for internal state of the biomarker selection view?
1742
+ ],
1743
+ [ViewType$1.TREEMAP]: [
1744
+ CoordinationType$1.DATASET,
1745
+ CoordinationType$1.OBS_TYPE,
1746
+ CoordinationType$1.FEATURE_TYPE,
1747
+ CoordinationType$1.FEATURE_VALUE_TYPE,
1748
+ CoordinationType$1.OBS_FILTER,
1749
+ CoordinationType$1.OBS_HIGHLIGHT,
1750
+ CoordinationType$1.OBS_SET_SELECTION,
1751
+ CoordinationType$1.OBS_SET_FILTER,
1752
+ CoordinationType$1.OBS_SELECTION,
1753
+ CoordinationType$1.OBS_SELECTION_MODE,
1754
+ CoordinationType$1.OBS_SET_HIGHLIGHT,
1755
+ CoordinationType$1.OBS_SET_COLOR,
1756
+ CoordinationType$1.OBS_COLOR_ENCODING,
1757
+ CoordinationType$1.ADDITIONAL_OBS_SETS,
1758
+ CoordinationType$1.SAMPLE_TYPE,
1759
+ CoordinationType$1.SAMPLE_SET_SELECTION,
1760
+ CoordinationType$1.SAMPLE_SET_FILTER,
1761
+ CoordinationType$1.SAMPLE_SET_COLOR,
1762
+ CoordinationType$1.SAMPLE_SELECTION,
1763
+ CoordinationType$1.SAMPLE_SELECTION_MODE,
1764
+ CoordinationType$1.SAMPLE_FILTER,
1765
+ CoordinationType$1.SAMPLE_FILTER_MODE,
1766
+ CoordinationType$1.SAMPLE_HIGHLIGHT,
1767
+ CoordinationType$1.HIERARCHY_LEVELS
1734
1768
  ]
1735
1769
  };
1736
1770
  function commonjsRequire(path2) {
@@ -2090,6 +2124,10 @@ var pluralizeExports = pluralize$1.exports;
2090
2124
  const plur = /* @__PURE__ */ getDefaultExportFromCjs(pluralizeExports);
2091
2125
  plur.addPluralRule("glomerulus", "glomeruli");
2092
2126
  plur.addPluralRule("interstitium", "interstitia");
2127
+ function commaNumber(n2) {
2128
+ const nf = new Intl.NumberFormat("en-US");
2129
+ return nf.format(n2);
2130
+ }
2093
2131
  function capitalize$2(word) {
2094
2132
  return word ? word.charAt(0).toUpperCase() + word.slice(1) : "";
2095
2133
  }
@@ -2131,6 +2169,279 @@ function getNextScope(prevScopes) {
2131
2169
  } while (prevScopes.includes(nextScope));
2132
2170
  return nextScope;
2133
2171
  }
2172
+ const identityFunc = (d) => d;
2173
+ function unnestMap(map2, keys3, aggFunc) {
2174
+ if (keys3.length < 2) {
2175
+ throw new Error("Insufficient number of keys passed to flattenInternMap");
2176
+ }
2177
+ const aggFuncToUse = !aggFunc ? identityFunc : aggFunc;
2178
+ return Array.from(map2.entries()).flatMap(([k, v]) => {
2179
+ if (v instanceof Map) {
2180
+ const keysWithoutFirst = [...keys3];
2181
+ keysWithoutFirst.splice(0, 1);
2182
+ return unnestMap(v, keysWithoutFirst, aggFuncToUse).map((childObj) => ({
2183
+ [keys3[0]]: k,
2184
+ ...childObj
2185
+ }));
2186
+ }
2187
+ return {
2188
+ [keys3[0]]: k,
2189
+ [keys3[1]]: aggFuncToUse(v)
2190
+ };
2191
+ });
2192
+ }
2193
+ var loglevel = { exports: {} };
2194
+ (function(module2) {
2195
+ (function(root2, definition2) {
2196
+ if (module2.exports) {
2197
+ module2.exports = definition2();
2198
+ } else {
2199
+ root2.log = definition2();
2200
+ }
2201
+ })(commonjsGlobal, function() {
2202
+ var noop2 = function() {
2203
+ };
2204
+ var undefinedType2 = "undefined";
2205
+ var isIE = typeof window !== undefinedType2 && typeof window.navigator !== undefinedType2 && /Trident\/|MSIE /.test(window.navigator.userAgent);
2206
+ var logMethods = [
2207
+ "trace",
2208
+ "debug",
2209
+ "info",
2210
+ "warn",
2211
+ "error"
2212
+ ];
2213
+ var _loggersByName = {};
2214
+ var defaultLogger = null;
2215
+ function bindMethod(obj, methodName) {
2216
+ var method2 = obj[methodName];
2217
+ if (typeof method2.bind === "function") {
2218
+ return method2.bind(obj);
2219
+ } else {
2220
+ try {
2221
+ return Function.prototype.bind.call(method2, obj);
2222
+ } catch (e3) {
2223
+ return function() {
2224
+ return Function.prototype.apply.apply(method2, [obj, arguments]);
2225
+ };
2226
+ }
2227
+ }
2228
+ }
2229
+ function traceForIE() {
2230
+ if (console.log) {
2231
+ if (console.log.apply) {
2232
+ console.log.apply(console, arguments);
2233
+ } else {
2234
+ Function.prototype.apply.apply(console.log, [console, arguments]);
2235
+ }
2236
+ }
2237
+ if (console.trace)
2238
+ console.trace();
2239
+ }
2240
+ function realMethod(methodName) {
2241
+ if (methodName === "debug") {
2242
+ methodName = "log";
2243
+ }
2244
+ if (typeof console === undefinedType2) {
2245
+ return false;
2246
+ } else if (methodName === "trace" && isIE) {
2247
+ return traceForIE;
2248
+ } else if (console[methodName] !== void 0) {
2249
+ return bindMethod(console, methodName);
2250
+ } else if (console.log !== void 0) {
2251
+ return bindMethod(console, "log");
2252
+ } else {
2253
+ return noop2;
2254
+ }
2255
+ }
2256
+ function replaceLoggingMethods() {
2257
+ var level = this.getLevel();
2258
+ for (var i2 = 0; i2 < logMethods.length; i2++) {
2259
+ var methodName = logMethods[i2];
2260
+ this[methodName] = i2 < level ? noop2 : this.methodFactory(methodName, level, this.name);
2261
+ }
2262
+ this.log = this.debug;
2263
+ if (typeof console === undefinedType2 && level < this.levels.SILENT) {
2264
+ return "No console available for logging";
2265
+ }
2266
+ }
2267
+ function enableLoggingWhenConsoleArrives(methodName) {
2268
+ return function() {
2269
+ if (typeof console !== undefinedType2) {
2270
+ replaceLoggingMethods.call(this);
2271
+ this[methodName].apply(this, arguments);
2272
+ }
2273
+ };
2274
+ }
2275
+ function defaultMethodFactory(methodName, _level, _loggerName) {
2276
+ return realMethod(methodName) || enableLoggingWhenConsoleArrives.apply(this, arguments);
2277
+ }
2278
+ function Logger(name2, factory) {
2279
+ var self2 = this;
2280
+ var inheritedLevel;
2281
+ var defaultLevel;
2282
+ var userLevel;
2283
+ var storageKey = "loglevel";
2284
+ if (typeof name2 === "string") {
2285
+ storageKey += ":" + name2;
2286
+ } else if (typeof name2 === "symbol") {
2287
+ storageKey = void 0;
2288
+ }
2289
+ function persistLevelIfPossible(levelNum) {
2290
+ var levelName = (logMethods[levelNum] || "silent").toUpperCase();
2291
+ if (typeof window === undefinedType2 || !storageKey)
2292
+ return;
2293
+ try {
2294
+ window.localStorage[storageKey] = levelName;
2295
+ return;
2296
+ } catch (ignore) {
2297
+ }
2298
+ try {
2299
+ window.document.cookie = encodeURIComponent(storageKey) + "=" + levelName + ";";
2300
+ } catch (ignore) {
2301
+ }
2302
+ }
2303
+ function getPersistedLevel() {
2304
+ var storedLevel;
2305
+ if (typeof window === undefinedType2 || !storageKey)
2306
+ return;
2307
+ try {
2308
+ storedLevel = window.localStorage[storageKey];
2309
+ } catch (ignore) {
2310
+ }
2311
+ if (typeof storedLevel === undefinedType2) {
2312
+ try {
2313
+ var cookie = window.document.cookie;
2314
+ var cookieName = encodeURIComponent(storageKey);
2315
+ var location = cookie.indexOf(cookieName + "=");
2316
+ if (location !== -1) {
2317
+ storedLevel = /^([^;]+)/.exec(
2318
+ cookie.slice(location + cookieName.length + 1)
2319
+ )[1];
2320
+ }
2321
+ } catch (ignore) {
2322
+ }
2323
+ }
2324
+ if (self2.levels[storedLevel] === void 0) {
2325
+ storedLevel = void 0;
2326
+ }
2327
+ return storedLevel;
2328
+ }
2329
+ function clearPersistedLevel() {
2330
+ if (typeof window === undefinedType2 || !storageKey)
2331
+ return;
2332
+ try {
2333
+ window.localStorage.removeItem(storageKey);
2334
+ } catch (ignore) {
2335
+ }
2336
+ try {
2337
+ window.document.cookie = encodeURIComponent(storageKey) + "=; expires=Thu, 01 Jan 1970 00:00:00 UTC";
2338
+ } catch (ignore) {
2339
+ }
2340
+ }
2341
+ function normalizeLevel(input) {
2342
+ var level = input;
2343
+ if (typeof level === "string" && self2.levels[level.toUpperCase()] !== void 0) {
2344
+ level = self2.levels[level.toUpperCase()];
2345
+ }
2346
+ if (typeof level === "number" && level >= 0 && level <= self2.levels.SILENT) {
2347
+ return level;
2348
+ } else {
2349
+ throw new TypeError("log.setLevel() called with invalid level: " + input);
2350
+ }
2351
+ }
2352
+ self2.name = name2;
2353
+ self2.levels = {
2354
+ "TRACE": 0,
2355
+ "DEBUG": 1,
2356
+ "INFO": 2,
2357
+ "WARN": 3,
2358
+ "ERROR": 4,
2359
+ "SILENT": 5
2360
+ };
2361
+ self2.methodFactory = factory || defaultMethodFactory;
2362
+ self2.getLevel = function() {
2363
+ if (userLevel != null) {
2364
+ return userLevel;
2365
+ } else if (defaultLevel != null) {
2366
+ return defaultLevel;
2367
+ } else {
2368
+ return inheritedLevel;
2369
+ }
2370
+ };
2371
+ self2.setLevel = function(level, persist) {
2372
+ userLevel = normalizeLevel(level);
2373
+ if (persist !== false) {
2374
+ persistLevelIfPossible(userLevel);
2375
+ }
2376
+ return replaceLoggingMethods.call(self2);
2377
+ };
2378
+ self2.setDefaultLevel = function(level) {
2379
+ defaultLevel = normalizeLevel(level);
2380
+ if (!getPersistedLevel()) {
2381
+ self2.setLevel(level, false);
2382
+ }
2383
+ };
2384
+ self2.resetLevel = function() {
2385
+ userLevel = null;
2386
+ clearPersistedLevel();
2387
+ replaceLoggingMethods.call(self2);
2388
+ };
2389
+ self2.enableAll = function(persist) {
2390
+ self2.setLevel(self2.levels.TRACE, persist);
2391
+ };
2392
+ self2.disableAll = function(persist) {
2393
+ self2.setLevel(self2.levels.SILENT, persist);
2394
+ };
2395
+ self2.rebuild = function() {
2396
+ if (defaultLogger !== self2) {
2397
+ inheritedLevel = normalizeLevel(defaultLogger.getLevel());
2398
+ }
2399
+ replaceLoggingMethods.call(self2);
2400
+ if (defaultLogger === self2) {
2401
+ for (var childName in _loggersByName) {
2402
+ _loggersByName[childName].rebuild();
2403
+ }
2404
+ }
2405
+ };
2406
+ inheritedLevel = normalizeLevel(
2407
+ defaultLogger ? defaultLogger.getLevel() : "WARN"
2408
+ );
2409
+ var initialLevel = getPersistedLevel();
2410
+ if (initialLevel != null) {
2411
+ userLevel = normalizeLevel(initialLevel);
2412
+ }
2413
+ replaceLoggingMethods.call(self2);
2414
+ }
2415
+ defaultLogger = new Logger();
2416
+ defaultLogger.getLogger = function getLogger(name2) {
2417
+ if (typeof name2 !== "symbol" && typeof name2 !== "string" || name2 === "") {
2418
+ throw new TypeError("You must supply a name when creating a logger.");
2419
+ }
2420
+ var logger2 = _loggersByName[name2];
2421
+ if (!logger2) {
2422
+ logger2 = _loggersByName[name2] = new Logger(
2423
+ name2,
2424
+ defaultLogger.methodFactory
2425
+ );
2426
+ }
2427
+ return logger2;
2428
+ };
2429
+ var _log = typeof window !== undefinedType2 ? window.log : void 0;
2430
+ defaultLogger.noConflict = function() {
2431
+ if (typeof window !== undefinedType2 && window.log === defaultLogger) {
2432
+ window.log = _log;
2433
+ }
2434
+ return defaultLogger;
2435
+ };
2436
+ defaultLogger.getLoggers = function getLoggers2() {
2437
+ return _loggersByName;
2438
+ };
2439
+ defaultLogger["default"] = defaultLogger;
2440
+ return defaultLogger;
2441
+ });
2442
+ })(loglevel);
2443
+ var loglevelExports = loglevel.exports;
2444
+ const log$b = /* @__PURE__ */ getDefaultExportFromCjs(loglevelExports);
2134
2445
  const DEFAULT_DARK_COLOR = [50, 50, 50];
2135
2446
  const DEFAULT_LIGHT_COLOR$3 = [200, 200, 200];
2136
2447
  const DEFAULT_LIGHT2_COLOR = [235, 235, 235];
@@ -9507,7 +9818,7 @@ function upgradeFrom1_0_14(config2) {
9507
9818
  Object.entries(propAnalogies).forEach(([oldProp, newType]) => {
9508
9819
  var _a2;
9509
9820
  if ((_a2 = viewDef.props) == null ? void 0 : _a2[oldProp]) {
9510
- console.warn(`Warning: the '${oldProp}' prop on the ${viewDef.component} view is deprecated. Please use the '${newType}' coordination type instead.`);
9821
+ log$b.warn(`Warning: the '${oldProp}' prop on the ${viewDef.component} view is deprecated. Please use the '${newType}' coordination type instead.`);
9511
9822
  }
9512
9823
  });
9513
9824
  });
@@ -9530,7 +9841,7 @@ function upgradeFrom1_0_15(config2) {
9530
9841
  Object.entries(coordinationScopes).forEach(([coordinationType, coordinationScope]) => {
9531
9842
  if (!Array.isArray(coordinationScope) && typeof coordinationScope === "object") {
9532
9843
  if (coordinationType === "dataset") {
9533
- console.error("Expected coordinationScopes.dataset value to be either string or string[], but got object.");
9844
+ log$b.error("Expected coordinationScopes.dataset value to be either string or string[], but got object.");
9534
9845
  }
9535
9846
  coordinationScopesBy.dataset[coordinationType] = coordinationScope;
9536
9847
  } else if (Array.isArray(coordinationScope) || typeof coordinationScope === "string") {
@@ -11889,7 +12200,7 @@ function makeConstantWithDeprecationMessage(currObj, oldObj) {
11889
12200
  const oldKeys = Object.keys(oldObj);
11890
12201
  const propKey = String(prop);
11891
12202
  if (oldKeys.includes(propKey)) {
11892
- console.warn(`Notice about the constant mapping ${propKey}: '${oldObj[propKey][0]}':
12203
+ log$b.warn(`Notice about the constant mapping ${propKey}: '${oldObj[propKey][0]}':
11893
12204
  ${oldObj[propKey][1]}`);
11894
12205
  return oldObj[propKey];
11895
12206
  }
@@ -11987,6 +12298,9 @@ const annDataObsSetsArr = z.array(z.object({
11987
12298
  z.object({
11988
12299
  obsSets: annDataObsSetsArr
11989
12300
  });
12301
+ z.object({
12302
+ sampleSets: annDataObsSetsArr
12303
+ });
11990
12304
  const annDataObsFeatureColumnsArr = z.array(z.object({
11991
12305
  path: z.string()
11992
12306
  }));
@@ -18872,8 +19186,8 @@ var json2csv_umd = { exports: {} };
18872
19186
  Object.defineProperty(exports3, "__esModule", { value: true });
18873
19187
  });
18874
19188
  })(json2csv_umd, json2csv_umd.exports);
18875
- class InternMap extends Map {
18876
- constructor(entries2, key2 = keyof) {
19189
+ let InternMap$1 = class InternMap extends Map {
19190
+ constructor(entries2, key2 = keyof$1) {
18877
19191
  super();
18878
19192
  Object.defineProperties(this, { _intern: { value: /* @__PURE__ */ new Map() }, _key: { value: key2 } });
18879
19193
  if (entries2 != null)
@@ -18881,20 +19195,20 @@ class InternMap extends Map {
18881
19195
  this.set(key22, value2);
18882
19196
  }
18883
19197
  get(key2) {
18884
- return super.get(intern_get(this, key2));
19198
+ return super.get(intern_get$1(this, key2));
18885
19199
  }
18886
19200
  has(key2) {
18887
- return super.has(intern_get(this, key2));
19201
+ return super.has(intern_get$1(this, key2));
18888
19202
  }
18889
19203
  set(key2, value2) {
18890
- return super.set(intern_set(this, key2), value2);
19204
+ return super.set(intern_set$1(this, key2), value2);
18891
19205
  }
18892
19206
  delete(key2) {
18893
- return super.delete(intern_delete(this, key2));
19207
+ return super.delete(intern_delete$1(this, key2));
18894
19208
  }
18895
- }
19209
+ };
18896
19210
  class InternSet extends Set {
18897
- constructor(values2, key2 = keyof) {
19211
+ constructor(values2, key2 = keyof$1) {
18898
19212
  super();
18899
19213
  Object.defineProperties(this, { _intern: { value: /* @__PURE__ */ new Map() }, _key: { value: key2 } });
18900
19214
  if (values2 != null)
@@ -18902,27 +19216,27 @@ class InternSet extends Set {
18902
19216
  this.add(value2);
18903
19217
  }
18904
19218
  has(value2) {
18905
- return super.has(intern_get(this, value2));
19219
+ return super.has(intern_get$1(this, value2));
18906
19220
  }
18907
19221
  add(value2) {
18908
- return super.add(intern_set(this, value2));
19222
+ return super.add(intern_set$1(this, value2));
18909
19223
  }
18910
19224
  delete(value2) {
18911
- return super.delete(intern_delete(this, value2));
19225
+ return super.delete(intern_delete$1(this, value2));
18912
19226
  }
18913
19227
  }
18914
- function intern_get({ _intern, _key }, value2) {
19228
+ function intern_get$1({ _intern, _key }, value2) {
18915
19229
  const key2 = _key(value2);
18916
19230
  return _intern.has(key2) ? _intern.get(key2) : value2;
18917
19231
  }
18918
- function intern_set({ _intern, _key }, value2) {
19232
+ function intern_set$1({ _intern, _key }, value2) {
18919
19233
  const key2 = _key(value2);
18920
19234
  if (_intern.has(key2))
18921
19235
  return _intern.get(key2);
18922
19236
  _intern.set(key2, value2);
18923
19237
  return value2;
18924
19238
  }
18925
- function intern_delete({ _intern, _key }, value2) {
19239
+ function intern_delete$1({ _intern, _key }, value2) {
18926
19240
  const key2 = _key(value2);
18927
19241
  if (_intern.has(key2)) {
18928
19242
  value2 = _intern.get(key2);
@@ -18930,7 +19244,7 @@ function intern_delete({ _intern, _key }, value2) {
18930
19244
  }
18931
19245
  return value2;
18932
19246
  }
18933
- function keyof(value2) {
19247
+ function keyof$1(value2) {
18934
19248
  return value2 !== null && typeof value2 === "object" ? value2.valueOf() : value2;
18935
19249
  }
18936
19250
  const schemeRdBu = [[103, 0, 31], [178, 24, 43], [214, 96, 77], [244, 165, 130], [253, 219, 199], [247, 247, 247], [209, 229, 240], [146, 197, 222], [67, 147, 195], [33, 102, 172], [5, 48, 97]];
@@ -18979,7 +19293,7 @@ function interpolateSequentialMulti(range2) {
18979
19293
  interpolateRgbBasis(schemeRdBu);
18980
19294
  interpolateSequentialMulti(schemePlasma);
18981
19295
  function stratifyExpressionData(sampleEdges, sampleSets, sampleSetSelection, expressionData, obsIndex, mergedCellSets, geneSelection, cellSetSelection, cellSetColor, featureValueTransform, featureValueTransformCoefficient) {
18982
- const result = new InternMap([], JSON.stringify);
19296
+ const result = new InternMap$1([], JSON.stringify);
18983
19297
  const hasSampleSetSelection = Array.isArray(sampleSetSelection) && sampleSetSelection.length > 0;
18984
19298
  const hasCellSetSelection = Array.isArray(cellSetSelection) && cellSetSelection.length > 0;
18985
19299
  const hasGeneSelection = Array.isArray(geneSelection) && geneSelection.length > 0;
@@ -18987,9 +19301,9 @@ function stratifyExpressionData(sampleEdges, sampleSets, sampleSetSelection, exp
18987
19301
  const cellSetKeys = hasCellSetSelection ? cellSetSelection : [null];
18988
19302
  const geneKeys = hasGeneSelection ? geneSelection : [null];
18989
19303
  cellSetKeys.forEach((cellSetKey) => {
18990
- result.set(cellSetKey, new InternMap([], JSON.stringify));
19304
+ result.set(cellSetKey, new InternMap$1([], JSON.stringify));
18991
19305
  sampleSetKeys.forEach((sampleSetKey) => {
18992
- result.get(cellSetKey).set(sampleSetKey, new InternMap([], JSON.stringify));
19306
+ result.get(cellSetKey).set(sampleSetKey, new InternMap$1([], JSON.stringify));
18993
19307
  geneKeys.forEach((geneKey) => {
18994
19308
  result.get(cellSetKey).get(sampleSetKey).set(geneKey, []);
18995
19309
  });
@@ -19021,9 +19335,9 @@ function stratifyExpressionData(sampleEdges, sampleSets, sampleSetSelection, exp
19021
19335
  return [null, null];
19022
19336
  }
19023
19337
  function aggregateStratifiedExpressionData(stratifiedResult, geneSelection) {
19024
- const result = new InternMap([], JSON.stringify);
19338
+ const result = new InternMap$1([], JSON.stringify);
19025
19339
  Array.from(stratifiedResult.entries()).forEach(([cellSetKey, firstLevelInternMap]) => {
19026
- result.set(cellSetKey, new InternMap([], JSON.stringify));
19340
+ result.set(cellSetKey, new InternMap$1([], JSON.stringify));
19027
19341
  Array.from(firstLevelInternMap.entries()).forEach(([sampleSetKey, secondLevelInternMap]) => {
19028
19342
  const values2 = secondLevelInternMap.get(geneSelection[0]);
19029
19343
  result.get(cellSetKey).set(sampleSetKey, values2);
@@ -133193,16 +133507,16 @@ function addDecoder(cases2, importFn) {
133193
133507
  }
133194
133508
  cases2.forEach((c2) => registry$1.set(c2, importFn));
133195
133509
  }
133196
- addDecoder([void 0, 1], () => import("./raw-9317b0fd.js").then((m2) => m2.default));
133197
- addDecoder(5, () => import("./lzw-b906a3b9.js").then((m2) => m2.default));
133510
+ addDecoder([void 0, 1], () => import("./raw-01dff90e.js").then((m2) => m2.default));
133511
+ addDecoder(5, () => import("./lzw-e60fb582.js").then((m2) => m2.default));
133198
133512
  addDecoder(6, () => {
133199
133513
  throw new Error("old style JPEG compression is not supported.");
133200
133514
  });
133201
- addDecoder(7, () => import("./jpeg-00a52550.js").then((m2) => m2.default));
133202
- addDecoder([8, 32946], () => import("./deflate-70ede287.js").then((m2) => m2.default));
133203
- addDecoder(32773, () => import("./packbits-10b5f4aa.js").then((m2) => m2.default));
133204
- addDecoder(34887, () => import("./lerc-55c1ff7e.js").then((m2) => m2.default));
133205
- addDecoder(50001, () => import("./webimage-1c43145b.js").then((m2) => m2.default));
133515
+ addDecoder(7, () => import("./jpeg-1b2c1d25.js").then((m2) => m2.default));
133516
+ addDecoder([8, 32946], () => import("./deflate-287e693d.js").then((m2) => m2.default));
133517
+ addDecoder(32773, () => import("./packbits-a8bfe098.js").then((m2) => m2.default));
133518
+ addDecoder(34887, () => import("./lerc-4f010cd7.js").then((m2) => m2.default));
133519
+ addDecoder(50001, () => import("./webimage-6b926ce3.js").then((m2) => m2.default));
133206
133520
  function decodeRowAcc(row, stride) {
133207
133521
  let length2 = row.length - stride;
133208
133522
  let offset5 = 0;
@@ -143418,9 +143732,76 @@ function extent$1(values2, valueof) {
143418
143732
  }
143419
143733
  return [min2, max2];
143420
143734
  }
143735
+ class InternMap2 extends Map {
143736
+ constructor(entries2, key2 = keyof) {
143737
+ super();
143738
+ Object.defineProperties(this, { _intern: { value: /* @__PURE__ */ new Map() }, _key: { value: key2 } });
143739
+ if (entries2 != null)
143740
+ for (const [key22, value2] of entries2)
143741
+ this.set(key22, value2);
143742
+ }
143743
+ get(key2) {
143744
+ return super.get(intern_get(this, key2));
143745
+ }
143746
+ has(key2) {
143747
+ return super.has(intern_get(this, key2));
143748
+ }
143749
+ set(key2, value2) {
143750
+ return super.set(intern_set(this, key2), value2);
143751
+ }
143752
+ delete(key2) {
143753
+ return super.delete(intern_delete(this, key2));
143754
+ }
143755
+ }
143756
+ function intern_get({ _intern, _key }, value2) {
143757
+ const key2 = _key(value2);
143758
+ return _intern.has(key2) ? _intern.get(key2) : value2;
143759
+ }
143760
+ function intern_set({ _intern, _key }, value2) {
143761
+ const key2 = _key(value2);
143762
+ if (_intern.has(key2))
143763
+ return _intern.get(key2);
143764
+ _intern.set(key2, value2);
143765
+ return value2;
143766
+ }
143767
+ function intern_delete({ _intern, _key }, value2) {
143768
+ const key2 = _key(value2);
143769
+ if (_intern.has(key2)) {
143770
+ value2 = _intern.get(value2);
143771
+ _intern.delete(key2);
143772
+ }
143773
+ return value2;
143774
+ }
143775
+ function keyof(value2) {
143776
+ return value2 !== null && typeof value2 === "object" ? value2.valueOf() : value2;
143777
+ }
143421
143778
  function identity$c(x2) {
143422
143779
  return x2;
143423
143780
  }
143781
+ function rollup(values2, reduce2, ...keys3) {
143782
+ return nest$1(values2, identity$c, reduce2, keys3);
143783
+ }
143784
+ function nest$1(values2, map2, reduce2, keys3) {
143785
+ return function regroup(values22, i2) {
143786
+ if (i2 >= keys3.length)
143787
+ return reduce2(values22);
143788
+ const groups2 = new InternMap2();
143789
+ const keyof2 = keys3[i2++];
143790
+ let index2 = -1;
143791
+ for (const value2 of values22) {
143792
+ const key2 = keyof2(value2, ++index2, values22);
143793
+ const group2 = groups2.get(key2);
143794
+ if (group2)
143795
+ group2.push(value2);
143796
+ else
143797
+ groups2.set(key2, [value2]);
143798
+ }
143799
+ for (const [key2, values3] of groups2) {
143800
+ groups2.set(key2, regroup(values3, i2));
143801
+ }
143802
+ return map2(groups2);
143803
+ }(values2, 0);
143804
+ }
143424
143805
  var array$8 = Array.prototype;
143425
143806
  var slice$4 = array$8.slice;
143426
143807
  function constant$8(x2) {
@@ -143668,10 +144049,10 @@ function multiSetsToTextureData(multiFeatureValues, multiMatrixObsIndex, setColo
143668
144049
  const valueTexHeight = Math.max(2, Math.ceil(totalValuesLength / texSize));
143669
144050
  const colorTexHeight = Math.max(2, Math.ceil(totalColorsLength / texSize));
143670
144051
  if (valueTexHeight > texSize) {
143671
- console.error("Error: length of concatenated quantitative feature values larger than maximum texture size");
144052
+ log$b.error("Error: length of concatenated quantitative feature values larger than maximum texture size");
143672
144053
  }
143673
144054
  if (colorTexHeight > texSize) {
143674
- console.error("Error: length of concatenated quantitative feature values larger than maximum texture size");
144055
+ log$b.error("Error: length of concatenated quantitative feature values larger than maximum texture size");
143675
144056
  }
143676
144057
  const totalData = new Uint8Array(texSize * valueTexHeight);
143677
144058
  const totalColors = new Uint8Array(texSize * colorTexHeight);
@@ -144540,7 +144921,7 @@ function initInterpolator$1(domain2, interpolator) {
144540
144921
  }
144541
144922
  const implicit$1 = Symbol("implicit");
144542
144923
  function ordinal$1() {
144543
- var index2 = new InternMap(), domain2 = [], range2 = [], unknown = implicit$1;
144924
+ var index2 = new InternMap$1(), domain2 = [], range2 = [], unknown = implicit$1;
144544
144925
  function scale2(d) {
144545
144926
  let i2 = index2.get(d);
144546
144927
  if (i2 === void 0) {
@@ -144553,7 +144934,7 @@ function ordinal$1() {
144553
144934
  scale2.domain = function(_) {
144554
144935
  if (!arguments.length)
144555
144936
  return domain2.slice();
144556
- domain2 = [], index2 = new InternMap();
144937
+ domain2 = [], index2 = new InternMap$1();
144557
144938
  for (const value2 of _) {
144558
144939
  if (index2.has(value2))
144559
144940
  continue;
@@ -153613,7 +153994,10 @@ function CellSetExpressionPlot(props) {
153613
153994
  stratificationSide = ordinal$1().domain(sampleSetNames).range(["left", "right"]);
153614
153995
  stratificationColor = ordinal$1().domain(sampleSetNames).range(
153615
153996
  // TODO: check for full path equality here.
153616
- sampleSetNames.map((name2) => sampleSetColor == null ? void 0 : sampleSetColor.find((d) => d.path.at(-1) === name2).color).map(colorArrayToString)
153997
+ sampleSetNames.map((name2) => {
153998
+ var _a2;
153999
+ return ((_a2 = sampleSetColor == null ? void 0 : sampleSetColor.find((d) => d.path.at(-1) === name2)) == null ? void 0 : _a2.color) || [125, 125, 125];
154000
+ }).map(colorArrayToString)
153617
154001
  );
153618
154002
  }
153619
154003
  const {
@@ -153750,11 +154134,11 @@ function summarize(iterable, keepZeros) {
153750
154134
  };
153751
154135
  }
153752
154136
  function dotStratifiedExpressionData(stratifiedResult, posThreshold) {
153753
- const result = new InternMap([], JSON.stringify);
154137
+ const result = new InternMap$1([], JSON.stringify);
153754
154138
  Array.from(stratifiedResult.entries()).forEach(([cellSetKey, firstLevelInternMap]) => {
153755
- result.set(cellSetKey, new InternMap([], JSON.stringify));
154139
+ result.set(cellSetKey, new InternMap$1([], JSON.stringify));
153756
154140
  Array.from(firstLevelInternMap.entries()).forEach(([sampleSetKey, secondLevelInternMap]) => {
153757
- result.get(cellSetKey).set(sampleSetKey, new InternMap([], JSON.stringify));
154141
+ result.get(cellSetKey).set(sampleSetKey, new InternMap$1([], JSON.stringify));
153758
154142
  Array.from(secondLevelInternMap.entries()).forEach(([geneKey, values2]) => {
153759
154143
  if (values2) {
153760
154144
  const exprMean = mean$1(values2);
@@ -153772,9 +154156,9 @@ function dotStratifiedExpressionData(stratifiedResult, posThreshold) {
153772
154156
  return result;
153773
154157
  }
153774
154158
  function summarizeStratifiedExpressionData(stratifiedResult, keepZeros) {
153775
- const summarizedResult = new InternMap([], JSON.stringify);
154159
+ const summarizedResult = new InternMap$1([], JSON.stringify);
153776
154160
  Array.from(stratifiedResult.entries()).forEach(([cellSetKey, firstLevelInternMap]) => {
153777
- summarizedResult.set(cellSetKey, new InternMap([], JSON.stringify));
154161
+ summarizedResult.set(cellSetKey, new InternMap$1([], JSON.stringify));
153778
154162
  Array.from(firstLevelInternMap.entries()).forEach(([sampleSetKey, secondLevelInternMap]) => {
153779
154163
  const values2 = secondLevelInternMap;
153780
154164
  const summary = summarize(values2, keepZeros);
@@ -173136,10 +173520,10 @@ const Tiles = {
173136
173520
  resquarify: treemapResquarify
173137
173521
  };
173138
173522
  const Output$4 = ["x0", "y0", "x1", "y1", "depth", "children"];
173139
- function Treemap(params2) {
173523
+ function Treemap$1(params2) {
173140
173524
  HierarchyLayout.call(this, params2);
173141
173525
  }
173142
- Treemap.Definition = {
173526
+ Treemap$1.Definition = {
173143
173527
  "type": "Treemap",
173144
173528
  "metadata": {
173145
173529
  "tree": true,
@@ -173205,7 +173589,7 @@ Treemap.Definition = {
173205
173589
  "default": Output$4
173206
173590
  }]
173207
173591
  };
173208
- inherits(Treemap, HierarchyLayout, {
173592
+ inherits(Treemap$1, HierarchyLayout, {
173209
173593
  /**
173210
173594
  * Treemap layout generator. Adds 'method' and 'ratio' parameters
173211
173595
  * to configure the underlying tile method.
@@ -173236,7 +173620,7 @@ const tree = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty
173236
173620
  stratify: Stratify,
173237
173621
  tree: Tree,
173238
173622
  treelinks: TreeLinks,
173239
- treemap: Treemap
173623
+ treemap: Treemap$1
173240
173624
  }, Symbol.toStringTag, { value: "Module" }));
173241
173625
  const ALPHA_MASK = 4278190080;
173242
173626
  function baseBitmaps($2, data2) {
@@ -206212,11 +206596,11 @@ function useExpressionSummaries(sampleEdges, sampleSets, sampleSetSelection, exp
206212
206596
  posThreshold
206213
206597
  );
206214
206598
  const geneToUuid = new Map(geneSelection == null ? void 0 : geneSelection.map((gene) => [gene, v4$1()]));
206215
- const cellSetToUuid = new InternMap(
206599
+ const cellSetToUuid = new InternMap$1(
206216
206600
  cellSetSelection == null ? void 0 : cellSetSelection.map((sampleSet) => [sampleSet, v4$1()]),
206217
206601
  JSON.stringify
206218
206602
  );
206219
- const sampleSetToUuid = new InternMap(
206603
+ const sampleSetToUuid = new InternMap$1(
206220
206604
  sampleSetSelection == null ? void 0 : sampleSetSelection.map((sampleSet) => [sampleSet, v4$1()]),
206221
206605
  JSON.stringify
206222
206606
  );
@@ -206718,12 +207102,460 @@ function FeatureBarPlotSubscriber(props) {
206718
207102
  }
206719
207103
  );
206720
207104
  }
207105
+ function uidGenerator(prefix2) {
207106
+ let i2 = 0;
207107
+ return () => {
207108
+ i2 += 1;
207109
+ return { id: `${prefix2}-${i2}`, href: `#${prefix2}-${i2}` };
207110
+ };
207111
+ }
207112
+ function getColorScale(setSelectionArr, setColorArr, theme) {
207113
+ var _a2;
207114
+ return ordinal$1().domain(setSelectionArr || []).range(
207115
+ ((_a2 = setSelectionArr == null ? void 0 : setSelectionArr.map((setNamePath) => {
207116
+ var _a3;
207117
+ return ((_a3 = setColorArr == null ? void 0 : setColorArr.find((d) => isEqual$2(d.path, setNamePath))) == null ? void 0 : _a3.color) || getDefaultColor(theme);
207118
+ })) == null ? void 0 : _a2.map(colorArrayToString)) || []
207119
+ );
207120
+ }
207121
+ function Treemap(props) {
207122
+ const {
207123
+ obsCounts,
207124
+ obsColorEncoding,
207125
+ hierarchyLevels,
207126
+ theme,
207127
+ width: width2,
207128
+ height: height2,
207129
+ obsType,
207130
+ sampleType,
207131
+ obsSetColor,
207132
+ sampleSetColor,
207133
+ obsSetSelection,
207134
+ sampleSetSelection,
207135
+ marginTop = 5,
207136
+ marginRight = 5,
207137
+ marginLeft = 80,
207138
+ marginBottom
207139
+ } = props;
207140
+ const hierarchyData = useMemo(() => {
207141
+ if (!obsCounts) {
207142
+ return null;
207143
+ }
207144
+ let map2;
207145
+ if (isEqual$2(hierarchyLevels, ["sampleSet", "obsSet"])) {
207146
+ map2 = rollup(
207147
+ obsCounts,
207148
+ (D2) => D2[0].value,
207149
+ (d) => d.sampleSetPath,
207150
+ (d) => d.obsSetPath
207151
+ );
207152
+ } else if (isEqual$2(hierarchyLevels, ["obsSet", "sampleSet"])) {
207153
+ map2 = rollup(
207154
+ obsCounts,
207155
+ (D2) => D2[0].value,
207156
+ (d) => d.obsSetPath,
207157
+ (d) => d.sampleSetPath
207158
+ );
207159
+ } else {
207160
+ throw new Error("Unexpected levels value.");
207161
+ }
207162
+ return hierarchy(map2);
207163
+ }, [obsCounts, hierarchyLevels]);
207164
+ const [obsSetColorScale, sampleSetColorScale] = useMemo(() => [
207165
+ getColorScale(obsSetSelection, obsSetColor, theme),
207166
+ getColorScale(sampleSetSelection, sampleSetColor, theme)
207167
+ ], [obsSetSelection, sampleSetSelection, sampleSetColor, obsSetColor, theme]);
207168
+ const treemapLeaves = useMemo(() => {
207169
+ const treemapFunc = treemap().tile(treemapBinary).size([width2, height2]).padding(1).round(true);
207170
+ const treemapLayout = treemapFunc(hierarchyData.sum((d) => d[1]).sort((a2, b2) => b2[1] - a2[1]));
207171
+ return treemapLayout.leaves();
207172
+ }, [hierarchyData, width2, height2]);
207173
+ const svgRef = useRef();
207174
+ useEffect(() => {
207175
+ const domElement = svgRef.current;
207176
+ const svg = select$1(domElement);
207177
+ svg.selectAll("g").remove();
207178
+ svg.attr("width", width2).attr("height", height2).attr("viewBox", [0, 0, width2, height2]).attr("style", "font: 10px sans-serif");
207179
+ if (!treemapLeaves || !obsSetSelection || !sampleSetSelection) {
207180
+ return;
207181
+ }
207182
+ const leaf = svg.selectAll("g").data(treemapLeaves).join("g").attr("transform", (d) => `translate(${d.x0},${d.y0})`);
207183
+ leaf.append("title").text((d) => {
207184
+ var _a2;
207185
+ const cellCount = (_a2 = d.data) == null ? void 0 : _a2[1];
207186
+ const primaryPathString = JSON.stringify(d.data[0]);
207187
+ const secondaryPathString = JSON.stringify(d.parent.data[0]);
207188
+ return `${cellCount.toLocaleString()} ${pluralize(obsType, cellCount)} in ${primaryPathString} and ${secondaryPathString}`;
207189
+ });
207190
+ const getLeafUid = uidGenerator("leaf");
207191
+ const getClipUid = uidGenerator("clip");
207192
+ const colorScale2 = obsColorEncoding === "sampleSetSelection" ? sampleSetColorScale : obsSetColorScale;
207193
+ const getPathForColoring = (d) => {
207194
+ var _a2, _b, _c, _d, _e, _f;
207195
+ return (
207196
+ // eslint-disable-next-line no-nested-ternary
207197
+ obsColorEncoding === "sampleSetSelection" ? hierarchyLevels[0] === "obsSet" ? (_a2 = d.data) == null ? void 0 : _a2[0] : (_c = (_b = d.parent) == null ? void 0 : _b.data) == null ? void 0 : _c[0] : hierarchyLevels[0] === "sampleSet" ? (_d = d.data) == null ? void 0 : _d[0] : (_f = (_e = d.parent) == null ? void 0 : _e.data) == null ? void 0 : _f[0]
207198
+ );
207199
+ };
207200
+ leaf.append("rect").attr("id", (d) => {
207201
+ d.leafUid = getLeafUid();
207202
+ return d.leafUid.id;
207203
+ }).attr("fill", (d) => colorScale2(getPathForColoring(d))).attr("fill-opacity", 0.8).attr("width", (d) => d.x1 - d.x0).attr("height", (d) => d.y1 - d.y0);
207204
+ leaf.append("clipPath").attr("id", (d) => {
207205
+ d.clipUid = getClipUid();
207206
+ return d.clipUid.id;
207207
+ }).append("use").attr("xlink:href", (d) => d.leafUid.href);
207208
+ leaf.append("text").attr("clip-path", (d) => `url(${d.clipUid.href})`).selectAll("tspan").data((d) => {
207209
+ var _a2, _b, _c, _d, _e, _f, _g;
207210
+ return [
207211
+ // Each element in this array corresponds to a line of text.
207212
+ (_b = (_a2 = d.data) == null ? void 0 : _a2[0]) == null ? void 0 : _b.at(-1),
207213
+ (_e = (_d = (_c = d.parent) == null ? void 0 : _c.data) == null ? void 0 : _d[0]) == null ? void 0 : _e.at(-1),
207214
+ `${(_f = d.data) == null ? void 0 : _f[1].toLocaleString()} ${pluralize(obsType, (_g = d.data) == null ? void 0 : _g[1])}`
207215
+ ];
207216
+ }).join("tspan").attr("x", 3).attr("y", (d, i2, nodes) => `${(i2 === nodes.length - 1) * 0.3 + 1.1 + i2 * 0.9}em`).text((d) => d);
207217
+ }, [
207218
+ width2,
207219
+ height2,
207220
+ marginLeft,
207221
+ marginBottom,
207222
+ theme,
207223
+ marginTop,
207224
+ marginRight,
207225
+ obsType,
207226
+ sampleType,
207227
+ treemapLeaves,
207228
+ sampleSetColor,
207229
+ sampleSetSelection,
207230
+ obsSetSelection,
207231
+ obsSetColor,
207232
+ obsSetColorScale,
207233
+ sampleSetColorScale,
207234
+ obsColorEncoding,
207235
+ hierarchyLevels
207236
+ ]);
207237
+ return /* @__PURE__ */ jsxRuntimeExports.jsx(
207238
+ "svg",
207239
+ {
207240
+ ref: svgRef,
207241
+ style: {
207242
+ top: 0,
207243
+ left: 0,
207244
+ width: `${width2}px`,
207245
+ height: `${height2}px`,
207246
+ position: "relative"
207247
+ }
207248
+ }
207249
+ );
207250
+ }
207251
+ function TreemapOptions(props) {
207252
+ const {
207253
+ children: children2,
207254
+ obsType,
207255
+ sampleType,
207256
+ hierarchyLevels,
207257
+ setHierarchyLevels,
207258
+ obsColorEncoding,
207259
+ setObsColorEncoding
207260
+ } = props;
207261
+ const treemapOptionsId = $bdb11010cef70236$export$f680877a34711e37();
207262
+ const classes = usePlotOptionsStyles();
207263
+ function handleColorEncodingChange(event2) {
207264
+ setObsColorEncoding(event2.target.value);
207265
+ }
207266
+ function handleHierarchyLevelsOrderingChange(event2) {
207267
+ if (event2.target.value === "sampleSet") {
207268
+ setHierarchyLevels(["sampleSet", "obsSet"]);
207269
+ } else {
207270
+ setHierarchyLevels(["obsSet", "sampleSet"]);
207271
+ }
207272
+ }
207273
+ const primaryHierarchyLevel = isEqual$2(hierarchyLevels, ["sampleSet", "obsSet"]) ? "sampleSet" : "obsSet";
207274
+ return /* @__PURE__ */ jsxRuntimeExports.jsxs(OptionsContainer, { children: [
207275
+ children2,
207276
+ /* @__PURE__ */ jsxRuntimeExports.jsxs(TableRow$1, { children: [
207277
+ /* @__PURE__ */ jsxRuntimeExports.jsx(TableCell$1, { className: classes.labelCell, variant: "head", scope: "row", children: /* @__PURE__ */ jsxRuntimeExports.jsx(
207278
+ "label",
207279
+ {
207280
+ htmlFor: `cell-color-encoding-select-${treemapOptionsId}`,
207281
+ children: "Color Encoding"
207282
+ }
207283
+ ) }),
207284
+ /* @__PURE__ */ jsxRuntimeExports.jsx(TableCell$1, { className: classes.inputCell, variant: "body", children: /* @__PURE__ */ jsxRuntimeExports.jsxs(
207285
+ OptionSelect,
207286
+ {
207287
+ className: classes.select,
207288
+ value: obsColorEncoding,
207289
+ onChange: handleColorEncodingChange,
207290
+ inputProps: {
207291
+ id: `cell-color-encoding-select-${treemapOptionsId}`
207292
+ },
207293
+ children: [
207294
+ /* @__PURE__ */ jsxRuntimeExports.jsxs("option", { value: "cellSetSelection", children: [
207295
+ capitalize$2(obsType),
207296
+ " Sets"
207297
+ ] }),
207298
+ /* @__PURE__ */ jsxRuntimeExports.jsxs("option", { value: "sampleSetSelection", children: [
207299
+ capitalize$2(sampleType),
207300
+ " Sets"
207301
+ ] })
207302
+ ]
207303
+ }
207304
+ ) })
207305
+ ] }),
207306
+ /* @__PURE__ */ jsxRuntimeExports.jsxs(TableRow$1, { children: [
207307
+ /* @__PURE__ */ jsxRuntimeExports.jsx(TableCell$1, { className: classes.labelCell, variant: "head", scope: "row", children: /* @__PURE__ */ jsxRuntimeExports.jsx(
207308
+ "label",
207309
+ {
207310
+ htmlFor: `treemap-set-hierarchy-levels-${treemapOptionsId}`,
207311
+ children: "Primary Hierarchy Level"
207312
+ }
207313
+ ) }),
207314
+ /* @__PURE__ */ jsxRuntimeExports.jsx(TableCell$1, { className: classes.inputCell, variant: "body", children: /* @__PURE__ */ jsxRuntimeExports.jsxs(
207315
+ OptionSelect,
207316
+ {
207317
+ className: classes.select,
207318
+ value: primaryHierarchyLevel,
207319
+ onChange: handleHierarchyLevelsOrderingChange,
207320
+ inputProps: {
207321
+ id: `hierarchy-level-select-${treemapOptionsId}`
207322
+ },
207323
+ children: [
207324
+ /* @__PURE__ */ jsxRuntimeExports.jsxs("option", { value: "obsSet", children: [
207325
+ capitalize$2(obsType),
207326
+ " Sets"
207327
+ ] }),
207328
+ /* @__PURE__ */ jsxRuntimeExports.jsxs("option", { value: "sampleSet", children: [
207329
+ capitalize$2(sampleType),
207330
+ " Sets"
207331
+ ] })
207332
+ ]
207333
+ }
207334
+ ) })
207335
+ ] })
207336
+ ] });
207337
+ }
207338
+ const DEFAULT_HIERARCHY_LEVELS = ["obsSet", "sampleSet"];
207339
+ function TreemapSubscriber(props) {
207340
+ const {
207341
+ coordinationScopes,
207342
+ removeGridComponent,
207343
+ theme,
207344
+ helpText = ViewHelpMapping.TREEMAP
207345
+ } = props;
207346
+ const classes = useStyles$1();
207347
+ const loaders = useLoaders();
207348
+ const [{
207349
+ dataset,
207350
+ obsType,
207351
+ featureType,
207352
+ featureValueType,
207353
+ obsFilter,
207354
+ obsHighlight,
207355
+ obsSetSelection,
207356
+ obsSetFilter,
207357
+ obsSelection,
207358
+ obsSelectionMode,
207359
+ obsSetHighlight,
207360
+ obsSetColor,
207361
+ obsColorEncoding,
207362
+ additionalObsSets,
207363
+ sampleType,
207364
+ sampleSetSelection,
207365
+ sampleSetFilter,
207366
+ sampleSetColor,
207367
+ sampleSelection,
207368
+ sampleSelectionMode,
207369
+ sampleFilter,
207370
+ sampleFilterMode,
207371
+ sampleHighlight,
207372
+ hierarchyLevels
207373
+ }, {
207374
+ setObsFilter,
207375
+ setObsSelection: setObsSelection2,
207376
+ setObsSetFilter,
207377
+ setObsSetSelection,
207378
+ setObsSelectionMode,
207379
+ setObsFilterMode,
207380
+ setObsHighlight,
207381
+ setObsSetColor,
207382
+ setObsColorEncoding,
207383
+ setAdditionalObsSets,
207384
+ setSampleFilter,
207385
+ setSampleSetFilter,
207386
+ setSampleFilterMode,
207387
+ setSampleSelection,
207388
+ setSampleSetSelection,
207389
+ setSampleSelectionMode,
207390
+ setSampleHighlight,
207391
+ setSampleSetColor,
207392
+ setHierarchyLevels
207393
+ }] = useCoordination(
207394
+ COMPONENT_COORDINATION_TYPES[ViewType$1.TREEMAP],
207395
+ coordinationScopes
207396
+ );
207397
+ const [width2, height2, containerRef] = useGridItemSize();
207398
+ const [{ obsIndex }, matrixIndicesStatus, matrixIndicesUrls] = useObsFeatureMatrixIndices(
207399
+ loaders,
207400
+ dataset,
207401
+ false,
207402
+ { obsType, featureType, featureValueType }
207403
+ );
207404
+ const [{ obsSets }, obsSetsStatus, obsSetsUrls] = useObsSetsData(
207405
+ loaders,
207406
+ dataset,
207407
+ true,
207408
+ {},
207409
+ {},
207410
+ { obsType }
207411
+ );
207412
+ const [{ sampleIndex, sampleSets }, sampleSetsStatus, sampleSetsUrls] = useSampleSetsData(
207413
+ loaders,
207414
+ dataset,
207415
+ // TODO: support `false`, i.e., configurations in which
207416
+ // there are no sampleSets
207417
+ true,
207418
+ { setSampleSetColor },
207419
+ { sampleSetColor },
207420
+ { sampleType }
207421
+ );
207422
+ const [{ sampleEdges }, sampleEdgesStatus, sampleEdgesUrls] = useSampleEdgesData(
207423
+ loaders,
207424
+ dataset,
207425
+ // TODO: support `false`, i.e., configurations in which
207426
+ // there are no sampleEdges
207427
+ true,
207428
+ {},
207429
+ {},
207430
+ { obsType, sampleType }
207431
+ );
207432
+ const isReady = useReady([
207433
+ matrixIndicesStatus,
207434
+ obsSetsStatus,
207435
+ sampleSetsStatus,
207436
+ sampleEdgesStatus
207437
+ ]);
207438
+ const urls = useUrls([
207439
+ matrixIndicesUrls,
207440
+ obsSetsUrls,
207441
+ sampleSetsUrls,
207442
+ sampleEdgesUrls
207443
+ ]);
207444
+ const mergedObsSets = useMemo(
207445
+ () => mergeObsSets(obsSets, additionalObsSets),
207446
+ [obsSets, additionalObsSets]
207447
+ );
207448
+ const mergedSampleSets = useMemo(
207449
+ () => mergeObsSets(sampleSets, null),
207450
+ [sampleSets]
207451
+ );
207452
+ const obsCount = (obsIndex == null ? void 0 : obsIndex.length) || 0;
207453
+ const sampleCount = (sampleIndex == null ? void 0 : sampleIndex.length) || 0;
207454
+ const [obsCounts, sampleCounts] = useMemo(() => {
207455
+ var _a2, _b;
207456
+ const obsResult = new InternMap$1([], JSON.stringify);
207457
+ const sampleResult = new InternMap$1([], JSON.stringify);
207458
+ const hasSampleSetSelection = Array.isArray(sampleSetSelection) && sampleSetSelection.length > 0;
207459
+ const hasCellSetSelection = Array.isArray(obsSetSelection) && obsSetSelection.length > 0;
207460
+ const sampleSetKeys = hasSampleSetSelection ? sampleSetSelection : [null];
207461
+ const cellSetKeys = hasCellSetSelection ? obsSetSelection : [null];
207462
+ cellSetKeys.forEach((cellSetKey) => {
207463
+ obsResult.set(cellSetKey, new InternMap$1([], JSON.stringify));
207464
+ sampleSetKeys.forEach((sampleSetKey) => {
207465
+ obsResult.get(cellSetKey).set(sampleSetKey, 0);
207466
+ });
207467
+ });
207468
+ const sampleSetSizes = treeToSetSizesBySetNames(
207469
+ mergedSampleSets,
207470
+ sampleSetSelection,
207471
+ sampleSetSelection,
207472
+ sampleSetColor,
207473
+ theme
207474
+ );
207475
+ sampleSetKeys.forEach((sampleSetKey) => {
207476
+ var _a3;
207477
+ const sampleSetSize = (_a3 = sampleSetSizes.find((d) => isEqual$2(d.setNamePath, sampleSetKey))) == null ? void 0 : _a3.size;
207478
+ sampleResult.set(sampleSetKey, sampleSetSize || 0);
207479
+ });
207480
+ if (mergedObsSets && obsSetSelection) {
207481
+ const sampleIdToSetMap = sampleSets && sampleSetSelection ? treeToSelectedSetMap(sampleSets, sampleSetSelection) : null;
207482
+ const cellIdToSetMap = treeToSelectedSetMap(mergedObsSets, obsSetSelection);
207483
+ for (let i2 = 0; i2 < obsIndex.length; i2 += 1) {
207484
+ const obsId = obsIndex[i2];
207485
+ const cellSet = cellIdToSetMap == null ? void 0 : cellIdToSetMap.get(obsId);
207486
+ const sampleId = sampleEdges == null ? void 0 : sampleEdges.get(obsId);
207487
+ const sampleSet = sampleId ? sampleIdToSetMap == null ? void 0 : sampleIdToSetMap.get(sampleId) : null;
207488
+ if (hasSampleSetSelection && !sampleSet) {
207489
+ continue;
207490
+ }
207491
+ const prevObsCount = (_a2 = obsResult.get(cellSet)) == null ? void 0 : _a2.get(sampleSet);
207492
+ (_b = obsResult.get(cellSet)) == null ? void 0 : _b.set(sampleSet, prevObsCount + 1);
207493
+ }
207494
+ }
207495
+ return [
207496
+ unnestMap(obsResult, ["obsSetPath", "sampleSetPath", "value"]),
207497
+ unnestMap(sampleResult, ["sampleSetPath", "value"])
207498
+ ];
207499
+ }, [
207500
+ obsIndex,
207501
+ sampleEdges,
207502
+ sampleSets,
207503
+ obsSetColor,
207504
+ sampleSetColor,
207505
+ mergedObsSets,
207506
+ obsSetSelection,
207507
+ mergedSampleSets
207508
+ // TODO: consider filtering-related coordination values
207509
+ ]);
207510
+ return /* @__PURE__ */ jsxRuntimeExports.jsx(
207511
+ TitleInfo,
207512
+ {
207513
+ title: `Treemap of ${capitalize$2(pluralize(obsType, 2))}`,
207514
+ info: `${commaNumber(obsCount)} ${pluralize(obsType, obsCount)} from ${commaNumber(sampleCount)} ${pluralize(sampleType, sampleCount)}`,
207515
+ removeGridComponent,
207516
+ urls,
207517
+ theme,
207518
+ isReady,
207519
+ helpText,
207520
+ options: /* @__PURE__ */ jsxRuntimeExports.jsx(
207521
+ TreemapOptions,
207522
+ {
207523
+ obsType,
207524
+ sampleType,
207525
+ obsColorEncoding,
207526
+ setObsColorEncoding,
207527
+ hierarchyLevels: hierarchyLevels || DEFAULT_HIERARCHY_LEVELS,
207528
+ setHierarchyLevels
207529
+ }
207530
+ ),
207531
+ children: /* @__PURE__ */ jsxRuntimeExports.jsx("div", { ref: containerRef, className: classes.vegaContainer, children: /* @__PURE__ */ jsxRuntimeExports.jsx(
207532
+ Treemap,
207533
+ {
207534
+ obsCounts,
207535
+ sampleCounts,
207536
+ obsColorEncoding,
207537
+ hierarchyLevels: hierarchyLevels || DEFAULT_HIERARCHY_LEVELS,
207538
+ theme,
207539
+ width: width2,
207540
+ height: height2,
207541
+ obsType,
207542
+ sampleType,
207543
+ obsSetColor,
207544
+ sampleSetColor,
207545
+ obsSetSelection,
207546
+ sampleSetSelection
207547
+ }
207548
+ ) })
207549
+ }
207550
+ );
207551
+ }
206721
207552
  export {
206722
207553
  BaseDecoder as B,
206723
207554
  CellSetExpressionPlotSubscriber as C,
206724
207555
  DotPlotSubscriber as D,
206725
207556
  ExpressionHistogramSubscriber as E,
206726
207557
  FeatureBarPlotSubscriber as F,
207558
+ TreemapSubscriber as T,
206727
207559
  CellSetSizesPlotSubscriber as a,
206728
207560
  CellSetSizesPlot as b,
206729
207561
  CellSetExpressionPlot as c,