Skip to content

Commit

Permalink
Do not allow expression profiles in results view unless studies are "…
Browse files Browse the repository at this point in the history
…comparable"
  • Loading branch information
alisman committed Nov 11, 2022
1 parent bc1edf8 commit 2cba915
Show file tree
Hide file tree
Showing 2 changed files with 65 additions and 3 deletions.
39 changes: 38 additions & 1 deletion src/pages/resultsView/ResultsViewPageStore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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
);
}
},
},
[]
Expand Down
29 changes: 27 additions & 2 deletions src/pages/resultsView/plots/PlotsTab.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -789,7 +792,18 @@ export default class PlotsTab extends React.Component<IPlotsTabProps, {}> {
}
// 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(
Expand Down Expand Up @@ -5486,6 +5500,17 @@ export default class PlotsTab extends React.Component<IPlotsTabProps, {}> {
store={this.props.store}
tabReflectsOql={false}
/>

{allowExpressionProfiles(
this.props.store.studies.result,
this.props.store.molecularProfilesInStudies.result
) && (
<div className={'alert alert-info'}>
Expression data cannot be compared across the
selected studies.
</div>
)}

<AlterationFilterWarning
store={this.props.store}
isUnaffected={true}
Expand Down

0 comments on commit 2cba915

Please sign in to comment.