Skip to content

Commit

Permalink
Separate unprofiled samples into separate group from unaltered in com…
Browse files Browse the repository at this point in the history
…parison tab

Signed-off-by: Adam Abeshouse <abeshoua@mskcc.org>
  • Loading branch information
Adam Abeshouse committed Jul 21, 2021
1 parent a6ae09a commit cc4e5e2
Show file tree
Hide file tree
Showing 2 changed files with 90 additions and 77 deletions.
127 changes: 59 additions & 68 deletions src/pages/resultsView/ResultsViewPageStore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -979,9 +979,8 @@ export class ResultsViewPageStore {
await: () => [
this.studyIds,
this.filteredAlteredSamples,
this.filteredUnalteredSamples,
this.filteredAlteredPatients,
this.filteredUnalteredPatients,
this.filteredUnalteredAndProfiledSamples,
this.unprofiledSamples,
this.filteredSamples,
this.oqlFilteredCaseAggregatedDataByUnflattenedOQLLine,
this.defaultOQLQuery,
Expand All @@ -995,8 +994,10 @@ export class ResultsViewPageStore {
this.usePatientLevelEnrichments,
this.studyIds.result!,
this.filteredAlteredSamples.result!,
this.filteredUnalteredSamples.result!,
this.queryContainsOql
this.filteredUnalteredAndProfiledSamples.result!,
this.unprofiledSamples.result!,
this.queryContainsOql,
this.hideUnprofiledSamples
)
);

Expand Down Expand Up @@ -2227,52 +2228,22 @@ export class ResultsViewPageStore {
),
});

readonly filteredUnalteredSampleKeys = remoteData({
await: () => [this.filteredSamples, this.oqlFilteredCaseAggregatedData],
invoke: () => {
const caseAggregatedData = this.oqlFilteredCaseAggregatedData
.result!;
return Promise.resolve(
this.filteredSamples
.result!.map(s => s.uniqueSampleKey)
.filter(
sampleKey =>
!caseAggregatedData.samples[sampleKey].length
)
);
},
});

readonly filteredUnalteredSamples = remoteData<Sample[]>(
{
await: () => [
this.sampleKeyToSample,
this.filteredUnalteredSampleKeys,
],
invoke: () => {
const unalteredSamples: Sample[] = [];
this.filteredUnalteredSampleKeys.result!.forEach(a =>
unalteredSamples.push(this.sampleKeyToSample.result![a])
);
return Promise.resolve(unalteredSamples);
},
},
[]
);

