Skip to content

Commit

Permalink
Adding Customizable Custom Driver Column to Mutation, CNA, and SV Tab…
Browse files Browse the repository at this point in the history
…le (#4840)

* remove hide_download_control from appContext and fix mutationMapper
* add custom driver/tiers columns
* add driver column with tooptips to SV and CNA table
* hide annotation and sort with custom driver column
* use existing oncoprint custom driver menu label and fix visibility and sorting issues
* support default sort column in tables and remove visible check on AnnotationColumnFormatter
* fix hide-download-controls.spec.js failed tests

---------

Co-authored-by: Qi-Xuan Lu <[email protected]>
  • Loading branch information
7xuanlu and qlu-cls authored Mar 1, 2024
1 parent 32de3d5 commit 0b095b1
Show file tree
Hide file tree
Showing 41 changed files with 900 additions and 50 deletions.
6 changes: 3 additions & 3 deletions end-to-end-test/local/specs/core/patientview.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -365,13 +365,13 @@ describe('patient view page', function() {
const mutationsTable = '[data-test=patientview-mutation-table]';
$(`${mutationsTable} button#dropdown-custom-1`).click();
$(`${mutationsTable} ul.dropdown-menu`)
.$$('li label input')[19]
.$$('li label input')[21]
.click();
$(`${mutationsTable} ul.dropdown-menu`)
.$$('li label input')[20]
.$$('li label input')[22]
.click();
$(`${mutationsTable} ul.dropdown-menu`)
.$$('li label input')[21]
.$$('li label input')[23]
.click();
$(`${mutationsTable} button#dropdown-custom-1`).click();
});
Expand Down
2 changes: 2 additions & 0 deletions end-to-end-test/local/specs/hide-download-controls.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -254,6 +254,7 @@ describe('hide download controls feature', function() {
it('global check for icon and occurrence of "Download" as a word', () => {
$('.tabAnchor_clinical').click();
$('[data-test=ClinicalTabPlotDiv]').waitForExist();
$('[data-test=LazyMobXTable]').waitForExist();
globalCheck();
});
});
Expand Down Expand Up @@ -609,6 +610,7 @@ describe('hide download controls feature', function() {
describe('clinical tab', () => {
it('global check for icon and occurrence of "Download" as a word', () => {
$('.tabAnchor_clinical').click();
$('[data-test=LazyMobXTable]').waitForExist();
$('[data-test=ClinicalTabPlotDiv]').waitForExist();
globalCheck();
});
Expand Down
Original file line number Diff line number Diff line change
@@ -1,17 +1,7 @@
import React, { Context } from 'react';

export enum DownloadControlOption {
SHOW_ALL = 'show',
HIDE_DATA = 'data',
HIDE_ALL = 'hide',
}

export interface IAppContext {
showDownloadControls: DownloadControlOption;
}
export interface IAppContext {}

export const AppContext: Context<IAppContext> = React.createContext<
IAppContext
>({
showDownloadControls: DownloadControlOption.SHOW_ALL,
});
>({});
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ import { saveSvg, saveSvgAsPng } from 'save-svg-as-png';
import svgToPdfDownload from '../../lib/svgToPdfDownload';
import { CSSProperties } from 'react';
import { isPromiseLike } from 'cbioportal-utils';
import { AppContext, DownloadControlOption } from '../appContext/AppContext';

type ButtonSpec = {
key: string;
Expand All @@ -30,6 +29,12 @@ export type DownloadControlsButton =

export type DataType = 'summary' | 'full';

export enum DownloadControlOption {
SHOW_ALL = 'show',
HIDE_DATA = 'data',
HIDE_ALL = 'hide',
}

interface IDownloadControlsProps {
getSvg?: () => SVGElement | null | PromiseLike<SVGElement | null>;
getData?: (
Expand Down Expand Up @@ -306,9 +311,7 @@ export default class DownloadControls extends React.Component<
}

render() {
if (
this.context.showDownloadControls === DownloadControlOption.HIDE_ALL
) {
if (this.showDownload === false) {
return null;
}

Expand Down Expand Up @@ -421,5 +424,3 @@ export default class DownloadControls extends React.Component<
}
}
}

DownloadControls.contextType = AppContext;
1 change: 1 addition & 0 deletions packages/cbioportal-frontend-commons/src/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ export {
default as DownloadControls,
DataType,
DownloadControlsButton,
DownloadControlOption,
} from './components/downloadControls/DownloadControls';
export { default as EditableSpan } from './components/editableSpan/EditableSpan';
export { default as EllipsisTextTooltip } from './components/ellipsisTextTooltip/EllipsisTextTooltip';
Expand Down
6 changes: 1 addition & 5 deletions src/appShell/App/Container.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ import {
import makeRoutes from 'routes';
import { AppContext } from 'cbioportal-frontend-commons';
import { IAppContext } from 'cbioportal-frontend-commons';
import { DownloadControlOption } from 'cbioportal-frontend-commons';
import { ErrorAlert } from 'shared/components/errorScreen/ErrorAlert';
import { ErrorInfo } from 'react';
import { observable } from 'mobx';
Expand Down Expand Up @@ -69,10 +68,7 @@ export default class Container extends React.Component<IContainerProps, {}> {
}

get appContext(): IAppContext {
return {
showDownloadControls: getServerConfig()
.skin_hide_download_controls as DownloadControlOption,
};
return {};
}

render() {
Expand Down
8 changes: 6 additions & 2 deletions src/config/IAppConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,10 @@ export interface IServerConfig {
app_version: string | null; // default: "1.0"
authenticationMethod: string | undefined;
bitly_access_token: string | null;
oncoprint_custom_driver_annotation_binary_menu_label: string | null; // default:
oncoprint_custom_driver_annotation_binary_menu_label: string | null;
oncoprint_custom_driver_annotation_binary_menu_description: string | null;
oncoprint_custom_driver_annotation_tiers_menu_label: string | null;
oncoprint_custom_driver_annotation_tiers_menu_description: string | null;
disabled_tabs: string | null;
custom_tabs: any[];
custom_js_urls: string; // comma delimited string
Expand Down Expand Up @@ -137,7 +140,6 @@ export interface IServerConfig {
studiesWithGermlineConsentedSamples: string[] | undefined;
mdacc_heatmap_study_meta_url: string | null;
mdacc_heatmap_study_url: string | null;
oncoprint_custom_driver_annotation_tiers_menu_label: string | null;
enable_darwin: boolean;
query_sets_of_genes: string | null;
skin_quick_select_buttons: string | null;
Expand Down Expand Up @@ -170,6 +172,8 @@ export interface IServerConfig {
skin_comparison_view_mutation_table_columns_show_on_init: string;
skin_patient_view_copy_number_table_columns_show_on_init: string;
skin_patient_view_structural_variant_table_columns_show_on_init: string;
skin_results_view_tables_default_sort_column: string;
skin_patient_view_tables_default_sort_column: string;
skin_patient_view_custom_sample_type_colors_json: string;
comparison_categorical_na_values: string;
oncoprint_clinical_tracks_config_json: string;
Expand Down
13 changes: 10 additions & 3 deletions src/config/serverConfigDefaults.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,12 @@ export const ServerConfigDefaults: Partial<IServerConfig> = {
mygene_info_url:
'https://mygene.info/v3/gene/<%= entrezGeneId %>?fields=uniprot',

oncoprint_custom_driver_annotation_binary_menu_label:
'Custom driver annotations',
oncoprint_custom_driver_annotation_tiers_menu_label: 'Driver tiers',
oncoprint_custom_driver_annotation_binary_menu_label: 'Custom Driver',
oncoprint_custom_driver_annotation_binary_menu_description:
'Custom driver annotation',
oncoprint_custom_driver_annotation_tiers_menu_label: 'Custom Driver Tiers',
oncoprint_custom_driver_annotation_tiers_menu_description:
'Custom driver tiers',
oncoprint_custom_driver_annotation_binary_default: true,
oncoprint_custom_driver_annotation_tiers_default: true,
oncoprint_oncokb_default: true,
Expand Down Expand Up @@ -221,6 +224,10 @@ export const ServerConfigDefaults: Partial<IServerConfig> = {

skin_patient_view_structural_variant_table_columns_show_on_init: '',

skin_results_view_tables_default_sort_column: 'Annotation',

skin_patient_view_tables_default_sort_column: 'Annotation',

skin_patient_view_custom_sample_type_colors_json: '',

studyview_max_samples_selected: 0,
Expand Down
11 changes: 10 additions & 1 deletion src/pages/groupComparison/ClinicalData.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,11 @@ import {
import { SimpleGetterLazyMobXTableApplicationDataStore } from 'shared/lib/ILazyMobXTableApplicationDataStore';
import ClinicalDataEnrichmentsTable from './ClinicalDataEnrichmentsTable';
import _ from 'lodash';
import { DownloadControls, remoteData } from 'cbioportal-frontend-commons';
import {
DownloadControlOption,
DownloadControls,
remoteData,
} from 'cbioportal-frontend-commons';
import { getRemoteDataGroupStatus } from 'cbioportal-utils';
import client from 'shared/api/cbioportalClientInstance';
import {
Expand Down Expand Up @@ -60,6 +64,7 @@ import CategoryPlot, {
CategoryPlotType,
} from 'pages/groupComparison/CategoryPlot';
import { OncoprintJS } from 'oncoprintjs';
import { getServerConfig } from 'config/config';

export interface IClinicalDataProps {
store: ComparisonStore;
Expand Down Expand Up @@ -975,6 +980,10 @@ export default class ClinicalData extends React.Component<
dontFade={true}
type="button"
style={{ position: 'absolute', right: 0, top: 0 }}
showDownload={
getServerConfig().skin_hide_download_controls ===
DownloadControlOption.SHOW_ALL
}
/>
</div>
);
Expand Down
6 changes: 6 additions & 0 deletions src/pages/groupComparison/GroupComparisonMutationMapper.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,12 @@ export default class GroupComparisonMutationMapper extends MutationMapper<
rowDataByProteinChange={this.rowDataByProteinChange}
initialSortColumn={'p-Value'}
initialSortDirection={'asc'}
customDriverName={this.props.customDriverName}
customDriverDescription={this.props.customDriverDescription}
customDriverTiersName={this.props.customDriverTiersName}
customDriverTiersDescription={
this.props.customDriverTiersDescription
}
/>
);
}
Expand Down
4 changes: 4 additions & 0 deletions src/pages/groupComparison/GroupComparisonMutationTable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,8 @@ export default class GroupComparisonMutationTable extends MutationTable<
...MutationTable.defaultProps,
columns: [
MutationTableColumnType.ANNOTATION,
MutationTableColumnType.CUSTOM_DRIVER,
MutationTableColumnType.CUSTOM_DRIVER_TIER,
MutationTableColumnType.MUTATION_STATUS,
MutationTableColumnType.PROTEIN_CHANGE,
MutationTableColumnType.MUTATION_TYPE,
Expand Down Expand Up @@ -357,6 +359,8 @@ export default class GroupComparisonMutationTable extends MutationTable<
// order columns
this._columns[MutationTableColumnType.PROTEIN_CHANGE].order = 10;
this._columns[MutationTableColumnType.ANNOTATION].order = 20;
this._columns[MutationTableColumnType.CUSTOM_DRIVER].order = 25;
this._columns[MutationTableColumnType.CUSTOM_DRIVER_TIER].order = 26;
this._columns[MutationTableColumnType.MUTATION_TYPE].order = 30;
this._columns[MutationTableColumnType.NUM_MUTATED_GROUP_A].order = 40;
this._columns[MutationTableColumnType.NUM_MUTATED_GROUP_B].order = 50;
Expand Down
49 changes: 49 additions & 0 deletions src/pages/patientView/PatientViewPageTabs.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -333,6 +333,7 @@ export function tabs(
onSelectGenePanel={pageComponent.toggleGenePanelModal}
mergeOncoKbIcons={pageComponent.mergeMutationTableOncoKbIcons}
onOncoKbIconToggle={pageComponent.handleOncoKbIconToggle}
enableOncoKb={getServerConfig().show_oncokb}
sampleIds={
sampleManager
? sampleManager.getActiveSampleIdsInOrder()
Expand All @@ -342,6 +343,22 @@ export function tabs(
pageComponent.patientViewPageStore.namespaceColumnConfig
.structVar
}
customDriverName={
getServerConfig()
.oncoprint_custom_driver_annotation_binary_menu_label!
}
customDriverDescription={
getServerConfig()
.oncoprint_custom_driver_annotation_binary_menu_description!
}
customDriverTiersName={
getServerConfig()
.oncoprint_custom_driver_annotation_tiers_menu_label!
}
customDriverTiersDescription={
getServerConfig()
.oncoprint_custom_driver_annotation_tiers_menu_description!
}
/>

<hr />
Expand Down Expand Up @@ -407,6 +424,22 @@ export function tabs(
pageComponent.patientViewPageStore
.namespaceColumnConfig.cna
}
customDriverName={
getServerConfig()
.oncoprint_custom_driver_annotation_binary_menu_label!
}
customDriverDescription={
getServerConfig()
.oncoprint_custom_driver_annotation_binary_menu_description!
}
customDriverTiersName={
getServerConfig()
.oncoprint_custom_driver_annotation_tiers_menu_label!
}
customDriverTiersDescription={
getServerConfig()
.oncoprint_custom_driver_annotation_tiers_menu_description!
}
/>
</If>
</div>
Expand Down Expand Up @@ -434,6 +467,22 @@ export function tabs(
pageComponent.mergeMutationTableOncoKbIcons
}
onOncoKbIconToggle={pageComponent.handleOncoKbIconToggle}
customDriverName={
getServerConfig()
.oncoprint_custom_driver_annotation_binary_menu_label!
}
customDriverDescription={
getServerConfig()
.oncoprint_custom_driver_annotation_binary_menu_description!
}
customDriverTiersName={
getServerConfig()
.oncoprint_custom_driver_annotation_tiers_menu_label!
}
customDriverTiersDescription={
getServerConfig()
.oncoprint_custom_driver_annotation_tiers_menu_description!
}
/>
</MSKTab>
);
Expand Down
Loading

0 comments on commit 0b095b1

Please sign in to comment.