Skip to content

Commit

Permalink
[Platform]: Numeric precision (#611)
Browse files Browse the repository at this point in the history
* use toPrecision instead toFixed

* format insilico predictors scores
  • Loading branch information
gjmcn authored Dec 9, 2024
1 parent e4ff874 commit 999c8b4
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 10 deletions.
4 changes: 2 additions & 2 deletions packages/sections/src/credibleSet/Variants/Body.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ function getColumns({ leadVariantId, leadReferenceAllele, leadAlternateAllele }:
tooltip: "Beta with respect to the ALT allele",
renderCell: ({ beta }) => {
if (typeof beta !== "number") return naLabel;
return beta.toFixed(3);
return beta.toPrecision(3);
},
},
{
Expand Down Expand Up @@ -138,7 +138,7 @@ function getColumns({ leadVariantId, leadReferenceAllele, leadAlternateAllele }:
sortable: true,
renderCell: ({ posteriorProbability }) => {
if (typeof posteriorProbability !== "number") return naLabel;
return posteriorProbability.toFixed(3);
return posteriorProbability.toPrecision(3);
},
},
{
Expand Down
2 changes: 1 addition & 1 deletion packages/sections/src/study/GWASCredibleSets/Body.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ const columns = [
tooltip: "Beta with respect to the ALT allele",
renderCell: ({ beta }) => {
if (typeof beta !== "number") return naLabel;
return beta.toFixed(3);
return beta.toPrecision(3);
},
},
{
Expand Down
2 changes: 1 addition & 1 deletion packages/sections/src/variant/GWASCredibleSets/Body.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ function getColumns({ id, referenceAllele, alternateAllele }: getColumnsType) {
sortable: true,
renderCell: ({ beta }) => {
if (typeof beta !== "number") return naLabel;
return beta.toFixed(3);
return beta.toPrecision(3);
},
},
{
Expand Down
10 changes: 6 additions & 4 deletions packages/sections/src/variant/InSilicoPredictors/Body.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -38,12 +38,14 @@ const columns = [
{
id: "score",
label: "Score",
renderCell: ({ score }) => score ?? naLabel,
numeric: true,
renderCell: ({ score }) => score?.toPrecision(3) ?? naLabel,
},
{
id: "normalisedScore",
label: "Normalised score",
renderCell: ({ normalisedScore }) => normalisedScore ?? naLabel,
numeric: true,
renderCell: ({ normalisedScore }) => normalisedScore?.toFixed(3) ?? naLabel,
},
];

Expand All @@ -55,8 +57,8 @@ type BodyProps = {
function getSortedRows(request) {
return request.data?.variant?.inSilicoPredictors
? [...request.data.variant.inSilicoPredictors]
.filter(e => e.method !== null)
.sort((row1, row2) => row1.method.localeCompare(row2.method))
.filter(e => e.method !== null)
.sort((row1, row2) => row1.method.localeCompare(row2.method))
: [];
}

Expand Down
4 changes: 2 additions & 2 deletions packages/sections/src/variant/QTLCredibleSets/Body.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ function getColumns({ id, referenceAllele, alternateAllele }: getColumnsType) {
</Link>
);
},
exportValue: ({ study }) => { return `[${study?.biosample?.biosampleId}]:${study?.biosample?.biosampleName}`},
exportValue: ({ study }) => { return `[${study?.biosample?.biosampleId}]:${study?.biosample?.biosampleName}` },
},
{
id: "study.condition",
Expand Down Expand Up @@ -142,7 +142,7 @@ function getColumns({ id, referenceAllele, alternateAllele }: getColumnsType) {
sortable: true,
renderCell: ({ beta }) => {
if (typeof beta !== "number") return naLabel;
return beta.toFixed(3);
return beta.toPrecision(3);
},
},
{
Expand Down

0 comments on commit 999c8b4

Please sign in to comment.