@jbrowse/plugin-variants 3.0.0 → 3.0.2

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 (155) hide show
  1. package/dist/MultiLinearVariantDisplay/components/Crosshair.js +1 -1
  2. package/dist/MultiLinearVariantDisplay/components/VariantDisplayComponent.js +1 -1
  3. package/dist/MultiLinearVariantDisplay/model.d.ts +7 -7
  4. package/dist/MultiLinearVariantDisplay/renderSvg.js +1 -1
  5. package/dist/MultiLinearVariantMatrixDisplay/components/Crosshair.js +1 -1
  6. package/dist/MultiLinearVariantMatrixDisplay/components/VariantDisplayComponent.js +1 -1
  7. package/dist/MultiLinearVariantMatrixDisplay/model.d.ts +7 -7
  8. package/dist/MultiLinearVariantMatrixDisplay/renderSvg.js +1 -1
  9. package/dist/MultiLinearVariantMatrixRenderer/LinearVariantMatrixRenderer.js +5 -5
  10. package/dist/MultiLinearVariantMatrixRenderer/makeImageData.d.ts +6 -3
  11. package/dist/MultiLinearVariantMatrixRenderer/makeImageData.js +58 -68
  12. package/dist/MultiLinearVariantMatrixRenderer/types.d.ts +2 -1
  13. package/dist/MultiLinearVariantRenderer/MultiVariantRendering.d.ts +1 -1
  14. package/dist/MultiLinearVariantRenderer/components/MultiVariantRendering.d.ts +22 -0
  15. package/dist/MultiLinearVariantRenderer/components/MultiVariantRendering.js +52 -0
  16. package/dist/MultiLinearVariantRenderer/index.js +1 -1
  17. package/dist/MultiLinearVariantRenderer/makeImageData.js +13 -21
  18. package/dist/MultiLinearVariantRenderer/types.d.ts +1 -1
  19. package/dist/MultiVariantBaseRenderer.d.ts +5 -5
  20. package/dist/VariantRPC/MultiVariantGetGenotypeMatrix.js +4 -4
  21. package/dist/VariantRPC/MultiVariantGetSimplifiedFeatures.d.ts +1 -1
  22. package/dist/VariantRPC/MultiVariantGetSimplifiedFeatures.js +9 -9
  23. package/dist/VcfTabixAdapter/VcfTabixAdapter.d.ts +6 -3
  24. package/dist/VcfTabixAdapter/VcfTabixAdapter.js +13 -13
  25. package/dist/getMultiVariantFeaturesAutorun.d.ts +1 -1
  26. package/dist/getMultiVariantSourcesAutorun.d.ts +1 -1
  27. package/dist/shared/MultiVariantBaseModel.d.ts +1 -1
  28. package/dist/shared/MultiVariantBaseModel.js +4 -4
  29. package/dist/shared/{SourcesGridHeader.js → components/SourcesGridHeader.js} +5 -5
  30. package/dist/shared/constants.d.ts +2 -0
  31. package/dist/shared/constants.js +5 -0
  32. package/dist/shared/drawAlleleCount.d.ts +1 -0
  33. package/dist/shared/{multiVariantColor.js → drawAlleleCount.js} +7 -14
  34. package/dist/shared/drawPhased.d.ts +1 -0
  35. package/dist/shared/drawPhased.js +21 -0
  36. package/dist/shared/findSecondLargestNumber.d.ts +0 -0
  37. package/dist/shared/findSecondLargestNumber.js +1 -0
  38. package/dist/shared/minorAlleleFrequencyUtils.d.ts +11 -0
  39. package/dist/shared/minorAlleleFrequencyUtils.js +62 -0
  40. package/dist/shared/sourcesGridUtils.d.ts +10 -0
  41. package/dist/shared/sourcesGridUtils.js +32 -0
  42. package/dist/shared/util.d.ts +3 -10
  43. package/dist/shared/util.js +23 -26
  44. package/dist/util.d.ts +0 -8
  45. package/dist/util.js +0 -85
  46. package/esm/MultiLinearVariantDisplay/components/Crosshair.js +1 -1
  47. package/esm/MultiLinearVariantDisplay/components/VariantDisplayComponent.js +1 -1
  48. package/esm/MultiLinearVariantDisplay/model.d.ts +7 -7
  49. package/esm/MultiLinearVariantDisplay/renderSvg.js +1 -1
  50. package/esm/MultiLinearVariantMatrixDisplay/components/Crosshair.js +1 -1
  51. package/esm/MultiLinearVariantMatrixDisplay/components/VariantDisplayComponent.js +1 -1
  52. package/esm/MultiLinearVariantMatrixDisplay/model.d.ts +7 -7
  53. package/esm/MultiLinearVariantMatrixDisplay/renderSvg.js +1 -1
  54. package/esm/MultiLinearVariantMatrixRenderer/LinearVariantMatrixRenderer.js +5 -5
  55. package/esm/MultiLinearVariantMatrixRenderer/makeImageData.d.ts +6 -3
  56. package/esm/MultiLinearVariantMatrixRenderer/makeImageData.js +56 -66
  57. package/esm/MultiLinearVariantMatrixRenderer/types.d.ts +2 -1
  58. package/esm/MultiLinearVariantRenderer/MultiVariantRendering.d.ts +1 -1
  59. package/esm/MultiLinearVariantRenderer/components/MultiVariantRendering.d.ts +22 -0
  60. package/esm/MultiLinearVariantRenderer/components/MultiVariantRendering.js +47 -0
  61. package/esm/MultiLinearVariantRenderer/index.js +1 -1
  62. package/esm/MultiLinearVariantRenderer/makeImageData.js +6 -14
  63. package/esm/MultiLinearVariantRenderer/types.d.ts +1 -1
  64. package/esm/MultiVariantBaseRenderer.d.ts +5 -5
  65. package/esm/VariantRPC/MultiVariantGetGenotypeMatrix.js +3 -3
  66. package/esm/VariantRPC/MultiVariantGetSimplifiedFeatures.d.ts +1 -1
  67. package/esm/VariantRPC/MultiVariantGetSimplifiedFeatures.js +8 -8
  68. package/esm/VcfTabixAdapter/VcfTabixAdapter.d.ts +6 -3
  69. package/esm/VcfTabixAdapter/VcfTabixAdapter.js +13 -13
  70. package/esm/getMultiVariantFeaturesAutorun.d.ts +1 -1
  71. package/esm/getMultiVariantSourcesAutorun.d.ts +1 -1
  72. package/esm/shared/MultiVariantBaseModel.d.ts +1 -1
  73. package/esm/shared/MultiVariantBaseModel.js +4 -4
  74. package/esm/shared/{SourcesGridHeader.js → components/SourcesGridHeader.js} +1 -1
  75. package/esm/shared/constants.d.ts +2 -0
  76. package/esm/shared/constants.js +2 -0
  77. package/esm/shared/drawAlleleCount.d.ts +1 -0
  78. package/esm/shared/{multiVariantColor.js → drawAlleleCount.js} +6 -11
  79. package/esm/shared/drawPhased.d.ts +1 -0
  80. package/esm/shared/drawPhased.js +18 -0
  81. package/esm/shared/findSecondLargestNumber.d.ts +0 -0
  82. package/esm/shared/findSecondLargestNumber.js +1 -0
  83. package/esm/shared/minorAlleleFrequencyUtils.d.ts +11 -0
  84. package/esm/shared/minorAlleleFrequencyUtils.js +56 -0
  85. package/esm/shared/sourcesGridUtils.d.ts +10 -0
  86. package/esm/shared/sourcesGridUtils.js +28 -0
  87. package/esm/shared/util.d.ts +3 -10
  88. package/esm/shared/util.js +20 -24
  89. package/esm/util.d.ts +0 -8
  90. package/esm/util.js +1 -77
  91. package/package.json +11 -11
  92. package/dist/shared/multiVariantColor.d.ts +0 -3
  93. package/esm/shared/multiVariantColor.d.ts +0 -3
  94. /package/dist/shared/{BulkEditPanel.d.ts → components/BulkEditPanel.d.ts} +0 -0
  95. /package/dist/shared/{BulkEditPanel.js → components/BulkEditPanel.js} +0 -0
  96. /package/dist/shared/{ClusterDialog.d.ts → components/ClusterDialog.d.ts} +0 -0
  97. /package/dist/shared/{ClusterDialog.js → components/ClusterDialog.js} +0 -0
  98. /package/dist/shared/{ColorLegend.d.ts → components/ColorLegend.d.ts} +0 -0
  99. /package/dist/shared/{ColorLegend.js → components/ColorLegend.js} +0 -0
  100. /package/dist/shared/{HelpfulTips.d.ts → components/HelpfulTips.d.ts} +0 -0
  101. /package/dist/shared/{HelpfulTips.js → components/HelpfulTips.js} +0 -0
  102. /package/dist/shared/{LegendBar.d.ts → components/LegendBar.d.ts} +0 -0
  103. /package/dist/shared/{LegendBar.js → components/LegendBar.js} +0 -0
  104. /package/dist/shared/{MAFFilterDialog.d.ts → components/MAFFilterDialog.d.ts} +0 -0
  105. /package/dist/shared/{MAFFilterDialog.js → components/MAFFilterDialog.js} +0 -0
  106. /package/dist/shared/{MultiVariantTooltip.d.ts → components/MultiVariantTooltip.d.ts} +0 -0
  107. /package/dist/shared/{MultiVariantTooltip.js → components/MultiVariantTooltip.js} +0 -0
  108. /package/dist/shared/{RectBg.d.ts → components/RectBg.d.ts} +0 -0
  109. /package/dist/shared/{RectBg.js → components/RectBg.js} +0 -0
  110. /package/dist/shared/{RowPalettizer.d.ts → components/RowPalettizer.d.ts} +0 -0
  111. /package/dist/shared/{RowPalettizer.js → components/RowPalettizer.js} +0 -0
  112. /package/dist/shared/{SetColorDialog.d.ts → components/SetColorDialog.d.ts} +0 -0
  113. /package/dist/shared/{SetColorDialog.js → components/SetColorDialog.js} +0 -0
  114. /package/dist/shared/{SetMinMaxDialog.d.ts → components/SetMinMaxDialog.d.ts} +0 -0
  115. /package/dist/shared/{SetMinMaxDialog.js → components/SetMinMaxDialog.js} +0 -0
  116. /package/dist/shared/{SetRowHeightDialog.d.ts → components/SetRowHeightDialog.d.ts} +0 -0
  117. /package/dist/shared/{SetRowHeightDialog.js → components/SetRowHeightDialog.js} +0 -0
  118. /package/dist/shared/{SourcesDataGrid.d.ts → components/SourcesDataGrid.d.ts} +0 -0
  119. /package/dist/shared/{SourcesDataGrid.js → components/SourcesDataGrid.js} +0 -0
  120. /package/dist/shared/{SourcesGrid.d.ts → components/SourcesGrid.d.ts} +0 -0
  121. /package/dist/shared/{SourcesGrid.js → components/SourcesGrid.js} +0 -0
  122. /package/dist/shared/{SourcesGridHeader.d.ts → components/SourcesGridHeader.d.ts} +0 -0
  123. /package/dist/{types.d.ts → shared/types.d.ts} +0 -0
  124. /package/dist/{types.js → shared/types.js} +0 -0
  125. /package/esm/shared/{BulkEditPanel.d.ts → components/BulkEditPanel.d.ts} +0 -0
  126. /package/esm/shared/{BulkEditPanel.js → components/BulkEditPanel.js} +0 -0
  127. /package/esm/shared/{ClusterDialog.d.ts → components/ClusterDialog.d.ts} +0 -0
  128. /package/esm/shared/{ClusterDialog.js → components/ClusterDialog.js} +0 -0
  129. /package/esm/shared/{ColorLegend.d.ts → components/ColorLegend.d.ts} +0 -0
  130. /package/esm/shared/{ColorLegend.js → components/ColorLegend.js} +0 -0
  131. /package/esm/shared/{HelpfulTips.d.ts → components/HelpfulTips.d.ts} +0 -0
  132. /package/esm/shared/{HelpfulTips.js → components/HelpfulTips.js} +0 -0
  133. /package/esm/shared/{LegendBar.d.ts → components/LegendBar.d.ts} +0 -0
  134. /package/esm/shared/{LegendBar.js → components/LegendBar.js} +0 -0
  135. /package/esm/shared/{MAFFilterDialog.d.ts → components/MAFFilterDialog.d.ts} +0 -0
  136. /package/esm/shared/{MAFFilterDialog.js → components/MAFFilterDialog.js} +0 -0
  137. /package/esm/shared/{MultiVariantTooltip.d.ts → components/MultiVariantTooltip.d.ts} +0 -0
  138. /package/esm/shared/{MultiVariantTooltip.js → components/MultiVariantTooltip.js} +0 -0
  139. /package/esm/shared/{RectBg.d.ts → components/RectBg.d.ts} +0 -0
  140. /package/esm/shared/{RectBg.js → components/RectBg.js} +0 -0
  141. /package/esm/shared/{RowPalettizer.d.ts → components/RowPalettizer.d.ts} +0 -0
  142. /package/esm/shared/{RowPalettizer.js → components/RowPalettizer.js} +0 -0
  143. /package/esm/shared/{SetColorDialog.d.ts → components/SetColorDialog.d.ts} +0 -0
  144. /package/esm/shared/{SetColorDialog.js → components/SetColorDialog.js} +0 -0
  145. /package/esm/shared/{SetMinMaxDialog.d.ts → components/SetMinMaxDialog.d.ts} +0 -0
  146. /package/esm/shared/{SetMinMaxDialog.js → components/SetMinMaxDialog.js} +0 -0
  147. /package/esm/shared/{SetRowHeightDialog.d.ts → components/SetRowHeightDialog.d.ts} +0 -0
  148. /package/esm/shared/{SetRowHeightDialog.js → components/SetRowHeightDialog.js} +0 -0
  149. /package/esm/shared/{SourcesDataGrid.d.ts → components/SourcesDataGrid.d.ts} +0 -0
  150. /package/esm/shared/{SourcesDataGrid.js → components/SourcesDataGrid.js} +0 -0
  151. /package/esm/shared/{SourcesGrid.d.ts → components/SourcesGrid.d.ts} +0 -0
  152. /package/esm/shared/{SourcesGrid.js → components/SourcesGrid.js} +0 -0
  153. /package/esm/shared/{SourcesGridHeader.d.ts → components/SourcesGridHeader.d.ts} +0 -0
  154. /package/esm/{types.d.ts → shared/types.d.ts} +0 -0
  155. /package/esm/{types.js → shared/types.js} +0 -0
