Skip to content

Commit

Permalink
Merge branch 'main' of github.com:opentargets/ot-ui-apps into cc-upgr…
Browse files Browse the repository at this point in the history
…ade-react-router
  • Loading branch information
carcruz committed Dec 11, 2024
2 parents 23c717f + 952627b commit cda2cbe
Show file tree
Hide file tree
Showing 18 changed files with 306 additions and 226 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
4 changes: 2 additions & 2 deletions apps/platform/src/pages/HomePage/searchExamples.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,12 +43,12 @@ export const pppSearchExamples: Examples = {
{ type: "suggestion", entity: "drug", name: "LYRICA", id: "CHEMBL1059" },
],
variants: [
{ type: "suggestion", entity: "variant", name: "rs7412", id: "19_44908822_C_T" },
{ type: "suggestion", entity: "variant", name: "rs4129267", id: "1_154453788_C_T" },
{ type: "suggestion", entity: "variant", name: "4_1804392_G_A", id: "4_1804392_G_A" },
{ type: "suggestion", entity: "variant", name: "11_64600382_G_A", id: "11_64600382_G_A" },
{ type: "suggestion", entity: "variant", name: "12_6333477_C_T", id: "12_6333477_C_T" },
{ type: "suggestion", entity: "variant", name: "15_90088702_C_T", id: "15_90088702_C_T" },
{ type: "suggestion", entity: "variant", name: "17_63945614_C_T", id: "17_63945614_C_T" },
{ type: "suggestion", entity: "variant", name: "17_43093010_G_A", id: "17_43093010_G_A" },
],
};

