Skip to content

Commit

Permalink
Fix Sift and Polyphen
Browse files Browse the repository at this point in the history
Show Sift and Polyphen by different transcript
  • Loading branch information
leexgh committed Nov 5, 2024
1 parent 1081908 commit eb00ee3
Show file tree
Hide file tree
Showing 3 changed files with 69 additions and 50 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -28,25 +28,21 @@ interface IFunctionalImpactData {
@observer
class FunctionalPrediction extends React.Component<IFunctionalPredictionProps> {
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,
Expand Down
6 changes: 4 additions & 2 deletions src/shared/components/mutationTable/MutationTable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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 <span></span>;
Expand All @@ -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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -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,
Expand All @@ -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)
Expand All @@ -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 {
Expand All @@ -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 {
Expand All @@ -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();

Expand All @@ -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
)}
</div>
);
Expand All @@ -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) {
Expand Down Expand Up @@ -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;

Expand All @@ -650,7 +669,8 @@ export default class FunctionalImpactColumnFormatter {
);
case FunctionalImpactColumnsName.SIFT:
functionalImpactData = FunctionalImpactColumnFormatter.getSiftData(
cacheData.data
cacheData.data,
selectedTranscriptId
);
return (
<Sift
Expand All @@ -660,7 +680,8 @@ export default class FunctionalImpactColumnFormatter {
);
case FunctionalImpactColumnsName.POLYPHEN2:
functionalImpactData = FunctionalImpactColumnFormatter.getPolyphenData(
cacheData.data
cacheData.data,
selectedTranscriptId
);
return (
<PolyPhen2
Expand Down

0 comments on commit eb00ee3

Please sign in to comment.