Skip to content

Commit

Permalink
[Platform] Numeric formatting on new pages (#597)
Browse files Browse the repository at this point in the history
  • Loading branch information
gjmcn authored Dec 6, 2024
1 parent cf81a33 commit 3dd8f9d
Show file tree
Hide file tree
Showing 9 changed files with 86 additions and 25 deletions.
18 changes: 14 additions & 4 deletions packages/sections/src/credibleSet/GWASColoc/Body.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ const columns = [
{
id: "pValue",
label: "P-Value",
numeric: true,
comparator: ({ otherStudyLocus: a }, { otherStudyLocus: b }) =>
mantissaExponentComparator(
a?.pValueMantissa,
Expand All @@ -97,7 +98,7 @@ const columns = [
renderCell: ({ otherStudyLocus }) => {
const { pValueMantissa, pValueExponent } = otherStudyLocus ?? {};
if (typeof pValueMantissa !== "number" || typeof pValueExponent !== "number") return naLabel;
return <ScientificNotation number={[pValueMantissa, pValueExponent]} />;
return <ScientificNotation number={[pValueMantissa, pValueExponent]} dp={2} />;
},
exportValue: ({ otherStudyLocus }) => {
const { pValueMantissa, pValueExponent } = otherStudyLocus ?? {};
Expand All @@ -108,8 +109,14 @@ const columns = [
{
id: "numberColocalisingVariants",
label: "Colocalising Variants (n)",
numeric: true,
filterValue: false,
comparator: (a, b) => a?.numberColocalisingVariants - b?.numberColocalisingVariants,
renderCell: ({ numberColocalisingVariants }) => {
return typeof numberColocalisingVariants === "number"
? numberColocalisingVariants.toLocaleString()
: naLabel;
},
sortable: true,
},
{
Expand Down Expand Up @@ -149,6 +156,7 @@ const columns = [
{
id: "h3",
label: "H3",
numeric: true,
tooltip: (
<>
Posterior probability that the signals <b>do not</b> colocalise
Expand All @@ -159,30 +167,32 @@ const columns = [
sortable: true,
renderCell: ({ h3 }) => {
if (typeof h3 !== "number") return naLabel;
return h3.toPrecision(3);
return h3.toFixed(3);
},
},
{
id: "h4",
label: "H4",
numeric: true,
tooltip: "Posterior probability that the signals colocalise",
filterValue: false,
comparator: (a, b) => a?.h4 - b?.h4,
sortable: true,
renderCell: ({ h4 }) => {
if (typeof h4 !== "number") return naLabel;
return h4.toPrecision(3);
return h4.toFixed(3);
},
},
{
id: "clpp",
label: "CLPP",
numeric: true,
filterValue: false,
comparator: (a, b) => a?.clpp - b?.clpp,
sortable: true,
renderCell: ({ clpp }) => {
if (typeof clpp !== "number") return naLabel;
return clpp.toPrecision(3);
return clpp.toFixed(3);
},
},
];
Expand Down
18 changes: 14 additions & 4 deletions packages/sections/src/credibleSet/MolQTLColoc/Body.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@ const columns = [
{
id: "pValue",
label: "P-Value",
numeric: true,
comparator: ({ otherStudyLocus: a }, { otherStudyLocus: b }) =>
mantissaExponentComparator(
a?.pValueMantissa,
Expand All @@ -115,7 +116,7 @@ const columns = [
renderCell: ({ otherStudyLocus }) => {
const { pValueMantissa, pValueExponent } = otherStudyLocus ?? {};
if (typeof pValueMantissa !== "number" || typeof pValueExponent !== "number") return naLabel;
return <ScientificNotation number={[pValueMantissa, pValueExponent]} />;
return <ScientificNotation number={[pValueMantissa, pValueExponent]} dp={2} />;
},
exportValue: ({ otherStudyLocus }) => {
const { pValueMantissa, pValueExponent } = otherStudyLocus ?? {};
Expand All @@ -127,8 +128,14 @@ const columns = [
id: "numberColocalisingVariants",
label: "Colocalising Variants (n)",
filterValue: false,
numeric: true,
comparator: (a, b) => a?.numberColocalisingVariants - b?.numberColocalisingVariants,
sortable: true,
renderCell: ({ numberColocalisingVariants }) => {
return typeof numberColocalisingVariants === "number"
? numberColocalisingVariants.toLocaleString()
: naLabel;
},
},
{
id: "colocalisationMethod",
Expand Down Expand Up @@ -172,34 +179,37 @@ const columns = [
</>
),
filterValue: false,
numeric: true,
comparator: (a, b) => a?.h3 - b?.h3,
sortable: true,
renderCell: ({ h3 }) => {
if (typeof h3 !== "number") return naLabel;
return h3.toPrecision(3);
return h3.toFixed(3);
},
},
{
id: "h4",
label: "H4",
tooltip: "Posterior probability that the signals colocalise",
filterValue: false,
numeric: true,
comparator: (a, b) => a?.h4 - b?.h4,
sortable: true,
renderCell: ({ h4 }) => {
if (typeof h4 !== "number") return naLabel;
return h4.toPrecision(3);
return h4.toFixed(3);
},
},
{
id: "clpp",
label: "CLPP",
filterValue: false,
numeric: true,
comparator: (a, b) => a?.clpp - b?.clpp,
sortable: true,
renderCell: ({ clpp }) => {
if (typeof clpp !== "number") return naLabel;
return clpp.toPrecision(3);
return clpp.toFixed(3);
},
},
];
Expand Down
14 changes: 10 additions & 4 deletions packages/sections/src/credibleSet/Variants/Body.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ function getColumns({ leadVariantId, leadReferenceAllele, leadAlternateAllele }:
{
id: "pValue",
label: "P-value",
numeric: true,
comparator: (a, b) =>
mantissaExponentComparator(
a?.pValueMantissa,
Expand All @@ -74,7 +75,7 @@ function getColumns({ leadVariantId, leadReferenceAllele, leadAlternateAllele }:
renderCell: ({ pValueMantissa, pValueExponent }) => {
if (typeof pValueMantissa !== "number" || typeof pValueExponent !== "number")
return naLabel;
return <ScientificNotation number={[pValueMantissa, pValueExponent]} />;
return <ScientificNotation number={[pValueMantissa, pValueExponent]} dp={2} />;
},
exportValue: ({ pValueMantissa, pValueExponent }) => {
if (typeof pValueMantissa !== "number" || typeof pValueExponent !== "number") return null;
Expand All @@ -84,29 +85,32 @@ function getColumns({ leadVariantId, leadReferenceAllele, leadAlternateAllele }:
{
id: "beta",
label: "Beta",
numeric: true,
filterValue: false,
sortable: true,
tooltip: "Beta with respect to the ALT allele",
renderCell: ({ beta }) => {
if (typeof beta !== "number") return naLabel;
return beta.toPrecision(3);
return beta.toFixed(3);
},
},
{
id: "standardError",
label: "Standard error",
numeric: true,
filterValue: false,
tooltip:
"Standard Error: Estimate of the standard deviation of the sampling distribution of the beta",
renderCell: ({ standardError }) => {
if (typeof standardError !== "number") return naLabel;
return standardError.toPrecision(3);
return standardError.toFixed(3);
},
},
{
id: "r2Overall",
label: "LD (r²)",
filterValue: false,
numeric: true,
tooltip: (
<>
Linkage disequilibrium with the lead variant (
Expand All @@ -128,17 +132,19 @@ function getColumns({ leadVariantId, leadReferenceAllele, leadAlternateAllele }:
id: "posteriorProbability",
label: "Posterior Probability",
filterValue: false,
numeric: true,
tooltip: "Posterior inclusion probability that this variant is causal within the fine-mapped credible set",
comparator: (rowA, rowB) => rowA?.posteriorProbability - rowB?.posteriorProbability,
sortable: true,
renderCell: ({ posteriorProbability }) => {
if (typeof posteriorProbability !== "number") return naLabel;
return posteriorProbability.toPrecision(3);
return posteriorProbability.toFixed(3);
},
},
{
id: "logBF",
label: "log(BF)",
numeric: true,
tooltip: "Natural logarithm of the Bayes Factor indicating relative likelihood of the variant being causal",
filterValue: false,
sortable: true,
Expand Down
13 changes: 10 additions & 3 deletions packages/sections/src/study/GWASCredibleSets/Body.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ const columns = [
{
id: "pValue",
label: "P-value",
numeric: true,
comparator: (a, b) =>
mantissaExponentComparator(
a?.pValueMantissa,
Expand All @@ -62,7 +63,7 @@ const columns = [
filterValue: false,
renderCell: ({ pValueMantissa, pValueExponent }) => {
if (typeof pValueMantissa !== "number" || typeof pValueExponent !== "number") return naLabel;
return <ScientificNotation number={[pValueMantissa, pValueExponent]} />;
return <ScientificNotation number={[pValueMantissa, pValueExponent]} dp={2} />;
},
exportValue: ({ pValueMantissa, pValueExponent }) => {
if (typeof pValueMantissa !== "number" || typeof pValueExponent !== "number") return null;
Expand All @@ -73,11 +74,12 @@ const columns = [
id: "beta",
label: "Beta",
filterValue: false,
numeric: true,
sortable: true,
tooltip: "Beta with respect to the ALT allele",
renderCell: ({ beta }) => {
if (typeof beta !== "number") return naLabel;
return beta.toPrecision(3);
return beta.toFixed(3);
},
},
{
Expand Down Expand Up @@ -138,8 +140,13 @@ const columns = [
label: "Credible set size",
comparator: (a, b) => a.locus?.count - b.locus?.count,
sortable: true,
numeric: true,
filterValue: false,
renderCell: ({ locus }) => locus?.count ?? naLabel,
renderCell: ({ locus }) => {
return typeof locus?.count === "number"
? locus.count.toLocaleString()
: naLabel;
},
exportValue: ({ locus }) => locus?.count,
},
];
Expand Down
11 changes: 9 additions & 2 deletions packages/sections/src/study/QTLCredibleSets/Body.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ const columns = [
{
id: "pValue",
label: "P-value",
numeric: true,
comparator: (a, b) =>
mantissaExponentComparator(
a?.pValueMantissa,
Expand All @@ -58,7 +59,7 @@ const columns = [
filterValue: false,
renderCell: ({ pValueMantissa, pValueExponent }) => {
if (typeof pValueMantissa !== "number" || typeof pValueExponent !== "number") return naLabel;
return <ScientificNotation number={[pValueMantissa, pValueExponent]} />;
return <ScientificNotation number={[pValueMantissa, pValueExponent]} dp={2} />;
},
exportValue: ({ pValueMantissa, pValueExponent }) => {
if (typeof pValueMantissa !== "number" || typeof pValueExponent !== "number") return null;
Expand All @@ -68,6 +69,7 @@ const columns = [
{
id: "beta",
label: "Beta",
numeric: true,
sortable: true,
filterValue: false,
tooltip: "Beta with respect to the ALT allele",
Expand All @@ -85,8 +87,13 @@ const columns = [
label: "Credible set size",
comparator: (a, b) => a.locus?.count - b.locus?.count,
sortable: true,
numeric: true,
filterValue: false,
renderCell: ({ locus }) => locus?.count ?? naLabel,
renderCell: ({ locus }) => {
return typeof locus?.count === "number"
? locus.count.toLocaleString()
: naLabel;
},
exportValue: ({ locus }) => locus?.count,
},
];
Expand Down
4 changes: 4 additions & 0 deletions packages/sections/src/study/SharedTraitStudies/Body.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,10 @@ function getColumns(diseaseIds: string[]) {
{
id: "nSamples",
label: "Sample size",
numeric: true,
renderCell: ({ nSamples }) => {
return typeof nSamples === "number" ? nSamples.toLocaleString() : naLabel
},
comparator: (a, b) => a?.nSamples - b?.nSamples,
sortable: true,
},
Expand Down
14 changes: 11 additions & 3 deletions packages/sections/src/variant/GWASCredibleSets/Body.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@ function getColumns({ id, referenceAllele, alternateAllele }: getColumnsType) {
{
id: "pValue",
label: "P-value",
numeric: true,
comparator: (a, b) =>
mantissaExponentComparator(
a?.pValueMantissa,
Expand All @@ -116,7 +117,7 @@ function getColumns({ id, referenceAllele, alternateAllele }: getColumnsType) {
renderCell: ({ pValueMantissa, pValueExponent }) => {
if (typeof pValueMantissa !== "number" || typeof pValueExponent !== "number")
return naLabel;
return <ScientificNotation number={[pValueMantissa, pValueExponent]} />;
return <ScientificNotation number={[pValueMantissa, pValueExponent]} dp={2} />;
},
exportValue: ({ pValueMantissa, pValueExponent }) => {
if (typeof pValueMantissa !== "number" || typeof pValueExponent !== "number") return null;
Expand All @@ -126,17 +127,19 @@ function getColumns({ id, referenceAllele, alternateAllele }: getColumnsType) {
{
id: "beta",
label: "Beta",
numeric: true,
filterValue: false,
tooltip: "Beta with respect to the ALT allele",
sortable: true,
renderCell: ({ beta }) => {
if (typeof beta !== "number") return naLabel;
return beta.toPrecision(3);
return beta.toFixed(3);
},
},
{
id: "posteriorProbability",
label: "Posterior probability",
numeric: true,
filterValue: false,
tooltip: (
<>
Expand Down Expand Up @@ -217,8 +220,13 @@ function getColumns({ id, referenceAllele, alternateAllele }: getColumnsType) {
label: "Credible set size",
comparator: (a, b) => a.locus?.count - b.locus?.count,
sortable: true,
numeric: true,
filterValue: false,
renderCell: ({ locus }) => locus?.count ?? naLabel,
renderCell: ({ locus }) => {
return typeof locus?.count === "number"
? locus.count.toLocaleString()
: naLabel;
},
exportValue: ({ locus }) => locus?.count,
},
];
Expand Down
Loading

0 comments on commit 3dd8f9d

Please sign in to comment.