Skip to content

Commit

Permalink
Added Gene panel column to tables in Patient View
Browse files Browse the repository at this point in the history
  • Loading branch information
Ngoc Nguyen authored and ngocnn1104 committed Oct 22, 2019
1 parent 5e96142 commit f5ba1e6
Show file tree
Hide file tree
Showing 6 changed files with 143 additions and 2 deletions.
1 change: 1 addition & 0 deletions src/pages/patientView/PatientViewPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -547,6 +547,7 @@ export default class PatientViewPage extends React.Component<IPatientViewPagePro
columnVisibilityProps={{
onColumnToggled: this.onCnaTableColumnVisibilityToggled
}}
sampleToMutationGenePanelId={patientViewPageStore.sampleToMutationGenePanelId}
/>
</div>
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import CopyNumberCountCache from "../clinicalInformation/CopyNumberCountCache";
import {ICivicGeneDataWrapper, ICivicVariantDataWrapper} from "shared/model/Civic.ts";
import HeaderIconMenu from '../mutation/HeaderIconMenu';
import GeneFilterMenu, { GeneFilterOption } from '../mutation/GeneFilterMenu';
import PanelColumnFormatter from "shared/components/mutationTable/column/PanelColumnFormatter";

class CNATableComponent extends LazyMobXTable<DiscreteCopyNumberData[]> {

Expand Down Expand Up @@ -55,6 +56,7 @@ type ICopyNumberTableWrapperProps = {
showGeneFilterMenu?:boolean;
currentGeneFilter:GeneFilterOption;
onFilterGenes?:(option:GeneFilterOption)=>void;
sampleToMutationGenePanelId?: {[sampleId:string]:string};
};

@observer
Expand Down Expand Up @@ -112,6 +114,15 @@ export default class CopyNumberTableWrapper extends React.Component<ICopyNumberT
visible: true,
order: 30
});

columns.push({
name: "Gene panel",
render: (d:DiscreteCopyNumberData[]) => PanelColumnFormatter.renderFunction(d, this.props.sampleToMutationGenePanelId),
download: (d:DiscreteCopyNumberData[]) => PanelColumnFormatter.download(d, this.props.sampleToMutationGenePanelId),
sortBy: (d:DiscreteCopyNumberData[]) => PanelColumnFormatter.getGenePanelIds(d, this.props.sampleToMutationGenePanelId),
visible: false,
order: 35
});

columns.push({
name: "CNA",
Expand Down
13 changes: 12 additions & 1 deletion src/pages/patientView/mutation/PatientViewMutationTable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import {Mutation} from "shared/api/generated/CBioPortalAPI";
import AlleleCountColumnFormatter from "shared/components/mutationTable/column/AlleleCountColumnFormatter";
import AlleleFreqColumnFormatter from "./column/AlleleFreqColumnFormatter";
import TumorColumnFormatter from "./column/TumorColumnFormatter";
import PanelColumnFormatter from "shared/components/mutationTable/column/PanelColumnFormatter";
import {isUncalled} from "shared/lib/MutationUtils";
import TumorAlleleFreqColumnFormatter from "shared/components/mutationTable/column/TumorAlleleFreqColumnFormatter";
import ExonColumnFormatter from "shared/components/mutationTable/column/ExonColumnFormatter";
Expand Down Expand Up @@ -66,7 +67,8 @@ export default class PatientViewMutationTable extends MutationTable<IPatientView
MutationTableColumnType.HGVSC,
MutationTableColumnType.GNOMAD,
MutationTableColumnType.CLINVAR,
MutationTableColumnType.DBSNP
MutationTableColumnType.DBSNP,
MutationTableColumnType.GENE_PANEL
]
};

Expand Down Expand Up @@ -98,6 +100,14 @@ export default class PatientViewMutationTable extends MutationTable<IPatientView
sortBy:(d:Mutation[])=>TumorColumnFormatter.getSortValue(d, this.props.sampleManager),
download: (d:Mutation[])=>TumorColumnFormatter.getSample(d),
};

this._columns[MutationTableColumnType.GENE_PANEL] = {
name: "Gene panel",
render: (d:Mutation[]) => PanelColumnFormatter.renderFunction(d, this.props.sampleToMutationGenePanelId),
download: (d:Mutation[]) => PanelColumnFormatter.download(d, this.props.sampleToMutationGenePanelId),
visible: false,
sortBy: (d:Mutation[]) => PanelColumnFormatter.getGenePanelIds(d, this.props.sampleToMutationGenePanelId)
}

// customization for allele count columns

