import * as React from 'react'; import { observer, Observer } from 'mobx-react'; import { Helmet } from 'react-helmet'; import { PageLayout } from '../../../../shared/components/PageLayout/PageLayout'; import OncoprinterStore from './OncoprinterStore'; import Oncoprinter from './Oncoprinter'; import { action, observable, runInAction, makeObservable } from 'mobx'; import { Button, ControlLabel, FormControl, FormGroup } from 'react-bootstrap'; import { Collapse } from 'react-collapse'; import autobind from 'autobind-decorator'; import { exampleClinicalData, exampleGeneticData, exampleHeatmapData, } from './OncoprinterConstants'; import { MSKTab, MSKTabs } from '../../../../shared/components/MSKTabs/MSKTabs'; import MutualExclusivityTab from '../../../resultsView/mutualExclusivity/MutualExclusivityTab'; import { getDataForSubmission } from './OncoprinterToolUtils'; import { ClinicalTrackDataType, HeatmapTrackDataType, ONCOPRINTER_VAL_NA, } from './OncoprinterClinicalAndHeatmapUtils'; import styles from './styles.module.scss'; import { getBrowserWindow } from 'cbioportal-frontend-commons'; import { ClinicalFormatHelp, GenomicFormatHelp, HeatmapFormatHelp, } from './OncoprinterHelp'; import { buildCBioLink } from 'shared/api/urls'; export interface IOncoprinterToolProps {} export enum OncoprinterTab { ONCOPRINT = 'oncoprint', MUTUAL_EXCLUSIVITY = 'mutualExclusivity', } @observer export default class OncoprinterTool extends React.Component< IOncoprinterToolProps, {} > { private store = new OncoprinterStore(); private geneticFileInput: HTMLInputElement | null; private clinicalFileInput: HTMLInputElement | null; private heatmapFileInput: HTMLInputElement | null; @observable private activeTabId: OncoprinterTab = OncoprinterTab.ONCOPRINT; @observable dataInputOpened = true; @observable geneticHelpOpened = false; @observable clinicalHelpOpened = false; @observable heatmapHelpOpened = false; // help @observable helpOpened = false; // input @observable geneticDataInput = ''; @observable clinicalDataInput = ''; @observable heatmapDataInput = ''; @observable geneOrderInput = ''; @observable sampleOrderInput = ''; constructor(props: IOncoprinterToolProps) { super(props); makeObservable(this); (window as any).oncoprinterTool = this; } componentDidMount() { // Load posted data, if it exists const postData = getBrowserWindow().clientPostedData; if (postData) { this.geneticDataInput = postData.genetic; this.clinicalDataInput = postData.clinical; this.heatmapDataInput = postData.heatmap; this.doSubmit( this.geneticDataInput, this.clinicalDataInput, this.heatmapDataInput ); getBrowserWindow().clientPostedData = null; } } @action.bound private toggleHelpOpened() { this.helpOpened = !this.helpOpened; } @action.bound private populateGeneticExampleData() { this.geneticDataInput = exampleGeneticData; } @action.bound private populateClinicalExampleData() { this.clinicalDataInput = exampleClinicalData; } @action.bound private populateHeatmapExampleData() { this.heatmapDataInput = exampleHeatmapData; } @action.bound public onGeneticDataInputChange(e: any) { this.geneticDataInput = e.currentTarget.value; } @action.bound private onClinicalDataInputChange(e: any) { this.clinicalDataInput = e.currentTarget.value; } @action.bound private onHeatmapDataInputChange(e: any) { this.heatmapDataInput = e.currentTarget.value; } @action.bound private onGeneOrderInputChange(e: any) { this.geneOrderInput = e.currentTarget.value; } @action.bound private onSampleOrderInputChange(e: any) { this.sampleOrderInput = e.currentTarget.value; } @action.bound private toggleGeneticHelp() { this.geneticHelpOpened = !this.geneticHelpOpened; } @action.bound private toggleClinicalHelp() { this.clinicalHelpOpened = !this.clinicalHelpOpened; } @action.bound private toggleHeatmapHelp() { this.heatmapHelpOpened = !this.heatmapHelpOpened; } @action private doSubmit( geneticDataInput: string, clinicalDataInput: string, heatmapDataInput: string ) { this.store.setInput( geneticDataInput, clinicalDataInput, heatmapDataInput, this.geneOrderInput, this.sampleOrderInput ); if (this.store.parseErrors.length === 0) { this.dataInputOpened = false; } } @autobind private geneticFileInputRef(input: HTMLInputElement | null) { this.geneticFileInput = input; } @autobind private clinicalFileInputRef(input: HTMLInputElement | null) { this.clinicalFileInput = input; } @autobind private heatmapFileInputRef(input: HTMLInputElement | null) { this.heatmapFileInput = input; } @autobind private getGeneticDataForSubmission() { return getDataForSubmission( this.geneticFileInput, this.geneticDataInput ); } @autobind private getClinicalDataForSubmission() { return getDataForSubmission( this.clinicalFileInput, this.clinicalDataInput ); } @autobind private getHeatmapDataForSubmission() { return getDataForSubmission( this.heatmapFileInput, this.heatmapDataInput ); } @action.bound private async onClickSubmit() { const geneticData = await this.getGeneticDataForSubmission(); const clinicalData = await this.getClinicalDataForSubmission(); const heatmapData = await this.getHeatmapDataForSubmission(); this.doSubmit(geneticData, clinicalData, heatmapData); } private openDataFormat(tab: 'genomic' | 'clinical' | 'heatmap') { window.open(`oncoprinterDataFormat?tab=${tab}`, '_blank'); } @autobind private getInputSection() { return (
Step 1) Input genomic alteration data (optional):
{GenomicFormatHelp}
or input data from file:

Step 2) Input clinical data (optional):
{ClinicalFormatHelp}
or input data from file:

Step 3) Input heatmap data (optional):
{HeatmapFormatHelp}
or input data from file:

Please define the order of genes (optional):
Please define the order of samples (optional):
{this.store.parseErrors.length > 0 && (
{this.store.parseErrors.map(err => (
{err}
))}
)}
); } render() { const numCells = this.store.hugoGeneSymbols.length * this.store.sampleIds.length; return ( {'cBioPortal for Cancer Genomics::Oncoprinter'}

Oncoprinter

{' '} Generate Oncoprints and perform mutual exclusivity analysis from your own data.

{this.getInputSection} {!this.dataInputOpened && ( )}
{ this.activeTabId = id as OncoprinterTab; }} className="mainTabs" > {numCells > 100000 && (
Warning: Because your inputted data is very large, the Oncoprinter may be slow, and downloaded PDF, SVG, and PNG may be huge and unresponsive. We recommend plotting data for fewer genes at a time.
)}
); } }