Aggregate feature values in scatterplot if multiple genes are selected#2335
Merged
keller-mark merged 10 commits intovitessce:mainfrom Nov 20, 2025
Merged
Aggregate feature values in scatterplot if multiple genes are selected#2335keller-mark merged 10 commits intovitessce:mainfrom
keller-mark merged 10 commits intovitessce:mainfrom
Conversation
Merged
Contributor
Author
|
@keller-mark what do you think of the last open question? Should I remove the aggregation part in stratifyArrays in a next PR? |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #2334
Summary
Problem
This PR solves fixes the problem that when selecting multiple genes from the featureList, the coloring of the points in the scatterplot was based only on the value of the first gene.
This is caused by
useExpressionValueGettertakingexpressionData[0]while it contains multiple arrays, one for each selected gene.Solution
I created a new file
packages/utils/other-utils/src/expr.tswith functionaggregateFeatureArraysthat aggregates multiple arrays of numbers into a single array using a specified strategy.I created a separated function because it's likely that we will have to reuse the function also for
SpatialSubscriberandExpressionHistogramSubscriber.Additional effects
This function also what I think is a secondary problem.
stratifyArraysruns after the normalization of the gene expression values (to the range 0-255), but this can be problematic.If Gene A has a range of [0, 1000] and Gene B has a range of [0, 10], normalizing them individually maps both max values to 255.
1000 + 10 = 1010first. Gene A dominates the signal, preserving biological reality.The data pipeline is now strictly ordered as follows:
aggregateFeatureArrays): Combines raw float arrays (N features -> 1 array).useUint8FeatureSelection): Calculates global min/max of the aggregated data and scales to Uint8.stratifyArrays): Groups the optimized Uint8 data into Sample/Cell Set hierarchies for rendering.Open questions
packages/utils/other-utils/src/expr.tsfor that type of function? I couldn't find any better place.stratifyArraysstratifyArraystakes in input the aggregated values (if multiple genes are selected, the aggregation code insidestratifyArraysbecomes useless if I am not mistaken. Should I change it?Checklist