Skip to content

Commit

Permalink
refactor: remove variant vsariable from CS profile request
Browse files Browse the repository at this point in the history
  • Loading branch information
carcruz committed Dec 11, 2024
1 parent 1b4c808 commit 0beab51
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 30 deletions.
4 changes: 2 additions & 2 deletions apps/platform/src/pages/CredibleSetPage/Profile.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ function Profile({ studyLocusId, variantId, referenceAllele, alternateAllele }:
);

const CREDIBLE_SET_PROFILE_QUERY = gql`
query CredibleSetProfileQuery($studyLocusId: String!, $variantIds: [String!]!) {
query CredibleSetProfileQuery($studyLocusId: String!) {
credibleSet(studyLocusId: $studyLocusId) {
studyLocusId
...CredibleSetProfileHeaderFragment
Expand All @@ -50,7 +50,7 @@ function Profile({ studyLocusId, variantId, referenceAllele, alternateAllele }:
<PlatformApiProvider
entity={CREDIBLE_SET}
query={CREDIBLE_SET_PROFILE_QUERY}
variables={{ studyLocusId: studyLocusId, variantIds: [variantId] }}
variables={{ studyLocusId: studyLocusId }}
client={client}
>
<ProfileHeader />
Expand Down
2 changes: 1 addition & 1 deletion apps/platform/src/pages/CredibleSetPage/ProfileHeader.gql
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ fragment CredibleSetProfileHeaderFragment on credibleSet {
standardError
effectAlleleFrequencyFromSource
qualityControls
locus(variantIds: $variantIds) {
locus(page: { size: 1, index: 0 }) {
count
rows {
posteriorProbability
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

0 comments on commit 0beab51

Please sign in to comment.