@vitessce/statistical-plots 3.5.6 → 3.5.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.
Files changed (60) hide show
  1. package/dist/{deflate-70ede287.js → deflate-1679ef33.js} +1 -1
  2. package/dist/{index-07a7a93a.js → index-0f4fe21d.js} +2926 -1090
  3. package/dist/index.js +10 -6
  4. package/dist/{jpeg-00a52550.js → jpeg-280f0ee1.js} +1 -1
  5. package/dist/{lerc-55c1ff7e.js → lerc-12264a36.js} +1 -1
  6. package/dist/{lzw-b906a3b9.js → lzw-70f852cc.js} +1 -1
  7. package/dist/{packbits-10b5f4aa.js → packbits-393c67b2.js} +1 -1
  8. package/dist/{raw-9317b0fd.js → raw-d8d7ab7f.js} +1 -1
  9. package/dist/{webimage-1c43145b.js → webimage-5d24a8e2.js} +1 -1
  10. package/dist-tsc/CellSetCompositionBarPlot.d.ts +5 -0
  11. package/dist-tsc/CellSetCompositionBarPlot.d.ts.map +1 -0
  12. package/dist-tsc/CellSetCompositionBarPlot.js +166 -0
  13. package/dist-tsc/CellSetCompositionBarPlotSubscriber.d.ts +2 -0
  14. package/dist-tsc/CellSetCompositionBarPlotSubscriber.d.ts.map +1 -0
  15. package/dist-tsc/CellSetCompositionBarPlotSubscriber.js +40 -0
  16. package/dist-tsc/CellSetExpressionPlot.d.ts.map +1 -1
  17. package/dist-tsc/CellSetExpressionPlot.js +2 -1
  18. package/dist-tsc/FeatureSetEnrichmentBarPlot.d.ts +5 -0
  19. package/dist-tsc/FeatureSetEnrichmentBarPlot.d.ts.map +1 -0
  20. package/dist-tsc/FeatureSetEnrichmentBarPlot.js +164 -0
  21. package/dist-tsc/FeatureSetEnrichmentBarPlotSubscriber.d.ts +2 -0
  22. package/dist-tsc/FeatureSetEnrichmentBarPlotSubscriber.d.ts.map +1 -0
  23. package/dist-tsc/FeatureSetEnrichmentBarPlotSubscriber.js +51 -0
  24. package/dist-tsc/Treemap.d.ts +11 -0
  25. package/dist-tsc/Treemap.d.ts.map +1 -0
  26. package/dist-tsc/Treemap.js +154 -0
  27. package/dist-tsc/TreemapOptions.d.ts +2 -0
  28. package/dist-tsc/TreemapOptions.d.ts.map +1 -0
  29. package/dist-tsc/TreemapOptions.js +29 -0
  30. package/dist-tsc/TreemapSubscriber.d.ts +2 -0
  31. package/dist-tsc/TreemapSubscriber.d.ts.map +1 -0
  32. package/dist-tsc/TreemapSubscriber.js +103 -0
  33. package/dist-tsc/VolcanoPlot.d.ts +2 -0
  34. package/dist-tsc/VolcanoPlot.d.ts.map +1 -0
  35. package/dist-tsc/VolcanoPlot.js +230 -0
  36. package/dist-tsc/VolcanoPlotOptions.d.ts +2 -0
  37. package/dist-tsc/VolcanoPlotOptions.d.ts.map +1 -0
  38. package/dist-tsc/VolcanoPlotOptions.js +23 -0
  39. package/dist-tsc/VolcanoPlotSubscriber.d.ts +2 -0
  40. package/dist-tsc/VolcanoPlotSubscriber.d.ts.map +1 -0
  41. package/dist-tsc/VolcanoPlotSubscriber.js +33 -0
  42. package/dist-tsc/index.d.ts +4 -0
  43. package/dist-tsc/index.js +4 -0
  44. package/dist-tsc/utils.d.ts +9 -0
  45. package/dist-tsc/utils.d.ts.map +1 -0
  46. package/dist-tsc/utils.js +40 -0
  47. package/package.json +8 -7
  48. package/src/CellSetCompositionBarPlot.js +205 -0
  49. package/src/CellSetCompositionBarPlotSubscriber.js +151 -0
  50. package/src/CellSetExpressionPlot.js +4 -1
  51. package/src/FeatureSetEnrichmentBarPlot.js +203 -0
  52. package/src/FeatureSetEnrichmentBarPlotSubscriber.js +166 -0
  53. package/src/Treemap.js +202 -0
  54. package/src/TreemapOptions.js +90 -0
  55. package/src/TreemapSubscriber.js +262 -0
  56. package/src/VolcanoPlot.js +313 -0
  57. package/src/VolcanoPlotOptions.js +136 -0
  58. package/src/VolcanoPlotSubscriber.js +162 -0
  59. package/src/index.js +4 -0
  60. package/src/utils.js +47 -0
