Skip to content

Commit

Permalink
[Platform] Update metadata on study page and credible set page (#589)
Browse files Browse the repository at this point in the history
  • Loading branch information
gjmcn authored Dec 5, 2024
1 parent e35a24c commit e291bbb
Show file tree
Hide file tree
Showing 12 changed files with 296 additions and 235 deletions.
2 changes: 1 addition & 1 deletion apps/platform/src/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -341,7 +341,7 @@ export const variantConsequenceSource = {
},
};

export const poulationMap = {
export const populationMap = {
fin: "Finish",
afr: "African",
nfe: "non-Finnish Europeans",
Expand Down
2 changes: 1 addition & 1 deletion apps/platform/src/pages/CredibleSetPage/Profile.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ function Profile({ studyLocusId, variantId, referenceAllele, alternateAllele }:
variables={{ studyLocusId: studyLocusId, variantIds: [variantId] }}
client={client}
>
<ProfileHeader variantId={variantId} />
<ProfileHeader />

<SummaryContainer>
<VariantsSummary />
Expand Down
2 changes: 2 additions & 0 deletions apps/platform/src/pages/CredibleSetPage/ProfileHeader.gql
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,8 @@ fragment CredibleSetProfileHeaderFragment on credibleSet {
publicationJournal
pubmedId
nSamples
cohorts
initialSampleSize
studyType
hasSumstats
analysisFlags
Expand Down
108 changes: 24 additions & 84 deletions apps/platform/src/pages/CredibleSetPage/ProfileHeader.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,79 +10,22 @@ import {
ClinvarStars,
LabelChip,
DetailPopover,
SummaryStatsTable,
DisplaySampleSize,
} from "ui";
import { Box, Typography } 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 { v1 } from "uuid";
import { credsetConfidenceMap, populationMap } from "../../constants";

type ProfileHeaderProps = {
variantId: string;
};

const dicSummary = [
{ 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",
},
];

function SummaryStatsTable({ sumstatQCValues }: any) {
return (
<>
<Typography sx={{ fontSize: 16, fontWeight: 600, my: 1 }} variant="subtitle2">
Harmonised summary statistics
</Typography>
<table>
<tbody>
{dicSummary.map((sumstat: any) => {
const summStatValue = sumstatQCValues.find(
(v: any) => v.QCCheckName === sumstat.id
).QCCheckValue;
return (
<tr key={v1()}>
<td>
<Tooltip title={sumstat.tooltip} showHelpIcon>
{sumstat.label}
</Tooltip>
</td>
<Typography sx={{ textAlign: "right" }} component="td" variant="body2">
{summStatValue}
</Typography>
</tr>
);
})}
</tbody>
</table>
</>
);
}

function ProfileHeader({ variantId }: ProfileHeaderProps) {
function ProfileHeader() {
const { loading, error, data } = usePlatformApi();

// TODO: Errors!
if (error) return null;

const credibleSet = data?.credibleSet;
const study = credibleSet?.study;
const studyCategory = study ? getStudyCategory(study.projectId) : null;
const target = study?.target;
const leadVariant = credibleSet?.locus.rows[0];
const beta = leadVariant?.beta ?? credibleSet?.beta;
Expand Down Expand Up @@ -249,7 +192,7 @@ function ProfileHeader({ variantId }: ProfileHeaderProps) {
<Typography variant="subtitle1" mt={0}>
{study?.studyType.replace(/(qtl|gwas)/gi, match => match.toUpperCase())} Study
</Typography>
{studyCategory !== "QTL" && (
{study?.studyType === "gwas" && (
<>
<Field loading={loading} title="Reported trait">
{study?.traitFromSource}
Expand All @@ -276,7 +219,7 @@ function ProfileHeader({ variantId }: ProfileHeaderProps) {
)}
</>
)}
{studyCategory === "QTL" && (
{study?.studyType !== "gwas" && (
<>
{target?.id && (
<Field loading={loading} title="Affected gene">
Expand Down Expand Up @@ -308,18 +251,9 @@ function ProfileHeader({ variantId }: ProfileHeaderProps) {
</PublicationsDrawer>
</Field>
)}
{study?.analysisFlags && (
<Field
loading={loading}
title={
<Tooltip title="Type of analysis" showHelpIcon>
Analysis
</Tooltip>
}
>
{study?.analysisFlags ? study.analysisFlags : "Not Available"}
</Field>
)}
<Field loading={loading} title="Analysis">
{study?.analysisFlags?.join(", ")}
</Field>
<Field loading={loading} title="Summary statistics">
{!study?.hasSumstats
? "Not Available"
Expand All @@ -330,21 +264,27 @@ function ProfileHeader({ variantId }: ProfileHeaderProps) {
: "Available"
}
</Field>
<Field loading={loading} title="Sample size">
{study?.nSamples.toLocaleString()}
</Field>
<Box display="flex" sx={{ gap: 1 }}>
{/* LD Ancestries */}
{study?.ldPopulationStructure?.length > 0 &&
study.ldPopulationStructure.map(({ ldPopulation, relativeSampleSize }, index) => (
{study?.nSamples &&
<Field loading={loading} title="Sample size">
<DisplaySampleSize
nSamples={study.nSamples}
cohorts={study?.cohorts}
initialSampleSize={study?.initialSampleSize}
/>
</Field>
}
{study?.ldPopulationStructure?.length > 0 &&
<Box display="flex" sx={{ gap: 1 }}>
{study.ldPopulationStructure.map(({ ldPopulation, relativeSampleSize }) => (
<LabelChip
key={ldPopulation}
label={ldPopulation.toUpperCase()}
value={`${(relativeSampleSize * 100).toFixed(0)}%`}
tooltip={`LD reference population: ${poulationMap[ldPopulation]}`}
tooltip={`LD reference population: ${populationMap[ldPopulation]}`}
/>
))}
</Box>
</Box>
}
</Box>
</BaseProfileHeader >
);
Expand Down
2 changes: 1 addition & 1 deletion apps/platform/src/pages/StudyPage/Header.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ function Header({
if (diseases?.length) {
traitLinks = (
<XRefLinks
label="Trait"
label="Disease or phenotype"
urlStem="../disease/"
ids={diseases.map(d => d.id)}
names={diseases.map(d => d.name)}
Expand Down
2 changes: 1 addition & 1 deletion apps/platform/src/pages/StudyPage/Profile.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ function Profile({ studyId, studyType, projectId, diseases }: ProfileProps) {
}}
client={client}
>
<ProfileHeader projectId={projectId} />
<ProfileHeader />

<SummaryContainer>
{studyType === "gwas" && (
Expand Down
28 changes: 21 additions & 7 deletions apps/platform/src/pages/StudyPage/StudyProfileHeader.gql
Original file line number Diff line number Diff line change
@@ -1,26 +1,40 @@
fragment StudyProfileHeaderFragment on Gwas {
studyType
publicationFirstAuthor
publicationDate
publicationJournal
pubmedId
traitFromSource
backgroundTraits {
id
name
}
diseases {
id
name
}
target {
id
approvedSymbol
}
nSamples
initialSampleSize
replicationSamples {
sampleSize
ancestry
}
nCases
nControls
cohorts
ldPopulationStructure {
ldPopulation
relativeSampleSize
}
hasSumstats
sumstatQCValues {
QCCheckName
QCCheckValue
}
qualityControls
analysisFlags
discoverySamples {
sampleSize
ancestry
biosample {
biosampleId
biosampleName
}
}
Loading

0 comments on commit e291bbb

Please sign in to comment.