Repository navigation
Shiny app organizational code refactor - #126
Merged
Merged
Conversation
…than exhaustively cover all functionality
… meant to address issues with plots and app text overlapping
… with devtools::document()
Member
Author
|
Forgot to mention a small change not described above: I reimplemented a base-R plot (layer-level boxplots) in ggplot2, which helped ensure plots didn't overlap app text (previously margins were hardcoded). Changes can be seen in R/layer_boxplot.R |
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.
Purpose of this pull request
This pull request does a full refactor of Shiny-app code used by
run_app()without changing functionality (except for a couple bug fixes that resulted
naturally from the refactor). In contrast to the original large
app_server.Rand
app_ui.Rscripts, this PR implements several newapp_*.Rfiles. Theoverall goal was to improve readability, modularity, and maintainability in
the future, particularly with major upcoming feature changes in mind.
Why such an extreme rewrite?
app_server.Rwas > 2000 lines,app_ui.R> 1200 lines. Finding or making changes to a specific app function in the code was quite difficult. Also, dependencies between sections of each script were difficult to navigate or understandWhile not a particularly interesting PR on its own, I see it as an important step for future feature updates to build upon.
What exactly changes in this PR?
Organizational improvements
The most important organizational change is delegating logical functional units of the app to individual
app_*.Rscripts, individually described here. For example, layer-level functionality goes into clearly namedapp_layer_*.Rscripts, and spot-level functionality intoapp_spot_*.R. Within those units, dropdown features of the app go intoapp_(layer|spot)_controls.R. Issues we've had in this package related to colors (e.g. part of this PR) naturally go away by delegating color-related code to a dedicatedapp_palettes.Rscript.Next,
app_server.Rbecomes short and elegant, outsourcing individual components to respective R files (such as in this code block), and something nearly identical conceptually happens inapp_ui.R.Bug fixes
These are interesting because they naturally became exposed and corrected as a direct consequence of code organization improvements, rather than due to intentional targeted fixes.
New tests
Using a new tiny example dataset, I built and individually verified new tests, most notably those in test-app-features.R. The idea here was to break the app into (29) individual functions, and do a tiny test checking a very basic version of each function. These are not intended to be comprehensive, but are meant to quickly automatically check that nothing major and obvious breaks in future changes to the app. As I'll describe later, I also manually inspected the app thoroughly after this PR's changes.
How do we know such a substantial rewrite didn't break anything?
As previously mentioned, the new automated tests verify a small fraction of the functionality of the app. I also thoroughly manually interacted with a copy of the NAc app, comparing the existing app with a version running the new
spatialLIBD. In detail, here's what I checked:Spot-level data
clusters (interactive))gene (interactive)Layer-level data
Other miscellaneous details
I used AI to help out with many of these changes, and initially overlooked that this commit touched files that weren't strictly necessary for the app-related changes. Rather than undoing the commit, I undid the changes with a new commit. The PR therefore might should edits to additional files that weren't really changed overall (a diff between the final PR and
develshould show no changes in those files).