Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 26 additions & 4 deletions src/pages/resultsView/ResultsViewPageStore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4460,16 +4460,19 @@ export class ResultsViewPageStore extends AnalysisStore
this.molecularProfilesInStudies,
this.selectedMolecularProfiles,
this.genesetMolecularProfile,
this.hasVAFData,
],
invoke: () => {
const MRNA_EXPRESSION = AlterationTypeConstants.MRNA_EXPRESSION;
const PROTEIN_LEVEL = AlterationTypeConstants.PROTEIN_LEVEL;
const METHYLATION = AlterationTypeConstants.METHYLATION;
const MUTATION_EXTENDED = AlterationTypeConstants.MUTATION_EXTENDED;
const selectedMolecularProfileIds = stringListToSet(
this.selectedMolecularProfiles.result!.map(
profile => profile.molecularProfileId
)
);
const hasVAF = this.hasVAFData.result;

const expressionHeatmaps = _.sortBy(
_.filter(this.molecularProfilesInStudies.result!, profile => {
Expand All @@ -4480,7 +4483,10 @@ export class ResultsViewPageStore extends AnalysisStore
profile.molecularAlterationType ===
PROTEIN_LEVEL) &&
profile.showProfileInAnalysisTab) ||
profile.molecularAlterationType === METHYLATION
profile.molecularAlterationType === METHYLATION ||
(profile.molecularAlterationType ===
MUTATION_EXTENDED &&
hasVAF)
);
}),
profile => {
Expand All @@ -4496,15 +4502,19 @@ export class ResultsViewPageStore extends AnalysisStore
return 1;
case METHYLATION:
return 2;
case MUTATION_EXTENDED:
return 3;
}
} else {
switch (profile.molecularAlterationType) {
case MRNA_EXPRESSION:
return 3;
case PROTEIN_LEVEL:
return 4;
case METHYLATION:
case PROTEIN_LEVEL:
return 5;
case METHYLATION:
return 6;
case MUTATION_EXTENDED:
return 7;
}
}
}
Expand All @@ -4518,6 +4528,18 @@ export class ResultsViewPageStore extends AnalysisStore
},
});

readonly hasVAFData = remoteData<boolean>({
await: () => [this.mutations],
invoke: () => {
const hasVAF = this.mutations.result!.some(
m => _.isFinite(m.tumorAltCount) && _.isFinite(m.tumorRefCount)
);

return Promise.resolve(hasVAF);
},
default: false,
});

