Commit 0a0a0742 authored by Midoux Cedric's avatar Midoux Cedric

filter variable

parent de81072a
......@@ -166,12 +166,20 @@ observeEvent(input$okData, {
filterSample <- function() {
modalDialog(
title = "Select some sample",
size = "m",
checkboxGroupInput(inputId = "checkSamples",
label = "Sample to keep :",
choices = sample_names(physeq()),
#selected = sample_names(physeq()),
inline = TRUE),
radioButtons(
inputId = "filterCriteria",
label = "Filter criteria : ",
inline = TRUE,
choices = c(
"Sample" = "sample",
sample_variables(physeq(), errorIfNULL = FALSE)
),
selected = "sample"
),
wellPanel(uiOutput("filterUI")),
footer = tagList(modalButton("Cancel"),
actionButton(inputId = "okData", label = "Refresh filter"),
actionButton(inputId = "selectData", label = "Select")
......@@ -179,17 +187,45 @@ filterSample <- function() {
)
}
output$filterUI <- renderUI({
if (is.null(input$filterCriteria))
return()
if (input$filterCriteria == "sample") {
label <- "Sample to keep :"
choices <- sample_names(physeq())
} else {
label <- "Variable to keep :"
choices <- levels(get_variable(physeq(), input$filterCriteria))
}
checkboxGroupInput(inputId = "filterCheck",
label = label,
choices = choices,
selected = choices,
inline = TRUE)
})
observeEvent(input$selectData, {
if(is.null(input$checkSamples)) {showModal(dataInput(failed = TRUE))}
if (is.null(input$filterCheck))
{
showModal(dataInput(failed = TRUE))
} else {
try(
physeq(prune_samples(samples = input$checkSamples, physeq())),
if (input$filterCriteria == "sample") {
physeq(prune_samples(samples = input$filterCheck, physeq()))
} else {
criteria <<- input$filterCriteria
check <<- input$filterCheck
physeq(subset_samples(physeq(), eval(parse(text = criteria)) %in% check))
},
silent = TRUE,
outFile = showModal(dataInput(failed = TRUE)))
if (class(physeq()) == "phyloseq") {
removeModal()
} else {
showModal(dataInput(failed = TRUE))
}
}
})
dataDownload <- function() {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment