import _ from 'lodash'; import * as React from 'react'; import { observer } from 'mobx-react'; import featureTableStyle from '../featureTable/FeatureTable.module.scss'; import { computed, makeObservable } from 'mobx'; import { VariantAnnotation } from 'genome-nexus-ts-api-client'; import { DefaultTooltip } from 'cbioportal-frontend-commons'; import { extendMutations, isGermlineMutation, isSomaticMutation, formatFrequencyValue, Pathogenicity, } from 'cbioportal-utils'; import { signalLogoInTable } from '../featureTable/SignalLogo'; interface ICancerPatientPopulationProps { variantAnnotation?: VariantAnnotation; } export const PathogenicityNameHelper = { [Pathogenicity.SOMATIC]: { title: 'Somatic', description: 'Percent of cancer patients with this mutation detected in somatic tumor sample.', }, [Pathogenicity.GERMLINE]: { title: 'Germline', description: 'Percent of cancer patients with this mutation detected in germline DNA.', }, [Pathogenicity.BIALLELIC]: { title: 'Biallelic', description: 'Percent of pathogenic germline carriers with somatic biallelic inactivation in the corresponding tumor sample.', }, }; @observer class CancerPatientPopulation extends React.Component< ICancerPatientPopulationProps > { constructor(props: ICancerPatientPopulationProps) { super(props); makeObservable(this); } @computed get frequenciesContent() { let contentMap: Map = new Map(); let content: JSX.Element[] = []; if ( this.props.variantAnnotation && this.props.variantAnnotation.signalAnnotation && this.props.variantAnnotation.signalAnnotation.annotation.length > 0 ) { const signalMutation = extendMutations( this.props.variantAnnotation.signalAnnotation.annotation ); _.forEach(signalMutation, mutation => { if (isGermlineMutation(mutation)) { contentMap.set( Pathogenicity.GERMLINE, this.percentageContent( Pathogenicity.GERMLINE, formatFrequencyValue(mutation.germlineFrequency) ) ); const germline = contentMap.get(Pathogenicity.GERMLINE); if (mutation.ratioBiallelicPathogenic && germline) { contentMap.set( Pathogenicity.GERMLINE, this.percentageContent( Pathogenicity.GERMLINE, formatFrequencyValue( mutation.germlineFrequency ), {` (`} { PathogenicityNameHelper[ Pathogenicity.BIALLELIC ].description } } > { PathogenicityNameHelper[ Pathogenicity.BIALLELIC ].title } {signalLogoInTable} {`: `} {formatFrequencyValue( mutation.ratioBiallelicPathogenic )} {`%)`} ) ); } } else if (isSomaticMutation(mutation)) { contentMap.set( Pathogenicity.SOMATIC, this.percentageContent( Pathogenicity.SOMATIC, formatFrequencyValue(mutation.somaticFrequency) ) ); } }); // show germline on the top if (contentMap.get(Pathogenicity.GERMLINE)) { content.push(contentMap.get(Pathogenicity.GERMLINE)!); } if (contentMap.get(Pathogenicity.SOMATIC)) { content.push(contentMap.get(Pathogenicity.SOMATIC)!); } } if (content.length === 0) { content.push(
No data available
); } return content; } private percentageContent( category: Pathogenicity, value: string, children?: JSX.Element ) { return (
{PathogenicityNameHelper[category].description} } > {PathogenicityNameHelper[category].title} {signalLogoInTable}
{value} {`%`} {children}
); } public render() { return this.frequenciesContent; } } export default CancerPatientPopulation;