Skip to content

Commit

Permalink
Merge pull request #4436 from gblaih/group-comparison-lollipop-plot-s…
Browse files Browse the repository at this point in the history
…cale-url

Capture selected scale in URL in group comparison lollipop plot
  • Loading branch information
alisman authored Dec 5, 2022
2 parents 2632ec8 + 32b8665 commit 6f47580
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,11 @@ export class AxisScaleSwitch extends React.Component<
this.props.selectedScale === scale
? 'bolder'
: 'normal',
color:
this.props.selectedScale === scale ? '#fff' : '#6c757d',
backgroundColor:
this.props.selectedScale === scale ? '#6c757d' : '#fff',
borderColor: '#6c757d',
}}
onClick={onClick}
>
Expand Down
9 changes: 9 additions & 0 deletions src/pages/groupComparison/GroupComparisonMutationsTab.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import GroupComparisonMutationsTabPlot from './GroupComparisonMutationsTabPlot';
import OverlapExclusionIndicator from './OverlapExclusionIndicator';
import { MSKTab, MSKTabs } from 'shared/components/MSKTabs/MSKTabs';
import GroupComparisonURLWrapper from './GroupComparisonURLWrapper';
import { AxisScale } from 'react-mutation-mapper';

interface IGroupComparisonMutationsTabProps {
store: GroupComparisonStore;
Expand Down Expand Up @@ -60,6 +61,13 @@ export default class GroupComparisonMutationsTab extends React.Component<
return activeTabId;
}

@action.bound
private onScaleToggle(selectedScale: AxisScale) {
this.props.urlWrapper.updateURL({
axisMode: selectedScale,
});
}

readonly tabUI = MakeMobxView({
await: () => [this.props.store.availableGenes],
render: () => {
Expand Down Expand Up @@ -132,6 +140,7 @@ export default class GroupComparisonMutationsTab extends React.Component<
</div>
<GroupComparisonMutationsTabPlot
store={this.props.store}
onScaleToggle={this.onScaleToggle}
mutations={_(this.props.store.mutationsByGroup.result!)
.values()
.flatten()
Expand Down
20 changes: 7 additions & 13 deletions src/pages/groupComparison/GroupComparisonMutationsTabPlot.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import { AxisScale, LollipopTooltipCountInfo } from 'react-mutation-mapper';

interface IGroupComparisonMutationsTabPlotProps {
store: GroupComparisonStore;
onScaleToggle: (selectedScale: AxisScale) => void;
mutations?: Mutation[];
filters?: any;
}
Expand All @@ -37,7 +38,6 @@ function plotYAxisLabelFormatter(symbol: string, groupName: string) {
}
}
return `${symbol} ${label}`;
// return `${symbol} ${groupName}`;
}

function plotLollipopTooltipCountInfo(
Expand All @@ -59,7 +59,6 @@ export default class GroupComparisonMutationsTabPlot extends React.Component<
IGroupComparisonMutationsTabPlotProps,
{}
> {
@observable public axisMode: AxisScale = AxisScale.PERCENT;
constructor(props: IGroupComparisonMutationsTabPlotProps) {
super(props);
makeObservable(this);
Expand All @@ -78,17 +77,12 @@ export default class GroupComparisonMutationsTabPlot extends React.Component<
mutations: Mutation[],
group: string
) {
return this.axisMode === AxisScale.PERCENT
? (countUniqueMutations(mutations) /
return this.props.store.userSelectedAxisMode === AxisScale.COUNT
? countUniqueMutations(mutations)
: (countUniqueMutations(mutations) /
this.props.store.groupToProfiledSamples.result![group]
.length) *
100
: countUniqueMutations(mutations);
}

@action.bound
private onScaleToggle(selectedScale: AxisScale) {
this.axisMode = selectedScale;
100;
}

readonly plotUI = MakeMobxView({
Expand Down Expand Up @@ -130,8 +124,8 @@ export default class GroupComparisonMutationsTabPlot extends React.Component<
plotLollipopTooltipCountInfo={
plotLollipopTooltipCountInfo
}
axisMode={this.axisMode}
onScaleToggle={this.onScaleToggle}
axisMode={this.props.store.userSelectedAxisMode}
onScaleToggle={this.props.onScaleToggle}
plotYAxisLabelFormatter={plotYAxisLabelFormatter}
/>
</>
Expand Down
4 changes: 4 additions & 0 deletions src/pages/groupComparison/GroupComparisonStore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -458,6 +458,10 @@ export default class GroupComparisonStore extends ComparisonStore {
return this.urlWrapper.query.selectedGene;
}

@computed get userSelectedAxisMode() {
return this.urlWrapper.query.axisMode;
}

@computed get activeMutationMapperGene() {
let gene =
this.availableGenes.result!.find(
Expand Down
3 changes: 3 additions & 0 deletions src/pages/groupComparison/GroupComparisonURLWrapper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import {
} from 'shared/lib/comparison/ComparisonStoreUtils';
import { getServerConfig } from 'config/config';
import { MapValues } from 'shared/lib/TypeScriptUtils';
import { AxisScale } from 'react-mutation-mapper';

export type GroupComparisonURLQuery = {
comparisonId: string;
Expand All @@ -24,6 +25,7 @@ export type GroupComparisonURLQuery = {
patientEnrichments?: string;
selectedEnrichmentEventTypes: string;
selectedGene?: string;
axisMode?: AxisScale;
};

export default class GroupComparisonURLWrapper
Expand All @@ -40,6 +42,7 @@ export default class GroupComparisonURLWrapper
patientEnrichments: { isSessionProp: false },
selectedEnrichmentEventTypes: { isSessionProp: true },
selectedGene: { isSessionProp: false },
axisMode: { isSessionProp: false },
},
true,
getServerConfig().session_url_length_threshold
Expand Down

0 comments on commit 6f47580

Please sign in to comment.