Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
Package: miaDash
Version: 1.1.1
Version: 1.1.2
Authors@R:
c(person(given = "Giulio", family = "Benedetti", role = c("aut", "cre"),
email = "giulio.benedetti@utu.fi",
Expand All @@ -25,7 +25,6 @@ Depends:
shiny
Imports:
ape,
biomformat,
htmltools,
iSEEtree (>= 1.1.4),
mia,
Expand Down
7 changes: 5 additions & 2 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ importFrom(SummarizedExperiment,colData)
importFrom(TreeSummarizedExperiment,TreeSummarizedExperiment)
importFrom(TreeSummarizedExperiment,rowTree)
importFrom(ape,read.tree)
importFrom(biomformat,read_biom)
importFrom(htmltools,HTML)
importFrom(htmltools,br)
importFrom(htmltools,div)
Expand All @@ -28,9 +27,12 @@ importFrom(iSEEtree,RowTreePlot)
importFrom(iSEEtree,ScreePlot)
importFrom(mia,addAlpha)
importFrom(mia,agglomerateByRank)
importFrom(mia,convertFromBIOM)
importFrom(mia,getDissimilarity)
importFrom(mia,importBIOM)
importFrom(mia,importHUMAnN)
importFrom(mia,importMetaPhlAn)
importFrom(mia,importMothur)
importFrom(mia,importQIIME2)
importFrom(mia,runNMDS)
importFrom(mia,runRDA)
importFrom(mia,subsetByPrevalent)
Expand All @@ -51,4 +53,5 @@ importFrom(stats,as.formula)
importFrom(utils,data)
importFrom(utils,packageVersion)
importFrom(utils,read.csv)
importFrom(utils,read.table)
importFrom(vegan,vegdist)
34 changes: 19 additions & 15 deletions NEWS
Original file line number Diff line number Diff line change
@@ -1,24 +1,28 @@
Changes in version 0.1.0
* Initialised app
* Added import functionality
Changes in version 1.1.2
* Added importers for HUMAnN, QIIME2 and Mothur
* Improved biom importer

Changes in version 0.2.0
* Added manipulate functionality
* Added estimate functionality
* Added panel layout customisation
* Added unit testing
Changes in version 0.99.12
* Fixed tab title

Changes in version 0.99.2
* Moved to shinydashboard
Changes in version 0.99.5
* Implemented error check system
* Added mia logo

Changes in version 0.99.3
* Added tree import option
* Fixed bugs with RDS and unifrac
* Added clickable title box

Changes in version 0.99.5
* Implemented error check system
* Added mia logo
Changes in version 0.99.2
* Moved to shinydashboard

Changes in version 0.99.12
* Fixed tab title
Changes in version 0.2.0
* Added manipulate functionality
* Added estimate functionality
* Added panel layout customisation
* Added unit testing

Changes in version 0.1.0
* Initialised app
* Added import functionality
58 changes: 38 additions & 20 deletions R/landing_page.R
Original file line number Diff line number Diff line change
Expand Up @@ -73,36 +73,54 @@

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

radioButtons(inputId = "ftype",
label = "Type:", choices = list("biom", "QZA",
"MetaPhlAn"), inline = TRUE),
radioButtons(inputId = "ftype", label = "Type:",
choices = list("biom", "HUMAnN", "MetaPhlAn",
"Mothur", "QIIME2"), inline = TRUE),

fileInput(inputId = "main.file",
label = "Main file:", accept = c(".biom",
".QZA", ".txt"),
placeholder = "biom, QZA or txt"),
".tsv", ".shared", ".QZA", ".txt"),
placeholder = "biom, tsv, shared, QZA or txt"),
div(style = "margin-top: -20px"),


fileInput(inputId = "col.data", label = "colData:",
accept = c(".tsv", ".design"),
placeholder = "tsv or design"),
div(style = "margin-top: -20px"),

conditionalPanel(
condition = "input.ftype == 'biom'",
condition = "input.ftype == 'Mothur' | input.ftype == 'QIIME2'",

fileInput(inputId = "f.rowdata",
label = "rowData:", accept = c(".taxonomy",
".qza"), placeholder = "taxonomy or qza"),
div(style = "margin-top: -20px")),

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

