Skip to content

Commit

Permalink
feature: data filtering input now completely dynamic
Browse files Browse the repository at this point in the history
  • Loading branch information
m-jahn committed Mar 23, 2021
1 parent 8ebe2e8 commit 4793a7f
Show file tree
Hide file tree
Showing 5 changed files with 61 additions and 120 deletions.
60 changes: 0 additions & 60 deletions R/fitness_interactive.R

This file was deleted.

44 changes: 30 additions & 14 deletions data/CRISPRi_library_2019.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,22 +11,38 @@ tree:
# main parameters to filter data
data:
condition:
- L100
- L300
- LAC
- LD
- NACL
values:
- L100
- L300
- LAC
- LD
- NACL
selected:
- L100
timepoint:
- 0
- 1
- 2
- 4
- 8
- 16
- 32
values:
- 0
- 1
- 2
- 4
- 8
- 16
- 32
selected:
- 0
- 1
- 2
- 4
- 8
- 16
- 32
induction:
- i
- u
values:
- i
- u
selected:
- i
- u

# variables for plotting data
plotting:
Expand Down
22 changes: 14 additions & 8 deletions data/Cupriavidus_BarSeq_2021.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,21 @@ tree:
# main parameters to filter data
data:
condition:
- continuous
- short pulse
- long pulse
values:
- continuous
- short pulse
- long pulse
selected:
- continuous
timepoint:
- 0
- 8
- 16
induction:
- not applicable
values:
- 0
- 8
- 16
selected:
- 0
- 8
- 16

# variables for plotting data
plotting:
Expand Down
37 changes: 13 additions & 24 deletions server.R
Original file line number Diff line number Diff line change
Expand Up @@ -19,36 +19,25 @@ server <- function(input, output) {
# filter data set by gene selection
data <- data() %>% filter(get(config()$tree$gene_level) %in% filtGenes())
# filter data set by user input
filter(data,
get(names(config()$data)[1]) %in% input$UserDataFilterCond,
get(names(config()$data)[2]) %in% input$UserDataFilterTime,
get(names(config()$data)[3]) %in% input$UserDataFilterInd
)
for (filt in names(config()$data)) {
data <- filter(data, get(filt) %in% input[[paste0("Filter_", filt)]])
}
data
})

# GET GLOBAL CONFIGURATION FOR CHOSEN DATASET
config <- reactive({data_config[[input$UserDataChoice]]})

# DYNAMIC BOXES FOR DATA FILTERING
output$FilterCond <- renderUI({
selectInput("UserDataFilterCond",
"Condition:", config()$data$condition,
selected = config()$data$condition[1],
multiple = TRUE)
})

output$FilterTime <- renderUI({
selectInput("UserDataFilterTime",
"Time point:", config()$data$timepoint,
selected = config()$data$timepoint,
multiple = TRUE)
})

output$FilterInd <- renderUI({
selectInput("UserDataFilterInd",
"Induction:", config()$data$induction,
selected = config()$data$induction,
multiple = TRUE)
output$UserFilters <- renderUI({
lapply(names(config()$data), function(filt) {
selectInput(
inputId = paste0("Filter_", filt),
label = paste0(filt, ":"),
choices = config()$data[[filt]]$values,
selected = config()$data[[filt]]$selected,
multiple = TRUE)
})
})

# DYNAMIC BOXES FOR DATA VIZ OPTIONS
Expand Down
18 changes: 4 additions & 14 deletions ui.R
Original file line number Diff line number Diff line change
Expand Up @@ -25,23 +25,13 @@ ui <- navbarPage(
h4("DATA OPTIONS"),

fluidRow(
column(width = 12,
column(width = 6,
selectInput("UserDataChoice",
"Choose data:", data_list,
"Choose data:", data_list,
selected = data_list[1])
)
),

# select additional filters
fluidRow(
column(width = 4,
uiOutput("FilterCond")
),
column(width = 4,
uiOutput("FilterTime")
),
column(width = 4,
uiOutput("FilterInd")
column(width = 6,
uiOutput("UserFilters")
)
),

Expand Down

0 comments on commit 4793a7f

Please sign in to comment.