Skip to content

Commit 1f57135

Browse files
authored
newest scatter plot (#178)
1 parent f14bae3 commit 1f57135

File tree

3 files changed

+76
-79
lines changed

3 files changed

+76
-79
lines changed

package-lock.json

Lines changed: 38 additions & 12 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@
3737
"@visx/tooltip": "^3",
3838
"@visx/zoom": "^3",
3939
"@weng-lab/genomebrowser": "^0.0.20",
40-
"@weng-lab/psychscreen-ui-components": "^2.0.13",
40+
"@weng-lab/psychscreen-ui-components": "^2.0.21",
4141
"copy-to-clipboard": "^3.3.3",
4242
"eslint-plugin-react": "^7",
4343
"eslint-plugin-react-hooks": "^5",

src/components/motifsearch/umap.tsx

Lines changed: 37 additions & 66 deletions
Original file line numberDiff line numberDiff line change
@@ -236,30 +236,11 @@ const MotifUMAP: React.FC<{ url: string; title: string }> = (props) => {
236236
};
237237

238238
const map = {
239-
defaultOpen: true,
240239
position: {
241240
right: 50,
242241
bottom: 50,
243-
},
244-
ref: graphContainerRef
245-
};
246-
247-
useEffect(() => {
248-
const graphElement = graphContainerRef.current;
249-
250-
const handleWheel = (event: WheelEvent) => {
251-
// Prevent default scroll behavior when using the wheel in the graph
252-
event.preventDefault();
253-
};
254-
if (graphElement) {
255-
graphElement.addEventListener('wheel', handleWheel, { passive: false });
256242
}
257-
return () => {
258-
if (graphElement) {
259-
graphElement.removeEventListener('wheel', handleWheel);
260-
}
261-
};
262-
}, []);
243+
};
263244

264245
return umapLoading ? (
265246
LoadingMemeUmap()
@@ -303,60 +284,50 @@ const MotifUMAP: React.FC<{ url: string; title: string }> = (props) => {
303284
<br />
304285
<Grid container spacing={5} alignItems={"flex-start"}>
305286
<Grid size={isMobile || isTablet ? 12 : 6}>
306-
<Stack overflow={"hidden"} padding={1} sx={{ border: '2px solid', borderColor: 'grey.400', borderRadius: '8px', height: '57vh', position: 'relative' }} ref={graphContainerRef}>
287+
<Stack overflow={"hidden"} padding={1} sx={{ border: '2px solid', borderColor: 'grey.400', borderRadius: '8px', height: '60vh', position: 'relative' }} ref={graphContainerRef}>
307288
<Stack direction="row" justifyContent="space-between" mt={1} sx={{ backgroundColor: '#dbdefc', borderRadius: '8px', zIndex: 10 }}>
308289
<Button endIcon={selection.length !== 0 && <Visibility />}>
309290
{`${selection.length} Motifs Selected`}
310291
</Button>
311292
<Button onClick={() => setSelection([])}>Clear Selection</Button>
312293
</Stack>
313-
<ParentSize>
314-
{({ width, height }) => {
315-
const squareSize = Math.min(width, height);
316-
294+
<ScatterPlot
295+
pointData={scatterData}
296+
loading={umapLoading}
297+
selectable
298+
onSelectionChange={handleSelectionChange}
299+
miniMap={map}
300+
leftAxisLabel="UMAP-2"
301+
bottomAxisLabel="UMAP-1"
302+
tooltipBody={(point) => {
303+
const formattedPWM = point.metaData?.pwm
304+
? formatPWM(point.metaData.pwm)
305+
: null;
317306
return (
318-
<ScatterPlot
319-
width={squareSize}
320-
height={squareSize}
321-
pointData={scatterData}
322-
loading={umapLoading}
323-
selectable
324-
onSelectionChange={handleSelectionChange}
325-
miniMap={map}
326-
leftAxisLable="UMAP-2"
327-
bottomAxisLabel="UMAP-1"
328-
tooltipBody={(point) => {
329-
const formattedPWM = point.metaData?.pwm
330-
? formatPWM(point.metaData.pwm)
331-
: null;
332-
return (
333-
<Box sx={{ textAlign: "center", p: 1 }}>
334-
{formattedPWM && (
335-
<DNALogo ppm={formattedPWM} height={100} />
336-
)}
337-
{point.metaData?.tooltipValues && (
338-
<>
339-
<Typography variant="body2">
340-
<strong>Accession:</strong>{" "}
341-
{point.metaData.tooltipValues.accession}
342-
</Typography>
343-
<Typography variant="body2">
344-
<strong>DBD:</strong>{" "}
345-
{point.metaData.tooltipValues.dbd}
346-
</Typography>
347-
<Typography variant="body2">
348-
<strong>Factor:</strong>{" "}
349-
{point.metaData.tooltipValues.factor}
350-
</Typography>
351-
</>
352-
)}
353-
</Box>
354-
);
355-
}}
356-
/>
357-
)
307+
<Box sx={{ textAlign: "center", p: 1 }}>
308+
{formattedPWM && (
309+
<DNALogo ppm={formattedPWM} height={100} />
310+
)}
311+
{point.metaData?.tooltipValues && (
312+
<>
313+
<Typography variant="body2">
314+
<strong>Accession:</strong>{" "}
315+
{point.metaData.tooltipValues.accession}
316+
</Typography>
317+
<Typography variant="body2">
318+
<strong>DBD:</strong>{" "}
319+
{point.metaData.tooltipValues.dbd}
320+
</Typography>
321+
<Typography variant="body2">
322+
<strong>Factor:</strong>{" "}
323+
{point.metaData.tooltipValues.factor}
324+
</Typography>
325+
</>
326+
)}
327+
</Box>
328+
);
358329
}}
359-
</ParentSize>
330+
/>
360331
</Stack>
361332
</Grid>
362333
<Grid size={isMobile || isTablet ? 12 : 6}>

0 commit comments

Comments
 (0)