@vitessce/utils 2.0.3 → 3.0.1
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 +15764 -0
- package/dist-tsc/Pool.d.ts +20 -0
- package/dist-tsc/Pool.d.ts.map +1 -0
- package/dist-tsc/Pool.js +58 -0
- package/dist-tsc/components.d.ts +35 -0
- package/dist-tsc/components.d.ts.map +1 -0
- package/dist-tsc/components.js +114 -0
- package/dist-tsc/gating.d.ts +18 -0
- package/dist-tsc/gating.d.ts.map +1 -0
- package/dist-tsc/gating.js +30 -0
- package/dist-tsc/index.d.ts +6 -0
- package/dist-tsc/index.d.ts.map +1 -0
- package/dist-tsc/index.js +7 -5
- package/dist-tsc/interpolate-colors.d.ts +22 -0
- package/dist-tsc/interpolate-colors.d.ts.map +1 -0
- package/dist-tsc/interpolate-colors.js +87 -0
- package/dist-tsc/interpolate-colors.test.d.ts +2 -0
- package/dist-tsc/interpolate-colors.test.d.ts.map +1 -0
- package/dist-tsc/interpolate-colors.test.js +25 -0
- package/dist-tsc/root.d.ts +26 -0
- package/dist-tsc/root.d.ts.map +1 -0
- package/dist-tsc/root.js +74 -0
- package/package.json +15 -6
- package/src/index.js +7 -5
- package/src/interpolate-colors.js +11 -26
- package/src/interpolate-colors.test.js +2 -1
- package/dist/index.mjs +0 -9995
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/* eslint-disable no-nested-ternary */
|
|
2
2
|
/* eslint-disable no-param-reassign */
|
|
3
3
|
import { treeToCellColorsBySetNames } from '@vitessce/sets-utils';
|
|
4
|
-
import { getDefaultColor } from './components';
|
|
4
|
+
import { getDefaultColor } from './components.js';
|
|
5
5
|
|
|
6
6
|
// The functions defined here have been adapted from d3-interpolate,
|
|
7
7
|
// d3-color, and d3-scale-chromatic.
|
|
@@ -77,39 +77,24 @@ export const interpolatePlasma = interpolateSequentialMulti(schemePlasma);
|
|
|
77
77
|
* Get a mapping of cell IDs to cell colors based on
|
|
78
78
|
* gene / cell set selection coordination state.
|
|
79
79
|
* @param {object} params
|
|
80
|
-
* @param {
|
|
81
|
-
* @param {
|
|
82
|
-
*
|
|
83
|
-
* @param {
|
|
84
|
-
*
|
|
85
|
-
*
|
|
80
|
+
* @param {array[]} params.cellSetSelection Selected cell sets.
|
|
81
|
+
* @param {object[]} params.cellSetColor Array of cell set color
|
|
82
|
+
* objects, each containing a path and color [r, g, b].
|
|
83
|
+
* @param {string[]} params.obsIndex Array of cell IDs,
|
|
84
|
+
* in order to initialize all cells to the default color.
|
|
85
|
+
* @param {string} params.theme The current theme,
|
|
86
|
+
* in order to get the theme-based default color.
|
|
86
87
|
* @returns {Map} Mapping from cell IDs to [r, g, b] color arrays.
|
|
87
88
|
*/
|
|
88
89
|
export function getCellColors(params) {
|
|
89
90
|
const {
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
cellSets, cellSetSelection,
|
|
91
|
+
cellSets,
|
|
92
|
+
cellSetSelection,
|
|
93
93
|
cellSetColor,
|
|
94
94
|
obsIndex,
|
|
95
95
|
theme,
|
|
96
96
|
} = params;
|
|
97
|
-
if (
|
|
98
|
-
// TODO: allow other color maps.
|
|
99
|
-
const geneExpColormap = interpolatePlasma;
|
|
100
|
-
const colors = new Map();
|
|
101
|
-
for (let i = 0; i < expressionData.length; i += 1) {
|
|
102
|
-
const value = expressionData[i];
|
|
103
|
-
const cellColor = geneExpColormap(value / 255);
|
|
104
|
-
colors.set(obsIndex[i], cellColor);
|
|
105
|
-
}
|
|
106
|
-
return colors;
|
|
107
|
-
}
|
|
108
|
-
if (cellColorEncoding === 'cellSetSelection' && cellSetSelection && cellSets) {
|
|
109
|
-
// Cell sets can potentially lack set colors since the color property
|
|
110
|
-
// is not a required part of the schema.
|
|
111
|
-
// The `initializeSets` function fills in any empty colors
|
|
112
|
-
// with defaults and returns the processed tree object.
|
|
97
|
+
if (cellSetSelection && cellSets) {
|
|
113
98
|
return treeToCellColorsBySetNames(cellSets, cellSetSelection, cellSetColor, theme);
|
|
114
99
|
}
|
|
115
100
|
if (obsIndex && theme) {
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { describe, it, expect } from 'vitest';
|
|
2
|
+
import { interpolateRdBu, interpolatePlasma } from './interpolate-colors.js';
|
|
2
3
|
|
|
3
4
|
const expectRgb = ([testR, testG, testB], [r, g, b]) => ([
|
|
4
5
|
expect(testR).toBeCloseTo(r),
|