Skip to content

Commit

Permalink
[Platform]: fix handle credible-set without lead variant (#621)
Browse files Browse the repository at this point in the history
  • Loading branch information
carcruz authored Dec 11, 2024
1 parent 9af583e commit c917b21
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 28 deletions.
3 changes: 3 additions & 0 deletions apps/platform/src/pages/CredibleSetPage/ProfileHeader.gql
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@ fragment CredibleSetProfileHeaderFragment on credibleSet {
standardError
}
}
locusSize: locus(page: { size: 1, index: 0 }) {
count
}
variant {
chromosome
position
Expand Down
58 changes: 31 additions & 27 deletions apps/platform/src/pages/CredibleSetPage/ProfileHeader.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,15 @@ function ProfileHeader() {
if (error) return null;

const credibleSet = data?.credibleSet;
const leadVariant = credibleSet?.locus?.rows?.[0] || {};
const beta = leadVariant.beta ?? credibleSet?.beta;
const standardError = leadVariant.standardError ?? credibleSet?.standardError;
const study = credibleSet?.study;
const target = study?.target;
const leadVariant = credibleSet?.locus.rows[0];
const beta = leadVariant?.beta ?? credibleSet?.beta;
const standardError = leadVariant?.standardError ?? credibleSet?.standardError;

const { pValueMantissa, pValueExponent } =
typeof leadVariant?.pValueMantissa === "number" &&
typeof leadVariant?.pValueExponent === "number"
typeof leadVariant?.pValueExponent === "number"
? leadVariant
: credibleSet ?? {};

Expand Down Expand Up @@ -169,24 +170,26 @@ function ProfileHeader() {
>
{credibleSet?.purityMinR2?.toPrecision(3)}
</Field>
{credibleSet?.qualityControls?.length > 0 &&
{credibleSet?.qualityControls?.length > 0 && (
<Box>
<DetailPopover title="QC warnings">
<ul style={{
display: "flex",
flexDirection: "column",
gap: "0.25rem",
padding: 0,
margin: "0 0 0 1rem"
}}>
<ul
style={{
display: "flex",
flexDirection: "column",
gap: "0.25rem",
padding: 0,
margin: "0 0 0 1rem",
}}
>
{credibleSet.qualityControls.map(warning => (
<li key={warning}>{warning}</li>
))}
</ul>
</DetailPopover>
</Box>
}
</Box >
)}
</Box>

<Box>
<Typography variant="subtitle1" mt={0}>
Expand Down Expand Up @@ -260,25 +263,26 @@ function ProfileHeader() {
{study?.analysisFlags?.join(", ")}
</Field>
<Field loading={loading} title="Summary statistics">
{!study?.hasSumstats
? "Not Available"
: study?.sumstatQCValues
? <DetailPopover title="Available">
<SummaryStatsTable sumstatQCValues={study.sumstatQCValues} />
</DetailPopover>
: "Available"
}
{!study?.hasSumstats ? (
"Not Available"
) : study?.sumstatQCValues ? (
<DetailPopover title="Available">
<SummaryStatsTable sumstatQCValues={study.sumstatQCValues} />
</DetailPopover>
) : (
"Available"
)}
</Field>
{study?.nSamples &&
{study?.nSamples && (
<Field loading={loading} title="Sample size">
<DisplaySampleSize
nSamples={study.nSamples}
cohorts={study?.cohorts}
initialSampleSize={study?.initialSampleSize}
/>
</Field>
}
{study?.ldPopulationStructure?.length > 0 &&
)}
{study?.ldPopulationStructure?.length > 0 && (
<Box display="flex" sx={{ gap: 1 }}>
{study.ldPopulationStructure.map(({ ldPopulation, relativeSampleSize }) => (
<LabelChip
Expand All @@ -289,9 +293,9 @@ function ProfileHeader() {
/>
))}
</Box>
}
)}
</Box>
</BaseProfileHeader >
</BaseProfileHeader>
);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,7 @@ fragment VariantsSummaryFragment on credibleSet {
locus(variantIds: $variantIds) {
count
}
locusSize: locus(page: { size: 1, index: 0 }) {
count
}
}
2 changes: 1 addition & 1 deletion packages/sections/src/credibleSet/Variants/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@ export const definition = {
id,
name: "Credible Set Variants",
shortName: "VA",
hasData: data => data?.locus.count > 0,
hasData: data => data?.locus.count > 0 || data?.locusSize.count > 0,
};

0 comments on commit c917b21

Please sign in to comment.