Skip to content

Pre-select featured/only variables in notebook computations and visualizations#1685

Merged
bobular merged 10 commits into
mainfrom
preselect-featured-vars-in-notebook
Jun 12, 2026
Merged

Pre-select featured/only variables in notebook computations and visualizations#1685
bobular merged 10 commits into
mainfrom
preselect-featured-vars-in-notebook

Conversation

@bobular

@bobular bobular commented May 13, 2026

Copy link
Copy Markdown
Member

Demo/testing

When out on beta, this is a good demo

https://beta.plasmodb.org/plasmo.beta/app/search/transcript/GenesByRNASeqEvidence#GenesByRNASeqpfal3D7_pf3d7_IDC2020_Subudhi_ebi_rnaSeq_RSRCDESeq

Because

  • it's stranded so we get to see the sense variable auto-selected
  • too many label annotations for PCA overlay, only one suitable annotation timepoint remains and this is auto-selected (and it looks pretty)
  • the PCA is beautiful
  • label is still auto-selected for the DESeq2 group comparison.

Changes

In the DE and Antibody Array notebook PCA cells, the overlay variable selector now auto-populates on load:

  • autoSelectFeatured — picks the first isFeatured variable that satisfies the overlay constraints. The user can clear the selection with the existing × button, and it won't re-assert itself.
  • autoSelectWhenPossible — if there is only one valid overlay choice (e.g. a dataset with a single metadata variable like timepoint), it is selected automatically and rendered as read-only.

Both behaviours are gated on hasComputedXAxis && hasComputedYAxis in ScatterplotVisualization, so they only activate when the axes are locked to PCA components and the overlay is the only free input.

autoSelectFeatured is also applied in two further places:

  • The shared compute inputs cell (gene identifier / measurement type), so featured expression variables are pre-filled there.
  • The DESeq2/Limma configuration panel, so the comparatorVariable (the metadata variable used to define comparison groups) is pre-filled with the first featured variable that satisfies its constraints.

Also did:

  • Made the AnnotationPanel (scatterplot mouse-over annotations) be vertically resizable
  • Added a useDebounceTrailing hook to complement the leading+trailing useDebounce - which may be useful (see below)

Limitations

The auto-select of the PCA scatterplot overlay causes two backend viz requests: one without and one with the overlay configuration. This is now solved: ✔️ in 465a72a

@bobular bobular marked this pull request as draft May 13, 2026 00:36
@bobular bobular changed the title Preselect featured variables in notebook variable selectors Pre-select featured/only variables in notebook computations and visualizations May 13, 2026
@bobular

bobular commented May 13, 2026

Copy link
Copy Markdown
Member Author

If you would like to test this before the database is updated, you can apply this patch (don't commit it).

It adds the featured variable annotation to the sense variable and hopefully most label annotation vars.

Save the contents below into /tmp/patch.diff and then from the root of this repo do: git apply /tmp/patch.diff

diff --git a/packages/libs/eda/src/lib/core/api/SubsettingClient/index.ts b/packages/libs/eda/src/lib/core/api/SubsettingClient/index.ts
index 137f8ba8d1..ddaeebe28b 100644
--- a/packages/libs/eda/src/lib/core/api/SubsettingClient/index.ts
+++ b/packages/libs/eda/src/lib/core/api/SubsettingClient/index.ts
@@ -42,6 +42,11 @@ export default class SubsettingClient extends FetchClientWithCredentials {
           const { study } = await ioTransformer(StudyResponse)(res);
           assertValidStudy(study);
           orderVariables(study);
+          // TODO: remove — spoofing isFeatured for front-end testing
+          spoofFeaturedVariables(study, [
+            { entityId: 'GENE_EXPRESSION_RNASEQ_DATA', variableId: 'SEQUENCE_READ_COUNT_SENSE' },
+	    { entityId: "ENT_8151325d", variableId: "VAR_64c65374" }
+          ]);
           return study;
         },
       })
@@ -136,6 +141,27 @@ function orderVariables(study: StudyMetadata) {
   return study;
 }
 
+// TODO: remove — spoof for front-end featured-variable testing
+function spoofFeaturedVariables(
+  study: StudyMetadata,
+  targets: Array<{ entityId: string; variableId: string }>
+) {
+  for (const entity of preorder(
+    study.rootEntity,
+    (entity) => entity.children ?? []
+  )) {
+    for (const variable of entity.variables) {
+      if (
+        targets.some(
+          (t) => t.entityId === entity.id && t.variableId === variable.id
+        )
+      ) {
+        (variable as any).isFeatured = true;
+      }
+    }
+  }
+}
+
 function assertValidStudy(study: StudyMetadata) {
   const entitiesWithoutVariables: StudyEntity[] = [];
   for (const entity of preorder(

@bobular bobular marked this pull request as ready for review May 13, 2026 10:47
display: flex;
flex-direction: column;
overflow: hidden;
resize: vertical;

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

This was just an easy nice-to-have that I slipped in. The mouse-over annotation panel can now be resized (useful in antibody arrays with lots of annotations)


const isDataReady = dataRequestDepsBase != null;

useEffect(() => {

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

This part adds a small react-query-disabling delay to prevent multiple scatterplot back-end requests (see PR description) when the auto-select effects in InputVariables fire.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

We didn't use this but it might be a useful addition anyway.

@bobular bobular merged commit 224679b into main Jun 12, 2026
1 check passed
@bobular bobular deleted the preselect-featured-vars-in-notebook branch June 12, 2026 17:22
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