Commit fb0f866e authored by Midoux Cedric's avatar Midoux Cedric

select_physeq()

parent b0d2c309
...@@ -172,7 +172,10 @@ observeEvent(input$okData, { ...@@ -172,7 +172,10 @@ observeEvent(input$okData, {
) )
if (inherits(raw_physeq(), "phyloseq")) { if (inherits(raw_physeq(), "phyloseq")) {
select_physeq(raw_physeq())
physeq(raw_physeq()) physeq(raw_physeq())
transform_physeq(NULL)
shinyWidgets::updateSwitchInput(session = session, inputId = "useTransf", disabled = TRUE, value = FALSE)
message(paste("[Easy16S] Correct upload with", input$dataset, "mode :", message)) message(paste("[Easy16S] Correct upload with", input$dataset, "mode :", message))
removeModal() removeModal()
} else { } else {
...@@ -191,7 +194,7 @@ filterSample <- function() { ...@@ -191,7 +194,7 @@ filterSample <- function() {
inline = TRUE, inline = TRUE,
choices = c( choices = c(
"Sample" = "sample", "Sample" = "sample",
sample_variables(raw_physeq(), errorIfNULL = FALSE) sample_variables(select_physeq(), errorIfNULL = FALSE)
), ),
selected = "sample" selected = "sample"
), ),
...@@ -212,10 +215,10 @@ output$filterUI <- renderUI({ ...@@ -212,10 +215,10 @@ output$filterUI <- renderUI({
if (input$filterCriteria == "sample") { if (input$filterCriteria == "sample") {
label <- "Sample to keep :" label <- "Sample to keep :"
choices <- sample_names(raw_physeq()) choices <- sample_names(select_physeq())
} else { } else {
label <- "Variable to keep :" label <- "Variable to keep :"
choices <- levels(get_variable(raw_physeq(), input$filterCriteria)) choices <- levels(get_variable(select_physeq(), input$filterCriteria))
} }
observe({ observe({
...@@ -251,18 +254,19 @@ observeEvent(input$selectData, { ...@@ -251,18 +254,19 @@ observeEvent(input$selectData, {
} else { } else {
try( try(
if (input$filterCriteria == "sample") { if (input$filterCriteria == "sample") {
raw_physeq(prune_samples(samples = input$filterCheck, raw_physeq())) select_physeq(prune_samples(samples = input$filterCheck, select_physeq()))
} else { } else {
criteria <<- input$filterCriteria criteria <<- input$filterCriteria
check <<- input$filterCheck check <<- input$filterCheck
raw_physeq(subset_samples(raw_physeq(), eval(parse(text = criteria)) %in% check)) select_physeq(subset_samples(select_physeq(), eval(parse(text = criteria)) %in% check))
}, },
silent = TRUE, silent = TRUE,
outFile = showModal(dataInput(failed = TRUE))) outFile = showModal(dataInput(failed = TRUE)))
if (inherits(raw_physeq(), "phyloseq")) { if (inherits(select_physeq(), "phyloseq")) {
message <- paste(input$filterCheck, collapse = ", ") message <- paste(input$filterCheck, collapse = ", ")
message(paste("[Easy16S] Select some samples :", message)) message(paste("[Easy16S] Select some samples :", message))
physeq(select_physeq())
removeModal() removeModal()
} else { } else {
showModal(dataInput(failed = TRUE)) showModal(dataInput(failed = TRUE))
...@@ -326,14 +330,14 @@ observeEvent(input$transformData, { ...@@ -326,14 +330,14 @@ observeEvent(input$transformData, {
switch (input$transformFun, switch (input$transformFun,
"prop" = { "prop" = {
count_to_prop <- function(x) {return( x / sum(x) )} count_to_prop <- function(x) {return( x / sum(x) )}
transform_physeq(transform_sample_counts(raw_physeq(), count_to_prop)) transform_physeq(transform_sample_counts(select_physeq(), count_to_prop))
}, },
"sqrt" = { "sqrt" = {
transform_physeq(transform_sample_counts(raw_physeq(), sqrt)) transform_physeq(transform_sample_counts(select_physeq(), sqrt))
}, },
"sqrtprop" = { "sqrtprop" = {
count_to_sqrtprop <- function(x) {return(sqrt(x / sum(x)))} count_to_sqrtprop <- function(x) {return(sqrt(x / sum(x)))}
transform_physeq(transform_sample_counts(raw_physeq(), count_to_sqrtprop)) transform_physeq(transform_sample_counts(select_physeq(), count_to_sqrtprop))
}, },
"clr" = { "clr" = {
gm_mean <- function(x, na.rm=TRUE) { gm_mean <- function(x, na.rm=TRUE) {
...@@ -344,7 +348,7 @@ observeEvent(input$transformData, { ...@@ -344,7 +348,7 @@ observeEvent(input$transformData, {
x <- log(x/gm_mean(x), base) x <- log(x/gm_mean(x), base)
return(x) return(x)
} }
transform_physeq(transform_sample_counts(raw_physeq(), clr)) transform_physeq(transform_sample_counts(select_physeq(), clr))
} }
), ),
silent = TRUE, silent = TRUE,
...@@ -365,7 +369,7 @@ observeEvent(input$useTransf, ...@@ -365,7 +369,7 @@ observeEvent(input$useTransf,
if (input$useTransf) { if (input$useTransf) {
physeq(transform_physeq()) physeq(transform_physeq())
} else { } else {
physeq(raw_physeq()) physeq(select_physeq())
} }
) )
......
...@@ -28,6 +28,7 @@ shinyServer ...@@ -28,6 +28,7 @@ shinyServer
physeq <- reactiveVal() physeq <- reactiveVal()
raw_physeq <- reactiveVal() raw_physeq <- reactiveVal()
select_physeq <- reactiveVal()
transform_physeq <- reactiveVal() transform_physeq <- reactiveVal()
showModal(dataInput()) showModal(dataInput())
......
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