Skip to content

Commit f218a0e

Browse files
Change populations to ancestry_groups in CNV page query and associated fields
1 parent 9b524e4 commit f218a0e

File tree

5 files changed

+62
-62
lines changed

5 files changed

+62
-62
lines changed

browser/src/CopyNumberVariantList/__snapshots__/CopyNumberVariants.spec.tsx.snap

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,14 @@ exports[`CopyNumberVariants has no unexpected changes 1`] = `
1414
[
1515
{
1616
"alts": null,
17+
"ancestry_groups": [],
1718
"chrom": "21",
1819
"end": 456,
1920
"endmax": 100168742,
2021
"endmin": 100168738,
2122
"filters": [],
2223
"genes": [],
2324
"length": 333,
24-
"populations": [],
2525
"pos": 123,
2626
"posmax": 100121284,
2727
"posmin": 100121281,
@@ -35,14 +35,14 @@ exports[`CopyNumberVariants has no unexpected changes 1`] = `
3535
},
3636
{
3737
"alts": null,
38+
"ancestry_groups": [],
3839
"chrom": "21",
3940
"end": 456,
4041
"endmax": 100168742,
4142
"endmin": 100168738,
4243
"filters": [],
4344
"genes": [],
4445
"length": 333,
45-
"populations": [],
4646
"pos": 123,
4747
"posmax": 100121284,
4848
"posmin": 100121281,
@@ -56,14 +56,14 @@ exports[`CopyNumberVariants has no unexpected changes 1`] = `
5656
},
5757
{
5858
"alts": null,
59+
"ancestry_groups": [],
5960
"chrom": "21",
6061
"end": 456,
6162
"endmax": 100168742,
6263
"endmin": 100168738,
6364
"filters": [],
6465
"genes": [],
6566
"length": 333,
66-
"populations": [],
6767
"pos": 123,
6868
"posmax": 100121284,
6969
"posmin": 100121281,
@@ -111,14 +111,14 @@ exports[`CopyNumberVariants has no unexpected changes 1`] = `
111111
[
112112
{
113113
"alts": null,
114+
"ancestry_groups": [],
114115
"chrom": "21",
115116
"end": 456,
116117
"endmax": 100168742,
117118
"endmin": 100168738,
118119
"filters": [],
119120
"genes": [],
120121
"length": 333,
121-
"populations": [],
122122
"pos": 123,
123123
"posmax": 100121284,
124124
"posmin": 100121281,
@@ -132,14 +132,14 @@ exports[`CopyNumberVariants has no unexpected changes 1`] = `
132132
},
133133
{
134134
"alts": null,
135+
"ancestry_groups": [],
135136
"chrom": "21",
136137
"end": 456,
137138
"endmax": 100168742,
138139
"endmin": 100168738,
139140
"filters": [],
140141
"genes": [],
141142
"length": 333,
142-
"populations": [],
143143
"pos": 123,
144144
"posmax": 100121284,
145145
"posmin": 100121281,
@@ -153,14 +153,14 @@ exports[`CopyNumberVariants has no unexpected changes 1`] = `
153153
},
154154
{
155155
"alts": null,
156+
"ancestry_groups": [],
156157
"chrom": "21",
157158
"end": 456,
158159
"endmax": 100168742,
159160
"endmin": 100168738,
160161
"filters": [],
161162
"genes": [],
162163
"length": 333,
163-
"populations": [],
164164
"pos": 123,
165165
"posmax": 100121284,
166166
"posmin": 100121281,
@@ -293,14 +293,14 @@ exports[`CopyNumberVariants has no unexpected changes 1`] = `
293293
[
294294
{
295295
"alts": null,
296+
"ancestry_groups": [],
296297
"chrom": "21",
297298
"end": 456,
298299
"endmax": 100168742,
299300
"endmin": 100168738,
300301
"filters": [],
301302
"genes": [],
302303
"length": 333,
303-
"populations": [],
304304
"pos": 123,
305305
"posmax": 100121284,
306306
"posmin": 100121281,
@@ -314,14 +314,14 @@ exports[`CopyNumberVariants has no unexpected changes 1`] = `
314314
},
315315
{
316316
"alts": null,
317+
"ancestry_groups": [],
317318
"chrom": "21",
318319
"end": 456,
319320
"endmax": 100168742,
320321
"endmin": 100168738,
321322
"filters": [],
322323
"genes": [],
323324
"length": 333,
324-
"populations": [],
325325
"pos": 123,
326326
"posmax": 100121284,
327327
"posmin": 100121281,
@@ -335,14 +335,14 @@ exports[`CopyNumberVariants has no unexpected changes 1`] = `
335335
},
336336
{
337337
"alts": null,
338+
"ancestry_groups": [],
338339
"chrom": "21",
339340
"end": 456,
340341
"endmax": 100168742,
341342
"endmin": 100168738,
342343
"filters": [],
343344
"genes": [],
344345
"length": 333,
345-
"populations": [],
346346
"pos": 123,
347347
"posmax": 100121284,
348348
"posmin": 100121281,

browser/src/CopyNumberVariantPage/CNVPopulationsTable.tsx

Lines changed: 18 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -62,18 +62,18 @@ const renderPopSF = (sf: number | string) => {
6262
return sf
6363
}
6464

65-
type OwnPopulationsTableProps = {
65+
type CNVPopulationsTableProps = {
6666
columnLabels?: {
6767
sc?: string
6868
sn?: string
6969
sf?: string
7070
}
71-
populations: {
71+
ancestry_groups: {
7272
id: string
7373
name: string
7474
sc: number
7575
sn: number
76-
subpopulations?: {
76+
subancestry_groups?: {
7777
id: string
7878
name: string
7979
sc: number
@@ -86,25 +86,23 @@ type OwnPopulationsTableProps = {
8686

8787
type CNVPopulationsTableState = any
8888

89-
type CNVPopulationsTableProps = OwnPopulationsTableProps & typeof CNVPopulationsTable.defaultProps
90-
9189
export class CNVPopulationsTable extends Component<
92-
CNVPopulationsTableProps & { variant: CopyNumberVariant},
90+
CNVPopulationsTableProps & { variant: CopyNumberVariant },
9391
CNVPopulationsTableState
9492
> {
9593
static defaultProps = {
9694
columnLabels: {},
9795
initiallyExpandRows: false,
98-
variant: {}
96+
variant: {},
9997
}
10098

101-
constructor(props: CNVPopulationsTableProps ) {
99+
constructor(props: CNVPopulationsTableProps) {
102100
super(props)
103101

104102
this.state = {
105103
sortBy: 'sf',
106104
sortAscending: false,
107-
expandedPopulations: props.populations.reduce(
105+
expandedPopulations: props.ancestry_groups.reduce(
108106
(acc, pop) => ({ ...acc, [pop.name]: props.initiallyExpandRows }),
109107
{}
110108
),
@@ -157,10 +155,10 @@ export class CNVPopulationsTable extends Component<
157155
const { expandedPopulations } = this.state
158156
const isExpanded = expandedPopulations[pop.name]
159157
const colSpan = isExpanded ? 1 : 2
160-
const rowSpan = isExpanded ? pop.subpopulations.length + 1 : 1
158+
const rowSpan = isExpanded ? pop.subancestry_groups.length + 1 : 1
161159
return (
162160
<th colSpan={colSpan} rowSpan={rowSpan} scope="row">
163-
{pop.subpopulations.length > 0 ? (
161+
{pop.subancestry_groups.length > 0 ? (
164162
<TogglePopulationButton
165163
// @ts-expect-error TS(2769) FIXME: No overload matches this call.
166164
isExpanded={isExpanded}
@@ -176,12 +174,13 @@ export class CNVPopulationsTable extends Component<
176174
}
177175

178176
render() {
179-
const { columnLabels, populations, variant } = this.props
177+
const { ancestry_groups, variant } = this.props
180178
const { expandedPopulations, sortAscending, sortBy } = this.state
179+
const columnLabels = this.props.columnLabels || {}
181180

182-
const renderedPopulations = populations
181+
const renderedPopulations = ancestry_groups
183182
.map((pop) => {
184-
const transformedSubpopulations = (pop.subpopulations || [])
183+
const transformedSubpopulations = (pop.subancestry_groups || [])
185184
.map((subPop) => ({
186185
id: subPop.id,
187186
name: subPop.name,
@@ -211,7 +210,7 @@ export class CNVPopulationsTable extends Component<
211210
sc: pop.sc,
212211
sn: pop.sn,
213212
sf: calculatePopSF(pop.sc, pop.sn),
214-
subpopulations: transformedSubpopulations,
213+
subancestry_groups: transformedSubpopulations,
215214
}
216215
})
217216
.sort((a, b) => {
@@ -275,7 +274,7 @@ export class CNVPopulationsTable extends Component<
275274
</tr>
276275
</thead>
277276
{renderedPopulations.map((pop, i) => (
278-
<tbody key={(pop as any).id}>
277+
<tbody key={pop.id}>
279278
<tr
280279
className={
281280
i > 0 &&
@@ -291,15 +290,15 @@ export class CNVPopulationsTable extends Component<
291290
<td className="right-align">{pop.sn}</td>
292291
<td className="right-align">{renderPopSF(pop.sf)}</td>
293292
</tr>
294-
{pop.subpopulations &&
293+
{pop.subancestry_groups &&
295294
expandedPopulations[pop.name] &&
296-
pop.subpopulations.map((subPop, j) => (
295+
pop.subancestry_groups.map((subPop, j) => (
297296
<tr
298297
key={`${pop.name}-${subPop.name}`}
299298
className={
300299
j === 0 ||
301300
(isSexSpecificPopulation(subPop) &&
302-
!isSexSpecificPopulation(pop.subpopulations[j - 1]))
301+
!isSexSpecificPopulation(pop.subancestry_groups[j - 1]))
303302
? 'border'
304303
: undefined
305304
}

browser/src/CopyNumberVariantPage/CopyNumberVariantPage.tsx

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,14 @@ import styled from 'styled-components'
44
import { ExternalLink, Page, ListItem } from '@gnomad/ui'
55
import Link from '../Link'
66

7-
import { DatasetId, labelForDataset } from '@gnomad/dataset-metadata/metadata'
7+
import { DatasetId, labelForDataset, ReferenceGenome } from '@gnomad/dataset-metadata/metadata'
88
import DocumentTitle from '../DocumentTitle'
99
import GnomadPageHeading from '../GnomadPageHeading'
1010
import Query from '../Query'
1111
import { variantFeedbackUrl } from '../variantFeedback'
1212
import CopyNumberVariantAttributeList from './CopyNumberVariantAttributeList'
1313
import CopyNumberVariantPopulationsTable from './CopyNumberVariantPopulationsTable'
1414
import CNVReferenceList from './CNVReferenceList'
15-
import { ReferenceGenome } from '@gnomad/dataset-metadata/metadata'
1615

1716
const Wrapper = styled.div`
1817
display: flex;
@@ -28,6 +27,13 @@ const ResponsiveSection = styled.section`
2827
}
2928
`
3029

30+
export type CopyNumberVariantPopulation = {
31+
id: string
32+
sc: number
33+
sn: number
34+
sf: number
35+
}
36+
3137
export type CopyNumberVariant = {
3238
alts: string[] | null
3339
sc: number
@@ -38,14 +44,7 @@ export type CopyNumberVariant = {
3844
filters: string[] | null
3945
genes: string[]
4046
length: number | null
41-
populations:
42-
| {
43-
id: string
44-
sc: number
45-
sn: number
46-
sf: number
47-
}[]
48-
| null
47+
ancestry_groups: CopyNumberVariantPopulation[] | null
4948
pos: number
5049
qual: number | null
5150
reference_genome: ReferenceGenome
@@ -133,7 +132,7 @@ const ConnectedCopyNumberVariantPage = ({
133132
filters
134133
genes
135134
length
136-
populations {
135+
ancestry_groups {
137136
id
138137
sc
139138
sn

0 commit comments

Comments
 (0)