From 4d24c404e1225ada374b1e4a65ace95919e5f692 Mon Sep 17 00:00:00 2001 From: Chintan Mehta Date: Fri, 22 Nov 2024 11:07:59 +0000 Subject: [PATCH 1/2] variant page query update --- .../src/variant/GWASCredibleSets/Body.tsx | 14 ++--- .../GWASCredibleSetsQuery.gql | 63 ++++++++++--------- .../GWASCredibleSetsSummaryFragment.gql | 9 +-- .../src/variant/GWASCredibleSets/index.ts | 3 +- .../src/variant/QTLCredibleSets/Body.tsx | 14 ++--- .../QTLCredibleSets/QTLCredibleSetsQuery.gql | 61 ++++++++++-------- .../QTLCredibleSetsSummaryFragment.gql | 10 +-- .../src/variant/QTLCredibleSets/index.ts | 5 +- 8 files changed, 94 insertions(+), 85 deletions(-) diff --git a/packages/sections/src/variant/GWASCredibleSets/Body.tsx b/packages/sections/src/variant/GWASCredibleSets/Body.tsx index 5ea988712..1779109f6 100644 --- a/packages/sections/src/variant/GWASCredibleSets/Body.tsx +++ b/packages/sections/src/variant/GWASCredibleSets/Body.tsx @@ -154,10 +154,10 @@ function getColumns({ id, referenceAllele, alternateAllele }: getColumnsType) { ), comparator: (rowA, rowB) => - rowA.locus[0].posteriorProbability - rowB.locus[0].posteriorProbability, + rowA.locus.rows[0].posteriorProbability - rowB.locus.rows[0].posteriorProbability, sortable: true, - renderCell: ({ locus }) => locus[0]?.posteriorProbability.toFixed(3) ?? naLabel, - exportValue: ({ locus }) => locus[0]?.posteriorProbability.toFixed(3), + renderCell: ({ locus }) => locus.rows[0]?.posteriorProbability.toFixed(3) ?? naLabel, + exportValue: ({ locus }) => locus.rows[0]?.posteriorProbability.toFixed(3), }, { id: "confidence", @@ -206,11 +206,11 @@ function getColumns({ id, referenceAllele, alternateAllele }: getColumnsType) { { id: "credibleSetSize", label: "Credible set size", - comparator: (a, b) => a.locus?.length - b.locus?.length, + comparator: (a, b) => a.locus?.count - b.locus?.count, sortable: true, filterValue: false, - renderCell: ({ locus }) => locus?.length ?? naLabel, - exportValue: ({ locus }) => locus?.length, + renderCell: ({ locus }) => locus?.count ?? naLabel, + exportValue: ({ locus }) => locus?.count, }, ]; } @@ -254,7 +254,7 @@ function Body({ id, entity }: BodyProps) { referenceAllele: request.data?.variant.referenceAllele, alternateAllele: request.data?.variant.alternateAllele, })} - rows={request.data?.variant.credibleSets} + rows={request.data?.variant.gwasCredibleSets.rows} loading={request.loading} query={GWAS_CREDIBLE_SETS_QUERY.loc.source.body} variables={variables} diff --git a/packages/sections/src/variant/GWASCredibleSets/GWASCredibleSetsQuery.gql b/packages/sections/src/variant/GWASCredibleSets/GWASCredibleSetsQuery.gql index 54465bcd5..5499ce7c1 100644 --- a/packages/sections/src/variant/GWASCredibleSets/GWASCredibleSetsQuery.gql +++ b/packages/sections/src/variant/GWASCredibleSets/GWASCredibleSetsQuery.gql @@ -3,38 +3,43 @@ query GWASCredibleSetsQuery($variantId: String!, $size: Int!) { id referenceAllele alternateAllele - credibleSets(studyTypes: [gwas], page: { size: $size, index: 0 }) { - studyLocusId - pValueMantissa - pValueExponent - beta - finemappingMethod - confidence - variant { - id - chromosome - position - referenceAllele - alternateAllele - } - study { - traitFromSource - studyId - diseases { - name + gwasCredibleSets: credibleSets(studyTypes: [gwas], page: { size: $size, index: 0 }) { + count + rows { + studyLocusId + pValueMantissa + pValueExponent + beta + finemappingMethod + confidence + variant { id + chromosome + position + referenceAllele + alternateAllele } - } - locus(variantIds: [$variantId]) { - r2Overall - posteriorProbability - } - l2Gpredictions(size: 1) { - target { - id - approvedSymbol + study { + traitFromSource + studyId + diseases { + name + id + } + } + locus(variantIds: [$variantId]) { + count + rows { + posteriorProbability + } + } + l2Gpredictions(size: 1) { + target { + id + approvedSymbol + } + score } - score } } } diff --git a/packages/sections/src/variant/GWASCredibleSets/GWASCredibleSetsSummaryFragment.gql b/packages/sections/src/variant/GWASCredibleSets/GWASCredibleSetsSummaryFragment.gql index bd87f01cb..fd8e2cb10 100644 --- a/packages/sections/src/variant/GWASCredibleSets/GWASCredibleSetsSummaryFragment.gql +++ b/packages/sections/src/variant/GWASCredibleSets/GWASCredibleSetsSummaryFragment.gql @@ -1,8 +1,5 @@ fragment GWASCredibleSetsSummaryFragment on Variant { - gwasCredibleSets: credibleSets( - studyTypes: [gwas], - page: { size: 1, index: 0 } - ) { - studyLocusId + gwasCredibleSets: credibleSets(studyTypes: [gwas], page: { size: 1, index: 0 }) { + count } -} \ No newline at end of file +} diff --git a/packages/sections/src/variant/GWASCredibleSets/index.ts b/packages/sections/src/variant/GWASCredibleSets/index.ts index a619d1ec7..966e3507d 100644 --- a/packages/sections/src/variant/GWASCredibleSets/index.ts +++ b/packages/sections/src/variant/GWASCredibleSets/index.ts @@ -3,6 +3,5 @@ export const definition = { id, name: "GWAS Credible Sets", shortName: "GW", - hasData: data => data?.gwasCredibleSets?.length > 0 || - data?.credibleSets?.length > 0, + hasData: data => data?.gwasCredibleSets?.count > 0, }; diff --git a/packages/sections/src/variant/QTLCredibleSets/Body.tsx b/packages/sections/src/variant/QTLCredibleSets/Body.tsx index ab5943ff5..3daa5ebc3 100644 --- a/packages/sections/src/variant/QTLCredibleSets/Body.tsx +++ b/packages/sections/src/variant/QTLCredibleSets/Body.tsx @@ -159,10 +159,10 @@ function getColumns({ id, referenceAllele, alternateAllele }: getColumnsType) { ), comparator: (rowA, rowB) => - rowA.locus[0].posteriorProbability - rowB.locus[0].posteriorProbability, + rowA.locus.rows[0].posteriorProbability - rowB.locus.rows[0].posteriorProbability, sortable: true, - renderCell: ({ locus }) => locus[0]?.posteriorProbability.toFixed(3) ?? naLabel, - exportValue: ({ locus }) => locus[0]?.posteriorProbability.toFixed(3), + renderCell: ({ locus }) => locus.rows[0]?.posteriorProbability.toFixed(3) ?? naLabel, + exportValue: ({ locus }) => locus.rows[0]?.posteriorProbability.toFixed(3), }, { id: "confidence", @@ -185,11 +185,11 @@ function getColumns({ id, referenceAllele, alternateAllele }: getColumnsType) { { id: "credibleSetSize", label: "Credible set size", - comparator: (a, b) => a.locus?.length - b.locus?.length, + comparator: (a, b) => a.locus?.count - b.locus?.count, sortable: true, filterValue: false, - renderCell: ({ locus }) => locus?.length ?? naLabel, - exportValue: ({ locus }) => locus?.length, + renderCell: ({ locus }) => locus?.count ?? naLabel, + exportValue: ({ locus }) => locus?.count, }, ]; } @@ -232,7 +232,7 @@ function Body({ id, entity }: BodyProps): ReactNode { referenceAllele: request.data?.variant.referenceAllele, alternateAllele: request.data?.variant.alternateAllele, })} - rows={request.data?.variant.credibleSets} + rows={request.data?.variant.qtlCredibleSets.rows} loading={request.loading} query={QTL_CREDIBLE_SETS_QUERY.loc.source.body} variables={variables} diff --git a/packages/sections/src/variant/QTLCredibleSets/QTLCredibleSetsQuery.gql b/packages/sections/src/variant/QTLCredibleSets/QTLCredibleSetsQuery.gql index 21fa2fa6d..6f5f16d35 100644 --- a/packages/sections/src/variant/QTLCredibleSets/QTLCredibleSetsQuery.gql +++ b/packages/sections/src/variant/QTLCredibleSets/QTLCredibleSetsQuery.gql @@ -3,36 +3,45 @@ query QTLCredibleSetsQuery($variantId: String!, $size: Int!) { id referenceAllele alternateAllele - credibleSets(studyTypes: [sqtl, pqtl, eqtl, tuqtl], page: { size: $size, index: 0 }) { - studyLocusId - pValueMantissa - pValueExponent - beta - finemappingMethod - confidence + qtlCredibleSets: credibleSets( + studyTypes: [sqtl, pqtl, eqtl, tuqtl] + page: { size: $size, index: 0 } + ) { + count + rows { + studyLocusId + pValueMantissa + pValueExponent + beta + finemappingMethod + confidence - variant { - id - chromosome - position - referenceAllele - alternateAllele - } - study { - studyId - studyType - condition - target { + variant { id - approvedSymbol + chromosome + position + referenceAllele + alternateAllele } - biosample { - biosampleId - biosampleName + study { + studyId + studyType + condition + target { + id + approvedSymbol + } + biosample { + biosampleId + biosampleName + } + } + locus(variantIds: [$variantId]) { + count + rows { + posteriorProbability + } } - } - locus(variantIds: [$variantId]) { - posteriorProbability } } } diff --git a/packages/sections/src/variant/QTLCredibleSets/QTLCredibleSetsSummaryFragment.gql b/packages/sections/src/variant/QTLCredibleSets/QTLCredibleSetsSummaryFragment.gql index 82901fce6..d517b547c 100644 --- a/packages/sections/src/variant/QTLCredibleSets/QTLCredibleSetsSummaryFragment.gql +++ b/packages/sections/src/variant/QTLCredibleSets/QTLCredibleSetsSummaryFragment.gql @@ -1,8 +1,8 @@ fragment QTLCredibleSetsSummaryFragment on Variant { qtlCredibleSets: credibleSets( - studyTypes: [sqtl, pqtl, eqtl, tuqtl], - page: { size: 1, index: 0 } - ) { - studyLocusId + studyTypes: [sqtl, pqtl, eqtl, tuqtl] + page: { size: 1, index: 0 } + ) { + count } -} \ No newline at end of file +} diff --git a/packages/sections/src/variant/QTLCredibleSets/index.ts b/packages/sections/src/variant/QTLCredibleSets/index.ts index 3a9624e9e..599d76fe9 100644 --- a/packages/sections/src/variant/QTLCredibleSets/index.ts +++ b/packages/sections/src/variant/QTLCredibleSets/index.ts @@ -3,6 +3,5 @@ export const definition = { id, name: "molQTL Credible Sets", shortName: "QT", - hasData: data => data?.qtlCredibleSets?.length > 0 || - data?.credibleSets?.length > 0, -}; \ No newline at end of file + hasData: data => data?.qtlCredibleSets?.count > 0, +}; From 6239a323e7202fc73593cf6e14797f15d7b3a692 Mon Sep 17 00:00:00 2001 From: Chintan Mehta Date: Fri, 22 Nov 2024 12:36:09 +0000 Subject: [PATCH 2/2] credible sets query fix --- .../pages/CredibleSetPage/CredibleSetPage.gql | 4 +- .../pages/CredibleSetPage/CredibleSetPage.tsx | 6 +- .../src/pages/CredibleSetPage/Profile.tsx | 8 +- .../pages/CredibleSetPage/ProfileHeader.gql | 18 +-- .../pages/CredibleSetPage/ProfileHeader.tsx | 121 +++++++++--------- .../src/credibleSet/GWASColoc/Body.tsx | 4 +- .../credibleSet/GWASColoc/GWASColocQuery.gql | 6 +- .../src/credibleSet/GWASColoc/index.ts | 4 +- .../src/credibleSet/GWASMolQTL/Body.tsx | 4 +- .../GWASMolQTL/GWASMolQTLColocQuery.gql | 4 +- .../src/credibleSet/GWASMolQTL/index.ts | 2 +- .../src/credibleSet/Locus2Gene/Body.tsx | 4 +- .../Locus2Gene/Locus2GeneQuery.gql | 4 +- .../src/credibleSet/Locus2Gene/index.ts | 2 +- .../src/credibleSet/Variants/Body.tsx | 5 +- .../credibleSet/Variants/VariantsQuery.gql | 35 ++--- .../Variants/VariantsSummaryFragment.gql | 6 +- .../src/credibleSet/Variants/index.ts | 4 +- 18 files changed, 121 insertions(+), 120 deletions(-) diff --git a/apps/platform/src/pages/CredibleSetPage/CredibleSetPage.gql b/apps/platform/src/pages/CredibleSetPage/CredibleSetPage.gql index 335ca68b0..b8fd51ee9 100644 --- a/apps/platform/src/pages/CredibleSetPage/CredibleSetPage.gql +++ b/apps/platform/src/pages/CredibleSetPage/CredibleSetPage.gql @@ -1,5 +1,5 @@ -query CredibleSetPageQuery($studyLocusIds: [String!]!) { - credibleSets(studyLocusIds: $studyLocusIds) { +query CredibleSetPageQuery($studyLocusId: String!) { + credibleSet(studyLocusId: $studyLocusId) { variant { id referenceAllele diff --git a/apps/platform/src/pages/CredibleSetPage/CredibleSetPage.tsx b/apps/platform/src/pages/CredibleSetPage/CredibleSetPage.tsx index e90641f10..7ac373d22 100644 --- a/apps/platform/src/pages/CredibleSetPage/CredibleSetPage.tsx +++ b/apps/platform/src/pages/CredibleSetPage/CredibleSetPage.tsx @@ -13,14 +13,14 @@ function CredibleSetPage() { const { path } = useRouteMatch(); const { loading, data } = useQuery(CREDIBLE_SET_PAGE_QUERY, { - variables: { studyLocusIds: [studyLocusId] }, + variables: { studyLocusId: studyLocusId }, }); - if (data && !data?.credibleSets.length) { + if (data && !data?.credibleSet) { return ; } - const credibleSet = data?.credibleSets[0]; + const credibleSet = data?.credibleSet; const variantId = credibleSet?.variant?.id; const referenceAllele = credibleSet?.variant?.referenceAllele; const alternateAllele = credibleSet?.variant?.alternateAllele; diff --git a/apps/platform/src/pages/CredibleSetPage/Profile.tsx b/apps/platform/src/pages/CredibleSetPage/Profile.tsx index 26178d0a2..d53fbca6b 100644 --- a/apps/platform/src/pages/CredibleSetPage/Profile.tsx +++ b/apps/platform/src/pages/CredibleSetPage/Profile.tsx @@ -22,7 +22,7 @@ const GWASColocSection = lazy(() => import("sections/src/credibleSet/GWASColoc/B const Locus2GeneSection = lazy(() => import("sections/src/credibleSet/Locus2Gene/Body")); -const CREDIBLE_SET = "credibleSets"; +const CREDIBLE_SET = "credibleSet"; const createProfileQuery = (studyType: string) => { const summaries = [VariantsSummary, Locus2GeneSummary]; @@ -40,8 +40,8 @@ const createProfileQuery = (studyType: string) => { ); const CREDIBLE_SET_PROFILE_QUERY = gql` - query CredibleSetProfileQuery($studyLocusIds: [String!]!) { - credibleSets(studyLocusIds: $studyLocusIds) { + query CredibleSetProfileQuery($studyLocusId: String!, $variantIds: [String!]!) { + credibleSet(studyLocusId: $studyLocusId) { studyLocusId ...CredibleSetProfileHeaderFragment ...CredibleSetProfileSummaryFragment @@ -65,7 +65,7 @@ function Profile({ diff --git a/apps/platform/src/pages/CredibleSetPage/ProfileHeader.gql b/apps/platform/src/pages/CredibleSetPage/ProfileHeader.gql index b4461e25e..9d3f09c7f 100644 --- a/apps/platform/src/pages/CredibleSetPage/ProfileHeader.gql +++ b/apps/platform/src/pages/CredibleSetPage/ProfileHeader.gql @@ -4,14 +4,14 @@ fragment CredibleSetProfileHeaderFragment on credibleSet { beta standardError effectAlleleFrequencyFromSource - locus { - posteriorProbability - pValueMantissa - pValueExponent - beta - standardError - variant { - id + locus(variantIds: $variantIds) { + count + rows { + posteriorProbability + pValueMantissa + pValueExponent + beta + standardError } } variant { @@ -44,4 +44,4 @@ fragment CredibleSetProfileHeaderFragment on credibleSet { pubmedId nSamples } -} \ No newline at end of file +} diff --git a/apps/platform/src/pages/CredibleSetPage/ProfileHeader.tsx b/apps/platform/src/pages/CredibleSetPage/ProfileHeader.tsx index 8f2bceada..36c3c6777 100644 --- a/apps/platform/src/pages/CredibleSetPage/ProfileHeader.tsx +++ b/apps/platform/src/pages/CredibleSetPage/ProfileHeader.tsx @@ -18,17 +18,16 @@ type ProfileHeaderProps = { }; function ProfileHeader({ variantId }: ProfileHeaderProps) { - const { loading, error, data } = usePlatformApi(); // TODO: Errors! if (error) return null; - const credibleSet = data?.credibleSets?.[0]; + const credibleSet = data?.credibleSet; const study = credibleSet?.study; const studyCategory = study ? getStudyCategory(study.projectId) : null; const target = study?.target; - const leadVariant = credibleSet?.locus?.find(loc => loc?.variant.id === variantId); + const leadVariant = credibleSet?.locus.rows[0]; const beta = leadVariant?.beta ?? credibleSet?.beta; const standardError = leadVariant?.standardError ?? credibleSet?.standardError; const { pValueMantissa, pValueExponent } = @@ -39,23 +38,22 @@ function ProfileHeader({ variantId }: ProfileHeaderProps) { return ( - - Lead Variant - {typeof pValueMantissa === "number" && typeof pValueExponent === "number" && + + Lead Variant + + {typeof pValueMantissa === "number" && typeof pValueExponent === "number" && ( - } - {typeof beta === 'number' && + )} + {typeof beta === "number" && ( - Beta with respect to the ALT allele - + Beta with respect to the ALT allele } showHelpIcon > @@ -65,15 +63,16 @@ function ProfileHeader({ variantId }: ProfileHeaderProps) { > {beta.toPrecision(3)} - } - {typeof standardError === 'number' && + )} + {typeof standardError === "number" && ( - Standard error: Estimate of the standard deviation of the sampling distribution of the beta + Standard error: Estimate of the standard deviation of the sampling distribution + of the beta } showHelpIcon @@ -84,13 +83,13 @@ function ProfileHeader({ variantId }: ProfileHeaderProps) { > {standardError.toPrecision(3)} - } - {typeof credibleSet?.effectAlleleFrequencyFromSource === "number" && + )} + {typeof credibleSet?.effectAlleleFrequencyFromSource === "number" && ( {credibleSet.effectAlleleFrequencyFromSource.toPrecision(3)} - } - {typeof leadVariant?.posteriorProbability === "number" && + )} + {typeof leadVariant?.posteriorProbability === "number" && ( {leadVariant.posteriorProbability.toPrecision(3)} - } + )} {credibleSet?.variant && - `${credibleSet.variant.chromosome}:${credibleSet.variant.position}` - } + `${credibleSet.variant.chromosome}:${credibleSet.variant.position}`} - { - credibleSet?.variant?.rsIds.length > 0 && - - { - credibleSet.variant.rsIds.map((rsid, index) => ( - - {index > 0 && ", "} - - {rsid} - - - )) - } - - } + {credibleSet?.variant?.rsIds.length > 0 && ( + + {credibleSet.variant.rsIds.map((rsid, index) => ( + + {index > 0 && ", "} + + {rsid} + + + ))} + + )} - Credible Set + + Credible Set + {credibleSet?.finemappingMethod} @@ -152,19 +149,21 @@ function ProfileHeader({ variantId }: ProfileHeaderProps) { - Study + + Study + {study?.publicationFirstAuthor} {study?.publicationDate?.slice(0, 4)} - {studyCategory !== "QTL" && + {studyCategory !== "QTL" && ( <> {study?.traitFromSource} - {study?.diseases?.length > 0 && + {study?.diseases?.length > 0 && ( {study.diseases.map(({ id, name }, index) => ( @@ -173,44 +172,42 @@ function ProfileHeader({ variantId }: ProfileHeaderProps) { ))} - } + )} - } - {studyCategory === "QTL" && + )} + {studyCategory === "QTL" && ( <> - {target?.id && + {target?.id && ( - - {target.approvedSymbol} - + {target.approvedSymbol} - } - { study?.biosample?.biosampleId && + )} + {study?.biosample?.biosampleId && ( - + {study.biosample.biosampleId} - } + )} - } + )} {study?.publicationJournal} - {study?.pubmedId && + {study?.pubmedId && ( - + {study.pubmedId} - } + )} {study?.nSamples} - ); } @@ -219,4 +216,4 @@ ProfileHeader.fragments = { profileHeader: CREDIBLE_SET_PROFILE_HEADER_FRAGMENT, }; -export default ProfileHeader; \ No newline at end of file +export default ProfileHeader; diff --git a/packages/sections/src/credibleSet/GWASColoc/Body.tsx b/packages/sections/src/credibleSet/GWASColoc/Body.tsx index 401811daf..687e2c970 100644 --- a/packages/sections/src/credibleSet/GWASColoc/Body.tsx +++ b/packages/sections/src/credibleSet/GWASColoc/Body.tsx @@ -157,7 +157,7 @@ type BodyProps = { function Body({ studyLocusId, entity }: BodyProps) { const variables = { - studyLocusIds: [studyLocusId], + studyLocusId: studyLocusId, }; const request = useQuery(GWAS_COLOC_QUERY, { @@ -180,7 +180,7 @@ function Body({ studyLocusId, entity }: BodyProps) { order="asc" columns={columns} loading={request.loading} - rows={request.data?.credibleSets[0].colocalisation} + rows={request.data?.credibleSet.colocalisation} query={GWAS_COLOC_QUERY.loc.source.body} variables={variables} /> diff --git a/packages/sections/src/credibleSet/GWASColoc/GWASColocQuery.gql b/packages/sections/src/credibleSet/GWASColoc/GWASColocQuery.gql index 40cb68f29..a87c86d57 100644 --- a/packages/sections/src/credibleSet/GWASColoc/GWASColocQuery.gql +++ b/packages/sections/src/credibleSet/GWASColoc/GWASColocQuery.gql @@ -1,5 +1,5 @@ -query GWASColocQuery($studyLocusIds: [String!]!) { - credibleSets(studyLocusIds: $studyLocusIds) { +query GWASColocQuery($studyLocusId: String!) { + credibleSet(studyLocusId: $studyLocusId) { colocalisation(studyTypes: [gwas], page: { size: 250, index: 0 }) { otherStudyLocus { studyLocusId @@ -26,4 +26,4 @@ query GWASColocQuery($studyLocusIds: [String!]!) { clpp } } -} \ No newline at end of file +} diff --git a/packages/sections/src/credibleSet/GWASColoc/index.ts b/packages/sections/src/credibleSet/GWASColoc/index.ts index 880614185..236a8c457 100644 --- a/packages/sections/src/credibleSet/GWASColoc/index.ts +++ b/packages/sections/src/credibleSet/GWASColoc/index.ts @@ -3,5 +3,5 @@ export const definition = { id, name: "GWAS Colocalisation", shortName: "GC", - hasData: data => data?.[0]?.colocalisation?.length > 0, -}; \ No newline at end of file + hasData: data => data?.colocalisation?.length > 0, +}; diff --git a/packages/sections/src/credibleSet/GWASMolQTL/Body.tsx b/packages/sections/src/credibleSet/GWASMolQTL/Body.tsx index 0de17ba85..869ab13af 100644 --- a/packages/sections/src/credibleSet/GWASMolQTL/Body.tsx +++ b/packages/sections/src/credibleSet/GWASMolQTL/Body.tsx @@ -184,7 +184,7 @@ type BodyProps = { function Body({ studyLocusId, entity }: BodyProps) { const variables = { - studyLocusIds: [studyLocusId], + studyLocusId: studyLocusId, }; const request = useQuery(GWAS_COLOC_QUERY, { @@ -207,7 +207,7 @@ function Body({ studyLocusId, entity }: BodyProps) { order="asc" columns={columns} loading={request.loading} - rows={request.data?.credibleSets[0].colocalisation} + rows={request.data?.credibleSet.colocalisation} query={GWAS_COLOC_QUERY.loc.source.body} variables={variables} /> diff --git a/packages/sections/src/credibleSet/GWASMolQTL/GWASMolQTLColocQuery.gql b/packages/sections/src/credibleSet/GWASMolQTL/GWASMolQTLColocQuery.gql index 5451c53f6..28616053c 100644 --- a/packages/sections/src/credibleSet/GWASMolQTL/GWASMolQTLColocQuery.gql +++ b/packages/sections/src/credibleSet/GWASMolQTL/GWASMolQTLColocQuery.gql @@ -1,5 +1,5 @@ -query GWASMolQTLColocQuery($studyLocusIds: [String!]!) { - credibleSets(studyLocusIds: $studyLocusIds) { +query GWASMolQTLColocQuery($studyLocusId: String!) { + credibleSet(studyLocusId: $studyLocusId) { colocalisation(studyTypes: [tuqtl, pqtl, eqtl, sqtl], page: { size: 250, index: 0 }) { otherStudyLocus { studyLocusId diff --git a/packages/sections/src/credibleSet/GWASMolQTL/index.ts b/packages/sections/src/credibleSet/GWASMolQTL/index.ts index cec2a6008..7fc492371 100644 --- a/packages/sections/src/credibleSet/GWASMolQTL/index.ts +++ b/packages/sections/src/credibleSet/GWASMolQTL/index.ts @@ -3,6 +3,6 @@ export const definition = { name: "GWAS/MolQTL Colocalisation", shortName: "GC", hasData: data => { - return data?.[0]?.colocalisation?.length > 0; + return data?.colocalisation?.length > 0; }, }; diff --git a/packages/sections/src/credibleSet/Locus2Gene/Body.tsx b/packages/sections/src/credibleSet/Locus2Gene/Body.tsx index cedfdb0d4..6f97b54c3 100644 --- a/packages/sections/src/credibleSet/Locus2Gene/Body.tsx +++ b/packages/sections/src/credibleSet/Locus2Gene/Body.tsx @@ -41,7 +41,7 @@ const columns = [ function Body({ studyLocusId, entity }: BodyProps): ReactNode { const variables = { - studyLocusIds: [studyLocusId], + studyLocusId: studyLocusId, }; const request = useQuery(LOCUS2GENE_QUERY, { @@ -62,7 +62,7 @@ function Body({ studyLocusId, entity }: BodyProps): ReactNode { dataDownloaderFileStem={`${studyLocusId}-locus2gene`} columns={columns} loading={request.loading} - rows={request.data?.credibleSets[0].l2Gpredictions} + rows={request.data?.credibleSet.l2Gpredictions} query={LOCUS2GENE_QUERY.loc.source.body} variables={variables} /> diff --git a/packages/sections/src/credibleSet/Locus2Gene/Locus2GeneQuery.gql b/packages/sections/src/credibleSet/Locus2Gene/Locus2GeneQuery.gql index ea6223c3d..90e061373 100644 --- a/packages/sections/src/credibleSet/Locus2Gene/Locus2GeneQuery.gql +++ b/packages/sections/src/credibleSet/Locus2Gene/Locus2GeneQuery.gql @@ -1,5 +1,5 @@ -query Locus2GeneQuery($studyLocusIds: [String!]!) { - credibleSets(studyLocusIds: $studyLocusIds) { +query Locus2GeneQuery($studyLocusId: String!) { + credibleSet(studyLocusId: $studyLocusId) { l2Gpredictions { target { id diff --git a/packages/sections/src/credibleSet/Locus2Gene/index.ts b/packages/sections/src/credibleSet/Locus2Gene/index.ts index 4862808a5..4a5334a1e 100644 --- a/packages/sections/src/credibleSet/Locus2Gene/index.ts +++ b/packages/sections/src/credibleSet/Locus2Gene/index.ts @@ -3,5 +3,5 @@ export const definition = { id, name: "Locus to Gene", shortName: "LG", - hasData: data => data[0]?.l2Gpredictions.length > 0, + hasData: data => data?.l2Gpredictions.length > 0, }; diff --git a/packages/sections/src/credibleSet/Variants/Body.tsx b/packages/sections/src/credibleSet/Variants/Body.tsx index 1b5e4aa59..727c16024 100644 --- a/packages/sections/src/credibleSet/Variants/Body.tsx +++ b/packages/sections/src/credibleSet/Variants/Body.tsx @@ -151,7 +151,8 @@ function Body({ entity, }: BodyProps) { const variables = { - studyLocusIds: [studyLocusId], + studyLocusId: studyLocusId, + variantIds: [leadVariantId], }; const request = useQuery(VARIANTS_QUERY, { @@ -180,7 +181,7 @@ function Body({ order="desc" columns={columns} loading={request.loading} - rows={request.data?.credibleSets[0].locus} + rows={request.data?.credibleSet.locus.rows} query={VARIANTS_QUERY.loc.source.body} variables={variables} /> diff --git a/packages/sections/src/credibleSet/Variants/VariantsQuery.gql b/packages/sections/src/credibleSet/Variants/VariantsQuery.gql index 432e9c206..640919df5 100644 --- a/packages/sections/src/credibleSet/Variants/VariantsQuery.gql +++ b/packages/sections/src/credibleSet/Variants/VariantsQuery.gql @@ -1,21 +1,24 @@ -query VariantsQuery($studyLocusIds: [String!]!) { - credibleSets(studyLocusIds: $studyLocusIds) { +query VariantsQuery($studyLocusId: String!, $variantIds: [String!]!) { + credibleSet(studyLocusId: $studyLocusId) { studyLocusId - locus { - logBF - posteriorProbability - variant { - id - chromosome - position - referenceAllele - alternateAllele + locus(variantIds: $variantIds) { + count + rows { + logBF + posteriorProbability + variant { + id + chromosome + position + referenceAllele + alternateAllele + } + pValueMantissa + pValueExponent + beta + standardError + r2Overall } - pValueMantissa - pValueExponent - beta - standardError - r2Overall } } } diff --git a/packages/sections/src/credibleSet/Variants/VariantsSummaryFragment.gql b/packages/sections/src/credibleSet/Variants/VariantsSummaryFragment.gql index 55d6fbeb4..45060f92b 100644 --- a/packages/sections/src/credibleSet/Variants/VariantsSummaryFragment.gql +++ b/packages/sections/src/credibleSet/Variants/VariantsSummaryFragment.gql @@ -1,5 +1,5 @@ fragment VariantsSummaryFragment on credibleSet { - locus { - beta + locus(variantIds: $variantIds) { + count } -} \ No newline at end of file +} diff --git a/packages/sections/src/credibleSet/Variants/index.ts b/packages/sections/src/credibleSet/Variants/index.ts index cf5933ced..e3f391f03 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: "Variants in Credible Set", shortName: "VA", - hasData: data => data?.[0]?.locus?.length > 0, -}; \ No newline at end of file + hasData: data => data?.locus.count > 0, +};