Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Platform]: Fix lead variant link from PheWas plot tooltip #620

Merged
merged 1 commit into from
Dec 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions packages/sections/src/variant/GWASCredibleSets/Body.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import {
import PheWasPlot from "./PheWasPlot";
import { useEffect, useState } from "react";
import { responseType } from "ui/src/types/response";
import { v1 } from "uuid";

type getColumnsType = {
id: string;
Expand Down Expand Up @@ -286,6 +287,7 @@ function Body({ id, entity }: BodyProps) {
});
return (
<PheWasPlot
key={v1()}
columns={columns}
query={GWAS_CREDIBLE_SETS_QUERY.loc.source.body}
variables={variables}
Expand Down
30 changes: 19 additions & 11 deletions packages/sections/src/variant/GWASCredibleSets/PheWasPlot.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Box, Skeleton, Typography, useTheme } from "@mui/material";
import { Box, Chip, Skeleton, Typography, useTheme } from "@mui/material";
import { faArrowRightToBracket } from "@fortawesome/free-solid-svg-icons";
import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
import {
Expand Down Expand Up @@ -77,6 +77,7 @@ export default function PheWasPlot({
variables,
columns,
}) {

const theme = useTheme();
const background = theme.palette.background.paper;
const fontFamily = theme.typography.fontFamily;
Expand Down Expand Up @@ -264,7 +265,7 @@ export default function PheWasPlot({
y={d => yMin}
pxWidth={tooltipWidth}
pxHeight={tooltipHeight}
content={tooltipContent}
content={d => tooltipContent(d, id)}
xOffset={40}
yOffset={-20}
/>
Expand All @@ -278,8 +279,16 @@ export default function PheWasPlot({
);
}

function tooltipContent(data) {
function tooltipContent(data, pageVariantId) {
const labelWidth = 160;

const displayId = <DisplayVariantId
variantId={data.variant.id}
referenceAllele={data.variant.referenceAllele}
alternateAllele={data.variant.alternateAllele}
expand={false}
/>;

return (
<HTMLTooltipTable>
<HTMLTooltipRow label="Navigate" data={data} labelWidth={labelWidth}>
Expand All @@ -288,14 +297,13 @@ function tooltipContent(data) {
</Link>
</HTMLTooltipRow>
<HTMLTooltipRow label="Lead variant" data={data} labelWidth={labelWidth}>
<Link to={`/variant/${data.variant.id}`}>
<DisplayVariantId
variantId={data.variant.id}
referenceAllele={data.variant.referenceAllele}
alternateAllele={data.variant.alternateAllele}
expand={false}
/>
</Link>
{data.variant.id === pageVariantId
? <Box display="flex" alignItems="center" gap={0.5}>
{displayId}
<Chip label="self" variant="outlined" size="small" />
</Box>
: <Link to={`/variant/${data.variant.id}`}>{displayId}</Link>
}
</HTMLTooltipRow>
<HTMLTooltipRow
label="Reported trait"
Expand Down
Loading