import autobind from 'autobind-decorator'; import * as React from 'react'; import ReactTable, { RowInfo } from 'react-table'; import { GnomadSummary } from '../../model/GnomadSummary'; import { GnomadTableColumnName } from '../../util/GnomadUtils'; import ColumnHeader from '../column/ColumnHeader'; import './gnomadFrequencyTable.scss'; export interface IGnomadFrequencyTableProps { data: GnomadSummary[]; gnomadUrl: string; hideDisclaimer?: boolean; } export function frequencyOutput(frequency: number) { if (frequency === 0) { return 0; } else { // show frequency as number with 4 significant digits return ( {frequency.toLocaleString(undefined, { maximumSignificantDigits: 2, minimumSignificantDigits: 2, })} ); } } const headerClassName = 'text-wrap font-weight-bold'; const HEADERS = { [GnomadTableColumnName.population]: ( Population} /> ), [GnomadTableColumnName.alleleCount]: ( Allele Count} overlay={Number of individuals with this allele} /> ), [GnomadTableColumnName.alleleNumber]: ( Allele Number} overlay={ Number of times any allele has been observed at this position in the population } /> ), [GnomadTableColumnName.homozygotes]: ( Number of Homozygotes} overlay={ Number of individuals carrying this allele in both copies } /> ), [GnomadTableColumnName.alleleFrequency]: ( Allele Frequency} overlay={Proportion of the population with this allele} /> ), }; function renderNumericalValue(column: any) { return {column.value}; } const Disclaimer: React.FunctionComponent<{ gnomadUrl: string }> = props => { const myVariantInfoLink = ( myvariant.info ); const genomeNexusLink = ( genomenexus.org ); const gnomadLink = ( gnomAD ); return (
Source: {genomeNexusLink}, which serves {myVariantInfoLink}'s gnomAD data.
Latest {gnomadLink} data may differ.
); }; export default class GnomadFrequencyTable extends React.Component< IGnomadFrequencyTableProps, {} > { public render() { return (
( {frequencyOutput(column.value)} ), width: 120, }, ]} /> {!this.props.hideDisclaimer && ( )}
); } @autobind protected getTrProps(state: any, row?: RowInfo) { return { style: { fontWeight: state && row && row.index === this.props.data.length - 1 ? 'bold' : undefined, }, }; } }