import * as React from 'react'; import PathwayMapperTable, { IPathwayMapperTable, } from '../../../shared/lib/pathwayMapper/PathwayMapperTable'; import { observer } from 'mobx-react'; import autobind from 'autobind-decorator'; import { action, computed, makeObservable, observable } from 'mobx'; import { Row } from 'react-bootstrap'; import PathwayMapper from 'pathway-mapper'; import 'pathway-mapper/dist/base.css'; import 'cytoscape-panzoom/cytoscape.js-panzoom.css'; import 'cytoscape-navigator/cytoscape.js-navigator.css'; import { AlterationEnrichmentRow } from 'shared/model/AlterationEnrichmentRow'; import { ComparisonGroup } from '../GroupComparisonUtils'; import { GenesSelection } from 'pages/resultsView/enrichments/GeneBarPlot'; import { DefaultTooltip } from 'cbioportal-frontend-commons'; import GroupComparisonStore from '../GroupComparisonStore'; import { GeneOptionLabel } from 'pages/resultsView/enrichments/EnrichmentsUtil'; import { SingleGeneQuery } from 'shared/lib/oql/oql-parser'; interface IGroupComparisonPathwayMapperProps { activeGroups: ComparisonGroup[] | undefined; genomicData: AlterationEnrichmentRow[]; store: GroupComparisonStore; } @observer export default class GroupComparisonPathwayMapper extends React.Component< IGroupComparisonPathwayMapperProps > { clearMessage: (() => void) | undefined; constructor(props: IGroupComparisonPathwayMapperProps) { super(props); makeObservable(this); // @ts-ignore import(/* webpackChunkName: "pathway-mapper" */ 'pathway-mapper').then( (module: any) => { this.PathwayMapperComponent = (module as any) .default as PathwayMapper; } ); } @observable.ref PathwayMapperComponent: | PathwayMapper | undefined = undefined; @observable isGeneSelectionPopupVisible: boolean = false; @observable private _userSelectedGenes: string[] | undefined = undefined; @computed get activeGenes() { return ( this._userSelectedGenes || this.props.store.genesSortedByMutationFrequency.result?.slice( 0, 10 ) || [] ); } @computed get alterationEnrichmentRowData(): AlterationEnrichmentRow[] { return this.props.store.alterationEnrichmentRowData.filter(gene => { return this.activeGenes.includes(gene.hugoGeneSymbol); }); } @action.bound onSelectedGenesChange( value: string, genes: SingleGeneQuery[], label: GeneOptionLabel ) { this._userSelectedGenes = genes.map(g => g.gene); this.isGeneSelectionPopupVisible = false; } public render() { if (!this.PathwayMapperComponent) { return null; } return (