Skip to content

Comments

Add annotations to plotly plots#1321

Merged
asizemore merged 6 commits intomainfrom
feature-1315-annotations
Feb 11, 2025
Merged

Add annotations to plotly plots#1321
asizemore merged 6 commits intomainfrom
feature-1315-annotations

Conversation

@asizemore
Copy link
Member

Resolves #1315

Uses plotly's layout.annotations prop to add annotations to plots (see examples). Examples included for Scatterplot and Histogram, but these annotations could be added to any plotly plot.

This PR does not add annotations for visx plots. I considered that as out of scope for the time being.

@asizemore asizemore requested a review from dmfalke February 5, 2025 15:56
Copy link
Contributor

@dmfalke dmfalke left a comment

Choose a reason for hiding this comment

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

This looks great! I do wonder if we should consider hiding plotly internals a bit more. It would be nice to have a generic interface for annotations that we can use with all plots. Is this a reasonable thought? Do we have other examples plots with annotations?

@asizemore
Copy link
Member Author

Ahh good point. While actually implementing the visx annotations might be out of scope, you're right that we should at least try to define a nice neutral interface that they could both use. I'll work on this!

@dmfalke
Copy link
Contributor

dmfalke commented Feb 10, 2025

Ahh good point. While actually implementing the visx annotations might be out of scope, you're right that we should at least try to define a nice neutral interface that they could both use. I'll work on this!

Cool! Let me know if you want to bounce ideas around. Something I'm wondering is, what is a reasonable approach to declaring where an annotation will appear. for example, are the annotations for the crispr scatterplots based on min and max points? more generally, is this specific to the dataset type? do we need a crispr-specific scatterplot component to declare these annotations?

Anyway, just some random thoughts about this.

@asizemore
Copy link
Member Author

Thanks @dmfalke ! I just added a new type. Plotly and visx approach annotations pretty differently, so I attempted to keep the type minimal and let it expand in the future if we need.

Something I'm wondering is, what is a reasonable approach to declaring where an annotation will appear. for example, are the annotations for the crispr scatterplots based on min and max points?

There are two ways to define where an annotation goes (in plotly): using a fraction of the axis distance (plotly's 'paper' reference') or an actual point on the plot. The stories I put up have an example of each. But i think your question about a crispr-specific plot is a good one. We don't necessarily need one because we could have another attribute in john's table that declares the annotation position as long as that position is with reference to the axes, not xmin and max. I believe that is the case for these plots - folks just want to see those annotations in the bottom left and top right, but I need to verify.

So we don't have to (at least not from what i see right now!) but of course we could!

@asizemore
Copy link
Member Author

To answer your earlier question, we do have a plot that uses annotations right now: the volcano visx plot. It has volcano-specific annotations already baked in, and the only thing it needs to know from the context is the text for those annotations. Our thinking was that all volcano plot should always have those annotations, so no need to worry about passing in more than just the annotation text (called the comparisonLabels prop).

@dmfalke
Copy link
Contributor

dmfalke commented Feb 11, 2025

@asizemore overall, I think this looks great. I'm not sure if you saw this build error: https://github.com/VEuPathDB/web-monorepo/actions/runs/13252170333/job/36992249053?pr=1321.

@dmfalke
Copy link
Contributor

dmfalke commented Feb 11, 2025

Once that build error is fixed, I think this can be merged.

@asizemore
Copy link
Member Author

oh i didn't! Glad you pointed it out!

Sounds good! I'll fix and merge!

@asizemore asizemore merged commit ae6bc00 into main Feb 11, 2025
1 check passed
@asizemore asizemore deleted the feature-1315-annotations branch February 11, 2025 21:31
dmfalke pushed a commit that referenced this pull request Feb 14, 2025
* added plot annotations functionality

* improve scatter annotation story

* added histogram annotation story

* introduce VEuPathDBAnnotation type

* fix annotation types in histogram
dmfalke added a commit that referenced this pull request Feb 18, 2025
* checkpoint

* Add type annotations to remove inferred `any` type.

