@genspectrum/dashboard-components 0.11.5 → 0.11.7
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/custom-elements.json +92 -6
- package/dist/assets/{mutationOverTimeWorker-CWneD7i5.js.map → mutationOverTimeWorker-DTv93Ere.js.map} +1 -1
- package/dist/components.d.ts +67 -19
- package/dist/components.js +301 -90
- package/dist/components.js.map +1 -1
- package/dist/style.css +3 -0
- package/dist/util.d.ts +53 -22
- package/package.json +1 -1
- package/src/preact/aggregatedData/__mockData__/aggregatedWith1Field.json +399 -0
- package/src/preact/aggregatedData/__mockData__/aggregatedWith2Fields.json +1771 -0
- package/src/preact/aggregatedData/aggregate-bar-chart.tsx +177 -0
- package/src/preact/aggregatedData/aggregate-table.tsx +24 -2
- package/src/preact/aggregatedData/aggregate.stories.tsx +61 -2
- package/src/preact/aggregatedData/aggregate.tsx +18 -6
- package/src/preact/mutations/__mockData__/baselineNucleotideMutations.json +337412 -0
- package/src/preact/mutations/__mockData__/overallVariantCount.json +14 -0
- package/src/preact/mutations/getMutationsTableData.spec.ts +20 -3
- package/src/preact/mutations/getMutationsTableData.ts +37 -2
- package/src/preact/mutations/mutations-table.tsx +47 -27
- package/src/preact/mutations/mutations.stories.tsx +41 -9
- package/src/preact/mutations/mutations.tsx +22 -6
- package/src/preact/mutations/queryMutations.ts +28 -8
- package/src/preact/mutationsOverTime/__mockData__/aminoAcidMutationsByDay.ts +11077 -3062
- package/src/preact/mutationsOverTime/__mockData__/byWeek.ts +3883 -6606
- package/src/preact/mutationsOverTime/__mockData__/defaultMockData.ts +17624 -2203
- package/src/preact/mutationsOverTime/mutations-over-time-grid.tsx +1 -1
- package/src/preact/mutationsOverTime/mutations-over-time.tsx +1 -1
- package/src/preact/shared/charts/colors.ts +1 -1
- package/src/query/queryAggregateData.spec.ts +16 -109
- package/src/query/queryAggregateData.ts +2 -12
- package/src/query/queryGeneralStatistics.ts +2 -2
- package/src/query/queryMutationsOverTime.spec.ts +144 -4
- package/src/query/queryMutationsOverTime.ts +17 -1
- package/src/web-components/visualization/gs-aggregate.stories.ts +90 -20
- package/src/web-components/visualization/gs-aggregate.tsx +20 -0
- package/src/web-components/visualization/gs-mutations.stories.ts +62 -4
- package/src/web-components/visualization/gs-mutations.tsx +44 -0
- package/standalone-bundle/assets/{mutationOverTimeWorker-x1ipPFL0.js.map → mutationOverTimeWorker-DEybsZ5r.js.map} +1 -1
- package/standalone-bundle/dashboard-components.js +4136 -3956
- package/standalone-bundle/dashboard-components.js.map +1 -1
- package/standalone-bundle/style.css +1 -1
|
@@ -2,18 +2,27 @@ import { expect, fireEvent, waitFor } from '@storybook/test';
|
|
|
2
2
|
import type { Meta, StoryObj } from '@storybook/web-components';
|
|
3
3
|
import { html } from 'lit';
|
|
4
4
|
|
|
5
|
-
import './gs-mutations';
|
|
6
|
-
import '../app';
|
|
7
5
|
import { withComponentDocs } from '../../../.storybook/ComponentDocsBlock';
|
|
8
|
-
import {
|
|
6
|
+
import {
|
|
7
|
+
AGGREGATED_ENDPOINT,
|
|
8
|
+
LAPIS_URL,
|
|
9
|
+
NUCLEOTIDE_INSERTIONS_ENDPOINT,
|
|
10
|
+
NUCLEOTIDE_MUTATIONS_ENDPOINT,
|
|
11
|
+
} from '../../constants';
|
|
12
|
+
import baselineNucleotideMutations from '../../preact/mutations/__mockData__/baselineNucleotideMutations.json';
|
|
9
13
|
import nucleotideInsertions from '../../preact/mutations/__mockData__/nucleotideInsertions.json';
|
|
10
14
|
import nucleotideMutations from '../../preact/mutations/__mockData__/nucleotideMutations.json';
|
|
15
|
+
import overallVariantCount from '../../preact/mutations/__mockData__/overallVariantCount.json';
|
|
11
16
|
import { type MutationsProps } from '../../preact/mutations/mutations';
|
|
12
17
|
import { withinShadowRoot } from '../withinShadowRoot.story';
|
|
13
18
|
|
|
19
|
+
import './gs-mutations';
|
|
20
|
+
import '../app';
|
|
21
|
+
|
|
14
22
|
const codeExample = String.raw`
|
|
15
23
|
<gs-mutations
|
|
16
|
-
lapisFilter='{ "country": "Switzerland", "pangoLineage": "B.1.1.7"
|
|
24
|
+
lapisFilter='{ "country": "Switzerland", "dateTo": "2022-01-01", "pangoLineage": "B.1.1.7"}'
|
|
25
|
+
baselineLapisFilter='{ "country": "Switzerland", "dateTo": "2022-01-01" }'
|
|
17
26
|
sequenceType="nucleotide"
|
|
18
27
|
views='["grid", "table", "insertions"]'
|
|
19
28
|
width='100%'
|
|
@@ -26,6 +35,7 @@ const meta: Meta<Required<MutationsProps>> = {
|
|
|
26
35
|
component: 'gs-mutations',
|
|
27
36
|
argTypes: {
|
|
28
37
|
lapisFilter: { control: 'object' },
|
|
38
|
+
baselineLapisFilter: { control: 'object' },
|
|
29
39
|
sequenceType: {
|
|
30
40
|
options: ['nucleotide', 'amino acid'],
|
|
31
41
|
control: { type: 'radio' },
|
|
@@ -40,6 +50,7 @@ const meta: Meta<Required<MutationsProps>> = {
|
|
|
40
50
|
},
|
|
41
51
|
args: {
|
|
42
52
|
lapisFilter: { country: 'Switzerland', pangoLineage: 'B.1.1.7', dateTo: '2022-01-01' },
|
|
53
|
+
baselineLapisFilter: { country: 'Switzerland', dateTo: '2022-01-01' },
|
|
43
54
|
sequenceType: 'nucleotide',
|
|
44
55
|
views: ['grid', 'table', 'insertions'],
|
|
45
56
|
width: '100%',
|
|
@@ -63,6 +74,7 @@ const Template: StoryObj<Required<MutationsProps>> = {
|
|
|
63
74
|
<gs-app lapis="${LAPIS_URL}">
|
|
64
75
|
<gs-mutations
|
|
65
76
|
.lapisFilter=${args.lapisFilter}
|
|
77
|
+
.baselineLapisFilter=${args.baselineLapisFilter}
|
|
66
78
|
.sequenceType=${args.sequenceType}
|
|
67
79
|
.views=${args.views}
|
|
68
80
|
.width=${args.width}
|
|
@@ -94,6 +106,37 @@ export const Default: StoryObj<Required<MutationsProps>> = {
|
|
|
94
106
|
body: nucleotideMutations,
|
|
95
107
|
},
|
|
96
108
|
},
|
|
109
|
+
{
|
|
110
|
+
matcher: {
|
|
111
|
+
name: 'baselineNucleotideMutations',
|
|
112
|
+
url: NUCLEOTIDE_MUTATIONS_ENDPOINT,
|
|
113
|
+
body: {
|
|
114
|
+
country: 'Switzerland',
|
|
115
|
+
dateTo: '2022-01-01',
|
|
116
|
+
minProportion: 0,
|
|
117
|
+
},
|
|
118
|
+
},
|
|
119
|
+
response: {
|
|
120
|
+
status: 200,
|
|
121
|
+
body: baselineNucleotideMutations,
|
|
122
|
+
},
|
|
123
|
+
},
|
|
124
|
+
{
|
|
125
|
+
matcher: {
|
|
126
|
+
name: 'overallVariantCount',
|
|
127
|
+
url: AGGREGATED_ENDPOINT,
|
|
128
|
+
body: {
|
|
129
|
+
country: 'Switzerland',
|
|
130
|
+
pangoLineage: 'B.1.1.7',
|
|
131
|
+
dateTo: '2022-01-01',
|
|
132
|
+
fields: [],
|
|
133
|
+
},
|
|
134
|
+
},
|
|
135
|
+
response: {
|
|
136
|
+
status: 200,
|
|
137
|
+
body: overallVariantCount,
|
|
138
|
+
},
|
|
139
|
+
},
|
|
97
140
|
{
|
|
98
141
|
matcher: {
|
|
99
142
|
name: 'nucleotideInsertions',
|
|
@@ -121,6 +164,21 @@ export const OnTableTab: StoryObj<Required<MutationsProps>> = {
|
|
|
121
164
|
},
|
|
122
165
|
};
|
|
123
166
|
|
|
167
|
+
export const OnTableTabWithoutJaccardSimilarity: StoryObj<Required<MutationsProps>> = {
|
|
168
|
+
...Default,
|
|
169
|
+
args: {
|
|
170
|
+
...Default.args,
|
|
171
|
+
baselineLapisFilter: undefined,
|
|
172
|
+
},
|
|
173
|
+
play: async ({ canvasElement }) => {
|
|
174
|
+
const canvas = await withinShadowRoot(canvasElement, 'gs-mutations');
|
|
175
|
+
|
|
176
|
+
await waitFor(() => expect(canvas.getByRole('button', { name: 'Table' })).toBeInTheDocument());
|
|
177
|
+
|
|
178
|
+
await fireEvent.click(canvas.getByRole('button', { name: 'Table' }));
|
|
179
|
+
},
|
|
180
|
+
};
|
|
181
|
+
|
|
124
182
|
export const OnInsertionsTab: StoryObj<Required<MutationsProps>> = {
|
|
125
183
|
...Default,
|
|
126
184
|
play: async ({ canvasElement }) => {
|
|
@@ -22,6 +22,29 @@ import { PreactLitAdapterWithGridJsStyles } from '../PreactLitAdapterWithGridJsS
|
|
|
22
22
|
*
|
|
23
23
|
* The proportion interval filter can be used to filter the displayed mutations on client side.
|
|
24
24
|
*
|
|
25
|
+
* #### Jaccard Similarity
|
|
26
|
+
*
|
|
27
|
+
* If the `baselineLapisFilter` attribute is set,
|
|
28
|
+
* the [Jaccard similarity](https://en.wikipedia.org/wiki/Jaccard_index) is computed for each mutation.
|
|
29
|
+
* It is computed as `variantWithMutationCount / (variantCount + mutationCount - variantWithMutationCount)`,
|
|
30
|
+
* - `variantCount` is the number of sequences of the variant (i.e. the number of sequences that match the `lapisFilter`),
|
|
31
|
+
* - `mutationCount` is the number of sequences with the mutation
|
|
32
|
+
* (i.e. the number of sequences matching the `baselineLapisFilter` that have the mutation),
|
|
33
|
+
* - `variantWithMutationCount` is the number of sequences that belong to the variant and have the mutation
|
|
34
|
+
* (i.e. the `count` value that is shown in the table).
|
|
35
|
+
*
|
|
36
|
+
* Typically, this is useful when you query mutations of a certain "variant"
|
|
37
|
+
* (i.e. a certain lineage or a certain set of mutations).
|
|
38
|
+
* Then the `baselineLapisFilter` should be the `lapisFilter` but without the lineage or mutations.
|
|
39
|
+
*
|
|
40
|
+
* For example:
|
|
41
|
+
* You are interested in a certain lineage in a certain country: `lapisFilter={country: 'Switzerland', linage: 'XY.1.2.3'}`.
|
|
42
|
+
* Then the "baseline" should be the same filter but without the lineage: `baselineLapisFilter={country: 'Switzerland'}`.
|
|
43
|
+
*
|
|
44
|
+
* Computing the Jaccard similarity is not always meaningful, because you might not have a "variant"
|
|
45
|
+
* (e.g. when you only query for a certain country).
|
|
46
|
+
* In this case you can simply omit the `baselineLapisFilter`.
|
|
47
|
+
*
|
|
25
48
|
* ### Grid View
|
|
26
49
|
*
|
|
27
50
|
* The grid view shows the proportion of each sequence symbol (nucleotide or amino acid) for each position that has a mutation.
|
|
@@ -45,6 +68,23 @@ export class MutationsComponent extends PreactLitAdapterWithGridJsStyles {
|
|
|
45
68
|
aminoAcidInsertions?: string[];
|
|
46
69
|
} = {};
|
|
47
70
|
|
|
71
|
+
// prettier-ignore
|
|
72
|
+
// The multiline union type must not start with `|` because it looks weird in the Storybook docs
|
|
73
|
+
/**
|
|
74
|
+
* LAPIS filter to select the mutation counts that are used to compute the Jaccard similarity.
|
|
75
|
+
* If not provided, the Jaccard similarity is not computed.
|
|
76
|
+
* For details, see the [Jaccard Similarity](#jaccard-similarity) section in the component description.
|
|
77
|
+
*/
|
|
78
|
+
@property({ type: Object })
|
|
79
|
+
baselineLapisFilter:
|
|
80
|
+
(Record<string, string | string[] | number | null | boolean | undefined> & {
|
|
81
|
+
nucleotideMutations?: string[];
|
|
82
|
+
aminoAcidMutations?: string[];
|
|
83
|
+
nucleotideInsertions?: string[];
|
|
84
|
+
aminoAcidInsertions?: string[];
|
|
85
|
+
})
|
|
86
|
+
| undefined = undefined;
|
|
87
|
+
|
|
48
88
|
/**
|
|
49
89
|
* The type of the sequence for which the mutations should be shown.
|
|
50
90
|
*/
|
|
@@ -89,6 +129,7 @@ export class MutationsComponent extends PreactLitAdapterWithGridJsStyles {
|
|
|
89
129
|
width={this.width}
|
|
90
130
|
height={this.height}
|
|
91
131
|
pageSize={this.pageSize}
|
|
132
|
+
baselineLapisFilter={this.baselineLapisFilter}
|
|
92
133
|
/>
|
|
93
134
|
);
|
|
94
135
|
}
|
|
@@ -113,6 +154,9 @@ declare global {
|
|
|
113
154
|
type LapisFilterMatches = Expect<
|
|
114
155
|
Equals<typeof MutationsComponent.prototype.lapisFilter, MutationsProps['lapisFilter']>
|
|
115
156
|
>;
|
|
157
|
+
type BaselineLapisFilterMatches = Expect<
|
|
158
|
+
Equals<typeof MutationsComponent.prototype.baselineLapisFilter, MutationsProps['baselineLapisFilter']>
|
|
159
|
+
>;
|
|
116
160
|
type SequenceTypeMatches = Expect<
|
|
117
161
|
Equals<typeof MutationsComponent.prototype.sequenceType, MutationsProps['sequenceType']>
|
|
118
162
|
>;
|