Skip to content

Commit

Permalink
Merge pull request #2073 from broadinstitute/jb-non-spatial-refcolors
Browse files Browse the repository at this point in the history
Only use refColorMap in multi-plot context (SCP-5692)
  • Loading branch information
eweitz authored Jul 8, 2024
2 parents c669aff + 12c39b5 commit 4694304
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
2 changes: 2 additions & 0 deletions app/javascript/components/explore/ScatterTab.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ export default function ScatterTab({
function updateScatterColor(color) {
updateExploreParamsWithDefaults({ scatterColor: color }, false)
}
const hasMultipleRefs = exploreParamsWithDefaults?.spatialGroups?.length > 0

// identify any repeat graphs
const newContextMap = getNewContextMap(scatterParams, plotlyContextMap.current)
Expand Down Expand Up @@ -68,6 +69,7 @@ export default function ScatterTab({
isRefCluster={isRefCluster}
refClusterRendered={refClusterRendered}
setRefClusterRendered={setRefClusterRendered}
hasMultipleRefs={hasMultipleRefs}
/>
</div>,
rowDivider
Expand Down
13 changes: 9 additions & 4 deletions app/javascript/components/visualization/ScatterPlot.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ function RawScatterPlot({
isAnnotatedScatter=false, isCorrelatedScatter=false, isCellSelecting=false, plotPointsSelected, dataCache,
canEdit, bucketId, expressionFilter=[0, 1], setCountsByLabelForDe, hiddenTraces=[],
isSplitLabelArrays, updateExploreParams, filteredCells, refColorMap, setRefColorMap, isRefCluster, refClusterRendered,
setRefClusterRendered
setRefClusterRendered, hasMultipleRefs
}) {
const [countsByLabel, setCountsByLabel] = useState(null)
const [isLoading, setIsLoading] = useState(false)
Expand Down Expand Up @@ -198,7 +198,7 @@ function RawScatterPlot({
refColorMap,
setRefColorMap,
isRefCluster,
refClusterRendered
hasMultipleRefs
})
if (isRG) {
setCountsByLabel(labelCounts)
Expand Down Expand Up @@ -719,7 +719,7 @@ function getPlotlyTraces({
refColorMap,
setRefColorMap,
isRefCluster,
refClusterRendered
hasMultipleRefs
}) {
const unfilteredTrace = {
type: is3D ? 'scatter3d' : 'scattergl',
Expand Down Expand Up @@ -755,7 +755,12 @@ function getPlotlyTraces({
groupTrace.type = unfilteredTrace.type
groupTrace.mode = unfilteredTrace.mode
groupTrace.opacity = unfilteredTrace.opacity
const color = getColorForLabel(groupTrace.name, customColors, editedCustomColors, refColorMap, labelIndex)
let color
if (hasMultipleRefs) {
color = getColorForLabel(groupTrace.name, customColors, editedCustomColors, refColorMap, labelIndex)
} else {
color = getColorForLabel(groupTrace.name, customColors, editedCustomColors, {}, labelIndex)
}
if (isRefCluster) {
updateRefColorMap(setRefColorMap, color, groupTrace.name)
}
Expand Down

0 comments on commit 4694304

Please sign in to comment.