* Allow an analysis descriptor to be provided to `useAnalysis`

* Only update state if the next param value is different than the previous
param value

* Extract useAnalysisState to allow external state tracking of analysis object

* Use useAnalysisState, add counts, etc

* Add stubbed question page with custom name

* Allow hiding starred variable feature

* fix typo

* Use global memoization

* Encapsulate creation of eda api clients

* Adhere to lastest "api" for GenesByEdaSubset

* dont wrap sentence

* fix label in user comment upload form

* Fix volcano plot thumbnail out of sync (#1299)

* fix for thumnails not rendering

* replace mutating state with better check of filters

* Allow html formatting in search page header

* Enable override for GenesByEdaSubset and set question page heading
dynamically.

* use more specific query name

* Use alphabetic ordering when displaying a flattened list of eda entities (#1323)

* only order variable tree entities alphabetically (#1324)

* Add annotations to plotly plots (#1321)

* added plot annotations functionality

* improve scatter annotation story

* added histogram annotation story

* introduce VEuPathDBAnnotation type

* fix annotation types in histogram

* update query name

* use dynamic import for plotly, to keep it out of the main bundle

* replace "EdaSubsetting" with "EdaSubset"

* Revert to injecting script and link tags in document head

* rename component

* Add custom formatter for stepDetails

* Handle empty filters in param value formatter

---------

Co-authored-by: aurreco-uga <aurreco@uga.edu>
Co-authored-by: Cristina Aurrecoechea <aurreco@palm.penn.apidb.org>
Co-authored-by: Ann Sizemore Blevins <asizemore@users.noreply.github.com>
dmfalke added a commit that referenced this pull request Feb 24, 2025
* checkpoint

* Add type annotations to remove inferred `any` type.

* Allow an analysis descriptor to be provided to `useAnalysis`

* Only update state if the next param value is different than the previous
param value

* Extract useAnalysisState to allow external state tracking of analysis object

* Use useAnalysisState, add counts, etc

* Add stubbed question page with custom name

* Allow hiding starred variable feature

* fix typo

* Use global memoization

* Encapsulate creation of eda api clients

* Adhere to lastest "api" for GenesByEdaSubset

* Stub in eda scatterplot for phenotype dataset

* Allow html formatting in search page header

* Enable override for GenesByEdaSubset and set question page heading
dynamically.

* use more specific query name

* update query name

* use dynamic import for plotly, to keep it out of the main bundle

* replace "EdaSubsetting" with "EdaSubset"

* dont wrap sentence

* fix label in user comment upload form

* Fix volcano plot thumbnail out of sync (#1299)

* fix for thumnails not rendering

* replace mutating state with better check of filters

* Allow html formatting in search page header

* Enable override for GenesByEdaSubset and set question page heading
dynamically.

* use more specific query name

* Use alphabetic ordering when displaying a flattened list of eda entities (#1323)

* only order variable tree entities alphabetically (#1324)

* Add annotations to plotly plots (#1321)

* added plot annotations functionality

* improve scatter annotation story

* added histogram annotation story

* introduce VEuPathDBAnnotation type

* fix annotation types in histogram

* update query name

* use dynamic import for plotly, to keep it out of the main bundle

* replace "EdaSubsetting" with "EdaSubset"

* Revert to injecting script and link tags in document head

* Export type

* Expand type to include ReactHTML elements

* Allow className to be overridden

* Add EdaDatasetGraph component

* Use EdaDatasetGraph component with EdaPhenotypeGraphsDataTable

* simplify layout and add warning message for genes not in experiment

* Add parentheses

* Wire up highlightIds

* Highlight graph_ids

* Allow arbitrary variable values to be highlighted

* Specify gene variable values to highlight

---------

Co-authored-by: aurreco-uga <aurreco@uga.edu>
Co-authored-by: Cristina Aurrecoechea <aurreco@palm.penn.apidb.org>
Co-authored-by: Ann Sizemore Blevins <asizemore@users.noreply.github.com>
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.

Phenotype data: Add annotations to scatterplot component

2 participants