Pre-select featured/only variables in notebook computations and visualizations#1685
Conversation
|
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 Save the contents below into 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( |
| display: flex; | ||
| flex-direction: column; | ||
| overflow: hidden; | ||
| resize: vertical; |
There was a problem hiding this comment.
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(() => { |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
We didn't use this but it might be a useful addition anyway.
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
labelannotations for PCA overlay, only one suitable annotationtimepointremains and this is auto-selected (and it looks pretty)labelis 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 firstisFeaturedvariable 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 liketimepoint), it is selected automatically and rendered as read-only.Both behaviours are gated on
hasComputedXAxis && hasComputedYAxisinScatterplotVisualization, so they only activate when the axes are locked to PCA components and the overlay is the only free input.autoSelectFeaturedis also applied in two further places:comparatorVariable(the metadata variable used to define comparison groups) is pre-filled with the first featured variable that satisfies its constraints.Also did:
AnnotationPanel(scatterplot mouse-over annotations) be vertically resizableuseDebounceTrailinghook to complement the leading+trailinguseDebounce- 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