Skip to content

Commit f66b459

Browse files
committed
Structural Variant tab with table
1 parent 7bef7f2 commit f66b459

32 files changed

+1237
-4442
lines changed

src/pages/patientView/PatientViewPage.tsx

+4-4
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,8 @@ import ResourceTab from '../../shared/components/resources/ResourceTab';
4646
import { isFusion } from '../../shared/lib/MutationUtils';
4747
import { Mutation } from 'cbioportal-ts-api-client';
4848
import {
49-
getOncoKbIconStyle,
50-
updateOncoKbIconStyle,
49+
getOncoKbIconStyleFromLocalStorage,
50+
saveOncoKbIconStyleToLocalStorage,
5151
} from 'shared/lib/AnnotationColumnUtils';
5252
import { ExtendedMutationTableColumnType } from 'shared/components/mutationTable/MutationTable';
5353
import { extractColumnNames } from 'shared/components/mutationMapper/MutationMapperUtils';
@@ -176,7 +176,7 @@ export class PatientViewPageInner extends React.Component<
176176

177177
this.setOpenResourceTabs();
178178

179-
this.mergeMutationTableOncoKbIcons = getOncoKbIconStyle().mergeIcons;
179+
this.mergeMutationTableOncoKbIcons = getOncoKbIconStyleFromLocalStorage().mergeIcons;
180180
}
181181