@@ -0,0 +1,162 @@
1
+ /* eslint-disable no-unused-vars */
2
+ import React, { useMemo, useCallback } from 'react';
3
+ import {
4
+ TitleInfo,
5
+ useCoordination,
6
+ useLoaders,
7
+ useReady,
8
+ useGridItemSize,
9
+ useFeatureStatsData,
10
+ useMatchingLoader,
11
+ useColumnNameMapping,
12
+ } from '@vitessce/vit-s';
13
+ import {
14
+ ViewType,
15
+ COMPONENT_COORDINATION_TYPES,
16
+ ViewHelpMapping,
17
+ DataType,
18
+ } from '@vitessce/constants-internal';
19
+ import VolcanoPlot from './VolcanoPlot.js';
20
+ import { useStyles } from './styles.js';
21
+ import VolcanoPlotOptions from './VolcanoPlotOptions.js';
22
+ import { useRawSetPaths } from './utils.js';
23
+
24
+ export function VolcanoPlotSubscriber(props) {
25
+ const {
26
+ coordinationScopes,
27
+ removeGridComponent,
28
+ theme,
29
+ helpText = ViewHelpMapping.VOLCANO_PLOT,
30
+ } = props;
31
+
32
+ const classes = useStyles();
33
+ const loaders = useLoaders();
34
+
35
+ // Get "props" from the coordination space.
36
+ const [{
37
+ dataset,
38
+ obsType,
39
+ sampleType,
40
+ featureType,
41
+ featureValueType,
42
+ obsFilter: cellFilter,
43
+ obsHighlight: cellHighlight,
44
+ obsSetSelection,
45
+ obsSetColor,
46
+ obsColorEncoding: cellColorEncoding,
47
+ additionalObsSets: additionalCellSets,
48
+ featurePointSignificanceThreshold,
49
+ featurePointFoldChangeThreshold,
50
+ featureLabelSignificanceThreshold,
51
+ featureLabelFoldChangeThreshold,
52
+ featureValueTransform,
53
+ featureValueTransformCoefficient,
54
+ gatingFeatureSelectionX,
55
+ gatingFeatureSelectionY,
56
+ featureSelection,
57
+ sampleSetSelection,
58
+ sampleSetColor,
59
+ }, {
60
+ setObsFilter: setCellFilter,
61
+ setObsSetSelection,
62
+ setObsHighlight: setCellHighlight,
63
+ setObsSetColor: setCellSetColor,
64
+ setObsColorEncoding: setCellColorEncoding,
65
+ setAdditionalObsSets: setAdditionalCellSets,
66
+ setFeaturePointSignificanceThreshold,
67
+ setFeaturePointFoldChangeThreshold,
68
+ setFeatureLabelSignificanceThreshold,
69
+ setFeatureLabelFoldChangeThreshold,
70
+ setFeatureValueTransform,
71
+ setFeatureValueTransformCoefficient,
72
+ setGatingFeatureSelectionX,
73
+ setGatingFeatureSelectionY,
74
+ setFeatureSelection,
75
+ setSampleSetSelection,
76
+ setSampleSetColor,
77
+ }] = useCoordination(
78
+ COMPONENT_COORDINATION_TYPES[ViewType.VOLCANO_PLOT],
79
+ coordinationScopes,
80
+ );
81
+ const [width, height, containerRef] = useGridItemSize();
82
+
83
+ const obsSetsLoader = useMatchingLoader(
84
+ loaders, dataset, DataType.OBS_SETS, { obsType },
85
+ );
86
+ const sampleSetsLoader = useMatchingLoader(
87
+ loaders, dataset, DataType.SAMPLE_SETS, { sampleType },
88
+ );
89
+ const obsSetsColumnNameMapping = useColumnNameMapping(obsSetsLoader);
90
+ const sampleSetsColumnNameMapping = useColumnNameMapping(sampleSetsLoader);
91
+
92
+ const rawSampleSetSelection = useRawSetPaths(sampleSetsColumnNameMapping, sampleSetSelection);
93
+ const rawObsSetSelection = useRawSetPaths(obsSetsColumnNameMapping, obsSetSelection);
94
+
95
+ const [{ featureStats }, featureStatsStatus] = useFeatureStatsData(
96
+ loaders, dataset, false,
97
+ { obsType, featureType, sampleType },
98
+ // These volcanoOptions are passed to FeatureStatsAnndataLoader.loadMulti():
99
+ { sampleSetSelection: rawSampleSetSelection, obsSetSelection: rawObsSetSelection },
100
+ );
101
+
102
+ const isReady = useReady([
103
+ featureStatsStatus,
104
+ ]);
105
+
106
+ const onFeatureClick = useCallback((featureId) => {
107
+ setFeatureSelection([featureId]);
108
+ }, [setFeatureSelection]);
109
+
110
+ return (
111
+ <TitleInfo
112
+ title="Volcano Plot"
113
+ removeGridComponent={removeGridComponent}
114
+ theme={theme}
115
+ isReady={isReady}
116
+ helpText={helpText}
117
+ options={(
118
+ <VolcanoPlotOptions
119
+ obsType={obsType}
120
+ featureType={featureType}
121
+
122
+ featurePointSignificanceThreshold={featurePointSignificanceThreshold}
123
+ featurePointFoldChangeThreshold={featurePointFoldChangeThreshold}
124
+ featureLabelSignificanceThreshold={featureLabelSignificanceThreshold}
125
+ featureLabelFoldChangeThreshold={featureLabelFoldChangeThreshold}
126
+
127
+ setFeaturePointSignificanceThreshold={setFeaturePointSignificanceThreshold}
128
+ setFeaturePointFoldChangeThreshold={setFeaturePointFoldChangeThreshold}
129
+ setFeatureLabelSignificanceThreshold={setFeatureLabelSignificanceThreshold}
130
+ setFeatureLabelFoldChangeThreshold={setFeatureLabelFoldChangeThreshold}
131
+ />
132
+ )}
133
+ >
134
+ <div ref={containerRef} className={classes.vegaContainer}>
135
+ {featureStats ? (
136
+ <VolcanoPlot
137
+ theme={theme}
138
+ width={width}
139
+ height={height}
140
+ obsType={obsType}
141
+ featureType={featureType}
142
+ obsSetsColumnNameMapping={obsSetsColumnNameMapping}
143
+ sampleSetsColumnNameMapping={sampleSetsColumnNameMapping}
144
+ sampleSetSelection={sampleSetSelection}
145
+ obsSetSelection={obsSetSelection}
146
+ obsSetColor={obsSetColor}
147
+ sampleSetColor={sampleSetColor}
148
+ data={featureStats}
149
+ onFeatureClick={onFeatureClick}
150
+
151
+ featurePointSignificanceThreshold={featurePointSignificanceThreshold}
152
+ featurePointFoldChangeThreshold={featurePointFoldChangeThreshold}
153
+ featureLabelSignificanceThreshold={featureLabelSignificanceThreshold}
154
+ featureLabelFoldChangeThreshold={featureLabelFoldChangeThreshold}
155
+ />
156
+ ) : (
157
+ <span>Select at least one {obsType} set.</span>
158
+ )}
159
+ </div>
160
+ </TitleInfo>
161
+ );
162
+ }
package/src/index.js CHANGED
@@ -3,6 +3,10 @@ export { CellSetSizesPlotSubscriber } from './CellSetSizesPlotSubscriber.js';
3
3
  export { ExpressionHistogramSubscriber } from './ExpressionHistogramSubscriber.js';
