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

Add consistency between cell plots tab and marker genes tab #388

Merged
merged 10 commits into from
May 9, 2024
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@ RedirectWithSearchAndHash.propTypes = {

const RedirectWithLocation = withRouter(RedirectWithSearchAndHash)

const CLUSTERS_PLOT = `clusters`
const METADATA_PLOT = `metatdata`
lingyun1010 marked this conversation as resolved.
Show resolved Hide resolved

class TSnePlotViewRoute extends React.Component {
constructor(props) {
super(props)
Expand All @@ -42,7 +45,7 @@ class TSnePlotViewRoute extends React.Component {
selectedColourBy: cellTypeValue ? cellTypeValue.toLowerCase() : this.props.ks[Math.round((this.props.ks.length -1) / 2)].toString(),
highlightClusters: [],
experimentAccession: this.props.experimentAccession,
selectedColourByCategory: isNaN(search.colourBy) ? `metadata` : `clusters`,
selectedColourByCategory: isNaN(search.colourBy) ? METADATA_PLOT : CLUSTERS_PLOT,
selectedClusterId: cellTypeValue ? cellTypeValue.toLowerCase() : this.props.ks[Math.round((this.props.ks.length -1) / 2)].toString(),
selectedClusterIdOption: ``
}
Expand Down Expand Up @@ -74,7 +77,7 @@ class TSnePlotViewRoute extends React.Component {

const routes = [
{
path: `/tsne`,
path: `/cell-plots`,
lingyun1010 marked this conversation as resolved.
Show resolved Hide resolved
title: `Cell plots`,
main: () => <TSnePlotView
atlasUrl={atlasUrl}
Expand Down Expand Up @@ -104,14 +107,15 @@ class TSnePlotViewRoute extends React.Component {
}
plotTypeDropdown={plotTypeDropdown}
selectedPlotOptionLabel={search.plotOption ?
search.plotType ?
Object.keys(plotTypeDropdown[plotTypeDropdown.findIndex(
(plot) => plot.plotType.toLowerCase() === search.plotType.toLowerCase())].plotOptions[0])[0] + `: ` + search.plotOption
:
Object.keys(plotTypeDropdown[plotTypeDropdown.findIndex(
(plot) => plot.plotType.toLowerCase() === this.state.selectedPlotType.toLowerCase())].plotOptions[0])[0] + `: ` + search.plotOption
:
this.state.selectedPlotOptionLabel}
search.plotType ?
Object.keys(plotTypeDropdown[plotTypeDropdown.findIndex(
(plot) => plot.plotType.toLowerCase() === search.plotType.toLowerCase())].plotOptions[0])[0] + `: ` + search.plotOption
:
Object.keys(plotTypeDropdown[plotTypeDropdown.findIndex(
(plot) => plot.plotType.toLowerCase() === this.state.selectedPlotType.toLowerCase())].plotOptions[0])[0] + `: ` + search.plotOption
:
this.state.selectedPlotOptionLabel
}
onChangePlotTypes={
(plotOption) => {
this.setState({
Expand Down Expand Up @@ -147,8 +151,12 @@ class TSnePlotViewRoute extends React.Component {
selectedColourBy : colourByValue,
selectedColourByCategory : colourByCategory
})
colourByCategory === CLUSTERS_PLOT && this.setState({
selectedClusterId : colourByValue
})
const query = new URLSearchParams(history.location.search)
query.set(`colourBy`, colourByValue)
colourByCategory === CLUSTERS_PLOT && query.set(`k`, colourByValue)
resetHighlightClusters(query)
updateUrlWithParams(query)
}
Expand All @@ -172,14 +180,17 @@ class TSnePlotViewRoute extends React.Component {
wrapperClassName={`row expanded`}
ks={ks}
selectedClusterByCategory={search.cellGroupType || search.k || preferredK}
selectedK={this.state.selectedClusterId}
selectedK={this.state.colourByCategory === CLUSTERS_PLOT ? this.state.selectedColourBy : this.state.selectedClusterId}
onSelectK={(colourByValue) => {
this.setState({
selectedClusterId : colourByValue
selectedClusterId : colourByValue,
selectedColourBy : colourByValue,
selectedColourByCategory : CLUSTERS_PLOT
})
const query = new URLSearchParams(history.location.search)
// If tsne plot is coloured by k
query.set(`k`, colourByValue)
query.set(`colourBy`, colourByValue)
resetHighlightClusters(query)
updateUrlWithParams(query)
}
Expand Down
Loading