@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
@@ -0,0 +1,158 @@
1
+ import Flatbush from '@jbrowse/core/util/flatbush';
2
+ import { checkStopToken2, checkStopToken, createStopTokenChecker, } from '@jbrowse/core/util/stopToken';
3
+ import { interpolateRgbBasis } from '@mui/x-charts-vendor/d3-interpolate';
4
+ import { scaleSequential } from '@mui/x-charts-vendor/d3-scale';
5
+ const colorSchemes = {
6
+ r2: interpolateRgbBasis([
7
+ 'rgb(255, 255, 255)',
8
+ 'rgb(255, 224, 224)',
9
+ 'rgb(255, 192, 192)',
10
+ 'rgb(255, 128, 128)',
11
+ 'rgb(255, 64, 64)',
12
+ 'rgb(255, 0, 0)',
13
+ 'rgb(208, 0, 0)',
14
+ 'rgb(160, 0, 0)',
15
+ ]),
16
+ dprime: interpolateRgbBasis([
17
+ 'rgb(255, 255, 255)',
18
+ 'rgb(224, 224, 255)',
19
+ 'rgb(192, 192, 255)',
20
+ 'rgb(128, 128, 255)',
21
+ 'rgb(64, 64, 255)',
22
+ 'rgb(0, 0, 255)',
23
+ 'rgb(0, 0, 208)',
24
+ 'rgb(0, 0, 160)',
25
+ ]),
26
+ rSigned: interpolateRgbBasis([
27
+ 'rgb(0, 0, 160)',
28
+ 'rgb(0, 0, 208)',
29
+ 'rgb(0, 0, 255)',
30
+ 'rgb(64, 64, 255)',
31
+ 'rgb(128, 128, 255)',
32
+ 'rgb(192, 192, 255)',
33
+ 'rgb(224, 224, 255)',
34
+ 'rgb(255, 255, 255)',
35
+ 'rgb(255, 224, 224)',
36
+ 'rgb(255, 192, 192)',
37
+ 'rgb(255, 128, 128)',
38
+ 'rgb(255, 64, 64)',
39
+ 'rgb(255, 0, 0)',
40
+ 'rgb(208, 0, 0)',
41
+ 'rgb(160, 0, 0)',
42
+ ]),
43
+ dprimeSigned: interpolateRgbBasis([
44
+ 'rgb(0, 100, 0)',
45
+ 'rgb(0, 128, 0)',
46
+ 'rgb(0, 160, 0)',
47
+ 'rgb(64, 192, 64)',
48
+ 'rgb(128, 224, 128)',
49
+ 'rgb(192, 240, 192)',
50
+ 'rgb(224, 248, 224)',
51
+ 'rgb(255, 255, 255)',
52
+ 'rgb(224, 224, 255)',
53
+ 'rgb(192, 192, 255)',
54
+ 'rgb(128, 128, 255)',
55
+ 'rgb(64, 64, 255)',
56
+ 'rgb(0, 0, 255)',
57
+ 'rgb(0, 0, 208)',
58
+ 'rgb(0, 0, 160)',
59
+ ]),
60
+ };
61
+ export function makeImageData(ctx, props) {
62
+ const { ldData, regions, bpPerPx, stopToken, yScalar, useGenomicPositions = false, signedLD = false, } = props;
63
+ const lastCheck = createStopTokenChecker(stopToken);
64
+ const { snps, ldValues, metric } = ldData;
65
+ const n = snps.length;
66
+ if (n === 0) {
67
+ return undefined;
68
+ }
69
+ checkStopToken(stopToken);
70
+ const region = regions[0];
71
+ if (!region) {
72
+ return undefined;
73
+ }
74
+ let colorInterpolator;
75
+ if (signedLD) {
76
+ colorInterpolator =
77
+ metric === 'dprime' ? colorSchemes.dprimeSigned : colorSchemes.rSigned;
78
+ }
79
+ else {
80
+ colorInterpolator =
81
+ metric === 'dprime' ? colorSchemes.dprime : colorSchemes.r2;
82
+ }
83
+ const scale = scaleSequential(colorInterpolator).domain(signedLD ? [-1, 1] : [0, 1]);
84
+ const viewWidthPx = (region.end - region.start) / bpPerPx;
85
+ const sqrt2 = Math.sqrt(2);
86
+ const uniformW = viewWidthPx / (n * sqrt2);
87
+ const boundaries = [];
88
+ if (useGenomicPositions) {
89
+ for (let i = 0; i < n; i++) {
90
+ const snpPos = snps[i].start;
91
+ const prevPos = i > 0 ? snps[i - 1].start : region.start;
92
+ const boundaryPos = (prevPos + snpPos) / 2;
93
+ const pixelPos = (boundaryPos - region.start) / bpPerPx / sqrt2;
94
+ boundaries.push(pixelPos);
95
+ }
96
+ const lastSnpPos = snps[n - 1].start;
97
+ const finalBoundary = lastSnpPos + 50 * bpPerPx;
98
+ boundaries.push((finalBoundary - region.start) / bpPerPx / sqrt2);
99
+ }
100
+ if (yScalar) {
101
+ ctx.scale(1, yScalar);
102
+ }
103
+ ctx.save();
104
+ ctx.rotate(-Math.PI / 4);
105
+ const coords = [];
106
+ const items = [];
107
+ let ldIdx = 0;
108
+ for (let i = 1; i < n; i++) {
109
+ for (let j = 0; j < i; j++) {
110
+ const ldVal = ldValues[ldIdx] ?? 0;
111
+ ctx.fillStyle = scale(ldVal);
112
+ let x;
113
+ let y;
114
+ let cellW;
115
+ let cellH;
116
+ if (useGenomicPositions) {
117
+ x = boundaries[j];
118
+ y = boundaries[i];
119
+ cellW = boundaries[j + 1] - x;
120
+ cellH = boundaries[i + 1] - y;
121
+ }
122
+ else {
123
+ x = j * uniformW;
124
+ y = i * uniformW;
125
+ cellW = uniformW;
126
+ cellH = uniformW;
127
+ }
128
+ ctx.fillRect(x, y, cellW, cellH);
129
+ coords.push(x, y, x + cellW, y + cellH);
130
+ items.push({
131
+ i,
132
+ j,
133
+ ldValue: ldVal,
134
+ snp1: snps[i],
135
+ snp2: snps[j],
136
+ });
137
+ ldIdx++;
138
+ checkStopToken2(lastCheck);
139
+ }
140
+ }
141
+ ctx.restore();
142
+ const flatbush = new Flatbush(Math.max(items.length, 1));
143
+ if (coords.length) {
144
+ for (let k = 0; k < coords.length; k += 4) {
145
+ flatbush.add(coords[k], coords[k + 1], coords[k + 2], coords[k + 3]);
146
+ }
147
+ }
148
+ else {
149
+ flatbush.add(0, 0, 0, 0);
150
+ }
151
+ flatbush.finish();
152
+ return {
153
+ flatbush: flatbush.data,
154
+ items,
155
+ maxScore: signedLD ? 1 : 1,
156
+ w: uniformW,
157
+ };
158
+ }
@@ -0,0 +1,8 @@
1
+ import type { LDMatrixResult } from '../VariantRPC/getLDMatrix.ts';
2
+ export interface LDFlatbushItem {
3
+ i: number;
4
+ j: number;
5
+ ldValue: number;
6
+ snp1: LDMatrixResult['snps'][0];
7
+ snp2: LDMatrixResult['snps'][0];
8
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,85 @@
1
+ import type PluginManager from '@jbrowse/core/PluginManager';
2
+ declare const configSchema: (pluginManager: PluginManager) => import("node_modules/@jbrowse/core/src/configuration/configurationSchema").ConfigurationSchemaType<{}, import("node_modules/@jbrowse/core/src/configuration/configurationSchema").ConfigurationSchemaOptions<import("node_modules/@jbrowse/core/src/configuration/configurationSchema").ConfigurationSchemaType<{
3
+ name: {
4
+ description: string;
5
+ type: string;
6
+ defaultValue: string;
7
+ };
8
+ assemblyNames: {
9
+ description: string;
10
+ type: string;
11
+ defaultValue: string[];
12
+ };
13
+ description: {
14
+ description: string;
15
+ type: string;
16
+ defaultValue: string;
17
+ };
18
+ category: {
19
+ description: string;
20
+ type: string;
21
+ defaultValue: never[];
22
+ };
23
+ metadata: {
24
+ type: string;
25
+ description: string;
26
+ defaultValue: {};
27
+ };
28
+ rpcDriverName: {
29
+ type: string;
30
+ description: string;
31
+ defaultValue: string;
32
+ };
33
+ adapter: import("@jbrowse/mobx-state-tree").IAnyModelType;
34
+ textSearching: import("node_modules/@jbrowse/core/src/configuration/configurationSchema").ConfigurationSchemaType<{
35
+ indexingAttributes: {
36
+ type: string;
37
+ description: string;
38
+ defaultValue: string[];
39
+ };
40
+ indexingFeatureTypesToExclude: {
41
+ type: string;
42
+ description: string;
43
+ defaultValue: string[];
44
+ };
45
+ textSearchAdapter: import("@jbrowse/mobx-state-tree").IAnyModelType;
46
+ }, import("node_modules/@jbrowse/core/src/configuration/configurationSchema").ConfigurationSchemaOptions<undefined, undefined>>;
47
+ displays: import("@jbrowse/mobx-state-tree").IArrayType<import("@jbrowse/mobx-state-tree").IAnyModelType>;
48
+ formatDetails: import("node_modules/@jbrowse/core/src/configuration/configurationSchema").ConfigurationSchemaType<{
49
+ feature: {
50
+ type: string;
51
+ description: string;
52
+ defaultValue: {};
53
+ contextVariable: string[];
54
+ };
55
+ subfeatures: {
56
+ type: string;
57
+ description: string;
58
+ defaultValue: {};
59
+ contextVariable: string[];
60
+ };
61
+ depth: {
62
+ type: string;
63
+ defaultValue: number;
64
+ description: string;
65
+ };
66
+ maxDepth: {
67
+ type: string;
68
+ defaultValue: number;
69
+ description: string;
70
+ };
71
+ }, import("node_modules/@jbrowse/core/src/configuration/configurationSchema").ConfigurationSchemaOptions<undefined, undefined>>;
72
+ formatAbout: import("node_modules/@jbrowse/core/src/configuration/configurationSchema").ConfigurationSchemaType<{
73
+ config: {
74
+ type: string;
75
+ description: string;
76
+ defaultValue: {};
77
+ contextVariable: string[];
78
+ };
79
+ hideUris: {
80
+ type: string;
81
+ defaultValue: boolean;
82
+ };
83
+ }, import("node_modules/@jbrowse/core/src/configuration/configurationSchema").ConfigurationSchemaOptions<undefined, undefined>>;
84
+ }, import("node_modules/@jbrowse/core/src/configuration/configurationSchema").ConfigurationSchemaOptions<undefined, "trackId">>, undefined>>;
85
+ export default configSchema;
@@ -0,0 +1,7 @@
1
+ import { ConfigurationSchema } from '@jbrowse/core/configuration';
2
+ import { createBaseTrackConfig } from '@jbrowse/core/pluggableElementTypes';
3
+ function x() { }
4
+ const configSchema = (pluginManager) => ConfigurationSchema('LDTrack', {}, {
5
+ baseConfiguration: createBaseTrackConfig(pluginManager),
6
+ });
7
+ export default configSchema;
@@ -0,0 +1,2 @@
1
+ import type PluginManager from '@jbrowse/core/PluginManager';
2
+ export default function LDTrackF(pm: PluginManager): void;
@@ -0,0 +1,14 @@
1
+ import TrackType from '@jbrowse/core/pluggableElementTypes/TrackType';
2
+ import { createBaseTrackModel } from '@jbrowse/core/pluggableElementTypes/models';
3
+ import configSchemaF from "./configSchema.js";
4
+ export default function LDTrackF(pm) {
5
+ pm.addTrackType(() => {
6
+ const configSchema = configSchemaF(pm);
7
+ return new TrackType({
8
+ name: 'LDTrack',
9
+ displayName: 'LD track',
10
+ configSchema,
11
+ stateModel: createBaseTrackModel(pm, 'LDTrack', configSchema),
12
+ });
13
+ });
14
+ }