Skip to content

Commit

Permalink
Change populations to ancestry_groups in variant cooccurrence page
Browse files Browse the repository at this point in the history
  • Loading branch information
phildarnowsky-broad committed Mar 27, 2024
1 parent 53ddc04 commit 8c7ec45
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ const baseApiResponse = {
haplotype_counts: [10, 11, 12, 13],
p_compound_heterozygous: 0.123, // TK calculate in real value

populations: [],
ancestry_groups: [],
},
variant1: {
exome: { ac: 999, an: 101010 },
Expand Down
21 changes: 11 additions & 10 deletions browser/src/VariantCooccurrencePage/VariantCooccurrencePage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ export type CooccurrenceData = {
genotype_counts: GenotypeCounts
haplotype_counts: HaplotypeCounts
p_compound_heterozygous: number | null
populations: {
ancestry_groups: {
id: string
genotype_counts: GenotypeCounts
haplotype_counts: HaplotypeCounts
Expand Down Expand Up @@ -193,7 +193,7 @@ const VariantCoocurrence = ({ cooccurrenceData }: VariantCoocurrenceProps) => {
const cooccurrenceInSelectedPopulation =
selectedPopulation === 'All'
? cooccurrenceData
: cooccurrenceData.populations!.find((pop: any) => pop.id === selectedPopulation)!
: cooccurrenceData.ancestry_groups!.find((pop) => pop.id === selectedPopulation)!

const prediction = makePrediction(cooccurrenceInSelectedPopulation)

Expand All @@ -206,9 +206,10 @@ const VariantCoocurrence = ({ cooccurrenceData }: VariantCoocurrenceProps) => {
cooccurrenceData.genotype_counts.hom_hom >
0

const anyPopulationWithoutPrediction = [cooccurrenceData, ...cooccurrenceData.populations].some(
noPredictionPossible
)
const anyPopulationWithoutPrediction = [
cooccurrenceData,
...cooccurrenceData.ancestry_groups,
].some(noPredictionPossible)

const isDistantCis =
prediction === 'in_cis' && variantDistance(cooccurrenceData) > distantCisThreshold
Expand Down Expand Up @@ -325,7 +326,7 @@ query ${operationName}($variants: [String!]!, $variant1: String!, $variant2: Str
genotype_counts
haplotype_counts
p_compound_heterozygous
populations {
ancestry_groups {
id
genotype_counts
haplotype_counts
Expand Down Expand Up @@ -444,12 +445,12 @@ const structureCounts = (population: ArrayCountPopulation): ObjectCountPopulatio
}

const normalizeCooccurrenceData = (cooccurrenceData: any): CooccurrenceData => {
const populations = cooccurrenceData.populations
? cooccurrenceData.populations.map(structureCounts)
: cooccurrenceData.populations
const ancestry_groups = cooccurrenceData.ancestry_groups
? cooccurrenceData.ancestry_groups.map(structureCounts)
: cooccurrenceData.ancestry_groups

const topLevel = structureCounts(cooccurrenceData)
return { ...topLevel, populations } as CooccurrenceData
return { ...topLevel, ancestry_groups } as CooccurrenceData
}

const VariantCoocurrenceContainer = ({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ const VariantCooccurrenceSummaryTable = ({
</tr>
</thead>
<tbody>
{cooccurrenceData.populations.map((pop) => (
{cooccurrenceData.ancestry_groups.map((pop) => (
<tr
key={pop.id}
style={pop.id === selectedPopulation ? { background: '#eee' } : undefined}
Expand Down

0 comments on commit 8c7ec45

Please sign in to comment.