Skip to content

Commit

Permalink
Add tests
Browse files Browse the repository at this point in the history
  • Loading branch information
RiboRings committed Oct 31, 2024
1 parent 60bb0c1 commit b7b4ee9
Show file tree
Hide file tree
Showing 13 changed files with 261 additions and 118 deletions.
2 changes: 0 additions & 2 deletions DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,6 @@ Suggests:
remotes,
rmarkdown,
testthat (>= 3.0.0)
Remotes:
github::microbiome/iSEEtree
URL: https://github.com/RiboRings/miaDash
BugReports: https://github.com/RiboRings/miaDash/issues
Roxygen: list(markdown = TRUE)
Expand Down
3 changes: 2 additions & 1 deletion NEWS
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,5 @@ Changes in version 0.1.0
Changes in version 0.2.0
* Added manipulate functionality
* Added estimate functionality
* Added panel layout customisation
* Added panel layout customisation
* Added unit testing
208 changes: 102 additions & 106 deletions R/landing_page.R
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,8 @@
#' @importFrom shinyjs disable
#' @importFrom utils data
.landing_page <- function(FUN, input, output, session) {

mia_datasets <- data(package = "mia")
mia_datasets <- mia_datasets$results[-c(2, 5), "Item"]
data(list = mia_datasets, package = "mia")

mia_datasets <- .import_datasets(-c(2, 5))

# nocov start
output$allPanels <- renderUI({
Expand All @@ -30,7 +28,7 @@

fluidRow(column(4, wellPanel(id = "import.panel",

titlePanel("Import"),
titlePanel("Import"),

tabsetPanel(id = "format",

Expand Down Expand Up @@ -60,159 +58,157 @@
fileInput(inputId = "rowdata", label = "rowData:",
accept = ".csv")

),
),

tabPanel(title = "Foreign", value = "foreign",
tabPanel(title = "Foreign", value = "foreign",

radioButtons(inputId = "ftype",
label = "Type:", choices = list("biom", "QZA",
"MetaPhlAn")),
radioButtons(inputId = "ftype",
label = "Type:", choices = list("biom", "QZA",
"MetaPhlAn")),

fileInput(inputId = "main.file",
label = "Main file:", accept = c(".biom",
".QZA", ".txt")),
fileInput(inputId = "main.file",
label = "Main file:", accept = c(".biom",
".QZA", ".txt")),

conditionalPanel(
condition = "input.ftype == 'biom'",
conditionalPanel(
condition = "input.ftype == 'biom'",

checkboxInput(inputId = "rm.tax.pref",
label = "Remove taxa prefixes"),
checkboxInput(inputId = "rm.tax.pref",
label = "Remove taxa prefixes"),

checkboxInput(inputId = "rank.from.pref",
label = "Derive taxa from prefixes")
),
checkboxInput(inputId = "rank.from.pref",
label = "Derive taxa from prefixes")
),

conditionalPanel(
condition = "input.ftype == 'MetaPhlAn'",
conditionalPanel(
condition = "input.ftype == 'MetaPhlAn'",

fileInput(inputId = "col.data", label = "colData:",
accept = ".tsv"),
fileInput(inputId = "col.data", label = "colData:",
accept = ".tsv"),

fileInput(inputId = "tree.file", label = "Tree:",
accept = ".tree")
)
fileInput(inputId = "tree.file", label = "Tree:",
accept = ".tree")
)

)
)

),
),

actionButton("import", "Upload", class = "btn-success",
style = .actionbutton_biocstyle)
actionButton("import", "Upload", class = "btn-success",
style = .actionbutton_biocstyle)

)),
)),

