diff --git a/internals.R b/internals.R index 2327b09d98e00c2c94b96341a688e86976b0a088..5dde6e6e5fc3babbf71a05f9789d6fa7c60a94ca 100644 --- a/internals.R +++ b/internals.R @@ -103,14 +103,3 @@ beautifulTable <- function(data) { height = "auto" ) } - -collapsedBox <- function(data, title = title) { - box( - title = title, - width = NULL, - status = "primary", - collapsible = TRUE, - collapsed = TRUE, - data - ) -} diff --git a/panels/Summary-server.R b/panels/Summary-server.R index b58a783972604f52014b896b3c5815d7364d7387..648b33a8fc7140f0825661c2c2f3fe5f3a72ed5e 100644 --- a/panels/Summary-server.R +++ b/panels/Summary-server.R @@ -7,68 +7,3 @@ output$phyloseqPrint <- renderPrint({ ) physeq() }) - -output$otuTable <- renderUI({ - validate(need(physeq(), "")) - collapsedBox( - beautifulTable(data.frame(OTU = taxa_names(physeq()), otu_table(physeq()))), - title = "OTU table" - ) -}) - -output$glomOtuTable <- renderUI({ - validate(need(physeq(), "")) - box( - title = "Agglomerate OTU table", - width = NULL, - status = "primary", - collapsible = TRUE, - collapsed = TRUE, - radioButtons("glomRank", - label = "Taxonomic rank : ", - choices = rank_names(physeq()), - inline = TRUE), - DT::dataTableOutput("tableGlom") - ) -}) - -output$taxTable <- renderUI({ - validate(need(physeq(), "")) - collapsedBox( - beautifulTable(data.frame(OTU = taxa_names(physeq()), tax_table(physeq()))), - title = "Taxonomy table" - ) -}) - -output$sampleDataTable <- renderUI({ - validate(need(physeq(), "")) - collapsedBox( - beautifulTable(data.frame(SAMPLE = sample_names(physeq()), sample_data(physeq()))), - title = "Sample data table" - ) -}) - -output$sampleDataType <- renderUI({ - validate(need(sample_data(physeq(), errorIfNULL = FALSE), "")) - collapsedBox(renderTable({ - (sapply(sample_data(physeq()), class)) - }, rownames = TRUE, colnames = FALSE), - title = "Class of sample data") -}) - -output$tableGlom <- DT::renderDataTable(server = FALSE, { - Glom <- tax_glom(physeq(), input$glomRank, NArm = FALSE) - taxTableGlom <- Glom %>% - tax_table() %>% - as.data.frame(stringsAsFactors = FALSE) %>% - dplyr::select(1:input$glomRank) %>% - tibble::rownames_to_column() - otuTableGlom <- Glom %>% - otu_table() %>% - as.data.frame(stringsAsFactors = FALSE) %>% - tibble::rownames_to_column() - joinGlom <- - dplyr::left_join(taxTableGlom, otuTableGlom, by = "rowname") %>% - dplyr::select(-rowname) - beautifulTable(joinGlom) -}) diff --git a/panels/Summary-ui.R b/panels/Summary-ui.R index 1d1d4b4e03e821d79d3934285638bc4ea2084485..460c1ca213e2e788f5bd87f80f4a0d93557d2236 100644 --- a/panels/Summary-ui.R +++ b/panels/Summary-ui.R @@ -1,12 +1,9 @@ -Summary <- div(verbatimTextOutput("phyloseqPrint"), - uiOutput("otuTable"), - uiOutput("glomOtuTable"), - uiOutput("taxTable"), - uiOutput("sampleDataTable"), - uiOutput("sampleDataType"), - tags$footer("Questions, problems or comments regarding this application should be sent to ", - a(href = "mailto:cedric.midoux@inrae.fr?subject=[Easy16S]", "cedric.midoux@inrae.fr"), - align = "center", - style = "position:absolute;bottom: 0;width: 100%;color: grey;padding: 10px;# background-color: white;z-index: 1000;" - ) - ) +Summary <- fluidPage( + withLoader(verbatimTextOutput("phyloseqPrint")), + tags$footer( + "Questions, problems or comments regarding this application should be sent to ", + a(href = "mailto:cedric.midoux@inrae.fr?subject=[Easy16S]", "cedric.midoux@inrae.fr"), + align = "center", + style = "position:absolute;bottom: 0;width: 100%;color: grey;padding: 10px;# background-color: white;z-index: 1000;" + ) +) diff --git a/panels/table-server.R b/panels/table-server.R new file mode 100644 index 0000000000000000000000000000000000000000..12a207390b80452c8ce3a64020538364783502b9 --- /dev/null +++ b/panels/table-server.R @@ -0,0 +1,67 @@ +output$otuTable <- renderUI({ + validate(need(physeq(), "Requires an abundance dataset")) + box( + title = "OTU table", + width = NULL, + status = "primary", + beautifulTable(tibble::rownames_to_column(as.data.frame(otu_table(physeq())), var = "OTU")) + ) +}) + +output$taxTable <- renderUI({ + validate(need(physeq(), "Requires an abundance dataset")) + box( + title = "Taxonomy table", + width = NULL, + status = "primary", + beautifulTable(tibble::rownames_to_column(as.data.frame(tax_table(physeq())), var = "OTU")) + ) +}) + +output$glomTable <- renderUI({ + validate(need(physeq(), "Requires an abundance dataset")) + box( + title = "Agglomerate OTU table", + width = NULL, + status = "primary", + radioButtons("glomRank", + label = "Taxonomic rank : ", + choices = rank_names(physeq()), + inline = TRUE), + withLoader(dataTableOutput("tableGlom")) + ) +}) + +output$tableGlom <- renderDataTable({ + Glom <- tax_glom(physeq(), input$glomRank, NArm = FALSE) + taxTableGlom <- Glom %>% + tax_table() %>% + as.data.frame(stringsAsFactors = FALSE) %>% + dplyr::select(1:input$glomRank) %>% + tibble::rownames_to_column() + otuTableGlom <- Glom %>% + otu_table() %>% + as.data.frame(stringsAsFactors = FALSE) %>% + tibble::rownames_to_column() + joinGlom <- dplyr::left_join(taxTableGlom, otuTableGlom, by = "rowname") %>% + dplyr::select(-rowname) + beautifulTable(joinGlom) +}) + +output$sampleTable <- renderUI({ + validate(need(physeq(), "Requires an abundance dataset")) + box( + title = "Sample data table", + width = NULL, + status = "primary", + beautifulTable(tibble::rownames_to_column(as.data.frame(sample_data(physeq())), var = "SAMPLE")), + box( + title = "Class of sample data", + width = NULL, + status = "primary", + collapsible = TRUE, + collapsed = TRUE, + renderTable({(sapply(sample_data(physeq()), class))}, rownames = TRUE, colnames = FALSE) + ) + ) +}) diff --git a/panels/table-ui.R b/panels/table-ui.R new file mode 100644 index 0000000000000000000000000000000000000000..8d3b169bb2a40fe31959222f8ab87413fb856cfb --- /dev/null +++ b/panels/table-ui.R @@ -0,0 +1,4 @@ +otuTable <- fluidPage(withLoader(uiOutput("otuTable"))) +taxtable <- fluidPage(withLoader(uiOutput("taxTable"))) +glomTable <- fluidPage(withLoader(uiOutput("glomTable"))) +sampleTable <- fluidPage(withLoader(uiOutput("sampleTable"))) diff --git a/server.R b/server.R index b02a5798096427b7c7ac8ceee4b61b55b10db1da..edf7ffb35179f4eda4c7f333fc0fb7050823be73 100644 --- a/server.R +++ b/server.R @@ -6,6 +6,7 @@ library(phyloseq) library(phyloseq.extended) library(ggplot2) library(dplyr) +library(DT) library(magrittr) library(factoextra) @@ -15,6 +16,7 @@ shinyServer source("internals.R") source("panels/dataInput.R", local = TRUE) source("panels/Summary-server.R", local = TRUE) + source("panels/table-server.R", local = TRUE) source("panels/barplot-server.R", local = TRUE) source("panels/heatmap-server.R", local = TRUE) source("panels/rarefactionCurve-server.R", local = TRUE) diff --git a/ui.R b/ui.R index dd708fe950cf39095bd406c0236fa6e994c7b828..eb35c1b37955d513e4c627f537c9aff1a6f734a6 100644 --- a/ui.R +++ b/ui.R @@ -2,6 +2,7 @@ library(shinydashboard) library(shinymeta) library(shinycustomloader) source("panels/Summary-ui.R", local = TRUE) +source("panels/table-ui.R", local = TRUE) source("panels/barplot-ui.R", local = TRUE) source("panels/heatmap-ui.R", local = TRUE) source("panels/rarefactionCurve-ui.R", local = TRUE) @@ -28,7 +29,13 @@ dashboardHeader(title = "Easy16S"), icon = icon("download"), style = "width: 80% ; color: black ; background-color: gray90"), sidebarMenu( - menuItem("Summary", tabName = "Summary", icon = icon("table")), + menuItem("Summary", tabName = "Summary", icon = icon("dna")), + menuItem("Tables", icon = icon("table"), + menuSubItem("OTU table", tabName = "otuTable"), + menuSubItem("Taxonomy table", tabName = "taxtable"), + menuSubItem("Agglomerate OTU table", tabName = "glomTable"), + menuSubItem("Sample data table", tabName = "sampleTable") + ), menuItem("Barplot", tabName = "barplot", icon = icon("chart-bar")), menuItem("Heatmap", tabName = "heatmap", icon = icon("chess-board")), menuItem("Rarefaction curves", tabName = "rarefactionCurve", icon = icon("chart-line")), @@ -53,6 +60,10 @@ dashboardHeader(title = "Easy16S"), dashboardBody( tabItems( tabItem(tabName = "Summary", Summary), + tabItem(tabName = "otuTable", otuTable), + tabItem(tabName = "taxtable", taxtable), + tabItem(tabName = "glomTable", glomTable), + tabItem(tabName = "sampleTable", sampleTable), tabItem(tabName = "barplot", barplot), tabItem(tabName = "heatmap", heatmap), tabItem(tabName = "rarefactionCurve", rarefactionCurve),