Skip to content

Commit

Permalink
Change Y Label for Survival Charts
Browse files Browse the repository at this point in the history
This makes the Y Label a little cleaner. Since both the X axis and the
title already mention the additional info it is not necessary to repeat
it in the y axis. This was proposed by stats team that evaluates the
GENIE BPC data. Addresses part of
https://github.com/cBioPortal/cbioportal/issues/8904.
  • Loading branch information
inodb committed Sep 24, 2021
1 parent b92e08b commit 701f0cb
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 3 deletions.
30 changes: 29 additions & 1 deletion src/pages/groupComparison/Survival.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ import {
SURVIVAL_PLOT_X_LABEL_WITH_EVENT_TOOLTIP,
SURVIVAL_PLOT_X_LABEL_WITHOUT_EVENT_TOOLTIP,
SURVIVAL_PLOT_Y_LABEL_TOOLTIP,
generateSurvivalPlotYAxisLabelFromDisplayName,
} from 'pages/resultsView/survival/SurvivalUtil';
import { observable, action, makeObservable } from 'mobx';
import survivalPlotStyle from './styles.module.scss';
Expand Down Expand Up @@ -484,6 +485,31 @@ export default class Survival extends React.Component<ISurvivalProps, {}> {
),
});

readonly survivalYLabel = remoteData({
await: () => [
this.props.store.survivalClinicalAttributesPrefix,
this.props.store.survivalDescriptions,
],
invoke: () =>
Promise.resolve(
this.props.store.survivalClinicalAttributesPrefix.result!.reduce(
(map, prefix) => {
// get survival plot titles
// use first display name as title
map[
prefix
] = generateSurvivalPlotYAxisLabelFromDisplayName(
this.props.store.survivalDescriptions.result![
prefix
][0].displayName
);
return map;
},
{} as { [prefix: string]: string }
)
),
});

readonly survivalUI = MakeMobxView({
await: () => [
this.props.store.survivalDescriptions,
Expand All @@ -495,6 +521,7 @@ export default class Survival extends React.Component<ISurvivalProps, {}> {
this.props.store.overlapComputations,
this.props.store.uidToGroup,
this.survivalTitleText,
this.survivalYLabel,
this.sortedGroupedSurvivals,
this.pValuesByPrefix,
],
Expand All @@ -507,6 +534,7 @@ export default class Survival extends React.Component<ISurvivalProps, {}> {
.result!.patientToAnalysisGroups;
const attributeDescriptions: { [prefix: string]: string } = {};
const survivalTitleText = this.survivalTitleText.result!;
const survivalYLabel = this.survivalYLabel.result!;
this.props.store.survivalClinicalAttributesPrefix.result!.forEach(
prefix => {
// get attribute description
Expand Down Expand Up @@ -613,7 +641,7 @@ export default class Survival extends React.Component<ISurvivalProps, {}> {
.survivalXAxisLabelGroupByPrefix
.result![key]
}
yAxisLabel={survivalTitleText[key]}
yAxisLabel={survivalYLabel[key]}
totalCasesHeader="Number of Cases, Total"
statusCasesHeader="Number of Events"
medianMonthsHeader={`Median Months ${survivalTitleText[key]} (95% CI)`}
Expand Down
16 changes: 14 additions & 2 deletions src/pages/resultsView/survival/SurvivalUtil.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -522,8 +522,20 @@ export function getSurvivalChartDataByAlteredStatus(
};
}

export function generateSurvivalPlotTitleFromDisplayName(title: string) {
return title.replace(/status|survival/gi, '');
export function generateSurvivalPlotTitleFromDisplayName(displayName: string) {
return displayName.replace(/status|survival/gi, '');
}

export function generateSurvivalPlotYAxisLabelFromDisplayName(
displayName: string
) {
if (displayName.includes('OS ') || displayName.includes('Overall')) {
return 'Probability of Overall Survival';
} else if (displayName.includes('PFS')) {
return 'Probability of Progression-Free Survival';
} else {
return generateSurvivalPlotTitleFromDisplayName(displayName);
}
}

export function generateStudyViewSurvivalPlotTitle(title: string) {
Expand Down

0 comments on commit 701f0cb

Please sign in to comment.