@genspectrum/dashboard-components 0.4.5 → 0.5.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.
Files changed (50) hide show
  1. package/README.md +2 -2
  2. package/custom-elements.json +178 -102
  3. package/dist/dashboard-components.js +318 -147
  4. package/dist/dashboard-components.js.map +1 -1
  5. package/dist/genspectrum-components.d.ts +91 -55
  6. package/dist/style.css +34 -7
  7. package/package.json +5 -5
  8. package/src/preact/mutationComparison/mutation-comparison-venn.tsx +1 -1
  9. package/src/preact/mutationComparison/mutation-comparison.stories.tsx +18 -18
  10. package/src/preact/mutationComparison/mutation-comparison.tsx +6 -6
  11. package/src/preact/mutationComparison/queryMutationData.ts +4 -4
  12. package/src/preact/mutations/mutations.stories.tsx +3 -3
  13. package/src/preact/mutations/mutations.tsx +16 -6
  14. package/src/preact/mutations/queryMutations.ts +3 -3
  15. package/src/preact/prevalenceOverTime/__mockData__/{denominatorOneVariant.json → denominatorFilterOneDataset.json} +1 -1
  16. package/src/preact/prevalenceOverTime/__mockData__/{numeratorOneVariant.json → numeratorFilterOneDataset.json} +1 -1
  17. package/src/preact/prevalenceOverTime/prevalence-over-time-bar-chart.tsx +42 -5
  18. package/src/preact/prevalenceOverTime/prevalence-over-time-bubble-chart.tsx +26 -7
  19. package/src/preact/prevalenceOverTime/prevalence-over-time-line-chart.tsx +62 -28
  20. package/src/preact/prevalenceOverTime/prevalence-over-time.stories.tsx +26 -16
  21. package/src/preact/prevalenceOverTime/prevalence-over-time.tsx +38 -11
  22. package/src/preact/relativeGrowthAdvantage/relative-growth-advantage-chart.tsx +39 -7
  23. package/src/preact/relativeGrowthAdvantage/relative-growth-advantage.stories.tsx +10 -4
  24. package/src/preact/relativeGrowthAdvantage/relative-growth-advantage.tsx +19 -10
  25. package/src/preact/shared/charts/confideceInterval.ts +7 -2
  26. package/src/preact/shared/charts/getYAxisMax.ts +24 -0
  27. package/src/preact/shared/charts/getYAxisScale.ts +1 -3
  28. package/src/query/queryAggregateData.ts +2 -2
  29. package/src/query/queryInsertions.ts +7 -2
  30. package/src/query/querySubstitutionsOrDeletions.ts +2 -2
  31. package/src/web-components/input/gs-date-range-selector.tsx +1 -1
  32. package/src/web-components/input/gs-location-filter.tsx +1 -1
  33. package/src/web-components/input/gs-mutation-filter.tsx +1 -1
  34. package/src/web-components/input/gs-text-input.tsx +1 -1
  35. package/src/web-components/visualization/gs-aggregate.tsx +2 -2
  36. package/src/web-components/visualization/gs-mutation-comparison.stories.ts +12 -12
  37. package/src/web-components/visualization/gs-mutation-comparison.tsx +18 -19
  38. package/src/web-components/visualization/gs-mutations.stories.ts +4 -4
  39. package/src/web-components/visualization/gs-mutations.tsx +10 -11
  40. package/src/web-components/visualization/gs-prevalence-over-time.stories.ts +46 -35
  41. package/src/web-components/visualization/gs-prevalence-over-time.tsx +54 -20
  42. package/src/web-components/visualization/gs-relative-growth-advantage.stories.ts +32 -18
  43. package/src/web-components/visualization/gs-relative-growth-advantage.tsx +51 -13
  44. /package/src/preact/mutationComparison/__mockData__/{nucleotideMutationsOtherVariant.json → nucleotideMutationsOtherDataset.json} +0 -0
  45. /package/src/preact/mutationComparison/__mockData__/{nucleotideMutationsSomeVariant.json → nucleotideMutationsSomeDataset.json} +0 -0
  46. /package/src/preact/prevalenceOverTime/__mockData__/{denominator.json → denominatorFilter.json} +0 -0
  47. /package/src/preact/prevalenceOverTime/__mockData__/{numeratorEG.json → numeratorFilterEG.json} +0 -0
  48. /package/src/preact/prevalenceOverTime/__mockData__/{numeratorJN1.json → numeratorFilterJN1.json} +0 -0
  49. /package/src/preact/relativeGrowthAdvantage/__mockData__/{denominator.json → denominatorFilter.json} +0 -0
  50. /package/src/preact/relativeGrowthAdvantage/__mockData__/{numerator.json → numeratorFilter.json} +0 -0
