Skip to content

Commit dbd2276

Browse files
Nellineyalisman
authored andcommitted
Add custom attribute type to the Plots tab
1 parent fae19ee commit dbd2276

File tree

7 files changed

+283
-31
lines changed

7 files changed

+283
-31
lines changed

src/pages/resultsView/ResultsViewPage.tsx

+4-1
Original file line numberDiff line numberDiff line change
@@ -265,7 +265,10 @@ export default class ResultsViewPage extends React.Component<
265265
entrezGeneIdToGene={store.entrezGeneIdToGene}
266266
sampleKeyToSample={store.sampleKeyToSample}
267267
genes={store.genes}
268-
clinicalAttributes={store.clinicalAttributes}
268+
clinicalAttributes={
269+
store.plotClinicalAttributes
270+
}
271+
customAttributes={store.customAttributes}
269272
genesets={store.genesets}
270273
genericAssayEntitiesGroupByMolecularProfileId={
271274
store.genericAssayEntitiesGroupByMolecularProfileId

src/pages/resultsView/ResultsViewPageStore.ts

+63-6
Original file line numberDiff line numberDiff line change
@@ -1093,7 +1093,7 @@ export class ResultsViewPageStore extends AnalysisStore
10931093
this.studyIds,
10941094
this.clinicalAttributes_profiledIn,
10951095
this.clinicalAttributes_comparisonGroupMembership,
1096-
this.clinicalAttributes_customCharts,
1096+
this.customAttributes,
10971097
this.samples,
10981098
this.patients,
10991099
],
@@ -1142,7 +1142,7 @@ export class ResultsViewPageStore extends AnalysisStore
11421142
...specialAttributes,
11431143
...this.clinicalAttributes_profiledIn.result!,
11441144
...this.clinicalAttributes_comparisonGroupMembership.result!,
1145-
...this.clinicalAttributes_customCharts.result!,
1145+
...this.customAttributes.result!,
11461146
];
11471147
},
11481148
});
@@ -1187,7 +1187,7 @@ export class ResultsViewPageStore extends AnalysisStore
11871187
this.studyToDataQueryFilter,
11881188
this.clinicalAttributes_profiledIn,
11891189
this.clinicalAttributes_comparisonGroupMembership,
1190-
this.clinicalAttributes_customCharts,
1190+
this.customAttributes,
11911191
],
11921192
invoke: async () => {
11931193
let clinicalAttributeCountFilter: ClinicalAttributeCountFilter;
@@ -1270,7 +1270,7 @@ export class ResultsViewPageStore extends AnalysisStore
12701270
);
12711271
}
12721272
// add counts for custom chart clinical attributes
1273-
for (const attr of this.clinicalAttributes_customCharts.result!) {
1273+
for (const attr of this.customAttributes.result!) {
12741274
ret[attr.clinicalAttributeId] = attr.data!.filter(
12751275
d => d.value !== 'NA'
12761276
).length;
@@ -2723,7 +2723,64 @@ export class ResultsViewPageStore extends AnalysisStore
27232723
default: [],
27242724
});
27252725

