diff --git a/browser/src/VariantPage/GnomadPopulationsTable.spec.tsx b/browser/src/VariantPage/GnomadPopulationsTable.spec.tsx index 5aec6cb7b..6debaa972 100644 --- a/browser/src/VariantPage/GnomadPopulationsTable.spec.tsx +++ b/browser/src/VariantPage/GnomadPopulationsTable.spec.tsx @@ -3,7 +3,7 @@ import { describe, expect, test } from '@jest/globals' import renderer from 'react-test-renderer' import { GnomadPopulationsTable } from './GnomadPopulationsTable' -import { allDatasetIds } from '@gnomad/dataset-metadata/metadata' +import { allDatasetIds, getTopLevelDataset } from '@gnomad/dataset-metadata/metadata' import { createAncestryGroupObjects } from '../__factories__/Variant' describe('GnomadPopulationsTable', () => { @@ -44,16 +44,19 @@ describe('GnomadPopulationsTable', () => { expect(tree).toMatchSnapshot() }) test('has no unexpected changes when missing genetic ancestry groups are filled in', () => { - const jointGeneticAncestryGroupObjects = createAncestryGroupObjects( - [ - { id: 'afr', value: 1 }, - { id: 'remaining', value: 2 }, - { id: 'eur', value: 4 }, - { id: 'XX', value: 8 }, - { id: 'XY', value: 16 }, - ], - true - ) + const jointGeneticAncestryGroupObjects = + getTopLevelDataset(dataset) === 'v4' + ? createAncestryGroupObjects( + [ + { id: 'afr', value: 1 }, + { id: 'remaining', value: 2 }, + { id: 'eur', value: 4 }, + { id: 'XX', value: 8 }, + { id: 'XY', value: 16 }, + ], + true + ) + : null const tree = renderer.create( (mergedAncestry.id as string) !== '') const mergedPopulationsWithNames = addPopulationNames(mergedPopulations) @@ -159,6 +153,32 @@ export class GnomadPopulationsTable extends Component< }) } + // If there's Joint and Exome data, allow users to toggle off Genome data to see just the Exome contribution to the Joint data, but do not allow toggling off of Exome data + const hasOnlyJointAndExomeData = + jointPopulations && exomePopulations.length !== 0 && genomePopulations.length === 0 + + // If there's no Exome or Joint data, don't allow users to toggle on the (non existent) Exome data + const doesNotHaveJointOrExomeData = !jointPopulations && exomePopulations.length === 0 + + // If there's both Exome and Genome Data, only allow users to toggle off one of the data sources at a time + const preventUnselectingExomeDataIfGenomeUnselected = includeExomes && !includeGenomes + + const disableExomesCheckbox = + hasOnlyJointAndExomeData || + doesNotHaveJointOrExomeData || + preventUnselectingExomeDataIfGenomeUnselected + + // Invert the logic above for Genomes + const hasOnlyJointAndGenomeData = + jointPopulations && exomePopulations.length === 0 && genomePopulations.length !== 0 + const doesNotHaveJointOrGenomeData = !jointPopulations && genomePopulations.length === 0 + const preventUnselectingGenomeDataIfExomeUnselected = !includeExomes && includeGenomes + + const disableGenomesCheckbox = + hasOnlyJointAndGenomeData || + doesNotHaveJointOrGenomeData || + preventUnselectingGenomeDataIfExomeUnselected + return ( <> { @@ -186,7 +206,7 @@ export class GnomadPopulationsTable extends Component< /> { diff --git a/browser/src/VariantPage/__snapshots__/GnomadPopulationsTable.spec.tsx.snap b/browser/src/VariantPage/__snapshots__/GnomadPopulationsTable.spec.tsx.snap index 83ea554da..d668b7571 100644 --- a/browser/src/VariantPage/__snapshots__/GnomadPopulationsTable.spec.tsx.snap +++ b/browser/src/VariantPage/__snapshots__/GnomadPopulationsTable.spec.tsx.snap @@ -684,22 +684,28 @@ exports[`GnomadPopulationsTable with a dataset of exac has no unexpected changes rowSpan={1} scope="row" > - African/African American + - 1 + 0 - 10 + 0 - 3 + 0 - 0.1000 + - @@ -893,98 +899,28 @@ exports[`GnomadPopulationsTable with a dataset of exac has no unexpected changes rowSpan={1} scope="row" > - Remaining - - - 2 - - - 20 - - - 4 - - - 0.1000 - - - - - - - XX - - - 8 - - - 80 - - - 10 - - - 0.1000 - - - - - - - XY + - 16 + 0 - 160 + 0 - 18 + 0 - 0.1000 + - @@ -1010,17 +946,17 @@ exports[`GnomadPopulationsTable with a dataset of exac has no unexpected changes - 3 + 0 - 30 + 0 - 7 + 0 - 0.1000 + 0.000 @@ -2371,9 +2307,9 @@ exports[`GnomadPopulationsTable with a dataset of gnomad_cnv_r4 has no unexpecte htmlFor="includeExomePopulations" > - African/African American + - 1 + 0 - 10 + 0 - 3 + 0 - 0.1000 + - @@ -3420,82 +3362,6 @@ exports[`GnomadPopulationsTable with a dataset of gnomad_r2_1 has no unexpected - - - - XX - - - 8 - - - 80 - - - 10 - - - 0.1000 - - - - - - - XY - - - 16 - - - 160 - - - 18 - - - 0.1000 - - - - 1 + 0 - 10 + 0 - 3 + 0 - 0.1000 + 0.000 @@ -4348,22 +4214,28 @@ exports[`GnomadPopulationsTable with a dataset of gnomad_r2_1_controls has no un rowSpan={1} scope="row" > - African/African American + - 1 + 0 - 10 + 0 - 3 + 0 - 0.1000 + - @@ -4591,33 +4463,30 @@ exports[`GnomadPopulationsTable with a dataset of gnomad_r2_1_controls has no un - + - XX + Total - 8 + 0 - 80 + 0 - 10 + 0 - 0.1000 - - - - - - - XY - - - 16 - - - 160 - - - 18 - - - 0.1000 - - - - - - - Total - - - 1 - - - 10 - - - 3 - - - 0.1000 + 0.000 @@ -5519,22 +5315,28 @@ exports[`GnomadPopulationsTable with a dataset of gnomad_r2_1_non_cancer has no rowSpan={1} scope="row" > - African/African American + - 1 + 0 - 10 + 0 - 3 + 0 - 0.1000 + - @@ -5762,82 +5564,6 @@ exports[`GnomadPopulationsTable with a dataset of gnomad_r2_1_non_cancer has no - - - - XX - - - 8 - - - 80 - - - 10 - - - 0.1000 - - - - - - - XY - - - 16 - - - 160 - - - 18 - - - 0.1000 - - - - 1 + 0 - 10 + 0 - 3 + 0 - 0.1000 + 0.000 @@ -6690,22 +6416,28 @@ exports[`GnomadPopulationsTable with a dataset of gnomad_r2_1_non_neuro has no u rowSpan={1} scope="row" > - African/African American + - 1 + 0 - 10 + 0 - 3 + 0 - 0.1000 + - @@ -6933,82 +6665,6 @@ exports[`GnomadPopulationsTable with a dataset of gnomad_r2_1_non_neuro has no u - - - - XX - - - 8 - - - 80 - - - 10 - - - 0.1000 - - - - - - - XY - - - 16 - - - 160 - - - 18 - - - 0.1000 - - - - 1 + 0 - 10 + 0 - 3 + 0 - 0.1000 + 0.000 @@ -7765,93 +7421,7 @@ exports[`GnomadPopulationsTable with a dataset of gnomad_r2_1_non_topmed has no - - - - - - - - 0 - - - 0 - - - 0 - - - - - - - - - - - - - - 0 - - - 0 - - - 0 - - - - - - - + @@ -7861,22 +7431,28 @@ exports[`GnomadPopulationsTable with a dataset of gnomad_r2_1_non_topmed has no rowSpan={1} scope="row" > - African/African American + - 1 + 0 - 10 + 0 - 3 + 0 - 0.1000 + - @@ -7903,7 +7479,7 @@ exports[`GnomadPopulationsTable with a dataset of gnomad_r2_1_non_topmed has no onClick={[Function]} type="button" > - Ashkenazi Jewish + European (non-Finnish) - East Asian + African/African American - European (Finnish) + Ashkenazi Jewish - South Asian + East Asian - Remaining individuals + European (Finnish) - + - XX + - 8 + 0 - 80 + 0 - 10 + 0 - 0.1000 + - @@ -8152,22 +7732,28 @@ exports[`GnomadPopulationsTable with a dataset of gnomad_r2_1_non_topmed has no rowSpan={1} scope="row" > - XY + - 16 + 0 - 160 + 0 - 18 + 0 - 0.1000 + - @@ -8193,17 +7779,17 @@ exports[`GnomadPopulationsTable with a dataset of gnomad_r2_1_non_topmed has no - 1 + 0 - 10 + 0 - 3 + 0 - 0.1000 + 0.000 @@ -9287,22 +8873,28 @@ exports[`GnomadPopulationsTable with a dataset of gnomad_r3 has no unexpected ch rowSpan={1} scope="row" > - African/African American + - 1 + 0 - 10 + 0 - 3 + 0 - 0.1000 + - @@ -9444,82 +9036,6 @@ exports[`GnomadPopulationsTable with a dataset of gnomad_r3 has no unexpected ch - - - - XX - - - 8 - - - 80 - - - 10 - - - 0.1000 - - - - - - - XY - - - 16 - - - 160 - - - 18 - - - 0.1000 - - - - 1 + 0 - 10 + 0 - 3 + 0 - 0.1000 + 0.000 @@ -10417,93 +9933,7 @@ exports[`GnomadPopulationsTable with a dataset of gnomad_r3_controls_and_biobank onClick={[Function]} type="button" > - European (Finnish) - - - - 0 - - - 0 - - - 0 - - - - - - - - - - - - - - 0 - - - 0 - - - 0 - - - - - - - - - - - - East Asian + Admixed American - Middle Eastern + Amish - African/African American + - 1 + 0 - 10 + 0 - 3 + 0 - 0.1000 + - @@ -10669,7 +10105,7 @@ exports[`GnomadPopulationsTable with a dataset of gnomad_r3_controls_and_biobank onClick={[Function]} type="button" > - South Asian + Middle Eastern - Ashkenazi Jewish + African/African American - Remaining individuals + South Asian - + - XX + - 8 + 0 - 80 + 0 - 10 + 0 - 0.1000 + - @@ -10832,22 +10272,28 @@ exports[`GnomadPopulationsTable with a dataset of gnomad_r3_controls_and_biobank rowSpan={1} scope="row" > - XY + - 16 + 0 - 160 + 0 - 18 + 0 - 0.1000 + - @@ -10873,17 +10319,17 @@ exports[`GnomadPopulationsTable with a dataset of gnomad_r3_controls_and_biobank - 1 + 0 - 10 + 0 - 3 + 0 - 0.1000 + 0.000 @@ -11967,22 +11413,28 @@ exports[`GnomadPopulationsTable with a dataset of gnomad_r3_non_cancer has no un rowSpan={1} scope="row" > - African/African American + - 1 + 0 - 10 + 0 - 3 + 0 - 0.1000 + - @@ -12124,82 +11576,6 @@ exports[`GnomadPopulationsTable with a dataset of gnomad_r3_non_cancer has no un - - - - XX - - - 8 - - - 80 - - - 10 - - - 0.1000 - - - - - - - XY - - - 16 - - - 160 - - - 18 - - - 0.1000 - - - - 1 + 0 - 10 + 0 - 3 + 0 - 0.1000 + 0.000 @@ -13183,93 +12559,7 @@ exports[`GnomadPopulationsTable with a dataset of gnomad_r3_non_neuro has no une onClick={[Function]} type="button" > - Amish - - - - 0 - - - 0 - - - 0 - - - - - - - - - - - - - - 0 - - - 0 - - - 0 - - - - - - - - - - - - African/African American + - 1 + 0 - 10 + 0 - 3 + 0 - 0.1000 + - @@ -13349,7 +12645,7 @@ exports[`GnomadPopulationsTable with a dataset of gnomad_r3_non_neuro has no une onClick={[Function]} type="button" > - South Asian + Middle Eastern - Ashkenazi Jewish + African/African American - Remaining individuals + South Asian - + - XX + - 8 + 0 - 80 + 0 - 10 + 0 - 0.1000 + - @@ -13512,22 +12812,28 @@ exports[`GnomadPopulationsTable with a dataset of gnomad_r3_non_neuro has no une rowSpan={1} scope="row" > - XY + - 16 + 0 - 160 + 0 - 18 + 0 - 0.1000 + - @@ -13553,17 +12859,17 @@ exports[`GnomadPopulationsTable with a dataset of gnomad_r3_non_neuro has no une - 1 + 0 - 10 + 0 - 3 + 0 - 0.1000 + 0.000 @@ -14647,22 +13953,28 @@ exports[`GnomadPopulationsTable with a dataset of gnomad_r3_non_topmed has no un rowSpan={1} scope="row" > - African/African American + - 1 + 0 - 10 + 0 - 3 + 0 - 0.1000 + - @@ -14804,82 +14116,6 @@ exports[`GnomadPopulationsTable with a dataset of gnomad_r3_non_topmed has no un - - - - XX - - - 8 - - - 80 - - - 10 - - - 0.1000 - - - - - - - XY - - - 16 - - - 160 - - - 18 - - - 0.1000 - - - - 1 + 0 - 10 + 0 - 3 + 0 - 0.1000 + 0.000 @@ -15987,22 +15223,28 @@ exports[`GnomadPopulationsTable with a dataset of gnomad_r3_non_v2 has no unexpe rowSpan={1} scope="row" > - African/African American + - 1 + 0 - 10 + 0 - 3 + 0 - 0.1000 + - @@ -16140,83 +15382,7 @@ exports[`GnomadPopulationsTable with a dataset of gnomad_r3_non_v2 has no unexpe } } > - - - - - - - - - XX - - - 8 - - - 80 - - - 10 - - - 0.1000 - - - - - - - XY - - - 16 - - - 160 - - - 18 - - - 0.1000 + - @@ -16233,17 +15399,17 @@ exports[`GnomadPopulationsTable with a dataset of gnomad_r3_non_v2 has no unexpe - 1 + 0 - 10 + 0 - 3 + 0 - 0.1000 + 0.000 @@ -17594,9 +16760,9 @@ exports[`GnomadPopulationsTable with a dataset of gnomad_r4 has no unexpected ch htmlFor="includeExomePopulations" > - - - - XX - - - 8 - - - 80 - - - 10 - - - 0.1000 - - - - - - - XY - - - 16 - - - 160 - - - 18 - - - 0.1000 - - - - - - - XX - - - 8 - - - 80 - - - 10 - - - 0.1000 - - - - - - - XY - - - 16 - - - 160 - - - 18 - - - 0.1000 - - - - - - - XX - - - 8 - - - 80 - - - 10 - - - 0.1000 - - - - - - - XY - - - 16 - - - 160 - - - 18 - - - 0.1000 - - -