@jbrowse/plugin-variants 4.0.4 → 4.1.3

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 (128) hide show
  1. package/esm/LDDisplay/SharedLDConfigSchema.d.ts +102 -0
  2. package/esm/LDDisplay/SharedLDConfigSchema.js +83 -0
  3. package/esm/LDDisplay/afterAttach.d.ts +2 -0
  4. package/esm/LDDisplay/afterAttach.js +123 -0
  5. package/esm/LDDisplay/components/BaseDisplayComponent.d.ts +15 -0
  6. package/esm/LDDisplay/components/BaseDisplayComponent.js +39 -0
  7. package/esm/LDDisplay/components/LDColorLegend.d.ts +15 -0
  8. package/esm/LDDisplay/components/LDColorLegend.js +75 -0
  9. package/esm/LDDisplay/components/LDDisplayComponent.d.ts +5 -0
  10. package/esm/LDDisplay/components/LDDisplayComponent.js +203 -0
  11. package/esm/LDDisplay/components/LinesConnectingMatrixToGenomicPosition.d.ts +16 -0
  12. package/esm/LDDisplay/components/LinesConnectingMatrixToGenomicPosition.js +109 -0
  13. package/esm/LDDisplay/configSchema1.d.ts +115 -0
  14. package/esm/LDDisplay/configSchema1.js +16 -0
  15. package/esm/LDDisplay/configSchema2.d.ts +115 -0
  16. package/esm/LDDisplay/configSchema2.js +16 -0
  17. package/esm/LDDisplay/index.d.ts +2 -0
  18. package/esm/LDDisplay/index.js +35 -0
  19. package/esm/LDDisplay/renderSvg.d.ts +3 -0
  20. package/esm/LDDisplay/renderSvg.js +36 -0
  21. package/esm/LDDisplay/shared.d.ts +367 -0
  22. package/esm/LDDisplay/shared.js +467 -0
  23. package/esm/LDDisplay/stateModel1.d.ts +365 -0
  24. package/esm/LDDisplay/stateModel1.js +10 -0
  25. package/esm/LDDisplay/stateModel2.d.ts +365 -0
  26. package/esm/LDDisplay/stateModel2.js +10 -0
  27. package/esm/LDRenderer/LDRenderer.d.ts +30 -0
  28. package/esm/LDRenderer/LDRenderer.js +109 -0
  29. package/esm/LDRenderer/components/LDRendering.d.ts +2 -0
  30. package/esm/LDRenderer/components/LDRendering.js +4 -0
  31. package/esm/LDRenderer/configSchema.d.ts +8 -0
  32. package/esm/LDRenderer/configSchema.js +10 -0
  33. package/esm/LDRenderer/index.d.ts +2 -0
  34. package/esm/LDRenderer/index.js +11 -0
  35. package/esm/LDRenderer/makeImageData.d.ts +20 -0
  36. package/esm/LDRenderer/makeImageData.js +157 -0
  37. package/esm/LDRenderer/types.d.ts +8 -0
  38. package/esm/LDRenderer/types.js +1 -0
  39. package/esm/LDTrack/configSchema.d.ts +85 -0
  40. package/esm/LDTrack/configSchema.js +7 -0
  41. package/esm/LDTrack/index.d.ts +2 -0
  42. package/esm/LDTrack/index.js +14 -0
  43. package/esm/LinearVariantDisplay/model.d.ts +126 -42
  44. package/esm/LinearVariantDisplay/model.js +46 -8
  45. package/esm/MultiLinearVariantDisplay/configSchema.d.ts +27 -1
  46. package/esm/MultiLinearVariantDisplay/model.d.ts +2635 -31
  47. package/esm/MultiLinearVariantDisplay/model.js +6 -0
  48. package/esm/MultiLinearVariantDisplay/renderSvg.d.ts +10 -2
  49. package/esm/MultiLinearVariantMatrixDisplay/configSchema.d.ts +25 -0
  50. package/esm/MultiLinearVariantMatrixDisplay/configSchema.js +26 -0
  51. package/esm/MultiLinearVariantMatrixDisplay/model.d.ts +2636 -32
  52. package/esm/MultiLinearVariantMatrixDisplay/model.js +6 -0
  53. package/esm/MultiLinearVariantMatrixRenderer/MultiLinearVariantMatrixRenderer.d.ts +2 -2
  54. package/esm/MultiLinearVariantMatrixRenderer/MultiLinearVariantMatrixRenderer.js +11 -9
  55. package/esm/MultiLinearVariantMatrixRenderer/components/MultiLinearVariantMatrixRendering.d.ts +8 -0
  56. package/esm/MultiLinearVariantMatrixRenderer/components/MultiLinearVariantMatrixRendering.js +14 -2
  57. package/esm/MultiLinearVariantMatrixRenderer/makeImageData.js +8 -11
  58. package/esm/MultiLinearVariantRenderer/MultiVariantRenderer.d.ts +2 -2
  59. package/esm/MultiLinearVariantRenderer/MultiVariantRenderer.js +4 -3
  60. package/esm/MultiLinearVariantRenderer/components/MultiLinearVariantRendering.d.ts +4 -0
  61. package/esm/MultiLinearVariantRenderer/components/MultiLinearVariantRendering.js +23 -2
  62. package/esm/MultiLinearVariantRenderer/makeImageData.js +12 -12
  63. package/esm/PlinkLDAdapter/PlinkLDAdapter.d.ts +25 -0
  64. package/esm/PlinkLDAdapter/PlinkLDAdapter.js +147 -0
  65. package/esm/PlinkLDAdapter/PlinkLDTabixAdapter.d.ts +24 -0
  66. package/esm/PlinkLDAdapter/PlinkLDTabixAdapter.js +156 -0
  67. package/esm/PlinkLDAdapter/configSchema.d.ts +10 -0
  68. package/esm/PlinkLDAdapter/configSchema.js +25 -0
  69. package/esm/PlinkLDAdapter/configSchemaTabix.d.ts +24 -0
  70. package/esm/PlinkLDAdapter/configSchemaTabix.js +46 -0
  71. package/esm/PlinkLDAdapter/index.d.ts +2 -0
  72. package/esm/PlinkLDAdapter/index.js +25 -0
  73. package/esm/PlinkLDAdapter/types.d.ts +29 -0
  74. package/esm/PlinkLDAdapter/types.js +1 -0
  75. package/esm/VariantFeatureWidget/VariantSampleGrid/VariantSampleGrid.js +1 -1
  76. package/esm/VariantRPC/MultiVariantGetFeatureDetails.d.ts +14 -0
  77. package/esm/VariantRPC/MultiVariantGetFeatureDetails.js +15 -0
  78. package/esm/VariantRPC/MultiVariantGetGenotypeMatrix.js +4 -1
  79. package/esm/VariantRPC/MultiVariantGetSimplifiedFeatures.js +3 -3
  80. package/esm/VariantRPC/executeClusterGenotypeMatrix.js +6 -3
  81. package/esm/VariantRPC/getGenotypeMatrix.d.ts +2 -3
  82. package/esm/VariantRPC/getGenotypeMatrix.js +4 -5
  83. package/esm/VariantRPC/getLDMatrix.d.ts +47 -0
  84. package/esm/VariantRPC/getLDMatrix.js +387 -0
  85. package/esm/VariantRPC/getLDMatrixFromPlink.d.ts +16 -0
  86. package/esm/VariantRPC/getLDMatrixFromPlink.js +105 -0
  87. package/esm/VariantRPC/getPhasedGenotypeMatrix.d.ts +2 -3
  88. package/esm/VariantRPC/getPhasedGenotypeMatrix.js +4 -5
  89. package/esm/VariantRPC/types.d.ts +3 -0
  90. package/esm/VcfAdapter/VcfAdapter.d.ts +1 -1
  91. package/esm/VcfAdapter/VcfAdapter.js +1 -2
  92. package/esm/VcfExtensionPoints/index.js +29 -3
  93. package/esm/VcfFeature/index.d.ts +2 -1
  94. package/esm/VcfFeature/index.js +4 -2
  95. package/esm/index.d.ts +1 -0
  96. package/esm/index.js +23 -0
  97. package/esm/shared/MultiVariantBaseModel.d.ts +2626 -26
  98. package/esm/shared/MultiVariantBaseModel.js +88 -39
  99. package/esm/shared/SharedVariantConfigSchema.d.ts +27 -1
  100. package/esm/shared/SharedVariantConfigSchema.js +28 -1
  101. package/esm/shared/VariantFeatureCache.d.ts +27 -0
  102. package/esm/shared/VariantFeatureCache.js +48 -0
  103. package/esm/shared/VariantRendererType.d.ts +23 -0
  104. package/esm/shared/VariantRendererType.js +15 -0
  105. package/esm/shared/applyColorPalette.d.ts +9 -0
  106. package/esm/shared/applyColorPalette.js +23 -0
  107. package/esm/shared/colorByAutorun.d.ts +10 -0
  108. package/esm/shared/colorByAutorun.js +39 -0
  109. package/esm/shared/components/AddFiltersDialog.d.ts +3 -3
  110. package/esm/shared/components/AddFiltersDialog.js +29 -22
  111. package/esm/shared/components/LDFilterDialog.d.ts +13 -0
  112. package/esm/shared/components/LDFilterDialog.js +102 -0
  113. package/esm/shared/components/MAFFilterDialog.js +23 -16
  114. package/esm/shared/components/RecombinationTrack.d.ts +21 -0
  115. package/esm/shared/components/RecombinationTrack.js +54 -0
  116. package/esm/shared/components/RecombinationYScaleBar.d.ts +7 -0
  117. package/esm/shared/components/RecombinationYScaleBar.js +34 -0
  118. package/esm/shared/components/SetColorDialogRowPalettizer.d.ts +3 -8
  119. package/esm/shared/components/SetColorDialogRowPalettizer.js +2 -14
  120. package/esm/shared/drawAlleleCount.js +9 -0
  121. package/esm/shared/drawPhased.d.ts +1 -1
  122. package/esm/shared/drawPhased.js +31 -2
  123. package/esm/shared/mafFilterUtils.d.ts +5 -0
  124. package/esm/shared/mafFilterUtils.js +17 -0
  125. package/esm/shared/minorAlleleFrequencyUtils.d.ts +4 -2
  126. package/esm/shared/minorAlleleFrequencyUtils.js +261 -19
  127. package/esm/shared/setupMultiVariantAutoruns.js +2 -0
  128. package/package.json +11 -10