column(4, wellPanel(id = "manipulate.panel",

titlePanel("Manipulate"),
titlePanel("Manipulate"),

tabsetPanel(id = "manipulate",
tabsetPanel(id = "manipulate",

tabPanel(title = "Subset", value = "subset",
tabPanel(title = "Subset", value = "subset",

radioButtons(inputId = "subkeep", label = "Keep:",
choices = c("prevalent", "rare"), inline = TRUE),
radioButtons(inputId = "subkeep", label = "Keep:",
choices = c("prevalent", "rare"), inline = TRUE),

selectInput(inputId = "subassay", label = "Assay:",
choices = NULL),
selectInput(inputId = "subassay", label = "Assay:",
choices = NULL),

sliderInput(inputId = "prevalence", value = 0,
label = "Prevalence threshold:", step = 0.01,
min = 0, max = 1),
sliderInput(inputId = "prevalence", value = 0,
label = "Prevalence threshold:", step = 0.01,
min = 0, max = 1),

numericInput(inputId = "detection", value = 0,
label = "Detection threshold:", min = 0, step = 1)
numericInput(inputId = "detection", value = 0,
label = "Detection threshold:", min = 0, step = 1)

),
),

tabPanel(title = "Agglomerate", value = "agglomerate",
tabPanel(title = "Agglomerate", value = "agglomerate",

selectInput(inputId = "taxrank", label = "Taxonomic rank:",
choices = NULL)
selectInput(inputId = "taxrank",
label = "Taxonomic rank:", choices = NULL)

),
),

tabPanel(title = "Transform", value = "transform",
tabPanel(title = "Transform", value = "transform",

selectInput(inputId = "assay.type", label = "Assay:",
choices = NULL),
selectInput(inputId = "assay.type", label = "Assay:",
choices = NULL),

selectInput(inputId = "trans.method", label = "Method:",
choices = c("relabundance", "clr", "standardize")),
selectInput(inputId = "trans.method", label = "Method:",
choices = c("relabundance", "clr", "standardize")),

checkboxInput(inputId = "pseudocount",
label = "Pseudocount"),
checkboxInput(inputId = "pseudocount",
label = "Pseudocount"),

textInput(inputId = "assay.name", label = "Name:"),
textInput(inputId = "assay.name", label = "Name:"),

radioButtons(inputId = "margin", label = "Margin:",
choices = c("samples", "features"), inline = TRUE)
radioButtons(inputId = "margin", label = "Margin:",
choices = c("samples", "features"), inline = TRUE)

)),
)),

actionButton("apply", "Apply", class = "btn-success",
style = .actionbutton_biocstyle)
actionButton("apply", "Apply", class = "btn-success",
style = .actionbutton_biocstyle)

)),

column(4, wellPanel(id = "estimate.panel",

titlePanel("Estimate"),
titlePanel("Estimate"),

tabsetPanel(id = "estimate",
tabsetPanel(id = "estimate",

tabPanel(title = "Alpha", value = "alpha",
tabPanel(title = "Alpha", value = "alpha",

selectInput(inputId = "alpha.assay", label = "Assay:",
choices = NULL),
selectInput(inputId = "alpha.assay", label = "Assay:",
choices = NULL),

selectInput(inputId = "alpha.index", label = "Metric:",
choices = c("coverage", "shannon", "faith"),
multiple = TRUE),
selectInput(inputId = "alpha.index", label = "Metric:",
choices = c("coverage", "shannon", "faith"),
multiple = TRUE),

textInput(inputId = "alpha.name", label = "Name:")
textInput(inputId = "alpha.name", label = "Name:")

),
),

tabPanel(title = "Beta", value = "beta",
tabPanel(title = "Beta", value = "beta",

radioButtons(inputId = "bmethod", label = "Method:",
choices = c("MDS", "NMDS", "PCA", "RDA"), inline = TRUE),
radioButtons(inputId = "bmethod", label = "Method:",
choices = c("MDS", "NMDS", "PCA", "RDA"),
inline = TRUE),


selectInput(inputId = "beta.assay", label = "Assay:",
choices = NULL),
selectInput(inputId = "beta.assay", label = "Assay:",
choices = NULL),

conditionalPanel(
condition = "input.bmethod != 'PCA'",
conditionalPanel(
condition = "input.bmethod != 'PCA'",

selectInput(inputId = "beta.index", label = "Metric:",
choices = c("euclidean", "bray", "jaccard", "unifrac")),
),
selectInput(inputId = "beta.index", label = "Metric:",
choices = c("euclidean", "bray", "jaccard", "unifrac")),
),

conditionalPanel(
condition = "input.bmethod == 'RDA'",
conditionalPanel(
condition = "input.bmethod == 'RDA'",

textInput(inputId = "rda.formula", label = "Formula:",
placeholder = "data ~ var1 + var2 * var3"),
),
textInput(inputId = "rda.formula", label = "Formula:",
placeholder = "data ~ var1 + var2 * var3"),
),

numericInput(inputId = "ncomponents", value = 5,
label = "Number of components:", min = 1, step = 1),
numericInput(inputId = "ncomponents", value = 5,
label = "Number of components:", min = 1, step = 1),

textInput(inputId = "beta.name", label = "Name:")
textInput(inputId = "beta.name", label = "Name:")

)
)

),
),

actionButton("compute", "Compute", class = "btn-success",
style = .actionbutton_biocstyle)
actionButton("compute", "Compute", class = "btn-success",
style = .actionbutton_biocstyle)

))),

