Skip to content
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

Capture selected scale in URL in group comparison lollipop plot #4436

Merged
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
1 change: 1 addition & 0 deletions src/pages/groupComparison/GroupComparisonMutationsTab.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,7 @@ export default class GroupComparisonMutationsTab extends React.Component<
</div>
<GroupComparisonMutationsTabPlot
store={this.props.store}
urlWrapper={this.props.urlWrapper}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it would be better to give this component a property onScaleToggle and then update the urlWrapper at this level.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed, gave component onScaleToggle

mutations={_(this.props.store.mutationsByGroup.result!)
.values()
.flatten()
Expand Down
22 changes: 14 additions & 8 deletions src/pages/groupComparison/GroupComparisonMutationsTabPlot.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,11 @@ import { MakeMobxView } from 'shared/components/MobxView';
import { countUniqueMutations } from 'shared/lib/MutationUtils';
import ErrorMessage from 'shared/components/ErrorMessage';
import { AxisScale, LollipopTooltipCountInfo } from 'react-mutation-mapper';
import GroupComparisonURLWrapper from './GroupComparisonURLWrapper';

interface IGroupComparisonMutationsTabPlotProps {
store: GroupComparisonStore;
urlWrapper: GroupComparisonURLWrapper;
mutations?: Mutation[];
filters?: any;
}
Expand All @@ -37,7 +39,6 @@ function plotYAxisLabelFormatter(symbol: string, groupName: string) {
}
}
return `${symbol} ${label}`;
// return `${symbol} ${groupName}`;
}

function plotLollipopTooltipCountInfo(
Expand All @@ -59,7 +60,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 +78,19 @@ export default class GroupComparisonMutationsTabPlot extends React.Component<
mutations: Mutation[],
group: string
) {
return this.axisMode === AxisScale.PERCENT
? (countUniqueMutations(mutations) /
return this.props.urlWrapper.query.axisMode === AxisScale.COUNT
? countUniqueMutations(mutations)
: (countUniqueMutations(mutations) /
this.props.store.groupToProfiledSamples.result![group]
.length) *
100
: countUniqueMutations(mutations);
100;
}

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

readonly plotUI = MakeMobxView({
Expand Down Expand Up @@ -130,7 +132,11 @@ export default class GroupComparisonMutationsTabPlot extends React.Component<
plotLollipopTooltipCountInfo={
plotLollipopTooltipCountInfo
}
axisMode={this.axisMode}
axisMode={
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

again, just give the component an axisMode property and keep it agnostic to the url, which is really a concert of the page component

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed

this.props.urlWrapper.query.axisMode
? this.props.urlWrapper.query.axisMode
: AxisScale.PERCENT
}
onScaleToggle={this.onScaleToggle}
plotYAxisLabelFormatter={plotYAxisLabelFormatter}
/>
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