@@ -3,30 +3,33 @@ import { html } from 'lit';
3
3
 
4
4
  import './gs-relative-growth-advantage';
5
5
  import '../app';
6
+ // eslint-disable-next-line no-duplicate-imports
7
+ import { type RelativeGrowthAdvantageComponentProps } from './gs-relative-growth-advantage';
6
8
  import { withComponentDocs } from '../../../.storybook/ComponentDocsBlock';
7
9
  import { AGGREGATED_ENDPOINT, LAPIS_URL } from '../../constants';
8
- import denominator from '../../preact/relativeGrowthAdvantage/__mockData__/denominator.json';
9
- import numerator from '../../preact/relativeGrowthAdvantage/__mockData__/numerator.json';
10
- import { type RelativeGrowthAdvantageProps } from '../../preact/relativeGrowthAdvantage/relative-growth-advantage';
10
+ import denominatorFilter from '../../preact/relativeGrowthAdvantage/__mockData__/denominatorFilter.json';
11
+ import numeratorFilter from '../../preact/relativeGrowthAdvantage/__mockData__/numeratorFilter.json';
11
12
 
12
13
  const codeExample = String.raw`
13
14
  <gs-relative-growth-advantage
14
- numerator='{ "country": "Switzerland", "pangoLineage": "B.1.1.7", "dateFrom": "2020-12-01" }'
15
- denominator='{ "country": "Switzerland", "dateFrom": "2020-12-01" }'
15
+ numeratorFilter='{ "country": "Switzerland", "pangoLineage": "B.1.1.7", "dateFrom": "2020-12-01" }'
16
+ denominatorFilter='{ "country": "Switzerland", "dateFrom": "2020-12-01" }'
16
17
  generationTime="7"
17
18
  views='["line"]'
18
19
  width='100%'
19
20
  height='700px'
20
21
  headline="Relative growth advantage"
21
22
  lapisDateField="date"
23
+ yAxisMaxLinear="1"
24
+ yAxisMaxLogarithmic="limitTo1"
22
25
  ></gs-relative-growth-advantage>`;
23
26
 
