Skip to content

Commit

Permalink
Add custom attribute type to the Plots tab
Browse files Browse the repository at this point in the history
  • Loading branch information
Nelliney committed Sep 13, 2024
1 parent 9ca3198 commit 3dc8ee3
Show file tree
Hide file tree
Showing 7 changed files with 283 additions and 31 deletions.
5 changes: 4 additions & 1 deletion src/pages/resultsView/ResultsViewPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -265,7 +265,10 @@ export default class ResultsViewPage extends React.Component<
entrezGeneIdToGene={store.entrezGeneIdToGene}
sampleKeyToSample={store.sampleKeyToSample}
genes={store.genes}
clinicalAttributes={store.clinicalAttributes}
clinicalAttributes={
store.plotClinicalAttributes
}
customAttributes={store.customAttributes}
genesets={store.genesets}
genericAssayEntitiesGroupByMolecularProfileId={
store.genericAssayEntitiesGroupByMolecularProfileId
Expand Down
69 changes: 63 additions & 6 deletions src/pages/resultsView/ResultsViewPageStore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1093,7 +1093,7 @@ export class ResultsViewPageStore extends AnalysisStore
this.studyIds,
this.clinicalAttributes_profiledIn,
this.clinicalAttributes_comparisonGroupMembership,
this.clinicalAttributes_customCharts,
this.customAttributes,
this.samples,
this.patients,
],
Expand Down Expand Up @@ -1142,7 +1142,7 @@ export class ResultsViewPageStore extends AnalysisStore
...specialAttributes,
...this.clinicalAttributes_profiledIn.result!,
...this.clinicalAttributes_comparisonGroupMembership.result!,
...this.clinicalAttributes_customCharts.result!,
...this.customAttributes.result!,
];
},
});
Expand Down Expand Up @@ -1187,7 +1187,7 @@ export class ResultsViewPageStore extends AnalysisStore
this.studyToDataQueryFilter,
this.clinicalAttributes_profiledIn,
this.clinicalAttributes_comparisonGroupMembership,
this.clinicalAttributes_customCharts,
this.customAttributes,
],
invoke: async () => {
let clinicalAttributeCountFilter: ClinicalAttributeCountFilter;
Expand Down Expand Up @@ -1270,7 +1270,7 @@ export class ResultsViewPageStore extends AnalysisStore
);
}
// add counts for custom chart clinical attributes
for (const attr of this.clinicalAttributes_customCharts.result!) {
for (const attr of this.customAttributes.result!) {
ret[attr.clinicalAttributeId] = attr.data!.filter(
d => d.value !== 'NA'
).length;
Expand Down Expand Up @@ -2723,7 +2723,64 @@ export class ResultsViewPageStore extends AnalysisStore
default: [],
});

readonly clinicalAttributes_customCharts = remoteData({
readonly plotClinicalAttributes = remoteData<ExtendedClinicalAttribute[]>({
await: () => [
this.studyIds,
this.clinicalAttributes_profiledIn,
this.clinicalAttributes_comparisonGroupMembership,
this.samples,
this.patients,
],
invoke: async () => {
const serverAttributes = await client.fetchClinicalAttributesUsingPOST(
{
studyIds: this.studyIds.result!,
}
);
const specialAttributes = [
{
clinicalAttributeId: SpecialAttribute.MutationSpectrum,
datatype: CLINICAL_ATTRIBUTE_FIELD_ENUM.DATATYPE_COUNTS_MAP,
description:
'Number of point mutations in the sample counted by different types of nucleotide changes.',
displayName: 'Mutation spectrum',
patientAttribute: false,
studyId: '',
priority: '0', // TODO: change?
} as ClinicalAttribute,
];
if (this.studyIds.result!.length > 1) {
// if more than one study, add "Study of Origin" attribute
specialAttributes.push({
clinicalAttributeId: SpecialAttribute.StudyOfOrigin,
datatype: CLINICAL_ATTRIBUTE_FIELD_ENUM.DATATYPE_STRING,
description: 'Study which the sample is a part of.',
displayName: 'Study of origin',
patientAttribute: false,
studyId: '',
priority: '0', // TODO: change?
} as ClinicalAttribute);
}
if (this.samples.result!.length !== this.patients.result!.length) {
// if different number of samples and patients, add "Num Samples of Patient" attribute
specialAttributes.push({
clinicalAttributeId: SpecialAttribute.NumSamplesPerPatient,
datatype: CLINICAL_ATTRIBUTE_FIELD_ENUM.DATATYPE_NUMBER,
description: 'Number of queried samples for each patient.',
displayName: '# Samples per Patient',
patientAttribute: true,
} as ClinicalAttribute);
}
return [
...serverAttributes,
...specialAttributes,
...this.clinicalAttributes_profiledIn.result!,
...this.clinicalAttributes_comparisonGroupMembership.result!,
];
},
});

readonly customAttributes = remoteData({
await: () => [this.sampleMap],
invoke: async () => {
let ret: ExtendedClinicalAttribute[] = [];
Expand Down Expand Up @@ -5693,7 +5750,7 @@ export class ResultsViewPageStore extends AnalysisStore
this.coverageInformation,
this.filteredSampleKeyToSample,
this.filteredPatientKeyToPatient,
this.clinicalAttributes_customCharts
this.customAttributes
);

public mutationCache = new MobxPromiseCache<
Expand Down
4 changes: 2 additions & 2 deletions src/pages/resultsView/oncoprint/TracksMenu.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ export default class TracksMenu extends React.Component<IAddTrackProps, {}> {
await: () => [
this.props.store.clinicalAttributes,
this.clinicalAttributeIdToAvailableFrequency,
this.props.store.clinicalAttributes_customCharts,
this.props.store.customAttributes,
],
invoke: () => {
const uniqueAttributes = _.uniqBy(
Expand All @@ -167,7 +167,7 @@ export default class TracksMenu extends React.Component<IAddTrackProps, {}> {
};

const customChartClinicalAttributeIds = _.keyBy(
this.props.store.clinicalAttributes_customCharts.result!,
this.props.store.customAttributes.result!,
a => a.clinicalAttributeId
);

Expand Down
3 changes: 3 additions & 0 deletions src/pages/studyView/StudyViewPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -772,6 +772,9 @@ export default class StudyViewPage extends React.Component<
clinicalAttributes={
this.store.clinicalAttributes
}
customAttributes={
this.store.customAttributes
}
genesets={this.store.genesets}
genericAssayEntitiesGroupByMolecularProfileId={
this.store
Expand Down
4 changes: 2 additions & 2 deletions src/pages/studyView/StudyViewPageStore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11439,7 +11439,7 @@ export class StudyViewPageStore
),
});

readonly clinicalAttributes_customCharts = remoteData({
readonly customAttributes = remoteData({
await: () => [this.sampleMap],
invoke: async () => {
let ret: ExtendedClinicalAttribute[] = [];
Expand Down Expand Up @@ -11485,7 +11485,7 @@ export class StudyViewPageStore
this.coverageInformation,
this.filteredSampleKeyToSample,
this.filteredPatientKeyToPatient,
this.clinicalAttributes_customCharts
this.customAttributes
);

private _numericGeneMolecularDataCache = new MobxPromiseCache<
Expand Down
Loading

0 comments on commit 3dc8ee3

Please sign in to comment.