Expand Down
23 changes: 20 additions & 3 deletions apps/platform/src/pages/VariantPage/ProfileHeader.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,26 @@ function ProfileHeader() {

{data?.variant.alleleFrequencies.length > 0 && (
<Paper sx={{ py: 2, px: 5, maxWidth: "100%" }} elevation={0} variant="outlined">
<Typography variant="subtitle2" mb={1}>
Population Allele Frequencies
</Typography>
<Box
display="flex"
justifyContent="space-between"
flexWrap="wrap"
columnGap={2}
mb={1.5}
alignItems="center"
>
<Typography variant="subtitle2">
Population Allele Frequencies
</Typography>
<Typography variant="body2">
<em>
Source:{" "}
<Link to="https://gnomad.broadinstitute.org/" external>
gnomAD
</Link>
</em>
</Typography>
</Box>
<Box sx={{ margin: "0 auto", maxWidth: "550px" }}>
<AlleleFrequencyPlot data={data.variant.alleleFrequencies} />
</Box>
Expand Down
25 changes: 11 additions & 14 deletions packages/sections/src/credibleSet/GWASColoc/Body.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import Description from "./Description";
import GWAS_COLOC_QUERY from "./GWASColocQuery.gql";
import { mantissaExponentComparator, variantComparator } from "../../utils/comparators";
import { getStudyCategory } from "../../utils/getStudyCategory";
import { useEffect, useState } from "react";
import { ReactElement, useEffect, useState } from "react";

const columns = [
{
Expand Down Expand Up @@ -131,12 +131,11 @@ const columns = [
let category = "Inconclusive";
if (betaRatioSignAverage <= -0.99) category = "Opposite";
else if (betaRatioSignAverage >= 0.99) category = "Same";
const displayValue = Math.abs(betaRatioSignAverage) === 1
? betaRatioSignAverage
: betaRatioSignAverage.toFixed(2)
return <Tooltip title={`Beta ratio sign average: ${displayValue}`}>
{category}
</Tooltip>
const displayValue =
Math.abs(betaRatioSignAverage) === 1
? betaRatioSignAverage
: betaRatioSignAverage.toFixed(2);
return <Tooltip title={`Beta ratio sign average: ${displayValue}`}>{category}</Tooltip>;
},
filterValue: ({ betaRatioSignAverage }) => {
if (betaRatioSignAverage == null) return null;
Expand Down Expand Up @@ -201,20 +200,18 @@ type BodyProps = {
entity: string;
};

function Body({ studyLocusId, entity }: BodyProps) {
function Body({ studyLocusId, entity }: BodyProps): ReactElement {
const variables = {
studyLocusId: studyLocusId,
size: table5HChunkSize,
index: 0,
};

const [request, setRequest] = useState<responseType>(initialResponse);

const getData = useBatchQuery({
query: GWAS_COLOC_QUERY,
variables: {
studyLocusId,
size: table5HChunkSize,
index: 0,
},
variables,
dataPath: "data.credibleSet.colocalisation",
size: table5HChunkSize,
});
Expand All @@ -223,7 +220,7 @@ function Body({ studyLocusId, entity }: BodyProps) {
getData().then(r => {
setRequest(r);
});
}, []);
}, [studyLocusId]);

return (
<SectionItem
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { Link } from "ui";
function Description(): ReactElement {
return (
<>
Gene assignment based on machine-learning prioritisation of credible set features. Source:{" "}
Gene assignment based on machine-learning prioritisation of credible set features [Feature metrics coming soon]. Source:{" "}
<Link to="https://home.opentargets.org/merged-product-documentation" external>
Open Targets
</Link>
Expand Down
2 changes: 1 addition & 1 deletion packages/sections/src/credibleSet/MolQTLColoc/Body.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,7 @@ function Body({ studyLocusId, entity }: BodyProps) {
getData().then(r => {
setRequest(r);
});
}, []);
}, [studyLocusId]);

return (
<SectionItem
Expand Down
20 changes: 10 additions & 10 deletions packages/sections/src/credibleSet/Variants/Body.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,8 @@ function getColumns({ leadVariantId, leadReferenceAllele, leadAlternateAllele }:
label: "Posterior Probability",
filterValue: false,
numeric: true,
tooltip: "Posterior inclusion probability that this variant is causal within the fine-mapped credible set",
tooltip:
"Posterior inclusion probability that this variant is causal within the fine-mapped credible set",
comparator: (rowA, rowB) => rowA?.posteriorProbability - rowB?.posteriorProbability,
sortable: true,
renderCell: ({ posteriorProbability }) => {
Expand All @@ -145,7 +146,8 @@ function getColumns({ leadVariantId, leadReferenceAllele, leadAlternateAllele }:
id: "logBF",
label: "log(BF)",
numeric: true,
tooltip: "Natural logarithm of the Bayes Factor indicating relative likelihood of the variant being causal",
tooltip:
"Natural logarithm of the Bayes Factor indicating relative likelihood of the variant being causal",
filterValue: false,
sortable: true,
renderCell: ({ logBF }) => {
Expand All @@ -159,7 +161,7 @@ function getColumns({ leadVariantId, leadReferenceAllele, leadAlternateAllele }:
tooltip: "Most severe consequence of the variant. Source: Ensembl VEP",

renderCell: ({ variant }) => {
const mostSevereConsequence = variant?.mostSevereConsequence
const mostSevereConsequence = variant?.mostSevereConsequence;
if (!mostSevereConsequence) return naLabel;
const displayElement = (
<Link external to={identifiersOrgLink("SO", mostSevereConsequence.id.slice(3))}>
Expand All @@ -169,7 +171,7 @@ function getColumns({ leadVariantId, leadReferenceAllele, leadAlternateAllele }:
return displayElement;
},
exportValue: ({ variant }) => {
return variant?.mostSevereConsequence.label
return variant?.mostSevereConsequence.label;
},
},
];
Expand All @@ -192,17 +194,15 @@ function Body({
}: BodyProps) {
const variables = {
studyLocusId: studyLocusId,
size: table5HChunkSize,
index: 0,
};

const [request, setRequest] = useState<responseType>(initialResponse);

const getData = useBatchQuery({
query: VARIANTS_QUERY,
variables: {
studyLocusId,
size: table5HChunkSize,
index: 0,
},
variables,
dataPath: "data.credibleSet.locus",
size: table5HChunkSize,
});
Expand All @@ -211,7 +211,7 @@ function Body({
getData().then(r => {
setRequest(r);
});
}, []);
}, [studyLocusId]);

const columns = getColumns({
leadVariantId,
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,
};
14 changes: 6 additions & 8 deletions packages/sections/src/disease/GWASStudies/Body.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import { getStudyCategory } from "../../utils/getStudyCategory";
import GWAS_STUDIES_BODY_QUERY from "./GWASStudiesQuery.gql";
import { definition } from ".";
import { epmcUrl } from "ui/src/utils/urls";
import { useEffect, useState } from "react";
import { ReactElement, useEffect, useState } from "react";
import { responseType } from "ui/src/types/response";

const columns = [
Expand Down Expand Up @@ -116,20 +116,18 @@ type BodyProps = {
label: string;
};

function Body({ id: efoId, label: diseaseName }: BodyProps) {
function Body({ id: efoId, label: diseaseName }: BodyProps): ReactElement {
const variables = {
diseaseIds: [efoId],
size: table5HChunkSize,
index: 0,
};

const [request, setRequest] = useState<responseType>(initialResponse);

const getData = useBatchQuery({
query: GWAS_STUDIES_BODY_QUERY,
variables: {
diseaseIds: variables.diseaseIds,
size: table5HChunkSize,
index: 0,
},
variables,
dataPath: "data.studies",
size: table5HChunkSize,
});
Expand All @@ -138,7 +136,7 @@ function Body({ id: efoId, label: diseaseName }: BodyProps) {
getData().then(r => {
setRequest(r);
});
}, []);
}, [efoId]);

return (
<SectionItem
Expand Down
Loading

0 comments on commit cda2cbe

Please sign in to comment.