From 6bca21a440d1ee3dc3390a34e05c8b038a610989 Mon Sep 17 00:00:00 2001 From: Riley Grant Date: Mon, 4 Nov 2024 11:31:37 -0600 Subject: [PATCH] fix(browser): use numeric sort for AF in grp freq table consistently --- browser/src/VariantPage/PopulationsTable.tsx | 22 +- .../GnomadPopulationsTable.spec.tsx.snap | 838 +++++++++--------- 2 files changed, 432 insertions(+), 428 deletions(-) diff --git a/browser/src/VariantPage/PopulationsTable.tsx b/browser/src/VariantPage/PopulationsTable.tsx index ce6fef903..f0355fa63 100644 --- a/browser/src/VariantPage/PopulationsTable.tsx +++ b/browser/src/VariantPage/PopulationsTable.tsx @@ -45,21 +45,25 @@ const SEX_IDENTIFIERS = ['XX', 'XY'] const isSexSpecificPopulation = (pop: any) => SEX_IDENTIFIERS.includes(pop.id) || SEX_IDENTIFIERS.some((id) => pop.id.endsWith(`_${id}`)) -// if the allele number (denominator) is 0, return a non-number -// to signal to users that there is no information to be displayed about -// the frequency, rather than artificially calling it 0 -const calculatePopAF = (ac: number, an: number) => { +// if the allele number (denominator) is 0, return a sentinel value of -1 +// this sorts this grp to the end of the table, and can be used to render +// a special symbol +const calculatePopAF = (ac: number, an: number): number => { if (an === 0) { - return '-' + return -1 } return ac / an } -const renderPopAF = (af: number | string) => { - if (typeof af === 'number') { - return af.toPrecision(4) +// When rendering AFs, the sentinel value of -1 denotes grps with an AN of 0 +// in this case, render a '-' character to communicate to users that +// there is no data to be displayed +const renderPopAF = (af: number) => { + if (af === -1) { + return '-' } - return af + + return af.toPrecision(4) } type OwnPopulationsTableProps = { diff --git a/browser/src/VariantPage/__snapshots__/GnomadPopulationsTable.spec.tsx.snap b/browser/src/VariantPage/__snapshots__/GnomadPopulationsTable.spec.tsx.snap index d668b7571..64e7c406f 100644 --- a/browser/src/VariantPage/__snapshots__/GnomadPopulationsTable.spec.tsx.snap +++ b/browser/src/VariantPage/__snapshots__/GnomadPopulationsTable.spec.tsx.snap @@ -106,28 +106,22 @@ exports[`GnomadPopulationsTable with a dataset of exac has no unexpected changes rowSpan={1} scope="row" > - + African/African American - 0 + 33 - 0 + 330 - 0 + 37 - - + 0.1000 @@ -149,22 +143,22 @@ exports[`GnomadPopulationsTable with a dataset of exac has no unexpected changes rowSpan={1} scope="row" > - African/African American + Remaining - 33 + 66 - 330 + 660 - 37 + 70 - Admixed American + South Asian - East Asian + Admixed American - European (Finnish) + East Asian - European (non-Finnish) + European (Finnish) - Remaining + - 66 + 0 - 660 + 0 - 70 + 0 - 0.1000 + - @@ -1149,28 +1149,22 @@ exports[`GnomadPopulationsTable with a dataset of gnomad_cnv_r4 has no unexpecte rowSpan={1} scope="row" > - + Remaining - 0 + 66 - 0 + 660 - 0 + 70 - - + 0.1000 @@ -1197,7 +1191,7 @@ exports[`GnomadPopulationsTable with a dataset of gnomad_cnv_r4 has no unexpecte onClick={[Function]} type="button" > - Ashkenazi Jewish + Admixed American - East Asian + Ashkenazi Jewish - European (Finnish) + East Asian - Middle Eastern + European (Finnish) - European (non-Finnish) + Middle Eastern - Amish + European (non-Finnish) - South Asian + Amish - Remaining + - 66 + 0 - 660 + 0 - 70 + 0 - 0.1000 + - @@ -1813,28 +1813,22 @@ exports[`GnomadPopulationsTable with a dataset of gnomad_cnv_r4 has no unexpecte rowSpan={1} scope="row" > - + Remaining - 0 + 2 - 0 + 20 - 0 + 4 - - + 0.1000 @@ -1861,7 +1855,7 @@ exports[`GnomadPopulationsTable with a dataset of gnomad_cnv_r4 has no unexpecte onClick={[Function]} type="button" > - Ashkenazi Jewish + Admixed American - East Asian + Ashkenazi Jewish - European (Finnish) + East Asian - Middle Eastern + European (Finnish) - European (non-Finnish) + Middle Eastern - Amish + European (non-Finnish) - South Asian + Amish - Remaining + - 2 + 0 - 20 + 0 - 4 + 0 - 0.1000 + - @@ -2440,28 +2440,22 @@ exports[`GnomadPopulationsTable with a dataset of gnomad_r2_1 has no unexpected rowSpan={1} scope="row" > - + African/African American - 0 + 33 - 0 + 330 - 0 + 37 - - + 0.1000 @@ -2488,7 +2482,7 @@ exports[`GnomadPopulationsTable with a dataset of gnomad_r2_1 has no unexpected onClick={[Function]} type="button" > - European (non-Finnish) + Admixed American - African/African American + - 33 + 0 - 330 + 0 - 37 + 0 - 0.1000 + - @@ -3541,28 +3541,22 @@ exports[`GnomadPopulationsTable with a dataset of gnomad_r2_1_controls has no un rowSpan={1} scope="row" > - + African/African American - 0 + 33 - 0 + 330 - 0 + 37 - - + 0.1000 @@ -3589,7 +3583,7 @@ exports[`GnomadPopulationsTable with a dataset of gnomad_r2_1_controls has no un onClick={[Function]} type="button" > - European (non-Finnish) + Admixed American - African/African American + - 33 + 0 - 330 + 0 - 37 + 0 - 0.1000 + - @@ -4642,28 +4642,22 @@ exports[`GnomadPopulationsTable with a dataset of gnomad_r2_1_non_cancer has no rowSpan={1} scope="row" > - + African/African American - 0 + 33 - 0 + 330 - 0 + 37 - - + 0.1000 @@ -4690,7 +4684,7 @@ exports[`GnomadPopulationsTable with a dataset of gnomad_r2_1_non_cancer has no onClick={[Function]} type="button" > - European (non-Finnish) + Admixed American - African/African American + - 33 + 0 - 330 + 0 - 37 + 0 - 0.1000 + - @@ -5743,28 +5743,22 @@ exports[`GnomadPopulationsTable with a dataset of gnomad_r2_1_non_neuro has no u rowSpan={1} scope="row" > - + African/African American - 0 + 33 - 0 + 330 - 0 + 37 - - + 0.1000 @@ -5791,7 +5785,7 @@ exports[`GnomadPopulationsTable with a dataset of gnomad_r2_1_non_neuro has no u onClick={[Function]} type="button" > - European (non-Finnish) + Admixed American - African/African American + - 33 + 0 - 330 + 0 - 37 + 0 - 0.1000 + - @@ -6844,28 +6844,22 @@ exports[`GnomadPopulationsTable with a dataset of gnomad_r2_1_non_topmed has no rowSpan={1} scope="row" > - + African/African American - 0 + 33 - 0 + 330 - 0 + 37 - - + 0.1000 @@ -6892,7 +6886,7 @@ exports[`GnomadPopulationsTable with a dataset of gnomad_r2_1_non_topmed has no onClick={[Function]} type="button" > - European (non-Finnish) + Admixed American - African/African American + - 33 + 0 - 330 + 0 - 37 + 0 - 0.1000 + - @@ -7945,28 +7945,22 @@ exports[`GnomadPopulationsTable with a dataset of gnomad_r3 has no unexpected ch rowSpan={1} scope="row" > - + African/African American - 0 + 33 - 0 + 330 - 0 + 37 - - + 0.1000 @@ -7993,7 +7987,7 @@ exports[`GnomadPopulationsTable with a dataset of gnomad_r3 has no unexpected ch onClick={[Function]} type="button" > - European (Finnish) + European (non-Finnish) - Admixed American + European (Finnish) - Amish + Admixed American - East Asian + Amish - Middle Eastern + East Asian - African/African American + - 33 + 0 - 330 + 0 - 37 + 0 - 0.1000 + - @@ -9215,28 +9215,22 @@ exports[`GnomadPopulationsTable with a dataset of gnomad_r3_controls_and_biobank rowSpan={1} scope="row" > - + African/African American - 0 + 33 - 0 + 330 - 0 + 37 - - + 0.1000 @@ -9263,7 +9257,7 @@ exports[`GnomadPopulationsTable with a dataset of gnomad_r3_controls_and_biobank onClick={[Function]} type="button" > - European (Finnish) + European (non-Finnish) - Admixed American + European (Finnish) - Amish + Admixed American - East Asian + Amish - Middle Eastern + East Asian - African/African American + - 33 + 0 - 330 + 0 - 37 + 0 - 0.1000 + - @@ -10485,28 +10485,22 @@ exports[`GnomadPopulationsTable with a dataset of gnomad_r3_non_cancer has no un rowSpan={1} scope="row" > - + African/African American - 0 + 33 - 0 + 330 - 0 + 37 - - + 0.1000 @@ -10533,7 +10527,7 @@ exports[`GnomadPopulationsTable with a dataset of gnomad_r3_non_cancer has no un onClick={[Function]} type="button" > - European (Finnish) + European (non-Finnish) - Admixed American + European (Finnish) - Amish + Admixed American - East Asian + Amish - Middle Eastern + East Asian - African/African American + - 33 + 0 - 330 + 0 - 37 + 0 - 0.1000 + - @@ -11755,28 +11755,22 @@ exports[`GnomadPopulationsTable with a dataset of gnomad_r3_non_neuro has no une rowSpan={1} scope="row" > - + African/African American - 0 + 33 - 0 + 330 - 0 + 37 - - + 0.1000 @@ -11803,7 +11797,7 @@ exports[`GnomadPopulationsTable with a dataset of gnomad_r3_non_neuro has no une onClick={[Function]} type="button" > - European (Finnish) + European (non-Finnish) - Admixed American + European (Finnish) - Amish + Admixed American - East Asian + Amish - Middle Eastern + East Asian - African/African American + - 33 + 0 - 330 + 0 - 37 + 0 - 0.1000 + - @@ -13025,28 +13025,22 @@ exports[`GnomadPopulationsTable with a dataset of gnomad_r3_non_topmed has no un rowSpan={1} scope="row" > - + African/African American - 0 + 33 - 0 + 330 - 0 + 37 - - + 0.1000 @@ -13073,7 +13067,7 @@ exports[`GnomadPopulationsTable with a dataset of gnomad_r3_non_topmed has no un onClick={[Function]} type="button" > - European (Finnish) + European (non-Finnish) - Admixed American + European (Finnish) - Amish + Admixed American - East Asian + Amish - Middle Eastern + East Asian - African/African American + - 33 + 0 - 330 + 0 - 37 + 0 - 0.1000 + - @@ -14295,28 +14295,22 @@ exports[`GnomadPopulationsTable with a dataset of gnomad_r3_non_v2 has no unexpe rowSpan={1} scope="row" > - + African/African American - 0 + 33 - 0 + 330 - 0 + 37 - - + 0.1000 @@ -14343,7 +14337,7 @@ exports[`GnomadPopulationsTable with a dataset of gnomad_r3_non_v2 has no unexpe onClick={[Function]} type="button" > - European (Finnish) + European (non-Finnish) - Admixed American + European (Finnish) - Amish + Admixed American - East Asian + Amish - Middle Eastern + East Asian - African/African American + - 33 + 0 - 330 + 0 - 37 + 0 - 0.1000 + - @@ -15602,28 +15602,22 @@ exports[`GnomadPopulationsTable with a dataset of gnomad_r4 has no unexpected ch rowSpan={1} scope="row" > - + Remaining - 0 + 66 - 0 + 660 - 0 + 70 - - + 0.1000 @@ -15650,7 +15644,7 @@ exports[`GnomadPopulationsTable with a dataset of gnomad_r4 has no unexpected ch onClick={[Function]} type="button" > - Ashkenazi Jewish + Admixed American - East Asian + Ashkenazi Jewish - European (Finnish) + East Asian - Middle Eastern + European (Finnish) - European (non-Finnish) + Middle Eastern - Amish + European (non-Finnish) - South Asian + Amish - Remaining + - 66 + 0 - 660 + 0 - 70 + 0 - 0.1000 + - @@ -16266,28 +16266,22 @@ exports[`GnomadPopulationsTable with a dataset of gnomad_r4 has no unexpected ch rowSpan={1} scope="row" > - + Remaining - 0 + 2 - 0 + 20 - 0 + 4 - - + 0.1000 @@ -16314,7 +16308,7 @@ exports[`GnomadPopulationsTable with a dataset of gnomad_r4 has no unexpected ch onClick={[Function]} type="button" > - Ashkenazi Jewish + Admixed American - East Asian + Ashkenazi Jewish - European (Finnish) + East Asian - Middle Eastern + European (Finnish) - European (non-Finnish) + Middle Eastern - Amish + European (non-Finnish) - South Asian + Amish - Remaining + - 2 + 0 - 20 + 0 - 4 + 0 - 0.1000 + - @@ -16930,28 +16930,22 @@ exports[`GnomadPopulationsTable with a dataset of gnomad_r4_non_ukb has no unexp rowSpan={1} scope="row" > - + Remaining - 0 + 66 - 0 + 660 - 0 + 70 - - + 0.1000 @@ -16978,7 +16972,7 @@ exports[`GnomadPopulationsTable with a dataset of gnomad_r4_non_ukb has no unexp onClick={[Function]} type="button" > - Ashkenazi Jewish + Admixed American - East Asian + Ashkenazi Jewish - European (Finnish) + East Asian - Middle Eastern + European (Finnish) - European (non-Finnish) + Middle Eastern - Amish + European (non-Finnish) - South Asian + Amish - Remaining + - 66 + 0 - 660 + 0 - 70 + 0 - 0.1000 + - @@ -17594,28 +17594,22 @@ exports[`GnomadPopulationsTable with a dataset of gnomad_r4_non_ukb has no unexp rowSpan={1} scope="row" > - + Remaining - 0 + 2 - 0 + 20 - 0 + 4 - - + 0.1000 @@ -17642,7 +17636,7 @@ exports[`GnomadPopulationsTable with a dataset of gnomad_r4_non_ukb has no unexp onClick={[Function]} type="button" > - Ashkenazi Jewish + Admixed American - East Asian + Ashkenazi Jewish - European (Finnish) + East Asian - Middle Eastern + European (Finnish) - European (non-Finnish) + Middle Eastern - Amish + European (non-Finnish) - South Asian + Amish - Remaining + - 2 + 0 - 20 + 0 - 4 + 0 - 0.1000 + - @@ -19500,28 +19500,22 @@ exports[`GnomadPopulationsTable with a dataset of gnomad_sv_r4 has no unexpected rowSpan={1} scope="row" > - + Remaining - 0 + 66 - 0 + 660 - 0 + 70 - - + 0.1000 @@ -19548,7 +19542,7 @@ exports[`GnomadPopulationsTable with a dataset of gnomad_sv_r4 has no unexpected onClick={[Function]} type="button" > - Ashkenazi Jewish + Admixed American - East Asian + Ashkenazi Jewish - European (Finnish) + East Asian - Middle Eastern + European (Finnish) - European (non-Finnish) + Middle Eastern - Amish + European (non-Finnish) - South Asian + Amish - Remaining + - 66 + 0 - 660 + 0 - 70 + 0 - 0.1000 + - @@ -20164,28 +20164,22 @@ exports[`GnomadPopulationsTable with a dataset of gnomad_sv_r4 has no unexpected rowSpan={1} scope="row" > - + Remaining - 0 + 2 - 0 + 20 - 0 + 4 - - + 0.1000 @@ -20212,7 +20206,7 @@ exports[`GnomadPopulationsTable with a dataset of gnomad_sv_r4 has no unexpected onClick={[Function]} type="button" > - Ashkenazi Jewish + Admixed American - East Asian + Ashkenazi Jewish - European (Finnish) + East Asian - Middle Eastern + European (Finnish) - European (non-Finnish) + Middle Eastern - Amish + European (non-Finnish) - South Asian + Amish - Remaining + - 2 + 0 - 20 + 0 - 4 + 0 - 0.1000 + -