Skip to content

Commit

Permalink
add hgvsg column in mutation table and link out to genome nexus
Browse files Browse the repository at this point in the history
- hgvsg is shown by default
- the hgvsg will be shorted with ... if the ref or var is too long
  • Loading branch information
leexgh committed Jan 7, 2020
1 parent 58d37c1 commit 4d2147e
Show file tree
Hide file tree
Showing 8 changed files with 158 additions and 1 deletion.
2 changes: 2 additions & 0 deletions src/pages/patientView/mutation/PatientViewMutationTable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ export default class PatientViewMutationTable extends MutationTable<IPatientView
MutationTableColumnType.MRNA_EXPR,
MutationTableColumnType.COPY_NUM,
MutationTableColumnType.ANNOTATION,
MutationTableColumnType.HGVSG,
MutationTableColumnType.REF_READS_N,
MutationTableColumnType.VAR_READS_N,
MutationTableColumnType.REF_READS,
Expand Down Expand Up @@ -160,6 +161,7 @@ export default class PatientViewMutationTable extends MutationTable<IPatientView
this._columns[MutationTableColumnType.GENE_PANEL].order = 25;
this._columns[MutationTableColumnType.PROTEIN_CHANGE].order = 30;
this._columns[MutationTableColumnType.ANNOTATION].order = 35;
this._columns[MutationTableColumnType.HGVSG].order = 36;
this._columns[MutationTableColumnType.FUNCTIONAL_IMPACT].order = 38;
this._columns[MutationTableColumnType.CHROMOSOME].order = 40;
this._columns[MutationTableColumnType.START_POS].order = 50;
Expand Down
2 changes: 2 additions & 0 deletions src/pages/resultsView/mutation/ResultsViewMutationTable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ export default class ResultsViewMutationTable extends MutationTable<IResultsView
MutationTableColumnType.SAMPLE_ID,
MutationTableColumnType.COPY_NUM,
MutationTableColumnType.ANNOTATION,
MutationTableColumnType.HGVSG,
MutationTableColumnType.FUNCTIONAL_IMPACT,
MutationTableColumnType.REF_READS_N,
MutationTableColumnType.VAR_READS_N,
Expand Down Expand Up @@ -77,6 +78,7 @@ export default class ResultsViewMutationTable extends MutationTable<IResultsView
this._columns[MutationTableColumnType.CANCER_TYPE].order = 15;
this._columns[MutationTableColumnType.PROTEIN_CHANGE].order = 20;
this._columns[MutationTableColumnType.ANNOTATION].order = 30;
this._columns[MutationTableColumnType.HGVSG].order = 35;
this._columns[MutationTableColumnType.FUNCTIONAL_IMPACT].order = 38;
this._columns[MutationTableColumnType.MUTATION_TYPE].order = 40;
this._columns[MutationTableColumnType.COPY_NUM].order = 50;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ export default class StandaloneMutationTable extends MutationTable<IStandaloneMu
MutationTableColumnType.SAMPLE_ID,
MutationTableColumnType.CANCER_TYPE,
MutationTableColumnType.ANNOTATION,
MutationTableColumnType.HGVSG,
MutationTableColumnType.FUNCTIONAL_IMPACT,
MutationTableColumnType.REF_READS_N,
MutationTableColumnType.VAR_READS_N,
Expand Down Expand Up @@ -66,6 +67,7 @@ export default class StandaloneMutationTable extends MutationTable<IStandaloneMu
this._columns[MutationTableColumnType.CANCER_TYPE].order = 15;
this._columns[MutationTableColumnType.PROTEIN_CHANGE].order = 20;
this._columns[MutationTableColumnType.ANNOTATION].order = 30;
this._columns[MutationTableColumnType.HGVSG].order = 35;
this._columns[MutationTableColumnType.FUNCTIONAL_IMPACT].order = 38;
this._columns[MutationTableColumnType.MUTATION_TYPE].order = 40;
//this._columns[MutationTableColumnType.COPY_NUM].order = 50;
Expand Down
11 changes: 11 additions & 0 deletions src/shared/components/mutationTable/MutationTable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ import {IColumnVisibilityControlsProps} from "../columnVisibilityControls/Column
import MobxPromise from "mobxpromise";
import { CancerGene, VariantAnnotation } from "cbioportal-frontend-commons";
import HgvscColumnFormatter from "./column/HgvscColumnFormatter";
import HgvsgColumnFormatter from "./column/HgvsgColumnFormatter";
import GnomadColumnFormatter from "./column/GnomadColumnFormatter";
import ClinVarColumnFormatter from "./column/ClinVarColumnFormatter";
import DbsnpColumnFormatter from "./column/DbsnpColumnFormatter";
Expand Down Expand Up @@ -115,6 +116,7 @@ export enum MutationTableColumnType {
NORMAL_ALLELE_FREQ,
FUNCTIONAL_IMPACT,
ANNOTATION,
HGVSG,
COSMIC,
COPY_NUM,
MRNA_EXPR,
Expand Down Expand Up @@ -500,6 +502,15 @@ export default class MutationTable<P extends IMutationTableProps> extends React.
}
};

this._columns[MutationTableColumnType.HGVSG] = {
name: "HGVSg",
render: (d:Mutation[]) => HgvsgColumnFormatter.renderFunction(d, this.props.genomeNexusCache),
download: (d:Mutation[]) => HgvsgColumnFormatter.download(d, this.props.genomeNexusCache as GenomeNexusCache),
sortBy: (d:Mutation[]) => HgvsgColumnFormatter.getSortValue(d, this.props.genomeNexusCache as GenomeNexusCache),
visible: true,
align: "left"
};

