@vitessce/statistical-plots 3.5.9 → 3.5.11

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 (67) hide show
  1. package/dist/{deflate-19841f78.js → deflate-b8c6daae.js} +1 -1
  2. package/dist/{index-dc733355.js → index-134a71c6.js} +33739 -15506
  3. package/dist/index.js +6 -5
  4. package/dist/{jpeg-a83077be.js → jpeg-1b818d11.js} +1 -1
  5. package/dist/{lerc-1edd075a.js → lerc-f38cbdfc.js} +1 -1
  6. package/dist/{lzw-9572eac3.js → lzw-1120aba9.js} +1 -1
  7. package/dist/{packbits-cce11fbc.js → packbits-2d02b5e3.js} +1 -1
  8. package/dist/{raw-f7587aff.js → raw-0887baec.js} +1 -1
  9. package/dist/{webimage-8d38cd8b.js → webimage-533922a5.js} +1 -1
  10. package/dist-tsc/CellSetCompositionBarPlot.d.ts.map +1 -1
  11. package/dist-tsc/CellSetCompositionBarPlot.js +31 -10
  12. package/dist-tsc/CellSetCompositionBarPlotSubscriber.js +1 -1
  13. package/dist-tsc/CellSetExpressionPlot.d.ts.map +1 -1
  14. package/dist-tsc/CellSetExpressionPlot.js +26 -10
  15. package/dist-tsc/CellSetExpressionPlotOptions.d.ts.map +1 -1
  16. package/dist-tsc/CellSetExpressionPlotOptions.js +11 -4
  17. package/dist-tsc/CellSetExpressionPlotSubscriber.d.ts.map +1 -1
  18. package/dist-tsc/CellSetExpressionPlotSubscriber.js +46 -11
  19. package/dist-tsc/DotPlot.d.ts.map +1 -1
  20. package/dist-tsc/DotPlot.js +59 -6
  21. package/dist-tsc/DotPlotSubscriber.d.ts.map +1 -1
  22. package/dist-tsc/DotPlotSubscriber.js +1 -1
  23. package/dist-tsc/FeatureSetEnrichmentBarPlot.d.ts.map +1 -1
  24. package/dist-tsc/FeatureSetEnrichmentBarPlot.js +7 -6
  25. package/dist-tsc/FeatureSetEnrichmentBarPlotSubscriber.d.ts.map +1 -1
  26. package/dist-tsc/FeatureSetEnrichmentBarPlotSubscriber.js +5 -2
  27. package/dist-tsc/FeatureStatsTable.d.ts +2 -0
  28. package/dist-tsc/FeatureStatsTable.d.ts.map +1 -0
  29. package/dist-tsc/FeatureStatsTable.js +81 -0
  30. package/dist-tsc/FeatureStatsTableSubscriber.d.ts +2 -0
  31. package/dist-tsc/FeatureStatsTableSubscriber.d.ts.map +1 -0
  32. package/dist-tsc/FeatureStatsTableSubscriber.js +28 -0
  33. package/dist-tsc/Treemap.d.ts.map +1 -1
  34. package/dist-tsc/Treemap.js +17 -3
  35. package/dist-tsc/TreemapSubscriber.d.ts.map +1 -1
  36. package/dist-tsc/TreemapSubscriber.js +15 -9
  37. package/dist-tsc/VolcanoPlot.d.ts.map +1 -1
  38. package/dist-tsc/VolcanoPlot.js +15 -46
  39. package/dist-tsc/VolcanoPlotSubscriber.d.ts.map +1 -1
  40. package/dist-tsc/VolcanoPlotSubscriber.js +4 -2
  41. package/dist-tsc/expr-hooks.d.ts.map +1 -1
  42. package/dist-tsc/expr-hooks.test.js +2 -1
  43. package/dist-tsc/index.d.ts +1 -0
  44. package/dist-tsc/index.js +1 -0
  45. package/dist-tsc/utils.d.ts +1 -0
  46. package/dist-tsc/utils.d.ts.map +1 -1
  47. package/dist-tsc/utils.js +56 -0
  48. package/package.json +8 -7
  49. package/src/CellSetCompositionBarPlot.js +38 -12
  50. package/src/CellSetCompositionBarPlotSubscriber.js +1 -1
  51. package/src/CellSetExpressionPlot.js +33 -10
  52. package/src/CellSetExpressionPlotOptions.js +39 -2
  53. package/src/CellSetExpressionPlotSubscriber.js +56 -13
  54. package/src/DotPlot.js +81 -11
  55. package/src/DotPlotSubscriber.js +3 -1
  56. package/src/FeatureSetEnrichmentBarPlot.js +7 -6
  57. package/src/FeatureSetEnrichmentBarPlotSubscriber.js +5 -2
  58. package/src/FeatureStatsTable.js +116 -0
  59. package/src/FeatureStatsTableSubscriber.js +133 -0
  60. package/src/Treemap.js +21 -3
  61. package/src/TreemapSubscriber.js +26 -11
  62. package/src/VolcanoPlot.js +16 -64
  63. package/src/VolcanoPlotSubscriber.js +6 -1
  64. package/src/expr-hooks.js +0 -1
  65. package/src/expr-hooks.test.js +2 -1
  66. package/src/index.js +1 -0
  67. package/src/utils.js +82 -1
