diff --git a/packages/react-mutation-mapper/src/component/gnomad/GnomadFrequency.tsx b/packages/react-mutation-mapper/src/component/gnomad/GnomadFrequency.tsx index 843b8663b3e..b1330513001 100644 --- a/packages/react-mutation-mapper/src/component/gnomad/GnomadFrequency.tsx +++ b/packages/react-mutation-mapper/src/component/gnomad/GnomadFrequency.tsx @@ -82,8 +82,7 @@ export type GnomadFrequencyProps = { @observer export default class GnomadFrequency extends React.Component { - public render() - { + public gnomad() { const myVariantInfo = this.props.myVariantInfo; let gnomadUrl = ""; @@ -145,7 +144,15 @@ export default class GnomadFrequency extends React.Component0; } else { - display = {parseFloat(result["Total"].alleleFrequency.toString()).toExponential(1)}; + // show frequency as number with 4 significant digits + display = ( + + {result['Total'].alleleFrequency.toLocaleString(undefined, { + maximumSignificantDigits: 2, + minimumSignificantDigits: 2, + })} + + ); } overlay = () => ; @@ -154,15 +161,19 @@ export default class GnomadFrequency extends React.Component ; overlay = () => Variant has no data in gnomAD.; } + return { overlay, display }; + } + public render() + { return ( - {display} + {this.gnomad().display} ); } diff --git a/packages/react-mutation-mapper/src/component/gnomad/GnomadFrequencyTable.tsx b/packages/react-mutation-mapper/src/component/gnomad/GnomadFrequencyTable.tsx index e39a40748ed..715763a4193 100644 --- a/packages/react-mutation-mapper/src/component/gnomad/GnomadFrequencyTable.tsx +++ b/packages/react-mutation-mapper/src/component/gnomad/GnomadFrequencyTable.tsx @@ -19,8 +19,15 @@ export function frequencyOutput(frequency: number) { return 0 } else { - // keep one digit on allele frequency and using scientific notation - return {parseFloat(frequency.toString()).toExponential(1)}; + // show frequency as number with 4 significant digits + return ( + + {frequency.toLocaleString(undefined, { + maximumSignificantDigits: 2, + minimumSignificantDigits: 2, + })} + + ); } } @@ -143,7 +150,7 @@ export default class GnomadFrequencyTable extends React.Component {frequencyOutput(column.value)} , - width: 80 + width: 120 }, ]} /> diff --git a/packages/react-mutation-mapper/src/util/FormatUtils.ts b/packages/react-mutation-mapper/src/util/FormatUtils.ts index 3da3d3f9624..cba94b03312 100644 --- a/packages/react-mutation-mapper/src/util/FormatUtils.ts +++ b/packages/react-mutation-mapper/src/util/FormatUtils.ts @@ -14,4 +14,4 @@ export function formatPercentValue(rate: number, fractionDigits: number = 1) export function numberOfLeadingDecimalZeros(value: number) { return -Math.floor( (Math.log10(value) / Math.log10(10)) + 1); -} +} \ No newline at end of file diff --git a/src/shared/components/mutationTable/MutationTable.tsx b/src/shared/components/mutationTable/MutationTable.tsx index 63989c5e78e..583fe66d68c 100644 --- a/src/shared/components/mutationTable/MutationTable.tsx +++ b/src/shared/components/mutationTable/MutationTable.tsx @@ -597,7 +597,7 @@ export default class MutationTable

extends React. Overall population allele frequency is shown. Hover over a frequency to see the frequency for each specific population.), defaultSortDirection: "desc", visible: false, - align: "right" + align: "left" }; this._columns[MutationTableColumnType.CLINVAR] = { diff --git a/src/shared/components/mutationTable/column/GnomadColumnFormatter.tsx b/src/shared/components/mutationTable/column/GnomadColumnFormatter.tsx index e0085ed6705..594d165d8f6 100644 --- a/src/shared/components/mutationTable/column/GnomadColumnFormatter.tsx +++ b/src/shared/components/mutationTable/column/GnomadColumnFormatter.tsx @@ -3,20 +3,13 @@ import {Circle} from "better-react-spinkit"; import 'rc-tooltip/assets/bootstrap_white.css'; import {Mutation} from "shared/api/generated/CBioPortalAPI"; import { - DefaultTooltip, TableCellStatusIndicator, TableCellStatus, MyVariantInfo, - MyVariantInfoAnnotation, - Gnomad, - AlleleCount, - AlleleNumber, - Homozygotes, - AlleleFrequency + MyVariantInfoAnnotation } from 'cbioportal-frontend-commons'; import GenomeNexusMyVariantInfoCache, { GenomeNexusCacheDataType } from "shared/cache/GenomeNexusMyVariantInfoCache"; import {calculateGnomadAllelFrequency, GnomadFrequency, gnomadSortValue} from "react-mutation-mapper"; -import generalStyles from "./styles.module.scss"; export default class GnomadColumnFormatter { @@ -24,9 +17,7 @@ export default class GnomadColumnFormatter { genomeNexusMyVariantInfoCache: GenomeNexusMyVariantInfoCache | undefined) { const genomeNexusCacheData = GnomadColumnFormatter.getGenomeNexusDataFromCache(data, genomeNexusMyVariantInfoCache); return ( -

- {GnomadColumnFormatter.getGnomadDataViz(genomeNexusCacheData)} -
+ {GnomadColumnFormatter.getGnomadDataViz(genomeNexusCacheData)} ); }