readonly genesetMolecularProfile = remoteData<Optional<MolecularProfile>>({
await: () => [this.selectedMolecularProfiles],
invoke: () => {
Expand Down
144 changes: 129 additions & 15 deletions src/shared/components/oncoprint/DataUtils.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import {
fillGeneticTrackDatum,
fillHeatmapTrackDatum,
getOncoprintMutationType,
HeatmapCaseDatum,
makeGeneticTrackData,
selectDisplayValue,
} from './DataUtils';
Expand Down Expand Up @@ -1554,7 +1555,12 @@ describe('DataUtils', () => {
{ sampleId: 'sample', studyId: 'study' } as Sample,
data
),
{ hugo_gene_symbol: 'gene', study_id: 'study', profile_data: 3 }
{
hugo_gene_symbol: 'gene',
study_id: 'study',
na: false,
profile_data: 3,
}
);
});
it('removes data points with NaN value', () => {
Expand All @@ -1570,7 +1576,12 @@ describe('DataUtils', () => {
{ sampleId: 'sample', studyId: 'study' } as Sample,
data
),
{ hugo_gene_symbol: 'gene', study_id: 'study', profile_data: 3 }
{
hugo_gene_symbol: 'gene',
study_id: 'study',
na: false,
profile_data: 3,
}
);
});
it('throws exception if more than one data given for sample', () => {
Expand Down Expand Up @@ -1604,7 +1615,12 @@ describe('DataUtils', () => {
{ patientId: 'patient', studyId: 'study' } as Sample,
data
),
{ hugo_gene_symbol: 'gene', study_id: 'study', profile_data: 3 }
{
hugo_gene_symbol: 'gene',
study_id: 'study',
na: false,
profile_data: 3,
}
);

data = [{ value: 2 }];
Expand All @@ -1619,7 +1635,12 @@ describe('DataUtils', () => {
{ patientId: 'patient', studyId: 'study' } as Sample,
data
),
{ hugo_gene_symbol: 'gene', study_id: 'study', profile_data: 2 }
{
hugo_gene_symbol: 'gene',
study_id: 'study',
na: false,
profile_data: 2,
}
);

data = [{ value: 2 }, { value: 3 }, { value: 4 }];
Expand All @@ -1634,7 +1655,12 @@ describe('DataUtils', () => {
{ patientId: 'patient', studyId: 'study' } as Sample,
data
),
{ hugo_gene_symbol: 'gene', study_id: 'study', profile_data: 4 }
{
hugo_gene_symbol: 'gene',
study_id: 'study',
na: false,
profile_data: 4,
}
);

data = [{ value: -10 }, { value: 3 }, { value: 4 }];
Expand All @@ -1652,6 +1678,7 @@ describe('DataUtils', () => {
{
hugo_gene_symbol: 'gene',
study_id: 'study',
na: false,
profile_data: -10,
}
);
Expand All @@ -1663,17 +1690,31 @@ describe('DataUtils', () => {
'geneset_id',
'MY_FAVORITE_GENE_SET-3',
{ sampleId: 'sample', studyId: 'study' } as Sample,
[{ value: 7 }]
[
{
value: 7,
uniquePatientKey: 'patient_key',
uniqueSampleKey: 'sample_key',
},
]
);
assert.deepEqual(partialTrackDatum, {
geneset_id: 'MY_FAVORITE_GENE_SET-3',
study_id: 'study',
na: false,
profile_data: 7,
});
});

it('adds thresholdType and category to trackDatum', () => {
let data = [{ value: 8, thresholdType: '>' as '>' }];
let data: HeatmapCaseDatum[] = [
{
value: 8,
thresholdType: '>' as '>',
uniquePatientKey: 'patient_key',
uniqueSampleKey: 'sample_key',
},
];
const partialTrackDatum = {};
fillHeatmapTrackDatum<IGenericAssayHeatmapTrackDatum, 'entityId'>(
partialTrackDatum,
Expand All @@ -1685,14 +1726,31 @@ describe('DataUtils', () => {
assert.deepEqual(partialTrackDatum, {
entityId: 'GENERIC_ASSAY_ID_1',
study_id: 'study',
na: false,
profile_data: 8,
thresholdType: '>',
category: '>8.00',
});
});

it('returns smallest value with ASC sort order', () => {
let data = [{ value: 1 }, { value: 2 }, { value: 3 }];
let data: HeatmapCaseDatum[] = [
{
value: 1,
uniquePatientKey: 'patient_key',
uniqueSampleKey: 'sample_key_1',
},
{
value: 2,
uniquePatientKey: 'patient_key',
uniqueSampleKey: 'sample_key_2',
},
{
value: 3,
uniquePatientKey: 'patient_key',
uniqueSampleKey: 'sample_key_3',
},
];
const partialTrackDatum = {};
fillHeatmapTrackDatum<IGenericAssayHeatmapTrackDatum, 'entityId'>(
partialTrackDatum,
Expand All @@ -1705,12 +1763,29 @@ describe('DataUtils', () => {
assert.deepEqual(partialTrackDatum, {
entityId: 'GENERIC_ASSAY_ID_1',
study_id: 'study',
na: false,
profile_data: 1,
});
});

it('returns largest value with DESC sort order', () => {
let data = [{ value: 1 }, { value: 2 }, { value: 3 }];
let data: HeatmapCaseDatum[] = [
{
value: 1,
uniquePatientKey: 'patient_key',
uniqueSampleKey: 'sample_key_1',
},
{
value: 2,
uniquePatientKey: 'patient_key',
uniqueSampleKey: 'sample_key_2',
},
{
value: 3,
uniquePatientKey: 'patient_key',
uniqueSampleKey: 'sample_key_3',
},
];
const partialTrackDatum = {};
fillHeatmapTrackDatum<IGenericAssayHeatmapTrackDatum, 'entityId'>(
partialTrackDatum,
Expand All @@ -1723,12 +1798,29 @@ describe('DataUtils', () => {
assert.deepEqual(partialTrackDatum, {
entityId: 'GENERIC_ASSAY_ID_1',
study_id: 'study',
na: false,
profile_data: 3,
});
});

it('selects non-threshold over threshold data point when values are equal', () => {
let data = [{ value: 1, thresholdType: '>' as '>' }, { value: 1 }];
let data: HeatmapCaseDatum[] = [
{
value: 1,
uniquePatientKey: 'patient_key',
uniqueSampleKey: 'sample_key_1',
},
{
value: 2,
uniquePatientKey: 'patient_key',
uniqueSampleKey: 'sample_key_2',
},
{
value: 3,
uniquePatientKey: 'patient_key',
uniqueSampleKey: 'sample_key_3',
},
];
const partialTrackDatum = {};
fillHeatmapTrackDatum<IGenericAssayHeatmapTrackDatum, 'entityId'>(
partialTrackDatum,
Expand All @@ -1740,12 +1832,24 @@ describe('DataUtils', () => {
assert.deepEqual(partialTrackDatum, {
entityId: 'GENERIC_ASSAY_ID_1',
study_id: 'study',
profile_data: 1,
na: false,
profile_data: 3,
});
});

it('handles all NaN-value data points', () => {
let data = [{ value: NaN }, { value: NaN }];
let data: HeatmapCaseDatum[] = [
{
value: NaN,
uniquePatientKey: 'patient_key',
uniqueSampleKey: 'sample_key_1',
},
{
value: NaN,
uniquePatientKey: 'patient_key',
uniqueSampleKey: 'sample_key_2',
},
];
const partialTrackDatum = {} as IGenericAssayHeatmapTrackDatum;
fillHeatmapTrackDatum<IGenericAssayHeatmapTrackDatum, 'entityId'>(
partialTrackDatum,
Expand All @@ -1759,9 +1863,18 @@ describe('DataUtils', () => {
});

it('Prefers largest non-threshold absolute value when no sort order provided', () => {
let data = [
{ value: -10 },
{ value: 10, thresholdType: '>' as '>' },
let data: HeatmapCaseDatum[] = [
{
value: -10,
uniquePatientKey: 'patient_key',
uniqueSampleKey: 'sample_key_1',
},
{
value: 10,
thresholdType: '>' as '>',
uniquePatientKey: 'patient_key',
uniqueSampleKey: 'sample_key_2',
},
];
const partialTrackDatum = {};
fillHeatmapTrackDatum<IGenericAssayHeatmapTrackDatum, 'entityId'>(
Expand All @@ -1774,6 +1887,7 @@ describe('DataUtils', () => {
assert.deepEqual(partialTrackDatum, {
entityId: 'GENERIC_ASSAY_ID_1',
study_id: 'study',
na: false,
profile_data: -10,
});
});
Expand Down
Loading
Loading