@@ -0,0 +1,156 @@
1
+ import { TabixIndexedFile } from '@gmod/tabix';
2
+ import { BaseAdapter } from '@jbrowse/core/data_adapters/BaseAdapter';
3
+ import { updateStatus } from '@jbrowse/core/util';
4
+ import { openLocation } from '@jbrowse/core/util/io';
5
+ export default class PlinkLDTabixAdapter extends BaseAdapter {
6
+ configured;
7
+ async configurePre(_opts) {
8
+ const ldLocation = this.getConf('ldLocation');
9
+ const location = this.getConf(['index', 'location']);
10
+ const indexType = this.getConf(['index', 'indexType']);
11
+ const filehandle = openLocation(ldLocation, this.pluginManager);
12
+ const isCSI = indexType === 'CSI';
13
+ const ld = new TabixIndexedFile({
14
+ filehandle,
15
+ csiFilehandle: isCSI
16
+ ? openLocation(location, this.pluginManager)
17
+ : undefined,
18
+ tbiFilehandle: !isCSI
19
+ ? openLocation(location, this.pluginManager)
20
+ : undefined,
21
+ chunkCacheSize: 50 * 2 ** 20,
22
+ });
23
+ const headerLine = await ld.getHeader();
24
+ const header = this.parseHeader(headerLine);
25
+ return { ld, header };
26
+ }
27
+ parseHeader(headerLine) {
28
+ const columns = headerLine.trim().split(/\s+/);
29
+ const findIdx = (names) => {
30
+ for (const name of names) {
31
+ const idx = columns.indexOf(name);
32
+ if (idx !== -1) {
33
+ return idx;
34
+ }
35
+ }
36
+ return -1;
37
+ };
38
+ const chrAIdx = findIdx(['CHR_A', 'CHR1']);
39
+ const bpAIdx = findIdx(['BP_A', 'BP1', 'POS_A', 'POS1']);
40
+ const snpAIdx = findIdx(['SNP_A', 'SNP1', 'ID_A', 'ID1']);
41
+ const chrBIdx = findIdx(['CHR_B', 'CHR2']);
42
+ const bpBIdx = findIdx(['BP_B', 'BP2', 'POS_B', 'POS2']);
43
+ const snpBIdx = findIdx(['SNP_B', 'SNP2', 'ID_B', 'ID2']);
44
+ const r2Idx = findIdx(['R2', 'R^2', 'RSQ']);
45
+ const dprimeIdx = findIdx(['DP', 'DPRIME', "D'"]);
46
+ const mafAIdx = findIdx(['MAF_A', 'MAF1']);
47
+ const mafBIdx = findIdx(['MAF_B', 'MAF2']);
48
+ if (chrAIdx === -1 || bpAIdx === -1 || chrBIdx === -1 || bpBIdx === -1) {
49
+ throw new Error(`Invalid PLINK LD header. Expected columns CHR_A, BP_A, CHR_B, BP_B. Got: ${columns.join(', ')}`);
50
+ }
51
+ if (r2Idx === -1 && dprimeIdx === -1) {
52
+ throw new Error(`Invalid PLINK LD header. Expected at least R2 or DP column. Got: ${columns.join(', ')}`);
53
+ }
54
+ return {
55
+ columns,
56
+ hasR2: r2Idx !== -1,
57
+ hasDprime: dprimeIdx !== -1,
58
+ hasMafA: mafAIdx !== -1,
59
+ hasMafB: mafBIdx !== -1,
60
+ chrAIdx,
61
+ bpAIdx,
62
+ snpAIdx,
63
+ chrBIdx,
64
+ bpBIdx,
65
+ snpBIdx,
66
+ r2Idx,
67
+ dprimeIdx,
68
+ mafAIdx,
69
+ mafBIdx,
70
+ };
71
+ }
72
+ async configurePre2() {
73
+ if (!this.configured) {
74
+ this.configured = this.configurePre().catch((e) => {
75
+ this.configured = undefined;
76
+ throw e;
77
+ });
78
+ }
79
+ return this.configured;
80
+ }
81
+ async configure(opts) {
82
+ const { statusCallback = () => { } } = opts || {};
83
+ return updateStatus('Downloading index', statusCallback, () => this.configurePre2());
84
+ }
85
+ async getRefNames(opts = {}) {
86
+ const { ld } = await this.configure(opts);
87
+ return ld.getReferenceSequenceNames(opts);
88
+ }
89
+ async getHeader(opts) {
90
+ const { header } = await this.configure(opts);
91
+ return header;
92
+ }
93
+ async getLDRecords(query, opts = {}) {
94
+ const { refName, start, end } = query;
95
+ const { ld, header } = await this.configure(opts);
96
+ const records = [];
97
+ await ld.getLines(refName, start, end, {
98
+ lineCallback: (line) => {
99
+ const record = this.parseLine(line, header);
100
+ if (record) {
101
+ records.push(record);
102
+ }
103
+ },
104
+ ...opts,
105
+ });
106
+ return records;
107
+ }
108
+ async getLDRecordsInRegion(query, opts = {}) {
109
+ const { refName, start, end } = query;
110
+ const records = await this.getLDRecords(query, opts);
111
+ return records.filter(r => r.chrB === refName &&
112
+ r.bpB >= start &&
113
+ r.bpB <= end &&
114
+ r.chrA === refName &&
115
+ r.bpA >= start &&
116
+ r.bpA <= end);
117
+ }
118
+ parseLine(line, header) {
119
+ const fields = line.trim().split(/\s+/);
120
+ const chrA = fields[header.chrAIdx];
121
+ const bpA = Number.parseInt(fields[header.bpAIdx] ?? '', 10);
122
+ const snpA = header.snpAIdx >= 0 ? fields[header.snpAIdx] : `${chrA}:${bpA}`;
123
+ const chrB = fields[header.chrBIdx];
124
+ const bpB = Number.parseInt(fields[header.bpBIdx] ?? '', 10);
125
+ const snpB = header.snpBIdx >= 0 ? fields[header.snpBIdx] : `${chrB}:${bpB}`;
126
+ if (!chrA || !chrB || Number.isNaN(bpA) || Number.isNaN(bpB)) {
127
+ return null;
128
+ }
129
+ const r2 = header.r2Idx >= 0
130
+ ? Number.parseFloat(fields[header.r2Idx] ?? '')
131
+ : undefined;
132
+ const dprime = header.dprimeIdx >= 0
133
+ ? Number.parseFloat(fields[header.dprimeIdx] ?? '')
134
+ : undefined;
135
+ const mafA = header.mafAIdx >= 0
136
+ ? Number.parseFloat(fields[header.mafAIdx] ?? '')
137
+ : undefined;
138
+ const mafB = header.mafBIdx >= 0
139
+ ? Number.parseFloat(fields[header.mafBIdx] ?? '')
140
+ : undefined;
141
+ return {
142
+ chrA,
143
+ bpA,
144
+ snpA: snpA ?? `${chrA}:${bpA}`,
145
+ chrB,
146
+ bpB,
147
+ snpB: snpB ?? `${chrB}:${bpB}`,
148
+ r2: r2 ?? 0,
149
+ dprime,
150
+ mafA,
151
+ mafB,
152
+ };
153
+ }
154
+ freeResources() {
155
+ }
156
+ }
@@ -0,0 +1,10 @@
1
+ declare const PlinkLDAdapter: import("node_modules/@jbrowse/core/src/configuration/configurationSchema").ConfigurationSchemaType<{
2
+ ldLocation: {
3
+ type: string;
4
+ defaultValue: {
5
+ uri: string;
6
+ locationType: string;
7
+ };
8
+ };
9
+ }, import("node_modules/@jbrowse/core/src/configuration/configurationSchema").ConfigurationSchemaOptions<undefined, undefined>>;
10
+ export default PlinkLDAdapter;
@@ -0,0 +1,25 @@
1
+ import { ConfigurationSchema } from '@jbrowse/core/configuration';
2
+ function x() { }
3
+ const PlinkLDAdapter = ConfigurationSchema('PlinkLDAdapter', {
4
+ ldLocation: {
5
+ type: 'fileLocation',
6
+ defaultValue: {
7
+ uri: '/path/to/plink.ld',
8
+ locationType: 'UriLocation',
9
+ },
10
+ },
11
+ }, {
12
+ explicitlyTyped: true,
13
+ preProcessSnapshot: snap => {
14
+ return snap.uri
15
+ ? {
16
+ ...snap,
17
+ ldLocation: {
18
+ uri: snap.uri,
19
+ baseUri: snap.baseUri,
20
+ },
21
+ }
22
+ : snap;
23
+ },
24
+ });
25
+ export default PlinkLDAdapter;
@@ -0,0 +1,24 @@
1
+ declare const PlinkLDTabixAdapter: import("node_modules/@jbrowse/core/src/configuration/configurationSchema").ConfigurationSchemaType<{
2
+ ldLocation: {
3
+ type: string;
4
+ defaultValue: {
5
+ uri: string;
6
+ locationType: string;
7
+ };
8
+ };
9
+ index: import("node_modules/@jbrowse/core/src/configuration/configurationSchema").ConfigurationSchemaType<{
10
+ indexType: {
11
+ model: import("@jbrowse/mobx-state-tree").ISimpleType<string>;
12
+ type: string;
13
+ defaultValue: string;
14
+ };
15
+ location: {
16
+ type: string;
17
+ defaultValue: {
18
+ uri: string;
19
+ locationType: string;
20
+ };
21
+ };
22
+ }, import("node_modules/@jbrowse/core/src/configuration/configurationSchema").ConfigurationSchemaOptions<undefined, undefined>>;
23
+ }, import("node_modules/@jbrowse/core/src/configuration/configurationSchema").ConfigurationSchemaOptions<undefined, undefined>>;
24
+ export default PlinkLDTabixAdapter;
@@ -0,0 +1,46 @@
1
+ import { ConfigurationSchema } from '@jbrowse/core/configuration';
2
+ import { types } from '@jbrowse/mobx-state-tree';
3
+ function x() { }
4
+ const PlinkLDTabixAdapter = ConfigurationSchema('PlinkLDTabixAdapter', {
5
+ ldLocation: {
6
+ type: 'fileLocation',
7
+ defaultValue: {
8
+ uri: '/path/to/plink.ld.gz',
9
+ locationType: 'UriLocation',
10
+ },
11
+ },
12
+ index: ConfigurationSchema('PlinkLDTabixIndex', {
13
+ indexType: {
14
+ model: types.enumeration('IndexType', ['TBI', 'CSI']),
15
+ type: 'stringEnum',
16
+ defaultValue: 'TBI',
17
+ },
18
+ location: {
19
+ type: 'fileLocation',
20
+ defaultValue: {
21
+ uri: '/path/to/plink.ld.gz.tbi',
22
+ locationType: 'UriLocation',
23
+ },
24
+ },
25
+ }),
26
+ }, {
27
+ explicitlyTyped: true,
28
+ preProcessSnapshot: snap => {
29
+ return snap.uri
30
+ ? {
31
+ ...snap,
32
+ ldLocation: {
33
+ uri: snap.uri,
34
+ baseUri: snap.baseUri,
35
+ },
36
+ index: {
37
+ location: {
38
+ uri: `${snap.uri}.tbi`,
39
+ baseUri: snap.baseUri,
40
+ },
41
+ },
42
+ }
43
+ : snap;
44
+ },
45
+ });
46
+ export default PlinkLDTabixAdapter;
@@ -0,0 +1,2 @@
1
+ import type PluginManager from '@jbrowse/core/PluginManager';
2
+ export default function PlinkLDAdapterF(pluginManager: PluginManager): void;
@@ -0,0 +1,25 @@
1
+ import AdapterType from '@jbrowse/core/pluggableElementTypes/AdapterType';
2
+ import configSchema from "./configSchema.js";
3
+ import configSchemaTabix from "./configSchemaTabix.js";
4
+ export default function PlinkLDAdapterF(pluginManager) {
5
+ pluginManager.addAdapterType(() => new AdapterType({
6
+ name: 'PlinkLDAdapter',
7
+ displayName: 'PLINK LD adapter',
8
+ configSchema,
9
+ adapterMetadata: {
10
+ category: 'Linkage disequilibrium',
11
+ description: 'Adapter for pre-computed LD data from PLINK --r2 output (loads into memory)',
12
+ },
13
+ getAdapterClass: () => import("./PlinkLDAdapter.js").then(r => r.default),
14
+ }));
15
+ pluginManager.addAdapterType(() => new AdapterType({
16
+ name: 'PlinkLDTabixAdapter',
17
+ displayName: 'PLINK LD tabix adapter',
18
+ configSchema: configSchemaTabix,
19
+ adapterMetadata: {
20
+ category: 'Linkage disequilibrium',
21
+ description: 'Adapter for pre-computed LD data from PLINK --r2 output (tabix-indexed)',
22
+ },
23
+ getAdapterClass: () => import("./PlinkLDTabixAdapter.js").then(r => r.default),
24
+ }));
25
+ }
@@ -0,0 +1,29 @@
1
+ export interface PlinkLDRecord {
2
+ chrA: string;
3
+ bpA: number;
4
+ snpA: string;
5
+ chrB: string;
6
+ bpB: number;
7
+ snpB: string;
8
+ r2: number;
9
+ dprime?: number;
10
+ mafA?: number;
11
+ mafB?: number;
12
+ }
13
+ export interface PlinkLDHeader {
14
+ columns: string[];
15
+ hasR2: boolean;
16
+ hasDprime: boolean;
17
+ hasMafA: boolean;
18
+ hasMafB: boolean;
19
+ chrAIdx: number;
20
+ bpAIdx: number;
21
+ snpAIdx: number;
22
+ chrBIdx: number;
23
+ bpBIdx: number;
24
+ snpBIdx: number;
25
+ r2Idx: number;
26
+ dprimeIdx: number;
27
+ mafAIdx: number;
28
+ mafBIdx: number;
29
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -43,7 +43,7 @@ export default function VariantSampleGrid(props) {
43
43
  }, [rows, filteredRows, descriptions]);
