-
Notifications
You must be signed in to change notification settings - Fork 2
/
degTable_module.R
86 lines (68 loc) · 3.56 KB
/
degTable_module.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
# UI function for the differentially expressed gene table module
deTableUI <- function(id, label = "Differentially expressed gene table") {
ns <- NS(id) # Setting a unique namespace for this module
fluidPage(
sidebarLayout(
position = "left",
sidebarPanel(
helpText("The table on the right contains the results of differential expression (DE) analysis performed on pediatric AML subgroups against normal marrow or other AML patients."),
helpText("The compared groups are specified in the 'Contrast' column. The reference group used is specified in the 'Reference' column."),
helpText("The dataset has been filtered to only display DE results for the transcript/gene of interest, aka the RNA species entered by the user in the left sidebar text box."),
br(),
actionButton(ns("col_key"),
label = "Click here for column descriptions",
style = 'padding:5px; font-size:80%')
),
mainPanel(position = "right",
fluidRow(
box(width = 12, div(style = 'overflow-x: scroll',
DT::dataTableOutput(ns("filteredTable")))
)
)
)
)
)
}
# Server function for the differentially expressed gene table module
deTable <- function(input, output, session, gene, table, parent) {
# Making a function to generate a summary table with outcome data
tableFun <- reactive({
validate(
need(gene(), "Please enter a gene symbol or miRNA in the text box to the left.")
)
table %>%
mutate(across(where(is.numeric), ~round(., 2))) %>%
filter(Gene_Symbol == gene()) %>%
arrange(desc(logFC))
})
# https://glin.github.io/reactable/articles/examples.html#conditional-styling
output$filteredTable <- DT::renderDataTable({
DT::datatable(tableFun(),
class = "compact nowrap hover row-border order-column", # Defines the CSS formatting of the final table, can string multiple options together
extensions = 'Buttons', # See https://rstudio.github.io/DT/extensions.html for more extensions & features
options = list(scrollY = "70vh",
dom = 'Bfrtip',
buttons = c('excel'),
scrollX = TRUE,
fixedColumns = list(leftColumns = 1),
searchHighlight = TRUE,
pageLength = 25),
escape = F) %>%
DT::formatStyle(columns = c(1,2,4), fontSize = "100%")
})
observeEvent(input$col_key, {
showModal( # Tells Shiny to create a modal popup when the corresponding button is activated
modalDialog(
title = "Differential Expression Analysis Results Key",
DT::renderDataTable(# Interactively renders the datatable
DT::datatable(deColKey, # Actually produces the datatable table object
class = "stripe row-border",
options = list(dom = "t", pageLength = nrow(deColKey)),
width = "500",
rownames = F) %>%
DT::formatStyle(columns = c(1,2), fontSize = "90%"),
),
easyClose = TRUE)
)
})
}