Skip to content

Commit 12869f6

Browse files
Change populations to ancestry_groups in variant page
1 parent 1c390b2 commit 12869f6

File tree

6 files changed

+45
-45
lines changed

6 files changed

+45
-45
lines changed

browser/src/VariantList/ExportVariantsButton.tsx

+3-3
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,8 @@ const getValueGivenProperty = (
2222
variant: VariantTableVariant,
2323
property: Property
2424
) => {
25-
return variant.populations.filter((v) => v.id === popId)[0]
26-
? JSON.stringify(variant.populations.filter((v) => v.id === popId)[0][property])
25+
return variant.ancestry_groups.filter((v) => v.id === popId)[0]
26+
? JSON.stringify(variant.ancestry_groups.filter((v) => v.id === popId)[0][property])
2727
: ''
2828
}
2929

@@ -342,7 +342,7 @@ export type VariantTableVariant = {
342342
hgvs?: string
343343
hgvsc?: string
344344
hgvsp?: string
345-
populations: Population[]
345+
ancestry_groups: Population[]
346346
pos: number
347347
rsids?: string[]
348348
transcript_id: string

browser/src/VariantList/mergeExomeAndGenomeData.spec.ts

+12-12
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ const createAncestryGroupObjects = (shorthands: AncestryGroupShorthand[]) => {
2626
}
2727

2828
describe('mergeExomeAndGenomePopulationData', () => {
29-
it('returns expected values when exomes and genomes have the same populations', () => {
29+
it('returns expected values when exomes and genomes have the same ancestry_groups', () => {
3030
const geneticAncestryGroupObjects = createAncestryGroupObjects([
3131
{ id: 'afr', value: 1 },
3232
{ id: 'remaining', value: 2 },
@@ -35,8 +35,8 @@ describe('mergeExomeAndGenomePopulationData', () => {
3535

3636
const testVariant = variantFactory.build({
3737
variant_id: 'test_variant',
38-
exome: { populations: geneticAncestryGroupObjects },
39-
genome: { populations: geneticAncestryGroupObjects },
38+
exome: { ancestry_groups: geneticAncestryGroupObjects },
39+
genome: { ancestry_groups: geneticAncestryGroupObjects },
4040
})
4141

4242
const result = mergeExomeAndGenomePopulationData(testVariant.exome!, testVariant.genome!)
@@ -50,7 +50,7 @@ describe('mergeExomeAndGenomePopulationData', () => {
5050
expect(result).toStrictEqual(expected)
5151
})
5252

53-
it('returns expected values when exomes have less populations than genomes', () => {
53+
it('returns expected values when exomes have less ancestry_groups than genomes', () => {
5454
const exomeGeneticAncestryGroupObjects = createAncestryGroupObjects([
5555
{ id: 'afr', value: 1 },
5656
{ id: 'remaining', value: 2 },
@@ -66,8 +66,8 @@ describe('mergeExomeAndGenomePopulationData', () => {
6666

6767
const testVariant = variantFactory.build({
6868
variant_id: 'test_variant',
69-
exome: { populations: exomeGeneticAncestryGroupObjects },
70-
genome: { populations: genomeGeneticAncestryGroupObjects },
69+
exome: { ancestry_groups: exomeGeneticAncestryGroupObjects },
70+
genome: { ancestry_groups: genomeGeneticAncestryGroupObjects },
7171
})
7272

7373
const result = mergeExomeAndGenomePopulationData(testVariant.exome!, testVariant.genome!)
@@ -82,7 +82,7 @@ describe('mergeExomeAndGenomePopulationData', () => {
8282
expect(result).toStrictEqual(expected)
8383
})
8484

85-
it('returns expected values exomes have more populations than genomes', () => {
85+
it('returns expected values exomes have more ancestry_groups than genomes', () => {
8686
const exomeGeneticAncestryGroupObjects = createAncestryGroupObjects([
8787
{ id: 'afr', value: 1 },
8888
{ id: 'remaining', value: 2 },
@@ -98,8 +98,8 @@ describe('mergeExomeAndGenomePopulationData', () => {
9898

9999
const testVariant = variantFactory.build({
100100
variant_id: 'test_variant',
101-
exome: { populations: exomeGeneticAncestryGroupObjects },
102-
genome: { populations: genomeGeneticAncestryGroupObjects },
101+
exome: { ancestry_groups: exomeGeneticAncestryGroupObjects },
102+
genome: { ancestry_groups: genomeGeneticAncestryGroupObjects },
103103
})
104104

105105
const result = mergeExomeAndGenomePopulationData(testVariant.exome!, testVariant.genome!)
@@ -114,7 +114,7 @@ describe('mergeExomeAndGenomePopulationData', () => {
114114
expect(result).toStrictEqual(expected)
115115
})
116116

117-
it('returns expected values when exome and genome populations are in a different order', () => {
117+
it('returns expected values when exome and genome ancestry_groups are in a different order', () => {
118118
const exomeGeneticAncestryGroupObjects = createAncestryGroupObjects([
119119
{ id: 'eur', value: 1 },
120120
{ id: 'afr', value: 2 },
@@ -129,8 +129,8 @@ describe('mergeExomeAndGenomePopulationData', () => {
129129

130130
const testVariant = variantFactory.build({
131131
variant_id: 'test_variant',
132-
exome: { populations: exomeGeneticAncestryGroupObjects },
133-
genome: { populations: genomeGeneticAncestryGroupObjects },
132+
exome: { ancestry_groups: exomeGeneticAncestryGroupObjects },
133+
genome: { ancestry_groups: genomeGeneticAncestryGroupObjects },
134134
})
135135

136136
const result = mergeExomeAndGenomePopulationData(testVariant.exome!, testVariant.genome!)

browser/src/VariantList/mergeExomeAndGenomeData.ts

+10-10
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,10 @@ export const mergeExomeAndGenomePopulationData = (
77
exome: SequencingType,
88
genome: SequencingType
99
) => {
10-
const populations: { [key: string]: Population } = {}
10+
const ancestry_groups: { [key: string]: Population } = {}
1111

12-
exome.populations.forEach((exomePopulation: Population) => {
13-
populations[exomePopulation.id] = {
12+
exome.ancestry_groups.forEach((exomePopulation: Population) => {
13+
ancestry_groups[exomePopulation.id] = {
1414
id: exomePopulation.id,
1515
ac: exomePopulation.ac,
1616
an: exomePopulation.an,
@@ -19,18 +19,18 @@ export const mergeExomeAndGenomePopulationData = (
1919
}
2020
})
2121

22-
genome.populations.forEach((genomePopulation: Population) => {
23-
if (genomePopulation.id in populations) {
24-
const entry = populations[genomePopulation.id]
25-
populations[genomePopulation.id] = {
22+
genome.ancestry_groups.forEach((genomePopulation: Population) => {
23+
if (genomePopulation.id in ancestry_groups) {
24+
const entry = ancestry_groups[genomePopulation.id]
25+
ancestry_groups[genomePopulation.id] = {
2626
id: genomePopulation.id,
2727
ac: add(entry.ac, genomePopulation.ac),
2828
an: add(entry.an, genomePopulation.an),
2929
ac_hemi: add(entry.ac_hemi, genomePopulation.ac_hemi),
3030
ac_hom: add(entry.ac_hom, genomePopulation.ac_hom),
3131
}
3232
} else {
33-
populations[genomePopulation.id] = {
33+
ancestry_groups[genomePopulation.id] = {
3434
id: genomePopulation.id,
3535
ac: genomePopulation.ac,
3636
an: genomePopulation.an,
@@ -40,7 +40,7 @@ export const mergeExomeAndGenomePopulationData = (
4040
}
4141
})
4242

43-
return Object.values(populations)
43+
return Object.values(ancestry_groups)
4444
}
4545

4646
const mergeExomeAndGenomeData = (variants: any) =>
@@ -74,7 +74,7 @@ const mergeExomeAndGenomeData = (variants: any) =>
7474
ac_hemi: add(exome.ac_hemi, genome.ac_hemi),
7575
ac_hom: add(exome.ac_hom, genome.ac_hom),
7676
filters: exome.filters.concat(genome.filters),
77-
populations: mergeExomeAndGenomePopulationData(exome!, genome!),
77+
ancestry_groups: mergeExomeAndGenomePopulationData(exome!, genome!),
7878
}
7979
})
8080

browser/src/VariantPage/VariantPage.tsx

+7-7
Original file line numberDiff line numberDiff line change
@@ -194,8 +194,8 @@ export type SequencingType = {
194194
hemizygote_count: number | null
195195
faf95: Faf95
196196
filters: string[]
197-
populations: Population[]
198-
local_ancestry_populations: LocalAncestryPopulation[]
197+
ancestry_groups: Population[]
198+
local_ancestry_groups: LocalAncestryPopulation[]
199199
age_distribution: AgeDistribution | null
200200
quality_metrics: VariantQualityMetrics
201201
}
@@ -348,7 +348,7 @@ export const VariantPageContent = ({ datasetId, variant }: VariantPageContentPro
348348
Genetic Ancestry Group Frequencies <InfoButton topic="ancestry" />
349349
</h2>
350350
{hasLocalAncestryPopulations(datasetId) &&
351-
((variant.genome && variant.genome.local_ancestry_populations) || []).length > 0 && (
351+
((variant.genome && variant.genome.local_ancestry_groups) || []).length > 0 && (
352352
<div
353353
style={{
354354
padding: '0 1em',
@@ -495,14 +495,14 @@ query ${operationName}($variantId: String!, $datasetId: DatasetId!, $referenceGe
495495
popmax_population
496496
}
497497
filters
498-
populations {
498+
ancestry_groups {
499499
id
500500
ac
501501
an
502502
ac_hemi
503503
ac_hom
504504
}
505-
local_ancestry_populations @include(if: $includeLocalAncestry) {
505+
local_ancestry_groups @include(if: $includeLocalAncestry) {
506506
id
507507
ac
508508
an
@@ -574,14 +574,14 @@ query ${operationName}($variantId: String!, $datasetId: DatasetId!, $referenceGe
574574
popmax_population
575575
}
576576
filters
577-
populations {
577+
ancestry_groups {
578578
id
579579
ac
580580
an
581581
ac_hemi
582582
ac_hom
583583
}
584-
local_ancestry_populations @include(if: $includeLocalAncestry) {
584+
local_ancestry_groups @include(if: $includeLocalAncestry) {
585585
id
586586
ac
587587
an

browser/src/VariantPage/VariantPopulationFrequencies.tsx

+7-7
Original file line numberDiff line numberDiff line change
@@ -23,22 +23,22 @@ type Props = {
2323
const VariantPopulationFrequencies = ({ datasetId, variant }: Props) => {
2424
if (hasLocalAncestryPopulations(datasetId) && variant.genome) {
2525
const genome = variant.genome!
26-
const genomePopulations = genome.populations.filter(
26+
const genomePopulations = genome.ancestry_groups.filter(
2727
(pop) => !(pop.id.startsWith('hgdp:') || pop.id.startsWith('1kg:'))
2828
)
2929
const exomePopulations = variant.exome
30-
? variant.exome.populations.filter(
30+
? variant.exome.ancestry_groups.filter(
3131
(pop) => !(pop.id.startsWith('hgdp:') || pop.id.startsWith('1kg:'))
3232
)
3333
: []
34-
const hgdpPopulations = genome.populations
34+
const hgdpPopulations = genome.ancestry_groups
3535
.filter((pop) => pop.id.startsWith('hgdp:'))
3636
.map((pop) => ({ ...pop, id: pop.id.slice(5) })) // Remove hgdp: prefix
37-
const tgpPopulations = genome.populations
37+
const tgpPopulations = genome.ancestry_groups
3838
.filter((pop) => pop.id.startsWith('1kg:'))
3939
.map((pop) => ({ ...pop, id: pop.id.slice(4) })) // Remove 1kg: prefix
4040

41-
const localAncestryPopulations = genome.local_ancestry_populations || []
41+
const localAncestryPopulations = genome.local_ancestry_groups || []
4242

4343
return (
4444
// @ts-expect-error TS(2741) FIXME: Property 'onChange' is missing in type '{ tabs: { ... Remove this comment to see the full error message
@@ -141,8 +141,8 @@ const VariantPopulationFrequencies = ({ datasetId, variant }: Props) => {
141141
<TableWrapper>
142142
<GnomadPopulationsTable
143143
datasetId={datasetId}
144-
exomePopulations={variant.exome ? variant.exome.populations : []}
145-
genomePopulations={variant.genome ? variant.genome.populations : []}
144+
exomePopulations={variant.exome ? variant.exome.ancestry_groups : []}
145+
genomePopulations={variant.genome ? variant.genome.ancestry_groups : []}
146146
showHemizygotes={variant.chrom === 'X' || variant.chrom === 'Y'}
147147
/>
148148
</TableWrapper>

browser/src/__factories__/Variant.ts

+6-6
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ export const variantTableVariantFactory = Factory.define<VariantTableVariant>(
148148
hgvs = 'string',
149149
hgvsc = 'string',
150150
hgvsp = 'string',
151-
populations = [],
151+
ancestry_groups = [],
152152
pos = 1,
153153
rsids = [],
154154
variant_id = '',
@@ -177,7 +177,7 @@ export const variantTableVariantFactory = Factory.define<VariantTableVariant>(
177177
hgvs,
178178
hgvsc,
179179
hgvsp,
180-
populations,
180+
ancestry_groups,
181181
pos,
182182
rsids,
183183
variant_id,
@@ -198,8 +198,8 @@ export const sequencingFactory = Factory.define<SequencingType>(({ params, assoc
198198
homozygote_count = null,
199199
hemizygote_count = null,
200200
filters = [],
201-
populations = [],
202-
local_ancestry_populations = [],
201+
ancestry_groups = [],
202+
local_ancestry_groups = [],
203203
ac_hemi = 1,
204204
ac_hom = 1,
205205
} = params
@@ -226,8 +226,8 @@ export const sequencingFactory = Factory.define<SequencingType>(({ params, assoc
226226
homozygote_count,
227227
hemizygote_count,
228228
filters,
229-
populations,
230-
local_ancestry_populations,
229+
ancestry_groups,
230+
local_ancestry_groups,
231231
age_distribution,
232232
quality_metrics,
233233
faf95,

0 commit comments

Comments
 (0)