@@ -82,7 +82,7 @@ export default function stateModelFactory(configSchema: AnyConfigurationSchemaTy
82
82
  configuration: AnyConfigurationSchemaType;
83
83
  } & {
84
84
  type: import("mobx-state-tree").ISimpleType<"LinearVariantMatrixDisplay">;
85
- layout: import("mobx-state-tree").IOptionalIType<import("mobx-state-tree").IType<import("../types").Source[], import("../types").Source[], import("../types").Source[]>, [undefined]>;
85
+ layout: import("mobx-state-tree").IOptionalIType<import("mobx-state-tree").IType<import("../shared/types").Source[], import("../shared/types").Source[], import("../shared/types").Source[]>, [undefined]>;
86
86
  configuration: AnyConfigurationSchemaType;
87
87
  minorAlleleFrequencyFilter: import("mobx-state-tree").IOptionalIType<import("mobx-state-tree").ISimpleType<number>, [undefined]>;
88
88
  showSidebarLabelsSetting: import("mobx-state-tree").IType<boolean | undefined, boolean, boolean>;
@@ -236,27 +236,27 @@ export default function stateModelFactory(configSchema: AnyConfigurationSchemaTy
236
236
  } & {
237
237
  sourcesLoadingStopToken: string | undefined;
238
238
  featureUnderMouseVolatile: import("@jbrowse/core/util").Feature | undefined;
239
- sourcesVolatile: import("../types").Source[] | undefined;
239
+ sourcesVolatile: import("../shared/types").Source[] | undefined;
240
240
  featuresVolatile: import("@jbrowse/core/util").Feature[] | undefined;
241
241
  hasPhased: boolean;
242
- sampleInfo: undefined | Record<string, import("../types").SampleInfo>;
242
+ sampleInfo: undefined | Record<string, import("../shared/types").SampleInfo>;
243
243
  hoveredGenotype: string | undefined;
244
244
  } & {
245
245
  setRowHeight(arg: number): void;
246
246
  setHoveredGenotype(arg: string): void;
247
247
  setFeatures(f: import("@jbrowse/core/util").Feature[]): void;
248
- setLayout(layout: import("../types").Source[]): void;
248
+ setLayout(layout: import("../shared/types").Source[]): void;
249
249
  clearLayout(): void;
250
250
  setSourcesLoading(str: string): void;
251
- setSources(sources: import("../types").Source[]): void;
251
+ setSources(sources: import("../shared/types").Source[]): void;
252
252
  setMafFilter(arg: number): void;
253
253
  setShowSidebarLabels(arg: boolean): void;
254
254
  setPhasedMode(arg: string): void;
255
255
  setAutoHeight(arg: boolean): void;
256
256
  setHasPhased(arg: boolean): void;
257
- setSampleInfo(arg: Record<string, import("../types").SampleInfo>): void;
257
+ setSampleInfo(arg: Record<string, import("../shared/types").SampleInfo>): void;
258
258
  } & {
259
- readonly preSources: import("../types").Source[] | undefined;
259
+ readonly preSources: import("../shared/types").Source[] | undefined;
260
260
  readonly sources: {
261
261
  label: string;
262
262
  id: string;
@@ -1,8 +1,8 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
2
2
  import { getContainingView } from '@jbrowse/core/util';
3
3
  import { when } from 'mobx';
4
- import LegendBar from '../shared/LegendBar';
5
4
  import LinesConnectingMatrixToGenomicPosition from './components/LinesConnectingMatrixToGenomicPosition';
5
+ import LegendBar from '../shared/components/LegendBar';
6
6
  export async function renderSvg(model, opts, superRenderSvg) {
7
7
  await when(() => !!model.regionCannotBeRenderedText);
8
8
  const { offsetPx } = getContainingView(model);
@@ -33,12 +33,12 @@ export default class LinearVariantMatrixRenderer extends BoxRendererType {
33
33
  ...results,
34
34
  ...res,
35
35
  features: new Map(),
36
- simplifiedFeatures: mafs.map((s) => new SimpleFeature({
37
- id: s.id(),
36
+ simplifiedFeatures: mafs.map(({ feature }) => new SimpleFeature({
37
+ id: feature.id(),
38
38
  data: {
39
- start: s.get('start'),
40
- end: s.get('end'),
41
- refName: s.get('refName'),
39
+ start: feature.get('start'),
40
+ end: feature.get('end'),
41
+ refName: feature.get('refName'),
42
42
  },
43
43
  })),
44
44
  height,
@@ -4,7 +4,10 @@ export declare function makeImageData({ ctx, canvasWidth, canvasHeight, renderAr
4
4
  canvasWidth: number;
5
5
  canvasHeight: number;
6
6
  renderArgs: RenderArgsDeserializedWithFeaturesAndLayout;
7
- }): {
8
- mafs: import("@jbrowse/core/util").Feature[];
7
+ }): Promise<{
8
+ mafs: {
9
+ feature: import("@jbrowse/core/util").Feature;
10
+ mostFrequentAlt: string;
11
+ }[];
9
12
  arr: string[][];
10
- };
13
+ }>;
@@ -1,50 +1,69 @@
1
- import { getColorAlleleCount, getColorPhased, getColorPhasedWithPhaseSet, } from '../shared/multiVariantColor';
2
- import { getFeaturesThatPassMinorAlleleFrequencyFilter } from '../util';
3
- const fudgeFactor = 0.6;
4
- const f2 = fudgeFactor / 2;
5
- function drawColorAlleleCount(alleles, ctx, x, y, w, h) {
6
- ctx.fillStyle = getColorAlleleCount(alleles);
7
- ctx.fillRect(x - f2, y - f2, w + f2, h + f2);
8
- }
9
- function drawPhased(alleles, ctx, x, y, w, h, HP, PS) {
10
- ctx.fillStyle =
11
- PS !== undefined
12
- ? getColorPhasedWithPhaseSet(alleles, HP, PS)
13
- : getColorPhased(alleles, HP);
14
- ctx.fillRect(x - f2, y - f2, w + f2, h + f2);
15
- }
16
- export function makeImageData({ ctx, canvasWidth, canvasHeight, renderArgs, }) {
17
- var _a, _b;
1
+ import { updateStatus } from '@jbrowse/core/util';
2
+ import { f2 } from '../shared/constants';
3
+ import { drawColorAlleleCount } from '../shared/drawAlleleCount';
4
+ import { drawPhased } from '../shared/drawPhased';
5
+ import { getFeaturesThatPassMinorAlleleFrequencyFilter } from '../shared/minorAlleleFrequencyUtils';
6
+ export async function makeImageData({ ctx, canvasWidth, canvasHeight, renderArgs, }) {
18
7
  const { renderingMode: renderingMode, minorAlleleFrequencyFilter, sources, features, } = renderArgs;
19
8
  const { statusCallback = () => { } } = renderArgs;
20
- statusCallback('Drawing variant matrix');
21
9
  const h = canvasHeight / sources.length;
22
10
  const mafs = getFeaturesThatPassMinorAlleleFrequencyFilter(features.values(), minorAlleleFrequencyFilter);
23
11
  const arr = [];
24
12
  const m = mafs.length;
25
13
  const w = canvasWidth / m;
26
- for (let i = 0; i < m; i++) {
27
- const arr2 = [];
28
- const f = mafs[i];
29
- const hasPhaseSet = f.get('format').includes('PS');
30
- if (hasPhaseSet) {
31
- const samp = f.get('samples');
32
- const x = (i / mafs.length) * canvasWidth;
33
- const sln = sources.length;
34
- for (let j = 0; j < sln; j++) {
35
- const y = (j / sln) * canvasHeight;
36
- const { name, HP } = sources[j];
37
- const s = samp[name];
38
- if (s) {
39
- const genotype = (_a = s.GT) === null || _a === void 0 ? void 0 : _a[0];
14
+ await updateStatus('Drawing variant matrix', statusCallback, () => {
15
+ var _a, _b;
16
+ for (let i = 0; i < m; i++) {
17
+ const arr2 = [];
18
+ const { feature, mostFrequentAlt } = mafs[i];
19
+ const hasPhaseSet = feature.get('format').includes('PS');
20
+ if (hasPhaseSet) {
21
+ const samp = feature.get('samples');
22
+ const x = (i / mafs.length) * canvasWidth;
23
+ const sln = sources.length;
24
+ for (let j = 0; j < sln; j++) {
25
+ const y = (j / sln) * canvasHeight;
26
+ const { name, HP } = sources[j];
27
+ const s = samp[name];
28
+ if (s) {
29
+ const genotype = (_a = s.GT) === null || _a === void 0 ? void 0 : _a[0];
30
+ if (genotype) {
31
+ arr2.push(genotype);
32
+ const isPhased = genotype.includes('|');
33
+ if (renderingMode === 'phased') {
34
+ if (isPhased) {
35
+ const PS = (_b = s.PS) === null || _b === void 0 ? void 0 : _b[0];
36
+ const alleles = genotype.split('|');
37
+ drawPhased(alleles, ctx, x, y, w, h, HP, PS);
38
+ }
39
+ else {
40
+ ctx.fillStyle = 'black';
41
+ ctx.fillRect(x - f2, y - f2, w + f2, h + f2);
42
+ }
43
+ }
44
+ else {
45
+ const alleles = genotype.split(/[/|]/);
46
+ drawColorAlleleCount(alleles, ctx, x, y, w, h, mostFrequentAlt);
47
+ }
48
+ }
49
+ }
50
+ }
51
+ }
52
+ else {
53
+ const samp = feature.get('genotypes');
54
+ const x = (i / mafs.length) * canvasWidth;
55
+ const sln = sources.length;
56
+ for (let j = 0; j < sln; j++) {
57
+ const y = (j / sln) * canvasHeight;
58
+ const { name, HP } = sources[j];
59
+ const genotype = samp[name];
40
60
  if (genotype) {
41
61
  arr2.push(genotype);
42
62
  const isPhased = genotype.includes('|');
43
63
  if (renderingMode === 'phased') {
44
64
  if (isPhased) {
45
- const PS = (_b = s.PS) === null || _b === void 0 ? void 0 : _b[0];
46
65
  const alleles = genotype.split('|');
47
- drawPhased(alleles, ctx, x, y, w, h, HP, PS);
66
+ drawPhased(alleles, ctx, x, y, w, h, HP);
48
67
  }
49
68
  else {
50
69
  ctx.fillStyle = 'black';
@@ -53,43 +72,14 @@ export function makeImageData({ ctx, canvasWidth, canvasHeight, renderArgs, }) {
53
72
  }
54
73
  else {
55
74
  const alleles = genotype.split(/[/|]/);
56
- drawColorAlleleCount(alleles, ctx, x, y, w, h);
75
+ drawColorAlleleCount(alleles, ctx, x, y, w, h, mostFrequentAlt);
57
76
  }
58
77
  }
59
78
  }
60
79
  }
80
+ arr.push(arr2);
61
81
  }
62
- else {
63
- const samp = f.get('genotypes');
64
- const x = (i / mafs.length) * canvasWidth;
65
- const sln = sources.length;
66
- const arr2 = [];
67
- for (let j = 0; j < sln; j++) {
68
- const y = (j / sln) * canvasHeight;
69
- const { name, HP } = sources[j];
70
- const genotype = samp[name];
71
- if (genotype) {
72
- arr2.push(genotype);
73
- const isPhased = genotype.includes('|');
74
- if (renderingMode === 'phased') {
75
- if (isPhased) {
76
- const alleles = genotype.split('|');
77
- drawPhased(alleles, ctx, x, y, w, h, HP);
78
- }
79
- else {
80
- ctx.fillStyle = 'black';
81
- ctx.fillRect(x - f2, y - f2, w + f2, h + f2);
82
- }
83
- }
84
- else {
85
- const alleles = genotype.split(/[/|]/);
86
- drawColorAlleleCount(alleles, ctx, x, y, w, h);
87
- }
88
- }
89
- }
90
- }
91
- arr.push(arr2);
92
- }
82
+ });
93
83
  return {
94
84
  mafs,
95
85
  arr,
@@ -1,4 +1,4 @@
1
- import type { Source } from '../types';
1
+ import type { Source } from '../shared/types';
2
2
  import type { RenderArgsDeserialized as BoxRenderArgsDeserialized } from '@jbrowse/core/pluggableElementTypes/renderers/BoxRendererType';
3
3
  import type { Feature } from '@jbrowse/core/util';
4
4
  export interface RenderArgsDeserialized extends BoxRenderArgsDeserialized {
@@ -12,4 +12,5 @@ export interface RenderArgsDeserializedWithFeaturesAndLayout extends RenderArgsD
12
12
  sources: Source[];
13
13
  features: Map<string, Feature>;
14
14
  renderingMode: string;
15
+ statusCallback?: (arg: string) => void;
15
16
  }
@@ -1,5 +1,5 @@
1
1
  import RBush from 'rbush';
2
- import type { Source } from '../types';
2
+ import type { Source } from '../shared/types';
3
3
  import type { Feature } from '@jbrowse/core/util';
4
4
  import type { Region } from '@jbrowse/core/util/types';
5
5
  declare const MultiVariantRendering: (props: {
@@ -0,0 +1,22 @@
1
+ import RBush from 'rbush';
2
+ import type { Source } from '../../shared/types';
3
+ import type { Feature } from '@jbrowse/core/util';
4
+ import type { Region } from '@jbrowse/core/util/types';
5
+ declare const MultiVariantRendering: (props: {
6
+ regions: Region[];
7
+ features: Map<string, Feature>;
8
+ bpPerPx: number;
9
+ width: number;
10
+ height: number;
11
+ sources: Source[];
12
+ scrollTop: number;
13
+ totalHeight: number;
14
+ rbush: RBush<{
15
+ genotype: string;
16
+ }>;
17
+ displayModel: any;
18
+ onMouseLeave?: (event: React.MouseEvent) => void;
19
+ onMouseMove?: (event: React.MouseEvent, arg?: Feature) => void;
20
+ onFeatureClick?: (event: React.MouseEvent, arg?: Feature) => void;
21
+ }) => import("react/jsx-runtime").JSX.Element;
22
+ export default MultiVariantRendering;
@@ -0,0 +1,47 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { useMemo, useRef } from 'react';
3
+ import { PrerenderedCanvas } from '@jbrowse/core/ui';
4
+ import { observer } from 'mobx-react';
5
+ import RBush from 'rbush';
6
+ const MultiVariantRendering = observer(function (props) {
7
+ const { totalHeight, scrollTop } = props;
8
+ const { rbush, displayModel } = props;
9
+ const ref = useRef(null);
10
+ const rbush2 = useMemo(() => new RBush().fromJSON(rbush), [rbush]);
11
+ function getFeatureUnderMouse(eventClientX, eventClientY) {
12
+ var _a;
13
+ let offsetX = 0;
14
+ let offsetY = 0;
15
+ if (ref.current) {
16
+ const r = ref.current.getBoundingClientRect();
17
+ offsetX = eventClientX - r.left;
18
+ offsetY = eventClientY - r.top;
19
+ }
20
+ const ret = rbush2.search({
21
+ minX: offsetX,
22
+ maxX: offsetX + 3,
23
+ minY: offsetY,
24
+ maxY: offsetY + 3,
25
+ });
26
+ return (_a = ret[0]) === null || _a === void 0 ? void 0 : _a.genotype;
27
+ }
28
+ return (_jsx("div", { ref: ref, onMouseMove: e => {
29
+ var _a;
30
+ return (_a = displayModel.setHoveredGenotype) === null || _a === void 0 ? void 0 : _a.call(displayModel, getFeatureUnderMouse(e.clientX, e.clientY));
31
+ }, onMouseLeave: () => {
32
+ var _a;
33
+ (_a = displayModel.setHoveredGenotype) === null || _a === void 0 ? void 0 : _a.call(displayModel, undefined);
34
+ }, onMouseOut: () => {
35
+ var _a;
36
+ (_a = displayModel.setHoveredGenotype) === null || _a === void 0 ? void 0 : _a.call(displayModel, undefined);
37
+ }, style: {
38
+ overflow: 'visible',
39
+ position: 'relative',
40
+ height: totalHeight,
41
+ }, children: _jsx(PrerenderedCanvas, { ...props, style: {
42
+ position: 'absolute',
43
+ left: 0,
44
+ top: scrollTop,
45
+ } }) }));
46
+ });
47
+ export default MultiVariantRendering;
@@ -1,5 +1,5 @@
1
1
  import MultiVariantRenderer from './MultiVariantRenderer';
2
- import ReactComponent from './MultiVariantRendering';
2
+ import ReactComponent from './components/MultiVariantRendering';
3
3
  import configSchema from './configSchema';
4
4
  export default function MultiVariantRendererF(pluginManager) {
5
5
  pluginManager.addRendererType(() => {
@@ -1,23 +1,15 @@
1
1
  import { featureSpanPx } from '@jbrowse/core/util';
2
2
  import RBush from 'rbush';
3
- import { getColorAlleleCount, getColorPhased, } from '../shared/multiVariantColor';
4
- import { getFeaturesThatPassMinorAlleleFrequencyFilter } from '../util';
5
- const fudgeFactor = 0.6;
6
- const f2 = fudgeFactor / 2;
7
- function drawColorAlleleCount(alleles, ctx, x, y, w, h) {
8
- ctx.fillStyle = getColorAlleleCount(alleles);
9
- ctx.fillRect(x - f2, y - f2, w + f2, h + f2);
10
- }
11
- function drawPhased(alleles, ctx, x, y, w, h, HP) {
12
- ctx.fillStyle = getColorPhased(alleles, HP);
13
- ctx.fillRect(x - f2, y - f2, w + f2, h + f2);
14
- }
3
+ import { f2 } from '../shared/constants';
4
+ import { drawColorAlleleCount } from '../shared/drawAlleleCount';
5
+ import { drawPhased } from '../shared/drawPhased';
6
+ import { getFeaturesThatPassMinorAlleleFrequencyFilter } from '../shared/minorAlleleFrequencyUtils';
15
7
  export async function makeImageData(ctx, props) {
16
8
  const { scrollTop, minorAlleleFrequencyFilter, sources, rowHeight, features, regions, bpPerPx, renderingMode, } = props;
17
9
  const region = regions[0];
18
10
  const mafs = getFeaturesThatPassMinorAlleleFrequencyFilter(features.values(), minorAlleleFrequencyFilter);
19
11
  const rbush = new RBush();
20
- for (const feature of mafs) {
12
+ for (const { mostFrequentAlt, feature } of mafs) {
21
13
  const [leftPx, rightPx] = featureSpanPx(feature, region, bpPerPx);
22
14
  const w = Math.max(Math.round(rightPx - leftPx), 2);
23
15
  const samp = feature.get('genotypes');
@@ -49,7 +41,7 @@ export async function makeImageData(ctx, props) {
49
41
  }
50
42
  else {
51
43
  const alleles = genotype.split(/[/|]/);
52
- drawColorAlleleCount(alleles, ctx, x, y, w, h);
44
+ drawColorAlleleCount(alleles, ctx, x, y, w, h, mostFrequentAlt);
53
45
  }
54
46
  }
55
47
  y += rowHeight;
@@ -1,4 +1,4 @@
1
- import type { Source } from '../types';
1
+ import type { Source } from '../shared/types';
2
2
  import type { RenderArgsDeserialized as FeatureRenderArgsDeserialized } from '@jbrowse/core/pluggableElementTypes/renderers/FeatureRendererType';
3
3
  import type { Feature } from '@jbrowse/core/util';
4
4
  import type { ThemeOptions } from '@mui/material';
@@ -1,15 +1,15 @@
1
1
  import FeatureRendererType from '@jbrowse/core/pluggableElementTypes/renderers/FeatureRendererType';
2
- import type { Source } from './types';
3
- import type { RenderArgsDeserialized as FeatureRenderArgsDeserialized } from '@jbrowse/core/pluggableElementTypes/renderers/FeatureRendererType';
2
+ import type { Source } from './shared/types';
3
+ import type { RenderArgsDeserialized } from '@jbrowse/core/pluggableElementTypes/renderers/FeatureRendererType';
4
4
  import type { Feature } from '@jbrowse/core/util';
5
5
  import type { ThemeOptions } from '@mui/material';
6
- export interface RenderArgsDeserialized extends FeatureRenderArgsDeserialized {
6
+ export interface RenderArgs extends RenderArgsDeserialized {
7
7
  bpPerPx: number;
8
8
  height: number;
9
9
  highResolutionScaling: number;
10
10
  themeOptions: ThemeOptions;
11
11
  }
12
- export interface RenderArgsDeserializedWithFeatures extends RenderArgsDeserialized {
12
+ export interface RenderArgsDeserializedWithFeatures extends RenderArgs {
13
13
  features: Map<string, Feature>;
14
14
  }
15
15
  export interface MultiRenderArgsDeserialized extends RenderArgsDeserializedWithFeatures {
@@ -17,7 +17,7 @@ export interface MultiRenderArgsDeserialized extends RenderArgsDeserializedWithF
17
17
  }
18
18
  export default abstract class MultiVariantBaseRenderer extends FeatureRendererType {
19
19
  supportsSVG: boolean;
20
- render(renderProps: RenderArgsDeserialized): Promise<{
20
+ render(renderProps: RenderArgs): Promise<{
21
21
  features: Map<string, Feature>;
22
22
  height: number;
23
23
  width: number;
@@ -1,7 +1,7 @@
1
1
  import { getAdapter } from '@jbrowse/core/data_adapters/dataAdapterCache';
2
2
  import RpcMethodTypeWithFiltersAndRenameRegions from '@jbrowse/core/pluggableElementTypes/RpcMethodTypeWithFiltersAndRenameRegions';
3
3
  import { firstValueFrom, toArray } from 'rxjs';
4
- import { getFeaturesThatPassMinorAlleleFrequencyFilter } from '../util';
4
+ import { getFeaturesThatPassMinorAlleleFrequencyFilter } from '../shared/minorAlleleFrequencyUtils';
5
5
  export class MultiVariantGetGenotypeMatrix extends RpcMethodTypeWithFiltersAndRenameRegions {
6
6
  constructor() {
7
7
  super(...arguments);
@@ -26,8 +26,8 @@ export class MultiVariantGetGenotypeMatrix extends RpcMethodTypeWithFiltersAndRe
26
26
  }
27
27
  const genotypeFactorMap = Object.fromEntries([...genotypeFactor].map((type, idx) => [type, idx]));
28
28
  const rows = {};
29
- for (const feat of mafs) {
30
- const samp = feat.get('genotypes');
29
+ for (const { feature } of mafs) {
30
+ const samp = feature.get('genotypes');
31
31
  for (const { name } of sources) {
32
32
  if (!rows[name]) {
33
33
  rows[name] = {
@@ -1,5 +1,5 @@
1
1
  import RpcMethodTypeWithFiltersAndRenameRegions from '@jbrowse/core/pluggableElementTypes/RpcMethodTypeWithFiltersAndRenameRegions';
2
- import type { SampleInfo } from '../types';
2
+ import type { SampleInfo } from '../shared/types';
3
3
  import type { AnyConfigurationModel } from '@jbrowse/core/configuration';
4
4
  import type { Region } from '@jbrowse/core/util';
5
5
  export declare class MultiVariantGetSimplifiedFeatures extends RpcMethodTypeWithFiltersAndRenameRegions {
@@ -1,7 +1,7 @@
1
1
  import { getAdapter } from '@jbrowse/core/data_adapters/dataAdapterCache';
2
2
  import RpcMethodTypeWithFiltersAndRenameRegions from '@jbrowse/core/pluggableElementTypes/RpcMethodTypeWithFiltersAndRenameRegions';
3
3
  import { firstValueFrom, toArray } from 'rxjs';
4
- import { getFeaturesThatPassMinorAlleleFrequencyFilter } from '../util';
4
+ import { getFeaturesThatPassMinorAlleleFrequencyFilter } from '../shared/minorAlleleFrequencyUtils';
5
5
  export class MultiVariantGetSimplifiedFeatures extends RpcMethodTypeWithFiltersAndRenameRegions {
6
6
  constructor() {
7
7
  super(...arguments);
@@ -19,8 +19,8 @@ export class MultiVariantGetSimplifiedFeatures extends RpcMethodTypeWithFiltersA
19
19
  const features = getFeaturesThatPassMinorAlleleFrequencyFilter(feats, minorAlleleFrequencyFilter);
20
20
  const sampleInfo = {};
21
21
  let hasPhased = false;
22
- for (const f of features) {
23
- const samp = f.get('genotypes');
22
+ for (const { feature } of features) {
23
+ const samp = feature.get('genotypes');
24
24
  for (const [key, val] of Object.entries(samp)) {
25
25
  const isPhased = val.includes('|');
26
26
  hasPhased || (hasPhased = isPhased);
@@ -33,12 +33,12 @@ export class MultiVariantGetSimplifiedFeatures extends RpcMethodTypeWithFiltersA
33
33
  return {
34
34
  hasPhased,
35
35
  sampleInfo,
36
- features: features.map(f => ({
37
- id: f.id(),
36
+ features: features.map(({ feature }) => ({
37
+ id: feature.id(),
38
38
  data: {
39
- start: f.get('start'),
40
- end: f.get('end'),
41
- refName: f.get('refName'),
39
+ start: feature.get('start'),
40
+ end: feature.get('end'),
41
+ refName: feature.get('refName'),
42
42
  },
43
43
  })),
44
44
  };
@@ -7,13 +7,16 @@ import type { NoAssemblyRegion } from '@jbrowse/core/util/types';
7
7
  export default class VcfTabixAdapter extends BaseFeatureDataAdapter {
8
8
  private configured?;
9
9
  private configurePre;
10
- protected configure(): Promise<{
10
+ protected configurePre2(): Promise<{
11
+ vcf: TabixIndexedFile;
12
+ parser: VcfParser;
13
+ }>;
14
+ configure(opts?: BaseOptions): Promise<{
11
15
  vcf: TabixIndexedFile;
12
16
  parser: VcfParser;
13
17
  }>;
14
18
  getRefNames(opts?: BaseOptions): Promise<string[]>;
15
- getHeader(): Promise<string>;
16
- getMetadata(): Promise<any>;
19
+ getHeader(opts?: BaseOptions): Promise<string>;
17
20
  getFeatures(query: NoAssemblyRegion, opts?: BaseOptions): import("rxjs").Observable<Feature>;
18
21
  getSources(): Promise<{
19
22
  name: string;
@@ -6,8 +6,7 @@ import { openLocation } from '@jbrowse/core/util/io';
6
6
  import { ObservableCreate } from '@jbrowse/core/util/rxjs';
7
7
  import VcfFeature from '../VcfFeature';
8
8
  export default class VcfTabixAdapter extends BaseFeatureDataAdapter {
9
- async configurePre(opts) {
10
- const { statusCallback = () => { } } = opts || {};
9
+ async configurePre(_opts) {
11
10
  const vcfGzLocation = this.getConf('vcfGzLocation');
12
11
  const location = this.getConf(['index', 'location']);
13
12
  const indexType = this.getConf(['index', 'indexType']);
@@ -23,13 +22,14 @@ export default class VcfTabixAdapter extends BaseFeatureDataAdapter {
23
22
  : undefined,
24
23
  chunkCacheSize: 50 * 2 ** 20,
25
24
  });
26
- const header = await updateStatus('Downloading index', statusCallback, () => vcf.getHeader());
27
25
  return {
28
26
  vcf,
29
- parser: new VcfParser({ header }),
27
+ parser: new VcfParser({
28
+ header: await vcf.getHeader(),
29
+ }),
30
30
  };
31
31
  }
32
- async configure() {
32
+ async configurePre2() {
33
33
  if (!this.configured) {
34
34
  this.configured = this.configurePre().catch((e) => {
35
35
  this.configured = undefined;
@@ -38,23 +38,23 @@ export default class VcfTabixAdapter extends BaseFeatureDataAdapter {
38
38
  }
39
39
  return this.configured;
40
40
  }
41
+ async configure(opts) {
42
+ const { statusCallback = () => { } } = opts || {};
43
+ return updateStatus('Downloading index', statusCallback, () => this.configurePre2());
44
+ }
41
45
  async getRefNames(opts = {}) {
42
- const { vcf } = await this.configure();
46
+ const { vcf } = await this.configure(opts);
43
47
  return vcf.getReferenceSequenceNames(opts);
44
48
  }
45
- async getHeader() {
46
- const { vcf } = await this.configure();
49
+ async getHeader(opts) {
50
+ const { vcf } = await this.configure(opts);
47
51
  return vcf.getHeader();
48
52
  }
49
- async getMetadata() {
50
- const { parser } = await this.configure();
51
- return parser.getMetadata();
52
- }
53
53
  getFeatures(query, opts = {}) {
54
54
  return ObservableCreate(async (observer) => {
55
55
  const { refName, start, end } = query;
56
56
  const { statusCallback = () => { } } = opts;
57
- const { vcf, parser } = await this.configure();
57
+ const { vcf, parser } = await this.configure(opts);
58
58
  await updateStatus('Downloading variants', statusCallback, () => vcf.getLines(refName, start, end, {
59
59
  lineCallback: (line, fileOffset) => {
60
60
  observer.next(new VcfFeature({
@@ -1,4 +1,4 @@
1
- import type { SampleInfo, Source } from './types';
1
+ import type { SampleInfo, Source } from './shared/types';
2
2
  import type { AnyConfigurationModel } from '@jbrowse/core/configuration';
3
3
  import type { Feature } from '@jbrowse/core/util';
4
4
  export declare function getMultiVariantFeaturesAutorun(self: {
@@ -1,4 +1,4 @@
1
- import type { Source } from './types';
1
+ import type { Source } from './shared/types';
2
2
  import type { AnyConfigurationModel } from '@jbrowse/core/configuration';
3
3
  export declare function getMultiVariantSourcesAutorun(self: {
4
4
  configuration: AnyConfigurationModel;
@@ -1,4 +1,4 @@
1
- import type { SampleInfo, Source } from '../types';
1
+ import type { SampleInfo, Source } from '../shared/types';
2
2
  import type { AnyConfigurationSchemaType } from '@jbrowse/core/configuration';
3
3
  import type { Feature } from '@jbrowse/core/util';
4
4
  import type { Instance } from 'mobx-state-tree';
@@ -9,10 +9,10 @@ import SplitscreenIcon from '@mui/icons-material/Splitscreen';
9
9
  import VisibilityIcon from '@mui/icons-material/Visibility';
10
10
  import deepEqual from 'fast-deep-equal';
11
11
  import { types } from 'mobx-state-tree';
12
- const SetColorDialog = lazy(() => import('../shared/SetColorDialog'));
13
- const MAFFilterDialog = lazy(() => import('../shared/MAFFilterDialog'));
14
- const ClusterDialog = lazy(() => import('../shared/ClusterDialog'));
15
- const SetRowHeightDialog = lazy(() => import('../shared/SetRowHeightDialog'));
12
+ const SetColorDialog = lazy(() => import('./components/SetColorDialog'));
13
+ const MAFFilterDialog = lazy(() => import('./components/MAFFilterDialog'));
14
+ const ClusterDialog = lazy(() => import('./components/ClusterDialog'));
15
+ const SetRowHeightDialog = lazy(() => import('./components/SetRowHeightDialog'));
16
16
  export default function MultiVariantBaseModelF(configSchema) {
17
17
  return types
18
18
  .compose('LinearVariantMatrixDisplay', linearBareDisplayStateModelFactory(configSchema), types.model({
@@ -6,7 +6,7 @@ import KeyboardArrowUpIcon from '@mui/icons-material/KeyboardArrowUp';
6
6
  import KeyboardDoubleArrowDownIcon from '@mui/icons-material/KeyboardDoubleArrowDown';
7
7
  import KeyboardDoubleArrowUpIcon from '@mui/icons-material/KeyboardDoubleArrowUp';
8
8
  import { Button } from '@mui/material';
9
- import { moveDown, moveUp } from './util';
9
+ import { moveDown, moveUp } from '../sourcesGridUtils';
10
10
  export default function SourcesGridHeader({ selected, onChange, rows, showTips, }) {
11
11
  const [anchorEl, setAnchorEl] = useState(null);
12
12
  const [widgetColor, setWidgetColor] = useState('blue');
@@ -0,0 +1,2 @@
1
+ export declare const fudgeFactor = 0.6;
2
+ export declare const f2: number;
@@ -0,0 +1,2 @@
1
+ export const fudgeFactor = 0.6;
2
+ export const f2 = fudgeFactor / 2;
@@ -0,0 +1 @@
1
+ export declare function drawColorAlleleCount(alleles: string[], ctx: CanvasRenderingContext2D, x: number, y: number, w: number, h: number, mostFrequentAlt: string): void;