-
Notifications
You must be signed in to change notification settings - Fork 0
/
volcano.R
94 lines (91 loc) · 3.08 KB
/
volcano.R
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
#' Shiny Module Server for Volcano Plots
#'
#' @param id identifier
#' @param panel_par,plot_par input parameters
#' @param plot_info reactive values from contrastPlot
#' @param contrast_table reactive data frame
#'
#' @return reactive object
#' @importFrom shiny column fluidRow moduleServer NS observeEvent
#' radioButtons reactive reactiveVal reactiveValues renderUI
#' req selectInput tagList uiOutput updateSelectInput
#' @importFrom DT renderDataTable
#' @importFrom foundr ggplot_conditionContrasts summary_conditionContrasts
#' summary_strainstats
#' @export
#'
volcanoServer <- function(id, panel_par, plot_par, plot_info,
contrast_table) {
shiny::moduleServer(id, function(input, output, session) {
ns <- session$ns
contrastVolcano <- shiny::reactive({
shiny::req(plot_info$rownames(), plot_par$ordername,
plot_info$threshold())
# Generic plot function for `traits` and `eigens`.``
foundr::ggplot_conditionContrasts(
plot_info$rownames(), bysex = panel_par$sex,
ordername = plot_par$ordername,
plottype = "volcano", threshold = plot_info$threshold(),
strain = panel_par$strain,
interact = shiny::isTruthy(plot_par$interact))
}, label = "contrastVolcano")
output$plot <- shiny::renderUI({
shiny::tagList(
shiny::h4("Volcano Plot"),
shiny::uiOutput(ns("rownames")),
if(shiny::isTruthy(plot_par$interact)) {
plotly::renderPlotly(shiny::req(contrastVolcano()))
} else {
shiny::renderPlot(print(shiny::req(contrastVolcano())))
}
)
})
###############################################################
contrastVolcano
})
}
#' Shiny Module Output for Volcano Plots
#' @return nothing returned
#' @rdname volcanoServer
#' @export
volcanoOutput <- function(id) {
ns <- shiny::NS(id)
shiny::tagList(
shiny::uiOutput(ns("title")),
shiny::uiOutput(ns("plot"))
)
}
#' Shiny App for Volcano Plots
#' @return nothing returned
#' @rdname volcanoServer
#' @export
volcanoApp <- function() {
title <- "Shiny Volcano"
ui <- function() {
shiny::fluidPage(
shiny::titlePanel(title),
shiny::sidebarLayout(
shiny::sidebarPanel(
mainParInput("main_par"), # dataset
plotParInput("plot_par") # ordername, interact
),
shiny::mainPanel(
mainParOutput("main_par"), # plot_table, height
plotParUI("plot_par"), # volsd, volvert (sliders)
plotParOutput("plot_par"), # rownames (strains/terms)
panelParUI("panel_par"), # sex
volcanoOutput("volcano")
)
)
)
}
server <- function(input, output, session) {
main_par <- mainParServer("main_par", traitStats)
panel_par <- panelParServer("panel_par", main_par, traitStats)
contrast_table <- contrastTableServer("contrast_table", main_par,
traitSignal, traitStats, customSettings)
plot_par <- plotParServer("plot_par", contrast_table)
volcanoServer("volcano", input, plot_par, contrast_table)
}
shiny::shinyApp(ui, server)
}