import * as React from 'react'; import 'rc-tooltip/assets/bootstrap_white.css'; import SampleManager from '../../SampleManager'; import { isUncalled } from 'shared/lib/MutationUtils'; import _ from 'lodash'; import { ClinicalDataBySampleId } from 'cbioportal-ts-api-client'; import { noGenePanelUsed } from 'shared/lib/StoreUtils'; import SampleInline from 'pages/patientView/patientHeader/SampleInline'; import SampleLabelNotProfiled from 'shared/components/sampleLabel/SampleLabelNotProfiled'; export default class TumorColumnFormatter { // NOTE: entrezGeneId can be array of genes // in order to support structural variant // alteration type which are associated with // two genes public static renderFunction< T extends { sampleId: string; entrezGeneId: number | number[] } >( mutations: T[], sampleManager: SampleManager | null, sampleToGenePanelId: { [sampleId: string]: string | undefined }, genePanelIdToGene: { [genePanelId: string]: number[] }, onSelectGenePanel?: (name: string) => void, disableTooltip?: boolean ) { if (!sampleManager) { return ; } // Rules for icon: // - when sample->gene has mutation (present in _mutatedSamples_) show the `sample` icon // - when sample->gene has no mutation (absent from _mutatedSamples_) and was profiled, show `no mutation` icon // - when sample->gene has no mutation (absent from _mutatedSamples_) and was not profiled, show `not profiled` icon const samples = sampleManager.samples; const sampleIds = _.map( samples, (sample: ClinicalDataBySampleId) => sample.id ); const entrezGeneId = mutations[0].entrezGeneId; const mutatedSamples = TumorColumnFormatter.getPresentSamples( mutations ); const profiledSamples = TumorColumnFormatter.getProfiledSamplesForGene( entrezGeneId, sampleIds, sampleToGenePanelId, genePanelIdToGene ); const notProfiledText = 'This gene was not profiled for this sample (absent from gene panel)'; const tdValue = samples.map((sample: any) => { // hide labels for non-existent mutation data // decreased opacity for uncalled mutations // show not-profiled icon when gene was not analyzed const isMutated = sample.id in mutatedSamples; const isProfiled = sample.id in profiledSamples && profiledSamples[sample.id]; let extraTooltipText = ''; // mutations can be read which are not part of the target of the gene panel // therefore a sample can still have mutations even if the gene was not profiled if (isMutated) { if (!mutatedSamples[sample.id]) { extraTooltipText = "Mutation has supporting reads, but wasn't called. "; } if (!isProfiled) { extraTooltipText = `${extraTooltipText}${notProfiledText}`; } } else { if (!isProfiled) { extraTooltipText = `${notProfiledText}. It is unknown whether it is mutated.`; } } return (