fluidRow(

column(4, wellPanel(id = "visualise.panel",
fluidRow(column(4, wellPanel(id = "visualise.panel",

titlePanel("Visualise"),

Expand All @@ -223,19 +219,19 @@
actionButton("launch", "Launch iSEE", class = "btn-success",
style = .actionbutton_biocstyle)

)),
)),

column(8, wellPanel(id = "output.panel",
column(8, wellPanel(id = "output.panel",

titlePanel("Output"),
titlePanel("Output"),

verbatimTextOutput(outputId = "object"),
verbatimTextOutput(outputId = "object"),

downloadButton(outputId = "download", label = "Download",
style = .actionbutton_biocstyle)
downloadButton(outputId = "download", label = "Download",
style = .actionbutton_biocstyle)

)))
)
))
))
})

## Disable navbar buttons that are not linked to any observer yet
Expand Down
2 changes: 2 additions & 0 deletions R/miaDash.R
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ miaDash <- function() {
#' @importFrom SingleCellExperiment reducedDims
.launch_isee <- function(FUN, initial, session, rObjects) {

# nocov start
tse <- rObjects$tse

initial <- lapply(initial, function(x) eval(parse(text = paste0(x, "()"))))
Expand All @@ -68,4 +69,5 @@ miaDash <- function() {
enable("iSEE_INTERNAL_citation_info") # citation info

invisible(NULL)
# nocov end
}
8 changes: 8 additions & 0 deletions R/observers.R
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
#' @importFrom TreeSummarizedExperiment TreeSummarizedExperiment
.create_import_observers <- function(input, rObjects) {

# nocov start
observeEvent(input$import, {

if( input$format == "dataset" ){
Expand Down Expand Up @@ -100,6 +101,7 @@
}

}, ignoreInit = TRUE, ignoreNULL = FALSE)
# nocov end

invisible(NULL)
}
Expand All @@ -111,6 +113,7 @@
#' transformAssay
.create_manipulate_observers <- function(input, rObjects) {

# nocov start
observeEvent(input$apply, {

if( input$manipulate == "subset" ){
Expand Down Expand Up @@ -172,6 +175,7 @@
}

}, ignoreInit = TRUE, ignoreNULL = TRUE)
# nocov end

invisible(NULL)
}
Expand All @@ -185,6 +189,7 @@
#' @importFrom vegan vegdist
.create_estimate_observers <- function(input, rObjects) {

# nocov start
observeEvent(input$compute, {

if( input$estimate == "alpha" ){
Expand Down Expand Up @@ -269,6 +274,7 @@
}

}, ignoreInit = TRUE, ignoreNULL = TRUE)
# nocov end

invisible(NULL)
}
Expand All @@ -280,6 +286,7 @@
#' @importFrom rintrojs introjs
.update_observers <- function(input, session, rObjects){

# nocov start
observe({

if( isS4(rObjects$tse) ){
Expand Down Expand Up @@ -311,6 +318,7 @@
introjs(session, options = list(steps = .landing_page_tour))

}, ignoreInit = TRUE)
# nocov end

invisible(NULL)
}
Expand Down
Loading

0 comments on commit b7b4ee9

Please sign in to comment.