Skip to content

Fix/efp relative mode per group control from global control#179

Open
VinLau wants to merge 5 commits intostagingfrom
fix/efp-relative-mode-per-group-control-from-global-control
Open

Fix/efp relative mode per group control from global control#179
VinLau wants to merge 5 commits intostagingfrom
fix/efp-relative-mode-per-group-control-from-global-control

Conversation

@VinLau
Copy link
Copy Markdown
Collaborator

@VinLau VinLau commented Apr 23, 2026

So there was an issue with colouring (both absolute [ fixed in #174 ] and now in relative [this fix]). Basically had to:

Problem

The eFP relative color mode and log2 fold change tooltip were using data.control — the average of all group controls across the entire experiment — instead of each tissue's own group.control. This produced incorrect colours and values in any experiment where groups have different controls.

Summary of Fixes:

  • Fix the per-group control if it is exists to be the control (Sometimes it is indeed experiment or data wide) hence the ?? operator in Eplant/views/eFP/Viewer/EFPTooltip.tsx
  • Make an absolute max for when a group max exists to co-exist with one another
  • Pass group control correctly

Before (Note that even the control samples are non-zero [they should always be 0 since its log 2 fold change of 1]):
image

After:
image

Details:

Commit 1 — per-group control for relative mode

EFPTooltip.tsx: tooltip log2 fold change now uses group.control (falls back to data.control, then 1)
svg.tsx: useStyles passes group instead of data to getColor, so the relative-mode extremum calculation scales against the group's own min/max and control
legend.tsx: removed unused EFPState import; added a comment noting the legend is a global approximation that may not exactly match per-group colours

Commit 2 — preserve absolute mode scaling

The first commit broke absolute mode: passing group to getColor meant absolute colours normalised against group.max instead of the experiment-wide data.max, making every tissue appear fully red
Added an optional absoluteMax parameter to getColor; absolute mode now uses absoluteMax ?? group.max
useStyles passes data.max as the new argument
legend.tsx unchanged — it already passes data as its group arg, so the fallback resolves correctly

What was NOT changed

The XML parser — group-level tags are parsed correctly
The data shape in types.tsx or the loader in views/eFP/index.tsx — per-group control was already computed correctly; only downstream consumers were ignoring it, so we are just making sure it gets read
The data.control aggregate field — it remains as a fallback

@VinLau
Copy link
Copy Markdown
Collaborator Author

VinLau commented May 5, 2026

@Yukthiw @bdls-jamal @mwkyuen can you take a look? I got another PR on top of this, want to keep things up to date.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant