-
Notifications
You must be signed in to change notification settings - Fork 313
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 Plot Diagram on Study View - GSoC #4646
base: master
Are you sure you want to change the base?
Conversation
…rtal-frontend into mutation-mapper
const filteredDataForStudyView = filteredDataByCodon( | ||
codon, | ||
this.props.dataStore | ||
); | ||
|
||
// Send the data to study view if the page is study view. | ||
if (this.props.getFilteredData !== undefined) { | ||
this.props.getFilteredData(filteredDataForStudyView); | ||
} |
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 is a low level library component. We should not introduce anything study view specific here. This needs to be done outside of this component. Also, I don't think we need a new filteredDataByCodon
function. It should be already computed in the store. This is probably what we should be using instead:
cbioportal-frontend/packages/react-mutation-mapper/src/store/DefaultMutationMapperStore.ts
Line 308 in 4a7f358
public get mutationsByPosition(): { [pos: number]: T[] } { |
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.
Thank you for the suggestions, the new implementation now uses this method.
@@ -37,6 +37,7 @@ export type LollipopPlotProps = { | |||
dataStore?: DataStore; | |||
onXAxisOffset?: (offset: number) => void; | |||
yAxisLabelFormatter?: (symbol?: string, groupName?: string) => string; | |||
getFilteredData?: (selectedLollipopData: any[]) => 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.
I don't think we need this getFilteredData
property in this component.
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 is removed now.
public setCustomDataByCodon(data: any[]) { | ||
this.props.store.sampleDataByCodon = data.slice(); | ||
} |
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 is not the correct way to do it. We don't need an action
like this. Instead sampleDataByCodon
can and should be computed
inside the store
.
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 is removed now.
clearFilters() { | ||
this.sampleDataByCodon = []; | ||
} |
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 is pretty confusing, and most likely we don't even need a function like this. sampleDataByCodon
should be a computed
value.
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.
Yes, I agree. This is removed too. Now there is StudyViewMutationMapperStore with computed samplesViaSelectedCodons
@@ -106,6 +106,7 @@ class DefaultMutationMapperStore<T extends Mutation> | |||
|
|||
@observable | |||
private _selectedTranscript: string | undefined = undefined; | |||
sampleDataByCodon?: 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.
This should be a computed
value. Also should be a well defined type, not just any
. We may need to do this in a more specific store, like StudyViewMutationMapperStore
.
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.
The type is updated in the new implementation.
@@ -17,6 +17,26 @@ import { ApplyFilterFn } from '../model/FilterApplier'; | |||
|
|||
export const TEXT_INPUT_FILTER_ID = '_mutationTableTextInputFilter_'; | |||
|
|||
export function filteredDataByCodon( |
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 don't need to recompute filtered data here. This data already exists in the mutation mapper store. We just need a @computed
value to get samplesByPosition
.
Another thing is the sample
defined in this function is actually a Partial<Mutation>
, we can probably use mutationsByPosition
as is without even adding a new function.
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 removed now.
@@ -2647,6 +2739,7 @@ export class StudyViewPageStore | |||
this.submittedPillStore = {}; | |||
this.hesitantPillStore = {}; | |||
this.resetClinicalEventTypeFilter(); | |||
this.mutationPlotStore[this.selectedMutationPlotGene].clearFilters(); |
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's just remove 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.
Done!
@@ -175,6 +181,7 @@ export interface IChartContainerProps { | |||
@observer | |||
export class ChartContainer extends React.Component<IChartContainerProps, {}> { | |||
private chartHeaderHeight = 20; | |||
private mutationPlotRef: 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.
we should avoid any
and be more specific here.
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 with the component name.
@@ -192,6 +199,7 @@ export class ChartContainer extends React.Component<IChartContainerProps, {}> { | |||
super(props); | |||
|
|||
makeObservable(this); | |||
this.mutationPlotRef = React.createRef(); |
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 probably don't need this line
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.
Yes, I was just trying out different things, removed this line
…rtal-frontend into mutation-mapper
patientId?: string; | ||
studyId?: string; | ||
sampleId?: string; |
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 should not modify our base Mutation model. These fields are specific to cbioportal mutation data. This mutation model is designed to be generic.
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 this model
@@ -83,6 +83,7 @@ export interface MutationMapperStore<T extends Mutation> { | |||
getTranscriptId?: () => string | undefined; | |||
selectedTranscript?: string | undefined; | |||
ptmSources?: string[]; | |||
sampleDataByCodon?: 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.
This should probably be defined somewhere else mutation mapper store should not store sample/patient data. Also we should avoid any
type
@@ -1,4 +1,4 @@ | |||
import _ from 'lodash'; | |||
import _, { uniq } from 'lodash'; |
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 don't need this import, we can simply call _.uniq
if (selectedTable == FreqColumnTypeEnum.MUTATION) | ||
this.addMutationPlot(hugoGeneSymbol); |
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.
if (selectedTable == FreqColumnTypeEnum.MUTATION) | |
this.addMutationPlot(hugoGeneSymbol); | |
if (selectedTable == FreqColumnTypeEnum.MUTATION) { | |
this.addMutationPlot(hugoGeneSymbol); | |
} |
@action.bound | ||
addMutationPlot(hugoGeneSymbol: string): void { | ||
if (!this.visibleMutationPlotByGene(hugoGeneSymbol)) { | ||
let mutationPlotSpecs = [ |
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 mutationPlotSpecs = [ | |
const mutationPlotSpecs = [ |
toggleXAxisAtTop={ | ||
this.chartType === ChartTypeEnum.MUTATION_DIAGRAM | ||
? this.props.store.getMutationStore( | ||
this.props.chartMeta.uniqueKey | ||
).toggleXAxisOnTop | ||
: undefined | ||
} |
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.
again, probably we won't need this
@@ -0,0 +1,66 @@ | |||
import { Mutation } from 'cbioportal-ts-api-client'; | |||
import { DefaultMutationMapperStoreConfig } from '../../../../../packages/react-mutation-mapper/dist/store/DefaultMutationMapperStore'; |
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 is not the right way to import from packages. Do this instead:
import { DefaultMutationMapperStoreConfig } from '../../../../../packages/react-mutation-mapper/dist/store/DefaultMutationMapperStore'; | |
import { DefaultMutationMapperStoreConfig } from 'react-mutation-mapper'; |
} | ||
|
||
@computed | ||
get samplesViaSelectedCodons(): SampleData[] { |
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.
samplesByPosition
const selectedPositions = dataStore.selectedPositions; | ||
const mutationsByPosition = this.mutationsByPosition; | ||
|
||
const mutationData = Object.values(selectedPositions).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.
We should be more clear here. This should be mutationsGroupedBySelectedPostions
, right?
const samplesViaSelectedCodons: SampleData[] = []; | ||
|
||
mutationData.map(val => { | ||
val.map(m => { | ||
samplesViaSelectedCodons.push({ | ||
patientId: m.patientId, | ||
studyId: m.studyId, | ||
sampleId: m.sampleId, | ||
value: m.keyword, | ||
}); | ||
}); | ||
}); | ||
|
||
return samplesViaSelectedCodons; |
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 are not using the return valiue of mutationData.map
here, ideally we should be doing something like this:
const samplesViaSelectedCodons: SampleData[] = []; | |
mutationData.map(val => { | |
val.map(m => { | |
samplesViaSelectedCodons.push({ | |
patientId: m.patientId, | |
studyId: m.studyId, | |
sampleId: m.sampleId, | |
value: m.keyword, | |
}); | |
}); | |
}); | |
return samplesViaSelectedCodons; | |
return _.flatten(mutationData).map(m => | |
({ | |
patientId: m.patientId, | |
studyId: m.studyId, | |
sampleId: m.sampleId, | |
value: m.keyword, | |
}) | |
); |
@@ -178,6 +178,10 @@ export default class StudyViewPage extends React.Component< | |||
let hashString: string = hash || getBrowserWindow().studyPageFilter; | |||
delete (window as any).studyPageFilter; | |||
|
|||
this.store.mutationMapperFF = query['test'] |
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.
is this a placeholder for a feature flag?
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.
yes
@@ -358,6 +375,7 @@ export type StudyViewURLQuery = { | |||
filterValues?: string; | |||
sharedGroups?: string; | |||
sharedCustomData?: string; | |||
test?: string; |
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.
placeholder for feature flag?
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.
yes
readonly genes = remoteData<Gene[]>({ | ||
await: () => [], | ||
invoke: async () => { | ||
let geneData: Gene[] = []; |
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 need to define a variable, we can just return the value from the map
function.
invoke: async () => { | ||
let mutations: Mutation[] = []; | ||
|
||
this.visibleMutationPlotGenes.map(gene => { |
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 should use the value returned by map function instead of defining a redundant mutations
variable
@@ -2568,8 +2601,70 @@ export class StudyViewPageStore | |||
); | |||
} | |||
|
|||
mutationMapperFF = true; |
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 should be more clear with variable naming, something like mutationMapperFeatureEnabled
would be better
@@ -80,6 +86,7 @@ export interface ChartControls { | |||
isShowNAChecked?: boolean; | |||
showNAToggle?: boolean; | |||
showSwapAxes?: boolean; | |||
showResultsPageButton?: boolean; |
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's make it more clear, something like
showResultsPageButton?: boolean; | |
showMutationDiagramResultsPageButton?: boolean; |
value: string; | ||
}; | ||
|
||
interface DefaultMutationMapperStoreConfig { |
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.
do we really need to duplicate DefaultMutationMapperStoreConfig
? We can probably reuse the existing one.
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.
Here, the package does not have DefaultMutationMapperStoreConfig
exported, so needed to create a copy on our frontend app.
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 can export DefaultMutationMapperStoreConfig
from the package's index.tsx
. We already made some modifications to the package itself, so it should okay to modify the index.tsx
as well.
tableType: FreqColumnTypeEnum | ||
) => void; | ||
selectedMutationPlotGenes?: string[]; | ||
mutationMapperFF?: boolean; |
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 name this property better. something like enableMutationDiagramButton
@@ -95,6 +101,9 @@ export type MultiSelectionTableProps = BaseMultiSelectionTableProps & { | |||
selectedGenes: string[]; | |||
onGeneSelect: (hugoGeneSymbol: string) => void; | |||
columns: MultiSelectionTableColumn[]; | |||
setOperationsButtonText: string; | |||
selectedMutationPlotGenes?: string[]; | |||
mutationMapperFF?: boolean; |
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.
same here, we need a better name
src/routes.tsx
Outdated
@@ -377,7 +377,7 @@ export const makeRoutes = () => { | |||
})} | |||
/> | |||
<Route | |||
path="/results/:tab?" | |||
path="/results/:tab" |
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 do we need to modify this 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.
Hi, this is a mistake. I will revert this.
…rtal-frontend into mutation-mapper
Mutation Plot on Study View