@jbrowse/plugin-variants 3.4.0 → 3.5.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/dist/LinearVariantDisplay/model.d.ts +2 -1
- package/dist/MultiLinearVariantDisplay/model.d.ts +2 -1
- package/dist/MultiLinearVariantMatrixDisplay/model.d.ts +2 -1
- package/dist/VariantFeatureWidget/VariantSampleGrid/VariantSampleGrid.js +18 -52
- package/dist/VariantFeatureWidget/VariantSampleGrid/getSampleGridRows.d.ts +5 -0
- package/dist/VariantFeatureWidget/VariantSampleGrid/getSampleGridRows.js +46 -0
- package/dist/shared/MultiVariantBaseModel.d.ts +2 -1
- package/dist/shared/SharedVariantMixin.d.ts +2 -1
- package/dist/shared/components/SourcesDataGrid.js +1 -1
- package/esm/LinearVariantDisplay/model.d.ts +2 -1
- package/esm/MultiLinearVariantDisplay/model.d.ts +2 -1
- package/esm/MultiLinearVariantMatrixDisplay/model.d.ts +2 -1
- package/esm/VariantFeatureWidget/VariantSampleGrid/VariantSampleGrid.js +19 -53
- package/esm/VariantFeatureWidget/VariantSampleGrid/getSampleGridRows.d.ts +5 -0
- package/esm/VariantFeatureWidget/VariantSampleGrid/getSampleGridRows.js +43 -0
- package/esm/shared/MultiVariantBaseModel.d.ts +2 -1
- package/esm/shared/SharedVariantMixin.d.ts +2 -1
- package/esm/shared/components/SourcesDataGrid.js +1 -1
- package/package.json +7 -7
|
@@ -191,6 +191,7 @@ export default function stateModelFactory(configSchema: AnyConfigurationSchemaTy
|
|
|
191
191
|
readonly renderDelay: number;
|
|
192
192
|
readonly TooltipComponent: import("@jbrowse/core/util").AnyReactComponentType;
|
|
193
193
|
readonly selectedFeatureId: string | undefined;
|
|
194
|
+
copyInfoToClipboard(feature: Feature): void;
|
|
194
195
|
} & {
|
|
195
196
|
readonly features: import("@jbrowse/core/util/compositeMap").default<string, Feature>;
|
|
196
197
|
readonly featureUnderMouse: Feature | undefined;
|
|
@@ -200,7 +201,7 @@ export default function stateModelFactory(configSchema: AnyConfigurationSchemaTy
|
|
|
200
201
|
} & {
|
|
201
202
|
addBlock(key: string, block: import("@jbrowse/core/util/blockTypes").BaseBlock): void;
|
|
202
203
|
deleteBlock(key: string): void;
|
|
203
|
-
selectFeature(feature: Feature):
|
|
204
|
+
selectFeature(feature: Feature): void;
|
|
204
205
|
navToFeature(feature: Feature): void;
|
|
205
206
|
clearFeatureSelection(): void;
|
|
206
207
|
setFeatureIdUnderMouse(feature?: string): void;
|
|
@@ -199,6 +199,7 @@ export declare function stateModelFactory(configSchema: AnyConfigurationSchemaTy
|
|
|
199
199
|
readonly renderDelay: number;
|
|
200
200
|
readonly TooltipComponent: import("@jbrowse/core/util").AnyReactComponentType;
|
|
201
201
|
readonly selectedFeatureId: string | undefined;
|
|
202
|
+
copyInfoToClipboard(feature: import("@jbrowse/core/util").Feature): void;
|
|
202
203
|
} & {
|
|
203
204
|
readonly features: import("@jbrowse/core/util/compositeMap").default<string, import("@jbrowse/core/util").Feature>;
|
|
204
205
|
readonly featureUnderMouse: import("@jbrowse/core/util").Feature | undefined;
|
|
@@ -208,7 +209,7 @@ export declare function stateModelFactory(configSchema: AnyConfigurationSchemaTy
|
|
|
208
209
|
} & {
|
|
209
210
|
addBlock(key: string, block: import("@jbrowse/core/util/blockTypes").BaseBlock): void;
|
|
210
211
|
deleteBlock(key: string): void;
|
|
211
|
-
selectFeature(feature: import("@jbrowse/core/util").Feature):
|
|
212
|
+
selectFeature(feature: import("@jbrowse/core/util").Feature): void;
|
|
212
213
|
navToFeature(feature: import("@jbrowse/core/util").Feature): void;
|
|
213
214
|
clearFeatureSelection(): void;
|
|
214
215
|
setFeatureIdUnderMouse(feature?: string): void;
|
|
@@ -199,6 +199,7 @@ export default function stateModelFactory(configSchema: AnyConfigurationSchemaTy
|
|
|
199
199
|
readonly renderDelay: number;
|
|
200
200
|
readonly TooltipComponent: import("@jbrowse/core/util").AnyReactComponentType;
|
|
201
201
|
readonly selectedFeatureId: string | undefined;
|
|
202
|
+
copyInfoToClipboard(feature: import("@jbrowse/core/util").Feature): void;
|
|
202
203
|
} & {
|
|
203
204
|
readonly features: import("@jbrowse/core/util/compositeMap").default<string, import("@jbrowse/core/util").Feature>;
|
|
204
205
|
readonly featureUnderMouse: import("@jbrowse/core/util").Feature | undefined;
|
|
@@ -208,7 +209,7 @@ export default function stateModelFactory(configSchema: AnyConfigurationSchemaTy
|
|
|
208
209
|
} & {
|
|
209
210
|
addBlock(key: string, block: import("@jbrowse/core/util/blockTypes").BaseBlock): void;
|
|
210
211
|
deleteBlock(key: string): void;
|
|
211
|
-
selectFeature(feature: import("@jbrowse/core/util").Feature):
|
|
212
|
+
selectFeature(feature: import("@jbrowse/core/util").Feature): void;
|
|
212
213
|
navToFeature(feature: import("@jbrowse/core/util").Feature): void;
|
|
213
214
|
clearFeatureSelection(): void;
|
|
214
215
|
setFeatureIdUnderMouse(feature?: string): void;
|
|
@@ -16,57 +16,19 @@ const x_data_grid_1 = require("@mui/x-data-grid");
|
|
|
16
16
|
const Checkbox2_1 = __importDefault(require("../Checkbox2"));
|
|
17
17
|
const VariantGenotypeFrequencyTable_1 = __importDefault(require("./VariantGenotypeFrequencyTable"));
|
|
18
18
|
const VariantSampleFilters_1 = __importDefault(require("./VariantSampleFilters"));
|
|
19
|
-
const
|
|
20
|
-
const util_3 = require("../../VcfFeature/util");
|
|
19
|
+
const getSampleGridRows_1 = require("./getSampleGridRows");
|
|
21
20
|
function VariantSampleGrid(props) {
|
|
22
|
-
var _a;
|
|
23
21
|
const { feature, descriptions = {} } = props;
|
|
24
22
|
const [filter, setFilter] = (0, react_1.useState)({});
|
|
25
|
-
const [
|
|
23
|
+
const [columnDisplayMode, setColumnDisplayMode] = (0, react_1.useState)('all');
|
|
26
24
|
const [showFilters, setShowFilters] = (0, react_1.useState)(false);
|
|
27
25
|
const samples = (feature.samples || {});
|
|
28
26
|
const ALT = feature.ALT;
|
|
29
27
|
const REF = feature.REF;
|
|
30
|
-
const
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
{
|
|
35
|
-
...val,
|
|
36
|
-
GT: `${(_a = val.GT) === null || _a === void 0 ? void 0 : _a[0]}`,
|
|
37
|
-
genotype: (0, util_3.makeSimpleAltString)(`${(_b = val.GT) === null || _b === void 0 ? void 0 : _b[0]}`, REF, ALT),
|
|
38
|
-
},
|
|
39
|
-
];
|
|
40
|
-
});
|
|
41
|
-
let error;
|
|
42
|
-
let rows = [];
|
|
43
|
-
const filters = Object.keys(filter);
|
|
44
|
-
try {
|
|
45
|
-
rows = preFilteredRows
|
|
46
|
-
.map(([key, val]) => {
|
|
47
|
-
return {
|
|
48
|
-
...Object.fromEntries(Object.entries(val).map(([formatField, formatValue]) => [
|
|
49
|
-
formatField,
|
|
50
|
-
formatValue,
|
|
51
|
-
])),
|
|
52
|
-
sample: key,
|
|
53
|
-
id: key,
|
|
54
|
-
};
|
|
55
|
-
})
|
|
56
|
-
.filter(row => filters.length
|
|
57
|
-
? filters.every(key => {
|
|
58
|
-
const currFilter = filter[key];
|
|
59
|
-
return currFilter
|
|
60
|
-
? new RegExp(currFilter, 'i').exec(row[key])
|
|
61
|
-
: true;
|
|
62
|
-
})
|
|
63
|
-
: true);
|
|
64
|
-
}
|
|
65
|
-
catch (e) {
|
|
66
|
-
console.error(e);
|
|
67
|
-
error = e;
|
|
68
|
-
}
|
|
69
|
-
const keys = ['sample', ...Object.keys(((_a = preFilteredRows[0]) === null || _a === void 0 ? void 0 : _a[1]) || {})];
|
|
28
|
+
const { rows, error } = (0, getSampleGridRows_1.getSampleGridRows)(samples, REF, ALT, filter);
|
|
29
|
+
const colKeySet = new Set(['sample', ...Object.keys(rows[0] || {})]);
|
|
30
|
+
colKeySet.delete('id');
|
|
31
|
+
const keys = [...colKeySet];
|
|
70
32
|
const widths = keys.map(e => (0, util_1.measureGridWidth)(rows.map(r => r[e])));
|
|
71
33
|
const columns = keys.map((field, index) => {
|
|
72
34
|
var _a, _b;
|
|
@@ -76,13 +38,17 @@ function VariantSampleGrid(props) {
|
|
|
76
38
|
width: widths[index],
|
|
77
39
|
});
|
|
78
40
|
});
|
|
79
|
-
const s1 = new Set(['sample', 'GT'
|
|
80
|
-
const s2 = new Set(
|
|
81
|
-
return !
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
41
|
+
const s1 = new Set(['sample', 'GT']);
|
|
42
|
+
const s2 = new Set(['sample', 'GT', 'genotype']);
|
|
43
|
+
return !rows.length ? null : ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(BaseCard_1.default, { ...props, title: "Genotype frequencies", children: (0, jsx_runtime_1.jsx)(ErrorBoundary_1.ErrorBoundary, { FallbackComponent: ui_1.ErrorMessage, children: (0, jsx_runtime_1.jsx)(VariantGenotypeFrequencyTable_1.default, { rows: rows }) }) }), (0, jsx_runtime_1.jsxs)(BaseCard_1.default, { ...props, title: "Samples", children: [error ? (0, jsx_runtime_1.jsx)(material_1.Typography, { color: "error", children: `${error}` }) : null, (0, jsx_runtime_1.jsxs)("div", { children: [(0, jsx_runtime_1.jsx)(Checkbox2_1.default, { label: "Show filters", checked: showFilters, onChange: event => {
|
|
44
|
+
setShowFilters(event.target.checked);
|
|
45
|
+
} }), (0, jsx_runtime_1.jsxs)(material_1.ToggleButtonGroup, { value: columnDisplayMode, exclusive: true, size: "small", onChange: (_, newValue) => {
|
|
46
|
+
if (newValue !== null) {
|
|
47
|
+
setColumnDisplayMode(newValue);
|
|
48
|
+
}
|
|
49
|
+
}, children: [(0, jsx_runtime_1.jsx)(material_1.ToggleButton, { value: "all", children: "All" }), (0, jsx_runtime_1.jsx)(material_1.ToggleButton, { value: "gtOnly", children: "GT only" }), (0, jsx_runtime_1.jsx)(material_1.ToggleButton, { value: "genotypeOnly", children: "GT+resolved genotype" })] })] }), showFilters ? ((0, jsx_runtime_1.jsx)(VariantSampleFilters_1.default, { setFilter: setFilter, columns: columns, filter: filter })) : null, (0, jsx_runtime_1.jsx)(DataGridFlexContainer_1.default, { children: (0, jsx_runtime_1.jsx)(x_data_grid_1.DataGrid, { rows: rows, hideFooter: rows.length < 100, columns: columnDisplayMode === 'gtOnly'
|
|
86
50
|
? columns.filter(f => s1.has(f.field))
|
|
87
|
-
:
|
|
51
|
+
: columnDisplayMode === 'genotypeOnly'
|
|
52
|
+
? columns.filter(f => s2.has(f.field))
|
|
53
|
+
: columns, rowHeight: 25, columnHeaderHeight: 35, showToolbar: true }) })] })] }));
|
|
88
54
|
}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getSampleGridRows = getSampleGridRows;
|
|
4
|
+
const util_1 = require("../../VcfFeature/util");
|
|
5
|
+
function getSampleGridRows(samples, REF, ALT, filter) {
|
|
6
|
+
const preFilteredRows = Object.entries(samples).map(([key, val]) => {
|
|
7
|
+
var _a, _b;
|
|
8
|
+
return [
|
|
9
|
+
key,
|
|
10
|
+
{
|
|
11
|
+
...val,
|
|
12
|
+
GT: `${(_a = val.GT) === null || _a === void 0 ? void 0 : _a[0]}`,
|
|
13
|
+
genotype: (0, util_1.makeSimpleAltString)(`${(_b = val.GT) === null || _b === void 0 ? void 0 : _b[0]}`, REF, ALT),
|
|
14
|
+
},
|
|
15
|
+
];
|
|
16
|
+
});
|
|
17
|
+
let error;
|
|
18
|
+
let rows = [];
|
|
19
|
+
const filters = Object.keys(filter);
|
|
20
|
+
try {
|
|
21
|
+
rows = preFilteredRows
|
|
22
|
+
.map(([key, val]) => {
|
|
23
|
+
return {
|
|
24
|
+
...Object.fromEntries(Object.entries(val).map(([formatField, formatValue]) => [
|
|
25
|
+
formatField,
|
|
26
|
+
formatValue,
|
|
27
|
+
])),
|
|
28
|
+
sample: key,
|
|
29
|
+
id: key,
|
|
30
|
+
};
|
|
31
|
+
})
|
|
32
|
+
.filter(row => filters.length
|
|
33
|
+
? filters.every(key => {
|
|
34
|
+
const currFilter = filter[key];
|
|
35
|
+
return currFilter
|
|
36
|
+
? new RegExp(currFilter, 'i').exec(row[key])
|
|
37
|
+
: true;
|
|
38
|
+
})
|
|
39
|
+
: true);
|
|
40
|
+
}
|
|
41
|
+
catch (e) {
|
|
42
|
+
console.error(e);
|
|
43
|
+
error = e;
|
|
44
|
+
}
|
|
45
|
+
return { rows, error };
|
|
46
|
+
}
|
|
@@ -196,6 +196,7 @@ export default function MultiVariantBaseModelF(configSchema: AnyConfigurationSch
|
|
|
196
196
|
readonly renderDelay: number;
|
|
197
197
|
readonly TooltipComponent: import("@jbrowse/core/util").AnyReactComponentType;
|
|
198
198
|
readonly selectedFeatureId: string | undefined;
|
|
199
|
+
copyInfoToClipboard(feature: Feature): void;
|
|
199
200
|
} & {
|
|
200
201
|
readonly features: import("@jbrowse/core/util/compositeMap").default<string, Feature>;
|
|
201
202
|
readonly featureUnderMouse: Feature | undefined;
|
|
@@ -205,7 +206,7 @@ export default function MultiVariantBaseModelF(configSchema: AnyConfigurationSch
|
|
|
205
206
|
} & {
|
|
206
207
|
addBlock(key: string, block: import("@jbrowse/core/util/blockTypes").BaseBlock): void;
|
|
207
208
|
deleteBlock(key: string): void;
|
|
208
|
-
selectFeature(feature: Feature):
|
|
209
|
+
selectFeature(feature: Feature): void;
|
|
209
210
|
navToFeature(feature: Feature): void;
|
|
210
211
|
clearFeatureSelection(): void;
|
|
211
212
|
setFeatureIdUnderMouse(feature?: string): void;
|
|
@@ -184,6 +184,7 @@ export default function SharedVariantMixin(configSchema: AnyConfigurationSchemaT
|
|
|
184
184
|
readonly renderDelay: number;
|
|
185
185
|
readonly TooltipComponent: import("@jbrowse/core/util").AnyReactComponentType;
|
|
186
186
|
readonly selectedFeatureId: string | undefined;
|
|
187
|
+
copyInfoToClipboard(feature: Feature): void;
|
|
187
188
|
} & {
|
|
188
189
|
readonly features: import("@jbrowse/core/util/compositeMap").default<string, Feature>;
|
|
189
190
|
readonly featureUnderMouse: Feature | undefined;
|
|
@@ -193,7 +194,7 @@ export default function SharedVariantMixin(configSchema: AnyConfigurationSchemaT
|
|
|
193
194
|
} & {
|
|
194
195
|
addBlock(key: string, block: import("@jbrowse/core/util/blockTypes").BaseBlock): void;
|
|
195
196
|
deleteBlock(key: string): void;
|
|
196
|
-
selectFeature(feature: Feature):
|
|
197
|
+
selectFeature(feature: Feature): void;
|
|
197
198
|
navToFeature(feature: Feature): void;
|
|
198
199
|
clearFeatureSelection(): void;
|
|
199
200
|
setFeatureIdUnderMouse(feature?: string): void;
|
|
@@ -25,7 +25,7 @@ function SourcesDataGrid({ rows, onChange, setSelected, }) {
|
|
|
25
25
|
idx: 0,
|
|
26
26
|
field: null,
|
|
27
27
|
});
|
|
28
|
-
return ((0, jsx_runtime_1.jsx)("div", { style: { height: 400, width: '100%' }, children: (0, jsx_runtime_1.jsx)(x_data_grid_1.DataGrid, { checkboxSelection: true, onRowSelectionModelChange: arg => {
|
|
28
|
+
return ((0, jsx_runtime_1.jsx)("div", { style: { height: 400, width: '100%' }, children: (0, jsx_runtime_1.jsx)(x_data_grid_1.DataGrid, { checkboxSelection: true, disableRowSelectionOnClick: true, onRowSelectionModelChange: arg => {
|
|
29
29
|
setSelected([...arg.ids]);
|
|
30
30
|
}, rows: rows, rowHeight: 25, columnHeaderHeight: 33, columns: [
|
|
31
31
|
{
|
|
@@ -191,6 +191,7 @@ export default function stateModelFactory(configSchema: AnyConfigurationSchemaTy
|
|
|
191
191
|
readonly renderDelay: number;
|
|
192
192
|
readonly TooltipComponent: import("@jbrowse/core/util").AnyReactComponentType;
|
|
193
193
|
readonly selectedFeatureId: string | undefined;
|
|
194
|
+
copyInfoToClipboard(feature: Feature): void;
|
|
194
195
|
} & {
|
|
195
196
|
readonly features: import("@jbrowse/core/util/compositeMap").default<string, Feature>;
|
|
196
197
|
readonly featureUnderMouse: Feature | undefined;
|
|
@@ -200,7 +201,7 @@ export default function stateModelFactory(configSchema: AnyConfigurationSchemaTy
|
|
|
200
201
|
} & {
|
|
201
202
|
addBlock(key: string, block: import("@jbrowse/core/util/blockTypes").BaseBlock): void;
|
|
202
203
|
deleteBlock(key: string): void;
|
|
203
|
-
selectFeature(feature: Feature):
|
|
204
|
+
selectFeature(feature: Feature): void;
|
|
204
205
|
navToFeature(feature: Feature): void;
|
|
205
206
|
clearFeatureSelection(): void;
|
|
206
207
|
setFeatureIdUnderMouse(feature?: string): void;
|
|
@@ -199,6 +199,7 @@ export declare function stateModelFactory(configSchema: AnyConfigurationSchemaTy
|
|
|
199
199
|
readonly renderDelay: number;
|
|
200
200
|
readonly TooltipComponent: import("@jbrowse/core/util").AnyReactComponentType;
|
|
201
201
|
readonly selectedFeatureId: string | undefined;
|
|
202
|
+
copyInfoToClipboard(feature: import("@jbrowse/core/util").Feature): void;
|
|
202
203
|
} & {
|
|
203
204
|
readonly features: import("@jbrowse/core/util/compositeMap").default<string, import("@jbrowse/core/util").Feature>;
|
|
204
205
|
readonly featureUnderMouse: import("@jbrowse/core/util").Feature | undefined;
|
|
@@ -208,7 +209,7 @@ export declare function stateModelFactory(configSchema: AnyConfigurationSchemaTy
|
|
|
208
209
|
} & {
|
|
209
210
|
addBlock(key: string, block: import("@jbrowse/core/util/blockTypes").BaseBlock): void;
|
|
210
211
|
deleteBlock(key: string): void;
|
|
211
|
-
selectFeature(feature: import("@jbrowse/core/util").Feature):
|
|
212
|
+
selectFeature(feature: import("@jbrowse/core/util").Feature): void;
|
|
212
213
|
navToFeature(feature: import("@jbrowse/core/util").Feature): void;
|
|
213
214
|
clearFeatureSelection(): void;
|
|
214
215
|
setFeatureIdUnderMouse(feature?: string): void;
|
|
@@ -199,6 +199,7 @@ export default function stateModelFactory(configSchema: AnyConfigurationSchemaTy
|
|
|
199
199
|
readonly renderDelay: number;
|
|
200
200
|
readonly TooltipComponent: import("@jbrowse/core/util").AnyReactComponentType;
|
|
201
201
|
readonly selectedFeatureId: string | undefined;
|
|
202
|
+
copyInfoToClipboard(feature: import("@jbrowse/core/util").Feature): void;
|
|
202
203
|
} & {
|
|
203
204
|
readonly features: import("@jbrowse/core/util/compositeMap").default<string, import("@jbrowse/core/util").Feature>;
|
|
204
205
|
readonly featureUnderMouse: import("@jbrowse/core/util").Feature | undefined;
|
|
@@ -208,7 +209,7 @@ export default function stateModelFactory(configSchema: AnyConfigurationSchemaTy
|
|
|
208
209
|
} & {
|
|
209
210
|
addBlock(key: string, block: import("@jbrowse/core/util/blockTypes").BaseBlock): void;
|
|
210
211
|
deleteBlock(key: string): void;
|
|
211
|
-
selectFeature(feature: import("@jbrowse/core/util").Feature):
|
|
212
|
+
selectFeature(feature: import("@jbrowse/core/util").Feature): void;
|
|
212
213
|
navToFeature(feature: import("@jbrowse/core/util").Feature): void;
|
|
213
214
|
clearFeatureSelection(): void;
|
|
214
215
|
setFeatureIdUnderMouse(feature?: string): void;
|
|
@@ -5,62 +5,24 @@ import { ErrorMessage } from '@jbrowse/core/ui';
|
|
|
5
5
|
import DataGridFlexContainer from '@jbrowse/core/ui/DataGridFlexContainer';
|
|
6
6
|
import { ErrorBoundary } from '@jbrowse/core/ui/ErrorBoundary';
|
|
7
7
|
import { measureGridWidth } from '@jbrowse/core/util';
|
|
8
|
-
import { Typography } from '@mui/material';
|
|
8
|
+
import { ToggleButton, ToggleButtonGroup, Typography } from '@mui/material';
|
|
9
9
|
import { DataGrid } from '@mui/x-data-grid';
|
|
10
10
|
import Checkbox2 from '../Checkbox2';
|
|
11
11
|
import VariantGenotypeFrequencyTable from './VariantGenotypeFrequencyTable';
|
|
12
12
|
import SampleFilters from './VariantSampleFilters';
|
|
13
|
-
import {
|
|
14
|
-
import { makeSimpleAltString } from '../../VcfFeature/util';
|
|
13
|
+
import { getSampleGridRows } from './getSampleGridRows';
|
|
15
14
|
export default function VariantSampleGrid(props) {
|
|
16
|
-
var _a;
|
|
17
15
|
const { feature, descriptions = {} } = props;
|
|
18
16
|
const [filter, setFilter] = useState({});
|
|
19
|
-
const [
|
|
17
|
+
const [columnDisplayMode, setColumnDisplayMode] = useState('all');
|
|
20
18
|
const [showFilters, setShowFilters] = useState(false);
|
|
21
19
|
const samples = (feature.samples || {});
|
|
22
20
|
const ALT = feature.ALT;
|
|
23
21
|
const REF = feature.REF;
|
|
24
|
-
const
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
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
|
-
});
|
|
35
|
-
let error;
|
|
36
|
-
let rows = [];
|
|
37
|
-
const filters = Object.keys(filter);
|
|
38
|
-
try {
|
|
39
|
-
rows = preFilteredRows
|
|
40
|
-
.map(([key, val]) => {
|
|
41
|
-
return {
|
|
42
|
-
...Object.fromEntries(Object.entries(val).map(([formatField, formatValue]) => [
|
|
43
|
-
formatField,
|
|
44
|
-
formatValue,
|
|
45
|
-
])),
|
|
46
|
-
sample: key,
|
|
47
|
-
id: key,
|
|
48
|
-
};
|
|
49
|
-
})
|
|
50
|
-
.filter(row => filters.length
|
|
51
|
-
? filters.every(key => {
|
|
52
|
-
const currFilter = filter[key];
|
|
53
|
-
return currFilter
|
|
54
|
-
? new RegExp(currFilter, 'i').exec(row[key])
|
|
55
|
-
: true;
|
|
56
|
-
})
|
|
57
|
-
: true);
|
|
58
|
-
}
|
|
59
|
-
catch (e) {
|
|
60
|
-
console.error(e);
|
|
61
|
-
error = e;
|
|
62
|
-
}
|
|
63
|
-
const keys = ['sample', ...Object.keys(((_a = preFilteredRows[0]) === null || _a === void 0 ? void 0 : _a[1]) || {})];
|
|
22
|
+
const { rows, error } = getSampleGridRows(samples, REF, ALT, filter);
|
|
23
|
+
const colKeySet = new Set(['sample', ...Object.keys(rows[0] || {})]);
|
|
24
|
+
colKeySet.delete('id');
|
|
25
|
+
const keys = [...colKeySet];
|
|
64
26
|
const widths = keys.map(e => measureGridWidth(rows.map(r => r[e])));
|
|
65
27
|
const columns = keys.map((field, index) => {
|
|
66
28
|
var _a, _b;
|
|
@@ -70,13 +32,17 @@ export default function VariantSampleGrid(props) {
|
|
|
70
32
|
width: widths[index],
|
|
71
33
|
});
|
|
72
34
|
});
|
|
73
|
-
const s1 = new Set(['sample', 'GT'
|
|
74
|
-
const s2 = new Set(
|
|
75
|
-
return !
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
35
|
+
const s1 = new Set(['sample', 'GT']);
|
|
36
|
+
const s2 = new Set(['sample', 'GT', 'genotype']);
|
|
37
|
+
return !rows.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, _jsxs("div", { children: [_jsx(Checkbox2, { label: "Show filters", checked: showFilters, onChange: event => {
|
|
38
|
+
setShowFilters(event.target.checked);
|
|
39
|
+
} }), _jsxs(ToggleButtonGroup, { value: columnDisplayMode, exclusive: true, size: "small", onChange: (_, newValue) => {
|
|
40
|
+
if (newValue !== null) {
|
|
41
|
+
setColumnDisplayMode(newValue);
|
|
42
|
+
}
|
|
43
|
+
}, children: [_jsx(ToggleButton, { value: "all", children: "All" }), _jsx(ToggleButton, { value: "gtOnly", children: "GT only" }), _jsx(ToggleButton, { value: "genotypeOnly", children: "GT+resolved genotype" })] })] }), showFilters ? (_jsx(SampleFilters, { setFilter: setFilter, columns: columns, filter: filter })) : null, _jsx(DataGridFlexContainer, { children: _jsx(DataGrid, { rows: rows, hideFooter: rows.length < 100, columns: columnDisplayMode === 'gtOnly'
|
|
80
44
|
? columns.filter(f => s1.has(f.field))
|
|
81
|
-
:
|
|
45
|
+
: columnDisplayMode === 'genotypeOnly'
|
|
46
|
+
? columns.filter(f => s2.has(f.field))
|
|
47
|
+
: columns, rowHeight: 25, columnHeaderHeight: 35, showToolbar: true }) })] })] }));
|
|
82
48
|
}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { makeSimpleAltString } from '../../VcfFeature/util';
|
|
2
|
+
export function getSampleGridRows(samples, REF, ALT, filter) {
|
|
3
|
+
const preFilteredRows = Object.entries(samples).map(([key, val]) => {
|
|
4
|
+
var _a, _b;
|
|
5
|
+
return [
|
|
6
|
+
key,
|
|
7
|
+
{
|
|
8
|
+
...val,
|
|
9
|
+
GT: `${(_a = val.GT) === null || _a === void 0 ? void 0 : _a[0]}`,
|
|
10
|
+
genotype: makeSimpleAltString(`${(_b = val.GT) === null || _b === void 0 ? void 0 : _b[0]}`, REF, ALT),
|
|
11
|
+
},
|
|
12
|
+
];
|
|
13
|
+
});
|
|
14
|
+
let error;
|
|
15
|
+
let rows = [];
|
|
16
|
+
const filters = Object.keys(filter);
|
|
17
|
+
try {
|
|
18
|
+
rows = preFilteredRows
|
|
19
|
+
.map(([key, val]) => {
|
|
20
|
+
return {
|
|
21
|
+
...Object.fromEntries(Object.entries(val).map(([formatField, formatValue]) => [
|
|
22
|
+
formatField,
|
|
23
|
+
formatValue,
|
|
24
|
+
])),
|
|
25
|
+
sample: key,
|
|
26
|
+
id: key,
|
|
27
|
+
};
|
|
28
|
+
})
|
|
29
|
+
.filter(row => filters.length
|
|
30
|
+
? filters.every(key => {
|
|
31
|
+
const currFilter = filter[key];
|
|
32
|
+
return currFilter
|
|
33
|
+
? new RegExp(currFilter, 'i').exec(row[key])
|
|
34
|
+
: true;
|
|
35
|
+
})
|
|
36
|
+
: true);
|
|
37
|
+
}
|
|
38
|
+
catch (e) {
|
|
39
|
+
console.error(e);
|
|
40
|
+
error = e;
|
|
41
|
+
}
|
|
42
|
+
return { rows, error };
|
|
43
|
+
}
|
|
@@ -196,6 +196,7 @@ export default function MultiVariantBaseModelF(configSchema: AnyConfigurationSch
|
|
|
196
196
|
readonly renderDelay: number;
|
|
197
197
|
readonly TooltipComponent: import("@jbrowse/core/util").AnyReactComponentType;
|
|
198
198
|
readonly selectedFeatureId: string | undefined;
|
|
199
|
+
copyInfoToClipboard(feature: Feature): void;
|
|
199
200
|
} & {
|
|
200
201
|
readonly features: import("@jbrowse/core/util/compositeMap").default<string, Feature>;
|
|
201
202
|
readonly featureUnderMouse: Feature | undefined;
|
|
@@ -205,7 +206,7 @@ export default function MultiVariantBaseModelF(configSchema: AnyConfigurationSch
|
|
|
205
206
|
} & {
|
|
206
207
|
addBlock(key: string, block: import("@jbrowse/core/util/blockTypes").BaseBlock): void;
|
|
207
208
|
deleteBlock(key: string): void;
|
|
208
|
-
selectFeature(feature: Feature):
|
|
209
|
+
selectFeature(feature: Feature): void;
|
|
209
210
|
navToFeature(feature: Feature): void;
|
|
210
211
|
clearFeatureSelection(): void;
|
|
211
212
|
setFeatureIdUnderMouse(feature?: string): void;
|
|
@@ -184,6 +184,7 @@ export default function SharedVariantMixin(configSchema: AnyConfigurationSchemaT
|
|
|
184
184
|
readonly renderDelay: number;
|
|
185
185
|
readonly TooltipComponent: import("@jbrowse/core/util").AnyReactComponentType;
|
|
186
186
|
readonly selectedFeatureId: string | undefined;
|
|
187
|
+
copyInfoToClipboard(feature: Feature): void;
|
|
187
188
|
} & {
|
|
188
189
|
readonly features: import("@jbrowse/core/util/compositeMap").default<string, Feature>;
|
|
189
190
|
readonly featureUnderMouse: Feature | undefined;
|
|
@@ -193,7 +194,7 @@ export default function SharedVariantMixin(configSchema: AnyConfigurationSchemaT
|
|
|
193
194
|
} & {
|
|
194
195
|
addBlock(key: string, block: import("@jbrowse/core/util/blockTypes").BaseBlock): void;
|
|
195
196
|
deleteBlock(key: string): void;
|
|
196
|
-
selectFeature(feature: Feature):
|
|
197
|
+
selectFeature(feature: Feature): void;
|
|
197
198
|
navToFeature(feature: Feature): void;
|
|
198
199
|
clearFeatureSelection(): void;
|
|
199
200
|
setFeatureIdUnderMouse(feature?: string): void;
|
|
@@ -19,7 +19,7 @@ export default function SourcesDataGrid({ rows, onChange, setSelected, }) {
|
|
|
19
19
|
idx: 0,
|
|
20
20
|
field: null,
|
|
21
21
|
});
|
|
22
|
-
return (_jsx("div", { style: { height: 400, width: '100%' }, children: _jsx(DataGrid, { checkboxSelection: true, onRowSelectionModelChange: arg => {
|
|
22
|
+
return (_jsx("div", { style: { height: 400, width: '100%' }, children: _jsx(DataGrid, { checkboxSelection: true, disableRowSelectionOnClick: true, onRowSelectionModelChange: arg => {
|
|
23
23
|
setSelected([...arg.ids]);
|
|
24
24
|
}, rows: rows, rowHeight: 25, columnHeaderHeight: 33, columns: [
|
|
25
25
|
{
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@jbrowse/plugin-variants",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.5.1",
|
|
4
4
|
"description": "JBrowse 2 variant adapters, tracks, etc.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"jbrowse",
|
|
@@ -37,13 +37,13 @@
|
|
|
37
37
|
},
|
|
38
38
|
"dependencies": {
|
|
39
39
|
"@flatten-js/interval-tree": "^1.0.15",
|
|
40
|
-
"@gmod/bgzf-filehandle": "^
|
|
40
|
+
"@gmod/bgzf-filehandle": "^4.0.0",
|
|
41
41
|
"@gmod/tabix": "^3.0.1",
|
|
42
42
|
"@gmod/vcf": "^6.0.8",
|
|
43
|
-
"@jbrowse/core": "^3.
|
|
44
|
-
"@jbrowse/plugin-circular-view": "^3.
|
|
45
|
-
"@jbrowse/plugin-linear-genome-view": "^3.
|
|
46
|
-
"@jbrowse/sv-core": "^3.
|
|
43
|
+
"@jbrowse/core": "^3.5.1",
|
|
44
|
+
"@jbrowse/plugin-circular-view": "^3.5.1",
|
|
45
|
+
"@jbrowse/plugin-linear-genome-view": "^3.5.1",
|
|
46
|
+
"@jbrowse/sv-core": "^3.5.1",
|
|
47
47
|
"@mui/icons-material": "^7.0.0",
|
|
48
48
|
"@mui/material": "^7.0.0",
|
|
49
49
|
"@mui/x-data-grid": "^8.0.0",
|
|
@@ -63,5 +63,5 @@
|
|
|
63
63
|
"distModule": "esm/index.js",
|
|
64
64
|
"srcModule": "src/index.ts",
|
|
65
65
|
"module": "esm/index.js",
|
|
66
|
-
"gitHead": "
|
|
66
|
+
"gitHead": "cb8859da9d838ad2594964777c5c54f385d98f5e"
|
|
67
67
|
}
|