diff --git a/packages/react-variant-view/src/component/functionalPrediction/FunctionalPrediction.tsx b/packages/react-variant-view/src/component/functionalPrediction/FunctionalPrediction.tsx index 63fe6274dca..1c9c31611ef 100644 --- a/packages/react-variant-view/src/component/functionalPrediction/FunctionalPrediction.tsx +++ b/packages/react-variant-view/src/component/functionalPrediction/FunctionalPrediction.tsx @@ -28,25 +28,21 @@ interface IFunctionalImpactData { @observer class FunctionalPrediction extends React.Component { public getData( - genomeNexusData: VariantAnnotation | undefined + genomeNexusData: VariantAnnotation | undefined, + selectedTranscriptId?: string ): IFunctionalImpactData { const mutationAssessor = genomeNexusData?.mutation_assessor; - const siftScore = - genomeNexusData && - genomeNexusData.transcript_consequences && - genomeNexusData.transcript_consequences[0].sift_score; - const siftPrediction = - genomeNexusData && - genomeNexusData.transcript_consequences && - genomeNexusData.transcript_consequences[0].sift_prediction; - const polyPhenScore = - genomeNexusData && - genomeNexusData.transcript_consequences && - genomeNexusData.transcript_consequences[0].polyphen_score; - const polyPhenPrediction = - genomeNexusData && - genomeNexusData.transcript_consequences && - genomeNexusData.transcript_consequences[0].polyphen_prediction; + const transcriptConsequence = + genomeNexusData && selectedTranscriptId + ? genomeNexusData.transcript_consequences.find( + tc => tc.transcript_id === selectedTranscriptId + ) + : undefined; + + const siftScore = transcriptConsequence?.sift_score; + const siftPrediction = transcriptConsequence?.sift_prediction; + const polyPhenScore = transcriptConsequence?.polyphen_score; + const polyPhenPrediction = transcriptConsequence?.polyphen_prediction; return { mutationAssessor, diff --git a/src/shared/components/mutationTable/MutationTable.tsx b/src/shared/components/mutationTable/MutationTable.tsx index ffe8ecfb5bb..f11417d8a46 100644 --- a/src/shared/components/mutationTable/MutationTable.tsx +++ b/src/shared/components/mutationTable/MutationTable.tsx @@ -906,7 +906,8 @@ export default class MutationTable< return FunctionalImpactColumnFormatter.renderFunction( d, this.props.genomeNexusCache, - this.props.genomeNexusMutationAssessorCache + this.props.genomeNexusMutationAssessorCache, + this.props.selectedTranscriptId ); } else { return ; @@ -917,7 +918,8 @@ export default class MutationTable< d, this.props.genomeNexusCache as GenomeNexusCache, this.props - .genomeNexusMutationAssessorCache as GenomeNexusMutationAssessorCache + .genomeNexusMutationAssessorCache as GenomeNexusMutationAssessorCache, + this.props.selectedTranscriptId ), headerRender: FunctionalImpactColumnFormatter.headerRender, visible: false, diff --git a/src/shared/components/mutationTable/column/FunctionalImpactColumnFormatter.tsx b/src/shared/components/mutationTable/column/FunctionalImpactColumnFormatter.tsx index e9f5340a517..be9e674083a 100644 --- a/src/shared/components/mutationTable/column/FunctionalImpactColumnFormatter.tsx +++ b/src/shared/components/mutationTable/column/FunctionalImpactColumnFormatter.tsx @@ -25,6 +25,7 @@ import GenomeNexusCache, { } from 'shared/cache/GenomeNexusCache'; import _ from 'lodash'; import { shouldShowMutationAssessor } from 'shared/lib/genomeNexusAnnotationSourcesUtils'; +import { selected } from 'pages/studyView/table/tables.module.scss'; type FunctionalImpactColumnTooltipProps = { active: 'mutationAssessor' | 'sift' | 'polyPhen2'; @@ -457,7 +458,8 @@ export default class FunctionalImpactColumnFormatter { public static getData( data: Mutation[], siftPolyphenCache: GenomeNexusCache, - mutationAssessorCache: GenomeNexusMutationAssessorCache + mutationAssessorCache: GenomeNexusMutationAssessorCache, + selectedTranscriptId?: string ): FunctionalImpactData { const siftPolyphenCacheData = FunctionalImpactColumnFormatter.getDataFromCache( data, @@ -471,10 +473,13 @@ export default class FunctionalImpactColumnFormatter { : null; const siftData = siftPolyphenCacheData - ? this.getSiftData(siftPolyphenCacheData.data) + ? this.getSiftData(siftPolyphenCacheData.data, selectedTranscriptId) : undefined; const polyphenData = siftPolyphenCacheData - ? this.getPolyphenData(siftPolyphenCacheData.data) + ? this.getPolyphenData( + siftPolyphenCacheData.data, + selectedTranscriptId + ) : undefined; const mutationAssessor = mutationAssessorCacheData ? this.getMutationAssessorData(mutationAssessorCacheData.data) @@ -496,17 +501,21 @@ export default class FunctionalImpactColumnFormatter { return functionalImpactData; } - public static getSiftData(siftDataCache: VariantAnnotation | null) { + public static getSiftData( + siftDataCache: VariantAnnotation | null, + selectedTranscriptId?: string + ) { let siftScore: number | undefined = undefined; let siftPrediction: string | undefined = undefined; - - if ( - siftDataCache && - !_.isEmpty(siftDataCache.transcript_consequences) - ) { - siftScore = siftDataCache.transcript_consequences[0].sift_score; - siftPrediction = - siftDataCache.transcript_consequences[0].sift_prediction; + if (siftDataCache && selectedTranscriptId) { + // find transcript consequence that matches the selected transcript + const transcriptConsequence = siftDataCache.transcript_consequences.find( + tc => tc.transcript_id === selectedTranscriptId + ); + if (transcriptConsequence) { + siftScore = transcriptConsequence.sift_score; + siftPrediction = transcriptConsequence.sift_prediction; + } } return { @@ -515,19 +524,22 @@ export default class FunctionalImpactColumnFormatter { }; } - public static getPolyphenData(polyphenDataCache: VariantAnnotation | null) { + public static getPolyphenData( + polyphenDataCache: VariantAnnotation | null, + selectedTranscriptId?: string + ) { let polyPhenScore: number | undefined = undefined; let polyPhenPrediction: string | undefined = undefined; - if ( - polyphenDataCache && - !_.isEmpty(polyphenDataCache.transcript_consequences) - ) { - polyPhenScore = - polyphenDataCache.transcript_consequences[0].polyphen_score; - polyPhenPrediction = - polyphenDataCache.transcript_consequences[0] - .polyphen_prediction; + if (polyphenDataCache && selectedTranscriptId) { + // find transcript consequence that matches the selected transcript + const transcriptConsequence = polyphenDataCache.transcript_consequences.find( + tc => tc.transcript_id === selectedTranscriptId + ); + if (transcriptConsequence) { + polyPhenScore = transcriptConsequence.polyphen_score; + polyPhenPrediction = transcriptConsequence.polyphen_prediction; + } } return { @@ -545,7 +557,8 @@ export default class FunctionalImpactColumnFormatter { public static renderFunction( data: Mutation[], siftPolyphenCache: GenomeNexusCache | undefined, - mutationAssessorCache: GenomeNexusMutationAssessorCache | undefined + mutationAssessorCache: GenomeNexusMutationAssessorCache | undefined, + selectedTranscriptId?: string ) { const showMutationAssessor = shouldShowMutationAssessor(); @@ -564,15 +577,18 @@ export default class FunctionalImpactColumnFormatter { {showMutationAssessor && FunctionalImpactColumnFormatter.makeFunctionalImpactViz( mutationAssessorCacheData, - FunctionalImpactColumnsName.MUTATION_ASSESSOR + FunctionalImpactColumnsName.MUTATION_ASSESSOR, + selectedTranscriptId )} {FunctionalImpactColumnFormatter.makeFunctionalImpactViz( siftPolyphenCacheData, - FunctionalImpactColumnsName.SIFT + FunctionalImpactColumnsName.SIFT, + selectedTranscriptId )} {FunctionalImpactColumnFormatter.makeFunctionalImpactViz( siftPolyphenCacheData, - FunctionalImpactColumnsName.POLYPHEN2 + FunctionalImpactColumnsName.POLYPHEN2, + selectedTranscriptId )} ); @@ -581,13 +597,15 @@ export default class FunctionalImpactColumnFormatter { public static download( data: Mutation[], siftPolyphenCache: GenomeNexusCache, - mutationAssessorCache: GenomeNexusMutationAssessorCache + mutationAssessorCache: GenomeNexusMutationAssessorCache, + selectedTranscriptId?: string ): string { if (siftPolyphenCache || mutationAssessorCache) { const functionalImpactData = FunctionalImpactColumnFormatter.getData( data, siftPolyphenCache, - mutationAssessorCache + mutationAssessorCache, + selectedTranscriptId ); let downloadData = []; if (functionalImpactData) { @@ -626,7 +644,8 @@ export default class FunctionalImpactColumnFormatter { private static makeFunctionalImpactViz( cacheData: GenomeNexusCacheDataType | null, - column: FunctionalImpactColumnsName + column: FunctionalImpactColumnsName, + selectedTranscriptId?: string ) { let status: TableCellStatus | null = null; @@ -650,7 +669,8 @@ export default class FunctionalImpactColumnFormatter { ); case FunctionalImpactColumnsName.SIFT: functionalImpactData = FunctionalImpactColumnFormatter.getSiftData( - cacheData.data + cacheData.data, + selectedTranscriptId ); return (