import * as React from 'react'; import { Geneset } from 'cbioportal-ts-api-client'; import { Gene } from 'cbioportal-ts-api-client'; import { correlationColor, correlationSortBy } from './CoExpressionTableUtils'; import LazyMobXTable from '../../../shared/components/lazyMobXTable/LazyMobXTable'; import { CoExpressionDataStore, TableMode } from './CoExpressionViz'; import Select from 'react-select1'; import { observer } from 'mobx-react'; import { CoExpressionWithQ, tableSearchInformation, } from './CoExpressionTabUtils'; import InfoIcon from '../../../shared/components/InfoIcon'; import { bind } from 'bind-decorator'; import { cytobandFilter } from 'pages/resultsView/ResultsViewTableUtils'; import { toConditionalPrecision } from 'shared/lib/NumberUtils'; import { formatSignificanceValueWithStyle } from 'shared/lib/FormatUtils'; export interface ICoExpressionTableGenesProps { referenceGeneticEntity: Gene | Geneset; dataStore: CoExpressionDataStore; tableMode: TableMode; onSelectTableMode: (t: TableMode) => void; } const SPEARMANS_CORRELATION_COLUMN_NAME = "Spearman's Correlation"; const P_VALUE_COLUMN_NAME = 'p-Value'; const Q_VALUE_COLUMN_NAME = 'q-Value'; const COLUMNS = [ { name: 'Correlated Gene', render: (d: CoExpressionWithQ) => ( {d.geneticEntityName} ), filter: (d: CoExpressionWithQ, f: string, filterStringUpper: string) => d.geneticEntityName.indexOf(filterStringUpper) > -1, download: (d: CoExpressionWithQ) => d.geneticEntityName, sortBy: (d: CoExpressionWithQ) => d.geneticEntityName, width: '30%', }, { name: 'Cytoband', render: (d: CoExpressionWithQ) => {d.cytoband}, filter: cytobandFilter, download: (d: CoExpressionWithQ) => d.cytoband, sortBy: (d: CoExpressionWithQ) => d.cytoband, width: '30%', }, makeNumberColumn( SPEARMANS_CORRELATION_COLUMN_NAME, 'spearmansCorrelation', true, false ), Object.assign( makeNumberColumn(P_VALUE_COLUMN_NAME, 'pValue', false, false), { tooltip: Derived from 2-sided t-test., } ), Object.assign( makeNumberColumn(Q_VALUE_COLUMN_NAME, 'qValue', false, true), { sortBy: (d: CoExpressionWithQ) => [d.qValue, d.pValue], tooltip: ( Derived from Benjamini-Hochberg FDR correction procedure. ), } ), ]; function makeNumberColumn( name: string, key: keyof CoExpressionWithQ, colorByValue: boolean, formatSignificance: boolean ) { return { name: name, render: (d: CoExpressionWithQ) => { return ( {formatSignificance ? formatSignificanceValueWithStyle(d[key] as number) : toConditionalPrecision(d[key] as number, 3, 0.01)} ); }, download: (d: CoExpressionWithQ) => (d[key] as number).toString() + '', sortBy: (d: CoExpressionWithQ) => correlationSortBy(d[key] as number), align: 'right' as 'right', }; } @observer export default class CoExpressionTableGenes extends React.Component< ICoExpressionTableGenesProps, {} > { @bind private onRowClick(d: CoExpressionWithQ) { this.props.dataStore.setHighlighted(d); } @bind private onSelectTableMode(d: any) { this.props.onSelectTableMode(d.value); } private tableModeOptions = [ { label: 'Show Any Correlation', value: TableMode.SHOW_ALL, }, { label: 'Show Only Positively Correlated', value: TableMode.SHOW_POSITIVE, }, { label: 'Show Only Negatively Correlated', value: TableMode.SHOW_NEGATIVE, }, ]; private paginationProps = { itemsPerPageOptions: [25], }; render() { return (