Skip to content

Commit

Permalink
[Platform]: study profile feedback (#565)
Browse files Browse the repository at this point in the history
  • Loading branch information
carcruz authored Nov 29, 2024
1 parent d0875d7 commit ab1df24
Show file tree
Hide file tree
Showing 19 changed files with 278 additions and 314 deletions.
103 changes: 57 additions & 46 deletions apps/platform/src/pages/StudyPage/Header.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,54 +17,71 @@ type HeaderProps = {
};

function Header({
loading,
studyId,
backgroundTraits,
targetId,
diseases,
studyCategory
}: HeaderProps) {

loading,
studyId,
backgroundTraits,
targetId,
diseases,
projectId,
}: HeaderProps) {
let traitLinks, sourceLink;
if (studyCategory === 'GWAS') {
if (projectId === "GCST") {
if (diseases?.length) {
traitLinks = <XRefLinks
label="Trait"
urlStem="../disease/"
ids={diseases.map(d => d.id)}
names={diseases.map(d => d.name)}
/>
traitLinks = (
<XRefLinks
label="Trait"
urlStem="../disease/"
ids={diseases.map(d => d.id)}
names={diseases.map(d => d.name)}
/>
);
}
sourceLink = {
id: "GWAS Catalog",
url: `https://www.ebi.ac.uk/gwas/studies/${studyId}`,
};
} else if (studyCategory === 'FINNGEN') {
} else if (projectId === "FINNGEN_R11") {
if (diseases?.length) {
traitLinks = <XRefLinks
label="Trait"
urlStem="../disease/"
ids={diseases.map(d => d.id)}
names={diseases.map(d => d.name)}
/>
traitLinks = (
<XRefLinks
label="Trait"
urlStem="../disease/"
ids={diseases.map(d => d.id)}
names={diseases.map(d => d.name)}
/>
);
}
sourceLink = {
id: "FinnGen",
url: `https://r10.finngen.fi/pheno/${studyId}`,
};
} else { // QTL
} else if (projectId === "UKB_PPP_EUR") {
if (diseases?.length) {
traitLinks = (
<XRefLinks
label="Trait"
urlStem="../disease/"
ids={diseases.map(d => d.id)}
names={diseases.map(d => d.name)}
/>
);
}
sourceLink = {
id: "UKB",
url: "https://www.synapse.org/Synapse:syn51364943/wiki/622119",
};
} else {
// QTL
if (targetId) {
traitLinks = <ExternalLink
title="Affected gene"
id={targetId}
url={`../target/${targetId}`}
/>
traitLinks = (
<ExternalLink title="Affected gene" id={targetId} url={`../target/${targetId}`} />
);
}
sourceLink = {
id: "eQTL Catalog",
url: "https://www.ebi.ac.uk/eqtl/Studies/",
};
};
}

return (
<HeaderBase
Expand All @@ -73,27 +90,21 @@ function Header({
subtitle={null}
Icon={faChartBar}
externalLinks={
<>
<>
{traitLinks}
{
studyCategory === "GWAS" && backgroundTraits?.length > 0 &&
<XRefLinks
label="Background traits"
urlStem="../disease/"
ids={backgroundTraits.map(t => t.id)}
names={backgroundTraits.map(t => t.name)}
/>
}
<ExternalLink
title="Source"
id={sourceLink.id}
url={sourceLink.url}
/>
{projectId === "GWAS" && backgroundTraits?.length > 0 && (
<XRefLinks
label="Background traits"
urlStem="../disease/"
ids={backgroundTraits.map(t => t.id)}
names={backgroundTraits.map(t => t.name)}
/>
)}
<ExternalLink title="Source" id={sourceLink.id} url={sourceLink.url} />
</>
}
/>
);

}

export default Header;
export default Header;
20 changes: 10 additions & 10 deletions apps/platform/src/pages/StudyPage/Profile.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import GWASCredidbleSetsSummary from "sections/src/study/GWASCredibleSets/Summar
import QTLCredibleSetsSummary from "sections/src/study/QTLCredibleSets/Summary";

import client from "../../client";
import ProfileHeader from "./ProfileHeader";
import ProfileHeader from "./StudyProfileHeader";

const SharedTraitStudiesSection = lazy(() => import("sections/src/study/SharedTraitStudies/Body"));
const GWASCredibleSetsSection = lazy(() => import("sections/src/study/GWASCredibleSets/Body"));
Expand All @@ -23,21 +23,23 @@ const QTLCredibleSetsSection = lazy(() => import("sections/src/study/QTLCredible
// (the summary cannot be written as a fragment as it gets further studies)
const summaries = [GWASCredidbleSetsSummary, QTLCredibleSetsSummary];

const STUDY = "gwasStudy";
const STUDY = "study";
const STUDY_PROFILE_SUMMARY_FRAGMENT = summaryUtils.createSummaryFragment(
summaries,
"Gwas",
"StudyProfileSummaryFragment"
);
const STUDY_PROFILE_QUERY = gql`
query StudyProfileQuery($studyId: String!, $diseaseIds: [String!]!) {
gwasStudy(studyId: $studyId) {
studyId
study(studyId: $studyId) {
id
...StudyProfileHeaderFragment
...StudyProfileSummaryFragment
}
sharedTraitStudies: gwasStudy(diseaseIds: $diseaseIds, page: { size: 2, index: 0 }) {
studyId
sharedTraitStudies: studies(diseaseIds: $diseaseIds, page: { size: 2, index: 0 }) {
rows {
id
}
}
}
${ProfileHeader.fragments.profileHeader}
Expand All @@ -53,11 +55,9 @@ type ProfileProps = {
}[];
};

function Profile({ studyId, studyType, diseases }: ProfileProps) {
function Profile({ studyId, studyType, projectId, diseases }: ProfileProps) {
const diseaseIds = diseases?.map(d => d.id) || [];

console.log({ studyType });

return (
<PlatformApiProvider
entity={STUDY}
Expand All @@ -68,7 +68,7 @@ function Profile({ studyId, studyType, diseases }: ProfileProps) {
}}
client={client}
>
<ProfileHeader studyCategory={studyType} />
<ProfileHeader projectId={projectId} />

<SummaryContainer>
{studyType === "gwas" && (
Expand Down
186 changes: 0 additions & 186 deletions apps/platform/src/pages/StudyPage/ProfileHeader.tsx

This file was deleted.

4 changes: 2 additions & 2 deletions apps/platform/src/pages/StudyPage/StudyPage.gql
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
query StudyPageQuery($studyId: String!) {
gwasStudy(studyId: $studyId) {
studyId
study(studyId: $studyId) {
id
studyType
projectId
backgroundTraits {
Expand Down
Loading

0 comments on commit ab1df24

Please sign in to comment.