Skip to content

Commit

Permalink
add react mutation mapper of alphaMissense
Browse files Browse the repository at this point in the history
  • Loading branch information
JunheZoooo committed Aug 23, 2024
1 parent 1ec1ded commit 3c85e7f
Show file tree
Hide file tree
Showing 5 changed files with 271 additions and 131 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
import { observer } from 'mobx-react';
import * as React from 'react';
import { Mutation } from 'cbioportal-ts-api-client';
import { VariantAnnotation } from 'genome-nexus-ts-api-client';
import { defaultSortMethod, RemoteData } from 'cbioportal-utils';
// import styles from './alphaMissense.module.scss'
import { getAlphaMissenseColumnData } from './AlphaMissenseHelper';
import { DefaultTooltip } from 'cbioportal-frontend-commons';
type AlphaMissenseProps = {
mutation: Mutation;
indexedVariantAnnotations?: RemoteData<
{ [genomicLocation: string]: VariantAnnotation } | undefined
>;
// selectedTranscriptId?: string;
};
export function download(alphaMissense?: string | null): string {
return alphaMissense || 'N/A';
}

export function sortValue(alphaMissense?: string | null): number | null {
const score = alphaMissense?.split('|')[1];
return score ? parseFloat(score) : 0.0;
}

// Main component for rendering AlphaMissense data
@observer
export default class AlphaMissense extends React.Component<
AlphaMissenseProps,
{}
> {
get alphaMissense() {
return getAlphaMissenseColumnData(
this.props.mutation,
this.props.indexedVariantAnnotations
);
}
public render() {
const pathogenicity = this.alphaMissense?.split('|')[0];
const score = this.alphaMissense?.split('|')[1];
return (
<span>
{/*{AlphaMissenseColumnFormatter.getAlphaMissenseDataViz(*/}
{/* alphaMissenseCache*/}
{/*)}*/}
<DefaultTooltip
overlay={() => <div style={{ maxWidth: 300 }}>{score}</div>}
placement="topLeft"
>
<span
style={{
width: '24px',
textAlign: 'center',
}}
>
{pathogenicity}
</span>
</DefaultTooltip>
</span>
);
}
}

// // Helper function to get GenomeNexus cache data
// function getGenomeNexusDataFromCache(
// data: Mutation[],
// cache: indexedVariantAnnotations | undefined
// ): GenomeNexusCacheDataType | null {
// if (data.length === 0 || !cache) return null;
// return cache.annoation_summery.get(data[0]);
// }
//

//
// indexedVariantAnnotations.annotation_summary?: RemoteData<
// { [genomicLocation: string]: VariantAnnotation } | undefined
// >;
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
import { AlphaMissense, VariantAnnotation } from 'genome-nexus-ts-api-client';
import { Mutation, RemoteData } from 'cbioportal-utils';
import { getAnnotation } from './VariantAnnotationHelper';
//
// export function getHgvsgColumnData(mutation: Mutation): string | null {
// return generateHgvsgByMutation(mutation) || null;
// }

export function getAlphaMissenseColumnData(
mutation: Mutation,
indexedVariantAnnotations?: RemoteData<
{ [genomicLocation: string]: VariantAnnotation } | undefined
>
): string | null {
const variantAnnotation = getAnnotation(
mutation,
indexedVariantAnnotations
);

if (!variantAnnotation) {
console.log('asdd');
return null;
}

// return data from transcriptConsequenceSummaries if transcript dropdown is enabled
// if (selectedTranscriptId) {
// const transcriptConsequenceSummary = variantAnnotation.annotation_summary?.transcriptConsequenceSummaries?.find(
// transcriptConsequenceSummary =>
// transcriptConsequenceSummary.transcriptId ===
// selectedTranscriptId
// );
// data = transcriptConsequenceSummary
// ? transcriptConsequenceSummary.hgvsc
// : null;
// }

return 'path|0.996';

// console.log("sss"+JSON.stringify(variantAnnotation.annotation_summary?.transcriptConsequenceSummary))
// return ((variantAnnotation.annotation_summary?.transcriptConsequenceSummary
// ?.alphaMissense.pathogenicity) + "|" + (variantAnnotation.annotation_summary?.transcriptConsequenceSummary
// ?.alphaMissense.score ))||'N/A';
}
6 changes: 6 additions & 0 deletions packages/react-mutation-mapper/src/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,12 @@ export {
} from './component/column/Hgvsc';
export { default as Hgvsg } from './component/column/Hgvsg';
export * from './component/column/HgvsHelper';
export {
default as AlphaMissense,
download as alphaMissenseDownload,
sortValue as alphaMissenseSortValue,
} from './component/column/AlphaMissense';
export * from './component/column/AlphaMissenseHelper';
export { MutationStatus } from './component/column/MutationStatus';
export {
default as ProteinChange,
Expand Down
9 changes: 6 additions & 3 deletions src/shared/components/mutationTable/MutationTable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -478,20 +478,23 @@ export default class MutationTable<
this.props.genomeNexusCache ? (
AlphaMissenseColumnFormatter.renderFunction(
d,
this.props.genomeNexusCache
// this.props.genomeNexusCache
this.props.indexedVariantAnnotations,
this.props.selectedTranscriptId
)
) : (
<span></span>
),
download: (d: Mutation[]) =>
AlphaMissenseColumnFormatter.download(
d,
this.props.genomeNexusCache as GenomeNexusCache
this.props.indexedVariantAnnotations
),
sortBy: (d: Mutation[]) =>
AlphaMissenseColumnFormatter.getSortValue(
d,
this.props.genomeNexusCache as GenomeNexusCache
this.props.indexedVariantAnnotations
// this.props.genomeNexusCache as GenomeNexusCache
),
visible: false,
tooltip: (
Expand Down
Loading

0 comments on commit 3c85e7f

Please sign in to comment.