@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.
- package/esm/ChordVariantDisplay/models/stateModelFactory.d.ts +9 -0
- package/esm/LDDisplay/SharedLDConfigSchema.d.ts +102 -0
- package/esm/LDDisplay/SharedLDConfigSchema.js +83 -0
- package/esm/LDDisplay/afterAttach.d.ts +2 -0
- package/esm/LDDisplay/afterAttach.js +123 -0
- package/esm/LDDisplay/components/BaseDisplayComponent.d.ts +15 -0
- package/esm/LDDisplay/components/BaseDisplayComponent.js +39 -0
- package/esm/LDDisplay/components/LDColorLegend.d.ts +15 -0
- package/esm/LDDisplay/components/LDColorLegend.js +75 -0
- package/esm/LDDisplay/components/LDDisplayComponent.d.ts +5 -0
- package/esm/LDDisplay/components/LDDisplayComponent.js +203 -0
- package/esm/LDDisplay/components/LinesConnectingMatrixToGenomicPosition.d.ts +16 -0
- package/esm/LDDisplay/components/LinesConnectingMatrixToGenomicPosition.js +109 -0
- package/esm/LDDisplay/configSchema1.d.ts +115 -0
- package/esm/LDDisplay/configSchema1.js +16 -0
- package/esm/LDDisplay/configSchema2.d.ts +115 -0
- package/esm/LDDisplay/configSchema2.js +16 -0
- package/esm/LDDisplay/index.d.ts +2 -0
- package/esm/LDDisplay/index.js +35 -0
- package/esm/LDDisplay/renderSvg.d.ts +3 -0
- package/esm/LDDisplay/renderSvg.js +36 -0
- package/esm/LDDisplay/shared.d.ts +367 -0
- package/esm/LDDisplay/shared.js +467 -0
- package/esm/LDDisplay/stateModel1.d.ts +365 -0
- package/esm/LDDisplay/stateModel1.js +10 -0
- package/esm/LDDisplay/stateModel2.d.ts +365 -0
- package/esm/LDDisplay/stateModel2.js +10 -0
- package/esm/LDRenderer/LDRenderer.d.ts +30 -0
- package/esm/LDRenderer/LDRenderer.js +109 -0
- package/esm/LDRenderer/components/LDRendering.d.ts +2 -0
- package/esm/LDRenderer/components/LDRendering.js +4 -0
- package/esm/LDRenderer/configSchema.d.ts +8 -0
- package/esm/LDRenderer/configSchema.js +10 -0
- package/esm/LDRenderer/index.d.ts +2 -0
- package/esm/LDRenderer/index.js +11 -0
- package/esm/LDRenderer/makeImageData.d.ts +20 -0
- package/esm/LDRenderer/makeImageData.js +158 -0
- package/esm/LDRenderer/types.d.ts +8 -0
- package/esm/LDRenderer/types.js +1 -0
- package/esm/LDTrack/configSchema.d.ts +85 -0
- package/esm/LDTrack/configSchema.js +7 -0
- package/esm/LDTrack/index.d.ts +2 -0
- package/esm/LDTrack/index.js +14 -0
- package/esm/LinearVariantDisplay/model.d.ts +139 -42
- package/esm/LinearVariantDisplay/model.js +46 -8
- package/esm/MultiLinearVariantDisplay/configSchema.d.ts +27 -1
- package/esm/MultiLinearVariantDisplay/model.d.ts +2647 -58
- package/esm/MultiLinearVariantDisplay/model.js +6 -0
- package/esm/MultiLinearVariantDisplay/renderSvg.d.ts +10 -2
- package/esm/MultiLinearVariantMatrixDisplay/configSchema.d.ts +25 -0
- package/esm/MultiLinearVariantMatrixDisplay/configSchema.js +26 -0
- package/esm/MultiLinearVariantMatrixDisplay/model.d.ts +2648 -59
- package/esm/MultiLinearVariantMatrixDisplay/model.js +6 -0
- package/esm/MultiLinearVariantMatrixRenderer/MultiLinearVariantMatrixRenderer.d.ts +2 -2
- package/esm/MultiLinearVariantMatrixRenderer/MultiLinearVariantMatrixRenderer.js +11 -9
- package/esm/MultiLinearVariantMatrixRenderer/components/MultiLinearVariantMatrixRendering.d.ts +8 -0
- package/esm/MultiLinearVariantMatrixRenderer/components/MultiLinearVariantMatrixRendering.js +14 -2
- package/esm/MultiLinearVariantMatrixRenderer/makeImageData.js +14 -8
- package/esm/MultiLinearVariantRenderer/MultiVariantRenderer.d.ts +2 -2
- package/esm/MultiLinearVariantRenderer/MultiVariantRenderer.js +4 -3
- package/esm/MultiLinearVariantRenderer/components/MultiLinearVariantRendering.d.ts +4 -0
- package/esm/MultiLinearVariantRenderer/components/MultiLinearVariantRendering.js +23 -2
- package/esm/MultiLinearVariantRenderer/makeImageData.js +8 -3
- package/esm/PlinkLDAdapter/PlinkLDAdapter.d.ts +25 -0
- package/esm/PlinkLDAdapter/PlinkLDAdapter.js +147 -0
- package/esm/PlinkLDAdapter/PlinkLDTabixAdapter.d.ts +24 -0
- package/esm/PlinkLDAdapter/PlinkLDTabixAdapter.js +156 -0
- package/esm/PlinkLDAdapter/configSchema.d.ts +10 -0
- package/esm/PlinkLDAdapter/configSchema.js +25 -0
- package/esm/PlinkLDAdapter/configSchemaTabix.d.ts +24 -0
- package/esm/PlinkLDAdapter/configSchemaTabix.js +46 -0
- package/esm/PlinkLDAdapter/index.d.ts +2 -0
- package/esm/PlinkLDAdapter/index.js +25 -0
- package/esm/PlinkLDAdapter/types.d.ts +29 -0
- package/esm/PlinkLDAdapter/types.js +1 -0
- package/esm/VariantFeatureWidget/VariantSampleGrid/VariantSampleGrid.js +1 -1
- package/esm/VariantRPC/MultiVariantGetFeatureDetails.d.ts +14 -0
- package/esm/VariantRPC/MultiVariantGetFeatureDetails.js +15 -0
- package/esm/VariantRPC/executeClusterGenotypeMatrix.d.ts +3 -1
- package/esm/VariantRPC/executeClusterGenotypeMatrix.js +8 -4
- package/esm/VariantRPC/getLDMatrix.d.ts +48 -0
- package/esm/VariantRPC/getLDMatrix.js +388 -0
- package/esm/VariantRPC/getLDMatrixFromPlink.d.ts +16 -0
- package/esm/VariantRPC/getLDMatrixFromPlink.js +105 -0
- package/esm/VariantRPC/getPhasedGenotypeMatrix.d.ts +20 -0
- package/esm/VariantRPC/getPhasedGenotypeMatrix.js +50 -0
- package/esm/VariantRPC/types.d.ts +3 -0
- package/esm/VcfAdapter/VcfAdapter.d.ts +1 -1
- package/esm/VcfAdapter/VcfAdapter.js +1 -2
- package/esm/VcfExtensionPoints/index.js +29 -3
- package/esm/VcfFeature/index.d.ts +2 -1
- package/esm/VcfFeature/index.js +4 -2
- package/esm/index.d.ts +1 -0
- package/esm/index.js +23 -0
- package/esm/shared/MultiVariantBaseModel.d.ts +2638 -53
- package/esm/shared/MultiVariantBaseModel.js +100 -47
- package/esm/shared/SharedVariantConfigSchema.d.ts +27 -1
- package/esm/shared/SharedVariantConfigSchema.js +28 -1
- package/esm/shared/VariantFeatureCache.d.ts +27 -0
- package/esm/shared/VariantFeatureCache.js +48 -0
- package/esm/shared/VariantRendererType.d.ts +23 -0
- package/esm/shared/VariantRendererType.js +15 -0
- package/esm/shared/applyColorPalette.d.ts +9 -0
- package/esm/shared/applyColorPalette.js +23 -0
- package/esm/shared/colorByAutorun.d.ts +10 -0
- package/esm/shared/colorByAutorun.js +39 -0
- package/esm/shared/components/AddFiltersDialog.d.ts +3 -3
- package/esm/shared/components/AddFiltersDialog.js +29 -22
- package/esm/shared/components/LDFilterDialog.d.ts +13 -0
- package/esm/shared/components/LDFilterDialog.js +102 -0
- package/esm/shared/components/MAFFilterDialog.js +23 -16
- package/esm/shared/components/MultiVariantClusterDialog/ClusterDialogAuto.js +19 -6
- package/esm/shared/components/MultiVariantClusterDialog/types.d.ts +4 -1
- package/esm/shared/components/MultiVariantColorLegend.js +4 -4
- package/esm/shared/components/MultiVariantLegendBar.js +1 -1
- package/esm/shared/components/MultiVariantTooltip.d.ts +1 -0
- package/esm/shared/components/MultiVariantTooltip.js +2 -2
- package/esm/shared/components/RecombinationTrack.d.ts +21 -0
- package/esm/shared/components/RecombinationTrack.js +54 -0
- package/esm/shared/components/RecombinationYScaleBar.d.ts +7 -0
- package/esm/shared/components/RecombinationYScaleBar.js +34 -0
- package/esm/shared/components/RectBg.js +1 -1
- package/esm/shared/components/SetColorDialogRowPalettizer.d.ts +3 -8
- package/esm/shared/components/SetColorDialogRowPalettizer.js +2 -14
- package/esm/shared/components/SourcesDataGrid.js +4 -4
- package/esm/shared/components/TreeSidebar.js +11 -1
- package/esm/shared/drawAlleleCount.js +9 -0
- package/esm/shared/drawPhased.d.ts +1 -1
- package/esm/shared/drawPhased.js +31 -2
- package/esm/shared/getMultiVariantFeaturesAutorun.d.ts +1 -0
- package/esm/shared/getMultiVariantFeaturesAutorun.js +3 -0
- package/esm/shared/getMultiVariantSourcesAutorun.d.ts +1 -0
- package/esm/shared/getMultiVariantSourcesAutorun.js +3 -0
- package/esm/shared/getSources.d.ts +5 -9
- package/esm/shared/getSources.js +30 -25
- package/esm/shared/mafFilterUtils.d.ts +5 -0
- package/esm/shared/mafFilterUtils.js +17 -0
- package/esm/shared/minorAlleleFrequencyUtils.d.ts +2 -0
- package/esm/shared/minorAlleleFrequencyUtils.js +259 -17
- package/esm/shared/setupMultiVariantAutoruns.js +2 -0
- package/esm/shared/treeDrawingAutorun.d.ts +1 -0
- package/esm/shared/treeDrawingAutorun.js +7 -1
- package/esm/shared/types.d.ts +1 -2
- package/package.json +12 -11
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { LDMatrixResult, LDMetric } from './getLDMatrix.ts';
|
|
2
|
+
import type PluginManager from '@jbrowse/core/PluginManager';
|
|
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';
|
|
6
|
+
export declare function getLDMatrixFromPlink({ pluginManager, args, }: {
|
|
7
|
+
pluginManager: PluginManager;
|
|
8
|
+
args: {
|
|
9
|
+
adapterConfig: AnyConfigurationModel;
|
|
10
|
+
stopToken?: StopToken;
|
|
11
|
+
sessionId: string;
|
|
12
|
+
headers?: Record<string, string>;
|
|
13
|
+
regions: Region[];
|
|
14
|
+
ldMetric?: LDMetric;
|
|
15
|
+
};
|
|
16
|
+
}): Promise<LDMatrixResult>;
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
import { getAdapter } from '@jbrowse/core/data_adapters/dataAdapterCache';
|
|
2
|
+
export async function getLDMatrixFromPlink({ pluginManager, args, }) {
|
|
3
|
+
const { regions, adapterConfig, sessionId, ldMetric = 'r2' } = args;
|
|
4
|
+
const adapter = await getAdapter(pluginManager, sessionId, adapterConfig);
|
|
5
|
+
const dataAdapter = adapter.dataAdapter;
|
|
6
|
+
const allRecords = [];
|
|
7
|
+
for (const region of regions) {
|
|
8
|
+
const records = await dataAdapter.getLDRecordsInRegion({
|
|
9
|
+
refName: region.refName,
|
|
10
|
+
start: region.start,
|
|
11
|
+
end: region.end,
|
|
12
|
+
});
|
|
13
|
+
for (const r of records) {
|
|
14
|
+
allRecords.push(r);
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
const snpMap = new Map();
|
|
18
|
+
for (const record of allRecords) {
|
|
19
|
+
const keyA = `${record.chrA}:${record.bpA}`;
|
|
20
|
+
if (!snpMap.has(keyA)) {
|
|
21
|
+
snpMap.set(keyA, {
|
|
22
|
+
id: record.snpA,
|
|
23
|
+
refName: record.chrA,
|
|
24
|
+
start: record.bpA,
|
|
25
|
+
end: record.bpA + 1,
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
|
+
const keyB = `${record.chrB}:${record.bpB}`;
|
|
29
|
+
if (!snpMap.has(keyB)) {
|
|
30
|
+
snpMap.set(keyB, {
|
|
31
|
+
id: record.snpB,
|
|
32
|
+
refName: record.chrB,
|
|
33
|
+
start: record.bpB,
|
|
34
|
+
end: record.bpB + 1,
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
const snps = [...snpMap.values()].sort((a, b) => {
|
|
39
|
+
if (a.refName !== b.refName) {
|
|
40
|
+
return a.refName.localeCompare(b.refName);
|
|
41
|
+
}
|
|
42
|
+
return a.start - b.start;
|
|
43
|
+
});
|
|
44
|
+
const snpToIndex = new Map();
|
|
45
|
+
for (const [idx, snp] of snps.entries()) {
|
|
46
|
+
snpToIndex.set(`${snp.refName}:${snp.start}`, idx);
|
|
47
|
+
}
|
|
48
|
+
const n = snps.length;
|
|
49
|
+
const ldSize = (n * (n - 1)) / 2;
|
|
50
|
+
const ldValues = new Float32Array(ldSize);
|
|
51
|
+
ldValues.fill(Number.NaN);
|
|
52
|
+
const getLowerTriIndex = (i, j) => {
|
|
53
|
+
if (i <= j) {
|
|
54
|
+
;
|
|
55
|
+
[i, j] = [j, i];
|
|
56
|
+
}
|
|
57
|
+
return (i * (i - 1)) / 2 + j;
|
|
58
|
+
};
|
|
59
|
+
for (const record of allRecords) {
|
|
60
|
+
const keyA = `${record.chrA}:${record.bpA}`;
|
|
61
|
+
const keyB = `${record.chrB}:${record.bpB}`;
|
|
62
|
+
const idxA = snpToIndex.get(keyA);
|
|
63
|
+
const idxB = snpToIndex.get(keyB);
|
|
64
|
+
if (idxA !== undefined && idxB !== undefined && idxA !== idxB) {
|
|
65
|
+
const matrixIdx = getLowerTriIndex(idxA, idxB);
|
|
66
|
+
const value = ldMetric === 'dprime' ? (record.dprime ?? record.r2) : record.r2;
|
|
67
|
+
ldValues[matrixIdx] = value;
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
for (let i = 0; i < ldValues.length; i++) {
|
|
71
|
+
if (Number.isNaN(ldValues[i])) {
|
|
72
|
+
ldValues[i] = 0;
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
const recombValues = new Float32Array(Math.max(0, n - 1));
|
|
76
|
+
const recombPositions = [];
|
|
77
|
+
for (let i = 0; i < n - 1; i++) {
|
|
78
|
+
const snp1 = snps[i];
|
|
79
|
+
const snp2 = snps[i + 1];
|
|
80
|
+
const matrixIdx = getLowerTriIndex(i + 1, i);
|
|
81
|
+
const r2 = ldValues[matrixIdx] ?? 0;
|
|
82
|
+
recombValues[i] = 1 - r2;
|
|
83
|
+
recombPositions.push((snp1.start + snp2.start) / 2);
|
|
84
|
+
}
|
|
85
|
+
const recombination = {
|
|
86
|
+
values: recombValues,
|
|
87
|
+
positions: recombPositions,
|
|
88
|
+
};
|
|
89
|
+
const filterStats = {
|
|
90
|
+
filteredByCallRate: 0,
|
|
91
|
+
totalVariants: snps.length,
|
|
92
|
+
passedVariants: snps.length,
|
|
93
|
+
filteredByMaf: 0,
|
|
94
|
+
filteredByLength: 0,
|
|
95
|
+
filteredByMultiallelic: 0,
|
|
96
|
+
filteredByHwe: 0,
|
|
97
|
+
};
|
|
98
|
+
return {
|
|
99
|
+
snps,
|
|
100
|
+
ldValues,
|
|
101
|
+
metric: ldMetric,
|
|
102
|
+
filterStats,
|
|
103
|
+
recombination,
|
|
104
|
+
};
|
|
105
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { SampleInfo, Source } from '../shared/types.ts';
|
|
2
|
+
import type PluginManager from '@jbrowse/core/PluginManager';
|
|
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';
|
|
6
|
+
export declare function getPhasedGenotypeMatrix({ pluginManager, args, }: {
|
|
7
|
+
pluginManager: PluginManager;
|
|
8
|
+
args: {
|
|
9
|
+
adapterConfig: AnyConfigurationModel;
|
|
10
|
+
stopToken?: StopToken;
|
|
11
|
+
sessionId: string;
|
|
12
|
+
headers?: Record<string, string>;
|
|
13
|
+
regions: Region[];
|
|
14
|
+
sources: Source[];
|
|
15
|
+
bpPerPx: number;
|
|
16
|
+
minorAlleleFrequencyFilter: number;
|
|
17
|
+
lengthCutoffFilter: number;
|
|
18
|
+
sampleInfo: Record<string, SampleInfo>;
|
|
19
|
+
};
|
|
20
|
+
}): Promise<Record<string, number[]>>;
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { getAdapter } from '@jbrowse/core/data_adapters/dataAdapterCache';
|
|
2
|
+
import { checkStopToken2, createStopTokenChecker, } from '@jbrowse/core/util/stopToken';
|
|
3
|
+
import { firstValueFrom, toArray } from 'rxjs';
|
|
4
|
+
import { getFeaturesThatPassMinorAlleleFrequencyFilter } from "../shared/minorAlleleFrequencyUtils.js";
|
|
5
|
+
export async function getPhasedGenotypeMatrix({ pluginManager, args, }) {
|
|
6
|
+
const { sources, minorAlleleFrequencyFilter, regions, adapterConfig, sessionId, lengthCutoffFilter, stopToken, sampleInfo, } = args;
|
|
7
|
+
const lastCheck = createStopTokenChecker(stopToken);
|
|
8
|
+
const adapter = await getAdapter(pluginManager, sessionId, adapterConfig);
|
|
9
|
+
const dataAdapter = adapter.dataAdapter;
|
|
10
|
+
const rows = {};
|
|
11
|
+
const splitCache = {};
|
|
12
|
+
for (const { name } of sources) {
|
|
13
|
+
const info = sampleInfo[name];
|
|
14
|
+
const ploidy = info?.maxPloidy ?? 2;
|
|
15
|
+
for (let hp = 0; hp < ploidy; hp++) {
|
|
16
|
+
rows[`${name} HP${hp}`] = [];
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
const mafs = getFeaturesThatPassMinorAlleleFrequencyFilter({
|
|
20
|
+
minorAlleleFrequencyFilter,
|
|
21
|
+
lengthCutoffFilter,
|
|
22
|
+
lastCheck,
|
|
23
|
+
splitCache,
|
|
24
|
+
features: await firstValueFrom(dataAdapter.getFeaturesInMultipleRegions(regions, args).pipe(toArray())),
|
|
25
|
+
});
|
|
26
|
+
for (const { feature } of mafs) {
|
|
27
|
+
const genotypes = feature.get('genotypes');
|
|
28
|
+
for (const { name } of sources) {
|
|
29
|
+
const val = genotypes[name];
|
|
30
|
+
const info = sampleInfo[name];
|
|
31
|
+
const ploidy = info?.maxPloidy ?? 2;
|
|
32
|
+
const isPhased = val.includes('|');
|
|
33
|
+
if (isPhased) {
|
|
34
|
+
const alleles = splitCache[val] ?? (splitCache[val] = val.split('|'));
|
|
35
|
+
for (let hp = 0; hp < ploidy; hp++) {
|
|
36
|
+
const allele = alleles[hp];
|
|
37
|
+
const value = allele === '.' || allele === undefined ? -1 : +allele;
|
|
38
|
+
rows[`${name} HP${hp}`].push(value);
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
else {
|
|
42
|
+
for (let hp = 0; hp < ploidy; hp++) {
|
|
43
|
+
rows[`${name} HP${hp}`].push(-1);
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
checkStopToken2(lastCheck);
|
|
48
|
+
}
|
|
49
|
+
return rows;
|
|
50
|
+
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { IntervalTree } from '@flatten-js/interval-tree';
|
|
2
1
|
import VcfParser from '@gmod/vcf';
|
|
3
2
|
import { BaseFeatureDataAdapter } from '@jbrowse/core/data_adapters/BaseAdapter';
|
|
3
|
+
import { IntervalTree } from '@jbrowse/core/util';
|
|
4
4
|
import type { BaseOptions } from '@jbrowse/core/data_adapters/BaseAdapter';
|
|
5
5
|
import type { Feature, Region } from '@jbrowse/core/util';
|
|
6
6
|
import type { StatusCallback } from '@jbrowse/core/util/parseLineByLine';
|
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
import { IntervalTree } from '@flatten-js/interval-tree';
|
|
2
1
|
import VcfParser from '@gmod/vcf';
|
|
3
2
|
import { BaseFeatureDataAdapter } from '@jbrowse/core/data_adapters/BaseAdapter';
|
|
4
|
-
import { fetchAndMaybeUnzip } from '@jbrowse/core/util';
|
|
3
|
+
import { IntervalTree, fetchAndMaybeUnzip } from '@jbrowse/core/util';
|
|
5
4
|
import { openLocation } from '@jbrowse/core/util/io';
|
|
6
5
|
import { ObservableCreate } from '@jbrowse/core/util/rxjs';
|
|
7
6
|
import { parseVcfBuffer } from "./vcfParser.js";
|
|
@@ -21,6 +21,28 @@ export default function VcfExtensionPointsF(pluginManager) {
|
|
|
21
21
|
vcfLocation: file,
|
|
22
22
|
};
|
|
23
23
|
}
|
|
24
|
+
else if (testAdapter(fileName, /\.ld\.b?gz$/i, adapterHint, 'PlinkLDTabixAdapter')) {
|
|
25
|
+
return {
|
|
26
|
+
type: 'PlinkLDTabixAdapter',
|
|
27
|
+
ldLocation: file,
|
|
28
|
+
index: {
|
|
29
|
+
location: index || makeIndex(file, '.tbi'),
|
|
30
|
+
indexType: makeIndexType(indexName, 'CSI', 'TBI'),
|
|
31
|
+
},
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
else if (testAdapter(fileName, /\.ld$/i, adapterHint, 'PlinkLDAdapter')) {
|
|
35
|
+
return {
|
|
36
|
+
type: 'PlinkLDAdapter',
|
|
37
|
+
ldLocation: file,
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
else if (testAdapter(fileName, /\.h5$/i, adapterHint, 'LdmatAdapter')) {
|
|
41
|
+
return {
|
|
42
|
+
type: 'LdmatAdapter',
|
|
43
|
+
ldmatLocation: file,
|
|
44
|
+
};
|
|
45
|
+
}
|
|
24
46
|
else {
|
|
25
47
|
return adapterGuesser(file, index, adapterHint);
|
|
26
48
|
}
|
|
@@ -28,9 +50,13 @@ export default function VcfExtensionPointsF(pluginManager) {
|
|
|
28
50
|
});
|
|
29
51
|
pluginManager.addToExtensionPoint('Core-guessTrackTypeForLocation', (trackTypeGuesser) => {
|
|
30
52
|
return (adapterName) => {
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
53
|
+
if (['VcfTabixAdapter', 'VcfAdapter'].includes(adapterName)) {
|
|
54
|
+
return 'VariantTrack';
|
|
55
|
+
}
|
|
56
|
+
if (['PlinkLDAdapter', 'PlinkLDTabixAdapter', 'LdmatAdapter'].includes(adapterName)) {
|
|
57
|
+
return 'LDTrack';
|
|
58
|
+
}
|
|
59
|
+
return trackTypeGuesser(adapterName);
|
|
34
60
|
};
|
|
35
61
|
});
|
|
36
62
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { type Feature } from '@jbrowse/core/util';
|
|
2
2
|
import type VCFParser from '@gmod/vcf';
|
|
3
|
-
import type { Variant } from '@gmod/vcf';
|
|
3
|
+
import type { GenotypeCallback, Variant } from '@gmod/vcf';
|
|
4
4
|
export default class VCFFeature implements Feature {
|
|
5
5
|
private variant;
|
|
6
6
|
private parser;
|
|
@@ -15,5 +15,6 @@ export default class VCFFeature implements Feature {
|
|
|
15
15
|
parent(): undefined;
|
|
16
16
|
children(): undefined;
|
|
17
17
|
id(): string;
|
|
18
|
+
processGenotypes(callback: GenotypeCallback): void;
|
|
18
19
|
toJSON(): any;
|
|
19
20
|
}
|
package/esm/VcfFeature/index.js
CHANGED
|
@@ -77,11 +77,13 @@ export default class VCFFeature {
|
|
|
77
77
|
id() {
|
|
78
78
|
return this._id;
|
|
79
79
|
}
|
|
80
|
+
processGenotypes(callback) {
|
|
81
|
+
this.variant.processGenotypes(callback);
|
|
82
|
+
}
|
|
80
83
|
toJSON() {
|
|
81
|
-
const { SAMPLES, GENOTYPES, ...rest } = this.variant;
|
|
82
84
|
return {
|
|
83
85
|
uniqueId: this._id,
|
|
84
|
-
...
|
|
86
|
+
...this.variant.toJSON(),
|
|
85
87
|
...this.data,
|
|
86
88
|
samples: this.variant.SAMPLES(),
|
|
87
89
|
};
|
package/esm/index.d.ts
CHANGED
|
@@ -3,5 +3,6 @@ import type PluginManager from '@jbrowse/core/PluginManager';
|
|
|
3
3
|
export default class VariantsPlugin extends Plugin {
|
|
4
4
|
name: string;
|
|
5
5
|
install(pluginManager: PluginManager): void;
|
|
6
|
+
configure(pluginManager: PluginManager): void;
|
|
6
7
|
}
|
|
7
8
|
export { default as VcfFeature } from './VcfFeature/index.ts';
|
package/esm/index.js
CHANGED
|
@@ -1,14 +1,19 @@
|
|
|
1
1
|
import Plugin from '@jbrowse/core/Plugin';
|
|
2
2
|
import ChordVariantDisplayF from "./ChordVariantDisplay/index.js";
|
|
3
|
+
import LDDisplayF from "./LDDisplay/index.js";
|
|
4
|
+
import LDRendererF from "./LDRenderer/index.js";
|
|
5
|
+
import LDTrackF from "./LDTrack/index.js";
|
|
3
6
|
import LinearVariantDisplayF from "./LinearVariantDisplay/index.js";
|
|
4
7
|
import MultiLinearVariantDisplayF from "./MultiLinearVariantDisplay/index.js";
|
|
5
8
|
import LinearVariantMatrixDisplayF from "./MultiLinearVariantMatrixDisplay/index.js";
|
|
6
9
|
import LinearVariantMatrixRendererF from "./MultiLinearVariantMatrixRenderer/index.js";
|
|
7
10
|
import MultiVariantRendererF from "./MultiLinearVariantRenderer/index.js";
|
|
11
|
+
import PlinkLDAdapterF from "./PlinkLDAdapter/index.js";
|
|
8
12
|
import SplitVcfTabixAdapterF from "./SplitVcfTabixAdapter/index.js";
|
|
9
13
|
import StructuralVariantChordRendererF from "./StructuralVariantChordRenderer/index.js";
|
|
10
14
|
import VariantFeatureWidgetF from "./VariantFeatureWidget/index.js";
|
|
11
15
|
import { MultiVariantClusterGenotypeMatrix } from "./VariantRPC/MultiVariantClusterGenotypeMatrix.js";
|
|
16
|
+
import { MultiVariantGetFeatureDetails } from "./VariantRPC/MultiVariantGetFeatureDetails.js";
|
|
12
17
|
import { MultiVariantGetGenotypeMatrix } from "./VariantRPC/MultiVariantGetGenotypeMatrix.js";
|
|
13
18
|
import { MultiVariantGetSimplifiedFeatures } from "./VariantRPC/MultiVariantGetSimplifiedFeatures.js";
|
|
14
19
|
import { MultiVariantGetSources } from "./VariantRPC/MultiVariantGetSources.js";
|
|
@@ -16,18 +21,23 @@ import VariantTrackF from "./VariantTrack/index.js";
|
|
|
16
21
|
import VcfAdapterF from "./VcfAdapter/index.js";
|
|
17
22
|
import ExtensionPointsF from "./VcfExtensionPoints/index.js";
|
|
18
23
|
import VcfTabixAdapterF from "./VcfTabixAdapter/index.js";
|
|
24
|
+
import { calculateAlleleCounts, calculateMinorAlleleFrequency, } from "./shared/minorAlleleFrequencyUtils.js";
|
|
19
25
|
export default class VariantsPlugin extends Plugin {
|
|
20
26
|
name = 'VariantsPlugin';
|
|
21
27
|
install(pluginManager) {
|
|
22
28
|
VcfAdapterF(pluginManager);
|
|
23
29
|
VcfTabixAdapterF(pluginManager);
|
|
24
30
|
SplitVcfTabixAdapterF(pluginManager);
|
|
31
|
+
PlinkLDAdapterF(pluginManager);
|
|
25
32
|
VariantFeatureWidgetF(pluginManager);
|
|
26
33
|
VariantTrackF(pluginManager);
|
|
34
|
+
LDTrackF(pluginManager);
|
|
27
35
|
ExtensionPointsF(pluginManager);
|
|
28
36
|
LinearVariantDisplayF(pluginManager);
|
|
29
37
|
LinearVariantMatrixDisplayF(pluginManager);
|
|
30
38
|
MultiLinearVariantDisplayF(pluginManager);
|
|
39
|
+
LDDisplayF(pluginManager);
|
|
40
|
+
LDRendererF(pluginManager);
|
|
31
41
|
MultiVariantRendererF(pluginManager);
|
|
32
42
|
LinearVariantMatrixRendererF(pluginManager);
|
|
33
43
|
StructuralVariantChordRendererF(pluginManager);
|
|
@@ -36,6 +46,19 @@ export default class VariantsPlugin extends Plugin {
|
|
|
36
46
|
pluginManager.addRpcMethod(() => new MultiVariantGetGenotypeMatrix(pluginManager));
|
|
37
47
|
pluginManager.addRpcMethod(() => new MultiVariantClusterGenotypeMatrix(pluginManager));
|
|
38
48
|
pluginManager.addRpcMethod(() => new MultiVariantGetSimplifiedFeatures(pluginManager));
|
|
49
|
+
pluginManager.addRpcMethod(() => new MultiVariantGetFeatureDetails(pluginManager));
|
|
50
|
+
}
|
|
51
|
+
configure(pluginManager) {
|
|
52
|
+
const { jexl } = pluginManager;
|
|
53
|
+
const splitCache = {};
|
|
54
|
+
jexl.addFunction('maf', (feature) => {
|
|
55
|
+
const genotypes = feature.get('genotypes');
|
|
56
|
+
if (!genotypes) {
|
|
57
|
+
return 0;
|
|
58
|
+
}
|
|
59
|
+
const alleleCounts = calculateAlleleCounts(genotypes, splitCache);
|
|
60
|
+
return calculateMinorAlleleFrequency(alleleCounts);
|
|
61
|
+
});
|
|
39
62
|
}
|
|
40
63
|
}
|
|
41
64
|
export { default as VcfFeature } from "./VcfFeature/index.js";
|