this._columns[MutationTableColumnType.CANCER_TYPE] = {
name: "Cancer Type",
render: (d:Mutation[]) => CancerTypeColumnFormatter.render(d, this.props.uniqueSampleKeyToTumorType),
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
107 changes: 107 additions & 0 deletions src/shared/components/mutationTable/column/HgvsgColumnFormatter.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,107 @@
import * as React from 'react';
import {Circle} from "better-react-spinkit";
import 'rc-tooltip/assets/bootstrap_white.css';
import {Mutation} from "shared/api/generated/CBioPortalAPI";
import {
TableCellStatusIndicator,
TableCellStatus,
VariantAnnotation
} from "cbioportal-frontend-commons";
import GenomeNexusCache, { GenomeNexusCacheDataType } from "shared/cache/GenomeNexusCache";

import hgvsgStyles from "./hgvsg.module.scss";


export default class HgvsgColumnFormatter {

public static renderFunction(data:Mutation[],
genomeNexusCache:GenomeNexusCache|undefined) {
const genomeNexusCacheData = HgvsgColumnFormatter.getGenomeNexusDataFromCache(data, genomeNexusCache);

return <span className={hgvsgStyles["hgvsg-data"]}>{HgvsgColumnFormatter.getHgvsgDataViz(genomeNexusCacheData)}</span>;
}

private static getGenomeNexusDataFromCache(data:Mutation[], cache:GenomeNexusCache|undefined):GenomeNexusCacheDataType | null {
if (data.length === 0 || !cache) {
return null;
}
return cache.get(data[0]);
}

private static getHgvsgDataViz(genomeNexusCacheData:GenomeNexusCacheDataType|null) {
let status:TableCellStatus | null = null;
if (genomeNexusCacheData === null) {
status = TableCellStatus.LOADING;
} else if (genomeNexusCacheData.status === "error") {
status = TableCellStatus.ERROR;
} else if (genomeNexusCacheData.data === null) {
status = TableCellStatus.NA;
} else {
let hgvsgData = HgvsgColumnFormatter.getData(genomeNexusCacheData.data);
if (hgvsgData == null) {
return null;
}
else {
return (
<a href={`https://www.genomenexus.org/variant/${hgvsgData}`} target="_blank" rel="noopener noreferrer">
{hgvsgData}
<img
height='16'
width='16'
src={require("./GenomeNexusLogo.png")}
alt='Genome Nexus'
/>
</a>
);
}
}

if (status !== null) {
// show loading circle
if (status === TableCellStatus.LOADING) {
return <Circle size={18} scaleEnd={0.5} scaleStart={0.2} color="#aaa" className="pull-left"/>;
}
else {
return <TableCellStatusIndicator status={status}/>;
}
}
}

public static getData(genomeNexusData: VariantAnnotation | null): string | null
{
if (!genomeNexusData)
{
return null;
}
return genomeNexusData.hgvsg;
}

public static download(data:Mutation[], genomeNexusCache:GenomeNexusCache): string
{
const genomeNexusData = HgvsgColumnFormatter.getGenomeNexusDataFromCache(data, genomeNexusCache);
const hgvsgData = genomeNexusData && HgvsgColumnFormatter.getData(genomeNexusData.data);

if (!hgvsgData) {
return "";
}
else {
return hgvsgData;
}
}

public static getSortValue(data:Mutation[], genomeNexusCache:GenomeNexusCache): string|null {
const genomeNexusCacheData = HgvsgColumnFormatter.getGenomeNexusDataFromCache(data, genomeNexusCache);
if (genomeNexusCacheData) {
let hgvsgData = HgvsgColumnFormatter.getData(genomeNexusCacheData.data);
if (hgvsgData == null) {
return null
}
else {
return hgvsgData;
}
}
else {
return null;
}
}
}
22 changes: 22 additions & 0 deletions src/shared/components/mutationTable/column/hgvsg.module.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
.hgvsg-data a,
.hgvsg-data a:hover,
.hgvsg-data a:focus,
.hgvsg-data a:active,
.hgvsg-data a:visited {
color: black;
}

.hgvsg-data {
white-space: nowrap;
max-width: 300px;
overflow: hidden;
text-overflow: ellipsis;
display:block;
}

.hgvsg-data:hover {
text-overflow: clip;
word-break: break-all;
overflow: visible;
white-space: normal;
}
13 changes: 12 additions & 1 deletion src/shared/lib/MutationUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,18 @@ export function extractGenomicLocation(mutation: Mutation)
// TODO remove when done refactoring mutation mapper
export function genomicLocationString(genomicLocation: GenomicLocation)
{
return `${genomicLocation.chromosome},${genomicLocation.start},${genomicLocation.end},${genomicLocation.referenceAllele},${genomicLocation.variantAllele}`;
// mapping chromosome X with 23
let chromosome = "";
if (genomicLocation.chromosome === "X") {
chromosome = "23";
}
else if (genomicLocation.chromosome === "Y") {
chromosome = "24";
}
else {
chromosome = genomicLocation.chromosome;
}
return `${chromosome},${genomicLocation.start},${genomicLocation.end},${genomicLocation.referenceAllele},${genomicLocation.variantAllele}`;
}

// TODO remove when done refactoring mutation mapper
Expand Down

0 comments on commit 4d2147e

Please sign in to comment.