@jbrowse/plugin-variants 4.1.3 → 4.1.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (41) hide show
  1. package/esm/ChordVariantDisplay/models/configSchema.d.ts +2 -2
  2. package/esm/LDDisplay/SharedLDConfigSchema.d.ts +3 -3
  3. package/esm/LDDisplay/components/LDDisplayComponent.js +3 -1
  4. package/esm/LDDisplay/components/LinesConnectingMatrixToGenomicPosition.d.ts +0 -9
  5. package/esm/LDDisplay/components/LinesConnectingMatrixToGenomicPosition.js +3 -29
  6. package/esm/LDDisplay/components/VariantLabels.d.ts +5 -0
  7. package/esm/LDDisplay/components/VariantLabels.js +27 -0
  8. package/esm/LDDisplay/components/Wrapper.d.ts +8 -0
  9. package/esm/LDDisplay/components/Wrapper.js +16 -0
  10. package/esm/LDDisplay/configSchema1.d.ts +6 -6
  11. package/esm/LDDisplay/configSchema2.d.ts +6 -6
  12. package/esm/LDDisplay/renderSvg.js +3 -1
  13. package/esm/LDRenderer/configSchema.d.ts +2 -2
  14. package/esm/LDTrack/configSchema.d.ts +8 -8
  15. package/esm/LinearVariantDisplay/configSchema.d.ts +3 -3
  16. package/esm/LinearVariantDisplay/model.d.ts +18 -8
  17. package/esm/MultiLinearVariantDisplay/configSchema.d.ts +6 -6
  18. package/esm/MultiLinearVariantDisplay/model.d.ts +72 -18
  19. package/esm/MultiLinearVariantMatrixDisplay/configSchema.d.ts +5 -5
  20. package/esm/MultiLinearVariantMatrixDisplay/model.d.ts +76 -20
  21. package/esm/MultiLinearVariantMatrixRenderer/configSchema.d.ts +1 -1
  22. package/esm/MultiLinearVariantRenderer/configSchema.d.ts +1 -1
  23. package/esm/PlinkLDAdapter/configSchema.d.ts +2 -2
  24. package/esm/PlinkLDAdapter/configSchemaTabix.d.ts +4 -4
  25. package/esm/SplitVcfTabixAdapter/configSchema.d.ts +2 -2
  26. package/esm/StructuralVariantChordRenderer/configSchema.d.ts +2 -2
  27. package/esm/VariantFeatureWidget/configSchema.d.ts +1 -1
  28. package/esm/VariantFeatureWidget/stateModelFactory.d.ts +2 -2
  29. package/esm/VariantTrack/configSchema.d.ts +8 -8
  30. package/esm/VcfAdapter/configSchema.d.ts +2 -2
  31. package/esm/VcfTabixAdapter/configSchema.d.ts +4 -4
  32. package/esm/shared/MultiVariantBaseModel.d.ts +76 -20
  33. package/esm/shared/MultiVariantBaseModel.js +53 -3
  34. package/esm/shared/SharedVariantConfigSchema.d.ts +3 -3
  35. package/esm/shared/components/RectBg.js +3 -1
  36. package/esm/shared/components/TreeSidebar.js +38 -5
  37. package/esm/shared/components/types.d.ts +2 -0
  38. package/esm/shared/constants.d.ts +1 -0
  39. package/esm/shared/constants.js +1 -0
  40. package/esm/shared/makeSidebarSvg.js +3 -2
  41. package/package.json +8 -8
@@ -1,8 +1,10 @@
1
1
  import { jsx as _jsx } from "react/jsx-runtime";
2
2
  import { getFillProps } from '@jbrowse/core/util';
3
3
  import { alpha, useTheme } from '@mui/material';
4
+ import { SIDEBAR_BACKGROUND_OPACITY } from "../constants.js";
4
5
  const RectBg = ({ x, y, width, height, color, }) => {
5
6
  const theme = useTheme();
6
- return (_jsx("rect", { pointerEvents: "auto", x: x, y: y, width: width, height: height, ...getFillProps(color || alpha(theme.palette.background.paper, 0.8)) }));
7
+ return (_jsx("rect", { pointerEvents: "auto", x: x, y: y, width: width, height: height, ...getFillProps(color ||
8
+ alpha(theme.palette.background.paper, SIDEBAR_BACKGROUND_OPACITY)) }));
7
9
  };
8
10
  export default RectBg;
@@ -4,9 +4,10 @@ import { ResizeHandle } from '@jbrowse/core/ui';
4
4
  import { getContainingView } from '@jbrowse/core/util';
5
5
  import Flatbush from '@jbrowse/core/util/flatbush';
6
6
  import { makeStyles } from '@jbrowse/core/util/tss-react';
7
- import { alpha } from '@mui/material';
7
+ import { Menu, MenuItem, alpha } from '@mui/material';
8
8
  import { autorun } from 'mobx';
9
9
  import { observer } from 'mobx-react';