4
4
  export { DotPlotSubscriber } from './DotPlotSubscriber.js';
5
5
  export { FeatureBarPlotSubscriber } from './FeatureBarPlotSubscriber.js';
6
+ export { TreemapSubscriber } from './TreemapSubscriber.js';
7
+ export { VolcanoPlotSubscriber } from './VolcanoPlotSubscriber.js';
8
+ export { CellSetCompositionBarPlotSubscriber } from './CellSetCompositionBarPlotSubscriber.js';
9
+ export { FeatureSetEnrichmentBarPlotSubscriber } from './FeatureSetEnrichmentBarPlotSubscriber.js';
6
10
  export { default as CellSetSizesPlot } from './CellSetSizesPlot.js';
7
11
  export { default as CellSetExpressionPlot } from './CellSetExpressionPlot.js';
8
12
  export { default as ExpressionHistogram } from './ExpressionHistogram.js';
package/src/utils.js ADDED
@@ -0,0 +1,47 @@
1
+ import { useMemo } from 'react';
2
+ import { isEqual } from 'lodash-es';
3
+ import { colorArrayToString } from '@vitessce/sets-utils';
4
+ import { getDefaultColor } from '@vitessce/utils';
5
+
6
+
7
+ function createOrdinalScale(domainArr, rangeArr) {
8
+ return (queryVal) => {
9
+ const i = domainArr.findIndex(domainVal => isEqual(domainVal, queryVal));
10
+ return rangeArr[i];
11
+ };
12
+ }
13
+
14
+ // Create a d3-scale ordinal scale mapping set paths to color strings.
15
+ export function getColorScale(setSelectionArr, setColorArr, theme) {
16
+ /*
17
+ // The equality seems incorrect with d3.scaleOrdinal
18
+ return scaleOrdinal()
19
+ .domain(setSelectionArr || [])
20
+ .range(
21
+ */
22
+ const domainArr = setSelectionArr || [];
23
+ const rangeArr = setSelectionArr
24
+ ?.map(setNamePath => (
25
+ setColorArr?.find(d => isEqual(d.path, setNamePath))?.color
26
+ || getDefaultColor(theme)
27
+ ))
28
+ ?.map(colorArrayToString) || [];
29
+ return createOrdinalScale(domainArr, rangeArr);
30
+ }
31
+
32
+
33
+ /**
34
+ * Transform set paths which use group names to those which use column names.
35
+ * @param {Record<string, string>} columnNameMapping Return value of useColumnNameMapping.
36
+ * @param {string[][]} setPaths Array of set paths, such as obsSetSelection.
37
+ * @returns {string[][]} Transformed set paths.
38
+ */
39
+ export function useRawSetPaths(columnNameMapping, setPaths) {
40
+ return useMemo(() => setPaths?.map((setPath) => {
41
+ const newSetPath = [...setPath];
42
+ if (newSetPath?.[0] && columnNameMapping[newSetPath[0]]) {
43
+ newSetPath[0] = columnNameMapping[newSetPath[0]];
44
+ }
45
+ return newSetPath;
46
+ }), [columnNameMapping, setPaths]);
47
+ }