@jbrowse/plugin-variants 4.0.3 → 4.1.1

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 (144) hide show
  1. package/esm/ChordVariantDisplay/models/stateModelFactory.d.ts +9 -0
  2. package/esm/LDDisplay/SharedLDConfigSchema.d.ts +102 -0
  3. package/esm/LDDisplay/SharedLDConfigSchema.js +83 -0
  4. package/esm/LDDisplay/afterAttach.d.ts +2 -0
  5. package/esm/LDDisplay/afterAttach.js +123 -0
  6. package/esm/LDDisplay/components/BaseDisplayComponent.d.ts +15 -0
  7. package/esm/LDDisplay/components/BaseDisplayComponent.js +39 -0
  8. package/esm/LDDisplay/components/LDColorLegend.d.ts +15 -0
  9. package/esm/LDDisplay/components/LDColorLegend.js +75 -0
  10. package/esm/LDDisplay/components/LDDisplayComponent.d.ts +5 -0
  11. package/esm/LDDisplay/components/LDDisplayComponent.js +203 -0
  12. package/esm/LDDisplay/components/LinesConnectingMatrixToGenomicPosition.d.ts +16 -0
  13. package/esm/LDDisplay/components/LinesConnectingMatrixToGenomicPosition.js +109 -0
  14. package/esm/LDDisplay/configSchema1.d.ts +115 -0
  15. package/esm/LDDisplay/configSchema1.js +16 -0
  16. package/esm/LDDisplay/configSchema2.d.ts +115 -0
  17. package/esm/LDDisplay/configSchema2.js +16 -0
  18. package/esm/LDDisplay/index.d.ts +2 -0
  19. package/esm/LDDisplay/index.js +35 -0
  20. package/esm/LDDisplay/renderSvg.d.ts +3 -0
  21. package/esm/LDDisplay/renderSvg.js +36 -0
  22. package/esm/LDDisplay/shared.d.ts +367 -0
  23. package/esm/LDDisplay/shared.js +467 -0
  24. package/esm/LDDisplay/stateModel1.d.ts +365 -0
  25. package/esm/LDDisplay/stateModel1.js +10 -0
  26. package/esm/LDDisplay/stateModel2.d.ts +365 -0
  27. package/esm/LDDisplay/stateModel2.js +10 -0
  28. package/esm/LDRenderer/LDRenderer.d.ts +30 -0
  29. package/esm/LDRenderer/LDRenderer.js +109 -0
  30. package/esm/LDRenderer/components/LDRendering.d.ts +2 -0
  31. package/esm/LDRenderer/components/LDRendering.js +4 -0
  32. package/esm/LDRenderer/configSchema.d.ts +8 -0
  33. package/esm/LDRenderer/configSchema.js +10 -0
  34. package/esm/LDRenderer/index.d.ts +2 -0
  35. package/esm/LDRenderer/index.js +11 -0
  36. package/esm/LDRenderer/makeImageData.d.ts +20 -0
  37. package/esm/LDRenderer/makeImageData.js +158 -0
  38. package/esm/LDRenderer/types.d.ts +8 -0
  39. package/esm/LDRenderer/types.js +1 -0
  40. package/esm/LDTrack/configSchema.d.ts +85 -0
  41. package/esm/LDTrack/configSchema.js +7 -0
  42. package/esm/LDTrack/index.d.ts +2 -0
  43. package/esm/LDTrack/index.js +14 -0
  44. package/esm/LinearVariantDisplay/model.d.ts +139 -42
  45. package/esm/LinearVariantDisplay/model.js +46 -8
  46. package/esm/MultiLinearVariantDisplay/configSchema.d.ts +27 -1
  47. package/esm/MultiLinearVariantDisplay/model.d.ts +2647 -58
  48. package/esm/MultiLinearVariantDisplay/model.js +6 -0
  49. package/esm/MultiLinearVariantDisplay/renderSvg.d.ts +10 -2
  50. package/esm/MultiLinearVariantMatrixDisplay/configSchema.d.ts +25 -0
  51. package/esm/MultiLinearVariantMatrixDisplay/configSchema.js +26 -0
  52. package/esm/MultiLinearVariantMatrixDisplay/model.d.ts +2648 -59
  53. package/esm/MultiLinearVariantMatrixDisplay/model.js +6 -0
  54. package/esm/MultiLinearVariantMatrixRenderer/MultiLinearVariantMatrixRenderer.d.ts +2 -2
  55. package/esm/MultiLinearVariantMatrixRenderer/MultiLinearVariantMatrixRenderer.js +11 -9
  56. package/esm/MultiLinearVariantMatrixRenderer/components/MultiLinearVariantMatrixRendering.d.ts +8 -0
  57. package/esm/MultiLinearVariantMatrixRenderer/components/MultiLinearVariantMatrixRendering.js +14 -2
  58. package/esm/MultiLinearVariantMatrixRenderer/makeImageData.js +14 -8
  59. package/esm/MultiLinearVariantRenderer/MultiVariantRenderer.d.ts +2 -2
  60. package/esm/MultiLinearVariantRenderer/MultiVariantRenderer.js +4 -3
  61. package/esm/MultiLinearVariantRenderer/components/MultiLinearVariantRendering.d.ts +4 -0
  62. package/esm/MultiLinearVariantRenderer/components/MultiLinearVariantRendering.js +23 -2
  63. package/esm/MultiLinearVariantRenderer/makeImageData.js +8 -3
  64. package/esm/PlinkLDAdapter/PlinkLDAdapter.d.ts +25 -0
  65. package/esm/PlinkLDAdapter/PlinkLDAdapter.js +147 -0
  66. package/esm/PlinkLDAdapter/PlinkLDTabixAdapter.d.ts +24 -0
  67. package/esm/PlinkLDAdapter/PlinkLDTabixAdapter.js +156 -0
  68. package/esm/PlinkLDAdapter/configSchema.d.ts +10 -0
  69. package/esm/PlinkLDAdapter/configSchema.js +25 -0
  70. package/esm/PlinkLDAdapter/configSchemaTabix.d.ts +24 -0
  71. package/esm/PlinkLDAdapter/configSchemaTabix.js +46 -0
  72. package/esm/PlinkLDAdapter/index.d.ts +2 -0
  73. package/esm/PlinkLDAdapter/index.js +25 -0
  74. package/esm/PlinkLDAdapter/types.d.ts +29 -0
  75. package/esm/PlinkLDAdapter/types.js +1 -0
  76. package/esm/VariantFeatureWidget/VariantSampleGrid/VariantSampleGrid.js +1 -1
  77. package/esm/VariantRPC/MultiVariantGetFeatureDetails.d.ts +14 -0
  78. package/esm/VariantRPC/MultiVariantGetFeatureDetails.js +15 -0
  79. package/esm/VariantRPC/executeClusterGenotypeMatrix.d.ts +3 -1
  80. package/esm/VariantRPC/executeClusterGenotypeMatrix.js +8 -4
  81. package/esm/VariantRPC/getLDMatrix.d.ts +48 -0
  82. package/esm/VariantRPC/getLDMatrix.js +388 -0
  83. package/esm/VariantRPC/getLDMatrixFromPlink.d.ts +16 -0
  84. package/esm/VariantRPC/getLDMatrixFromPlink.js +105 -0
  85. package/esm/VariantRPC/getPhasedGenotypeMatrix.d.ts +20 -0
  86. package/esm/VariantRPC/getPhasedGenotypeMatrix.js +50 -0
  87. package/esm/VariantRPC/types.d.ts +3 -0
  88. package/esm/VcfAdapter/VcfAdapter.d.ts +1 -1
  89. package/esm/VcfAdapter/VcfAdapter.js +1 -2
  90. package/esm/VcfExtensionPoints/index.js +29 -3
  91. package/esm/VcfFeature/index.d.ts +2 -1
  92. package/esm/VcfFeature/index.js +4 -2
  93. package/esm/index.d.ts +1 -0
  94. package/esm/index.js +23 -0
  95. package/esm/shared/MultiVariantBaseModel.d.ts +2638 -53
  96. package/esm/shared/MultiVariantBaseModel.js +100 -47
  97. package/esm/shared/SharedVariantConfigSchema.d.ts +27 -1
  98. package/esm/shared/SharedVariantConfigSchema.js +28 -1
  99. package/esm/shared/VariantFeatureCache.d.ts +27 -0
  100. package/esm/shared/VariantFeatureCache.js +48 -0
  101. package/esm/shared/VariantRendererType.d.ts +23 -0
  102. package/esm/shared/VariantRendererType.js +15 -0
  103. package/esm/shared/applyColorPalette.d.ts +9 -0
  104. package/esm/shared/applyColorPalette.js +23 -0
  105. package/esm/shared/colorByAutorun.d.ts +10 -0
  106. package/esm/shared/colorByAutorun.js +39 -0
  107. package/esm/shared/components/AddFiltersDialog.d.ts +3 -3
  108. package/esm/shared/components/AddFiltersDialog.js +29 -22
  109. package/esm/shared/components/LDFilterDialog.d.ts +13 -0
  110. package/esm/shared/components/LDFilterDialog.js +102 -0
  111. package/esm/shared/components/MAFFilterDialog.js +23 -16
  112. package/esm/shared/components/MultiVariantClusterDialog/ClusterDialogAuto.js +19 -6
  113. package/esm/shared/components/MultiVariantClusterDialog/types.d.ts +4 -1
  114. package/esm/shared/components/MultiVariantColorLegend.js +4 -4
  115. package/esm/shared/components/MultiVariantLegendBar.js +1 -1
  116. package/esm/shared/components/MultiVariantTooltip.d.ts +1 -0
  117. package/esm/shared/components/MultiVariantTooltip.js +2 -2
  118. package/esm/shared/components/RecombinationTrack.d.ts +21 -0
  119. package/esm/shared/components/RecombinationTrack.js +54 -0
  120. package/esm/shared/components/RecombinationYScaleBar.d.ts +7 -0
  121. package/esm/shared/components/RecombinationYScaleBar.js +34 -0
  122. package/esm/shared/components/RectBg.js +1 -1
  123. package/esm/shared/components/SetColorDialogRowPalettizer.d.ts +3 -8
  124. package/esm/shared/components/SetColorDialogRowPalettizer.js +2 -14
  125. package/esm/shared/components/SourcesDataGrid.js +4 -4
  126. package/esm/shared/components/TreeSidebar.js +11 -1
  127. package/esm/shared/drawAlleleCount.js +9 -0
  128. package/esm/shared/drawPhased.d.ts +1 -1
  129. package/esm/shared/drawPhased.js +31 -2
  130. package/esm/shared/getMultiVariantFeaturesAutorun.d.ts +1 -0
  131. package/esm/shared/getMultiVariantFeaturesAutorun.js +3 -0
  132. package/esm/shared/getMultiVariantSourcesAutorun.d.ts +1 -0
  133. package/esm/shared/getMultiVariantSourcesAutorun.js +3 -0
  134. package/esm/shared/getSources.d.ts +5 -9
  135. package/esm/shared/getSources.js +30 -25
  136. package/esm/shared/mafFilterUtils.d.ts +5 -0
  137. package/esm/shared/mafFilterUtils.js +17 -0
  138. package/esm/shared/minorAlleleFrequencyUtils.d.ts +2 -0
  139. package/esm/shared/minorAlleleFrequencyUtils.js +259 -17
  140. package/esm/shared/setupMultiVariantAutoruns.js +2 -0
  141. package/esm/shared/treeDrawingAutorun.d.ts +1 -0
  142. package/esm/shared/treeDrawingAutorun.js +7 -1
  143. package/esm/shared/types.d.ts +1 -2
  144. package/package.json +12 -11