24
- const meta: Meta<RelativeGrowthAdvantageProps> = {
27
+ const meta: Meta<RelativeGrowthAdvantageComponentProps> = {
25
28
  title: 'Visualization/Relative growth advantage',
26
29
  component: 'gs-relative-growth-advantage',
27
30
  argTypes: {
28
- numerator: { control: 'object' },
29
- denominator: { control: 'object' },
31
+ numeratorFilter: { control: 'object' },
32
+ denominatorFilter: { control: 'object' },
30
33
  generationTime: { control: 'number' },
31
34
  views: {
32
35
  options: ['line'],
@@ -35,6 +38,8 @@ const meta: Meta<RelativeGrowthAdvantageProps> = {
35
38
  width: { control: 'text' },
36
39
  height: { control: 'text' },
37
40
  headline: { control: 'text' },
41
+ yAxisMaxLinear: { control: 'object' },
42
+ yAxisMaxLogarithmic: { control: 'object' },
38
43
  },
39
44
  parameters: withComponentDocs({
40
45
  componentDocs: {
@@ -48,41 +53,50 @@ const meta: Meta<RelativeGrowthAdvantageProps> = {
48
53
 
49
54
  export default meta;
50
55
 
51
- const Template: StoryObj<Required<RelativeGrowthAdvantageProps>> = {
56
+ const Template: StoryObj<Required<RelativeGrowthAdvantageComponentProps>> = {
52
57
  render: (args) => html`
53
58
  <gs-app lapis="${LAPIS_URL}">
54
59
  <gs-relative-growth-advantage
55
- .numerator=${args.numerator}
56
- .denominator=${args.denominator}
60
+ .numeratorFilter=${args.numeratorFilter}
61
+ .denominatorFilter=${args.denominatorFilter}
57
62
  .generationTime=${args.generationTime}
58
63
  .views=${args.views}
59
64
  .width=${args.width}
60
65
  .height=${args.height}
61
66
  .headline=${args.headline}
62
67
  .lapisDateField=${args.lapisDateField}
68
+ .yAxisMaxLinear=${args.yAxisMaxLinear}
69
+ .yAxisMaxLogarithmic=${args.yAxisMaxLogarithmic}
63
70
  ></gs-relative-growth-advantage>
64
71
  </gs-app>
65
72
  `,
66
73
  };
67
74
 
68
- export const Default: StoryObj<Required<RelativeGrowthAdvantageProps>> = {
75
+ export const Default: StoryObj<Required<RelativeGrowthAdvantageComponentProps>> = {
69
76
  ...Template,
70
77
  args: {
71
- numerator: { country: 'Switzerland', pangoLineage: 'B.1.1.7', dateFrom: '2020-12-01', dateTo: '2021-03-01' },
72
- denominator: { country: 'Switzerland', dateFrom: '2020-12-01', dateTo: '2021-03-01' },
78
+ numeratorFilter: {
79
+ country: 'Switzerland',
80
+ pangoLineage: 'B.1.1.7',
81
+ dateFrom: '2020-12-01',
82
+ dateTo: '2021-03-01',
83
+ },
84
+ denominatorFilter: { country: 'Switzerland', dateFrom: '2020-12-01', dateTo: '2021-03-01' },
73
85
  generationTime: 7,
74
86
  views: ['line'],
75
87
  width: '100%',
76
88
  height: '700px',
77
89
  headline: 'Relative growth advantage',
78
90
  lapisDateField: 'date',
91
+ yAxisMaxLinear: 1,
92
+ yAxisMaxLogarithmic: 'limitTo1',
79
93
  },
80
94
  parameters: {
81
95
  fetchMock: {
82
96
  mocks: [
83
97
  {
84
98
  matcher: {
85
- name: 'numerator',
99
+ name: 'numeratorFilter',
86
100
  url: AGGREGATED_ENDPOINT,
87
101
  body: {
88
102
  country: 'Switzerland',
@@ -94,12 +108,12 @@ export const Default: StoryObj<Required<RelativeGrowthAdvantageProps>> = {
94
108
  },
95
109
  response: {
96
110
  status: 200,
97
- body: numerator,
111
+ body: numeratorFilter,
98
112
  },
99
113
  },
100
114
  {
101
115
  matcher: {
102
- name: 'denominator',
116
+ name: 'denominatorFilter',
103
117
  url: AGGREGATED_ENDPOINT,
104
118
  body: {
105
119
  country: 'Switzerland',
@@ -110,7 +124,7 @@ export const Default: StoryObj<Required<RelativeGrowthAdvantageProps>> = {
110
124
  },
111
125
  response: {
112
126
  status: 200,
113
- body: denominator,
127
+ body: denominatorFilter,
114
128
  },
115
129
  },
116
130
  ],
@@ -1,6 +1,11 @@
1
1
  import { customElement, property } from 'lit/decorators.js';
2
2
 
3
- import { RelativeGrowthAdvantage, type View } from '../../preact/relativeGrowthAdvantage/relative-growth-advantage';
3
+ import {
4
+ RelativeGrowthAdvantage,
5
+ type RelativeGrowthAdvantageProps,
6
+ type View,
7
+ } from '../../preact/relativeGrowthAdvantage/relative-growth-advantage';
8
+ import { type AxisMax } from '../../preact/shared/charts/getYAxisMax';
4
9
  import type { LapisFilter } from '../../types';
5
10
  import { type Equals, type Expect } from '../../utils/typeAssertions';
6
11
  import { PreactLitAdapter } from '../PreactLitAdapter';
@@ -11,7 +16,7 @@ import { PreactLitAdapter } from '../PreactLitAdapter';
11
16
  * For this component, we assume a discrete time model, where new infections happen exactly every `generationTime` days.
12
17
  * This is what we call a "generation".
13
18
  *
14
- * This component estimates the relative growth advantage of a variant by performing a logistic regression.
19
+ * This component estimates the relative growth advantage of a variant (defined by its LAPIS filter) by performing a logistic regression.
15
20
  * Based on the inferred logistic growth rate, we derive the relative growth advantage (per generation).
16
21
  *
17
22
  * For details on the scientific method, see:
@@ -27,7 +32,7 @@ import { PreactLitAdapter } from '../PreactLitAdapter';
27
32
  * ### Line View
28
33
  *
29
34
  * The line view shows the relative growth advantage over time in a line chart.
30
- * The dots in the plot show the proportions of the focal variant (`numerator`) to the `denominator` variant
35
+ * The dots in the plot show the proportions of the focal variant (defined by the `numeratorFilter`) to the baseline variant (defined by the `denominatorFilter`)
31
36
  * for every day as observed in the data.
32
37
  * The line shows a logistic curve fitted to the data points, including a 95% confidence interval.
33
38
  */
@@ -36,18 +41,20 @@ export class RelativeGrowthAdvantageComponent extends PreactLitAdapter {
36
41
  /**
37
42
  * Required.
38
43
  *
39
- * The LAPIS filter for the focal variant.
44
+ * LAPIS filter to select the data of the focal variant.
45
+ * It must be a valid LAPIS filter object.
40
46
  */
41
47
  @property({ type: Object })
42
- numerator: Record<string, string | number | null | boolean> = {};
48
+ numeratorFilter: Record<string, string | number | null | boolean> = {};
43
49
 
44
50
  /**
45
51
  * Required.
46
52
  *
47
- * The LAPIS filter for the variant that the focal variant (`numerator`) should be compared to.
53
+ * LAPIS filter to select the data of the baseline variant.
54
+ * It must be a valid LAPIS filter object.
48
55
  */
49
56
  @property({ type: Object })
50
- denominator: Record<string, string | number | null | boolean> = {};
57
+ denominatorFilter: Record<string, string | number | null | boolean> = {};
51
58
 
52
59
  /**
53
60
  * The generation time represents the number of days over which the variant's relative growth advantage is measured.
@@ -71,7 +78,7 @@ export class RelativeGrowthAdvantageComponent extends PreactLitAdapter {
71
78
  /**
72
79
  * The width of the component.
73
80
  *
74
- * Visit https://genspectrum.github.io/dashboards/?path=/docs/components-size-of-components--docs for more information.
81
+ * Visit https://genspectrum.github.io/dashboard-components/?path=/docs/components-size-of-components--docs for more information.
75
82
  */
76
83
  @property({ type: String })
77
84
  width: string = '100%';
@@ -79,7 +86,7 @@ export class RelativeGrowthAdvantageComponent extends PreactLitAdapter {
79
86
  /**
80
87
  * The height of the component.
81
88
  *
82
- * Visit https://genspectrum.github.io/dashboards/?path=/docs/components-size-of-components--docs for more information.
89
+ * Visit https://genspectrum.github.io/dashboard-components/?path=/docs/components-size-of-components--docs for more information.
83
90
  */
84
91
  @property({ type: String })
85
92
  height: string = '700px';
@@ -94,22 +101,51 @@ export class RelativeGrowthAdvantageComponent extends PreactLitAdapter {
94
101
  @property({ type: String })
95
102
  lapisDateField: string = 'date';
96
103
 
104
+ /**
105
+ * The maximum value for the y-axis on all graphs in linear view.
106
+ * If set to a number, the maximum value is set to this number.
107
+ * If set to `maxInData`, the maximum value is set to the maximum value in the data.
108
+ * If set to `limitTo1`, the maximum value is set to `min(1, the maximum value in the data)`.
109
+ * If not set, the maximum value is set to the default value (1).
110
+ */
111
+ @property({ type: String })
112
+ yAxisMaxLinear: 'maxInData' | 'limitTo1' | number = 1;
113
+
114
+ /**
115
+ * The maximum value for the y-axis on all graphs in logarithmic view.
116
+ * If set to a number, the maximum value is set to this number.
117
+ * If set to `maxInData`, the maximum value is set to the maximum value in the data.
118
+ * If set to `limitTo1`, the maximum value is set to `min(1, the maximum value in the data)`.
119
+ * If not set, the maximum value is set to the default value (1).
120
+ */
121
+ @property({ type: String })
122
+ yAxisMaxLogarithmic: 'maxInData' | 'limitTo1' | number = 1;
123
+
97
124
  override render() {
98
125
  return (
99
126
  <RelativeGrowthAdvantage
100
- numerator={this.numerator}
101
- denominator={this.denominator}
127
+ numeratorFilter={this.numeratorFilter}
128
+ denominatorFilter={this.denominatorFilter}
102
129
  generationTime={this.generationTime}
103
130
  views={this.views}
104
131
  width={this.width}
105
132
  height={this.height}
106
133
  headline={this.headline}
107
134
  lapisDateField={this.lapisDateField}
135
+ yAxisMaxConfig={{
136
+ linear: this.yAxisMaxLinear,
137
+ logarithmic: this.yAxisMaxLogarithmic,
138
+ }}
108
139
  />
109
140
  );
110
141
  }
111
142
  }
112
143
 
144
+ export interface RelativeGrowthAdvantageComponentProps extends Omit<RelativeGrowthAdvantageProps, 'yAxisMaxConfig'> {
145
+ yAxisMaxLinear?: AxisMax;
146
+ yAxisMaxLogarithmic?: AxisMax;
147
+ }
148
+
113
149
  declare global {
114
150
  interface HTMLElementTagNameMap {
115
151
  'gs-relative-growth-advantage': RelativeGrowthAdvantageComponent;
@@ -117,7 +153,9 @@ declare global {
117
153
  }
118
154
 
119
155
  /* eslint-disable @typescript-eslint/no-unused-vars, no-unused-vars */
120
- type NumeratorMatches = Expect<Equals<typeof RelativeGrowthAdvantageComponent.prototype.numerator, LapisFilter>>;
121
- type DenominatorMatches = Expect<Equals<typeof RelativeGrowthAdvantageComponent.prototype.denominator, LapisFilter>>;
156
+ type NumeratorMatches = Expect<Equals<typeof RelativeGrowthAdvantageComponent.prototype.numeratorFilter, LapisFilter>>;
157
+ type DenominatorMatches = Expect<
158
+ Equals<typeof RelativeGrowthAdvantageComponent.prototype.denominatorFilter, LapisFilter>
159
+ >;
122
160
  type ViewsMatches = Expect<Equals<typeof RelativeGrowthAdvantageComponent.prototype.views, View[]>>;
123
161
  /* eslint-enable @typescript-eslint/no-unused-vars, no-unused-vars */