diff --git a/apps/platform/src/pages/CredibleSetPage/ProfileHeader.tsx b/apps/platform/src/pages/CredibleSetPage/ProfileHeader.tsx index 528cd290..98fdd6d3 100644 --- a/apps/platform/src/pages/CredibleSetPage/ProfileHeader.tsx +++ b/apps/platform/src/pages/CredibleSetPage/ProfileHeader.tsx @@ -14,10 +14,7 @@ import { Box, Typography, Popover } from "@mui/material"; import CREDIBLE_SET_PROFILE_HEADER_FRAGMENT from "./ProfileHeader.gql"; import { getStudyCategory } from "sections/src/utils/getStudyCategory"; import { epmcUrl } from "../../utils/urls"; -import { - credsetConfidenceMap, - poulationMap, -} from "../../constants"; +import { credsetConfidenceMap, poulationMap } from "../../constants"; import { FontAwesomeIcon } from "@fortawesome/react-fontawesome"; import { faCaretDown, faTriangleExclamation } from "@fortawesome/free-solid-svg-icons"; import { v1 } from "uuid"; @@ -27,17 +24,30 @@ type ProfileHeaderProps = { }; const dicSummary = [ - {id:"n_variants", label:"Total variants", tooltip:"Number of harmonised variants"}, + { id: "n_variants", label: "Total variants", tooltip: "Number of harmonised variants" }, { id: "n_variants_sig", label: "Significant variants", tooltip: "P-value significant variants" }, - {id:"mean_beta", label:"Mean beta", tooltip:"Mean effect size across all variants"}, - {id:"gc_lambda", label:"GC lambda", tooltip:"Additive Genomic Control (GC) lambda indicating GWAS inflation"}, - {id:"mean_diff_pz", label:"Mean diff P-Z", tooltip:"Mean difference between reported and calculated log p-values"}, - {id:"se_diff_pz", label:"SD diff P-Z", tooltip:"Standard deviation of the difference between reported and calculated log p-values"}, -] + { id: "mean_beta", label: "Mean beta", tooltip: "Mean effect size across all variants" }, + { + id: "gc_lambda", + label: "GC lambda", + tooltip: "Additive Genomic Control (GC) lambda indicating GWAS inflation", + }, + { + id: "mean_diff_pz", + label: "Mean diff P-Z", + tooltip: "Mean difference between reported and calculated log p-values", + }, + { + id: "se_diff_pz", + label: "SD diff P-Z", + tooltip: "Standard deviation of the difference between reported and calculated log p-values", + }, +]; function SummaryStatisticsField({ sumstatQCValues }: any) { const [anchorEl, setAnchorEl] = useState(null); - + if (!sumstatQCValues) return null; + const handleClick = (event: React.MouseEvent) => { setAnchorEl(event.currentTarget); }; @@ -47,11 +57,16 @@ function SummaryStatisticsField({ sumstatQCValues }: any) { }; const open = Boolean(anchorEl); - const id = open ? 'simple-popover' : undefined; + const id = open ? "simple-popover" : undefined; return ( - + Available @@ -63,25 +78,36 @@ function SummaryStatisticsField({ sumstatQCValues }: any) { elevation={1} disableScrollLock anchorOrigin={{ - vertical: 'bottom', - horizontal: 'left', + vertical: "bottom", + horizontal: "left", }} > - - Harmonised summary statistics + + + Harmonised summary statistics + - {dicSummary.map((sumstat: any) => { - const summStatValue = sumstatQCValues.find((v: any) => v.QCCheckName === sumstat.id).QCCheckValue - return ( - - - {sumstat.label} - - {summStatValue} - -)})} -
-
+ + {dicSummary.map((sumstat: any) => { + const summStatValue = sumstatQCValues.find( + (v: any) => v.QCCheckName === sumstat.id + ).QCCheckValue; + return ( + + + + {sumstat.label} + + + + {summStatValue} + + + ); + })} + + +
); @@ -155,16 +181,21 @@ function ProfileHeader({ variantId }: ProfileHeaderProps) { )} {typeof credibleSet?.effectAlleleFrequencyFromSource === "number" && ( - - Frequency of the effect allele in studied population - + + Frequency of the effect allele in studied population + + } + showHelpIcon + > + Effective allele frequency + } - showHelpIcon > - Effective allele frequency - }> {credibleSet.effectAlleleFrequencyFromSource.toPrecision(3)} )} @@ -191,21 +222,23 @@ function ProfileHeader({ variantId }: ProfileHeaderProps) { Fine-mapping - { - credibleSet?.locusStart && ( - {credibleSet?.variant?.chromosome}:{credibleSet?.locusStart}-{credibleSet?.locusEnd} - ) - } + {credibleSet?.locusStart && ( + + {credibleSet?.variant?.chromosome}:{credibleSet?.locusStart}-{credibleSet?.locusEnd} + + )} {credibleSet?.finemappingMethod} - - Confidence - + + Confidence + } > @@ -217,15 +250,18 @@ function ProfileHeader({ variantId }: ProfileHeaderProps) { Minimum pairwise correlation (R2) observed between all variants in the credible set - } - showHelpIcon - > - Minimum R2 - - } + + Minimum pairwise correlation (R2) observed between all variants in the + credible set + + } + showHelpIcon + > + Minimum R2 + + } > {credibleSet?.purityMinR2?.toPrecision(3)} @@ -233,7 +269,7 @@ function ProfileHeader({ variantId }: ProfileHeaderProps) { - {study?.studyType.replace(/(qtl|gwas)/gi, (match) => match.toUpperCase())} Study + {study?.studyType.replace(/(qtl|gwas)/gi, match => match.toUpperCase())} Study {studyCategory !== "QTL" && ( <> @@ -281,9 +317,12 @@ function ProfileHeader({ variantId }: ProfileHeaderProps) { )} )} - {study?.publicationFirstAuthor && ( - {study?.publicationFirstAuthor} et al. {study?.publicationJournal} ({study?.publicationDate?.slice(0, 4)}) - )} + {study?.publicationFirstAuthor && ( + + {study?.publicationFirstAuthor} et al. {study?.publicationJournal} ( + {study?.publicationDate?.slice(0, 4)}) + + )} {study?.pubmedId && ( @@ -291,36 +330,42 @@ function ProfileHeader({ variantId }: ProfileHeaderProps) { )} - {study?.analysisFlags && ( - Analysis - - }> - {study?.analysisFlags ? study.analysisFlags : "Not Available"} - + {study?.analysisFlags && ( + + Analysis + + } + > + {study?.analysisFlags ? study.analysisFlags : "Not Available"} + )} {study?.hasSumstats && ( - - + + )} {study?.nSamples.toLocaleString()} {/* LD Ancestries */} - {study?.ldPopulationStructure?.length > 0 && ( - study.ldPopulationStructure.map(({ ldPopulation, relativeSampleSize}, index) => ( + {study?.ldPopulationStructure?.length > 0 && + study.ldPopulationStructure.map(({ ldPopulation, relativeSampleSize }, index) => ( - )) - )} + ))} {/* Quality controls */} - {study?.qualityControls.length > 0 && ( + {study?.qualityControls?.length > 0 && ( } @@ -332,7 +377,7 @@ function ProfileHeader({ variantId }: ProfileHeaderProps) { )} - + ); } diff --git a/packages/sections/src/study/GWASCredibleSets/index.ts b/packages/sections/src/study/GWASCredibleSets/index.ts index 6524684d..20ae8ef7 100644 --- a/packages/sections/src/study/GWASCredibleSets/index.ts +++ b/packages/sections/src/study/GWASCredibleSets/index.ts @@ -3,8 +3,5 @@ export const definition = { id, name: "GWAS Credible Sets", shortName: "GW", - hasData: data => { - console.log(data, "foo"); - return data?.gwasCredibleSets?.count > 0 || data?.credibleSets?.count > 0; - }, + hasData: data => data?.gwasCredibleSets?.count > 0 || data?.credibleSets?.count > 0, }; diff --git a/packages/sections/src/study/SharedTraitStudies/Body.tsx b/packages/sections/src/study/SharedTraitStudies/Body.tsx index d68d512a..14796e68 100644 --- a/packages/sections/src/study/SharedTraitStudies/Body.tsx +++ b/packages/sections/src/study/SharedTraitStudies/Body.tsx @@ -137,18 +137,6 @@ type BodyProps = { entity: string; }; -const parseStudies = (studyId, studies) => { - const parsedStudies = []; - const studyIds = new Set([studyId]); - for (const study of studies) { - if (!studyIds.has(study.studyId)) { - parsedStudies.push(study); - studyIds.add(study.studyId); - } - } - return parsedStudies; -}; - export function Body({ studyId, diseaseIds, entity }: BodyProps) { const variables = { diseaseIds: diseaseIds, @@ -167,11 +155,10 @@ export function Body({ studyId, diseaseIds, entity }: BodyProps) { entity={"studies"} renderDescription={() => } renderBody={() => { - const rows = request.data?.studies ? parseStudies(studyId, request.data.studies.rows) : []; return (