Skip to content

Commit

Permalink
fix(browser): render XX and XY sums in variant table
Browse files Browse the repository at this point in the history
  • Loading branch information
rileyhgrant committed Jun 26, 2024
1 parent 03738ba commit 863dbf4
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 5 deletions.
20 changes: 17 additions & 3 deletions browser/src/VariantList/mergeExomeAndGenomeData.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@ describe('mergeExomeGenomeAndJointPopulationData', () => {
{ id: 'afr', value: 1 },
{ id: 'remaining', value: 2 },
{ id: 'eur', value: 4 },
{ id: 'XX', value: 8 },
{ id: 'XY', value: 16 },
],
false
)
Expand All @@ -62,6 +64,8 @@ describe('mergeExomeGenomeAndJointPopulationData', () => {
{ ac: 2, ac_hemi: 4, ac_hom: 6, an: 20, id: 'afr' },
{ ac: 4, ac_hemi: 6, ac_hom: 8, an: 40, id: 'remaining' },
{ ac: 8, ac_hemi: 10, ac_hom: 12, an: 80, id: 'eur' },
{ ac: 16, ac_hemi: 18, ac_hom: 20, an: 160, id: 'XX' },
{ ac: 32, ac_hemi: 34, ac_hom: 36, an: 320, id: 'XY' },
]

expect(result).toStrictEqual(expected)
Expand Down Expand Up @@ -250,15 +254,19 @@ describe('mergeExomeGenomeAndJointPopulationData', () => {
{ id: 'eur', value: 1 },
{ id: 'afr', value: 2 },
{ id: 'remaining', value: 4 },
{ id: 'XX', value: 8 },
{ id: 'XY', value: 16 },
],
false
)

const genomeGeneticAncestryGroupObjects = createAncestryGroupObjects(
[
{ id: 'afr', value: 8 },
{ id: 'remaining', value: 16 },
{ id: 'eur', value: 32 },
{ id: 'afr', value: 32 },
{ id: 'remaining', value: 64 },
{ id: 'eur', value: 128 },
{ id: 'XX', value: 256 },
{ id: 'XY', value: 512 },
],
false
)
Expand All @@ -270,6 +278,8 @@ describe('mergeExomeGenomeAndJointPopulationData', () => {
{ ac: 32, hemizygote_count: 33, homozygote_count: 34, an: 320, id: 'remaining' },
{ ac: 64, hemizygote_count: 65, homozygote_count: 66, an: 640, id: 'eur' },
{ ac: 128, hemizygote_count: 129, homozygote_count: 130, an: 1280, id: 'mid' },
{ ac: 256, hemizygote_count: 257, homozygote_count: 258, an: 2560, id: 'XX' },
{ ac: 512, hemizygote_count: 513, homozygote_count: 514, an: 5120, id: 'XY' },
]

const testVariant = variantFactory.build({
Expand All @@ -294,6 +304,8 @@ describe('mergeExomeGenomeAndJointPopulationData', () => {
{ id: 'remaining', value: 32 },
{ id: 'eur', value: 64 },
{ id: 'mid', value: 128 },
{ id: 'XX', value: 256 },
{ id: 'XY', value: 512 },
],
true
)
Expand Down Expand Up @@ -346,6 +358,8 @@ describe('mergeExomeAndGenomeData', () => {
{ id: 'afr', value: 1 },
{ id: 'remaining', value: 2 },
{ id: 'eur', value: 4 },
{ id: 'XX', value: 8 },
{ id: 'XY', value: 16 },
],
false
)
Expand Down
7 changes: 6 additions & 1 deletion browser/src/VariantList/mergeExomeAndGenomeData.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,12 @@ const addMissingAncestries = (
findAncestries(versionAncestry, currentAncestries) || emptyAncestries(versionAncestry)
)

return fullAncestries
const totalXX = currentAncestries.filter((ancestry) => ancestry.id === 'XX')
const totalXY = currentAncestries.filter((ancestry) => ancestry.id === 'XY')

const fullAncestriesWithTotalKaryotypes = fullAncestries.concat(totalXX, totalXY)

return fullAncestriesWithTotalKaryotypes
}

export const mergeExomeGenomeAndJointPopulationData = ({
Expand Down
7 changes: 6 additions & 1 deletion dataset-metadata/gnomadPopulations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,12 @@ export const GNOMAD_POPULATION_NAMES = {

export type PopulationId = keyof typeof GNOMAD_POPULATION_NAMES

export type PopulationIdAndChromosome = PopulationId | `${PopulationId}_XX` | `${PopulationId}_XY`
export type PopulationIdAndChromosome =
| PopulationId
| `${PopulationId}_XX`
| `${PopulationId}_XY`
| 'XX'
| 'XY'

export const populationName = (populationId: string) =>
textOrMissingTextWarning('genetic ancestry group name', GNOMAD_POPULATION_NAMES, populationId)
Expand Down

0 comments on commit 863dbf4

Please sign in to comment.