-
Notifications
You must be signed in to change notification settings - Fork 303
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Mutation pie chart and multi-selection table #4794
Conversation
Hi @inodb, this frontend PR needs cBioPortal/cbioportal#10395 to be able to work. It is ready for review, thanks. |
@h164654156465 do you have a specific timeline for needing this out or is it ok if we review in a few weeks? We have a lot of backend movement happening with the spring boot refactoring |
Let's review this on early to mid January next year. We're not in a hurry, but we do want to close it out as best as we can. As this PR is closely related to backend revamp. We might need to merge those changes as well. Thank you. |
✅ Deploy Preview for cbioportalfrontend ready!
To edit notification comments on pull requests, go to your Netlify site configuration. |
e3690e1
to
c3cce60
Compare
Need fixes:
|
} | ||
|
||
@action.bound | ||
updateMutationDataFilters(uniqueKey: string, values: string[][]): void { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can we make the name "values" more specific?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I renamed it to be valueArrays so that we know it's a two dimensional array.
if (values.every(valueArray => valueArray.length === 0)) { | ||
this._mutationDataFilterSet.delete(uniqueKey); | ||
} else { | ||
const dataFilterValues: DataFilterValue[][] = values.map( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maybe a comment explaining why this is necessary
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Comments added like so:
valueArrays represent a two-dimensional array that supports union and
intersection selection on samples
for the first condition, I also added "delete mutationDataFilter if valueArrays is empty"
...params, | ||
$queryParameters: { | ||
projection: | ||
chartInfo.mutationOptionType === |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what's reason for this? put comment explaining why one case needs DETAILED
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There's no DETAILED condition in here, code updated
params = {
...params,
$queryParameters: {
projection: 'SUMMARY'
},
};
}, | ||
] as any, | ||
studyViewFilter: this.filters, | ||
let result = []; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we need to avoid adding a lot of logic/bloat to the store, which already HUGE. Lets put this code inside named helper functions, which will also document it better. we need to explain the basic fork: type==MUTATION_EXTENDED or otherwise.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
moved to util module
@@ -8948,6 +9225,38 @@ export class StudyViewPageStore | |||
} else return ''; | |||
} | |||
|
|||
public async getMutationTypesDownloadData( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
move to util file
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I also updated similar download functions.
@@ -124,18 +177,59 @@ export default class GeneLevelSelection extends React.Component< | |||
return []; | |||
} | |||
|
|||
private get subOptions() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
no reason to make this a class member. it's a constant really
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
extracted to constant under the same file
src/pages/studyView/addChartButton/geneLevelSelection/GeneLevelSelection.tsx
Show resolved
Hide resolved
this.store.updateScatterPlotFilterByValues( | ||
props.chartMeta!.uniqueKey | ||
); | ||
const props: any = { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@7xuanlu can you fix this type? you can see that is used to be set to Partial< > something other
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
updated
getDisplayedValue?: (value: string) => string, | ||
getDisplayedColor?: (value: string) => string | ||
): ClinicalDataCountSummary[] { | ||
return getClinicalDataCountWithColorByClinicalDataCount(counts).map( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
in the name of reducing the bloat of this file we should move this to another file. if you would rather just put a TODO we can follow up with that when do the refactor discussed a few weeks ago. i've actually already started this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
additionally, this logic should probably should have unit tests
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This function is not part of this PR although I did try to move it to util file but decided not to. The thing is it's using lots of internal data such as this.chartToUsedColors in StudyViewPageStore. I prefer to delaying it to another PR that address this.
I agree that we should have unit tests once we move it to util file.
} else if ( | ||
newChart.mutationOptionType && | ||
newChart.mutationOptionType === | ||
MutationOptionConstants.MUTATION_TYPE |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
correct me if i'm wrong but it seems like we use mutation_type, mutation_event and mutationData terminology interchangeably. is it possibly to make this consistent?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We make mutation_type as the final say both in frontend and backend.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
let me change all occurences in frontend
var words = eventType.split('_'); | ||
|
||
// Capitalize the first letter of each word | ||
var capitalizedWords = words.map(function(word) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i think lodash has _.capitalize that does this
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
updated
chartInfo: GenericAssayChart, | ||
filters: StudyViewFilter | ||
) { | ||
let result: GenericAssayDataCountItem[] = []; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why set it to empty array and then overwrite?
const result = await internalClient ...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
updated
stableId = data.stableId; | ||
} | ||
|
||
return { stableId: stableId, counts: counts }; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
slightly weird that it will return empty string as stableId if no matching data is found. seems like an error case yeah?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've made it to return undefined if no data matched
profileName: option.label, | ||
}; | ||
} | ||
let options: MolecularProfileOption[] = this.props |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
try to avoid using let uncessarily.
this will be clearer and more concise
const options = this.props.xxx.result!.map
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
np problem modified
@@ -175,7 +265,8 @@ export default class GeneLevelSelection extends React.Component< | |||
<div | |||
style={{ | |||
flex: 1, | |||
marginRight: 15, | |||
width: '50%', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
concerns me slightly. why would it be 50%?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not comfortable with CSS but I'm aligning molecular profile dropdown with the sub profile dropdown. Feel free to change it if you have better idea.
src/pages/studyView/addChartButton/geneLevelSelection/GeneLevelSelection.tsx
Outdated
Show resolved
Hide resolved
chartMeta: ChartMeta, | ||
props: Partial<IChartContainerProps> | ||
) => ({ | ||
[ChartTypeEnum.PIE_CHART]: () => ({ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what's reason for putting these inside of callbacks?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm trying to make sure every subTypeProps
can be created successfully and used consistently.
Some of the subtype needs callback to enable this.store.getMutationDataFiltersByUniqueKey( chartMeta.uniqueKey )
to evaluate to some values. Otherwise, it would be an undefined/error.
[ChartTypeEnum.MUTATION_EVENT_TYPE_COUNTS_TABLE]: () => ({
filters: this.store.getMutationDataFiltersByUniqueKey(
chartMeta.uniqueKey
),
promise: this.store.getMutationEventChartDataCount(chartMeta),
onValueSelection: this.handlers.onAddMutationDataValues,
onResetSelection: this.handlers.onSetMutationDataValues,
id: 'mutation-type-counts-table',
title: this.store.getChartTitle(
ChartTypeEnum.MUTATION_EVENT_TYPE_COUNTS_TABLE,
props.title
),
getData: () =>
getMutationTypesDownloadData(
this.store.getMutationEventChartDataCount(chartMeta)
),
downloadTypes: ['Data'],
onChangeCancerGeneFilter: this.store
.updateMutatedGenesTableByCancerGenesFilter,
}),
That's why I make [ChartTypeEnum.PIE_CHART] also a callback, that way we can
const subTypeProps = this.chartTypeConfig(chartMeta, props)[
chartType
]();
Fix cBioPortal/cbioportal#6759
This is breakdown of cBioPortal/cbioportal#6759. It covers only mutation data as part of this story.
A pie chart and a multi-selection table will be displayed.
The slices for MUTATED pie chart:
Mutated
Wild Type
NA
The data for EVENT table:
Missense_Mutation
...
Backend updates
Try adding new study-page api to get plot data instead of doing it in frontend
Support mutationDataFilter object in StudyViewFilter object
Frontend updates