diff --git a/DESCRIPTION b/DESCRIPTION index ae2bebc..f63e1bb 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,5 +1,5 @@ Package: miaDash -Version: 1.1.2 +Version: 1.1.3 Authors@R: c(person(given = "Giulio", family = "Benedetti", role = c("aut", "cre"), email = "giulio.benedetti@utu.fi", @@ -10,7 +10,7 @@ Authors@R: person(given = "Leo", family = "Lahti", role = c("aut"), email = "leo.lahti@iki.fi", comment = c(ORCID = "0000-0001-5537-637X"))) -Title: Shiny app for the interactive analysis and exploration of microbiome data +Title: Dashboard for the interactive analysis and exploration of microbiome data Description: miaDash provides a Graphical User Interface for the exploration of microbiome data. This way, no knowledge of programming is required to @@ -30,6 +30,7 @@ Imports: mia, rintrojs, scater, + scuttle, shinydashboard, shinyjs, S4Vectors, diff --git a/NAMESPACE b/NAMESPACE index 5662f41..0496495 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -26,6 +26,9 @@ importFrom(iSEEtree,RowGraphPlot) importFrom(iSEEtree,RowTreePlot) importFrom(iSEEtree,ScreePlot) importFrom(mia,addAlpha) +importFrom(mia,addHierarchyTree) +importFrom(mia,addPrevalence) +importFrom(mia,addPrevalentAbundance) importFrom(mia,agglomerateByRank) importFrom(mia,getDissimilarity) importFrom(mia,importBIOM) @@ -42,6 +45,7 @@ importFrom(mia,transformAssay) importFrom(rintrojs,introjs) importFrom(scater,runMDS) importFrom(scater,runPCA) +importFrom(scuttle,addPerCellQC) importFrom(shinydashboard,box) importFrom(shinydashboard,dashboardBody) importFrom(shinydashboard,dashboardHeader) diff --git a/NEWS b/NEWS index 906a3fb..a940602 100644 --- a/NEWS +++ b/NEWS @@ -1,3 +1,6 @@ +Changes in version 1.1.3 +* Introduced tab for Quality Control + Changes in version 1.1.2 * Added importers for HUMAnN, QIIME2 and Mothur * Improved biom importer diff --git a/R/constants.R b/R/constants.R index 28014b5..5d70700 100644 --- a/R/constants.R +++ b/R/constants.R @@ -50,4 +50,9 @@ NULL #' @rdname constants .betaMethods <- c("MDS", "NMDS", "PCA", "RDA") -#"TSNE", "UMAP") \ No newline at end of file +#"TSNE", "UMAP") + +#' @rdname constants +.qualityMetrics <- list("Library size" = "PerCellQC", + "Prevalence" = "Prevalence", "Prevalent abundance" = "PrevalentAbundance", + "Hierarchy tree" = "HierarchyTree") diff --git a/R/landing_page.R b/R/landing_page.R index bfb0af9..a344924 100644 --- a/R/landing_page.R +++ b/R/landing_page.R @@ -180,11 +180,17 @@ header = tagList( br(), selectInput(inputId = "estimate.assay", label = "Assay:", choices = NULL)), + + tabPanel(title = "Quality", value = "quality", + + checkboxGroupInput(inputId = "quality.metrics", + label = "Metrics:", + choices = .qualityMetrics)), tabPanel(title = "Alpha", value = "alpha", selectInput(inputId = "alpha.index", - label = "Metric:", multiple = TRUE, + label = "Metrics:", multiple = TRUE, choices = .alphaMetrics)), tabPanel(title = "Beta", value = "beta", diff --git a/R/observers.R b/R/observers.R index c4a8961..f360ab8 100644 --- a/R/observers.R +++ b/R/observers.R @@ -212,17 +212,37 @@ #' @rdname create_observers #' @importFrom stats as.formula -#' @importFrom mia addAlpha runNMDS runRDA getDissimilarity +#' @importFrom mia addAlpha runNMDS runRDA getDissimilarity addHierarchyTree +#' addPrevalence addPrevalentAbundance #' @importFrom TreeSummarizedExperiment rowTree #' @importFrom scater runMDS runPCA +#' @importFrom scuttle addPerCellQC #' @importFrom vegan vegdist .create_estimate_observers <- function(input, rObjects) { # nocov start observeEvent(input$compute, { - if( input$estimate == "alpha" ){ - + if( input$estimate == "quality" ){ + + isolate({ + req(input$estimate.assay) + + for( qmetric in input$quality.metrics ){ + + qfun <- eval(parse(text = paste0("add", qmetric))) + + qfun_args <- list(x = rObjects$tse, + assay.type = input$estimate.assay) + + rObjects$tse <- .update_tse(rObjects$tse, qfun, qfun_args) + + } + + }) + + }else if( input$estimate == "alpha" ){ + if( is.null(input$alpha.index) ){ .print_message("Please select one or more metrics.") return() @@ -230,13 +250,13 @@ isolate({ req(input$estimate.assay) - + if( input$estimate.name != "" ){ name <- input$estimate.name } else { name <- input$alpha.index } - + fun_args <- list(x = rObjects$tse, name = name, assay.type = input$estimate.assay, index = input$alpha.index) @@ -338,9 +358,6 @@ updateSelectInput(session, inputId = "estimate.assay", choices = assayNames(rObjects$tse)) - updateSelectInput(session, inputId = "estimate.assay", - choices = assayNames(rObjects$tse)) - updateNumericInput(session, inputId = "ncomponents", max = nrow(rObjects$tse) - 1) diff --git a/R/utils.R b/R/utils.R index 419d023..5e4380b 100644 --- a/R/utils.R +++ b/R/utils.R @@ -61,7 +61,7 @@ NULL } #' @rdname utils -.update_tse <- function(tse, fun, fun.args) { +.update_tse <- function(tse, fun, fun.args = list()) { tse <- tryCatch({withCallingHandlers({ @@ -119,6 +119,8 @@ NULL } #' @importFrom mia importBIOM +#' @importFrom SummarizedExperiment colData +#' @importFrom TreeSummarizedExperiment rowTree #' @importFrom S4Vectors DataFrame #' @importFrom ape read.tree #' @importFrom utils read.table diff --git a/man/constants.Rd b/man/constants.Rd index 1a128d4..0ff7237 100644 --- a/man/constants.Rd +++ b/man/constants.Rd @@ -9,6 +9,7 @@ \alias{.alphaMetrics} \alias{.betaMetrics} \alias{.betaMethods} +\alias{.qualityMetrics} \title{Constants} \format{ An object of class \code{character} of length 7. @@ -22,6 +23,8 @@ An object of class \code{character} of length 23. An object of class \code{character} of length 4. An object of class \code{character} of length 4. + +An object of class \code{list} of length 4. } \usage{ .miaDashDefaultPanels @@ -35,6 +38,8 @@ An object of class \code{character} of length 4. .betaMetrics .betaMethods + +.qualityMetrics } \description{ Constant values used throughout the miaDash app. diff --git a/man/utils.Rd b/man/utils.Rd index bab8c36..da4acd3 100644 --- a/man/utils.Rd +++ b/man/utils.Rd @@ -11,7 +11,7 @@ \usage{ .import_datasets(selection) -.update_tse(tse, fun, fun.args) +.update_tse(tse, fun, fun.args = list()) .print_message(..., title = "Invalid input:")