@vitessce/sets-utils 3.4.7 → 3.4.8

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.
package/dist/index.js CHANGED
@@ -17478,13 +17478,15 @@ function stratifyExpressionData(sampleEdges, sampleSets, sampleSetSelection, exp
17478
17478
  }
17479
17479
  function aggregateStratifiedExpressionData(stratifiedResult, geneSelection) {
17480
17480
  const result = new InternMap([], JSON.stringify);
17481
- [...stratifiedResult.keys()].forEach((cellSetKey) => {
17482
- result.set(cellSetKey, new InternMap([], JSON.stringify));
17483
- [...stratifiedResult.get(cellSetKey).keys()].forEach((sampleSetKey) => {
17484
- const values = stratifiedResult.get(cellSetKey).get(sampleSetKey).get(geneSelection[0]);
17485
- result.get(cellSetKey).set(sampleSetKey, values);
17481
+ if (stratifiedResult) {
17482
+ Array.from(stratifiedResult.keys()).forEach((cellSetKey) => {
17483
+ result.set(cellSetKey, new InternMap([], JSON.stringify));
17484
+ Array.from(stratifiedResult.get(cellSetKey).keys()).forEach((sampleSetKey) => {
17485
+ const values = stratifiedResult.get(cellSetKey).get(sampleSetKey).get(geneSelection[0]);
17486
+ result.get(cellSetKey).set(sampleSetKey, values);
17487
+ });
17486
17488
  });
17487
- });
17489
+ }
17488
17490
  return result;
17489
17491
  }
17490
17492
  export {
@@ -1 +1 @@
1
- {"version":3,"file":"expr-utils.d.ts","sourceRoot":"","sources":["../src/expr-utils.js"],"names":[],"mappings":"AASA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,4CAbW,GAAC,wCACD,GAAC,sBACD,GAAC,YAED,GAAC,kBACD,GAAC,oBAED,GAAC,8BAoIX;AAED;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,oDAbW,GAAC,cACD,GAAC,sBACD,GAAC,kBACD,GAAC,YACD,GAAC,kBACD,GAAC,iBACD,GAAC,oBACD,GAAC,gBACD,GAAC,yBACD,GAAC,oCACD,GAAC,SAiFX;AAED;;;;;;;;;;GAUG;AACH,oEAJW,GAAC,iBACD,GAAC,OAkBX"}
1
+ {"version":3,"file":"expr-utils.d.ts","sourceRoot":"","sources":["../src/expr-utils.js"],"names":[],"mappings":"AASA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,4CAbW,GAAC,wCACD,GAAC,sBACD,GAAC,YAED,GAAC,kBACD,GAAC,oBAED,GAAC,8BAoIX;AAED;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,oDAbW,GAAC,cACD,GAAC,sBACD,GAAC,kBACD,GAAC,YACD,GAAC,kBACD,GAAC,iBACD,GAAC,oBACD,GAAC,gBACD,GAAC,yBACD,GAAC,oCACD,GAAC,SAiFX;AAED;;;;;;;;;;GAUG;AACH,oEAJW,GAAC,iBACD,GAAC,OAmBX"}
@@ -225,14 +225,16 @@ featureValueTransform, featureValueTransformCoefficient) {
225
225
  */
226
226
  export function aggregateStratifiedExpressionData(stratifiedResult, geneSelection) {
227
227
  const result = new InternMap([], JSON.stringify);
228
- ([...stratifiedResult.keys()]).forEach((cellSetKey) => {
229
- result.set(cellSetKey, new InternMap([], JSON.stringify));
230
- ([...stratifiedResult.get(cellSetKey).keys()]).forEach((sampleSetKey) => {
231
- // For now, we just take the first gene.
232
- // TODO: support multiple genes via signature score method.
233
- const values = stratifiedResult.get(cellSetKey).get(sampleSetKey).get(geneSelection[0]);
234
- result.get(cellSetKey).set(sampleSetKey, values);
228
+ if (stratifiedResult) {
229
+ Array.from(stratifiedResult.keys()).forEach((cellSetKey) => {
230
+ result.set(cellSetKey, new InternMap([], JSON.stringify));
231
+ Array.from(stratifiedResult.get(cellSetKey).keys()).forEach((sampleSetKey) => {
232
+ // For now, we just take the first gene.
233
+ // TODO: support multiple genes via signature score method.
234
+ const values = stratifiedResult.get(cellSetKey).get(sampleSetKey).get(geneSelection[0]);
235
+ result.get(cellSetKey).set(sampleSetKey, values);
236
+ });
235
237
  });
236
- });
238
+ }
237
239
  return result;
238
240
  }
@@ -70,14 +70,14 @@ describe('Utility functions for processing expression data', () => {
70
70
  const featureValueTransformCoefficient = 1;
71
71
  it('stratifyExpressionData: stratify by cell set, then sample set', () => {
72
72
  const [result, exprMax] = stratifyExpressionData(sampleEdges, sampleSets, sampleSetSelection, expressionData, obsIndex, mergedCellSets, geneSelection, cellSetSelection, cellSetColor, featureValueTransform, featureValueTransformCoefficient);
73
- expect([...result.keys()]).toEqual([['Cell type', 'T cell'], ['Cell type', 'B cell']]);
74
- expect([...result.get(['Cell type', 'T cell']).keys()]).toEqual([['Clinical groups', 'AKI'], ['Clinical groups', 'CKD']]);
73
+ expect(Array.from(result.keys())).toEqual([['Cell type', 'T cell'], ['Cell type', 'B cell']]);
74
+ expect(Array.from(result.get(['Cell type', 'T cell']).keys())).toEqual([['Clinical groups', 'AKI'], ['Clinical groups', 'CKD']]);
75
75
  expect(result.get(['Cell type', 'T cell']).get(['Clinical groups', 'AKI']).get('Gene 1').length).toBe(2);
76
76
  expect(result.get(['Cell type', 'T cell']).get(['Clinical groups', 'AKI']).get('Gene 1')).toEqual([10, 30]);
77
77
  expect(exprMax).toEqual(41);
78
78
  const aggregateData = aggregateStratifiedExpressionData(result, geneSelection);
79
- expect([...aggregateData.keys()]).toEqual([['Cell type', 'T cell'], ['Cell type', 'B cell']]);
80
- expect([...aggregateData.get(['Cell type', 'T cell']).keys()]).toEqual([['Clinical groups', 'AKI'], ['Clinical groups', 'CKD']]);
79
+ expect(Array.from(aggregateData.keys())).toEqual([['Cell type', 'T cell'], ['Cell type', 'B cell']]);
80
+ expect(Array.from(aggregateData.get(['Cell type', 'T cell']).keys())).toEqual([['Clinical groups', 'AKI'], ['Clinical groups', 'CKD']]);
81
81
  expect(aggregateData.get(['Cell type', 'T cell']).get(['Clinical groups', 'AKI']).length).toBe(2);
82
82
  // TODO: add expect statements that check the aggregateData result, once it supports
83
83
  // aggregation of expression data from multiple genes into a single array.
@@ -103,9 +103,9 @@ describe('Utility functions for processing expression data', () => {
103
103
  // TODO: aggregate and transform expression data if needed prior to passing here
104
104
  ...(uint8ExpressionData?.[0] ? { featureValue: uint8ExpressionData?.[0] } : {}),
105
105
  });
106
- expect([...result.keys()]).toEqual([['Cell type', 'T cell'], ['Cell type', 'B cell']]);
107
- expect([...result.get(['Cell type', 'T cell']).keys()]).toEqual([['Clinical groups', 'AKI'], ['Clinical groups', 'CKD']]);
108
- expect([...result.get(['Cell type', 'T cell']).get(['Clinical groups', 'AKI']).keys()]).toEqual(['obsEmbeddingX', 'obsEmbeddingY', 'featureValue', 'obsIndex']);
106
+ expect(Array.from(result.keys())).toEqual([['Cell type', 'T cell'], ['Cell type', 'B cell']]);
107
+ expect(Array.from(result.get(['Cell type', 'T cell']).keys())).toEqual([['Clinical groups', 'AKI'], ['Clinical groups', 'CKD']]);
108
+ expect(Array.from(result.get(['Cell type', 'T cell']).get(['Clinical groups', 'AKI']).keys())).toEqual(['obsEmbeddingX', 'obsEmbeddingY', 'featureValue', 'obsIndex']);
109
109
  expect(result.get(['Cell type', 'T cell']).get(['Clinical groups', 'AKI']).get('featureValue').length).toBe(2);
110
110
  expect(result.get(['Cell type', 'T cell']).get(['Clinical groups', 'AKI']).get('featureValue')).toEqual(new Uint8Array([10, 30]));
111
111
  expect(result.get(['Cell type', 'T cell']).get(['Clinical groups', 'AKI']).get('obsEmbeddingX').length).toBe(2);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vitessce/sets-utils",
3
- "version": "3.4.7",
3
+ "version": "3.4.8",
4
4
  "author": "Gehlenborg Lab",
5
5
  "homepage": "http://vitessce.io",
6
6
  "repository": {
@@ -25,8 +25,8 @@
25
25
  "lodash-es": "^4.17.21",
26
26
  "tinycolor2": "^1.4.1",
27
27
  "uuid": "^9.0.0",
28
- "@vitessce/schemas": "3.4.7",
29
- "@vitessce/utils": "3.4.7"
28
+ "@vitessce/schemas": "3.4.8",
29
+ "@vitessce/utils": "3.4.8"
30
30
  },
31
31
  "scripts": {
32
32
  "bundle": "pnpm exec vite build -c ../../../scripts/vite.config.js",
package/src/expr-utils.js CHANGED
@@ -278,15 +278,16 @@ export function aggregateStratifiedExpressionData(
278
278
  stratifiedResult, geneSelection,
279
279
  ) {
280
280
  const result = new InternMap([], JSON.stringify);
281
- ([...stratifiedResult.keys()]).forEach((cellSetKey) => {
282
- result.set(cellSetKey, new InternMap([], JSON.stringify));
283
- ([...stratifiedResult.get(cellSetKey).keys()]).forEach((sampleSetKey) => {
284
- // For now, we just take the first gene.
285
- // TODO: support multiple genes via signature score method.
286
- const values = stratifiedResult.get(cellSetKey).get(sampleSetKey).get(geneSelection[0]);
287
- result.get(cellSetKey).set(sampleSetKey, values);
281
+ if (stratifiedResult) {
282
+ Array.from(stratifiedResult.keys()).forEach((cellSetKey) => {
283
+ result.set(cellSetKey, new InternMap([], JSON.stringify));
284
+ Array.from(stratifiedResult.get(cellSetKey).keys()).forEach((sampleSetKey) => {
285
+ // For now, we just take the first gene.
286
+ // TODO: support multiple genes via signature score method.
287
+ const values = stratifiedResult.get(cellSetKey).get(sampleSetKey).get(geneSelection[0]);
288
+ result.get(cellSetKey).set(sampleSetKey, values);
289
+ });
288
290
  });
289
- });
290
-
291
+ }
291
292
  return result;
292
293
  }
@@ -84,8 +84,8 @@ describe('Utility functions for processing expression data', () => {
84
84
  featureValueTransform, featureValueTransformCoefficient,
85
85
  );
86
86
 
87
- expect([...result.keys()]).toEqual([['Cell type', 'T cell'], ['Cell type', 'B cell']]);
88
- expect([...result.get(['Cell type', 'T cell']).keys()]).toEqual([['Clinical groups', 'AKI'], ['Clinical groups', 'CKD']]);
87
+ expect(Array.from(result.keys())).toEqual([['Cell type', 'T cell'], ['Cell type', 'B cell']]);
88
+ expect(Array.from(result.get(['Cell type', 'T cell']).keys())).toEqual([['Clinical groups', 'AKI'], ['Clinical groups', 'CKD']]);
89
89
  expect(result.get(['Cell type', 'T cell']).get(['Clinical groups', 'AKI']).get('Gene 1').length).toBe(2);
90
90
  expect(result.get(['Cell type', 'T cell']).get(['Clinical groups', 'AKI']).get('Gene 1')).toEqual([10, 30]);
91
91
  expect(exprMax).toEqual(41);
@@ -94,8 +94,8 @@ describe('Utility functions for processing expression data', () => {
94
94
  result, geneSelection,
95
95
  );
96
96
 
97
- expect([...aggregateData.keys()]).toEqual([['Cell type', 'T cell'], ['Cell type', 'B cell']]);
98
- expect([...aggregateData.get(['Cell type', 'T cell']).keys()]).toEqual([['Clinical groups', 'AKI'], ['Clinical groups', 'CKD']]);
97
+ expect(Array.from(aggregateData.keys())).toEqual([['Cell type', 'T cell'], ['Cell type', 'B cell']]);
98
+ expect(Array.from(aggregateData.get(['Cell type', 'T cell']).keys())).toEqual([['Clinical groups', 'AKI'], ['Clinical groups', 'CKD']]);
99
99
  expect(aggregateData.get(['Cell type', 'T cell']).get(['Clinical groups', 'AKI']).length).toBe(2);
100
100
 
101
101
  // TODO: add expect statements that check the aggregateData result, once it supports
@@ -129,9 +129,9 @@ describe('Utility functions for processing expression data', () => {
129
129
  },
130
130
  );
131
131
 
132
- expect([...result.keys()]).toEqual([['Cell type', 'T cell'], ['Cell type', 'B cell']]);
133
- expect([...result.get(['Cell type', 'T cell']).keys()]).toEqual([['Clinical groups', 'AKI'], ['Clinical groups', 'CKD']]);
134
- expect([...result.get(['Cell type', 'T cell']).get(['Clinical groups', 'AKI']).keys()]).toEqual(['obsEmbeddingX', 'obsEmbeddingY', 'featureValue', 'obsIndex']);
132
+ expect(Array.from(result.keys())).toEqual([['Cell type', 'T cell'], ['Cell type', 'B cell']]);
133
+ expect(Array.from(result.get(['Cell type', 'T cell']).keys())).toEqual([['Clinical groups', 'AKI'], ['Clinical groups', 'CKD']]);
134
+ expect(Array.from(result.get(['Cell type', 'T cell']).get(['Clinical groups', 'AKI']).keys())).toEqual(['obsEmbeddingX', 'obsEmbeddingY', 'featureValue', 'obsIndex']);
135
135
  expect(result.get(['Cell type', 'T cell']).get(['Clinical groups', 'AKI']).get('featureValue').length).toBe(2);
136
136
  expect(result.get(['Cell type', 'T cell']).get(['Clinical groups', 'AKI']).get('featureValue')).toEqual(new Uint8Array([10, 30]));
137
137
  expect(result.get(['Cell type', 'T cell']).get(['Clinical groups', 'AKI']).get('obsEmbeddingX').length).toBe(2);