Commit c1ce19e5 authored by Midoux Cedric's avatar Midoux Cedric

rework tables

parent 4024f03f
...@@ -103,14 +103,3 @@ beautifulTable <- function(data) { ...@@ -103,14 +103,3 @@ beautifulTable <- function(data) {
height = "auto" height = "auto"
) )
} }
collapsedBox <- function(data, title = title) {
box(
title = title,
width = NULL,
status = "primary",
collapsible = TRUE,
collapsed = TRUE,
data
)
}
...@@ -7,68 +7,3 @@ output$phyloseqPrint <- renderPrint({ ...@@ -7,68 +7,3 @@ output$phyloseqPrint <- renderPrint({
) )
physeq() 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)
})
Summary <- div(verbatimTextOutput("phyloseqPrint"), Summary <- fluidPage(
uiOutput("otuTable"), withLoader(verbatimTextOutput("phyloseqPrint")),
uiOutput("glomOtuTable"), tags$footer(
uiOutput("taxTable"), "Questions, problems or comments regarding this application should be sent to ",
uiOutput("sampleDataTable"), a(href = "mailto:cedric.midoux@inrae.fr?subject=[Easy16S]", "cedric.midoux@inrae.fr"),
uiOutput("sampleDataType"), align = "center",
tags$footer("Questions, problems or comments regarding this application should be sent to ", style = "position:absolute;bottom: 0;width: 100%;color: grey;padding: 10px;# background-color: white;z-index: 1000;"
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;"
)
)
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)
)
)
})
otuTable <- fluidPage(withLoader(uiOutput("otuTable")))
taxtable <- fluidPage(withLoader(uiOutput("taxTable")))
glomTable <- fluidPage(withLoader(uiOutput("glomTable")))
sampleTable <- fluidPage(withLoader(uiOutput("sampleTable")))
...@@ -6,6 +6,7 @@ library(phyloseq) ...@@ -6,6 +6,7 @@ library(phyloseq)
library(phyloseq.extended) library(phyloseq.extended)
library(ggplot2) library(ggplot2)
library(dplyr) library(dplyr)
library(DT)
library(magrittr) library(magrittr)
library(factoextra) library(factoextra)
...@@ -15,6 +16,7 @@ shinyServer ...@@ -15,6 +16,7 @@ shinyServer
source("internals.R") source("internals.R")
source("panels/dataInput.R", local = TRUE) source("panels/dataInput.R", local = TRUE)
source("panels/Summary-server.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/barplot-server.R", local = TRUE)
source("panels/heatmap-server.R", local = TRUE) source("panels/heatmap-server.R", local = TRUE)
source("panels/rarefactionCurve-server.R", local = TRUE) source("panels/rarefactionCurve-server.R", local = TRUE)
......
...@@ -2,6 +2,7 @@ library(shinydashboard) ...@@ -2,6 +2,7 @@ library(shinydashboard)
library(shinymeta) library(shinymeta)
library(shinycustomloader) library(shinycustomloader)
source("panels/Summary-ui.R", local = TRUE) source("panels/Summary-ui.R", local = TRUE)
source("panels/table-ui.R", local = TRUE)
source("panels/barplot-ui.R", local = TRUE) source("panels/barplot-ui.R", local = TRUE)
source("panels/heatmap-ui.R", local = TRUE) source("panels/heatmap-ui.R", local = TRUE)
source("panels/rarefactionCurve-ui.R", local = TRUE) source("panels/rarefactionCurve-ui.R", local = TRUE)
...@@ -28,7 +29,13 @@ dashboardHeader(title = "Easy16S"), ...@@ -28,7 +29,13 @@ dashboardHeader(title = "Easy16S"),
icon = icon("download"), icon = icon("download"),
style = "width: 80% ; color: black ; background-color: gray90"), style = "width: 80% ; color: black ; background-color: gray90"),
sidebarMenu( 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("Barplot", tabName = "barplot", icon = icon("chart-bar")),
menuItem("Heatmap", tabName = "heatmap", icon = icon("chess-board")), menuItem("Heatmap", tabName = "heatmap", icon = icon("chess-board")),
menuItem("Rarefaction curves", tabName = "rarefactionCurve", icon = icon("chart-line")), menuItem("Rarefaction curves", tabName = "rarefactionCurve", icon = icon("chart-line")),
...@@ -53,6 +60,10 @@ dashboardHeader(title = "Easy16S"), ...@@ -53,6 +60,10 @@ dashboardHeader(title = "Easy16S"),
dashboardBody( dashboardBody(
tabItems( tabItems(
tabItem(tabName = "Summary", Summary), 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 = "barplot", barplot),
tabItem(tabName = "heatmap", heatmap), tabItem(tabName = "heatmap", heatmap),
tabItem(tabName = "rarefactionCurve", rarefactionCurve), tabItem(tabName = "rarefactionCurve", rarefactionCurve),
......
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