@vitessce/comparative 0.0.1 → 3.9.5

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 (45) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +4 -18
  3. package/dist/OrbitControls-BwflPmLE.js +6202 -0
  4. package/dist/ReactNeuroglancer-UbR-Ehra.js +43478 -0
  5. package/dist/blosc-DKW2fp0s.js +716 -0
  6. package/dist/chunk-INHXZS53-DiyuLb3Z.js +14 -0
  7. package/dist/deflate-DFQkIOhL.js +10 -0
  8. package/dist/higlass-DHc5-L51.js +92988 -0
  9. package/dist/index-BLxG4AHN.js +3127 -0
  10. package/dist/index-DAP0IGbf.js +6178 -0
  11. package/dist/index-cJZeOqnJ.js +283191 -0
  12. package/dist/index.min.js +43 -0
  13. package/dist/jpeg-DalHlKqK.js +533 -0
  14. package/dist/lerc-Bj34z9Qs.js +1032 -0
  15. package/dist/lz4-D5NbssRf.js +640 -0
  16. package/dist/lzw-N9cMPzo2.js +84 -0
  17. package/dist/packbits-DGrkR5HU.js +24 -0
  18. package/dist/pako.esm-D68R8YXe.js +1071 -0
  19. package/dist/raw-D6zj6koi.js +9 -0
  20. package/dist/troika-three-text.esm-C-0BO8OV.js +4192 -0
  21. package/dist/webimage-D1WQPC9_.js +19 -0
  22. package/dist/zstd-DoGJTjDa.js +603 -0
  23. package/dist-tsc/BiomarkerSelect.d.ts +2 -0
  24. package/dist-tsc/BiomarkerSelect.d.ts.map +1 -0
  25. package/dist-tsc/BiomarkerSelect.js +65 -0
  26. package/dist-tsc/ComparativeConfig.d.ts +12 -0
  27. package/dist-tsc/ComparativeConfig.d.ts.map +1 -0
  28. package/dist-tsc/ComparativeConfig.js +326 -0
  29. package/dist-tsc/ControlledComparative.d.ts +30 -0
  30. package/dist-tsc/ControlledComparative.d.ts.map +1 -0
  31. package/dist-tsc/ControlledComparative.js +95 -0
  32. package/dist-tsc/UncontrolledComparative.d.ts +10 -0
  33. package/dist-tsc/UncontrolledComparative.d.ts.map +1 -0
  34. package/dist-tsc/UncontrolledComparative.js +50 -0
  35. package/dist-tsc/index.d.ts +7 -0
  36. package/dist-tsc/index.d.ts.map +1 -0
  37. package/dist-tsc/index.js +14 -0
  38. package/package.json +53 -16
  39. package/src/BiomarkerSelect.jsx +107 -0
  40. package/src/ComparativeConfig.jsx +562 -0
  41. package/src/ControlledComparative.jsx +140 -0
  42. package/src/UncontrolledComparative.jsx +88 -0
  43. package/src/index.js +18 -0
  44. package/dist/index.d.ts +0 -4
  45. package/dist/index.js +0 -9
