Shiny app tools companion package for foundr package. To install:
install.packages("devtools")
devtools::install_github("byandell/foundr", ref = "foundrBase")
devtools::install_github("byandell/foundrShiny")
This package can be used to build shiny apps for analysis and visualization of founder data. It is part of a (planned) collection of packages. See Foundr App Developer Guide for an overview of package(s) use and components.
-
foundr: data analysis and visualization
- See foundrBase tree of foundr for the revised
foundrpackage (in testing phase).
- See foundrBase tree of foundr for the revised
- foundrShiny: interactive shiny app
- foundrHarmony: harmonize data from multiple sources (being written)
- modulr: harmonize WGCNA module objects
Improvements Planned
- order module list on contrast by p-values
- SD and logp calc and guideline defaults
- add pct eigenvalue from module
- larger points on several plots
- need to rethink foundr::ggplot_conditionContrasts, which is now bloated
- added
panelApp()as a diagnostic tool to investigate tabs and panels
foundrShiny Modular Organization
The foundrShiny package is completely organized using Shiny modules. All files in the R function directory have built-in apps following shiny module naming conventions. A useful guide is Mastering Shiny.
The app has a primary module foundr with secondary modules for the tab panels trait, contrast, stats, time and about.
- foundr.R: main app; see also app.R: for deployment example.
- trait.R: trait visualization
- contrast.R: contrasts of conditions across strains by sex
- stats.R: stats on design effects
- time.R: traits over time
- about.R: about this app
Specialized modules are called from these modules. Two additional files that are not modules are the following:
- foundr_helpers.R: helper functions
- foundrSetup.R: setup data for all apps (requires data access)
foundrShiny Parameters
Parameters are organized into sets
-
main_parglobal parameters -
panel_parpanel-specific parameters -
plot_parplot-specific parameters
These sets of parameters are reactiveValues placed in Shiny modules to simplify code readability through reuse.
The parameter sets are served up via servers, which depend on some data object,
main_par <- mainParServer("main_par", traitSignal)
panel_par <- panelParServer("panel_par", main_par, traitSignal)
plot_par <- plotParServer("plot_par", contrast_table)
and deployed via three UIs, which input parameter values. Each set is organized in its own shiny module, complete with app.
Global Parameters (main_par)
The main parameters main_par are set in the main app in foundr.R and flow through to the panels
mainParInput("main_par"), # dataset
mainParUI("main_par"), # order
mainParOutput("main_par"), # plot_table, height
Plot-specific Parameters (plot_par)
This set is used in the contrastPlot.R module, which is reused to develop contrast plots across traits.
plotParInput("plot_par") # ordername, interact
plotParUI("plot_par"), # volsd, volvert (sliders)
plotParOutput("plot_par"), # rownames (strains/terms)
These parameters are used in the three types of plots called via contrastPlot
which are deployed in the contrast and stats panels via the following modules
- contrastSex.R: contrasts of conditions across strains by sex
- contrastGroup.R: contrasts for groups of traits (such as WGCNA modules)
- stats.R: stats on design effects
Panel-specific Parameters (panel_par)
Panel parameters are reused in different panels in slightly different ways. It made sense to allow these to let the user set these separately within each panel. This is in development and not yet implemented. Note that some modules have input$trait or input$traits. I have begun migrating to panelPar in traitTable.
panelParInput("panel_par"), # Strains, Facet
panelParUI("panel_par"), # Traits
panelParOutput("panel_par") # Sexes (B/F/M/C)
Some parameters are passed as lists from one module to another. For instance, the traitTable module returns a - trait + traitTable: strains + traitSolos: facet + traitPairs: facet - stats + contrastPlot: sex - time + timePlot: strains, facet + timeTable: strains + timeTraits: contrast (traits) - contrast + contrastSex: sex + contrastTime: contrast, strains + timePlot: strains, facet + contrastGroup: sex, group + contrastPlot: sex, strain (via volcano?)
Careful that contrastPlot and its sub-modules (volcano,biplot,dotplot) us rownames from plotPar, which is substitute for strain. Volcano may have wrong call for strain.
Panel sub-modules
Panels deploy sub-modules, which in turn might deploy other sub-modules. By convention, each module has a Server and one or more of Input, UI, Output. Several sub-modules return reactive objects, which might be used by other sub-modules.
Contrast module
- contrastTable (used three times)
- traitOrder (reused from trait module)
- contrastSex
- contrastPlot
- contrastTime
- timeTraits
- timePlot (reused from time module)
- contrastGroup
- contrastPlot
foundrSetup(data_subset = "Physio",
dirpath = "~/Documents/Research/attie_alan/FounderDietStudy/deployLiver")