44
44
  return !rows.length ? null : (_jsxs(BaseCard, { ...props, title: "Samples", children: [error ? _jsx(Typography, { color: "error", children: `${error}` }) : null, _jsxs("div", { style: { display: 'flex', alignItems: 'center', gap: 8 }, children: [_jsx(CascadingMenuButton, { menuItems: [
45
45
  {
46
- label: 'Show allele counts ("dosage") instead of exact GT',
46
+ label: 'Show allele counts ("dosage")',
47
47
  helpText: 'This converts a genotype like 1/1 into 1:2 which says there were two occurrences of the ALT allele 1 in the genotype',
48
48
  type: 'checkbox',
49
49
  checked: useCounts,
@@ -0,0 +1,14 @@
1
+ import RpcMethodType from '@jbrowse/core/pluggableElementTypes/RpcMethodType';
2
+ interface GetFeatureArgs {
3
+ featureId: string;
4
+ sessionId: string;
5
+ trackInstanceId: string;
6
+ rendererType: string;
7
+ }
8
+ export declare class MultiVariantGetFeatureDetails extends RpcMethodType {
9
+ name: string;
10
+ execute(args: GetFeatureArgs): Promise<{
11
+ feature: import("@jbrowse/core/util").SimpleFeatureSerialized | undefined;
12
+ }>;
13
+ }
14
+ export {};
@@ -0,0 +1,15 @@
1
+ import RpcMethodType from '@jbrowse/core/pluggableElementTypes/RpcMethodType';
2
+ export class MultiVariantGetFeatureDetails extends RpcMethodType {
3
+ name = 'MultiVariantGetFeatureDetails';
4
+ async execute(args) {
5
+ const { featureId, sessionId, trackInstanceId, rendererType } = args;
6
+ const RendererType = this.pluginManager.getRendererType(rendererType);
7
+ const feature = RendererType.getFeatureById(featureId, {
8
+ sessionId,
9
+ trackInstanceId,
10
+ });
11
+ return {
12
+ feature: feature?.toJSON(),
13
+ };
14
+ }
15
+ }
@@ -1,11 +1,14 @@
1
1
  import RpcMethodTypeWithFiltersAndRenameRegions from '@jbrowse/core/pluggableElementTypes/RpcMethodTypeWithFiltersAndRenameRegions';
2
+ import { createStopTokenChecker } from '@jbrowse/core/util/stopToken';
2
3
  import { getGenotypeMatrix } from "./getGenotypeMatrix.js";
3
4
  export class MultiVariantGetGenotypeMatrix extends RpcMethodTypeWithFiltersAndRenameRegions {
4
5
  name = 'MultiVariantGetGenotypeMatrix';
5
6
  async execute(args, rpcDriverClassName) {
7
+ const deserializedArgs = await this.deserializeArguments(args, rpcDriverClassName);
8
+ const stopTokenCheck = createStopTokenChecker(deserializedArgs.stopToken);
6
9
  return getGenotypeMatrix({
7
10
  pluginManager: this.pluginManager,
8
- args: await this.deserializeArguments(args, rpcDriverClassName),
11
+ args: { ...deserializedArgs, stopTokenCheck },
9
12
  });
10
13
  }
11
14
  }
@@ -8,6 +8,7 @@ export class MultiVariantGetSimplifiedFeatures extends RpcMethodTypeWithFiltersA
8
8
  async execute(args, rpcDriverClassName) {
9
9
  const deserializedArgs = await this.deserializeArguments(args, rpcDriverClassName);
10
10
  const { lengthCutoffFilter, minorAlleleFrequencyFilter, regions, adapterConfig, stopToken, sessionId, } = deserializedArgs;
11
+ const stopTokenCheck = createStopTokenChecker(stopToken);
11
12
  const { dataAdapter } = await getAdapter(this.pluginManager, sessionId, adapterConfig);
12
13
  const rawFeatures = await firstValueFrom(dataAdapter
13
14
  .getFeaturesInMultipleRegions(regions, deserializedArgs)
@@ -15,11 +16,10 @@ export class MultiVariantGetSimplifiedFeatures extends RpcMethodTypeWithFiltersA
15
16
  const sampleInfo = {};
16
17
  const genotypesCache = new Map();
17
18
  let hasPhased = false;
18
- const lastCheck = createStopTokenChecker(stopToken);
19
19
  const features = getFeaturesThatPassMinorAlleleFrequencyFilter({
20
20
  minorAlleleFrequencyFilter,
21
21
  lengthCutoffFilter,
22
- lastCheck,
22
+ stopTokenCheck,
23
23
  features: rawFeatures,
24
24
  genotypesCache,
25
25
  });
@@ -47,7 +47,7 @@ export class MultiVariantGetSimplifiedFeatures extends RpcMethodTypeWithFiltersA
47
47
  isPhased: existing?.isPhased || isPhased,
48
48
  };
49
49
  }
50
- checkStopToken2(lastCheck);
50
+ checkStopToken2(stopTokenCheck);
51
51
  }
52
52
  return {
53
53
  hasPhased,
@@ -1,14 +1,17 @@
1
1
  import { clusterData, toNewick } from '@gmod/hclust';
2
+ import { createStopTokenChecker } from '@jbrowse/core/util/stopToken';
2
3
  import { getGenotypeMatrix } from "./getGenotypeMatrix.js";
3
4
  import { getPhasedGenotypeMatrix } from "./getPhasedGenotypeMatrix.js";
4
5
  export async function executeClusterGenotypeMatrix({ pluginManager, args, }) {
5
- const { renderingMode, sampleInfo } = args;
6
+ const { renderingMode, sampleInfo, stopToken } = args;
7
+ const stopTokenCheck = createStopTokenChecker(stopToken);
8
+ const argsWithCheck = { ...args, stopTokenCheck };
6
9
  const matrix = renderingMode === 'phased' && sampleInfo
7
10
  ? await getPhasedGenotypeMatrix({
8
11
  pluginManager,
9
- args: { ...args, sampleInfo },
12
+ args: { ...argsWithCheck, sampleInfo },
10
13
  })
11
- : await getGenotypeMatrix({ pluginManager, args });
14
+ : await getGenotypeMatrix({ pluginManager, args: argsWithCheck });
12
15
  const sampleLabels = Object.keys(matrix);
13
16
  const result = await clusterData({
14
17
  data: Object.values(matrix),
@@ -1,13 +1,12 @@
1
1
  import type { Source } from '../shared/types.ts';
2
2
  import type PluginManager from '@jbrowse/core/PluginManager';
3
3
  import type { AnyConfigurationModel } from '@jbrowse/core/configuration';
4
- import type { Region } from '@jbrowse/core/util';
5
- import type { StopToken } from '@jbrowse/core/util/stopToken';
4
+ import type { LastStopTokenCheck, Region } from '@jbrowse/core/util';
6
5
  export declare function getGenotypeMatrix({ pluginManager, args, }: {
7
6
  pluginManager: PluginManager;
8
7
  args: {
9
8
  adapterConfig: AnyConfigurationModel;
10
- stopToken?: StopToken;
9
+ stopTokenCheck?: LastStopTokenCheck;
11
10
  sessionId: string;
12
11
  headers?: Record<string, string>;
13
12
  regions: Region[];
@@ -1,11 +1,10 @@
1
1
  import { getAdapter } from '@jbrowse/core/data_adapters/dataAdapterCache';
2
- import { checkStopToken2, createStopTokenChecker, } from '@jbrowse/core/util/stopToken';
2
+ import { checkStopToken2 } from '@jbrowse/core/util/stopToken';
3
3
  import { firstValueFrom, toArray } from 'rxjs';
4
4
  import { getFeaturesThatPassMinorAlleleFrequencyFilter } from "../shared/minorAlleleFrequencyUtils.js";
5
5
  const SPLITTER = /[/|]/;
6
6
  export async function getGenotypeMatrix({ pluginManager, args, }) {
7
- const { sources, minorAlleleFrequencyFilter, regions, adapterConfig, sessionId, lengthCutoffFilter, stopToken, } = args;
8
- const lastCheck = createStopTokenChecker(stopToken);
7
+ const { sources, minorAlleleFrequencyFilter, regions, adapterConfig, sessionId, lengthCutoffFilter, stopTokenCheck, } = args;
9
8
  const adapter = await getAdapter(pluginManager, sessionId, adapterConfig);
10
9
  const dataAdapter = adapter.dataAdapter;
11
10
  const rows = Object.fromEntries(sources.map(s => [s.name, []]));
@@ -13,7 +12,7 @@ export async function getGenotypeMatrix({ pluginManager, args, }) {
13
12
  const mafs = getFeaturesThatPassMinorAlleleFrequencyFilter({
14
13
  minorAlleleFrequencyFilter,
15
14
  lengthCutoffFilter,
16
- lastCheck,
15
+ stopTokenCheck,
17
16
  splitCache,
18
17
  features: await firstValueFrom(dataAdapter.getFeaturesInMultipleRegions(regions, args).pipe(toArray())),
19
18
  });
@@ -42,7 +41,7 @@ export async function getGenotypeMatrix({ pluginManager, args, }) {
42
41
  : 1;
43
42
  rows[name].push(genotypeStatus);
44
43
  }
45
- checkStopToken2(lastCheck);
44
+ checkStopToken2(stopTokenCheck);
46
45
  }
47
46
  return rows;
48
47
  }
@@ -0,0 +1,47 @@
1
+ import type PluginManager from '@jbrowse/core/PluginManager';
2
+ import type { AnyConfigurationModel } from '@jbrowse/core/configuration';
3
+ import type { LastStopTokenCheck, Region } from '@jbrowse/core/util';
4
+ export type LDMetric = 'r2' | 'dprime';
5
+ export interface FilterStats {
6
+ totalVariants: number;
7
+ passedVariants: number;
8
+ filteredByMaf: number;
9
+ filteredByLength: number;
10
+ filteredByMultiallelic: number;
11
+ filteredByHwe: number;
12
+ filteredByCallRate: number;
13
+ }
14
+ export interface RecombinationData {
15
+ values: Float32Array;
16
+ positions: number[];
17
+ }
18
+ export interface LDMatrixResult {
19
+ snps: {
20
+ id: string;
21
+ refName: string;
22
+ start: number;
23
+ end: number;
24
+ }[];
25
+ ldValues: Float32Array;
26
+ metric: LDMetric;
27
+ filterStats: FilterStats;
28
+ recombination: RecombinationData;
29
+ }
30
+ export declare function getLDMatrix({ pluginManager, args, }: {
31
+ pluginManager: PluginManager;
32
+ args: {
33
+ adapterConfig: AnyConfigurationModel;
34
+ stopTokenCheck?: LastStopTokenCheck;
35
+ sessionId: string;
36
+ headers?: Record<string, string>;
37
+ regions: Region[];
38
+ bpPerPx: number;
39
+ minorAlleleFrequencyFilter: number;
40
+ lengthCutoffFilter: number;
41
+ hweFilterThreshold?: number;
42
+ callRateFilter?: number;
43
+ jexlFilters?: string[];
44
+ ldMetric?: LDMetric;
45
+ signedLD?: boolean;
46
+ };
47
+ }): Promise<LDMatrixResult>;