@vitessce/comparative 4.1.3 → 4.2.0
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/{GeometryAndMeshXR-CqZrKpgj.js → GeometryAndMeshXR-CYO2tqUV.js} +1 -1
- package/dist/ReactNeuroglancer-pk3hhe45.js +68657 -0
- package/dist/{XREnterButton-CSyePMXM.js → XREnterButton-BdEVWrV7.js} +1 -1
- package/dist/{XRSceneComponents-lFaSg5aj.js → XRSceneComponents-DYeS3CwE.js} +1 -1
- package/dist/{XRWrapper-CVhBuEjL.js → XRWrapper-DbheKuSQ.js} +2 -2
- package/dist/{deflate-BXZYC1-Y.js → deflate-D76idIbp.js} +1 -1
- package/dist/{higlass-DE1ZWzP3.js → higlass-HE5ijNPv.js} +1 -1
- package/dist/{index-BW8y8e2T.js → index-CSfNzXQa.js} +125915 -124333
- package/dist/index-DOITJzp5.js +30089 -0
- package/dist/{index-DzznGedr.js → index-DeGz6Kci.js} +1 -1
- package/dist/{index-BeGaR3Mx.js → index-YJLqH5aL.js} +4 -4
- package/dist/index.min.js +20 -20
- package/dist/{jpeg-sFJJnIsn.js → jpeg-CtV9axAi.js} +1 -1
- package/dist/{lerc-BtLFACSi.js → lerc-C2iyBV3P.js} +1 -1
- package/dist/{lzw-_ihEMKTy.js → lzw-BDK3wuTu.js} +1 -1
- package/dist/{packbits-CJ9ZtM9C.js → packbits-BmhmFJpE.js} +1 -1
- package/dist/{raw-FSjtk0dS.js → raw-AV6N1HZT.js} +1 -1
- package/dist/{webimage-BmQdgUV0.js → webimage-D8fd9G2X.js} +1 -1
- package/dist/{xrStore-C-wbuI_U.js → xrStore-B_SjnbWm.js} +1 -1
- package/dist-tsc/BiomarkerSelect.d.ts +19 -1
- package/dist-tsc/BiomarkerSelect.d.ts.map +1 -1
- package/dist-tsc/BiomarkerSelect.js +46 -39
- package/dist-tsc/BiomarkerSelect.js.map +1 -1
- package/dist-tsc/ComparativeConfig.d.ts +112 -3
- package/dist-tsc/ComparativeConfig.d.ts.map +1 -1
- package/dist-tsc/ComparativeConfig.js +255 -13
- package/dist-tsc/ComparativeConfig.js.map +1 -1
- package/dist-tsc/ComparativeConfig.test.d.ts +2 -0
- package/dist-tsc/ComparativeConfig.test.d.ts.map +1 -0
- package/dist-tsc/ComparativeConfig.test.js +119 -0
- package/dist-tsc/ComparativeConfig.test.js.map +1 -0
- package/dist-tsc/ControlledComparative.d.ts +13 -3
- package/dist-tsc/ControlledComparative.d.ts.map +1 -1
- package/dist-tsc/ControlledComparative.js +32 -14
- package/dist-tsc/ControlledComparative.js.map +1 -1
- package/dist-tsc/UncontrolledComparative.d.ts.map +1 -1
- package/dist-tsc/UncontrolledComparative.js +39 -12
- package/dist-tsc/UncontrolledComparative.js.map +1 -1
- package/dist-tsc/url-params.d.ts +24 -0
- package/dist-tsc/url-params.d.ts.map +1 -0
- package/dist-tsc/url-params.js +32 -0
- package/dist-tsc/url-params.js.map +1 -0
- package/dist-tsc/url-params.test.d.ts +2 -0
- package/dist-tsc/url-params.test.d.ts.map +1 -0
- package/dist-tsc/url-params.test.js +18 -0
- package/dist-tsc/url-params.test.js.map +1 -0
- package/package.json +15 -13
- package/src/BiomarkerSelect.jsx +70 -45
- package/src/ComparativeConfig.jsx +295 -13
- package/src/ComparativeConfig.test.jsx +151 -0
- package/src/ControlledComparative.jsx +47 -13
- package/src/UncontrolledComparative.jsx +62 -16
- package/src/url-params.js +34 -0
- package/src/url-params.test.js +20 -0
- package/dist/ReactNeuroglancer-CsYUFP61.js +0 -43672
|
@@ -1,49 +1,87 @@
|
|
|
1
1
|
/* eslint-disable max-len */
|
|
2
2
|
/* eslint-disable react-refresh/only-export-components */
|
|
3
|
-
import React, { useState } from 'react';
|
|
3
|
+
import React, { useState, useCallback } from 'react';
|
|
4
4
|
// eslint-disable-next-line import/no-unresolved
|
|
5
5
|
import { NuqsAdapter } from 'nuqs/adapters/react';
|
|
6
|
-
import {
|
|
6
|
+
import {
|
|
7
|
+
useQueryState, parseAsString, parseAsArrayOf, parseAsStringLiteral,
|
|
8
|
+
} from 'nuqs';
|
|
7
9
|
import { ControlledComparative } from './ControlledComparative.jsx';
|
|
8
10
|
import { BiomarkerSelect } from './BiomarkerSelect.jsx';
|
|
11
|
+
import { COMPARATIVE_MODALITIES } from './ComparativeConfig.jsx';
|
|
12
|
+
import { parseAsBiomarker } from './url-params.js';
|
|
13
|
+
|
|
14
|
+
const MODALITY_UIDS = COMPARATIVE_MODALITIES.map(m => m.uid);
|
|
9
15
|
|
|
10
16
|
/**
|
|
11
17
|
* The UncontrolledComparative component is a wrapper
|
|
12
18
|
* around the ControlledComparative and BiomarkerSelect components.
|
|
13
19
|
* @param {object} props
|
|
14
|
-
*
|
|
15
|
-
*
|
|
20
|
+
* At least one of singleCellDatasetUrl or singleNucleusDatasetUrl must be provided.
|
|
21
|
+
* When both are provided, the user can switch between modalities.
|
|
22
|
+
* @param {string} [props.singleCellDatasetUrl] URL of the single-cell
|
|
23
|
+
* dataset to load, which should point to the root of an anndata-zarr store,
|
|
24
|
+
* containing comparative metadata.
|
|
25
|
+
* @param {string} [props.singleNucleusDatasetUrl] URL of the single-nucleus
|
|
26
|
+
* dataset to load, which should point to the root of an anndata-zarr store,
|
|
16
27
|
* containing comparative metadata.
|
|
17
28
|
* @param {boolean} props.enableQueryParams Whether to
|
|
18
|
-
* sync state to the URL query parameters for gene
|
|
19
|
-
* sample set selection. By default, true.
|
|
29
|
+
* sync state to the URL query parameters for feature (e.g., gene or pathway),
|
|
30
|
+
* sample set, and modality selection. By default, true.
|
|
31
|
+
* The `feature` URL param is formatted like `nodeType:label`,
|
|
32
|
+
* e.g., `?feature=gene:UMOD` or `?feature=pathway:Cell Cycle R-HSA-1640170`.
|
|
20
33
|
* @returns {JSX.Element}
|
|
21
34
|
*/
|
|
22
35
|
function UncontrolledComparativeInner(props) {
|
|
23
36
|
const {
|
|
24
|
-
|
|
37
|
+
singleCellDatasetUrl,
|
|
38
|
+
singleNucleusDatasetUrl,
|
|
25
39
|
enableQueryParams = true,
|
|
26
40
|
} = props;
|
|
27
41
|
|
|
28
|
-
const [
|
|
29
|
-
'
|
|
30
|
-
|
|
42
|
+
const [biomarkerSelectionViaUrl, setBiomarkerSelectionViaUrl] = useQueryState(
|
|
43
|
+
'feature',
|
|
44
|
+
parseAsBiomarker,
|
|
31
45
|
);
|
|
32
46
|
const [sampleSetSelectionViaUrl, setSampleSetSelectionViaUrl] = useQueryState(
|
|
33
47
|
'groups',
|
|
34
48
|
parseAsArrayOf(parseAsArrayOf(parseAsString)),
|
|
35
49
|
);
|
|
50
|
+
const [modalitySelectionViaUrl, setModalitySelectionViaUrl] = useQueryState(
|
|
51
|
+
'modality',
|
|
52
|
+
parseAsStringLiteral(MODALITY_UIDS),
|
|
53
|
+
);
|
|
36
54
|
|
|
37
|
-
const [
|
|
55
|
+
const [biomarkerSelectionNonUrl, setBiomarkerSelectionNonUrl] = useState(null);
|
|
38
56
|
const [sampleSetSelectionNonUrl, setSampleSetSelectionNonUrl] = useState([]);
|
|
57
|
+
const [modalitySelectionNonUrl, setModalitySelectionNonUrl] = useState(null);
|
|
39
58
|
|
|
40
59
|
// Depending on the value of enableQueryParams,
|
|
41
60
|
// we either use the state that is synced to the URL query parameters,
|
|
42
61
|
// or we use local state that is not synced to the URL.
|
|
43
|
-
const
|
|
44
|
-
const
|
|
62
|
+
const biomarkerSelection = enableQueryParams ? biomarkerSelectionViaUrl : biomarkerSelectionNonUrl;
|
|
63
|
+
const setBiomarkerSelection = enableQueryParams ? setBiomarkerSelectionViaUrl : setBiomarkerSelectionNonUrl;
|
|
45
64
|
const sampleSetSelection = enableQueryParams ? sampleSetSelectionViaUrl : sampleSetSelectionNonUrl;
|
|
46
65
|
const setSampleSetSelection = enableQueryParams ? setSampleSetSelectionViaUrl : setSampleSetSelectionNonUrl;
|
|
66
|
+
const selectedModality = enableQueryParams ? modalitySelectionViaUrl : modalitySelectionNonUrl;
|
|
67
|
+
const setSelectedModality = enableQueryParams ? setModalitySelectionViaUrl : setModalitySelectionNonUrl;
|
|
68
|
+
|
|
69
|
+
// The gene selection is not synced to the URL, since it is derived
|
|
70
|
+
// from the biomarker selection (e.g., the member genes of a selected pathway)
|
|
71
|
+
// by the biomarkerSelectAlt view.
|
|
72
|
+
const [geneSelection, setGeneSelection] = useState(null);
|
|
73
|
+
|
|
74
|
+
// When genes are selected from inside the comparative views
|
|
75
|
+
// (e.g., by clicking a point in the volcano plot), update the biomarker selection accordingly.
|
|
76
|
+
const setGeneSelectionFromComparative = useCallback((newGeneSelection) => {
|
|
77
|
+
setGeneSelection(newGeneSelection);
|
|
78
|
+
setBiomarkerSelection(
|
|
79
|
+
Array.isArray(newGeneSelection) && newGeneSelection.length === 1
|
|
80
|
+
? { label: newGeneSelection[0], nodeType: 'gene' }
|
|
81
|
+
// Multiple genes cannot be represented by a single biomarker selection.
|
|
82
|
+
: null,
|
|
83
|
+
);
|
|
84
|
+
}, [setBiomarkerSelection]);
|
|
47
85
|
|
|
48
86
|
if (Array.isArray(sampleSetSelection) && sampleSetSelection.length > 2) {
|
|
49
87
|
throw new Error('groups query param array can have at most two entries.');
|
|
@@ -52,16 +90,24 @@ function UncontrolledComparativeInner(props) {
|
|
|
52
90
|
return (
|
|
53
91
|
<div>
|
|
54
92
|
<BiomarkerSelect
|
|
55
|
-
|
|
93
|
+
singleCellDatasetUrl={singleCellDatasetUrl}
|
|
94
|
+
singleNucleusDatasetUrl={singleNucleusDatasetUrl}
|
|
95
|
+
selectedModality={selectedModality}
|
|
96
|
+
setSelectedModality={setSelectedModality}
|
|
97
|
+
biomarkerSelection={biomarkerSelection}
|
|
98
|
+
setBiomarkerSelection={setBiomarkerSelection}
|
|
56
99
|
geneSelection={geneSelection}
|
|
57
100
|
setGeneSelection={setGeneSelection}
|
|
58
101
|
sampleSetSelection={sampleSetSelection}
|
|
59
102
|
setSampleSetSelection={setSampleSetSelection}
|
|
60
103
|
/>
|
|
61
104
|
<ControlledComparative
|
|
62
|
-
|
|
105
|
+
singleCellDatasetUrl={singleCellDatasetUrl}
|
|
106
|
+
singleNucleusDatasetUrl={singleNucleusDatasetUrl}
|
|
107
|
+
selectedModality={selectedModality}
|
|
108
|
+
setSelectedModality={setSelectedModality}
|
|
63
109
|
geneSelection={geneSelection}
|
|
64
|
-
setGeneSelection={
|
|
110
|
+
setGeneSelection={setGeneSelectionFromComparative}
|
|
65
111
|
sampleSetSelection={sampleSetSelection}
|
|
66
112
|
setSampleSetSelection={setSampleSetSelection}
|
|
67
113
|
/>
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { createParser } from 'nuqs';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Parse the value of the `feature` URL param,
|
|
5
|
+
* formatted like `nodeType:label` (e.g., `gene:UMOD` or `pathway:Cell Cycle R-HSA-1640170`).
|
|
6
|
+
* @param {string} value
|
|
7
|
+
* @returns {{ label: string, nodeType: string } | null}
|
|
8
|
+
*/
|
|
9
|
+
export function parseBiomarkerParam(value) {
|
|
10
|
+
// Split at the first colon, since the label may contain colons.
|
|
11
|
+
const separatorIndex = value.indexOf(':');
|
|
12
|
+
if (separatorIndex <= 0 || separatorIndex === value.length - 1) {
|
|
13
|
+
return null;
|
|
14
|
+
}
|
|
15
|
+
return {
|
|
16
|
+
nodeType: value.slice(0, separatorIndex),
|
|
17
|
+
label: value.slice(separatorIndex + 1),
|
|
18
|
+
};
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* Serialize a biomarker selection to the `feature` URL param format.
|
|
23
|
+
* @param {{ label: string, nodeType: string }} value
|
|
24
|
+
* @returns {string}
|
|
25
|
+
*/
|
|
26
|
+
export function serializeBiomarkerParam(value) {
|
|
27
|
+
return `${value.nodeType}:${value.label}`;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
export const parseAsBiomarker = createParser({
|
|
31
|
+
parse: parseBiomarkerParam,
|
|
32
|
+
serialize: serializeBiomarkerParam,
|
|
33
|
+
eq: (a, b) => a.label === b.label && a.nodeType === b.nodeType,
|
|
34
|
+
});
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { describe, it, expect } from 'vitest';
|
|
2
|
+
import { parseBiomarkerParam, serializeBiomarkerParam } from './url-params.js';
|
|
3
|
+
|
|
4
|
+
describe('feature URL param', () => {
|
|
5
|
+
it('parses and serializes genes and pathways', () => {
|
|
6
|
+
expect(parseBiomarkerParam('gene:UMOD')).toEqual({ nodeType: 'gene', label: 'UMOD' });
|
|
7
|
+
const pathway = { nodeType: 'pathway', label: 'Cell Cycle R-HSA-1640170' };
|
|
8
|
+
expect(parseBiomarkerParam(serializeBiomarkerParam(pathway))).toEqual(pathway);
|
|
9
|
+
});
|
|
10
|
+
|
|
11
|
+
it('splits at the first colon, since labels may contain colons', () => {
|
|
12
|
+
expect(parseBiomarkerParam('pathway:A: B')).toEqual({ nodeType: 'pathway', label: 'A: B' });
|
|
13
|
+
});
|
|
14
|
+
|
|
15
|
+
it('returns null for malformed values', () => {
|
|
16
|
+
expect(parseBiomarkerParam('UMOD')).toBeNull();
|
|
17
|
+
expect(parseBiomarkerParam(':UMOD')).toBeNull();
|
|
18
|
+
expect(parseBiomarkerParam('gene:')).toBeNull();
|
|
19
|
+
});
|
|
20
|
+
});
|