@@ -4,6 +4,7 @@ import type { StopToken } from '@jbrowse/core/util/stopToken';
4
4
  export declare function getMultiVariantSourcesAutorun(self: {
5
5
  configuration: AnyConfigurationModel;
6
6
  adapterConfig: AnyConfigurationModel;
7
+ isMinimized: boolean;
7
8
  adapterProps: () => Record<string, unknown>;
8
9
  setSourcesLoading: (aborter: StopToken) => void;
9
10
  setError: (error: unknown) => void;
@@ -7,6 +7,9 @@ import { autorun } from 'mobx';
7
7
  export function getMultiVariantSourcesAutorun(self) {
8
8
  addDisposer(self, autorun(async () => {
9
9
  try {
10
+ if (!isAlive(self) || self.isMinimized) {
11
+ return;
12
+ }
10
13
  const view = getContainingView(self);
11
14
  if (!view.initialized) {
12
15
  return;
@@ -1,15 +1,11 @@
1
1
  import type { SampleInfo, Source } from './types.ts';
2
+ export declare function expandSourcesToHaplotypes({ sources, sampleInfo, }: {
3
+ sources: Source[];
4
+ sampleInfo: Record<string, SampleInfo>;
5
+ }): Source[];
2
6
  export declare function getSources({ sources, layout, renderingMode, sampleInfo, }: {
3
7
  sources: Source[];
4
8
  layout?: Source[];
5
9
  renderingMode: string;
6
10
  sampleInfo?: Record<string, SampleInfo>;
7
- }): {
8
- label: string;
9
- id: string;
10
- baseUri?: string;
11
- name: string;
12
- color?: string;
13
- group?: string;
14
- HP?: number;
15
- }[];
11
+ }): Source[];
@@ -1,31 +1,36 @@
1
+ function makeHaplotypeSources(source, ploidy) {
2
+ const results = [];
3
+ for (let i = 0; i < ploidy; i++) {
4
+ const name = `${source.name} HP${i}`;
5
+ results.push({ ...source, name, baseName: source.name, HP: i });
6
+ }
7
+ return results;
8
+ }
9
+ export function expandSourcesToHaplotypes({ sources, sampleInfo, }) {
10
+ return sources.flatMap(source => {
11
+ const ploidy = sampleInfo[source.name]?.maxPloidy ?? 2;
12
+ return makeHaplotypeSources(source, ploidy);
13
+ });
14
+ }
1
15
  export function getSources({ sources, layout = sources, renderingMode, sampleInfo, }) {
2
- const rows = [];
3
16
  const sourceMap = Object.fromEntries(sources.map(s => [s.name, s]));
4
- for (const row of layout) {
17
+ return layout.flatMap(row => {
18
+ const sampleName = row.baseName ?? row.name;
19
+ const baseSource = sourceMap[sampleName];
20
+ if (!baseSource) {
21
+ return [];
22
+ }
23
+ const merged = { ...baseSource, ...row };
5
24
  if (renderingMode === 'phased') {
6
- const info = sampleInfo?.[row.name];
7
- if (info?.isPhased) {
8
- const ploidy = info.maxPloidy;
9
- for (let i = 0; i < ploidy; i++) {
10
- const id = `${row.name} HP${i}`;
11
- rows.push({
12
- ...sourceMap[row.name],
13
- ...row,
14
- label: id,
15
- HP: i,
16
- id: id,
17
- });
18
- }
25
+ if (row.HP !== undefined) {
26
+ return [{ ...merged, baseName: sampleName }];
19
27
  }
28
+ const ploidy = sampleInfo?.[row.name]?.maxPloidy;
29
+ if (ploidy) {
30
+ return makeHaplotypeSources(merged, ploidy);
31
+ }
32
+ return [];
20
33
  }
21
- else {
22
- rows.push({
23
- ...sourceMap[row.name],
24
- ...row,
25
- label: row.name,
26
- id: row.name,
27
- });
28
- }
29
- }
30
- return rows;
34
+ return [merged];
35
+ });
31
36
  }
@@ -0,0 +1,5 @@
1
+ import type { MenuItem } from '@jbrowse/core/ui';
2
+ export declare function createMAFFilterMenuItem(model: {
3
+ minorAlleleFrequencyFilter?: number;
4
+ setMafFilter: (arg: number) => void;
5
+ }): MenuItem;
@@ -0,0 +1,17 @@
1
+ import { lazy } from 'react';
2
+ import { getSession } from '@jbrowse/core/util';
3
+ const MAFFilterDialog = lazy(() => import("./components/MAFFilterDialog.js"));
4
+ export function createMAFFilterMenuItem(model) {
5
+ return {
6
+ label: 'Minor allele frequency',
7
+ onClick: () => {
8
+ getSession(model).queueDialog(handleClose => [
9
+ MAFFilterDialog,
10
+ {
11
+ model,
12
+ handleClose,
13
+ },
14
+ ]);
15
+ },
16
+ };
17
+ }
@@ -1,4 +1,6 @@
1
+ import type VcfFeature from '../VcfFeature/index.ts';
1
2
  import type { Feature, LastStopTokenCheck } from '@jbrowse/core/util';
3
+ export declare function calculateAlleleCountsFast(feature: VcfFeature): Record<string, number>;
2
4
  export declare function calculateAlleleCounts(genotypes: Record<string, string>, cacheSplit: Record<string, string[]>): Record<string, number>;
3
5
  export declare function calculateMinorAlleleFrequency(alleleCounts: Record<string, number>): number;
4
6
  export declare function getFeaturesThatPassMinorAlleleFrequencyFilter({ features, minorAlleleFrequencyFilter, lengthCutoffFilter, lastCheck, genotypesCache, splitCache, }: {
@@ -1,28 +1,263 @@
1
1
  import { checkStopToken2 } from '@jbrowse/core/util/stopToken';
2
+ const GENOTYPE_SPLIT_REGEX = /[/|]/;
3
+ const SLASH = 47;
4
+ const PIPE = 124;
5
+ export function calculateAlleleCountsFast(feature) {
6
+ let count0 = 0;
7
+ let count1 = 0;
8
+ let count2 = 0;
9
+ let count3 = 0;
10
+ let countDot = 0;
11
+ const otherCounts = {};
12
+ feature.processGenotypes((str, start, end) => {
13
+ const len = end - start;
14
+ if (len === 3) {
15
+ const sep = str.charCodeAt(start + 1);
16
+ if (sep === SLASH || sep === PIPE) {
17
+ const c0 = str.charCodeAt(start);
18
+ const c1 = str.charCodeAt(start + 2);
19
+ if (c0 === 48) {
20
+ count0++;
21
+ }
22
+ else if (c0 === 49) {
23
+ count1++;
24
+ }
25
+ else if (c0 === 50) {
26
+ count2++;
27
+ }
28
+ else if (c0 === 51) {
29
+ count3++;
30
+ }
31
+ else if (c0 === 46) {
32
+ countDot++;
33
+ }
34
+ else {
35
+ const a0 = str[start];
36
+ otherCounts[a0] = (otherCounts[a0] || 0) + 1;
37
+ }
38
+ if (c1 === 48) {
39
+ count0++;
40
+ }
41
+ else if (c1 === 49) {
42
+ count1++;
43
+ }
44
+ else if (c1 === 50) {
45
+ count2++;
46
+ }
47
+ else if (c1 === 51) {
48
+ count3++;
49
+ }
50
+ else if (c1 === 46) {
51
+ countDot++;
52
+ }
53
+ else {
54
+ const a1 = str[start + 2];
55
+ otherCounts[a1] = (otherCounts[a1] || 0) + 1;
56
+ }
57
+ return;
58
+ }
59
+ }
60
+ if (len === 1) {
61
+ const c = str.charCodeAt(start);
62
+ if (c === 48) {
63
+ count0++;
64
+ }
65
+ else if (c === 49) {
66
+ count1++;
67
+ }
68
+ else if (c === 50) {
69
+ count2++;
70
+ }
71
+ else if (c === 51) {
72
+ count3++;
73
+ }
74
+ else if (c === 46) {
75
+ countDot++;
76
+ }
77
+ else {
78
+ const a = str[start];
79
+ otherCounts[a] = (otherCounts[a] || 0) + 1;
80
+ }
81
+ return;
82
+ }
83
+ const gt = str.slice(start, end);
84
+ const alleles = gt.split(GENOTYPE_SPLIT_REGEX);
85
+ for (const allele of alleles) {
86
+ if (allele === '0') {
87
+ count0++;
88
+ }
89
+ else if (allele === '1') {
90
+ count1++;
91
+ }
92
+ else if (allele === '2') {
93
+ count2++;
94
+ }
95
+ else if (allele === '3') {
96
+ count3++;
97
+ }
98
+ else if (allele === '.') {
99
+ countDot++;
100
+ }
101
+ else {
102
+ otherCounts[allele] = (otherCounts[allele] || 0) + 1;
103
+ }
104
+ }
105
+ });
106
+ const result = {};
107
+ if (count0 > 0) {
108
+ result['0'] = count0;
109
+ }
110
+ if (count1 > 0) {
111
+ result['1'] = count1;
112
+ }
113
+ if (count2 > 0) {
114
+ result['2'] = count2;
115
+ }
116
+ if (count3 > 0) {
117
+ result['3'] = count3;
118
+ }
119
+ if (countDot > 0) {
120
+ result['.'] = countDot;
121
+ }
122
+ for (const key in otherCounts) {
123
+ result[key] = otherCounts[key];
124
+ }
125
+ return result;
126
+ }
2
127
  export function calculateAlleleCounts(genotypes, cacheSplit) {
3
- const alleleCounts = {};
4
- const vals = Object.values(genotypes);
5
- for (const val of vals) {
6
- const genotype = val;
7
- const alleles = cacheSplit[genotype] ?? (cacheSplit[genotype] = genotype.split(/[/|]/));
128
+ let count0 = 0;
129
+ let count1 = 0;
130
+ let count2 = 0;
131
+ let count3 = 0;
132
+ let countDot = 0;
133
+ const otherCounts = {};
134
+ for (const key in genotypes) {
135
+ const genotype = genotypes[key];
136
+ const len = genotype.length;
137
+ if (len === 3) {
138
+ const sep = genotype[1];
139
+ if (sep === '/' || sep === '|') {
140
+ const a0 = genotype[0];
141
+ const a1 = genotype[2];
142
+ if (a0 === '0') {
143
+ count0++;
144
+ }
145
+ else if (a0 === '1') {
146
+ count1++;
147
+ }
148
+ else if (a0 === '2') {
149
+ count2++;
150
+ }
151
+ else if (a0 === '3') {
152
+ count3++;
153
+ }
154
+ else if (a0 === '.') {
155
+ countDot++;
156
+ }
157
+ else {
158
+ otherCounts[a0] = (otherCounts[a0] || 0) + 1;
159
+ }
160
+ if (a1 === '0') {
161
+ count0++;
162
+ }
163
+ else if (a1 === '1') {
164
+ count1++;
165
+ }
166
+ else if (a1 === '2') {
167
+ count2++;
168
+ }
169
+ else if (a1 === '3') {
170
+ count3++;
171
+ }
172
+ else if (a1 === '.') {
173
+ countDot++;
174
+ }
175
+ else {
176
+ otherCounts[a1] = (otherCounts[a1] || 0) + 1;
177
+ }
178
+ continue;
179
+ }
180
+ }
181
+ if (len === 1) {
182
+ if (genotype === '0') {
183
+ count0++;
184
+ }
185
+ else if (genotype === '1') {
186
+ count1++;
187
+ }
188
+ else if (genotype === '2') {
189
+ count2++;
190
+ }
191
+ else if (genotype === '3') {
192
+ count3++;
193
+ }
194
+ else if (genotype === '.') {
195
+ countDot++;
196
+ }
197
+ else {
198
+ otherCounts[genotype] = (otherCounts[genotype] || 0) + 1;
199
+ }
200
+ continue;
201
+ }
202
+ let alleles = cacheSplit[genotype];
203
+ if (!alleles) {
204
+ alleles = genotype.split(GENOTYPE_SPLIT_REGEX);
205
+ cacheSplit[genotype] = alleles;
206
+ }
8
207
  for (const allele of alleles) {
9
- const a = allele;
10
- alleleCounts[a] = (alleleCounts[a] || 0) + 1;
208
+ if (allele === '0') {
209
+ count0++;
210
+ }
211
+ else if (allele === '1') {
212
+ count1++;
213
+ }
214
+ else if (allele === '2') {
215
+ count2++;
216
+ }
217
+ else if (allele === '3') {
218
+ count3++;
219
+ }
220
+ else if (allele === '.') {
221
+ countDot++;
222
+ }
223
+ else {
224
+ otherCounts[allele] = (otherCounts[allele] || 0) + 1;
225
+ }
11
226
  }
12
227
  }
13
- return alleleCounts;
228
+ const result = {};
229
+ if (count0 > 0) {
230
+ result['0'] = count0;
231
+ }
232
+ if (count1 > 0) {
233
+ result['1'] = count1;
234
+ }
235
+ if (count2 > 0) {
236
+ result['2'] = count2;
237
+ }
238
+ if (count3 > 0) {
239
+ result['3'] = count3;
240
+ }
241
+ if (countDot > 0) {
242
+ result['.'] = countDot;
243
+ }
244
+ for (const key in otherCounts) {
245
+ result[key] = otherCounts[key];
246
+ }
247
+ return result;
14
248
  }
15
249
  export function calculateMinorAlleleFrequency(alleleCounts) {
16
250
  let firstMax = 0;
17
251
  let secondMax = 0;
18
252
  let total = 0;
19
- for (const count of Object.values(alleleCounts)) {
253
+ for (const key in alleleCounts) {
254
+ const count = alleleCounts[key];
20
255
  total += count;
21
256
  if (count > firstMax) {
22
257
  secondMax = firstMax;
23
258
  firstMax = count;
24
259
  }
25
- else if (count > secondMax && count !== firstMax) {
260
+ else if (count > secondMax) {
26
261
  secondMax = count;
27
262
  }
28
263
  }
@@ -31,7 +266,8 @@ export function calculateMinorAlleleFrequency(alleleCounts) {
31
266
  function getMostFrequentAlt(alleleCounts) {
32
267
  let mostFrequentAlt;
33
268
  let max = 0;
34
- for (const [alt, altCount] of Object.entries(alleleCounts)) {
269
+ for (const alt in alleleCounts) {
270
+ const altCount = alleleCounts[alt];
35
271
  if (alt !== '.' && alt !== '0' && altCount > max) {
36
272
  mostFrequentAlt = alt;
37
273
  max = altCount;
@@ -43,13 +279,19 @@ export function getFeaturesThatPassMinorAlleleFrequencyFilter({ features, minorA
43
279
  const results = [];
44
280
  for (const feature of features) {
45
281
  if (feature.get('end') - feature.get('start') <= lengthCutoffFilter) {
46
- const featureId = feature.id();
47
- let genotypes = genotypesCache?.get(featureId);
48
- if (!genotypes) {
49
- genotypes = feature.get('genotypes');
50
- genotypesCache?.set(featureId, genotypes);
282
+ let alleleCounts;
283
+ if ('processGenotypes' in feature) {
284
+ alleleCounts = calculateAlleleCountsFast(feature);
285
+ }
286
+ else {
287
+ const featureId = feature.id();
288
+ let genotypes = genotypesCache?.get(featureId);
289
+ if (!genotypes) {
290
+ genotypes = feature.get('genotypes');
291
+ genotypesCache?.set(featureId, genotypes);
292
+ }
293
+ alleleCounts = calculateAlleleCounts(genotypes, splitCache);
51
294
  }
52
- const alleleCounts = calculateAlleleCounts(genotypes, splitCache);
53
295
  if (calculateMinorAlleleFrequency(alleleCounts) >=
54
296
  minorAlleleFrequencyFilter) {
55
297
  results.push({
@@ -1,3 +1,4 @@
1
+ import { setupColorByAutorun } from "./colorByAutorun.js";
1
2
  import { getMultiVariantFeaturesAutorun } from "./getMultiVariantFeaturesAutorun.js";
2
3
  import { getMultiVariantSourcesAutorun } from "./getMultiVariantSourcesAutorun.js";
3
4
  import { setupTreeDrawingAutorun } from "./treeDrawingAutorun.js";
@@ -5,4 +6,5 @@ export function setupMultiVariantAutoruns(self) {
5
6
  getMultiVariantSourcesAutorun(self);
6
7
  getMultiVariantFeaturesAutorun(self);
7
8
  setupTreeDrawingAutorun(self);
9
+ setupColorByAutorun(self);
8
10
  }
@@ -11,6 +11,7 @@ interface TreeDrawingModel {
11
11
  totalHeight: number;
12
12
  hoveredTreeNode?: HoveredTreeNode;
13
13
  sources?: Source[];
14
+ isMinimized: boolean;
14
15
  }
15
16
  export declare function setupTreeDrawingAutorun(self: TreeDrawingModel): void;
16
17
  export {};
@@ -1,8 +1,11 @@
1
1
  import { getContainingView } from '@jbrowse/core/util';
2
- import { addDisposer } from '@jbrowse/mobx-state-tree';
2
+ import { addDisposer, isAlive } from '@jbrowse/mobx-state-tree';
3
3
  import { autorun } from 'mobx';
4
4
  export function setupTreeDrawingAutorun(self) {
5
5
  addDisposer(self, autorun(function treeDrawAutorun() {
6
+ if (!isAlive(self) || self.isMinimized) {
7
+ return;
8
+ }
6
9
  const { treeCanvas, hierarchy, treeAreaWidth, height, scrollTop, totalHeight: _totalHeight, } = self;
7
10
  if (!treeCanvas || !hierarchy) {
8
11
  return;
@@ -34,6 +37,9 @@ export function setupTreeDrawingAutorun(self) {
34
37
  name: 'TreeDraw',
35
38
  }));
36
39
  addDisposer(self, autorun(function treeHoverAutorun() {
40
+ if (!isAlive(self) || self.isMinimized) {
41
+ return;
42
+ }
37
43
  const { mouseoverCanvas, hierarchy, rowHeight, hoveredTreeNode, height, scrollTop, sources, totalHeight, } = self;
38
44
  if (!mouseoverCanvas) {
39
45
  return;
@@ -3,11 +3,10 @@ import type { Feature } from '@jbrowse/core/util';
3
3
  export interface Source {
4
4
  baseUri?: string;
5
5
  name: string;
6
- label?: string;
6
+ baseName?: string;
7
7
  color?: string;
8
8
  group?: string;
9
9
  HP?: number;
10
- id?: string;
11
10
  [key: string]: unknown;
12
11
  }
13
12
  export interface SampleInfo {
package/package.json CHANGED
@@ -1,6 +1,7 @@
1
1
  {
2
2
  "name": "@jbrowse/plugin-variants",
3
- "version": "4.0.3",
3
+ "version": "4.1.1",
4
+ "type": "module",
4
5
  "description": "JBrowse 2 variant adapters, tracks, etc.",
5
6
  "keywords": [
6
7
  "jbrowse",
@@ -23,24 +24,24 @@
23
24
  "@flatten-js/interval-tree": "^2.0.3",
24
25
  "@gmod/hclust": "^1.0.7",
25
26
  "@gmod/tabix": "^3.2.2",
26
- "@gmod/vcf": "^6.1.0",
27
+ "@gmod/vcf": "^7.0.0",
27
28
  "@jbrowse/mobx-state-tree": "^5.5.0",
28
- "@mui/icons-material": "^7.3.6",
29
- "@mui/material": "^7.3.6",
30
- "@mui/x-charts-vendor": "^8.23.0",
31
- "@mui/x-data-grid": "^8.23.0",
29
+ "@mui/icons-material": "^7.3.7",
30
+ "@mui/material": "^7.3.7",
31
+ "@mui/x-charts-vendor": "^8.26.0",
32
+ "@mui/x-data-grid": "^8.26.0",
33
+ "@types/file-saver-es": "^2.0.3",
32
34
  "copy-to-clipboard": "^3.3.3",
33
35
  "escape-html": "^1.0.3",
34
36
  "fast-deep-equal": "^3.1.3",
35
- "@types/file-saver-es": "^2.0.3",
36
37
  "file-saver-es": "^2.0.5",
37
38
  "mobx": "^6.15.0",
38
39
  "mobx-react": "^9.2.1",
39
40
  "rxjs": "^7.8.2",
40
- "@jbrowse/plugin-circular-view": "^4.0.3",
41
- "@jbrowse/core": "^4.0.3",
42
- "@jbrowse/plugin-linear-genome-view": "^4.0.3",
43
- "@jbrowse/sv-core": "^4.0.3"
41
+ "@jbrowse/core": "^4.1.1",
42
+ "@jbrowse/plugin-linear-genome-view": "^4.1.1",
43
+ "@jbrowse/sv-core": "^4.1.1",
44
+ "@jbrowse/plugin-circular-view": "^4.1.1"
44
45
  },
45
46
  "peerDependencies": {
46
47
  "react": ">=18.0.0"