Skip to content

Commit c22fc2a

Browse files
author
Bryan Lai
committed
remove unnecessary patient view specific conditions and add more data to store
1 parent 97d2827 commit c22fc2a

File tree

2 files changed

+59
-66
lines changed

2 files changed

+59
-66
lines changed

src/pages/patientView/clinicalInformation/PatientViewPageStore.ts

Lines changed: 52 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -213,8 +213,9 @@ import { SiteError } from 'shared/model/appMisc';
213213
import { AnnotatedExtendedAlteration } from 'shared/model/AnnotatedExtendedAlteration';
214214
import { CustomDriverNumericGeneMolecularData } from 'shared/model/CustomDriverNumericGeneMolecularData';
215215
import {
216+
ExtendedClinicalAttribute,
216217
fetchPatients,
217-
isRNASeqProfile,
218+
getExtendsClinicalAttributesFromCustomData,
218219
parseGenericAssayGroups,
219220
} from 'pages/resultsView/ResultsViewPageStoreUtils';
220221
import { getSuffixOfMolecularProfile } from 'shared/lib/molecularProfileUtils';
@@ -231,6 +232,9 @@ import ClinicalDataCache from 'shared/cache/ClinicalDataCache';
231232
import GenesetMolecularDataCache from 'shared/cache/GenesetMolecularDataCache';
232233
import GenericAssayMolecularDataCache from 'shared/cache/GenericAssayMolecularDataCache';
233234
import { CohortOptions } from 'shared/components/plots/PlotsTab';
235+
import GenesetCache from 'shared/cache/GenesetCache';
236+
import ComplexKeyMap from 'shared/lib/complexKeyDataStructures/ComplexKeyMap';
237+
import sessionServiceClient from '../../../shared/api/sessionServiceInstance';
234238

235239
type PageMode = 'patient' | 'sample';
236240
type ResourceId = string;
@@ -739,20 +743,28 @@ export class PatientViewPageStore {
739743
onError: () => {},
740744
});
741745

746+
readonly genesetCache = new GenesetCache();
747+
748+
@computed get genesetIds() {
749+
return this.urlWrapper.query.geneset_list &&
750+
this.urlWrapper.query.geneset_list.trim().length
751+
? this.urlWrapper.query.geneset_list.trim().split(/\s+/)
752+
: [];
753+
}
754+
742755
readonly genesets = remoteData<Geneset[]>({
743756
invoke: () => {
744-
// if (this.genesetIds && this.genesetIds.length > 0) {
745-
// return this.internalClient.fetchGenesetsUsingPOST({
746-
// genesetIds: this.genesetIds.slice(),
747-
// });
748-
// } else {
749-
// return Promise.resolve([]);
750-
// }
751-
return Promise.resolve([]);
757+
if (this.genesetIds && this.genesetIds.length > 0) {
758+
return this.internalClient.fetchGenesetsUsingPOST({
759+
genesetIds: this.genesetIds.slice(),
760+
});
761+
} else {
762+
return Promise.resolve([]);
763+
}
764+
},
765+
onResult: (genesets: Geneset[]) => {
766+
this.genesetCache.addData(genesets);
752767
},
753-
// onResult: (genesets: Geneset[]) => {
754-
// this.genesetCache.addData(genesets);
755-
// },
756768
});
757769

758770
readonly genericAssayEntitiesGroupedByProfileId = remoteData<{
@@ -780,30 +792,36 @@ export class PatientViewPageStore {
780792
default: [],
781793
});
782794

795+
readonly sampleMap = remoteData({
796+
await: () => [this.selectedCohortSamples],
797+
invoke: () => {
798+
return Promise.resolve(
799+
ComplexKeyMap.from(this.selectedCohortSamples.result!, s => ({
800+
studyId: s.studyId,
801+
sampleId: s.sampleId,
802+
}))
803+
);
804+
},
805+
});
806+
783807
readonly customAttributes = remoteData({
784-
// await: () => [this.sampleMap],
808+
await: () => [this.sampleMap],
785809
invoke: async () => {
786-
// let ret: ExtendedClinicalAttribute[] = [];
787-
// if (this.appStore.isLoggedIn) {
788-
// try {
789-
// const unknownQueriedIdsMap = stringListToSet(
790-
// this.unknownQueriedIds.result
791-
// );
792-
// //Add custom data from user profile
793-
// const customChartSessions = await sessionServiceClient.getCustomDataForStudies(
794-
// this.studyIds.filter(
795-
// studyId => !unknownQueriedIdsMap[studyId]
796-
// )
797-
// );
798-
799-
// ret = getExtendsClinicalAttributesFromCustomData(
800-
// customChartSessions,
801-
// this.sampleMap.result!
802-
// );
803-
// } catch (e) {}
804-
// }
805-
// return ret;
806-
return Promise.resolve([]);
810+
let ret: ExtendedClinicalAttribute[] = [];
811+
if (this.appStore.isLoggedIn) {
812+
try {
813+
//Add custom data from user profile
814+
const customChartSessions = await sessionServiceClient.getCustomDataForStudies(
815+
[this.studyId]
816+
);
817+
818+
ret = getExtendsClinicalAttributesFromCustomData(
819+
customChartSessions,
820+
this.sampleMap.result!
821+
);
822+
} catch (e) {}
823+
}
824+
return ret;
807825
},
808826
});
809827