readonly filteredUnalteredPatients = remoteData({
readonly filteredUnalteredAndProfiledSamples = remoteData({
await: () => [
this.filteredPatients,
this.filteredSamples,
this.oqlFilteredCaseAggregatedData,
this.unprofiledSampleKeyToSample,
],
invoke: () => {
const caseAggregatedData = this.oqlFilteredCaseAggregatedData
.result!;
const unprofiledSamples = this.unprofiledSampleKeyToSample.result!;
return Promise.resolve(
this.filteredPatients.result!.filter(
patient =>
!caseAggregatedData.patients[patient.uniquePatientKey]
.length
this.filteredSamples.result!.filter(
sample =>
!caseAggregatedData.samples[sample.uniqueSampleKey]
.length &&
!(sample.uniqueSampleKey in unprofiledSamples)
)
);
},
Expand Down Expand Up @@ -3759,40 +3730,60 @@ export class ResultsViewPageStore {
});

readonly filteredSamples = remoteData({
await: () => [
this.samples,
this.coverageInformation,
this.genes,
this.selectedMolecularProfiles,
],
await: () => [this.samples, this.unprofiledSampleKeyToSample],
invoke: () => {
if (this.hideUnprofiledSamples) {
// only show samples that are profiled in every gene in every selected profile
const genes = this.genes.result!;
const coverageInfo = this.coverageInformation.result!;
const queryProfileIds = this.selectedMolecularProfiles.result!.map(
p => p.molecularProfileId
);
const unprofiledSampleKeys = this.unprofiledSampleKeyToSample
.result!;
return Promise.resolve(
this.samples.result!.filter(sample => {
return _.every(genes, gene => {
return _.every(
isSampleProfiledInMultiple(
sample.uniqueSampleKey,
queryProfileIds,
coverageInfo,
gene.hugoGeneSymbol
)
);
});
})
this.samples.result!.filter(
s => !(s.uniqueSampleKey in unprofiledSampleKeys)
)
);
} else {
return Promise.resolve(this.samples.result!);
}
},
});

readonly unprofiledSamples = remoteData({
await: () => [
this.samples,
this.coverageInformation,
this.genes,
this.selectedMolecularProfiles,
],
invoke: () => {
const genes = this.genes.result!;
const coverageInfo = this.coverageInformation.result!;
const queryProfileIds = this.selectedMolecularProfiles.result!.map(
p => p.molecularProfileId
);
return Promise.resolve(
this.samples.result!.filter(sample => {
return _.every(genes, gene => {
return !_.some(
isSampleProfiledInMultiple(
sample.uniqueSampleKey,
queryProfileIds,
coverageInfo,
gene.hugoGeneSymbol
)
);
});
})
);
},
});

readonly unprofiledSampleKeyToSample = remoteData({
await: () => [this.unprofiledSamples],
invoke: () =>
Promise.resolve(
_.keyBy(this.unprofiledSamples.result!, s => s.uniqueSampleKey)
),
});

readonly filteredSampleKeyToSample = remoteData({
await: () => [this.filteredSamples],
invoke: () =>
Expand Down
40 changes: 31 additions & 9 deletions src/pages/resultsView/comparison/ResultsViewComparisonUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import ComplexKeyMap from '../../../shared/lib/complexKeyDataStructures/ComplexK
import { SingleGeneQuery } from '../../../shared/lib/oql/oql-parser';
import oql_parser from '../../../shared/lib/oql/oql-parser';
import _ from 'lodash';
import { DEFAULT_NA_COLOR } from 'shared/lib/Colors';

export type ResultsViewComparisonGroup = ComparisonGroup & {
nameOfEnrichmentDirection: string;
Expand All @@ -28,6 +29,7 @@ export const ALTERED_COLOR = '#dc3912';
export const UNALTERED_COLOR = '#3366cc';
export const ALTERED_GROUP_NAME = 'Altered group';
export const UNALTERED_GROUP_NAME = 'Unaltered group';
export const UNPROFILED_GROUP_NAME = 'Unprofiled group';

// compute/add members to SessionGroupData to make them
// into complete ComparisonGroup objects
Expand Down Expand Up @@ -69,11 +71,14 @@ export function getAlteredVsUnalteredGroups(
patientLevel: boolean,
studyIds: string[],
alteredSamples: Sample[],
unalteredSamples: Sample[],
queryContainsOql: boolean
unalteredAndProfiledSamples: Sample[],
unprofiledSamples: Sample[],
queryContainsOql: boolean,
hideUnprofiledSamples: boolean
): SessionGroupData[] {
return [
{
const ret = [];
if (alteredSamples.length > 0) {
ret.push({
name: ALTERED_GROUP_NAME,
description: `${
patientLevel ? 'Patients' : 'Samples'
Expand All @@ -83,19 +88,36 @@ export function getAlteredVsUnalteredGroups(
studies: getStudiesAttr(alteredSamples, alteredSamples),
origin: studyIds,
color: ALTERED_COLOR,
},
{
});
}
if (unalteredAndProfiledSamples.length > 0) {
ret.push({
name: UNALTERED_GROUP_NAME,
description: `${
patientLevel ? 'Patients' : 'Samples'
} without any alterations in ${
queryContainsOql ? 'the OQL specification for ' : ''
}your queried genes in the selected profiles.`,
studies: getStudiesAttr(unalteredSamples, unalteredSamples),
studies: getStudiesAttr(
unalteredAndProfiledSamples,
unalteredAndProfiledSamples
),
origin: studyIds,
color: UNALTERED_COLOR,
},
];
});
}
if (unprofiledSamples.length > 0 && !hideUnprofiledSamples) {
ret.push({
name: UNPROFILED_GROUP_NAME,
description: `${
patientLevel ? 'Patients' : 'Samples'
} not profiled in any queried genes in any selected profiles.`,
studies: getStudiesAttr(unprofiledSamples, unprofiledSamples),
origin: studyIds,
color: DEFAULT_NA_COLOR,
});
}
return ret;
}

export function getAlteredByOncoprintTrackGroups(
Expand Down

0 comments on commit cc4e5e2

Please sign in to comment.