From c917b21a17e08be0edfb024d05fcd2aaf9bcf4cf Mon Sep 17 00:00:00 2001 From: Carlos Cruz Date: Wed, 11 Dec 2024 03:56:38 -0600 Subject: [PATCH] [Platform]: fix handle credible-set without lead variant (#621) --- .../pages/CredibleSetPage/ProfileHeader.gql | 3 + .../pages/CredibleSetPage/ProfileHeader.tsx | 58 ++++++++++--------- .../Variants/VariantsSummaryFragment.gql | 3 + .../src/credibleSet/Variants/index.ts | 2 +- 4 files changed, 38 insertions(+), 28 deletions(-) diff --git a/apps/platform/src/pages/CredibleSetPage/ProfileHeader.gql b/apps/platform/src/pages/CredibleSetPage/ProfileHeader.gql index c5af1b08f..9feb13bfc 100644 --- a/apps/platform/src/pages/CredibleSetPage/ProfileHeader.gql +++ b/apps/platform/src/pages/CredibleSetPage/ProfileHeader.gql @@ -15,6 +15,9 @@ fragment CredibleSetProfileHeaderFragment on credibleSet { standardError } } + locusSize: locus(page: { size: 1, index: 0 }) { + count + } variant { chromosome position diff --git a/apps/platform/src/pages/CredibleSetPage/ProfileHeader.tsx b/apps/platform/src/pages/CredibleSetPage/ProfileHeader.tsx index ec5f2e263..94292533c 100644 --- a/apps/platform/src/pages/CredibleSetPage/ProfileHeader.tsx +++ b/apps/platform/src/pages/CredibleSetPage/ProfileHeader.tsx @@ -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 ?? {}; @@ -169,24 +170,26 @@ function ProfileHeader() { > {credibleSet?.purityMinR2?.toPrecision(3)} - {credibleSet?.qualityControls?.length > 0 && + {credibleSet?.qualityControls?.length > 0 && ( -
    +
      {credibleSet.qualityControls.map(warning => (
    • {warning}
    • ))}
    - } - + )} + @@ -260,16 +263,17 @@ function ProfileHeader() { {study?.analysisFlags?.join(", ")} - {!study?.hasSumstats - ? "Not Available" - : study?.sumstatQCValues - ? - - - : "Available" - } + {!study?.hasSumstats ? ( + "Not Available" + ) : study?.sumstatQCValues ? ( + + + + ) : ( + "Available" + )} - {study?.nSamples && + {study?.nSamples && ( - } - {study?.ldPopulationStructure?.length > 0 && + )} + {study?.ldPopulationStructure?.length > 0 && ( {study.ldPopulationStructure.map(({ ldPopulation, relativeSampleSize }) => ( ))} - } + )} - + ); } diff --git a/packages/sections/src/credibleSet/Variants/VariantsSummaryFragment.gql b/packages/sections/src/credibleSet/Variants/VariantsSummaryFragment.gql index 45060f92b..118c50555 100644 --- a/packages/sections/src/credibleSet/Variants/VariantsSummaryFragment.gql +++ b/packages/sections/src/credibleSet/Variants/VariantsSummaryFragment.gql @@ -2,4 +2,7 @@ fragment VariantsSummaryFragment on credibleSet { locus(variantIds: $variantIds) { count } + locusSize: locus(page: { size: 1, index: 0 }) { + count + } } diff --git a/packages/sections/src/credibleSet/Variants/index.ts b/packages/sections/src/credibleSet/Variants/index.ts index 3b9dab34d..4907a1674 100644 --- a/packages/sections/src/credibleSet/Variants/index.ts +++ b/packages/sections/src/credibleSet/Variants/index.ts @@ -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, };