Expand Down Expand Up @@ -136,6 +146,7 @@ export default class PatientViewMutationTable extends MutationTable<IPatientView
// order columns
this._columns[MutationTableColumnType.SAMPLES].order = 5;
this._columns[MutationTableColumnType.GENE].order = 20;
this._columns[MutationTableColumnType.GENE_PANEL].order = 25;
this._columns[MutationTableColumnType.PROTEIN_CHANGE].order = 30;
this._columns[MutationTableColumnType.ANNOTATION].order = 35;
this._columns[MutationTableColumnType.FUNCTIONAL_IMPACT].order = 38;
Expand Down
4 changes: 3 additions & 1 deletion src/shared/components/mutationTable/MutationTable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ export interface IMutationTableProps {
showCountHeader?:boolean;
columnVisibility?: {[columnId: string]: boolean};
columnVisibilityProps?: IColumnVisibilityControlsProps;
sampleToMutationGenePanelId?: {[sampleId:string]: string};
}

export enum MutationTableColumnType {
Expand Down Expand Up @@ -130,7 +131,8 @@ export enum MutationTableColumnType {
HGVSC,
GNOMAD,
CLINVAR,
DBSNP
DBSNP,
GENE_PANEL
}

type MutationTableColumn = Column<Mutation[]>&{order?:number, shouldExclude?:()=>boolean};
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
import PanelColumnFormatter from "./PanelColumnFormatter";
import { shallow } from "enzyme";
import { assert } from 'chai';

const mockData = [
{
alteration: 1,
entrezGeneId: 1,
gene: {
entrezGeneId: 1,
hugoGeneSymbol: 'test',
geneticEntityId: 1,
type: 'test'
},
molecularProfileId: 'test',
patientId: 'test',
sampleId: 'sampleId',
studyId: 'test',
uniquePatientKey: 'test',
uniqueSampleKey: 'test',
}
];

const mockSampleToMutationGenePanelId = { 'sampleId': 'genePanelId' };

describe("PanelColumnFormatter", () => {
it('renders spinner icon if sampleToMutationGenePanelId object is empty', () => {
const PanelColumn = shallow(PanelColumnFormatter.renderFunction(mockData, {}));
assert.isTrue(PanelColumn.find('i.fa-spinner').exists());
});

it('renders gene panel information', () => {
const PanelColumn = shallow(PanelColumnFormatter.renderFunction(
mockData,
mockSampleToMutationGenePanelId
));
assert.isTrue(PanelColumn.text().includes('genePanelId'));
});

it('returns a list of gene panel ids on download', () => {
const genePanelIds = PanelColumnFormatter.download(mockData, mockSampleToMutationGenePanelId);
assert.deepEqual(genePanelIds, ['genePanelId'])
});

it('returns a list of gene panel ids on getGenePanelIds', () => {
const genePanelIds = PanelColumnFormatter.getGenePanelIds(mockData, mockSampleToMutationGenePanelId);
assert.deepEqual(genePanelIds, ['genePanelId'])
})
})
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
import * as React from 'react';
import {
Mutation,
DiscreteCopyNumberData
} from 'shared/api/generated/CBioPortalAPI';

interface PanelColumnFormatterProps {
data: Mutation[] | DiscreteCopyNumberData[];
sampleToMutationGenePanelId: {[sampleId:string]: string} | undefined;
}

class PanelColumn extends React.Component<PanelColumnFormatterProps, {}> {
constructor(props: PanelColumnFormatterProps) {
super(props);
}

render() {
const { data, sampleToMutationGenePanelId } = this.props;

if (!sampleToMutationGenePanelId) return;

if (sampleToMutationGenePanelId && !Object.keys(sampleToMutationGenePanelId).length) {
return <i className='fa fa-spinner fa-pulse' />;
}

const genePanelIds: string[] = getGenePanelIds(
data,
sampleToMutationGenePanelId
);

return (
<div style={{ position: 'relative' }}>
<ul style={{ marginBottom: 0 }} className='list-inline list-unstyled'>
{genePanelIds.join(', ')}
</ul>
</div>
);
}
}

const getGenePanelIds = (
data: any[],
sampleToMutationGenePanelId: {[sampleId:string]: string} | undefined
) => {
if (sampleToMutationGenePanelId) {
const sampleIds = data.map((datum) => datum.sampleId);
return sampleIds.map((id) => sampleToMutationGenePanelId[id]);
}
return [];
};

export default {
renderFunction: (
data: Mutation[] | DiscreteCopyNumberData[],
sampleToMutationGenePanelId: {[sampleId:string]: string} | undefined
) => (
<PanelColumn
data={data}
sampleToMutationGenePanelId={sampleToMutationGenePanelId}
/>
),
download: (
data: Mutation[] | DiscreteCopyNumberData[],
sampleToMutationGenePanelId: {[sampleId:string]: string} | undefined
) => getGenePanelIds(data, sampleToMutationGenePanelId),
getGenePanelIds
};

0 comments on commit f5ba1e6

Please sign in to comment.