Skip to content

Commit afb7e33

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

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
@@ -1173,30 +1173,11 @@ export default class PlotsTab extends React.Component<IPlotsTabProps, {}> {
11731173
(this._dataType === undefined && dataTypeOptions.length) ||
11741174
selectedDataTypeDoesNotExist
11751175
) {
1176-
// if no queried genes, default is undefined
1176+
// if no queried genes and no highlighted samples (study view plots), default is undefined
11771177
if (
1178-
self.props.highlightedSamples &&
1179-
vertical &&
1180-
isAlterationTypePresent(
1181-
dataTypeOptions,
1182-
vertical,
1183-
AlterationTypeConstants.MRNA_EXPRESSION
1184-
)
1178+
self.props.hasNoQueriedGenes &&
1179+
!self.props.highlightedSamples
11851180
) {
1186-
return AlterationTypeConstants.MRNA_EXPRESSION;
1187-
}
1188-
if (
1189-
self.props.highlightedSamples &&
1190-
!vertical &&
1191-
isAlterationTypePresent(
1192-
dataTypeOptions,
1193-
!vertical,
1194-
AlterationTypeConstants.MRNA_EXPRESSION
1195-
)
1196-
) {
1197-
return AlterationTypeConstants.COPY_NUMBER_ALTERATION;
1198-
}
1199-
if (self.props.hasNoQueriedGenes) {
12001181
return undefined;
12011182
}
12021183
// return computed default if _dataType is undefined and if there are options to select a default value from
@@ -2066,7 +2047,7 @@ export default class PlotsTab extends React.Component<IPlotsTabProps, {}> {
20662047
this.props.handleCohortChange(option.value);
20672048
}
20682049

2069-
@computed get selectedCohort(): MobxPromise<Sample[]> {
2050+
@computed get selectedCohortSamples(): MobxPromise<Sample[]> {
20702051
if (
20712052
this.props.cohortSelection &&
20722053
this.props.cohortSelection === CohortOptions.CancerType &&
@@ -3423,7 +3404,7 @@ export default class PlotsTab extends React.Component<IPlotsTabProps, {}> {
34233404
this.props.structuralVariantCache,
34243405
this.props.numericGeneMolecularDataCache,
34253406
this.props.coverageInformation,
3426-
this.selectedCohort,
3407+
this.selectedCohortSamples,
34273408
this.props.genesetMolecularDataCache,
34283409
this.props.genericAssayMolecularDataCache
34293410
);
@@ -3451,7 +3432,7 @@ export default class PlotsTab extends React.Component<IPlotsTabProps, {}> {
34513432
this.props.structuralVariantCache,
34523433
this.props.numericGeneMolecularDataCache,
34533434
this.props.coverageInformation,
3454-
this.selectedCohort,
3435+
this.selectedCohortSamples,
34553436
this.props.genesetMolecularDataCache,
34563437
this.props.genericAssayMolecularDataCache
34573438
);
@@ -3778,12 +3759,6 @@ export default class PlotsTab extends React.Component<IPlotsTabProps, {}> {
37783759
const searchMutationWords = this.searchMutationWords;
37793760
const searchHighlight = (d: IPlotSampleData) => {
37803761
let caseMatch = false;
3781-
if (
3782-
this.props.highlightedSamples &&
3783-
this.props.highlightedSamples.includes(d.sampleId)
3784-
) {
3785-
caseMatch = true;
3786-
}
37873762
for (const word of searchCaseWords) {
37883763
caseMatch =
37893764
caseMatch ||
@@ -6535,7 +6510,7 @@ export default class PlotsTab extends React.Component<IPlotsTabProps, {}> {
65356510
/>
65366511
<CaseFilterWarning
65376512
samples={this.props.samples!}
6538-
filteredSamples={this.selectedCohort!}
6513+
filteredSamples={this.selectedCohortSamples!}
65396514
patients={this.props.patients!}
65406515
filteredPatients={this.props.filteredPatients!}
65416516
hideUnprofiledSamples={

0 commit comments

Comments
 (0)