2726-
readonly clinicalAttributes_customCharts = remoteData({
2726+
readonly plotClinicalAttributes = remoteData<ExtendedClinicalAttribute[]>({
2727+
await: () => [
2728+
this.studyIds,
2729+
this.clinicalAttributes_profiledIn,
2730+
this.clinicalAttributes_comparisonGroupMembership,
2731+
this.samples,
2732+
this.patients,
2733+
],
2734+
invoke: async () => {
2735+
const serverAttributes = await client.fetchClinicalAttributesUsingPOST(
2736+
{
2737+
studyIds: this.studyIds.result!,
2738+
}
2739+
);
2740+
const specialAttributes = [
2741+
{
2742+
clinicalAttributeId: SpecialAttribute.MutationSpectrum,
2743+
datatype: CLINICAL_ATTRIBUTE_FIELD_ENUM.DATATYPE_COUNTS_MAP,
2744+
description:
2745+
'Number of point mutations in the sample counted by different types of nucleotide changes.',
2746+
displayName: 'Mutation spectrum',
2747+
patientAttribute: false,
2748+
studyId: '',
2749+
priority: '0', // TODO: change?
2750+
} as ClinicalAttribute,
2751+
];
2752+
if (this.studyIds.result!.length > 1) {
2753+
// if more than one study, add "Study of Origin" attribute
2754+
specialAttributes.push({
2755+
clinicalAttributeId: SpecialAttribute.StudyOfOrigin,
2756+
datatype: CLINICAL_ATTRIBUTE_FIELD_ENUM.DATATYPE_STRING,
2757+
description: 'Study which the sample is a part of.',
2758+
displayName: 'Study of origin',
2759+
patientAttribute: false,
2760+
studyId: '',
2761+
priority: '0', // TODO: change?
2762+
} as ClinicalAttribute);
2763+
}
2764+
if (this.samples.result!.length !== this.patients.result!.length) {
2765+
// if different number of samples and patients, add "Num Samples of Patient" attribute
2766+
specialAttributes.push({
2767+
clinicalAttributeId: SpecialAttribute.NumSamplesPerPatient,
2768+
datatype: CLINICAL_ATTRIBUTE_FIELD_ENUM.DATATYPE_NUMBER,
2769+
description: 'Number of queried samples for each patient.',
2770+
displayName: '# Samples per Patient',
2771+
patientAttribute: true,
2772+
} as ClinicalAttribute);
2773+
}
2774+
return [
2775+
...serverAttributes,
2776+
...specialAttributes,
2777+
...this.clinicalAttributes_profiledIn.result!,
2778+
...this.clinicalAttributes_comparisonGroupMembership.result!,
2779+
];
2780+
},
2781+
});
2782+
2783+
readonly customAttributes = remoteData({
27272784
await: () => [this.sampleMap],
27282785
invoke: async () => {
27292786
let ret: ExtendedClinicalAttribute[] = [];
@@ -5693,7 +5750,7 @@ export class ResultsViewPageStore extends AnalysisStore
56935750
this.coverageInformation,
56945751
this.filteredSampleKeyToSample,
56955752
this.filteredPatientKeyToPatient,
5696-
this.clinicalAttributes_customCharts
5753+
this.customAttributes
56975754
);
56985755

56995756
public mutationCache = new MobxPromiseCache<

src/pages/resultsView/oncoprint/TracksMenu.tsx

+2-2
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ export default class TracksMenu extends React.Component<IAddTrackProps, {}> {
151151
await: () => [
152152
this.props.store.clinicalAttributes,
153153
this.clinicalAttributeIdToAvailableFrequency,
154-
this.props.store.clinicalAttributes_customCharts,
154+
this.props.store.customAttributes,
155155
],
156156
invoke: () => {
157157
const uniqueAttributes = _.uniqBy(
@@ -167,7 +167,7 @@ export default class TracksMenu extends React.Component<IAddTrackProps, {}> {
167167
};
168168

169169
const customChartClinicalAttributeIds = _.keyBy(
170-
this.props.store.clinicalAttributes_customCharts.result!,
170+
this.props.store.customAttributes.result!,
171171
a => a.clinicalAttributeId
172172
);
173173

src/pages/studyView/StudyViewPage.tsx

+3
Original file line numberDiff line numberDiff line change
@@ -769,6 +769,9 @@ export default class StudyViewPage extends React.Component<
769769
clinicalAttributes={
770770
this.store.clinicalAttributes
771771
}
772+
customAttributes={
773+
this.store.customAttributes
774+
}
772775
genesets={this.store.genesets}
773776
genericAssayEntitiesGroupByMolecularProfileId={
774777
this.store

src/pages/studyView/StudyViewPageStore.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -11477,7 +11477,7 @@ export class StudyViewPageStore
1147711477
),
1147811478
});
1147911479

11480-
readonly clinicalAttributes_customCharts = remoteData({
11480+
readonly customAttributes = remoteData({
1148111481
await: () => [this.sampleMap],
1148211482
invoke: async () => {
1148311483
let ret: ExtendedClinicalAttribute[] = [];
@@ -11523,7 +11523,7 @@ export class StudyViewPageStore
1152311523
this.coverageInformation,
1152411524
this.filteredSampleKeyToSample,
1152511525
this.filteredPatientKeyToPatient,
11526-
this.clinicalAttributes_customCharts
11526+
this.customAttributes
1152711527
);
1152811528

1152911529
private _numericGeneMolecularDataCache = new MobxPromiseCache<

0 commit comments

Comments
 (0)