From f8b21b5154926e647d01492979045242ac6c545c Mon Sep 17 00:00:00 2001 From: BananaCancer <72008568+BananaCancer@users.noreply.github.com> Date: Fri, 7 Jul 2023 15:05:25 +0300 Subject: [PATCH 1/4] Updated plotDMN to work with newest DMM version (#80) * Updated plotDMN to work with newest DMM version * Suppressed warnings in the examples * Updated examples * Updated DESCRIPTION and NEWS files * Updated workflow with bluster github install * Removed bluster dependency * New examples * Additional changes * Added bluster dependency * Removed bluster install in check script --- .github/workflows/check-bioc-devel.yml | 2 +- DESCRIPTION | 8 +++++--- NEWS | 3 +++ R/plotDMN.R | 26 ++++++++++++++++++++------ man/plotDMN.Rd | 16 ++++++++++++---- 5 files changed, 41 insertions(+), 14 deletions(-) diff --git a/.github/workflows/check-bioc-devel.yml b/.github/workflows/check-bioc-devel.yml index 2fb9eb9a..80850292 100644 --- a/.github/workflows/check-bioc-devel.yml +++ b/.github/workflows/check-bioc-devel.yml @@ -167,7 +167,7 @@ jobs: BiocManager::install("HDF5Array") BiocManager::install("fionarhuang/TreeSummarizedExperiment") BiocManager::install("microbiome/mia") - devtools::install_github("microbiome/miaTime") + devtools::install_github("microbiome/miaTime") # rspm is out of date install.packages("matrixStats", repos = "https://cran.rstudio.com/") diff --git a/DESCRIPTION b/DESCRIPTION index 00fb93a4..7423711d 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,6 +1,6 @@ Package: miaViz Title: Microbiome Analysis Plotting and Visualization -Version: 1.9.1 +Version: 1.9.2 Authors@R: c(person(given = "Tuomas", family = "Borman", role = c("aut", "cre"), email = "tuomas.v.borman@utu.fi", @@ -10,7 +10,8 @@ Authors@R: comment = c(ORCID = "0000-0001-5064-0928")), person(given = "Leo", family = "Lahti", role = c("aut"), email = "leo.lahti@iki.fi", - comment = c(ORCID = "0000-0001-5537-637X")) + comment = c(ORCID = "0000-0001-5537-637X")), + person(given = "Basil", family = "Courbayre", role = c("ctb")) ) Description: The miaViz package implements functions to visualize TreeSummarizedExperiment objects especially in the context of microbiome @@ -54,7 +55,8 @@ Suggests: testthat, patchwork, vegan, - microbiomeDataSets + microbiomeDataSets, + bluster Roxygen: list(markdown = TRUE) RoxygenNote: 7.2.3 VignetteBuilder: knitr diff --git a/NEWS b/NEWS index c6a291fb..45477bdf 100644 --- a/NEWS +++ b/NEWS @@ -17,3 +17,6 @@ Changes in version 1.5.x Changes in version 1.7.x + Fixed plotGraph* that was broked due changes in dependencies + +Changes in version 1.9.x ++ Updated plotDMN to work with newest mia version \ No newline at end of file diff --git a/R/plotDMN.R b/R/plotDMN.R index 2d707dd3..f646fd5e 100644 --- a/R/plotDMN.R +++ b/R/plotDMN.R @@ -23,11 +23,19 @@ #' @name plotDMN #' #' @examples -#' data(dmn_se, package = "mia") -#' names(metadata(dmn_se)) -#' -#' # plot the fit -#' plotDMNFit(dmn_se, type = "laplace") +#' library(mia) +#' library(bluster) +#' +#' # Get dataset +#' data("peerj13075", package = "mia") +#' tse <- peerj13075 +#' +#' # Cluster the samples +#' tse <- cluster(tse, DmmParam(k = 1:4), name = "DMM", full = TRUE) +#' +#' # Plot the fit +#' plotDMNFit(tse, name = "DMM", type = "laplace") +#' NULL #' @rdname plotDMN @@ -43,7 +51,13 @@ setGeneric("plotDMNFit", signature = "x", setMethod("plotDMNFit", signature = c(x = "SummarizedExperiment"), function(x, name = "DMN", type = c("laplace","AIC","BIC")){ # - dmn <- getDMN(x, name) + if (!is.null(metadata(x)[[name]]$dmm)) { + dmn <- metadata(x)[[name]]$dmm + } else { + .Deprecated(old="getDMN", new="cluster", + "Now runDMN and calculateDMN are deprecated. Use cluster with DMMParam parameter and full parameter set as true instead.") + dmn <- metadata(x)[[name]] + } fit_FUN <- mia:::.get_dmn_fit_FUN(type) # k <- vapply(dmn, function(d){ncol(mixture(d))}, numeric(1)) diff --git a/man/plotDMN.Rd b/man/plotDMN.Rd index e44f557d..5f49c8dc 100644 --- a/man/plotDMN.Rd +++ b/man/plotDMN.Rd @@ -30,11 +30,19 @@ object contain the DMN data in \code{metadata}.} To plot DMN fits generated with \code{mia} use \code{plotDMNFit}. } \examples{ -data(dmn_se, package = "mia") -names(metadata(dmn_se)) +library(mia) +library(bluster) + +# Get dataset +data("peerj13075", package = "mia") +tse <- peerj13075 + +# Cluster the samples +tse <- cluster(tse, DmmParam(k = 1:4), name = "DMM", full = TRUE) + +# Plot the fit +plotDMNFit(tse, name = "DMM", type = "laplace") -# plot the fit -plotDMNFit(dmn_se, type = "laplace") } \seealso{ \code{\link[mia:calculateDMN]{calculateDMN}} From e7778c5e0cb224d80ee0a463f10bc4ba4de24dbb Mon Sep 17 00:00:00 2001 From: Tuomas Borman <60338854+TuomasBorman@users.noreply.github.com> Date: Sat, 8 Jul 2023 14:02:17 +0300 Subject: [PATCH 2/4] Fix build (#81) * bump x.y.z version to even y prior to creation of RELEASE_3_16 branch * bump x.y.z version to odd y following creation of RELEASE_3_16 branch * bump x.y.z version to even y prior to creation of RELEASE_3_17 branch * bump x.y.z version to odd y following creation of RELEASE_3_17 branch * Fix build * up * up --------- Co-authored-by: J Wokaty Co-authored-by: J Wokaty --- DESCRIPTION | 4 ++-- NAMESPACE | 1 - R/miaViz.R | 1 - 3 files changed, 2 insertions(+), 4 deletions(-) diff --git a/DESCRIPTION b/DESCRIPTION index 7423711d..fdacfcc3 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -31,7 +31,6 @@ Imports: methods, stats, S4Vectors, - miaTime, BiocGenerics, BiocParallel, DelayedArray, @@ -56,7 +55,8 @@ Suggests: patchwork, vegan, microbiomeDataSets, - bluster + bluster, + miaTime Roxygen: list(markdown = TRUE) RoxygenNote: 7.2.3 VignetteBuilder: knitr diff --git a/NAMESPACE b/NAMESPACE index af07bf1b..c4a449db 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -33,7 +33,6 @@ import(ggplot2) import(ggraph) import(methods) import(mia) -import(miaTime) importFrom(BiocGenerics,ncol) importFrom(BiocGenerics,nrow) importFrom(BiocParallel,SerialParam) diff --git a/R/miaViz.R b/R/miaViz.R index 7bf97ad8..0838ab41 100644 --- a/R/miaViz.R +++ b/R/miaViz.R @@ -13,7 +13,6 @@ NULL #' @import methods #' @import TreeSummarizedExperiment #' @import mia -#' @import miaTime #' @import ggplot2 #' @import ggraph #' @importFrom rlang sym !! := From b811da566810617a8bf866b6f32eb3ce96152993 Mon Sep 17 00:00:00 2001 From: Tuomas Borman <60338854+TuomasBorman@users.noreply.github.com> Date: Wed, 30 Aug 2023 16:00:00 +0300 Subject: [PATCH 3/4] Fix build (#82) * up * up * up --- R/plotAbundance.R | 2 +- R/plotAbundanceDensity.R | 2 +- R/plotSeries.R | 2 +- man/plotAbundance.Rd | 2 +- man/plotAbundanceDensity.Rd | 2 +- man/plotSeries.Rd | 2 +- vignettes/miaViz.Rmd | 8 ++++---- 7 files changed, 10 insertions(+), 10 deletions(-) diff --git a/R/plotAbundance.R b/R/plotAbundance.R index d1943870..c64a594e 100644 --- a/R/plotAbundance.R +++ b/R/plotAbundance.R @@ -110,7 +110,7 @@ #' ## Compositional barplot with top 5 taxa and samples sorted by "Bacteroidetes" #' #' # Getting top taxa on a Phylum level -#' se <- transformCounts(se, method="relabundance") +#' se <- transformAssay(se, method="relabundance") #' se_phylum <- agglomerateByRank(se, rank ="Phylum", onRankOnly=TRUE) #' top_taxa <- getTopTaxa(se_phylum,top = 5, assay.type = "relabundance") #' diff --git a/R/plotAbundanceDensity.R b/R/plotAbundanceDensity.R index b8d3ea8f..b8d314d6 100644 --- a/R/plotAbundanceDensity.R +++ b/R/plotAbundanceDensity.R @@ -94,7 +94,7 @@ #' plotAbundanceDensity(tse, assay.type = "counts") #' #' # Counts relative abundances -#' tse <- transformCounts(tse, method = "relabundance") +#' tse <- transformAssay(tse, method = "relabundance") #' #' # Plots the relative abundance of 10 most abundant taxa. #' # "nationality" information is used to color the points. X-axis is log-scaled. diff --git a/R/plotSeries.R b/R/plotSeries.R index 637a524c..751825c5 100644 --- a/R/plotSeries.R +++ b/R/plotSeries.R @@ -67,7 +67,7 @@ #' colour_by = "Family") #' #' # Counts relative abundances -#' object <- transformCounts(object, method = "relabundance") +#' object <- transformAssay(object, method = "relabundance") #' #' # Selects taxa #' taxa <- c("seq_1", "seq_2", "seq_3", "seq_4", "seq_5") diff --git a/man/plotAbundance.Rd b/man/plotAbundance.Rd index bffe42bb..8cd5cbdc 100644 --- a/man/plotAbundance.Rd +++ b/man/plotAbundance.Rd @@ -134,7 +134,7 @@ wrap_plots(plot, ncol = 1, heights = c(0.8,0.2)) ## Compositional barplot with top 5 taxa and samples sorted by "Bacteroidetes" # Getting top taxa on a Phylum level -se <- transformCounts(se, method="relabundance") +se <- transformAssay(se, method="relabundance") se_phylum <- agglomerateByRank(se, rank ="Phylum", onRankOnly=TRUE) top_taxa <- getTopTaxa(se_phylum,top = 5, assay.type = "relabundance") diff --git a/man/plotAbundanceDensity.Rd b/man/plotAbundanceDensity.Rd index 27acde66..8b8a7f3b 100644 --- a/man/plotAbundanceDensity.Rd +++ b/man/plotAbundanceDensity.Rd @@ -112,7 +112,7 @@ tse <- microbiomeDataSets::atlas1006() plotAbundanceDensity(tse, assay.type = "counts") # Counts relative abundances -tse <- transformCounts(tse, method = "relabundance") +tse <- transformAssay(tse, method = "relabundance") # Plots the relative abundance of 10 most abundant taxa. # "nationality" information is used to color the points. X-axis is log-scaled. diff --git a/man/plotSeries.Rd b/man/plotSeries.Rd index 75405a2e..e45fa6aa 100644 --- a/man/plotSeries.Rd +++ b/man/plotSeries.Rd @@ -96,7 +96,7 @@ plotSeries(object, colour_by = "Family") # Counts relative abundances -object <- transformCounts(object, method = "relabundance") +object <- transformAssay(object, method = "relabundance") # Selects taxa taxa <- c("seq_1", "seq_2", "seq_3", "seq_4", "seq_5") diff --git a/vignettes/miaViz.Rmd b/vignettes/miaViz.Rmd index 2fbceaea..99b0dc2c 100644 --- a/vignettes/miaViz.Rmd +++ b/vignettes/miaViz.Rmd @@ -63,7 +63,7 @@ However, if the `rank` is set not `NULL` a bar plot is returned. At the same time the `features` argument can be set to `NULL` (default). ```{r} -GlobalPatterns <- transformCounts(GlobalPatterns, method = "relabundance") +GlobalPatterns <- transformAssay(GlobalPatterns, method = "relabundance") ``` ```{r} @@ -261,7 +261,7 @@ plotColGraph(altExp(GlobalPatterns,"Genus"), library("miaTime") data(SilvermanAGutData, package="miaTime") tse <- SilvermanAGutData -tse <- transformCounts(tse, method = "relabundance") +tse <- transformAssay(tse, method = "relabundance") taxa <- getTopTaxa(tse, 2) ``` @@ -334,7 +334,7 @@ if(!requireNamespace("devtools", quietly = TRUE)){ BiocManager::install("devtools") } if(!requireNamespace("miaTime", quietly = TRUE)){ - devtools::install_github("microbiome/miaTime") + devtools::install_github("microbiome/miaTime", upgrade = "never") } ``` @@ -345,7 +345,7 @@ Principal Coordinates Analysis using Bray-Curtis dissimilarity on the library(miaTime) data(hitchip1006, package = "miaTime") tse <- hitchip1006 -tse <- transformCounts(tse, method = "relabundance") +tse <- transformAssay(tse, method = "relabundance") ## Ordination with PCoA with Bray-Curtis dissimilarity tse <- runMDS(tse, FUN = vegan::vegdist, method = "bray", name = "PCoA_BC", assay.type = "relabundance", na.rm = TRUE) From b37bbbf86f8e0046605a2186e9245fed4c7d2464 Mon Sep 17 00:00:00 2001 From: TuomasBorman Date: Thu, 31 Aug 2023 09:37:21 +0300 Subject: [PATCH 4/4] up --- .Rbuildignore | 2 ++ .gitignore | 2 ++ R/plotCCA.R | 8 ++++---- 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/.Rbuildignore b/.Rbuildignore index c46ab48e..0f56b95e 100644 --- a/.Rbuildignore +++ b/.Rbuildignore @@ -5,3 +5,5 @@ .RData .pdf inst/extras/ +^doc$ +^Meta$ diff --git a/.gitignore b/.gitignore index b424f209..3c152361 100644 --- a/.gitignore +++ b/.gitignore @@ -3,3 +3,5 @@ inst/doc docs .Rhistory *.RData +/doc/ +/Meta/ diff --git a/R/plotCCA.R b/R/plotCCA.R index ca17d9bd..d146f6e0 100644 --- a/R/plotCCA.R +++ b/R/plotCCA.R @@ -142,7 +142,7 @@ setMethod("plotRDA", signature = c(object = "SingleCellExperiment"), vector_label <- rownames(vector_data) # Make labels more tidy if( all_var_found ){ - vector_label <- .tidy_vector_labels(vector_label, coldata) + vector_label <- .tidy_vector_labels(vector_label, coldata, ...) } # Add to df vector_data$vector_label <- vector_label @@ -172,7 +172,7 @@ setMethod("plotRDA", signature = c(object = "SingleCellExperiment"), # Get vector labels vector_label <- vector_data[["vector_label"]] # Add significance to vector labels - vector_label <- .add_signif_to_vector_labels(vector_label, variable_names, signif_data) + vector_label <- .add_signif_to_vector_labels(vector_label, variable_names, signif_data, ...) vector_data[["vector_label"]] <- vector_label } else{ # If it cannot be found, give warning @@ -217,7 +217,7 @@ setMethod("plotRDA", signature = c(object = "SingleCellExperiment"), # Make vector labels more tidy, i.e, separate variable and group names. # Replace also underscores with space .tidy_vector_labels <- function( - vector_label, coldata, sep_group = "\U2012", sep_underscore = " "){ + vector_label, coldata, sep_group = "\U2012", sep_underscore = " ", ...){ # Get variable names from sample metadata var_names <- colnames(coldata) # Loop through vector labels @@ -242,7 +242,7 @@ setMethod("plotRDA", signature = c(object = "SingleCellExperiment"), } # This function adds significance info to vector labels -.add_signif_to_vector_labels <- function(vector_label, var_names, signif_data, sep_underscore = " "){ +.add_signif_to_vector_labels <- function(vector_label, var_names, signif_data, sep_underscore = " ", ...){ # Replace underscores from significance data and variable names to match labels rownames(signif_data) <- sapply(rownames(signif_data), function(x) gsub("_", sep_underscore, x)) var_names <- sapply(var_names, function(x) gsub("_", sep_underscore, x))