Skip to content

Commit

Permalink
[Platform]: Credible-set page queries fix (#549)
Browse files Browse the repository at this point in the history
* variant page query update

* credible sets query fix
  • Loading branch information
chinmehta authored Nov 22, 2024
1 parent 427ccae commit bb469ad
Show file tree
Hide file tree
Showing 18 changed files with 124 additions and 123 deletions.
4 changes: 2 additions & 2 deletions apps/platform/src/pages/CredibleSetPage/CredibleSetPage.gql
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
query CredibleSetPageQuery($studyLocusIds: [String!]!) {
credibleSets(studyLocusIds: $studyLocusIds) {
query CredibleSetPageQuery($studyLocusId: String!) {
credibleSet(studyLocusId: $studyLocusId) {
variant {
id
referenceAllele
Expand Down
6 changes: 3 additions & 3 deletions apps/platform/src/pages/CredibleSetPage/CredibleSetPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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 <NotFoundPage />;
}

const credibleSet = data?.credibleSets[0];
const credibleSet = data?.credibleSet;
const variantId = credibleSet?.variant?.id;
const referenceAllele = credibleSet?.variant?.referenceAllele;
const alternateAllele = credibleSet?.variant?.alternateAllele;
Expand Down
8 changes: 4 additions & 4 deletions apps/platform/src/pages/CredibleSetPage/Profile.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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];
Expand All @@ -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
Expand All @@ -65,7 +65,7 @@ function Profile({
<PlatformApiProvider
entity={CREDIBLE_SET}
query={CREDIBLE_SET_PROFILE_QUERY}
variables={{ studyLocusIds: [studyLocusId] }}
variables={{ studyLocusId: studyLocusId, variantIds: [variantId] }}
client={client}
>
<ProfileHeader variantId={variantId} />
Expand Down
18 changes: 9 additions & 9 deletions apps/platform/src/pages/CredibleSetPage/ProfileHeader.gql
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -44,4 +44,4 @@ fragment CredibleSetProfileHeaderFragment on credibleSet {
pubmedId
nSamples
}
}
}
127 changes: 62 additions & 65 deletions apps/platform/src/pages/CredibleSetPage/ProfileHeader.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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 } =
Expand All @@ -39,23 +38,22 @@ function ProfileHeader({ variantId }: ProfileHeaderProps) {

return (
<BaseProfileHeader>

<Box>
<Typography variant="subtitle1" mt={0}>Lead Variant</Typography>
{typeof pValueMantissa === "number" && typeof pValueExponent === "number" &&
<Typography variant="subtitle1" mt={0}>
Lead Variant
</Typography>
{typeof pValueMantissa === "number" && typeof pValueExponent === "number" && (
<Field loading={loading} title="P-value">
<ScientificNotation number={[pValueMantissa, pValueExponent]} />
</Field>
}
{typeof beta === 'number' &&
)}
{typeof beta === "number" && (
<Field
loading={loading}
title={
<Tooltip
title={
<Typography variant="caption">
Beta with respect to the ALT allele
</Typography>
<Typography variant="caption">Beta with respect to the ALT allele</Typography>
}
showHelpIcon
>
Expand All @@ -65,15 +63,16 @@ function ProfileHeader({ variantId }: ProfileHeaderProps) {
>
{beta.toPrecision(3)}
</Field>
}
{typeof standardError === 'number' &&
)}
{typeof standardError === "number" && (
<Field
loading={loading}
title={
<Tooltip
title={
<Typography variant="caption">
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
</Typography>
}
showHelpIcon
Expand All @@ -84,13 +83,13 @@ function ProfileHeader({ variantId }: ProfileHeaderProps) {
>
{standardError.toPrecision(3)}
</Field>
}
{typeof credibleSet?.effectAlleleFrequencyFromSource === "number" &&
)}
{typeof credibleSet?.effectAlleleFrequencyFromSource === "number" && (
<Field loading={loading} title="EAF">
{credibleSet.effectAlleleFrequencyFromSource.toPrecision(3)}
</Field>
}
{typeof leadVariant?.posteriorProbability === "number" &&
)}
{typeof leadVariant?.posteriorProbability === "number" && (
<Field
loading={loading}
title={
Expand All @@ -108,33 +107,31 @@ function ProfileHeader({ variantId }: ProfileHeaderProps) {
>
{leadVariant.posteriorProbability.toPrecision(3)}
</Field>
}
)}
<Field loading={loading} title="GRCh38">
{credibleSet?.variant &&
`${credibleSet.variant.chromosome}:${credibleSet.variant.position}`
}
`${credibleSet.variant.chromosome}:${credibleSet.variant.position}`}
</Field>
{
credibleSet?.variant?.rsIds.length > 0 &&
<Field loading={loading} title="Ensembl">
{
credibleSet.variant.rsIds.map((rsid, index) => (
<Fragment key={rsid}>
{index > 0 && ", "}
<Link
external
to={`https://www.ensembl.org/Homo_sapiens/Variation/Explore?v=${rsid}`}
>
{rsid}
</Link>
</Fragment>
))
}
</Field>
}
{credibleSet?.variant?.rsIds.length > 0 && (
<Field loading={loading} title="Ensembl">
{credibleSet.variant.rsIds.map((rsid, index) => (
<Fragment key={rsid}>
{index > 0 && ", "}
<Link
external
to={`https://www.ensembl.org/Homo_sapiens/Variation/Explore?v=${rsid}`}
>
{rsid}
</Link>
</Fragment>
))}
</Field>
)}

<Typography variant="subtitle1" mt={1}>Credible Set</Typography>
<Field loading={loading} title="Fine-mapping method">
<Typography variant="subtitle1" mt={1}>
Credible Set
</Typography>
<Field loading={loading} title="Finemapping method">
{credibleSet?.finemappingMethod}
</Field>
<Field loading={loading} title="Credible set index within locus">
Expand All @@ -152,65 +149,65 @@ function ProfileHeader({ variantId }: ProfileHeaderProps) {
</Box>

<Box>
<Typography variant="subtitle1" mt={0}>Study</Typography>
<Field loading={loading} title="First author">
<Typography variant="subtitle1" mt={0}>
Study
</Typography>
<Field loading={loading} title="Author">
{study?.publicationFirstAuthor}
</Field>
<Field loading={loading} title="Publication year">
{study?.publicationDate?.slice(0, 4)}
</Field>
{studyCategory !== "QTL" &&
{studyCategory !== "QTL" && (
<>
<Field loading={loading} title="Reported trait">
{study?.traitFromSource}
</Field>
{study?.diseases?.length > 0 &&
<Field loading={loading} title="Disease/phenotype">
{study?.diseases?.length > 0 && (
<Field loading={loading} title="Diseases">
{study.diseases.map(({ id, name }, index) => (
<Fragment key={id}>
{index > 0 ? ", " : null}
<Link to={`../disease/${id}`}>{name}</Link>
</Fragment>
))}
</Field>
}
)}
</>
}
{studyCategory === "QTL" &&
)}
{studyCategory === "QTL" && (
<>
{target?.id &&
{target?.id && (
<Field loading={loading} title="Affected gene">
<Link to={`../target/${target.id}`}>
{target.approvedSymbol}
</Link>
<Link to={`../target/${target.id}`}>{target.approvedSymbol}</Link>
</Field>
}
{ study?.biosample?.biosampleId &&
)}
{study?.biosample?.biosampleId && (
<Field loading={loading} title="Affected cell/tissue">
<Link external to={`https://www.ebi.ac.uk/ols4/search?q=${study.biosample.biosampleId}&ontology=uberon`}>
<Link
external
to={`https://www.ebi.ac.uk/ols4/search?q=${study.biosample.biosampleId}&ontology=uberon`}
>
{study.biosample.biosampleId}
</Link>
</Field>
}
)}
</>
}
)}
<Field loading={loading} title="Journal">
{study?.publicationJournal}
</Field>
{study?.pubmedId &&
{study?.pubmedId && (
<Field loading={loading} title="PubMed">
<PublicationsDrawer
entries={[{ name: study.pubmedId, url: epmcUrl(study.pubmedId)}]}
>
<PublicationsDrawer entries={[{ name: study.pubmedId, url: epmcUrl(study.pubmedId) }]}>
{study.pubmedId}
</PublicationsDrawer>
</Field>
}
)}
<Field loading={loading} title="Sample size">
{study?.nSamples}
</Field>
</Box>

</BaseProfileHeader>
);
}
Expand All @@ -219,4 +216,4 @@ ProfileHeader.fragments = {
profileHeader: CREDIBLE_SET_PROFILE_HEADER_FRAGMENT,
};

export default ProfileHeader;
export default ProfileHeader;
4 changes: 2 additions & 2 deletions packages/sections/src/credibleSet/GWASColoc/Body.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ type BodyProps = {

function Body({ studyLocusId, entity }: BodyProps) {
const variables = {
studyLocusIds: [studyLocusId],
studyLocusId: studyLocusId,
};

const request = useQuery(GWAS_COLOC_QUERY, {
Expand All @@ -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}
/>
Expand Down
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -26,4 +26,4 @@ query GWASColocQuery($studyLocusIds: [String!]!) {
clpp
}
}
}
}
4 changes: 2 additions & 2 deletions packages/sections/src/credibleSet/GWASColoc/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@ export const definition = {
id,
name: "GWAS Colocalisation",
shortName: "GC",
hasData: data => data?.[0]?.colocalisation?.length > 0,
};
hasData: data => data?.colocalisation?.length > 0,
};
4 changes: 2 additions & 2 deletions packages/sections/src/credibleSet/GWASMolQTL/Body.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ type BodyProps = {

function Body({ studyLocusId, entity }: BodyProps) {
const variables = {
studyLocusIds: [studyLocusId],
studyLocusId: studyLocusId,
};

const request = useQuery(GWAS_COLOC_QUERY, {
Expand All @@ -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}
/>
Expand Down
Original file line number Diff line number Diff line change
@@ -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
Expand Down
Loading

0 comments on commit bb469ad

Please sign in to comment.