-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathapp.R
38 lines (32 loc) · 1.11 KB
/
app.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
library(shiny)
library(tidyverse)
# A very nice explanation of how reactivity in Shiny works -
# https://shiny.rstudio.com/articles/understanding-reactivity.html
df <- read_csv("df.csv")
genes <- pull(df, Gene.symbol)
ui <- fluidPage(titlePanel("Outlier Detector"),
sidebarLayout(
sidebarPanel(selectInput("gene", "Gene:",
choices = genes)),
mainPanel(textOutput("text"),
plotOutput("plot"))
))
server <- function(input, output) {
output$plot <- renderPlot({
df %>%
filter(Gene.symbol == input$gene) %>%
pivot_longer(
cols = contains("GSM"),
names_to = "Sample",
values_to = "Expression"
) %>%
ggplot(aes(Sample, Expression)) +
geom_point(col = "darkblue", size = 5) +
theme_bw()
})
output$text <- renderText({
paste0("Expression levels for gene: ", input$gene)
})
}
# Run the application
shinyApp(ui = ui, server = server)