@@ -0,0 +1,2 @@
1
+ export function BiomarkerSelect(props: any): JSX.Element;
2
+ //# sourceMappingURL=BiomarkerSelect.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"BiomarkerSelect.d.ts","sourceRoot":"","sources":["../src/BiomarkerSelect.jsx"],"names":[],"mappings":"AAOA,yDAmGC"}
@@ -0,0 +1,65 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ /* eslint-disable max-len */
3
+ /* eslint-disable no-underscore-dangle */
4
+ import React, { useMemo, useState, useCallback } from 'react';
5
+ import { Vitessce } from '@vitessce/all';
6
+ import { isEqual } from 'lodash-es';
7
+ import { BiomarkerSelectPageComponent, generateComparativeConfig } from './ComparativeConfig.jsx';
8
+ export function BiomarkerSelect(props) {
9
+ const { datasetUrl = 'https://data-2.vitessce.io/kpmp-atlas-v2/sn-rna-seq/processed/kpmp-aug-2025.adata.zarr', geneSelection, sampleSetSelection, setGeneSelection, setSampleSetSelection, theme = 'light2', debugMode = false, logLevel = undefined, } = props;
10
+ const initialConfig = useMemo(() => generateComparativeConfig(datasetUrl, true), [datasetUrl]);
11
+ const [currentConfig, setCurrentConfig] = useState(null);
12
+ // Merge currentConfig with geneSelection and sampleSetSelection,
13
+ // which may have been updated from outside Vitessce (e.g., from URL params).
14
+ const mergedConfig = useMemo(() => {
15
+ if (!currentConfig) {
16
+ return initialConfig;
17
+ }
18
+ // Merge currentConfig with geneSelection and sampleSetSelection.
19
+ const isValidGeneSelection = Array.isArray(geneSelection) && geneSelection.every(g => typeof g === 'string');
20
+ const isValidSampleSetSelection = Array.isArray(sampleSetSelection) && sampleSetSelection.every(s => Array.isArray(s) && s.every(t => typeof t === 'string'));
21
+ const newConfig = {
22
+ ...currentConfig,
23
+ coordinationSpace: {
24
+ ...currentConfig.coordinationSpace,
25
+ featureSelection: {
26
+ ...currentConfig.coordinationSpace?.featureSelection,
27
+ __comparison__: (isValidGeneSelection
28
+ ? geneSelection
29
+ : currentConfig.coordinationSpace?.featureSelection?.__comparison__),
30
+ },
31
+ sampleSetSelection: {
32
+ ...currentConfig.coordinationSpace?.sampleSetSelection,
33
+ __comparison__: (isValidSampleSetSelection
34
+ ? sampleSetSelection
35
+ : currentConfig.coordinationSpace?.sampleSetSelection?.__comparison__),
36
+ },
37
+ },
38
+ };
39
+ return newConfig;
40
+ }, [initialConfig, currentConfig, geneSelection, sampleSetSelection]);
41
+ const onConfigChange = useCallback((newConfig) => {
42
+ // Listen for changes to the config from inside vITESSCE
43
+ setCurrentConfig(newConfig);
44
+ // Listen for changes to featureSelection and sampleSetSelection in the coordination space.
45
+ const newFeatureSelection = newConfig.coordinationSpace?.featureSelection?.__comparison__;
46
+ const newSampleSetSelection = newConfig.coordinationSpace?.sampleSetSelection?.__comparison__;
47
+ // Was there a new selection made from inside Vitessce?
48
+ // Note: this will prevent from CLEARING the selections from inside Vitessce
49
+ // (any clearing will need to be done from the BiomarkerSelect UI).
50
+ const hasNewGeneSelection = (Array.isArray(newFeatureSelection)
51
+ && newFeatureSelection.length > 0
52
+ && !isEqual(newFeatureSelection, geneSelection));
53
+ const hasNewSampleSetSelection = (Array.isArray(newSampleSetSelection)
54
+ && newSampleSetSelection.length > 0
55
+ && !isEqual(newSampleSetSelection, sampleSetSelection));
56
+ if (hasNewGeneSelection) {
57
+ setGeneSelection(newFeatureSelection);
58
+ }
59
+ if (hasNewSampleSetSelection) {
60
+ setSampleSetSelection(newSampleSetSelection);
61
+ }
62
+ }, [geneSelection, sampleSetSelection]);
63
+ const didFirstValidation = currentConfig !== null;
64
+ return (_jsx("div", { children: _jsx(Vitessce, { config: mergedConfig, onConfigChange: onConfigChange, remountOnUidChange: false, validateConfig: !didFirstValidation, validateOnConfigChange: false, rowHeight: null, theme: theme, pageMode: true, debugMode: debugMode, logLevel: logLevel, children: _jsx(BiomarkerSelectPageComponent, {}) }) }));
65
+ }
@@ -0,0 +1,12 @@
1
+ /**
2
+ * Generate a Vitessce config for comparative visualization.
3
+ * If isBiomarkerSelectOnly is true, only the biomarkerSelect view is included.
4
+ * Otherwise, a config without the biomarkerSelect view is generated.
5
+ * @param {string} baseUrl
6
+ * @param {boolean} isBiomarkerSelectOnly
7
+ * @returns
8
+ */
9
+ export function generateComparativeConfig(baseUrl: string, isBiomarkerSelectOnly: boolean): object;
10
+ export function BiomarkerSelectPageComponent(): JSX.Element;
11
+ export function ComparativePageComponent(): JSX.Element;
12
+ //# sourceMappingURL=ComparativeConfig.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ComparativeConfig.d.ts","sourceRoot":"","sources":["../src/ComparativeConfig.jsx"],"names":[],"mappings":"AAgBA;;;;;;;GAOG;AACH,mDAJW,MAAM,yBACN,OAAO,UA0OjB;AAED,4DAkDC;AAED,wDA4PC"}
@@ -0,0 +1,326 @@
1
+ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
2
+ /* eslint-disable max-len */
3
+ /* eslint-disable camelcase */
4
+ /* eslint-disable no-unused-vars */
5
+ /* eslint-disable react-refresh/only-export-components */
6
+ /* eslint-disable jsx-a11y/anchor-is-valid */ // Remove once the "Show analysis details" dropdowns are implemented.
7
+ import React, { useState } from 'react';
8
+ import { VitessceConfig, hconcat, vconcat, } from '@vitessce/config';
9
+ import { usePageModeView } from '@vitessce/vit-s';
10
+ import Sticky from 'react-sticky-el';
11
+ import clsx from 'clsx';
12
+ import { Tabs, Tab, Link } from '@vitessce/styles';
13
+ /**
14
+ * Generate a Vitessce config for comparative visualization.
15
+ * If isBiomarkerSelectOnly is true, only the biomarkerSelect view is included.
16
+ * Otherwise, a config without the biomarkerSelect view is generated.
17
+ * @param {string} baseUrl
18
+ * @param {boolean} isBiomarkerSelectOnly
19
+ * @returns
20
+ */
21
+ export function generateComparativeConfig(baseUrl, isBiomarkerSelectOnly) {
22
+ const vc = new VitessceConfig({ schemaVersion: '1.0.16', name: 'Lake et al.' });
23
+ const dataset = vc.addDataset('lake_et_al').addFile({
24
+ fileType: 'comparisonMetadata.anndata.zarr',
25
+ url: baseUrl,
26
+ options: {
27
+ path: 'uns/comparison_metadata',
28
+ },
29
+ coordinationValues: {
30
+ obsType: 'cell',
31
+ sampleType: 'sample',
32
+ },
33
+ // TODO: remove the below once the biomarkerSelect view is capable of adding them based on the above comparisonMetadata.
34
+ }).addFile({
35
+ fileType: 'comparativeFeatureStats.anndata.zarr',
36
+ url: baseUrl,
37
+ options: {
38
+ metadataPath: 'uns/comparison_metadata',
39
+ indexColumn: 'names',
40
+ pValueColumn: 'pvals_adj',
41
+ foldChangeColumn: 'logfoldchanges',
42
+ // pValueTransformation: 'minuslog10',
43
+ pValueAdjusted: true,
44
+ foldChangeTransformation: 'log2',
45
+ },
46
+ coordinationValues: {
47
+ obsType: 'cell',
48
+ sampleType: 'sample',
49
+ featureType: 'gene',
50
+ },
51
+ // TODO: remove the below once the biomarkerSelect view is capable of adding them based on the above comparisonMetadata.
52
+ }).addFile({
53
+ fileType: 'comparativeObsSetStats.anndata.zarr',
54
+ url: baseUrl,
55
+ options: {
56
+ metadataPath: 'uns/comparison_metadata',
57
+ indexColumn: 'Cell Type',
58
+ interceptExpectedSampleColumn: 'Expected Sample_intercept',
59
+ effectExpectedSampleColumn: 'Expected Sample_effect',
60
+ foldChangeColumn: 'log2-fold change',
61
+ foldChangeTransformation: 'log2',
62
+ isCredibleEffectColumn: 'is_credible_effect',
63
+ },
64
+ coordinationValues: {
65
+ obsType: 'cell',
66
+ sampleType: 'sample',
67
+ },
68
+ // TODO: remove the below once the biomarkerSelect view is capable of adding them based on the above comparisonMetadata.
69
+ })
70
+ .addFile({
71
+ fileType: 'comparativeFeatureSetStats.anndata.zarr',
72
+ url: baseUrl,
73
+ options: {
74
+ metadataPath: 'uns/comparison_metadata',
75
+ indexColumn: 'pathway_name',
76
+ termColumn: 'pathway_term',
77
+ pValueColumn: 'pvals_adj',
78
+ pValueAdjusted: true,
79
+ analysisType: 'pertpy_hypergeometric',
80
+ featureSetLibrary: 'Reactome_2022',
81
+ },
82
+ coordinationValues: {
83
+ obsType: 'cell',
84
+ featureType: 'gene',
85
+ sampleType: 'sample',
86
+ },
87
+ // TODO: remove the below once the biomarkerSelect view is capable of adding them based on the above comparisonMetadata.
88
+ })
89
+ .addFile({
90
+ fileType: 'anndata.zarr',
91
+ url: baseUrl,
92
+ coordinationValues: {
93
+ obsType: 'cell',
94
+ featureType: 'gene',
95
+ featureValueType: 'expression',
96
+ sampleType: 'sample',
97
+ },
98
+ options: {
99
+ obsFeatureMatrix: {
100
+ // "path": "layers/counts",
101
+ // "path": "layers/logcounts",
102
+ path: 'layers/pearson_residuals',
103
+ },
104
+ obsEmbedding: [
105
+ {
106
+ path: 'obsm/X_densmap',
107
+ embeddingType: 'densMAP',
108
+ },
109
+ ],
110
+ obsSets: [
111
+ {
112
+ name: 'Subclass L1',
113
+ path: 'obs/subclass_l1',
114
+ },
115
+ {
116
+ name: 'Subclass L2',
117
+ path: 'obs/subclass_l2',
118
+ },
119
+ {
120
+ name: 'Subclass L3',
121
+ path: 'obs/subclass_l3',
122
+ },
123
+ /* {
124
+ name: 'Donor ID',
125
+ path: 'obs/patient',
126
+ }, */
127
+ /* {
128
+ name: 'Disease',
129
+ path: 'obs/disease',
130
+ },
131
+ {
132
+ name: 'Disease Type',
133
+ path: 'obs/diseasetype',
134
+ },
135
+ {
136
+ name: 'Adjudicated Category',
137
+ path: 'obs/AdjudicatedCategory',
138
+ },
139
+ {
140
+ name: 'Enrollment Category',
141
+ path: 'obs/EnrollmentCategory',
142
+ }, */
143
+ ],
144
+ /* featureLabels: {
145
+ path: 'var/features',
146
+ }, */
147
+ sampleEdges: {
148
+ path: 'obs/specimen',
149
+ },
150
+ },
151
+ })
152
+ .addFile({
153
+ fileType: 'sampleSets.anndata.zarr',
154
+ url: `${baseUrl}/uns/__all__.samples`,
155
+ options: {
156
+ sampleSets: [
157
+ {
158
+ name: 'Adjudicated Category',
159
+ path: 'AdjudicatedCategory',
160
+ },
161
+ {
162
+ name: 'Enrollment Category',
163
+ path: 'EnrollmentCategory',
164
+ },
165
+ ],
166
+ },
167
+ coordinationValues: {
168
+ sampleType: 'sample',
169
+ },
170
+ });
171
+ const [sampleSetScope_caseControl] = vc.addCoordination({
172
+ cType: 'sampleSetSelection',
173
+ cScope: '__comparison__',
174
+ // cValue: [['Enrollment Category', 'Healthy Reference'], ['Enrollment Category', 'AKI']],
175
+ cValue: null,
176
+ });
177
+ const [featureSelectionScope] = vc.addCoordination({
178
+ cType: 'featureSelection',
179
+ cScope: '__comparison__',
180
+ // cValue: ['UMOD', 'NPHS2'], // , 'ENSG00000074803', 'ENSG00000164825'],
181
+ cValue: null,
182
+ });
183
+ if (isBiomarkerSelectOnly) {
184
+ const biomarkerSelect = vc.addView(dataset, 'biomarkerSelectAlt', { uid: 'biomarker-select' });
185
+ vc.linkViews([biomarkerSelect], ['sampleType'], ['sample']);
186
+ vc.linkViewsByObject([biomarkerSelect], {
187
+ sampleSetSelection: sampleSetScope_caseControl,
188
+ featureSelection: featureSelectionScope,
189
+ }, { meta: false });
190
+ vc.layout(biomarkerSelect);
191
+ }
192
+ else {
193
+ const comparativeHeading = vc.addView(dataset, 'comparativeHeading', { uid: 'comparative-heading' });
194
+ const dualScatterplot = vc.addView(dataset, 'dualScatterplot', { uid: 'scatterplot' }).setProps({ circleScaleFactor: 0.5 });
195
+ const obsSets = vc.addView(dataset, 'obsSets', { uid: 'cell-sets' });
196
+ const sampleSets = vc.addView(dataset, 'sampleSetPairManager', { uid: 'sample-sets' });
197
+ const obsSetSizes = vc.addView(dataset, 'obsSetSizes');
198
+ const featureList = vc.addView(dataset, 'featureList');
199
+ const violinPlots = vc.addView(dataset, 'obsSetFeatureValueDistribution', { uid: 'violin-plot' });
200
+ const dotPlot = vc.addView(dataset, 'dotPlot', { uid: 'dot-plot' });
201
+ const treemap = vc.addView(dataset, 'treemap', { uid: 'treemap' });
202
+ const volcanoPlot = vc.addView(dataset, 'volcanoPlot', { uid: 'volcano-plot' });
203
+ const volcanoPlotTable = vc.addView(dataset, 'featureStatsTable', { uid: 'volcano-plot-table' });
204
+ const obsSetCompositionBarPlot = vc.addView(dataset, 'obsSetCompositionBarPlot', { uid: 'sccoda-plot' });
205
+ const featureSetEnrichmentBarPlot = vc.addView(dataset, 'featureSetEnrichmentBarPlot', { uid: 'pathways-plot' });
206
+ vc.linkViewsByObject([dualScatterplot], {
207
+ embeddingType: 'densMAP',
208
+ embeddingContoursVisible: true,
209
+ embeddingPointsVisible: false,
210
+ embeddingObsSetLabelsVisible: true,
211
+ }, { meta: false });
212
+ vc.linkViews([dualScatterplot, obsSets, obsSetSizes, featureList, violinPlots, dotPlot, treemap, volcanoPlot, volcanoPlotTable, comparativeHeading, obsSetCompositionBarPlot, featureSetEnrichmentBarPlot, sampleSets], ['sampleType'], ['sample']);
213
+ vc.linkViewsByObject([dualScatterplot, obsSets, obsSetSizes, featureList, violinPlots, dotPlot, treemap, volcanoPlot, volcanoPlotTable, comparativeHeading, obsSetCompositionBarPlot, featureSetEnrichmentBarPlot, sampleSets], {
214
+ sampleSetSelection: sampleSetScope_caseControl,
215
+ featureSelection: featureSelectionScope,
216
+ }, { meta: false });
217
+ vc.linkViewsByObject([dualScatterplot, violinPlots, featureList, dotPlot], {
218
+ obsColorEncoding: 'geneSelection',
219
+ featureValueColormap: 'greys',
220
+ featureValueColormapRange: [0, 0.25],
221
+ featureAggregationStrategy: null,
222
+ }, { meta: false });
223
+ vc.linkViewsByObject([obsSets], {
224
+ obsSetExpansion: [['Subclass L1']],
225
+ }, { meta: false });
226
+ /*
227
+ const [donorSelectionScope, cellTypeSelectionScope] = vc.addCoordination(
228
+ { cType: 'obsSetSelection', cScope: 'donor', cValue: [['Donor ID', '3593'], ['Donor ID', '3535']] },
229
+ { cType: 'obsSetSelection', cScope: 'cellType', cValue: [['Cell Type', 'leukocyte'], ['Cell Type', 'kidney collecting duct intercalated cell']] },
230
+ );
231
+ */
232
+ vc.layout(hconcat(vconcat(dualScatterplot, comparativeHeading, obsSets, obsSetSizes), vconcat(treemap, dotPlot, obsSetCompositionBarPlot, sampleSets), vconcat(volcanoPlotTable, featureList, featureSetEnrichmentBarPlot, violinPlots)));
233
+ }
234
+ const configJSON = vc.toJSON();
235
+ return configJSON;
236
+ }
237
+ export function BiomarkerSelectPageComponent() {
238
+ const BiomarkerSelect = usePageModeView('biomarker-select');
239
+ return (_jsxs(_Fragment, { children: [_jsx("style", { children: `
240
+ .view-row {
241
+ width: 100%;
242
+ display: flex;
243
+ flex-direction: row;
244
+ }
245
+ .view-row-left {
246
+ width: ${(15 / 85) * 100}%;
247
+ padding: 10px;
248
+ }
249
+ .view-row-left p {
250
+ font-size: 12px;
251
+ margin-top: 20px;
252
+ }
253
+ .view-row-left p.tabs-description {
254
+ margin-top: 0px;
255
+ }
256
+ .view-row-center {
257
+ width: ${(70 / 85) * 100}%;
258
+ }
259
+ ` }), _jsx("div", { style: { width: '100%', display: 'flex', flexDirection: 'row' }, children: _jsx("div", { style: { width: '85%' }, children: _jsxs("div", { className: clsx('view-row'), children: [_jsx("div", { className: "view-row-left" }), _jsx("div", { className: "view-row-center", children: _jsx(BiomarkerSelect, {}) })] }) }) })] }));
260
+ }
261
+ export function ComparativePageComponent() {
262
+ const ComparativeHeading = usePageModeView('comparative-heading');
263
+ const CellSets = usePageModeView('cell-sets');
264
+ const SampleSets = usePageModeView('sample-sets');
265
+ const DualScatterplot = usePageModeView('scatterplot');
266
+ const ViolinPlot = usePageModeView('violin-plot');
267
+ const DotPlot = usePageModeView('dot-plot');
268
+ const Treemap = usePageModeView('treemap');
269
+ const VolcanoPlot = usePageModeView('volcano-plot');
270
+ const VolcanoPlotTable = usePageModeView('volcano-plot-table');
271
+ const SccodaPlot = usePageModeView('sccoda-plot');
272
+ const PathwaysPlot = usePageModeView('pathways-plot');
273
+ const [visTab, setVisTab] = useState(0);
274
+ const [tableTab, setTableTab] = useState(0);
275
+ return (_jsxs(_Fragment, { children: [_jsx("style", { children: `
276
+ h1, h2, h3, h4, h5, h6 {
277
+ font-family: sans-serif;
278
+ }
279
+ h1 {
280
+ font-weight: normal;
281
+ }
282
+ h2 {
283
+ font-size: 36px;
284
+ }
285
+ h3 {
286
+ font-size: 28px;
287
+ }
288
+ .stuck-comparative-heading {
289
+ background-color: rgba(255, 255, 255, 0.7);
290
+ }
291
+ .stuck-comparative-heading h2 {
292
+ font-size: 16px;
293
+ }
294
+ .stuck-comparative-heading h3 {
295
+ font-size: 14px;
296
+ }
297
+ .view-row {
298
+ width: 100%;
299
+ display: flex;
300
+ flex-direction: row;
301
+ }
302
+ .view-row-short {
303
+ height: 300px;
304
+ }
305
+ .view-row-tall {
306
+ height: 500px;
307
+ }
308
+ .view-row-left {
309
+ width: ${(15 / 85) * 100}%;
310
+ padding: 10px;
311
+ }
312
+ .view-row-left p {
313
+ font-size: 12px;
314
+ margin-top: 20px;
315
+ }
316
+ .view-row-left p.tabs-description {
317
+ margin-top: 0px;
318
+ }
319
+ .view-row-center {
320
+ width: ${(70 / 85) * 100}%;
321
+ }
322
+ .view-row-right > div {
323
+ max-height: 100vh;
324
+ }
325
+ ` }), _jsxs("div", { style: { width: '100%', display: 'flex', flexDirection: 'row' }, children: [_jsxs("div", { style: { width: '85%' }, children: [_jsxs("div", { className: clsx('view-row', 'view-row-tall'), children: [_jsx("div", { className: "view-row-left", children: _jsx("p", { children: "This view contains contour scatterplots which display the results of a density-preserving dimensionality reduction (Narayan et al. 2021). Contour opacities correspond to the shown percentile thresholds." }) }), _jsx("div", { className: "view-row-center", children: _jsx(DualScatterplot, {}) })] }), _jsxs("div", { className: clsx('view-row'), children: [_jsx("div", { className: "view-row-left" }), _jsx("div", { className: "view-row-center", children: _jsx(Link, { component: "button", href: "#", variant: "body2", children: "Show analysis details" }) })] }), _jsxs("div", { className: clsx('view-row'), children: [_jsx("div", { className: "view-row-left", children: _jsx("p", { className: "tabs-description", children: "Use the tabs to switch the visualization rendered below." }) }), _jsx("div", { className: "view-row-center", children: _jsxs(Tabs, { value: visTab, onChange: (event, newValue) => setVisTab(newValue), "aria-label": "Switch visualization tabs", children: [_jsx(Tab, { label: "Treemap Plot" }), _jsx(Tab, { label: "Volcano Plot" }), _jsx(Tab, { label: "Dot Plot" }), _jsx(Tab, { label: "Violin Plot" }), _jsx(Tab, { label: "Cell Type Composition Bar Plot" })] }) })] }), visTab === 0 ? (_jsxs(_Fragment, { children: [_jsxs("div", { className: clsx('view-row', 'view-row-short'), children: [_jsx("div", { className: "view-row-left", children: _jsx("p", { children: "This view contains a treemap visualization to communicate cell type composition in each of the selected sample groups." }) }), _jsx("div", { className: "view-row-center", children: _jsx(Treemap, {}) })] }), _jsxs("div", { className: clsx('view-row'), children: [_jsx("div", { className: "view-row-left" }), _jsx("div", { className: "view-row-center", children: _jsx(Link, { component: "button", href: "#", variant: "body2", children: "Show analysis details" }) })] })] })) : null, visTab === 1 ? (_jsxs(_Fragment, { children: [_jsxs("div", { className: clsx('view-row', 'view-row-tall'), children: [_jsx("div", { className: "view-row-left", children: _jsxs("p", { children: ["This view displays differential expression test results, performed using the rank_genes_groups function from Scanpy (Wolf et al. 2018) with method \"wilcoxon\". ", _jsx("br", {}), _jsx("br", {}), "The arrows on the bottom left and bottom right denote the direction of the effect. Click a point in the plot to select the corresponding gene. ", _jsx("br", {}), _jsx("br", {}), "Note that differential expression tests have been run for each cell type separately, so the each gene can appear multiple times (once per cell type). If there are too many points on the plot, cell types can be selected to filter the points."] }) }), _jsx("div", { className: "view-row-center", children: _jsx(VolcanoPlot, {}) })] }), _jsxs("div", { className: clsx('view-row'), children: [_jsx("div", { className: "view-row-left" }), _jsx("div", { className: "view-row-center", children: _jsx(Link, { component: "button", href: "#", variant: "body2", children: "Show analysis details" }) })] })] })) : null, visTab === 2 ? (_jsxs(_Fragment, { children: [_jsxs("div", { className: clsx('view-row', 'view-row-tall'), children: [_jsx("div", { className: "view-row-left", children: _jsx("p", { children: "This dot plot view displays gene expression values per cell type and sample group for the selected biomarkers." }) }), _jsx("div", { className: "view-row-center", children: _jsx(DotPlot, {}) })] }), _jsxs("div", { className: clsx('view-row'), children: [_jsx("div", { className: "view-row-left" }), _jsx("div", { className: "view-row-center", children: _jsx(Link, { component: "button", href: "#", variant: "body2", children: "Show analysis details" }) })] })] })) : null, visTab === 3 ? (_jsxs(_Fragment, { children: [_jsxs("div", { className: clsx('view-row', 'view-row-tall'), children: [_jsx("div", { className: "view-row-left", children: _jsx("p", { children: "This violin plot view displays gene expression values per cell type and sample group for the selected biomarker." }) }), _jsx("div", { className: "view-row-center", children: _jsx(ViolinPlot, {}) })] }), _jsxs("div", { className: clsx('view-row'), children: [_jsx("div", { className: "view-row-left" }), _jsx("div", { className: "view-row-center", children: _jsx(Link, { component: "button", href: "#", variant: "body2", children: "Show analysis details" }) })] })] })) : null, visTab === 4 ? (_jsxs(_Fragment, { children: [_jsxs("div", { className: clsx('view-row', 'view-row-tall'), children: [_jsx("div", { className: "view-row-left", children: _jsx("p", { children: "This view displays the results of a cell type composition analysis performed using the ScCODA algorithm (B\u00FCttner et al. 2021). Cell types with significantly different composition between the selected sample groups are displayed opaque while not-signficant results are displayed with transparent bars. The single outlined bar denotes the automatically-selected reference cell type." }) }), _jsx("div", { className: "view-row-center", children: _jsx(SccodaPlot, {}) })] }), _jsxs("div", { className: clsx('view-row'), children: [_jsx("div", { className: "view-row-left" }), _jsx("div", { className: "view-row-center", children: _jsx(Link, { component: "button", href: "#", variant: "body2", children: "Show analysis details" }) })] })] })) : null, _jsxs("div", { className: clsx('view-row'), children: [_jsx("div", { className: "view-row-left", children: _jsx("p", { className: "tabs-description", children: "Use the tabs to switch the table rendered below." }) }), _jsx("div", { className: "view-row-center", children: _jsxs(Tabs, { value: tableTab, onChange: (event, newValue) => setTableTab(newValue), "aria-label": "Switch table tabs", children: [_jsx(Tab, { label: "Differential Expression Results for Selected Gene" }), _jsx(Tab, { label: "Differential Expression Results for All Genes" }), _jsx(Tab, { label: "Gene Set Enrichment Analysis Results" })] }) })] }), tableTab === 0 ? (_jsxs(_Fragment, { children: [_jsxs("div", { className: clsx('view-row', 'view-row-tall'), children: [_jsx("div", { className: "view-row-left", children: _jsx("p", { children: "This view displays differential expression test results in tabular form. Click a row in the table to select the corresponding gene." }) }), _jsx("div", { className: "view-row-center", children: _jsx(VolcanoPlotTable, {}) })] }), _jsxs("div", { className: clsx('view-row'), children: [_jsx("div", { className: "view-row-left" }), _jsx("div", { className: "view-row-center", children: _jsx(Link, { component: "button", href: "#", variant: "body2", children: "Show analysis details" }) })] })] })) : null] }), _jsx("div", { style: { width: '14%', marginTop: '114px', marginBottom: '100px' }, children: _jsx(Sticky, { children: _jsx("div", { className: "view-row-right", children: _jsx(CellSets, {}) }) }) })] })] }));
326
+ }
@@ -0,0 +1,30 @@
1
+ /**
2
+ * A controlled component for comparative visualization that synchronizes
3
+ * gene selection and sample set selection state with its parent.
4
+ * @param {object} props
5
+ * @param {string} props.datasetUrl - URL to the comparative AnnData-Zarr
6
+ * store.
7
+ * @param {string[]} props.geneSelection - Array of selected gene names.
8
+ * @param {Function} props.setGeneSelection - Setter function
9
+ * called when the gene selection has been updated from inside.
10
+ * @param {string[][]} props.sampleSetSelection - Array of sample set
11
+ * selections, where each element is an array of sample identifiers,
12
+ * like [["Enrollment Category", "CKD"], ["Enrollment Category", "AKI"]].
13
+ * @param {Function} props.setSampleSetSelection - Setter function
14
+ * called when the sample set selection has been updated from inside.
15
+ * @param {string} [props.theme='light2'] - Theme name.
16
+ * @param {boolean} [props.debugMode=false] - Enable debug mode.
17
+ * @param {string} props.logLevel - Log level.
18
+ * @returns {React.ReactElement} The comparative visualization component.
19
+ */
20
+ export function ControlledComparative(props: {
21
+ datasetUrl: string;
22
+ geneSelection: string[];
23
+ setGeneSelection: Function;
24
+ sampleSetSelection: string[][];
25
+ setSampleSetSelection: Function;
26
+ theme?: string | undefined;
27
+ debugMode?: boolean | undefined;
28
+ logLevel: string;
29
+ }): React.ReactElement;
30
+ //# sourceMappingURL=ControlledComparative.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ControlledComparative.d.ts","sourceRoot":"","sources":["../src/ControlledComparative.jsx"],"names":[],"mappings":"AAOA;;;;;;;;;;;;;;;;;;GAkBG;AACH,6CAfG;IAAsB,UAAU,EAAxB,MAAM;IAEU,aAAa,EAA7B,MAAM,EAAE;IACQ,gBAAgB;IAEd,kBAAkB,EAApC,MAAM,EAAE,EAAE;IAGM,qBAAqB;IAEtB,KAAK;IACJ,SAAS;IACX,QAAQ,EAAtB,MAAM;CACd,GAAU,KAAK,CAAC,YAAY,CAmH9B"}
@@ -0,0 +1,95 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ /* eslint-disable max-len */
3
+ /* eslint-disable no-underscore-dangle */
4
+ import React, { useMemo, useState, useCallback } from 'react';
5
+ import { Vitessce } from '@vitessce/all';
6
+ import { isEqual } from 'lodash-es';
7
+ import { ComparativePageComponent, generateComparativeConfig } from './ComparativeConfig.jsx';
8
+ /**
9
+ * A controlled component for comparative visualization that synchronizes
10
+ * gene selection and sample set selection state with its parent.
11
+ * @param {object} props
12
+ * @param {string} props.datasetUrl - URL to the comparative AnnData-Zarr
13
+ * store.
14
+ * @param {string[]} props.geneSelection - Array of selected gene names.
15
+ * @param {Function} props.setGeneSelection - Setter function
16
+ * called when the gene selection has been updated from inside.
17
+ * @param {string[][]} props.sampleSetSelection - Array of sample set
18
+ * selections, where each element is an array of sample identifiers,
19
+ * like [["Enrollment Category", "CKD"], ["Enrollment Category", "AKI"]].
20
+ * @param {Function} props.setSampleSetSelection - Setter function
21
+ * called when the sample set selection has been updated from inside.
22
+ * @param {string} [props.theme='light2'] - Theme name.
23
+ * @param {boolean} [props.debugMode=false] - Enable debug mode.
24
+ * @param {string} props.logLevel - Log level.
25
+ * @returns {React.ReactElement} The comparative visualization component.
26
+ */
27
+ export function ControlledComparative(props) {
28
+ const { datasetUrl = 'https://data-2.vitessce.io/kpmp-atlas-v2/sn-rna-seq/processed/kpmp-aug-2025.adata.zarr', geneSelection, setGeneSelection, sampleSetSelection, setSampleSetSelection, theme = 'light2', debugMode = false, logLevel = undefined, } = props;
29
+ const initialConfig = useMemo(() => generateComparativeConfig(datasetUrl, false), [datasetUrl]);
30
+ const [currentConfig, setCurrentConfig] = useState(null);
31
+ // Merge currentConfig with geneSelection and sampleSetSelection,
32
+ // which may have been updated from outside Vitessce (e.g., from URL params).
33
+ const mergedConfig = useMemo(() => {
34
+ if (!currentConfig) {
35
+ return initialConfig;
36
+ }
37
+ // Merge currentConfig with geneSelection and sampleSetSelection.
38
+ const isValidGeneSelection = Array.isArray(geneSelection) && geneSelection.every(g => typeof g === 'string');
39
+ const isValidSampleSetSelection = Array.isArray(sampleSetSelection) && sampleSetSelection.every(s => Array.isArray(s) && s.every(t => typeof t === 'string'));
40
+ // Check if geneSelection or sampleSetSelection have changed before specifying a different config.uid value.
41
+ const prevGeneSelection = currentConfig.coordinationSpace?.featureSelection?.__comparison__;
42
+ const prevSampleSetSelection = currentConfig.coordinationSpace?.sampleSetSelection?.__comparison__;
43
+ if (isEqual(prevGeneSelection, geneSelection)
44
+ && isEqual(prevSampleSetSelection, sampleSetSelection)) {
45
+ return currentConfig;
46
+ }
47
+ const newConfig = {
48
+ ...currentConfig,
49
+ // Note: this forces Vitessce to re-initialize the coordination space for featureSelection and sampleSetSelection,
50
+ // but it also causes the data to be re-loaded.
51
+ uid: `controlled-comparative-${Date.now()}`,
52
+ coordinationSpace: {
53
+ ...currentConfig.coordinationSpace,
54
+ featureSelection: {
55
+ ...currentConfig.coordinationSpace?.featureSelection,
56
+ __comparison__: (isValidGeneSelection
57
+ ? geneSelection
58
+ : currentConfig.coordinationSpace?.featureSelection?.__comparison__),
59
+ },
60
+ sampleSetSelection: {
61
+ ...currentConfig.coordinationSpace?.sampleSetSelection,
62
+ __comparison__: (isValidSampleSetSelection
63
+ ? sampleSetSelection
64
+ : currentConfig.coordinationSpace?.sampleSetSelection?.__comparison__),
65
+ },
66
+ },
67
+ };
68
+ // console.log(geneSelection, isValidGeneSelection, newConfig);
69
+ return newConfig;
70
+ }, [initialConfig, currentConfig, geneSelection, sampleSetSelection]);
71
+ const onConfigChange = useCallback((newConfig) => {
72
+ // Listen for changes to the config from inside vITESSCE
73
+ setCurrentConfig(newConfig);
74
+ // Listen for changes to featureSelection and sampleSetSelection in the coordination space.
75
+ const newFeatureSelection = newConfig.coordinationSpace?.featureSelection?.__comparison__;
76
+ const newSampleSetSelection = newConfig.coordinationSpace?.sampleSetSelection?.__comparison__;
77
+ // Was there a new selection made from inside Vitessce?
78
+ // Note: this will prevent from CLEARING the selections from inside Vitessce
79
+ // (any clearing will need to be done from the BiomarkerSelect UI).
80
+ const hasNewGeneSelection = (Array.isArray(newFeatureSelection)
81
+ && newFeatureSelection.length > 0
82
+ && !isEqual(newFeatureSelection, geneSelection));
83
+ const hasNewSampleSetSelection = (Array.isArray(newSampleSetSelection)
84
+ && newSampleSetSelection.length > 0
85
+ && !isEqual(newSampleSetSelection, sampleSetSelection));
86
+ if (hasNewGeneSelection) {
87
+ setGeneSelection(newFeatureSelection);
88
+ }
89
+ if (hasNewSampleSetSelection) {
90
+ setSampleSetSelection(newSampleSetSelection);
91
+ }
92
+ }, [geneSelection, sampleSetSelection]);
93
+ const didFirstValidation = currentConfig !== null;
94
+ return (_jsx("div", { children: _jsx(Vitessce, { config: mergedConfig, onConfigChange: onConfigChange, remountOnUidChange: false, validateConfig: !didFirstValidation, validateOnConfigChange: false, rowHeight: null, theme: theme, pageMode: true, debugMode: debugMode, logLevel: logLevel, children: _jsx(ComparativePageComponent, {}) }) }));
95
+ }
@@ -0,0 +1,10 @@
1
+ /**
2
+ * The UncontrolledComparative component is a Provider component
3
+ * that wraps the UncontrolledComparativeInner component.
4
+ * See the UncontrolledComparativeInner component documentation
5
+ * for details on the props (all props are simply passed through).
6
+ * @param {*} props
7
+ * @returns
8
+ */
9
+ export function UncontrolledComparative(props: any): JSX.Element;
10
+ //# sourceMappingURL=UncontrolledComparative.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"UncontrolledComparative.d.ts","sourceRoot":"","sources":["../src/UncontrolledComparative.jsx"],"names":[],"mappings":"AAuEA;;;;;;;GAOG;AACH,+CAHW,GAAC,eAWX"}
@@ -0,0 +1,50 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ /* eslint-disable max-len */
3
+ /* eslint-disable react-refresh/only-export-components */
4
+ import React, { useState } from 'react';
5
+ // eslint-disable-next-line import/no-unresolved
6
+ import { NuqsAdapter } from 'nuqs/adapters/react';
7
+ import { useQueryState, parseAsString, parseAsArrayOf } from 'nuqs';
8
+ import { ControlledComparative } from './ControlledComparative.jsx';
9
+ import { BiomarkerSelect } from './BiomarkerSelect.jsx';
10
+ /**
11
+ * The UncontrolledComparative component is a wrapper
12
+ * around the ControlledComparative and BiomarkerSelect components.
13
+ * @param {object} props
14
+ * @param {string} props.datasetUrl URL of the dataset to load,
15
+ * which should point to the root of an anndata-zarr store,
16
+ * containing comparative metadata.
17
+ * @param {boolean} props.enableQueryParams Whether to
18
+ * sync state to the URL query parameters for gene and
19
+ * sample set selection. By default, true.
20
+ * @returns {JSX.Element}
21
+ */
22
+ function UncontrolledComparativeInner(props) {
23
+ const { datasetUrl, enableQueryParams = true, } = props;
24
+ const [geneSelectionViaUrl, setGeneSelectionViaUrl] = useQueryState('gene', parseAsArrayOf(parseAsString));
25
+ const [sampleSetSelectionViaUrl, setSampleSetSelectionViaUrl] = useQueryState('groups', parseAsArrayOf(parseAsArrayOf(parseAsString)));
26
+ const [geneSelectionNonUrl, setGeneSelectionNonUrl] = useState([]);
27
+ const [sampleSetSelectionNonUrl, setSampleSetSelectionNonUrl] = useState([]);
28
+ // Depending on the value of enableQueryParams,
29
+ // we either use the state that is synced to the URL query parameters,
30
+ // or we use local state that is not synced to the URL.
31
+ const geneSelection = enableQueryParams ? geneSelectionViaUrl : geneSelectionNonUrl;
32
+ const setGeneSelection = enableQueryParams ? setGeneSelectionViaUrl : setGeneSelectionNonUrl;
33
+ const sampleSetSelection = enableQueryParams ? sampleSetSelectionViaUrl : sampleSetSelectionNonUrl;
34
+ const setSampleSetSelection = enableQueryParams ? setSampleSetSelectionViaUrl : setSampleSetSelectionNonUrl;
35
+ if (Array.isArray(sampleSetSelection) && sampleSetSelection.length > 2) {
36
+ throw new Error('groups query param array can have at most two entries.');
37
+ }
38
+ return (_jsxs("div", { children: [_jsx(BiomarkerSelect, { datasetUrl: datasetUrl, geneSelection: geneSelection, setGeneSelection: setGeneSelection, sampleSetSelection: sampleSetSelection, setSampleSetSelection: setSampleSetSelection }), _jsx(ControlledComparative, { datasetUrl: datasetUrl, geneSelection: geneSelection, setGeneSelection: setGeneSelection, sampleSetSelection: sampleSetSelection, setSampleSetSelection: setSampleSetSelection })] }));
39
+ }
40
+ /**
41
+ * The UncontrolledComparative component is a Provider component
42
+ * that wraps the UncontrolledComparativeInner component.
43
+ * See the UncontrolledComparativeInner component documentation
44
+ * for details on the props (all props are simply passed through).
45
+ * @param {*} props
46
+ * @returns
47
+ */
48
+ export function UncontrolledComparative(props) {
49
+ return (_jsx(NuqsAdapter, { children: _jsx(UncontrolledComparativeInner, { ...props }) }));
50
+ }
@@ -0,0 +1,7 @@
1
+ export * from "@vitessce/constants";
2
+ export * from "@vitessce/config";
3
+ export * from "@vitessce/all";
4
+ export * from "./ControlledComparative.jsx";
5
+ export * from "./UncontrolledComparative.jsx";
6
+ export { encodeConfInUrl, decodeURLParamsToConf } from "@vitessce/export-utils";
7
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.js"],"names":[],"mappings":""}
@@ -0,0 +1,14 @@
1
+ // Copied from packages/main/prod/src/index.js
2
+ // @ts-check
3
+ // eslint-disable-next-line react-refresh/only-export-components
4
+ export * from '@vitessce/constants';
5
+ // eslint-disable-next-line react-refresh/only-export-components
6
+ export * from '@vitessce/config';
7
+ // eslint-disable-next-line react-refresh/only-export-components
8
+ export * from '@vitessce/all';
9
+ export { encodeConfInUrl, decodeURLParamsToConf, } from '@vitessce/export-utils';
10
+ // Comparative-specific exports below
11
+ // eslint-disable-next-line react-refresh/only-export-components
12
+ export * from './ControlledComparative.jsx';
13
+ // eslint-disable-next-line react-refresh/only-export-components
14
+ export * from './UncontrolledComparative.jsx';