package/src/utils.js CHANGED
@@ -1,9 +1,9 @@
1
+ /* eslint-disable camelcase */
1
2
  import { useMemo } from 'react';
2
3
  import { isEqual } from 'lodash-es';
3
4
  import { colorArrayToString } from '@vitessce/sets-utils';
4
5
  import { getDefaultColor } from '@vitessce/utils';
5
6
 
6
-
7
7
  function createOrdinalScale(domainArr, rangeArr) {
8
8
  return (queryVal) => {
9
9
  const i = domainArr.findIndex(domainVal => isEqual(domainVal, queryVal));
@@ -45,3 +45,84 @@ export function useRawSetPaths(columnNameMapping, setPaths) {
45
45
  return newSetPath;
46
46
  }), [columnNameMapping, setPaths]);
47
47
  }
48
+
49
+ // Data transformation hook function that is used both here
50
+ // and in the FeatureStatsTable view.
51
+ export function useFilteredVolcanoData(props) {
52
+ const {
53
+ data,
54
+ obsSetsColumnNameMappingReversed,
55
+ sampleSetsColumnNameMappingReversed,
56
+ featurePointFoldChangeThreshold,
57
+ featurePointSignificanceThreshold,
58
+ sampleSetSelection,
59
+ } = props;
60
+
61
+
62
+ const computedData = useMemo(() => data.map((d) => {
63
+ const { metadata } = d;
64
+
65
+ const coordinationValues = metadata.coordination_values;
66
+
67
+ const rawObsSetPath = coordinationValues.obsSetFilter
68
+ ? coordinationValues.obsSetFilter[0]
69
+ : coordinationValues.obsSetSelection[0];
70
+ const obsSetPath = [...rawObsSetPath];
71
+ obsSetPath[0] = obsSetsColumnNameMappingReversed[rawObsSetPath[0]];
72
+
73
+ // Swap the foldchange direction if backwards with
74
+ // respect to the current sampleSetSelection pair.
75
+ // TODO: move this swapping into the computedData useMemo?
76
+ let shouldSwapFoldChangeDirection = false;
77
+ if (
78
+ coordinationValues.sampleSetFilter
79
+ && coordinationValues.sampleSetFilter.length === 2
80
+ ) {
81
+ const rawSampleSetPathA = coordinationValues.sampleSetFilter[0];
82
+ const sampleSetPathA = [...rawSampleSetPathA];
83
+ sampleSetPathA[0] = sampleSetsColumnNameMappingReversed[rawSampleSetPathA[0]];
84
+
85
+ const rawSampleSetPathB = coordinationValues.sampleSetFilter[1];
86
+ const sampleSetPathB = [...rawSampleSetPathB];
87
+ sampleSetPathB[0] = sampleSetsColumnNameMappingReversed[rawSampleSetPathB[0]];
88
+
89
+ if (
90
+ isEqual(sampleSetPathA, sampleSetSelection[1])
91
+ && isEqual(sampleSetPathB, sampleSetSelection[0])
92
+ ) {
93
+ shouldSwapFoldChangeDirection = true;
94
+ }
95
+ }
96
+
97
+ return ({
98
+ ...d,
99
+ df: {
100
+ ...d.df,
101
+ minusLog10p: d.df.featureSignificance.map(v => -Math.log10(v)),
102
+ logFoldChange: d.df.featureFoldChange.map(v => (
103
+ Math.log2(v) * (shouldSwapFoldChangeDirection ? -1 : 1)
104
+ )),
105
+ },
106
+ });
107
+ }), [
108
+ data, obsSetsColumnNameMappingReversed, sampleSetsColumnNameMappingReversed,
109
+ sampleSetSelection,
110
+ ]);
111
+
112
+ const filteredData = useMemo(() => computedData.map(obj => ({
113
+ ...obj,
114
+ // Instead of an object of one array per column,
115
+ // this is now an array of one object per row.
116
+ df: obj.df.featureId.map((featureId, i) => ({
117
+ featureId,
118
+ logFoldChange: obj.df.logFoldChange[i],
119
+ featureSignificance: obj.df.featureSignificance[i],
120
+ minusLog10p: obj.df.minusLog10p[i],
121
+ })).filter(d => (
122
+ (Math.abs(d.logFoldChange) >= (featurePointFoldChangeThreshold ?? 1.0))
123
+ && (d.featureSignificance <= (featurePointSignificanceThreshold ?? 0.05))
124
+ )),
125
+ })), [computedData, featurePointFoldChangeThreshold, featurePointSignificanceThreshold]);
126
+
127
+ return [computedData, filteredData];
128
+ }