src/shared/components/plots/PlotsTab.tsx

Lines changed: 7 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1151,30 +1151,11 @@ export default class PlotsTab extends React.Component<IPlotsTabProps, {}> {
11511151
(this._dataType === undefined && dataTypeOptions.length) ||
11521152
selectedDataTypeDoesNotExist
11531153
) {
1154-
// if no queried genes, default is undefined
1154+
// if no queried genes and no highlighted samples (study view plots), default is undefined
11551155
if (
1156-
self.props.highlightedSamples &&
1157-
vertical &&
1158-
isAlterationTypePresent(
1159-
dataTypeOptions,
1160-
vertical,
1161-
AlterationTypeConstants.MRNA_EXPRESSION
1162-
)
1156+
self.props.hasNoQueriedGenes &&
1157+
!self.props.highlightedSamples
11631158
) {
1164-
return AlterationTypeConstants.MRNA_EXPRESSION;
1165-
}
1166-
if (
1167-
self.props.highlightedSamples &&
1168-
!vertical &&
1169-
isAlterationTypePresent(
1170-
dataTypeOptions,
1171-
!vertical,
1172-
AlterationTypeConstants.MRNA_EXPRESSION
1173-
)
1174-
) {
1175-
return AlterationTypeConstants.COPY_NUMBER_ALTERATION;
1176-
}
1177-
if (self.props.hasNoQueriedGenes) {
11781159
return undefined;
11791160
}
11801161
// return computed default if _dataType is undefined and if there are options to select a default value from
@@ -2044,7 +2025,7 @@ export default class PlotsTab extends React.Component<IPlotsTabProps, {}> {
20442025
this.props.handleCohortChange(option.value);
20452026
}
20462027

2047-
@computed get selectedCohort(): MobxPromise<Sample[]> {
2028+
@computed get selectedCohortSamples(): MobxPromise<Sample[]> {
20482029
if (
20492030
this.props.cohortSelection &&
20502031
this.props.cohortSelection === CohortOptions.CancerType &&
@@ -3401,7 +3382,7 @@ export default class PlotsTab extends React.Component<IPlotsTabProps, {}> {
34013382
this.props.structuralVariantCache,
34023383
this.props.numericGeneMolecularDataCache,
34033384
this.props.coverageInformation,
3404-
this.selectedCohort,
3385+
this.selectedCohortSamples,
34053386
this.props.genesetMolecularDataCache,
34063387
this.props.genericAssayMolecularDataCache
34073388
);
@@ -3429,7 +3410,7 @@ export default class PlotsTab extends React.Component<IPlotsTabProps, {}> {
34293410
this.props.structuralVariantCache,
34303411
this.props.numericGeneMolecularDataCache,
34313412
this.props.coverageInformation,
3432-
this.selectedCohort,
3413+
this.selectedCohortSamples,
34333414
this.props.genesetMolecularDataCache,
34343415
this.props.genericAssayMolecularDataCache
34353416
);
@@ -3756,12 +3737,6 @@ export default class PlotsTab extends React.Component<IPlotsTabProps, {}> {
37563737
const searchMutationWords = this.searchMutationWords;
37573738
const searchHighlight = (d: IPlotSampleData) => {
37583739
let caseMatch = false;
3759-
if (
3760-
this.props.highlightedSamples &&
3761-
this.props.highlightedSamples.includes(d.sampleId)
3762-
) {
3763-
caseMatch = true;
3764-
}
37653740
for (const word of searchCaseWords) {
37663741
caseMatch =
37673742
caseMatch ||
@@ -6513,7 +6488,7 @@ export default class PlotsTab extends React.Component<IPlotsTabProps, {}> {
65136488
/>
65146489
<CaseFilterWarning
65156490
samples={this.props.samples!}
6516-
filteredSamples={this.selectedCohort!}
6491+
filteredSamples={this.selectedCohortSamples!}
65176492
patients={this.props.patients!}
65186493
filteredPatients={this.props.filteredPatients!}
65196494
hideUnprofiledSamples={

0 commit comments

Comments
 (0)