fileInput(inputId = "tree.file",
label = "rowTree:", placeholder = "tree.tree",
accept = c(".tree", ".tre", ".qza")),
div(style = "margin-top: -20px")),

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

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

label = "Remove taxa prefixes")),

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

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

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

fileInput(inputId = "col.data",
label = "colData:", accept = ".tsv",
placeholder = "coldata.tsv"),
div(style = "margin-top: -20px"),

fileInput(inputId = "tree.file",
label = "Tree:", placeholder = "tree.tree",
accept = c(".tree", ".tre"))))),
condition = "input.ftype == 'HUMAnN'",

checkboxInput(inputId = "rm.hum.suf",
label = "Remove sample suffix")))),

actionButton("import", "Upload", class = "btn-primary")),

Expand Down
61 changes: 43 additions & 18 deletions R/observers.R
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,11 @@
#' @importFrom utils read.csv
#' @importFrom ape read.tree
#' @importFrom S4Vectors DataFrame
#' @importFrom biomformat read_biom
#' @importFrom mia convertFromBIOM importMetaPhlAn
#' @importFrom mia importHUMAnN importMetaPhlAn importQIIME2 importMothur
#' addAlpha
#' @importFrom TreeSummarizedExperiment TreeSummarizedExperiment
.create_import_observers <- function(input, rObjects) {

# nocov start
observeEvent(input$import, {

Expand Down Expand Up @@ -72,33 +72,58 @@

isolate({
req(input$main.file)


coldata <- .set_optarg(input$col.data$datapath,
alternative = input$col.data$datapath)

treefile <- .set_optarg(input$tree.file$datapath,
alternative = input$tree.file$datapath)

if( input$ftype == "biom" ){

biom_object <- read_biom(input$main.file$datapath)

fun_args <- list(x = biom_object,
fun_args <- list(file = input$main.file$datapath,
col.data = coldata, tree.file = treefile,
removeTaxaPrefixes = input$rm.tax.pref,
rankFromPrefix = input$rank.from.pref)

rObjects$tse <- .update_tse(
rObjects$tse, convertFromBIOM, fun_args
rObjects$tse, .importBIOM, fun_args
)

} else if( input$ftype == "MetaPhlAn" ){

coldata <- .set_optarg(input$col.data$datapath,
alternative = input$col.data$datapath)
}else if( input$ftype == "HUMAnN" ){

fun_args <- list(file = input$main.file$datapath,
col.data = coldata,
prefix.rm = input$rm.tax.pref,
remove.suffix = input$rm.hum.suf)

treefile <- .set_optarg(input$tree.file$datapath)

rObjects$tse <- .update_tse(
rObjects$tse, importHUMAnN, fun_args
)

}else if( input$ftype == "MetaPhlAn" ){

fun_args <- list(file = input$main.file$datapath,
col.data = coldata, tree.file = treefile)

rObjects$tse <- .update_tse(
rObjects$tse, importMetaPhlAn, fun_args
)

rObjects$tse, importMetaPhlAn, fun_args
)

}else if( input$ftype %in% c("Mothur", "QIIME2") ){

imp_fun <- eval(parse(text = paste0("import", input$ftype)))

rowdata <- .set_optarg(input$f.rowdata$datapath,
alternative = input$f.rowdata$datapath)

fun_args <- list(assay.file = input$main.file$datapath,
row.file = input, col.file = rowdata)

rObjects$tse <- .update_tse(
rObjects$tse, imp_fun, fun_args
)

}

})
Expand Down
21 changes: 21 additions & 0 deletions R/utils.R
Original file line number Diff line number Diff line change
Expand Up @@ -116,4 +116,25 @@ NULL

cond <- all(vars %in% names(colData(tse)))
return(cond)
}

#' @importFrom mia importBIOM
#' @importFrom S4Vectors DataFrame
#' @importFrom ape read.tree
#' @importFrom utils read.table
.importBIOM <- function(file, col.data = NULL, tree.file = NULL, ...){

tse <- importBIOM(file, ...)

if( !is.null(col.data) ){
coldata <- read.table(file = col.data, header = TRUE, sep = "\t")
rownames(coldata) <- colnames(tse)
colData(tse) <- DataFrame(coldata)
}

if( !is.null(tree.file) ){
rowTree(tse) <- read.tree(tree.file)
}

return(tse)
}
Loading