@jbrowse/plugin-variants 3.2.0 → 3.3.0
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/dist/MultiLinearVariantDisplay/components/VariantDisplayComponent.js +3 -3
- package/dist/MultiLinearVariantDisplay/index.js +1 -1
- package/dist/MultiLinearVariantDisplay/model.d.ts +39 -3
- package/dist/MultiLinearVariantDisplay/model.js +0 -1
- package/dist/MultiLinearVariantDisplay/renderSvg.js +2 -2
- package/dist/MultiLinearVariantMatrixDisplay/components/LinesConnectingMatrixToGenomicPosition.js +15 -5
- package/dist/MultiLinearVariantMatrixDisplay/components/VariantDisplayComponent.js +3 -3
- package/dist/MultiLinearVariantMatrixDisplay/index.js +1 -1
- package/dist/MultiLinearVariantMatrixDisplay/model.d.ts +39 -2
- package/dist/MultiLinearVariantMatrixDisplay/model.js +1 -0
- package/dist/MultiLinearVariantMatrixDisplay/renderSvg.js +2 -2
- package/dist/MultiLinearVariantMatrixRenderer/{LinearVariantMatrixRenderer.d.ts → MultiLinearVariantMatrixRenderer.d.ts} +7 -3
- package/dist/MultiLinearVariantMatrixRenderer/components/MultiLinearVariantMatrixRendering.d.ts +8 -0
- package/dist/MultiLinearVariantMatrixRenderer/components/MultiLinearVariantMatrixRendering.js +41 -0
- package/dist/MultiLinearVariantMatrixRenderer/index.js +4 -4
- package/dist/MultiLinearVariantMatrixRenderer/makeImageData.d.ts +2 -2
- package/dist/MultiLinearVariantMatrixRenderer/makeImageData.js +12 -13
- package/dist/MultiLinearVariantMatrixRenderer/types.d.ts +2 -4
- package/dist/MultiLinearVariantRenderer/MultiVariantRenderer.d.ts +30 -1
- package/dist/MultiLinearVariantRenderer/MultiVariantRenderer.js +11 -5
- package/dist/MultiLinearVariantRenderer/components/{MultiVariantRendering.d.ts → MultiLinearVariantRendering.d.ts} +10 -4
- package/dist/MultiLinearVariantRenderer/{MultiVariantRendering.js → components/MultiLinearVariantRendering.js} +25 -7
- package/dist/MultiLinearVariantRenderer/components/util.d.ts +1 -0
- package/dist/MultiLinearVariantRenderer/components/util.js +15 -0
- package/dist/MultiLinearVariantRenderer/index.js +2 -2
- package/dist/MultiLinearVariantRenderer/makeImageData.d.ts +9 -0
- package/dist/MultiLinearVariantRenderer/makeImageData.js +60 -28
- package/dist/MultiLinearVariantRenderer/types.d.ts +1 -0
- package/dist/SplitVcfTabixAdapter/configSchema.js +4 -2
- package/dist/VariantFeatureWidget/AltFormatter.d.ts +4 -0
- package/dist/VariantFeatureWidget/AltFormatter.js +13 -0
- package/dist/VariantFeatureWidget/Checkbox2.js +1 -8
- package/dist/VariantFeatureWidget/Formatter.d.ts +3 -0
- package/dist/VariantFeatureWidget/Formatter.js +23 -0
- package/dist/VariantFeatureWidget/{VariantConsequenceDataGridWrapper.js → VariantConsequence/VariantConsequenceDataGridWrapper.js} +3 -5
- package/dist/VariantFeatureWidget/VariantFeatureWidget.js +7 -2
- package/dist/VariantFeatureWidget/VariantSampleGrid/VariantGenotypeFrequencyTable.d.ts +4 -0
- package/dist/VariantFeatureWidget/VariantSampleGrid/VariantGenotypeFrequencyTable.js +80 -0
- package/dist/VariantFeatureWidget/VariantSampleGrid/VariantSampleGrid.d.ts +3 -9
- package/dist/VariantFeatureWidget/VariantSampleGrid/VariantSampleGrid.js +41 -20
- package/dist/VariantFeatureWidget/VariantSampleGrid/types.d.ts +21 -0
- package/dist/VariantFeatureWidget/VariantSampleGrid/util.d.ts +1 -0
- package/dist/VariantFeatureWidget/VariantSampleGrid/util.js +14 -0
- package/dist/VariantRPC/MultiVariantClusterGenotypeMatrix.d.ts +2 -16
- package/dist/VariantRPC/MultiVariantClusterGenotypeMatrix.js +4 -7
- package/dist/VariantRPC/MultiVariantGetGenotypeMatrix.d.ts +2 -15
- package/dist/VariantRPC/MultiVariantGetSimplifiedFeatures.d.ts +3 -13
- package/dist/VariantRPC/MultiVariantGetSimplifiedFeatures.js +14 -8
- package/dist/VariantRPC/getGenotypeMatrix.js +10 -5
- package/dist/VariantRPC/types.d.ts +23 -0
- package/dist/VcfFeature/index.js +0 -1
- package/dist/VcfFeature/util.d.ts +2 -0
- package/dist/VcfFeature/util.js +123 -25
- package/dist/VcfTabixAdapter/VcfTabixAdapter.js +12 -7
- package/dist/getMultiVariantFeaturesAutorun.d.ts +2 -0
- package/dist/getMultiVariantFeaturesAutorun.js +9 -2
- package/dist/getMultiVariantSourcesAutorun.js +3 -2
- package/dist/shared/MultiVariantBaseModel.d.ts +40 -3
- package/dist/shared/MultiVariantBaseModel.js +69 -3
- package/dist/shared/components/AddFiltersDialog.d.ts +9 -0
- package/dist/shared/components/AddFiltersDialog.js +61 -0
- package/dist/shared/components/MultiVariantBaseDisplayComponent.d.ts +5 -0
- package/dist/shared/components/MultiVariantBaseDisplayComponent.js +29 -0
- package/dist/shared/components/{ClusterDialog → MultiVariantClusterDialog}/ClusterDialog.js +2 -2
- package/dist/shared/components/{ClusterDialog → MultiVariantClusterDialog}/ClusterDialogAuto.js +8 -3
- package/dist/shared/components/{ClusterDialog → MultiVariantClusterDialog}/ClusterDialogManual.js +29 -28
- package/dist/shared/components/{ClusterDialog → MultiVariantClusterDialog}/types.d.ts +1 -0
- package/dist/shared/components/MultiVariantClusterDialog/types.js +2 -0
- package/{esm/shared/components/ColorLegend.d.ts → dist/shared/components/MultiVariantColorLegend.d.ts} +2 -2
- package/dist/shared/components/{ColorLegend.js → MultiVariantColorLegend.js} +5 -3
- package/dist/shared/components/MultiVariantCrosshairs.d.ts +7 -0
- package/dist/shared/components/MultiVariantCrosshairs.js +40 -0
- package/dist/shared/components/MultiVariantLegendBar.d.ts +7 -0
- package/dist/shared/components/{LegendBar.js → MultiVariantLegendBar.js} +2 -2
- package/dist/shared/components/MultiVariantTooltip.d.ts +4 -0
- package/dist/shared/components/MultiVariantTooltip.js +3 -2
- package/dist/shared/components/RectBg.js +4 -2
- package/dist/shared/components/SetColorDialog.js +1 -1
- package/dist/shared/components/SourcesDataGrid.d.ts +2 -1
- package/dist/shared/components/SourcesDataGrid.js +40 -47
- package/dist/shared/components/SourcesGrid.js +1 -1
- package/dist/shared/components/SourcesGridHeader.d.ts +2 -1
- package/dist/shared/drawAlleleCount.d.ts +1 -1
- package/dist/shared/drawAlleleCount.js +29 -5
- package/dist/shared/drawPhased.d.ts +1 -1
- package/dist/shared/drawPhased.js +14 -10
- package/dist/shared/minorAlleleFrequencyUtils.d.ts +6 -1
- package/dist/shared/minorAlleleFrequencyUtils.js +4 -5
- package/dist/shared/sourcesGridUtils.d.ts +3 -2
- package/esm/MultiLinearVariantDisplay/components/VariantDisplayComponent.js +2 -2
- package/esm/MultiLinearVariantDisplay/index.js +1 -1
- package/esm/MultiLinearVariantDisplay/model.d.ts +39 -3
- package/esm/MultiLinearVariantDisplay/model.js +0 -1
- package/esm/MultiLinearVariantDisplay/renderSvg.js +1 -1
- package/esm/MultiLinearVariantMatrixDisplay/components/LinesConnectingMatrixToGenomicPosition.js +15 -8
- package/esm/MultiLinearVariantMatrixDisplay/components/VariantDisplayComponent.js +2 -2
- package/esm/MultiLinearVariantMatrixDisplay/index.js +1 -1
- package/esm/MultiLinearVariantMatrixDisplay/model.d.ts +39 -2
- package/esm/MultiLinearVariantMatrixDisplay/model.js +1 -0
- package/esm/MultiLinearVariantMatrixDisplay/renderSvg.js +1 -1
- package/esm/MultiLinearVariantMatrixRenderer/{LinearVariantMatrixRenderer.d.ts → MultiLinearVariantMatrixRenderer.d.ts} +7 -3
- package/esm/MultiLinearVariantMatrixRenderer/components/MultiLinearVariantMatrixRendering.d.ts +8 -0
- package/esm/MultiLinearVariantMatrixRenderer/components/MultiLinearVariantMatrixRendering.js +39 -0
- package/esm/MultiLinearVariantMatrixRenderer/index.js +4 -4
- package/esm/MultiLinearVariantMatrixRenderer/makeImageData.d.ts +2 -2
- package/esm/MultiLinearVariantMatrixRenderer/makeImageData.js +13 -14
- package/esm/MultiLinearVariantMatrixRenderer/types.d.ts +2 -4
- package/esm/MultiLinearVariantRenderer/MultiVariantRenderer.d.ts +30 -1
- package/esm/MultiLinearVariantRenderer/MultiVariantRenderer.js +11 -5
- package/esm/MultiLinearVariantRenderer/components/{MultiVariantRendering.d.ts → MultiLinearVariantRendering.d.ts} +10 -4
- package/esm/MultiLinearVariantRenderer/components/{MultiVariantRendering.js → MultiLinearVariantRendering.js} +25 -7
- package/esm/MultiLinearVariantRenderer/components/util.d.ts +1 -0
- package/esm/MultiLinearVariantRenderer/components/util.js +12 -0
- package/esm/MultiLinearVariantRenderer/index.js +1 -1
- package/esm/MultiLinearVariantRenderer/makeImageData.d.ts +9 -0
- package/esm/MultiLinearVariantRenderer/makeImageData.js +61 -29
- package/esm/MultiLinearVariantRenderer/types.d.ts +1 -0
- package/esm/SplitVcfTabixAdapter/configSchema.js +4 -2
- package/esm/VariantFeatureWidget/AltFormatter.d.ts +4 -0
- package/esm/VariantFeatureWidget/AltFormatter.js +10 -0
- package/esm/VariantFeatureWidget/Checkbox2.js +2 -9
- package/esm/VariantFeatureWidget/Formatter.d.ts +3 -0
- package/esm/VariantFeatureWidget/Formatter.js +17 -0
- package/esm/VariantFeatureWidget/{VariantConsequenceDataGridWrapper.js → VariantConsequence/VariantConsequenceDataGridWrapper.js} +4 -6
- package/esm/VariantFeatureWidget/VariantFeatureWidget.js +7 -2
- package/esm/VariantFeatureWidget/VariantSampleGrid/VariantGenotypeFrequencyTable.d.ts +4 -0
- package/esm/VariantFeatureWidget/VariantSampleGrid/VariantGenotypeFrequencyTable.js +74 -0
- package/esm/VariantFeatureWidget/VariantSampleGrid/VariantSampleGrid.d.ts +3 -9
- package/esm/VariantFeatureWidget/VariantSampleGrid/VariantSampleGrid.js +43 -22
- package/esm/VariantFeatureWidget/VariantSampleGrid/types.d.ts +21 -0
- package/esm/VariantFeatureWidget/VariantSampleGrid/util.d.ts +1 -0
- package/esm/VariantFeatureWidget/VariantSampleGrid/util.js +11 -0
- package/esm/VariantRPC/MultiVariantClusterGenotypeMatrix.d.ts +2 -16
- package/esm/VariantRPC/MultiVariantClusterGenotypeMatrix.js +4 -7
- package/esm/VariantRPC/MultiVariantGetGenotypeMatrix.d.ts +2 -15
- package/esm/VariantRPC/MultiVariantGetSimplifiedFeatures.d.ts +3 -13
- package/esm/VariantRPC/MultiVariantGetSimplifiedFeatures.js +14 -8
- package/esm/VariantRPC/getGenotypeMatrix.js +10 -5
- package/esm/VariantRPC/types.d.ts +23 -0
- package/esm/VcfFeature/index.js +0 -1
- package/esm/VcfFeature/util.d.ts +2 -0
- package/esm/VcfFeature/util.js +121 -25
- package/esm/VcfTabixAdapter/VcfTabixAdapter.js +13 -8
- package/esm/getMultiVariantFeaturesAutorun.d.ts +2 -0
- package/esm/getMultiVariantFeaturesAutorun.js +9 -2
- package/esm/getMultiVariantSourcesAutorun.js +3 -2
- package/esm/shared/MultiVariantBaseModel.d.ts +40 -3
- package/esm/shared/MultiVariantBaseModel.js +71 -5
- package/esm/shared/components/AddFiltersDialog.d.ts +9 -0
- package/esm/shared/components/AddFiltersDialog.js +59 -0
- package/esm/shared/components/MultiVariantBaseDisplayComponent.d.ts +5 -0
- package/esm/shared/components/MultiVariantBaseDisplayComponent.js +24 -0
- package/esm/shared/components/{ClusterDialog → MultiVariantClusterDialog}/ClusterDialog.js +2 -2
- package/esm/shared/components/{ClusterDialog → MultiVariantClusterDialog}/ClusterDialogAuto.js +9 -4
- package/esm/shared/components/{ClusterDialog → MultiVariantClusterDialog}/ClusterDialogManual.js +29 -28
- package/esm/shared/components/{ClusterDialog → MultiVariantClusterDialog}/types.d.ts +1 -0
- package/esm/shared/components/MultiVariantClusterDialog/types.js +1 -0
- package/{dist/shared/components/ColorLegend.d.ts → esm/shared/components/MultiVariantColorLegend.d.ts} +2 -2
- package/esm/shared/components/{ColorLegend.js → MultiVariantColorLegend.js} +6 -4
- package/esm/shared/components/MultiVariantCrosshairs.d.ts +7 -0
- package/esm/shared/components/MultiVariantCrosshairs.js +35 -0
- package/esm/shared/components/MultiVariantLegendBar.d.ts +7 -0
- package/esm/shared/components/{LegendBar.js → MultiVariantLegendBar.js} +1 -1
- package/esm/shared/components/MultiVariantTooltip.d.ts +4 -0
- package/esm/shared/components/MultiVariantTooltip.js +3 -2
- package/esm/shared/components/RectBg.js +4 -2
- package/esm/shared/components/SetColorDialog.js +1 -1
- package/esm/shared/components/SourcesDataGrid.d.ts +2 -1
- package/esm/shared/components/SourcesDataGrid.js +40 -47
- package/esm/shared/components/SourcesGrid.js +1 -1
- package/esm/shared/components/SourcesGridHeader.d.ts +2 -1
- package/esm/shared/drawAlleleCount.d.ts +1 -1
- package/esm/shared/drawAlleleCount.js +29 -5
- package/esm/shared/drawPhased.d.ts +1 -1
- package/esm/shared/drawPhased.js +14 -10
- package/esm/shared/minorAlleleFrequencyUtils.d.ts +6 -1
- package/esm/shared/minorAlleleFrequencyUtils.js +5 -6
- package/esm/shared/sourcesGridUtils.d.ts +3 -2
- package/package.json +10 -9
- package/dist/MultiLinearVariantDisplay/components/Crosshair.d.ts +0 -7
- package/dist/MultiLinearVariantDisplay/components/Crosshair.js +0 -35
- package/dist/MultiLinearVariantMatrixDisplay/components/Crosshair.d.ts +0 -7
- package/dist/MultiLinearVariantMatrixDisplay/components/Crosshair.js +0 -28
- package/dist/MultiLinearVariantMatrixRenderer/components/LinearVariantMatrixRendering.d.ts +0 -7
- package/dist/MultiLinearVariantMatrixRenderer/components/LinearVariantMatrixRendering.js +0 -38
- package/dist/MultiLinearVariantRenderer/MultiVariantRendering.d.ts +0 -22
- package/dist/MultiLinearVariantRenderer/components/MultiVariantRendering.js +0 -52
- package/dist/VariantFeatureWidget/VariantConsequencePanel.d.ts +0 -5
- package/dist/VariantFeatureWidget/VariantConsequencePanel.js +0 -15
- package/dist/VariantRPC/cluster.d.ts +0 -17
- package/dist/VariantRPC/cluster.js +0 -84
- package/dist/shared/components/LegendBar.d.ts +0 -18
- package/esm/MultiLinearVariantDisplay/components/Crosshair.d.ts +0 -7
- package/esm/MultiLinearVariantDisplay/components/Crosshair.js +0 -30
- package/esm/MultiLinearVariantMatrixDisplay/components/Crosshair.d.ts +0 -7
- package/esm/MultiLinearVariantMatrixDisplay/components/Crosshair.js +0 -23
- package/esm/MultiLinearVariantMatrixRenderer/components/LinearVariantMatrixRendering.d.ts +0 -7
- package/esm/MultiLinearVariantMatrixRenderer/components/LinearVariantMatrixRendering.js +0 -36
- package/esm/MultiLinearVariantRenderer/MultiVariantRendering.d.ts +0 -22
- package/esm/MultiLinearVariantRenderer/MultiVariantRendering.js +0 -47
- package/esm/VariantFeatureWidget/VariantConsequencePanel.d.ts +0 -5
- package/esm/VariantFeatureWidget/VariantConsequencePanel.js +0 -9
- package/esm/VariantRPC/cluster.d.ts +0 -17
- package/esm/VariantRPC/cluster.js +0 -79
- package/esm/shared/components/LegendBar.d.ts +0 -18
- /package/dist/MultiLinearVariantMatrixRenderer/{LinearVariantMatrixRenderer.js → MultiLinearVariantMatrixRenderer.js} +0 -0
- /package/dist/VariantFeatureWidget/{VariantConsequenceDataGrid.d.ts → VariantConsequence/VariantConsequenceDataGrid.d.ts} +0 -0
- /package/dist/VariantFeatureWidget/{VariantConsequenceDataGrid.js → VariantConsequence/VariantConsequenceDataGrid.js} +0 -0
- /package/dist/VariantFeatureWidget/{VariantConsequenceDataGridWrapper.d.ts → VariantConsequence/VariantConsequenceDataGridWrapper.d.ts} +0 -0
- /package/dist/{shared/components/ClusterDialog → VariantFeatureWidget/VariantSampleGrid}/types.js +0 -0
- /package/dist/shared/components/{ClusterDialog → MultiVariantClusterDialog}/ClusterDialog.d.ts +0 -0
- /package/dist/shared/components/{ClusterDialog → MultiVariantClusterDialog}/ClusterDialogAuto.d.ts +0 -0
- /package/dist/shared/components/{ClusterDialog → MultiVariantClusterDialog}/ClusterDialogManual.d.ts +0 -0
- /package/esm/MultiLinearVariantMatrixRenderer/{LinearVariantMatrixRenderer.js → MultiLinearVariantMatrixRenderer.js} +0 -0
- /package/esm/VariantFeatureWidget/{VariantConsequenceDataGrid.d.ts → VariantConsequence/VariantConsequenceDataGrid.d.ts} +0 -0
- /package/esm/VariantFeatureWidget/{VariantConsequenceDataGrid.js → VariantConsequence/VariantConsequenceDataGrid.js} +0 -0
- /package/esm/VariantFeatureWidget/{VariantConsequenceDataGridWrapper.d.ts → VariantConsequence/VariantConsequenceDataGridWrapper.d.ts} +0 -0
- /package/esm/{shared/components/ClusterDialog → VariantFeatureWidget/VariantSampleGrid}/types.js +0 -0
- /package/esm/shared/components/{ClusterDialog → MultiVariantClusterDialog}/ClusterDialog.d.ts +0 -0
- /package/esm/shared/components/{ClusterDialog → MultiVariantClusterDialog}/ClusterDialogAuto.d.ts +0 -0
- /package/esm/shared/components/{ClusterDialog → MultiVariantClusterDialog}/ClusterDialogManual.d.ts +0 -0
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { useState } from 'react';
|
|
3
|
+
import DataGridFlexContainer from '@jbrowse/core/ui/DataGridFlexContainer';
|
|
4
|
+
import { measureGridWidth } from '@jbrowse/core/util';
|
|
5
|
+
import { Checkbox, FormControlLabel, Typography } from '@mui/material';
|
|
6
|
+
import { DataGrid } from '@mui/x-data-grid';
|
|
7
|
+
function toP(n) {
|
|
8
|
+
return n.toPrecision(3);
|
|
9
|
+
}
|
|
10
|
+
export default function VariantGenotypeFrequencyTable({ rows, }) {
|
|
11
|
+
const [useCounts, setUseCounts] = useState(false);
|
|
12
|
+
const summary = {};
|
|
13
|
+
if (!useCounts) {
|
|
14
|
+
for (const row of rows) {
|
|
15
|
+
const gt = row.GT;
|
|
16
|
+
if (!summary[gt]) {
|
|
17
|
+
summary[gt] = {
|
|
18
|
+
count: 0,
|
|
19
|
+
GT: row.GT,
|
|
20
|
+
genotype: row.genotype,
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
summary[gt].count++;
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
else {
|
|
27
|
+
for (const row of rows) {
|
|
28
|
+
const alleleCounts = {};
|
|
29
|
+
const alleles = row.GT.split(/[/|]/);
|
|
30
|
+
for (const allele of alleles) {
|
|
31
|
+
alleleCounts[allele] = (alleleCounts[allele] || 0) + 1;
|
|
32
|
+
}
|
|
33
|
+
const key = Object.entries(alleleCounts)
|
|
34
|
+
.map(([key, val]) => `${key}:${val}`)
|
|
35
|
+
.join(';');
|
|
36
|
+
if (!summary[key]) {
|
|
37
|
+
summary[key] = {
|
|
38
|
+
count: 0,
|
|
39
|
+
GT: key,
|
|
40
|
+
genotype: row.genotype,
|
|
41
|
+
};
|
|
42
|
+
}
|
|
43
|
+
summary[key].count++;
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
const gridRows = Object.entries(summary).map(([key, val]) => ({
|
|
47
|
+
id: key,
|
|
48
|
+
...val,
|
|
49
|
+
count: `${val.count} / ${rows.length}`,
|
|
50
|
+
frequency: `${toP((val.count / rows.length) * 100)}%`,
|
|
51
|
+
}));
|
|
52
|
+
const keys = gridRows[0] ? Object.keys(gridRows[0]) : [];
|
|
53
|
+
const widths = keys.map(e => measureGridWidth(gridRows.map(r => `${r[e]}`)));
|
|
54
|
+
return (_jsxs("div", { children: [_jsx(FormControlLabel, { control: _jsx(Checkbox, { checked: useCounts }), label: _jsx(Typography, { variant: "body2", children: "Use allele counts instead of exact GT" }), onChange: (_, checked) => {
|
|
55
|
+
setUseCounts(checked);
|
|
56
|
+
} }), _jsx(DataGridFlexContainer, { children: _jsx(DataGrid, { rows: gridRows, hideFooter: true, rowHeight: 25, columnHeaderHeight: 35, columns: [
|
|
57
|
+
{
|
|
58
|
+
field: 'GT',
|
|
59
|
+
width: widths[0],
|
|
60
|
+
},
|
|
61
|
+
{
|
|
62
|
+
field: 'count',
|
|
63
|
+
width: widths[1],
|
|
64
|
+
},
|
|
65
|
+
{
|
|
66
|
+
field: 'frequency',
|
|
67
|
+
width: widths[2],
|
|
68
|
+
},
|
|
69
|
+
{
|
|
70
|
+
field: 'genotype',
|
|
71
|
+
width: widths[3],
|
|
72
|
+
},
|
|
73
|
+
] }) })] }));
|
|
74
|
+
}
|
|
@@ -1,12 +1,6 @@
|
|
|
1
|
+
import type { VariantFieldDescriptions } from './types';
|
|
1
2
|
import type { SimpleFeatureSerialized } from '@jbrowse/core/util';
|
|
2
|
-
|
|
3
|
-
Description?: string;
|
|
4
|
-
}
|
|
5
|
-
interface Descriptions {
|
|
6
|
-
FORMAT?: Record<string, FormatRecord>;
|
|
7
|
-
}
|
|
8
|
-
export default function VariantSamples(props: {
|
|
3
|
+
export default function VariantSampleGrid(props: {
|
|
9
4
|
feature: SimpleFeatureSerialized;
|
|
10
|
-
descriptions?:
|
|
5
|
+
descriptions?: VariantFieldDescriptions | null;
|
|
11
6
|
}): import("react/jsx-runtime").JSX.Element | null;
|
|
12
|
-
export {};
|
|
@@ -1,26 +1,50 @@
|
|
|
1
|
-
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
2
|
import { useState } from 'react';
|
|
3
3
|
import BaseCard from '@jbrowse/core/BaseFeatureWidget/BaseFeatureDetail/BaseCard';
|
|
4
|
+
import { ErrorMessage } from '@jbrowse/core/ui';
|
|
5
|
+
import DataGridFlexContainer from '@jbrowse/core/ui/DataGridFlexContainer';
|
|
6
|
+
import { ErrorBoundary } from '@jbrowse/core/ui/ErrorBoundary';
|
|
4
7
|
import { measureGridWidth } from '@jbrowse/core/util';
|
|
5
|
-
import {
|
|
6
|
-
import { DataGrid
|
|
8
|
+
import { Typography } from '@mui/material';
|
|
9
|
+
import { DataGrid } from '@mui/x-data-grid';
|
|
10
|
+
import Checkbox2 from '../Checkbox2';
|
|
11
|
+
import VariantGenotypeFrequencyTable from './VariantGenotypeFrequencyTable';
|
|
7
12
|
import SampleFilters from './VariantSampleFilters';
|
|
8
|
-
|
|
13
|
+
import { areSetsEqual } from './util';
|
|
14
|
+
import { makeSimpleAltString } from '../../VcfFeature/util';
|
|
15
|
+
export default function VariantSampleGrid(props) {
|
|
9
16
|
var _a;
|
|
10
17
|
const { feature, descriptions = {} } = props;
|
|
11
18
|
const [filter, setFilter] = useState({});
|
|
19
|
+
const [showOnlyGenotypeColumns, setShowOnlyGenotypeColumns] = useState(true);
|
|
20
|
+
const [showFilters, setShowFilters] = useState(false);
|
|
12
21
|
const samples = (feature.samples || {});
|
|
13
|
-
const
|
|
22
|
+
const ALT = feature.ALT;
|
|
23
|
+
const REF = feature.REF;
|
|
24
|
+
const preFilteredRows = Object.entries(samples).map(([key, val]) => {
|
|
25
|
+
var _a, _b;
|
|
26
|
+
return [
|
|
27
|
+
key,
|
|
28
|
+
{
|
|
29
|
+
...val,
|
|
30
|
+
GT: `${(_a = val.GT) === null || _a === void 0 ? void 0 : _a[0]}`,
|
|
31
|
+
genotype: makeSimpleAltString(`${(_b = val.GT) === null || _b === void 0 ? void 0 : _b[0]}`, REF, ALT),
|
|
32
|
+
},
|
|
33
|
+
];
|
|
34
|
+
});
|
|
14
35
|
let error;
|
|
15
36
|
let rows = [];
|
|
16
37
|
const filters = Object.keys(filter);
|
|
17
38
|
try {
|
|
18
39
|
rows = preFilteredRows
|
|
19
|
-
.map(
|
|
40
|
+
.map(([key, val]) => {
|
|
20
41
|
return {
|
|
21
|
-
...Object.fromEntries(Object.entries(
|
|
22
|
-
|
|
23
|
-
|
|
42
|
+
...Object.fromEntries(Object.entries(val).map(([formatField, formatValue]) => [
|
|
43
|
+
formatField,
|
|
44
|
+
formatValue,
|
|
45
|
+
])),
|
|
46
|
+
sample: key,
|
|
47
|
+
id: key,
|
|
24
48
|
};
|
|
25
49
|
})
|
|
26
50
|
.filter(row => filters.length
|
|
@@ -33,9 +57,9 @@ export default function VariantSamples(props) {
|
|
|
33
57
|
: true);
|
|
34
58
|
}
|
|
35
59
|
catch (e) {
|
|
60
|
+
console.error(e);
|
|
36
61
|
error = e;
|
|
37
62
|
}
|
|
38
|
-
const [checked, setChecked] = useState(false);
|
|
39
63
|
const keys = ['sample', ...Object.keys(((_a = preFilteredRows[0]) === null || _a === void 0 ? void 0 : _a[1]) || {})];
|
|
40
64
|
const widths = keys.map(e => measureGridWidth(rows.map(r => r[e])));
|
|
41
65
|
const columns = keys.map((field, index) => {
|
|
@@ -46,16 +70,13 @@ export default function VariantSamples(props) {
|
|
|
46
70
|
width: widths[index],
|
|
47
71
|
});
|
|
48
72
|
});
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
},
|
|
59
|
-
},
|
|
60
|
-
} }) })] }));
|
|
73
|
+
const s1 = new Set(['sample', 'GT', 'genotype']);
|
|
74
|
+
const s2 = new Set(keys);
|
|
75
|
+
return !preFilteredRows.length ? null : (_jsxs(_Fragment, { children: [_jsx(BaseCard, { ...props, title: "Genotype frequencies", children: _jsx(ErrorBoundary, { FallbackComponent: ErrorMessage, children: _jsx(VariantGenotypeFrequencyTable, { rows: rows }) }) }), _jsxs(BaseCard, { ...props, title: "Samples", children: [error ? _jsx(Typography, { color: "error", children: `${error}` }) : null, _jsx(Checkbox2, { label: "Show filters", checked: showFilters, onChange: event => {
|
|
76
|
+
setShowFilters(event.target.checked);
|
|
77
|
+
} }), areSetsEqual(s1, s2) ? null : (_jsx(Checkbox2, { label: "Show only genotype columns", checked: showOnlyGenotypeColumns, onChange: event => {
|
|
78
|
+
setShowOnlyGenotypeColumns(event.target.checked);
|
|
79
|
+
} })), showFilters ? (_jsx(SampleFilters, { setFilter: setFilter, columns: columns, filter: filter })) : null, _jsx(DataGridFlexContainer, { children: _jsx(DataGrid, { rows: rows, hideFooter: rows.length < 100, columns: showOnlyGenotypeColumns
|
|
80
|
+
? columns.filter(f => s1.has(f.field))
|
|
81
|
+
: columns, rowHeight: 25, columnHeaderHeight: 35, showToolbar: true }) })] })] }));
|
|
61
82
|
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
export interface FrequencyTableEntry {
|
|
2
|
+
count: number;
|
|
3
|
+
GT: string;
|
|
4
|
+
genotype: string | undefined;
|
|
5
|
+
}
|
|
6
|
+
export type FrequencyTable = Record<string, FrequencyTableEntry>;
|
|
7
|
+
export interface VariantSampleGridRow {
|
|
8
|
+
sample: string;
|
|
9
|
+
id: string;
|
|
10
|
+
GT: string;
|
|
11
|
+
[key: string]: string;
|
|
12
|
+
}
|
|
13
|
+
export type InfoFields = Record<string, unknown[]>;
|
|
14
|
+
export type Filters = Record<string, string>;
|
|
15
|
+
interface FormatRecord {
|
|
16
|
+
Description?: string;
|
|
17
|
+
}
|
|
18
|
+
export interface VariantFieldDescriptions {
|
|
19
|
+
FORMAT?: Record<string, FormatRecord>;
|
|
20
|
+
}
|
|
21
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function areSetsEqual<T>(set1: Set<T>, set2: Set<T>): boolean;
|
|
@@ -1,21 +1,8 @@
|
|
|
1
1
|
import RpcMethodTypeWithFiltersAndRenameRegions from '@jbrowse/core/pluggableElementTypes/RpcMethodTypeWithFiltersAndRenameRegions';
|
|
2
|
-
import type {
|
|
3
|
-
import type { AnyConfigurationModel } from '@jbrowse/core/configuration';
|
|
4
|
-
import type { Region } from '@jbrowse/core/util';
|
|
5
|
-
interface Args {
|
|
6
|
-
adapterConfig: AnyConfigurationModel;
|
|
7
|
-
stopToken?: string;
|
|
8
|
-
statusCallback: (arg: string) => void;
|
|
9
|
-
sessionId: string;
|
|
10
|
-
headers?: Record<string, string>;
|
|
11
|
-
regions: Region[];
|
|
12
|
-
bpPerPx: number;
|
|
13
|
-
sources: Source[];
|
|
14
|
-
minorAlleleFrequencyFilter: number;
|
|
15
|
-
}
|
|
2
|
+
import type { ClusterGenotypeMatrixArgs } from './types';
|
|
16
3
|
export declare class MultiVariantClusterGenotypeMatrix extends RpcMethodTypeWithFiltersAndRenameRegions {
|
|
17
4
|
name: string;
|
|
18
|
-
execute(args:
|
|
5
|
+
execute(args: ClusterGenotypeMatrixArgs, rpcDriverClassName: string): Promise<{
|
|
19
6
|
clusters: {
|
|
20
7
|
height: number;
|
|
21
8
|
indexes: number[];
|
|
@@ -25,4 +12,3 @@ export declare class MultiVariantClusterGenotypeMatrix extends RpcMethodTypeWith
|
|
|
25
12
|
clustersGivenK: number[][][];
|
|
26
13
|
}>;
|
|
27
14
|
}
|
|
28
|
-
export {};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import RpcMethodTypeWithFiltersAndRenameRegions from '@jbrowse/core/pluggableElementTypes/RpcMethodTypeWithFiltersAndRenameRegions';
|
|
2
|
-
import { clusterData } from '
|
|
2
|
+
import { clusterData } from '@jbrowse/core/util/cluster';
|
|
3
3
|
import { getGenotypeMatrix } from './getGenotypeMatrix';
|
|
4
4
|
export class MultiVariantClusterGenotypeMatrix extends RpcMethodTypeWithFiltersAndRenameRegions {
|
|
5
5
|
constructor() {
|
|
@@ -14,13 +14,10 @@ export class MultiVariantClusterGenotypeMatrix extends RpcMethodTypeWithFiltersA
|
|
|
14
14
|
});
|
|
15
15
|
return clusterData({
|
|
16
16
|
data: Object.values(matrix),
|
|
17
|
-
onProgress: a => {
|
|
18
|
-
deserializedArgs.statusCallback(`${toP(a * 100)}%`);
|
|
19
|
-
},
|
|
20
17
|
stopToken: deserializedArgs.stopToken,
|
|
18
|
+
onProgress: progress => {
|
|
19
|
+
deserializedArgs.statusCallback(progress);
|
|
20
|
+
},
|
|
21
21
|
});
|
|
22
22
|
}
|
|
23
23
|
}
|
|
24
|
-
function toP(n) {
|
|
25
|
-
return Number.parseFloat(n.toPrecision(3));
|
|
26
|
-
}
|
|
@@ -1,19 +1,6 @@
|
|
|
1
1
|
import RpcMethodTypeWithFiltersAndRenameRegions from '@jbrowse/core/pluggableElementTypes/RpcMethodTypeWithFiltersAndRenameRegions';
|
|
2
|
-
import type {
|
|
3
|
-
import type { AnyConfigurationModel } from '@jbrowse/core/configuration';
|
|
4
|
-
import type { Region } from '@jbrowse/core/util';
|
|
5
|
-
interface Args {
|
|
6
|
-
adapterConfig: AnyConfigurationModel;
|
|
7
|
-
stopToken?: string;
|
|
8
|
-
sessionId: string;
|
|
9
|
-
headers?: Record<string, string>;
|
|
10
|
-
regions: Region[];
|
|
11
|
-
bpPerPx: number;
|
|
12
|
-
sources: Source[];
|
|
13
|
-
minorAlleleFrequencyFilter: number;
|
|
14
|
-
}
|
|
2
|
+
import type { GetGenotypeMatrixArgs } from './types';
|
|
15
3
|
export declare class MultiVariantGetGenotypeMatrix extends RpcMethodTypeWithFiltersAndRenameRegions {
|
|
16
4
|
name: string;
|
|
17
|
-
execute(args:
|
|
5
|
+
execute(args: GetGenotypeMatrixArgs, rpcDriverClassName: string): Promise<Record<string, number[]>>;
|
|
18
6
|
}
|
|
19
|
-
export {};
|
|
@@ -1,19 +1,9 @@
|
|
|
1
1
|
import RpcMethodTypeWithFiltersAndRenameRegions from '@jbrowse/core/pluggableElementTypes/RpcMethodTypeWithFiltersAndRenameRegions';
|
|
2
|
+
import type { GetSimplifiedFeaturesArgs } from './types';
|
|
2
3
|
import type { SampleInfo } from '../shared/types';
|
|
3
|
-
import type { AnyConfigurationModel } from '@jbrowse/core/configuration';
|
|
4
|
-
import type { Region } from '@jbrowse/core/util';
|
|
5
|
-
interface Args {
|
|
6
|
-
adapterConfig: AnyConfigurationModel;
|
|
7
|
-
stopToken?: string;
|
|
8
|
-
sessionId: string;
|
|
9
|
-
headers?: Record<string, string>;
|
|
10
|
-
regions: Region[];
|
|
11
|
-
bpPerPx: number;
|
|
12
|
-
minorAlleleFrequencyFilter: number;
|
|
13
|
-
}
|
|
14
4
|
export declare class MultiVariantGetSimplifiedFeatures extends RpcMethodTypeWithFiltersAndRenameRegions {
|
|
15
5
|
name: string;
|
|
16
|
-
execute(args:
|
|
6
|
+
execute(args: GetSimplifiedFeaturesArgs, rpcDriverClassName: string): Promise<{
|
|
17
7
|
hasPhased: boolean;
|
|
18
8
|
sampleInfo: Record<string, SampleInfo>;
|
|
19
9
|
features: {
|
|
@@ -22,8 +12,8 @@ export declare class MultiVariantGetSimplifiedFeatures extends RpcMethodTypeWith
|
|
|
22
12
|
start: number;
|
|
23
13
|
end: number;
|
|
24
14
|
refName: string;
|
|
15
|
+
name: any;
|
|
25
16
|
};
|
|
26
17
|
}[];
|
|
27
18
|
}>;
|
|
28
19
|
}
|
|
29
|
-
export {};
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { getAdapter } from '@jbrowse/core/data_adapters/dataAdapterCache';
|
|
2
2
|
import RpcMethodTypeWithFiltersAndRenameRegions from '@jbrowse/core/pluggableElementTypes/RpcMethodTypeWithFiltersAndRenameRegions';
|
|
3
|
+
import { forEachWithStopTokenCheck } from '@jbrowse/core/util';
|
|
3
4
|
import { firstValueFrom, toArray } from 'rxjs';
|
|
4
5
|
import { getFeaturesThatPassMinorAlleleFrequencyFilter } from '../shared/minorAlleleFrequencyUtils';
|
|
5
6
|
export class MultiVariantGetSimplifiedFeatures extends RpcMethodTypeWithFiltersAndRenameRegions {
|
|
@@ -8,17 +9,21 @@ export class MultiVariantGetSimplifiedFeatures extends RpcMethodTypeWithFiltersA
|
|
|
8
9
|
this.name = 'MultiVariantGetSimplifiedFeatures';
|
|
9
10
|
}
|
|
10
11
|
async execute(args, rpcDriverClassName) {
|
|
11
|
-
var _a, _b;
|
|
12
12
|
const deserializedArgs = await this.deserializeArguments(args, rpcDriverClassName);
|
|
13
|
-
const { minorAlleleFrequencyFilter, regions, adapterConfig, sessionId } = deserializedArgs;
|
|
13
|
+
const { lengthCutoffFilter, minorAlleleFrequencyFilter, regions, adapterConfig, stopToken, sessionId, } = deserializedArgs;
|
|
14
14
|
const { dataAdapter } = await getAdapter(this.pluginManager, sessionId, adapterConfig);
|
|
15
|
-
const
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
15
|
+
const features = getFeaturesThatPassMinorAlleleFrequencyFilter({
|
|
16
|
+
minorAlleleFrequencyFilter,
|
|
17
|
+
lengthCutoffFilter,
|
|
18
|
+
stopToken,
|
|
19
|
+
features: await firstValueFrom(dataAdapter
|
|
20
|
+
.getFeaturesInMultipleRegions(regions, deserializedArgs)
|
|
21
|
+
.pipe(toArray())),
|
|
22
|
+
});
|
|
19
23
|
const sampleInfo = {};
|
|
20
24
|
let hasPhased = false;
|
|
21
|
-
|
|
25
|
+
forEachWithStopTokenCheck(features, stopToken, ({ feature }) => {
|
|
26
|
+
var _a, _b;
|
|
22
27
|
const samp = feature.get('genotypes');
|
|
23
28
|
for (const [key, val] of Object.entries(samp)) {
|
|
24
29
|
const isPhased = val.includes('|');
|
|
@@ -28,7 +33,7 @@ export class MultiVariantGetSimplifiedFeatures extends RpcMethodTypeWithFiltersA
|
|
|
28
33
|
isPhased: ((_b = sampleInfo[key]) === null || _b === void 0 ? void 0 : _b.isPhased) || isPhased,
|
|
29
34
|
};
|
|
30
35
|
}
|
|
31
|
-
}
|
|
36
|
+
});
|
|
32
37
|
return {
|
|
33
38
|
hasPhased,
|
|
34
39
|
sampleInfo,
|
|
@@ -38,6 +43,7 @@ export class MultiVariantGetSimplifiedFeatures extends RpcMethodTypeWithFiltersA
|
|
|
38
43
|
start: feature.get('start'),
|
|
39
44
|
end: feature.get('end'),
|
|
40
45
|
refName: feature.get('refName'),
|
|
46
|
+
name: feature.get('name'),
|
|
41
47
|
},
|
|
42
48
|
})),
|
|
43
49
|
};
|
|
@@ -1,20 +1,25 @@
|
|
|
1
1
|
import { getAdapter } from '@jbrowse/core/data_adapters/dataAdapterCache';
|
|
2
|
+
import { forEachWithStopTokenCheck } from '@jbrowse/core/util';
|
|
2
3
|
import { firstValueFrom, toArray } from 'rxjs';
|
|
3
4
|
import { getFeaturesThatPassMinorAlleleFrequencyFilter } from '../shared/minorAlleleFrequencyUtils';
|
|
4
5
|
export async function getGenotypeMatrix({ pluginManager, args, }) {
|
|
5
|
-
const { sources, minorAlleleFrequencyFilter, regions, adapterConfig, sessionId, } = args;
|
|
6
|
+
const { sources, minorAlleleFrequencyFilter, regions, adapterConfig, sessionId, lengthCutoffFilter, stopToken, } = args;
|
|
6
7
|
const adapter = await getAdapter(pluginManager, sessionId, adapterConfig);
|
|
7
8
|
const dataAdapter = adapter.dataAdapter;
|
|
8
|
-
const feats = await firstValueFrom(dataAdapter.getFeaturesInMultipleRegions(regions, args).pipe(toArray()));
|
|
9
9
|
const genotypeFactor = new Set();
|
|
10
|
-
const mafs = getFeaturesThatPassMinorAlleleFrequencyFilter(
|
|
10
|
+
const mafs = getFeaturesThatPassMinorAlleleFrequencyFilter({
|
|
11
|
+
minorAlleleFrequencyFilter,
|
|
12
|
+
lengthCutoffFilter,
|
|
13
|
+
stopToken,
|
|
14
|
+
features: await firstValueFrom(dataAdapter.getFeaturesInMultipleRegions(regions, args).pipe(toArray())),
|
|
15
|
+
});
|
|
11
16
|
for (const { alleleCounts } of mafs) {
|
|
12
17
|
for (const alt of alleleCounts.keys()) {
|
|
13
18
|
genotypeFactor.add(alt);
|
|
14
19
|
}
|
|
15
20
|
}
|
|
16
21
|
const rows = {};
|
|
17
|
-
|
|
22
|
+
forEachWithStopTokenCheck(mafs, stopToken, ({ feature }) => {
|
|
18
23
|
const genotypes = feature.get('genotypes');
|
|
19
24
|
for (const { name } of sources) {
|
|
20
25
|
if (!rows[name]) {
|
|
@@ -47,6 +52,6 @@ export async function getGenotypeMatrix({ pluginManager, args, }) {
|
|
|
47
52
|
}
|
|
48
53
|
rows[name].push(genotypeStatus);
|
|
49
54
|
}
|
|
50
|
-
}
|
|
55
|
+
});
|
|
51
56
|
return rows;
|
|
52
57
|
}
|
|
@@ -10,4 +10,27 @@ export interface GetGenotypeMatrixArgs {
|
|
|
10
10
|
headers?: Record<string, string>;
|
|
11
11
|
regions: Region[];
|
|
12
12
|
bpPerPx: number;
|
|
13
|
+
lengthCutoffFilter: number;
|
|
14
|
+
}
|
|
15
|
+
export interface GetSimplifiedFeaturesArgs {
|
|
16
|
+
adapterConfig: AnyConfigurationModel;
|
|
17
|
+
stopToken?: string;
|
|
18
|
+
sessionId: string;
|
|
19
|
+
headers?: Record<string, string>;
|
|
20
|
+
regions: Region[];
|
|
21
|
+
bpPerPx: number;
|
|
22
|
+
minorAlleleFrequencyFilter: number;
|
|
23
|
+
lengthCutoffFilter: number;
|
|
24
|
+
}
|
|
25
|
+
export interface ClusterGenotypeMatrixArgs {
|
|
26
|
+
adapterConfig: AnyConfigurationModel;
|
|
27
|
+
stopToken?: string;
|
|
28
|
+
statusCallback: (arg: string) => void;
|
|
29
|
+
sessionId: string;
|
|
30
|
+
headers?: Record<string, string>;
|
|
31
|
+
regions: Region[];
|
|
32
|
+
bpPerPx: number;
|
|
33
|
+
sources: Source[];
|
|
34
|
+
minorAlleleFrequencyFilter: number;
|
|
35
|
+
lengthCutoffFilter: number;
|
|
13
36
|
}
|
package/esm/VcfFeature/index.js
CHANGED
package/esm/VcfFeature/util.d.ts
CHANGED
|
@@ -2,3 +2,5 @@ import type VCF from '@gmod/vcf';
|
|
|
2
2
|
export declare function getSOTermAndDescription(ref: string, alt: string[] | undefined, parser: VCF): string[];
|
|
3
3
|
export declare function getSOAndDescFromAltDefs(alt: string, parser: VCF): string[];
|
|
4
4
|
export declare function getSOAndDescByExamination(ref: string, alt: string): string[];
|
|
5
|
+
export declare function getMinimalDesc(ref: string, alt: string): string;
|
|
6
|
+
export declare function makeSimpleAltString(genotype: string, ref: string, alt: string[]): string;
|
package/esm/VcfFeature/util.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { parseBreakend } from '@gmod/vcf';
|
|
2
|
+
import { getBpDisplayStr } from '@jbrowse/core/util';
|
|
2
3
|
const altTypeToSO = {
|
|
3
4
|
DEL: 'deletion',
|
|
4
5
|
INS: 'insertion',
|
|
@@ -62,63 +63,158 @@ export function getSOAndDescFromAltDefs(alt, parser) {
|
|
|
62
63
|
return [soTerm, alt];
|
|
63
64
|
}
|
|
64
65
|
const modAlt = alt.split(':');
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
return [];
|
|
66
|
+
return modAlt.length > 1
|
|
67
|
+
? getSOAndDescFromAltDefs(`<${modAlt.slice(0, -1).join(':')}>`, parser)
|
|
68
|
+
: [];
|
|
69
69
|
}
|
|
70
70
|
export function getSOAndDescByExamination(ref, alt) {
|
|
71
71
|
const bnd = parseBreakend(alt);
|
|
72
72
|
if (bnd) {
|
|
73
73
|
return ['breakend', alt];
|
|
74
74
|
}
|
|
75
|
-
if (ref.length === 1 && alt.length === 1) {
|
|
75
|
+
else if (ref.length === 1 && alt.length === 1) {
|
|
76
76
|
return ['SNV', makeDescriptionString('SNV', ref, alt)];
|
|
77
77
|
}
|
|
78
|
-
if (alt === '<INS>') {
|
|
78
|
+
else if (alt === '<INS>') {
|
|
79
79
|
return ['insertion', alt];
|
|
80
80
|
}
|
|
81
|
-
if (alt === '<DEL>') {
|
|
81
|
+
else if (alt === '<DEL>') {
|
|
82
82
|
return ['deletion', alt];
|
|
83
83
|
}
|
|
84
|
-
if (alt === '<DUP>') {
|
|
84
|
+
else if (alt === '<DUP>') {
|
|
85
85
|
return ['duplication', alt];
|
|
86
86
|
}
|
|
87
|
-
if (alt === '<CNV>') {
|
|
87
|
+
else if (alt === '<CNV>') {
|
|
88
88
|
return ['cnv', alt];
|
|
89
89
|
}
|
|
90
|
-
if (alt === '<INV>') {
|
|
90
|
+
else if (alt === '<INV>') {
|
|
91
91
|
return ['inversion', alt];
|
|
92
92
|
}
|
|
93
|
-
if (alt === '<TRA>') {
|
|
93
|
+
else if (alt === '<TRA>') {
|
|
94
94
|
return ['translocation', alt];
|
|
95
95
|
}
|
|
96
|
-
if (alt.includes('<')) {
|
|
96
|
+
else if (alt.includes('<')) {
|
|
97
97
|
return ['sv', alt];
|
|
98
98
|
}
|
|
99
|
-
if (ref.length === alt.length) {
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
99
|
+
else if (ref.length === alt.length) {
|
|
100
|
+
const lenRef = ref.length;
|
|
101
|
+
const lenAlt = alt.length;
|
|
102
|
+
if (lenRef > 5 || lenAlt > 5) {
|
|
103
|
+
const lena = getBpDisplayStr(lenRef);
|
|
104
|
+
const lenb = getBpDisplayStr(lenAlt);
|
|
105
|
+
return ref.split('').reverse().join('') === alt
|
|
106
|
+
? ['inverson', makeDescriptionString('inv', lena, lenb)]
|
|
107
|
+
: ['substitution', makeDescriptionString('substitution', lena, lenb)];
|
|
108
|
+
}
|
|
109
|
+
else {
|
|
110
|
+
return ref.split('').reverse().join('') === alt
|
|
111
|
+
? ['inversion', makeDescriptionString('inv', ref, alt)]
|
|
112
|
+
: ['substitution', makeDescriptionString('substitution', ref, alt)];
|
|
113
|
+
}
|
|
103
114
|
}
|
|
104
|
-
if (ref.length <= alt.length) {
|
|
115
|
+
else if (ref.length <= alt.length) {
|
|
105
116
|
const len = alt.length - ref.length;
|
|
106
|
-
const
|
|
117
|
+
const lenAlt = alt.length;
|
|
118
|
+
const lenRef = ref.length;
|
|
119
|
+
const lena = getBpDisplayStr(len);
|
|
107
120
|
return [
|
|
108
121
|
'insertion',
|
|
109
|
-
|
|
122
|
+
lenRef > 5 || lenAlt > 5
|
|
123
|
+
? `${lena} INS`
|
|
124
|
+
: makeDescriptionString('insertion', len > 5 ? lena : ref, alt),
|
|
110
125
|
];
|
|
111
126
|
}
|
|
112
|
-
if (ref.length > alt.length) {
|
|
113
|
-
const
|
|
114
|
-
const
|
|
127
|
+
else if (ref.length > alt.length) {
|
|
128
|
+
const lenRef = ref.length;
|
|
129
|
+
const lenAlt = alt.length;
|
|
130
|
+
const lena = getBpDisplayStr(lenRef - lenAlt);
|
|
115
131
|
return [
|
|
116
132
|
'deletion',
|
|
117
|
-
|
|
133
|
+
lenRef > 5 || lenAlt > 5
|
|
134
|
+
? `${lena} DEL`
|
|
135
|
+
: makeDescriptionString('deletion', ref, alt),
|
|
118
136
|
];
|
|
119
137
|
}
|
|
120
|
-
|
|
138
|
+
else {
|
|
139
|
+
return ['indel', makeDescriptionString('indel', ref, alt)];
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
export function getMinimalDesc(ref, alt) {
|
|
143
|
+
const bnd = parseBreakend(alt);
|
|
144
|
+
if (bnd) {
|
|
145
|
+
return alt;
|
|
146
|
+
}
|
|
147
|
+
else if (ref.length === 1 && alt.length === 1) {
|
|
148
|
+
return alt;
|
|
149
|
+
}
|
|
150
|
+
else if (alt === '<INS>') {
|
|
151
|
+
return alt;
|
|
152
|
+
}
|
|
153
|
+
else if (alt === '<DEL>') {
|
|
154
|
+
return alt;
|
|
155
|
+
}
|
|
156
|
+
else if (alt === '<DUP>') {
|
|
157
|
+
return alt;
|
|
158
|
+
}
|
|
159
|
+
else if (alt === '<CNV>') {
|
|
160
|
+
return alt;
|
|
161
|
+
}
|
|
162
|
+
else if (alt === '<INV>') {
|
|
163
|
+
return alt;
|
|
164
|
+
}
|
|
165
|
+
else if (alt === '<TRA>') {
|
|
166
|
+
return alt;
|
|
167
|
+
}
|
|
168
|
+
else if (alt.includes('<')) {
|
|
169
|
+
return alt;
|
|
170
|
+
}
|
|
171
|
+
else if (ref.length === alt.length) {
|
|
172
|
+
const lenRef = ref.length;
|
|
173
|
+
const lenAlt = alt.length;
|
|
174
|
+
if (lenRef > 5 || lenAlt > 5) {
|
|
175
|
+
const lena = getBpDisplayStr(lenRef);
|
|
176
|
+
const lenb = getBpDisplayStr(lenAlt);
|
|
177
|
+
return ref.split('').reverse().join('') === alt
|
|
178
|
+
? makeDescriptionString('inv', lena, lenb)
|
|
179
|
+
: makeDescriptionString('substitution', lena, lenb);
|
|
180
|
+
}
|
|
181
|
+
else {
|
|
182
|
+
return ref.split('').reverse().join('') === alt
|
|
183
|
+
? makeDescriptionString('inv', ref, alt)
|
|
184
|
+
: makeDescriptionString('substitution', ref, alt);
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
else if (ref.length <= alt.length) {
|
|
188
|
+
const len = alt.length - ref.length;
|
|
189
|
+
const lenAlt = alt.length;
|
|
190
|
+
const lenRef = ref.length;
|
|
191
|
+
const lena = getBpDisplayStr(len);
|
|
192
|
+
return lenRef > 5 || lenAlt > 5
|
|
193
|
+
? `${lena} INS`
|
|
194
|
+
: makeDescriptionString('insertion', len > 5 ? lena : ref, alt);
|
|
195
|
+
}
|
|
196
|
+
else if (ref.length > alt.length) {
|
|
197
|
+
const lenRef = ref.length;
|
|
198
|
+
const lenAlt = alt.length;
|
|
199
|
+
const lena = getBpDisplayStr(lenRef - lenAlt);
|
|
200
|
+
return lenRef > 5 || lenAlt > 5
|
|
201
|
+
? `${lena} DEL`
|
|
202
|
+
: makeDescriptionString('deletion', ref, alt);
|
|
203
|
+
}
|
|
204
|
+
else {
|
|
205
|
+
return makeDescriptionString('indel', ref, alt);
|
|
206
|
+
}
|
|
121
207
|
}
|
|
122
208
|
function makeDescriptionString(soTerm, ref, alt) {
|
|
123
|
-
return `${soTerm} ${ref
|
|
209
|
+
return `${soTerm} ${[ref, alt].join(' -> ')}`;
|
|
210
|
+
}
|
|
211
|
+
export function makeSimpleAltString(genotype, ref, alt) {
|
|
212
|
+
return genotype
|
|
213
|
+
.split(/[/|]/)
|
|
214
|
+
.map(r => r === '.'
|
|
215
|
+
? '.'
|
|
216
|
+
: +r === 0
|
|
217
|
+
? `ref(${ref.length < 10 ? ref : getBpDisplayStr(ref.length)})`
|
|
218
|
+
: getMinimalDesc(ref, alt[+r - 1] || ''))
|
|
219
|
+
.join(genotype.includes('|') ? '|' : '/');
|
|
124
220
|
}
|