Skip to content

Commit

Permalink
Specify unprofiled in any or unprofiled in every for results view fil…
Browse files Browse the repository at this point in the history
…tering

Signed-off-by: Adam Abeshouse <abeshoua@mskcc.org>
  • Loading branch information
Adam Abeshouse committed Aug 19, 2021
1 parent 9c77447 commit 1fb506c
Show file tree
Hide file tree
Showing 5 changed files with 126 additions and 38 deletions.
69 changes: 55 additions & 14 deletions src/pages/resultsView/ResultsViewPageStore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -521,7 +521,9 @@ export type ModifyQueryParams = {

interface IResultsViewExclusionSettings {
setExcludeGermlineMutations: (value: boolean) => void;
setHideUnprofiledSamples: (value: boolean) => void;
setHideUnprofiledSamples: (
value: IAnnotationFilterSettings['hideUnprofiledSamples']
) => void;
}

/* fields and methods in the class below are ordered based on roughly
Expand Down Expand Up @@ -701,17 +703,24 @@ export class ResultsViewPageStore

@computed
public get hideUnprofiledSamples() {
return this.urlWrapper.query.hide_unprofiled_samples === 'true';
const value = this.urlWrapper.query.hide_unprofiled_samples;
if (value === 'any' || value === 'totally') {
return value;
} else {
return false;
}
}

@action.bound
public setHideUnprofiledSamples(e: boolean) {
public setHideUnprofiledSamples(
e: IAnnotationFilterSettings['hideUnprofiledSamples']
) {
this.urlWrapper.updateURL({
hide_unprofiled_samples: e.toString(),
hide_unprofiled_samples: (e || false).toString(),
});
}

public set hideUnprofiledSamples(include: boolean) {
public set hideUnprofiledSamples(include: 'any' | 'totally' | false) {
this.setHideUnprofiledSamples(include);
}

Expand Down Expand Up @@ -3810,11 +3819,23 @@ export class ResultsViewPageStore
});

readonly filteredSamples = remoteData({
await: () => [this.samples, this.unprofiledSampleKeyToSample],
await: () => [
this.samples,
this.unprofiledSampleKeyToSample,
this.totallyUnprofiledSamples,
],
invoke: () => {
if (this.hideUnprofiledSamples) {
const unprofiledSampleKeys = this.unprofiledSampleKeyToSample
.result!;
let unprofiledSampleKeys: { [key: string]: Sample };
if (this.hideUnprofiledSamples === 'any') {
unprofiledSampleKeys = this.unprofiledSampleKeyToSample
.result!;
} else if (this.hideUnprofiledSamples === 'totally') {
unprofiledSampleKeys = _.keyBy(
this.totallyUnprofiledSamples.result!,
s => s.uniqueSampleKey
);
}
return Promise.resolve(
this.samples.result!.filter(
s => !(s.uniqueSampleKey in unprofiledSampleKeys)
Expand All @@ -3837,19 +3858,29 @@ export class ResultsViewPageStore
// Samples that are unprofiled for at least one (gene, profile)
const genes = this.genes.result!;
const coverageInfo = this.coverageInformation.result!;
const queryProfileIds = this.selectedMolecularProfiles.result!.map(
p => p.molecularProfileId
const studyToSelectedMolecularProfileIds = _.mapValues(
_.groupBy(
this.selectedMolecularProfiles.result!,
p => p.studyId
),
profiles => profiles.map(p => p.molecularProfileId)
);

return Promise.resolve(
this.samples.result!.filter(sample => {
// Only look at profiles for this sample's study - doesn't
// make sense to look at profiles for other studies, which
// the sample certainly is not part of.
const profileIds =
studyToSelectedMolecularProfileIds[sample.studyId];

// Sample that is unprofiled for some gene
return _.some(genes, gene => {
// for some profile
return !_.every(
isSampleProfiledInMultiple(
sample.uniqueSampleKey,
queryProfileIds,
profileIds,
coverageInfo,
gene.hugoGeneSymbol
)
Expand All @@ -3870,19 +3901,29 @@ export class ResultsViewPageStore
invoke: () => {
const genes = this.genes.result!;
const coverageInfo = this.coverageInformation.result!;
const queryProfileIds = this.selectedMolecularProfiles.result!.map(
p => p.molecularProfileId
const studyToSelectedMolecularProfileIds = _.mapValues(
_.groupBy(
this.selectedMolecularProfiles.result!,
p => p.studyId
),
profiles => profiles.map(p => p.molecularProfileId)
);

return Promise.resolve(
this.unprofiledSamples.result!.filter(sample => {
// Only look at profiles for this sample's study - doesn't
// make sense to look at profiles for other studies, which
// the sample certainly is not part of.
const profileIds =
studyToSelectedMolecularProfileIds[sample.studyId];

// Among unprofiled samples, pick out samples that are unprofiled for EVERY gene ...(gene x profile)
return _.every(genes, gene => {
// for EVERY profile
return !_.some(
isSampleProfiledInMultiple(
sample.uniqueSampleKey,
queryProfileIds,
profileIds,
coverageInfo,
gene.hugoGeneSymbol
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ export function getAlteredVsUnalteredGroups(
unalteredAndProfiledSamples: Sample[],
totallyUnprofiledSamples: Sample[],
queryContainsOql: boolean,
hideUnprofiledSamples: boolean
hideUnprofiledSamples: 'any' | 'totally' | false
): SessionGroupData[] {
const ret = [];
if (alteredSamples.length > 0) {
Expand Down Expand Up @@ -106,7 +106,10 @@ export function getAlteredVsUnalteredGroups(
color: UNALTERED_COLOR,
});
}
if (totallyUnprofiledSamples.length > 0 && !hideUnprofiledSamples) {
if (
totallyUnprofiledSamples.length > 0 &&
hideUnprofiledSamples !== 'totally'
) {
ret.push({
name: UNPROFILED_GROUP_NAME,
description: `${
Expand Down
81 changes: 65 additions & 16 deletions src/pages/resultsView/settings/SettingsMenu.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ enum EVENT_KEY {
hidePutativePassengers = '0',
showGermlineMutations = '1',
hideUnprofiledSamples = '1.1',
hideAnyUnprofiledSamples = '1.2',
hideTotallyUnprofiledSamples = '1.3',

dataTypeSample = '2',
dataTypePatient = '3',
Expand Down Expand Up @@ -63,8 +65,17 @@ export default class SettingsMenu extends React.Component<
.props.store.driverAnnotationSettings.includeVUS;
break;
case EVENT_KEY.hideUnprofiledSamples:
this.props.store.hideUnprofiledSamples = !this.props.store
.hideUnprofiledSamples;
if (!this.props.store.hideUnprofiledSamples) {
this.props.store.hideUnprofiledSamples = 'any';
} else {
this.props.store.hideUnprofiledSamples = false;
}
break;
case EVENT_KEY.hideAnyUnprofiledSamples:
this.props.store.hideUnprofiledSamples = 'any';
break;
case EVENT_KEY.hideTotallyUnprofiledSamples:
this.props.store.hideUnprofiledSamples = 'totally';
break;
case EVENT_KEY.showGermlineMutations:
this.props.store.includeGermlineMutations = !this.props.store
Expand Down Expand Up @@ -161,20 +172,58 @@ export default class SettingsMenu extends React.Component<
</label>
</div>
{this.props.resultsView && (
<div className="checkbox">
<label>
<input
data-test="HideUnprofiled"
type="checkbox"
value={EVENT_KEY.hideUnprofiledSamples}
checked={
this.props.store.hideUnprofiledSamples
}
onClick={this.onInputClick}
/>{' '}
Exclude samples that are not profiled for all
queried genes in all queried profiles
</label>
<div>
<div className="checkbox">
<label>
<input
data-test="HideUnprofiled"
type="checkbox"
value={EVENT_KEY.hideUnprofiledSamples}
checked={
this.props.store
.hideUnprofiledSamples !== false
}
onClick={this.onInputClick}
/>{' '}
Exclude unprofiled samples
</label>
</div>
<div style={{ marginLeft: 10 }}>
<div className="radio">
<label>
<input
type="radio"
checked={
this.props.store
.hideUnprofiledSamples ===
'any'
}
value={
EVENT_KEY.hideAnyUnprofiledSamples
}
onClick={this.onInputClick}
/>
Exclude samples that are unprofiled in
any queried gene or profile
</label>
<label>
<input
type="radio"
checked={
this.props.store
.hideUnprofiledSamples ===
'totally'
}
value={
EVENT_KEY.hideTotallyUnprofiledSamples
}
onClick={this.onInputClick}
/>
Exclude samples that are unprofiled in
every queried gene and profile.
</label>
</div>
</div>
</div>
)}
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ export interface IExclusionSettings {
includeGermlineMutations: boolean;
includeSomaticMutations: boolean;
includeUnknownStatusMutations: boolean;
hideUnprofiledSamples?: boolean;
hideUnprofiledSamples?: 'any' | 'totally' | false;
}

export interface DriverAnnotationSettings {
Expand Down
5 changes: 0 additions & 5 deletions src/shared/components/driverAnnotations/SettingsMenu.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ enum EVENT_KEY {
showSomaticMutations = '4',
showUnknownStatusMutations = '5',
showUnknownTier = '6',
hideUnprofiledSamples = '7',
toggleAllMutationStatus = '8',
toggleAllDriverAnnotation = '9',
toggleAllDriverTiers = '10',
Expand Down Expand Up @@ -82,10 +81,6 @@ export default class SettingsMenu extends React.Component<
.props.store.driverAnnotationSettings
.includeUnknownOncogenicity;
break;
case EVENT_KEY.hideUnprofiledSamples:
this.props.store.hideUnprofiledSamples = !this.props.store
.hideUnprofiledSamples;
break;
case EVENT_KEY.showGermlineMutations:
this.props.store.includeGermlineMutations = !this.props.store
.includeGermlineMutations;
Expand Down

0 comments on commit 1fb506c

Please sign in to comment.