182182
setOpenResourceTabs() {
@@ -225,7 +225,7 @@ export class PatientViewPageInner extends React.Component<
225225
@action.bound
226226
handleOncoKbIconToggle(mergeIcons: boolean) {
227227
this.mergeMutationTableOncoKbIcons = mergeIcons;
228-
updateOncoKbIconStyle({ mergeIcons });
228+
saveOncoKbIconStyleToLocalStorage({ mergeIcons });
229229
}
230230

231231
@computed get showWholeSlideViewerTab() {

src/pages/resultsView/ResultsViewPage.tsx

+8-5
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ import MutualExclusivityTab from './mutualExclusivity/MutualExclusivityTab';
1818
import DownloadTab from './download/DownloadTab';
1919
import { getServerConfig, ServerConfigHelpers } from 'config/config';
2020
import CNSegments from './cnSegments/CNSegments';
21-
import Fusion from './fusion/Fusions';
21+
import StructuralVariants from 'pages/resultsView/structuralVariant/StructuralVariants';
2222
import './styles.scss';
2323
import ResultsViewOncoprint from 'shared/components/oncoprint/ResultsViewOncoprint';
2424
import QuerySummary from './querySummary/QuerySummary';
@@ -278,7 +278,7 @@ export default class ResultsViewPage extends React.Component<
278278
},
279279
},
280280
{
281-
id: ResultsViewTab.FUSION,
281+
id: ResultsViewTab.STRUCTURALVARIANTS,
282282
hide: () => {
283283
return (
284284
!this.resultsViewPageStore.structuralVariants
@@ -291,10 +291,13 @@ export default class ResultsViewPage extends React.Component<
291291
return (
292292
<MSKTab
293293
key={13}
294-
id={ResultsViewTab.FUSION}
295-
linkText="Fusion"
294+
id={ResultsViewTab.STRUCTURALVARIANTS}
295+
linkText="Structural Variants"
296296
>
297-
<Fusion store={store} />
297+
<StructuralVariants
298+
store={store}
299+
urlWrapper={this.urlWrapper}
300+
/>
298301
</MSKTab>
299302
);
300303
},

src/pages/resultsView/ResultsViewPageHelpers.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ export enum ResultsViewTab {
1515
MUTUAL_EXCLUSIVITY = 'mutualExclusivity',
1616
PLOTS = 'plots',
1717
MUTATIONS = 'mutations',
18-
FUSION = 'fusions',
18+
STRUCTURALVARIANTS = 'structuralVariants',
1919
COEXPRESSION = 'coexpression',
2020
COMPARISON = 'comparison',
2121
CN_SEGMENTS = 'cnSegments',

src/pages/resultsView/ResultsViewPageStore.ts

+101-9
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,7 @@ import {
9292
makeGetOncoKbCnaAnnotationForOncoprint,
9393
mapSampleIdToClinicalData,
9494
ONCOKB_DEFAULT,
95+
fetchOncoKbInfo,
9596
} from 'shared/lib/StoreUtils';
9697
import {
9798
CoverageInformation,
@@ -186,6 +187,7 @@ import {
186187
FGA_VS_MUTATION_COUNT_KEY,
187188
getChartMetaDataType,
188189
getDefaultPriorityByUniqueKey,
190+
getFilteredMolecularProfilesByAlterationType,
189191
getFilteredStudiesWithSamples,
190192
getPriorityByClinicalAttribute,
191193
getUniqueKey,
@@ -297,7 +299,11 @@ import { ExtendedAlteration } from 'shared/model/ExtendedAlteration';
297299
import { IQueriedCaseData } from 'shared/model/IQueriedCaseData';
298300
import { GeneticEntity } from 'shared/model/GeneticEntity';
299301
import { IQueriedMergedTrackCaseData } from 'shared/model/IQueriedMergedTrackCaseData';
300-
import { ResultViewFusionMapperStore } from 'pages/resultsView/fusion/ResultViewFusionMapperStore';
302+
import { ResultsViewStructuralVariantMapperStore } from 'pages/resultsView/structuralVariant/ResultsViewStructuralVariantMapperStore';
303+
import {
304+
ONCOKB_DEFAULT_INFO,
305+
USE_DEFAULT_PUBLIC_INSTANCE_FOR_ONCOKB,
306+
} from 'react-mutation-mapper';
301307

302308
type Optional<T> =
303309
| { isApplicable: true; value: T }
@@ -3373,13 +3379,13 @@ export class ResultsViewPageStore extends AnalysisStore
33733379
invoke: async () => {
33743380
const svByGene: Record<string, StructuralVariant[]> = {};
33753381
this.structuralVariants.result!.forEach(sv => {
3376-
if (sv.site1HugoSymbol?.length) {
3382+
if (sv.site1HugoSymbol) {
33773383
svByGene[sv.site1HugoSymbol] =
33783384
svByGene[sv.site1HugoSymbol] || [];
33793385
svByGene[sv.site1HugoSymbol].push(sv);
33803386
}
33813387

3382-
if (sv.site2HugoSymbol?.length) {
3388+
if (sv.site2HugoSymbol) {
33833389
svByGene[sv.site2HugoSymbol] =
33843390
svByGene[sv.site2HugoSymbol] || [];
33853391
svByGene[sv.site2HugoSymbol].push(sv);
@@ -5006,8 +5012,8 @@ export class ResultsViewPageStore extends AnalysisStore
50065012
},
50075013
});
50085014

5009-
readonly fusionMapperStores = remoteData<{
5010-
[hugoGeneSymbol: string]: ResultViewFusionMapperStore;
5015+
readonly structuralVariantMapperStores = remoteData<{
5016+
[hugoGeneSymbol: string]: ResultsViewStructuralVariantMapperStore;
50115017
}>(
50125018
{
50135019
await: () => [
@@ -5023,20 +5029,23 @@ export class ResultsViewPageStore extends AnalysisStore
50235029
this.genes.result.reduce(
50245030
(
50255031
map: {
5026-
[hugoGeneSymbol: string]: ResultViewFusionMapperStore;
5032+
[hugoGeneSymbol: string]: ResultsViewStructuralVariantMapperStore;
50275033
},
50285034
gene: Gene
50295035
) => {
50305036
map[
50315037
gene.hugoGeneSymbol
5032-
] = new ResultViewFusionMapperStore(
5038+
] = new ResultsViewStructuralVariantMapperStore(
50335039
gene,
50345040
this.studyIdToStudy,
50355041
this.molecularProfileIdToMolecularProfile,
5036-
this.samples,
50375042
this.structuralVariantsByGene.result![
50385043
gene.hugoGeneSymbol
5039-
] || []
5044+
] || [],
5045+
this.uniqueSampleKeyToTumorType.result!,
5046+
this.structuralVariantOncoKbData,
5047+
this.oncoKbCancerGenes,
5048+
this.usingPublicOncoKbInstance
50405049
);
50415050
return map;
50425051
},
@@ -5764,4 +5773,87 @@ export class ResultsViewPageStore extends AnalysisStore
57645773
? (m: AnnotatedMutation) => m.putativeDriver
57655774
: undefined;
57665775
}
5776+
5777+
readonly structuralVariantProfile = remoteData({
5778+
await: () => [this.studyToMolecularProfiles],
5779+
invoke: async () => {
5780+
const structuralVariantProfiles = getFilteredMolecularProfilesByAlterationType(
5781+
this.studyToMolecularProfiles.result!,
5782+
AlterationTypeConstants.STRUCTURAL_VARIANT,
5783+
[DataTypeConstants.FUSION, DataTypeConstants.SV]
5784+
);
5785+
if (structuralVariantProfiles.length > 0) {
5786+
return structuralVariantProfiles[0];
5787+
}
5788+
return undefined;
5789+
},
5790+
});
5791+
5792+
readonly structuralVariantData = remoteData({
5793+
await: () => [this.samples, this.structuralVariantProfile],
5794+
invoke: async () => {
5795+
if (this.structuralVariantProfile.result) {
5796+
const structuralVariantFilter = {
5797+
sampleMolecularIdentifiers: this.sampleIds.map(sampleId => {
5798+
return {
5799+
molecularProfileId: this.structuralVariantProfile
5800+
.result!.molecularProfileId,
5801+
sampleId,
5802+
};
5803+
}),
5804+
} as StructuralVariantFilter;
5805+
5806+
return internalClient.fetchStructuralVariantsUsingPOST({
5807+
structuralVariantFilter,
5808+
});
5809+
}
5810+
return [];
5811+
},
5812+
default: [],
5813+
});
5814+
5815+
readonly structuralVariantOncoKbData = remoteData<IOncoKbData>(
5816+
{
5817+
await: () => [
5818+
this.oncoKbAnnotatedGenes,
5819+
this.structuralVariantData,
5820+
this.clinicalDataForSamples,
5821+
this.studies,
5822+
],
5823+
invoke: async () => {
5824+
if (getServerConfig().show_oncokb) {
5825+
return fetchStructuralVariantOncoKbData(
5826+
this.uniqueSampleKeyToTumorType.result!,
5827+
this.oncoKbAnnotatedGenes.result || {},
5828+
this.structuralVariantData
5829+
);
5830+
} else {
5831+
return ONCOKB_DEFAULT;
5832+
}
5833+
},
5834+
onError: (err: Error) => {
5835+
// fail silently, leave the error handling responsibility to the data consumer
5836+
},
5837+
},
5838+
ONCOKB_DEFAULT
5839+
);
5840+
5841+
readonly oncoKbInfo = remoteData(
5842+
{
5843+
invoke: () => {
5844+
if (getServerConfig().show_oncokb) {
5845+
return fetchOncoKbInfo();
5846+
} else {
5847+
return Promise.resolve(ONCOKB_DEFAULT_INFO);
5848+
}
5849+
},
5850+
},
5851+
ONCOKB_DEFAULT_INFO
5852+
);
5853+
5854+
@computed get usingPublicOncoKbInstance() {
5855+
return this.oncoKbInfo.result
5856+
? this.oncoKbInfo.result.publicInstance
5857+
: USE_DEFAULT_PUBLIC_INSTANCE_FOR_ONCOKB;
5858+
}
57675859
}

src/pages/resultsView/ResultsViewPageStoreUtils.ts

-45
Original file line numberDiff line numberDiff line change
@@ -926,48 +926,3 @@ export function getGeneAndProfileChunksForRequest(
926926
profileChunks: _.chunk(profileIds, profilesPerChunk),
927927
};
928928
}
929-
930-
export function getStructuralVariantProfile(studyId: string) {
931-
return studyId + '_structural_variants';
932-
}
933-
934-
export function getParamsForStructuralVariants(
935-
genes: Gene[],
936-
selectedMolecularProfiles: MolecularProfile[] | undefined,
937-
samples: Sample[] | undefined
938-
) {
939-
const params: StructuralVariantFilterExt = { entrezGeneIds: [] };
940-
if (genes) {
941-
params.entrezGeneIds = _.chain(genes)
942-
.map(gene => gene.entrezGeneId)
943-
.compact()
944-
.value();
945-
}
946-
// compose request parameters
947-
if (samples) {
948-
// get sample molecular identifiers
949-
const sampleMolecularIds = samples.map(sample => {
950-
return {
951-
molecularProfileId: getStructuralVariantProfile(sample.studyId),
952-
sampleId: sample.sampleId,
953-
};
954-
});
955-
params.sampleMolecularIdentifiers = sampleMolecularIds;
956-
} else {
957-
// get molecular profile ids
958-
if (selectedMolecularProfiles) {
959-
const molecularProfiles = selectedMolecularProfiles
960-
.filter(profile => {
961-
return (
962-
profile.molecularAlterationType ===
963-
AlterationTypeConstants.STRUCTURAL_VARIANT
964-
);
965-
})
966-
.map(profile => {
967-
return profile.molecularProfileId;
968-
});
969-
params.molecularProfileIds = molecularProfiles;
970-
}
971-
}
972-
return params as StructuralVariantFilter;
973-
}

0 commit comments

Comments
 (0)