From 2cba9154937e69d5194bd10757b63f63f475c5b8 Mon Sep 17 00:00:00 2001 From: alisman Date: Fri, 4 Nov 2022 15:55:34 -0400 Subject: [PATCH] Do not allow expression profiles in results view unless studies are "comparable" --- src/pages/resultsView/ResultsViewPageStore.ts | 39 ++++++++++++++++++- src/pages/resultsView/plots/PlotsTab.tsx | 29 +++++++++++++- 2 files changed, 65 insertions(+), 3 deletions(-) diff --git a/src/pages/resultsView/ResultsViewPageStore.ts b/src/pages/resultsView/ResultsViewPageStore.ts index 2d8bcb8edf2..087bb0917ab 100644 --- a/src/pages/resultsView/ResultsViewPageStore.ts +++ b/src/pages/resultsView/ResultsViewPageStore.ts @@ -421,6 +421,31 @@ export type GeneticEntity = { geneticEntityData: Gene | Geneset; }; +// this can be adapted to consume new profile membership data +export function allowExpressionProfiles( + studies: CancerStudy[], + profiles: MolecularProfile[] +) { + if (getServerConfig().app_name === 'public-portal') { + if (studies.length === 1) { + return true; + } else { + return ( + profiles.length === 1 || + _(profiles) + .filter( + p => + p.molecularAlterationType === + AlterationTypeConstants.MRNA_EXPRESSION + ) + .every(p => /pan_can_atlas/.test(p.molecularProfileId)) + ); + } + } else { + return true; + } +} + export function buildDefaultOQLProfile( profilesTypes: string[], zScoreThreshold: number, @@ -4328,11 +4353,23 @@ export class ResultsViewPageStore { await: () => [this.studyIds], invoke: async () => { - return client.fetchMolecularProfilesUsingPOST({ + let profiles = await client.fetchMolecularProfilesUsingPOST({ molecularProfileFilter: { studyIds: this.studyIds.result!, } as MolecularProfileFilter, }); + + // expression profiles are not allowed + // under some circumstances + if (allowExpressionProfiles(this.studies.result, profiles)) { + return profiles; + } else { + return profiles.filter( + p => + p.molecularAlterationType !== + AlterationTypeConstants.MRNA_EXPRESSION + ); + } }, }, [] diff --git a/src/pages/resultsView/plots/PlotsTab.tsx b/src/pages/resultsView/plots/PlotsTab.tsx index 3f0f00e876f..50ac2255ce0 100644 --- a/src/pages/resultsView/plots/PlotsTab.tsx +++ b/src/pages/resultsView/plots/PlotsTab.tsx @@ -9,7 +9,10 @@ import { } from 'mobx'; import { Observer, observer } from 'mobx-react'; import './styles.scss'; -import { ResultsViewPageStore } from '../ResultsViewPageStore'; +import { + allowExpressionProfiles, + ResultsViewPageStore, +} from '../ResultsViewPageStore'; import { AlterationTypeConstants, DataTypeConstants } from 'shared/constants'; import { Button, FormControl } from 'react-bootstrap'; import ReactSelect from 'react-select1'; @@ -789,7 +792,18 @@ export default class PlotsTab extends React.Component { } // otherwise, pick the default based on available options const dataTypeOptions = dataTypeOptionsPromise.result!; - if (this._dataType === undefined && dataTypeOptions.length) { + + // due to legacy urls, it's possible that selections can be made which + // are no longer avaiable. this handles that case + const selectedDataTypeDoesNotExists = !_.some( + dataTypeOptions, + o => o.value === this._dataType + ); + + if ( + (this._dataType === undefined && dataTypeOptions.length) || + selectedDataTypeDoesNotExists + ) { // return computed default if _dataType is undefined and if there are options to select a default value from if ( isAlterationTypePresent( @@ -5486,6 +5500,17 @@ export default class PlotsTab extends React.Component { store={this.props.store} tabReflectsOql={false} /> + + {allowExpressionProfiles( + this.props.store.studies.result, + this.props.store.molecularProfilesInStudies.result + ) && ( +
+ Expression data cannot be compared across the + selected studies. +
+ )} +