10
+ import { SIDEBAR_BACKGROUND_OPACITY } from "../constants.js";
10
11
  const useStyles = makeStyles()(theme => ({
11
12
  resizeHandle: {
12
13
  position: 'absolute',
@@ -23,7 +24,7 @@ const useStyles = makeStyles()(theme => ({
23
24
  position: 'absolute',
24
25
  top: 0,
25
26
  left: 0,
26
- background: alpha(theme.palette.background.paper, 0.8),
27
+ background: alpha(theme.palette.background.paper, SIDEBAR_BACKGROUND_OPACITY),
27
28
  },
28
29
  }));
29
30
  function getDescendantNames(node) {
@@ -37,6 +38,7 @@ const TreeSidebar = observer(function TreeSidebar({ model, }) {
37
38
  const { width: viewWidth } = getContainingView(model);
38
39
  const [nodeIndex, setNodeIndex] = useState(null);
39
40
  const [nodeData, setNodeData] = useState([]);
41
+ const [menuAnchor, setMenuAnchor] = useState(null);
40
42
  const { hierarchy, treeAreaWidth, height, scrollTop, showTree, sources } = model;
41
43
  const treeCanvasRef = useCallback((ref) => {
42
44
  model.setTreeCanvasRef(ref);
@@ -47,7 +49,7 @@ const TreeSidebar = observer(function TreeSidebar({ model, }) {
47
49
  useEffect(() => {
48
50
  return autorun(function treeSpatialIndexAutorun() {
49
51
  const { treeAreaWidth: _t, hierarchy: h, totalHeight: th } = model;
50
- void th;
52
+ th;
51
53
  if (!h) {
52
54
  setNodeIndex(null);
53
55
  setNodeData([]);
@@ -88,6 +90,27 @@ const TreeSidebar = observer(function TreeSidebar({ model, }) {
88
90
  const handleMouseLeave = useCallback(() => {
89
91
  model.setHoveredTreeNode(undefined);
90
92
  }, [model]);
93
+ const handleClick = useCallback((event) => {
94
+ if (!hierarchy || !nodeIndex) {
95
+ return;
96
+ }
97
+ const rect = event.currentTarget.getBoundingClientRect();
98
+ const x = event.clientX - rect.left;
99
+ const y = event.clientY - rect.top + scrollTop;
100
+ const results = nodeIndex.search(x, y, x, y);
101
+ const node = results.length > 0 ? nodeData[results[0]] : undefined;
102
+ if (node) {
103
+ const descendantNames = getDescendantNames(node);
104
+ setMenuAnchor({
105
+ x: event.clientX,
106
+ y: event.clientY,
107
+ names: descendantNames,
108
+ });
109
+ }
110
+ }, [hierarchy, nodeIndex, nodeData, scrollTop]);
111
+ const handleCloseMenu = useCallback(() => {
112
+ setMenuAnchor(null);
113
+ }, []);
91
114
  if (!hierarchy || !showTree || !sources?.length) {
92
115
  return null;
93
116
  }
@@ -108,12 +131,14 @@ const TreeSidebar = observer(function TreeSidebar({ model, }) {
108
131
  left: 0,
109
132
  pointerEvents: 'none',
110
133
  } }), _jsx("canvas", { ref: mouseoverCanvasRef, width: viewWidth, height: height, style: {
134
+ width: viewWidth,
135
+ height,
111
136
  position: 'absolute',
112
137
  top: 0,
113
138
  left: 0,
114
139
  zIndex: 1,
115
140
  pointerEvents: 'none',
116
- } }), _jsx("div", { onMouseMove: handleMouseMove, onMouseLeave: handleMouseLeave, style: {
141
+ } }), _jsx("div", { onMouseMove: handleMouseMove, onMouseLeave: handleMouseLeave, onClick: handleClick, style: {
117
142
  position: 'absolute',
118
143
  top: 0,
119
144
  left: 0,
@@ -126,6 +151,14 @@ const TreeSidebar = observer(function TreeSidebar({ model, }) {
126
151
  return undefined;
127
152
  }, className: classes.resizeHandle, style: {
128
153
  left: treeAreaWidth,
129
- }, vertical: true })] }));
154
+ }, vertical: true }), _jsxs(Menu, { open: !!menuAnchor, onClose: handleCloseMenu, anchorReference: "anchorPosition", anchorPosition: menuAnchor ? { top: menuAnchor.y, left: menuAnchor.x } : undefined, children: [model.subtreeFilter?.length ? (_jsx(MenuItem, { onClick: () => {
155
+ model.setSubtreeFilter(undefined);
156
+ handleCloseMenu();
157
+ }, children: "Clear subtree filter" })) : null, _jsxs(MenuItem, { onClick: () => {
158
+ if (menuAnchor) {
159
+ model.setSubtreeFilter(menuAnchor.names);
160
+ }
161
+ handleCloseMenu();
162
+ }, children: ["Show only subtree (", menuAnchor?.names.length, " samples)"] })] })] }));
130
163
  });
131
164
  export default TreeSidebar;
@@ -18,10 +18,12 @@ export interface TreeSidebarModel {
18
18
  scrollTop: number;
19
19
  showTree: boolean;
20
20
  sources?: Source[];
21
+ subtreeFilter?: string[];
21
22
  setTreeCanvasRef: (ref: HTMLCanvasElement | null) => void;
22
23
  setMouseoverCanvasRef: (ref: HTMLCanvasElement | null) => void;
23
24
  setHoveredTreeNode: (node?: HoveredTreeNode) => void;
24
25
  setTreeAreaWidth: (width: number) => void;
26
+ setSubtreeFilter: (names?: string[]) => void;
25
27
  }
26
28
  export interface LegendBarModel {
27
29
  id: string;
@@ -1,4 +1,5 @@
1
1
  export declare const f2 = 0.3;
2
+ export declare const SIDEBAR_BACKGROUND_OPACITY = 0.8;
2
3
  export declare const REFERENCE_COLOR = "#ccc";
3
4
  export declare const NO_CALL_COLOR = "hsl(50,50%,50%)";
4
5
  export declare const UNPHASED_COLOR = "black";
@@ -1,4 +1,5 @@
1
1
  export const f2 = 0.3;
2
+ export const SIDEBAR_BACKGROUND_OPACITY = 0.8;
2
3
  export const REFERENCE_COLOR = '#ccc';
3
4
  export const NO_CALL_COLOR = 'hsl(50,50%,50%)';
4
5
  export const UNPHASED_COLOR = 'black';
@@ -1,9 +1,10 @@
1
- import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
1
+ import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  import { getContainingView } from '@jbrowse/core/util';
3
+ import RectBg from "./components/RectBg.js";
3
4
  import SvgTree from "./components/SvgTree.js";
4
5
  import LegendBar from "../shared/components/MultiVariantLegendBar.js";
5
6
  export async function makeSidebarSvg(self) {
6
7
  const { offsetPx } = getContainingView(self);
7
8
  const { hierarchy, showTree, treeAreaWidth, availableHeight } = self;
8
- return (_jsxs("g", { id: "tree-layer", "data-testid": "tree-layer", transform: `translate(${Math.max(-offsetPx, 0)})`, clipPath: "url(#sidebarClip)", children: [_jsx("clipPath", { id: "sidebarClip", children: _jsx("rect", { x: "0", y: "0", width: "100%", height: availableHeight }) }), _jsx("g", { id: "legend-layer", transform: `translate(${showTree && hierarchy ? treeAreaWidth : 0})`, children: _jsx(LegendBar, { model: self, orientation: "left", exportSVG: true }) }), showTree ? _jsx(SvgTree, { model: self }) : null] }));
9
+ return (_jsxs("g", { id: "tree-layer", "data-testid": "tree-layer", transform: `translate(${Math.max(-offsetPx, 0)})`, clipPath: "url(#sidebarClip)", children: [_jsx("clipPath", { id: "sidebarClip", children: _jsx("rect", { x: "0", y: "0", width: "100%", height: availableHeight }) }), _jsx("g", { id: "legend-layer", transform: `translate(${showTree && hierarchy ? treeAreaWidth : 0})`, children: _jsx(LegendBar, { model: self, orientation: "left", exportSVG: true }) }), showTree && hierarchy ? (_jsxs(_Fragment, { children: [_jsx(RectBg, { x: 0, y: 0, width: treeAreaWidth, height: availableHeight }), _jsx(SvgTree, { model: self })] })) : null] }));
9
10
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jbrowse/plugin-variants",
3
- "version": "4.1.3",
3
+ "version": "4.1.4",
4
4
  "type": "module",
5
5
  "description": "JBrowse 2 variant adapters, tracks, etc.",
6
6
  "keywords": [
@@ -26,10 +26,10 @@
26
26
  "@gmod/tabix": "^3.2.2",
27
27
  "@gmod/vcf": "^7.0.0",
28
28
  "@jbrowse/mobx-state-tree": "^5.5.0",
29
- "@mui/icons-material": "^7.3.7",
30
- "@mui/material": "^7.3.7",
29
+ "@mui/icons-material": "^7.3.8",
30
+ "@mui/material": "^7.3.8",
31
31
  "@mui/x-charts-vendor": "^8.26.0",
32
- "@mui/x-data-grid": "^8.26.0",
32
+ "@mui/x-data-grid": "^8.27.1",
33
33
  "@types/file-saver-es": "^2.0.3",
34
34
  "copy-to-clipboard": "^3.3.3",
35
35
  "escape-html": "^1.0.3",
@@ -38,10 +38,10 @@
38
38
  "mobx": "^6.15.0",
39
39
  "mobx-react": "^9.2.1",
40
40
  "rxjs": "^7.8.2",
41
- "@jbrowse/plugin-linear-genome-view": "^4.1.3",
42
- "@jbrowse/core": "^4.1.3",
43
- "@jbrowse/plugin-circular-view": "^4.1.3",
44
- "@jbrowse/sv-core": "^4.1.3"
41
+ "@jbrowse/plugin-circular-view": "^4.1.4",
42
+ "@jbrowse/core": "^4.1.4",
43
+ "@jbrowse/plugin-linear-genome-view": "^4.1.4",
44
+ "@jbrowse/sv-core": "^4.1.4"
45
45
  },
46
46
  "peerDependencies": {
47
47
  "react": ">=18.0.0"