From 9995a5ab66ba2b8314f22307ed1d81c3f8c1b776 Mon Sep 17 00:00:00 2001 From: thpralas Date: Mon, 22 Apr 2024 11:46:41 +0300 Subject: [PATCH 1/3] replace getPrevalent* and getTop* functions --- DESCRIPTION | 2 +- NEWS | 1 + R/plotAbundance.R | 2 +- R/plotAbundanceDensity.R | 2 +- R/plotPrevalence.R | 2 +- R/plotSeries.R | 4 ++-- R/plotTree.R | 4 ++-- man/plotAbundance.Rd | 2 +- man/plotPrevalence.Rd | 2 +- man/plotSeries.Rd | 4 ++-- man/plotTree.Rd | 4 ++-- tests/testthat/test-2plotTree.R | 2 +- vignettes/miaViz.Rmd | 8 ++++---- 13 files changed, 20 insertions(+), 19 deletions(-) diff --git a/DESCRIPTION b/DESCRIPTION index b678d7ed..d30de098 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,6 +1,6 @@ Package: miaViz Title: Microbiome Analysis Plotting and Visualization -Version: 1.11.3 +Version: 1.11.4 Authors@R: c(person(given = "Tuomas", family = "Borman", role = c("aut", "cre"), email = "tuomas.v.borman@utu.fi", diff --git a/NEWS b/NEWS index 344736e8..ac32b5a9 100644 --- a/NEWS +++ b/NEWS @@ -24,3 +24,4 @@ Changes in version 1.9.x Changes in version 1.11.x + replace addTaxonomyTree with addHierarchyTree after renaming in mia package ++ replace getPrevalent* with getPrevalent and getTop* with getTop diff --git a/R/plotAbundance.R b/R/plotAbundance.R index 29f2adad..9798e031 100644 --- a/R/plotAbundance.R +++ b/R/plotAbundance.R @@ -112,7 +112,7 @@ #' # Getting top taxa on a Phylum level #' se <- transformAssay(se, method="relabundance") #' se_phylum <- agglomerateByRank(se, rank ="Phylum", onRankOnly=TRUE) -#' top_taxa <- getTopFeatures(se_phylum,top = 5, assay.type = "relabundance") +#' top_taxa <- getTop(se_phylum,top = 5, assay.type = "relabundance") #' #' # Renaming the "Phylum" rank to keep only top taxa and the rest to "Other" #' phylum_renamed <- lapply(rowData(se)$Phylum, diff --git a/R/plotAbundanceDensity.R b/R/plotAbundanceDensity.R index 278c2063..ae3749d5 100644 --- a/R/plotAbundanceDensity.R +++ b/R/plotAbundanceDensity.R @@ -214,7 +214,7 @@ setMethod("plotAbundanceDensity", signature = c(object = "SummarizedExperiment") # Gets the assay mat <- assay(object, assay.type, withDimnames = TRUE) # Gets the most abundant taxa - top_taxa <- getTopFeatures(object, top = n, assay.type = assay.type) + top_taxa <- getTop(object, top = n, assay.type = assay.type) # Subsets abundance table by taking taxa of highest abundance mat <- mat[top_taxa, , drop=FALSE] # enable conversion to data.frame for non-matrix assays, e.g. sparseMatrices diff --git a/R/plotPrevalence.R b/R/plotPrevalence.R index a67ea4b3..6e082d8c 100644 --- a/R/plotPrevalence.R +++ b/R/plotPrevalence.R @@ -78,7 +78,7 @@ #' \code{rank} argument. #' #' To exclude certain taxa, preprocess \code{x} to your liking, for example -#' with subsetting via \code{getPrevalentTaxa} or +#' with subsetting via \code{getPrevalent} or #' \code{agglomerateByPrevalence}. #' #' @return diff --git a/R/plotSeries.R b/R/plotSeries.R index 5b3eae12..46cdfac3 100644 --- a/R/plotSeries.R +++ b/R/plotSeries.R @@ -63,7 +63,7 @@ #' # Plots 2 most abundant taxa, which are colored by their family #' plotSeries(object, #' x = "DAY_ORDER", -#' y = getTopFeatures(object, 2), +#' y = getTop(object, 2), #' colour_by = "Family") #' #' # Counts relative abundances @@ -82,7 +82,7 @@ #' # In addition to 'colour_by' and 'linetype_by', 'size_by' can also be used to group taxa. #' plotSeries(object, #' x = "DAY_ORDER", -#' y = getTopFeatures(object, 5), +#' y = getTop(object, 5), #' colour_by = "Family", #' size_by = "Phylum", #' assay.type = "counts") diff --git a/R/plotTree.R b/R/plotTree.R index 0aea3015..8cb88bc8 100644 --- a/R/plotTree.R +++ b/R/plotTree.R @@ -112,7 +112,7 @@ #' log(rowData(altExp(GlobalPatterns,"Genus"))$mean) #' rowData(altExp(GlobalPatterns,"Genus"))$detected <- #' rowData(altExp(GlobalPatterns,"Genus"))$detected / 100 -#' top_genus <- getTopFeatures(altExp(GlobalPatterns,"Genus"), +#' top_genus <- getTop(altExp(GlobalPatterns,"Genus"), #' method="mean", #' top=100L, #' assay.type="counts") @@ -149,7 +149,7 @@ #' # please note that the original tree of GlobalPatterns is dropped by #' # unsplitByRanks #' altExps(GlobalPatterns) <- splitByRanks(GlobalPatterns) -#' top_phyla <- getTopFeatures(altExp(GlobalPatterns,"Phylum"), +#' top_phyla <- getTop(altExp(GlobalPatterns,"Phylum"), #' method="mean", #' top=10L, #' assay.type="counts") diff --git a/man/plotAbundance.Rd b/man/plotAbundance.Rd index eb29a844..02a8222f 100644 --- a/man/plotAbundance.Rd +++ b/man/plotAbundance.Rd @@ -136,7 +136,7 @@ wrap_plots(plot, ncol = 1, heights = c(0.8,0.2)) # Getting top taxa on a Phylum level se <- transformAssay(se, method="relabundance") se_phylum <- agglomerateByRank(se, rank ="Phylum", onRankOnly=TRUE) -top_taxa <- getTopFeatures(se_phylum,top = 5, assay.type = "relabundance") +top_taxa <- getTop(se_phylum,top = 5, assay.type = "relabundance") # Renaming the "Phylum" rank to keep only top taxa and the rest to "Other" phylum_renamed <- lapply(rowData(se)$Phylum, diff --git a/man/plotPrevalence.Rd b/man/plotPrevalence.Rd index 0884ae88..3aa55b78 100644 --- a/man/plotPrevalence.Rd +++ b/man/plotPrevalence.Rd @@ -146,7 +146,7 @@ Agglomeration on different taxonomic levels is available through the \code{rank} argument. To exclude certain taxa, preprocess \code{x} to your liking, for example -with subsetting via \code{getPrevalentTaxa} or +with subsetting via \code{getPrevalent} or \code{agglomerateByPrevalence}. } \examples{ diff --git a/man/plotSeries.Rd b/man/plotSeries.Rd index 44e10314..a6c4bd29 100644 --- a/man/plotSeries.Rd +++ b/man/plotSeries.Rd @@ -92,7 +92,7 @@ object <- SilvermanAGutData # Plots 2 most abundant taxa, which are colored by their family plotSeries(object, x = "DAY_ORDER", - y = getTopFeatures(object, 2), + y = getTop(object, 2), colour_by = "Family") # Counts relative abundances @@ -111,7 +111,7 @@ plotSeries(object[taxa,], # In addition to 'colour_by' and 'linetype_by', 'size_by' can also be used to group taxa. plotSeries(object, x = "DAY_ORDER", - y = getTopFeatures(object, 5), + y = getTop(object, 5), colour_by = "Family", size_by = "Phylum", assay.type = "counts") diff --git a/man/plotTree.Rd b/man/plotTree.Rd index 5790a767..198f899e 100644 --- a/man/plotTree.Rd +++ b/man/plotTree.Rd @@ -173,7 +173,7 @@ rowData(altExp(GlobalPatterns,"Genus"))$log_mean <- log(rowData(altExp(GlobalPatterns,"Genus"))$mean) rowData(altExp(GlobalPatterns,"Genus"))$detected <- rowData(altExp(GlobalPatterns,"Genus"))$detected / 100 -top_genus <- getTopFeatures(altExp(GlobalPatterns,"Genus"), +top_genus <- getTop(altExp(GlobalPatterns,"Genus"), method="mean", top=100L, assay.type="counts") @@ -210,7 +210,7 @@ plotRowTree(x[rownames(x) \%in\% top_genus,], # please note that the original tree of GlobalPatterns is dropped by # unsplitByRanks altExps(GlobalPatterns) <- splitByRanks(GlobalPatterns) -top_phyla <- getTopFeatures(altExp(GlobalPatterns,"Phylum"), +top_phyla <- getTop(altExp(GlobalPatterns,"Phylum"), method="mean", top=10L, assay.type="counts") diff --git a/tests/testthat/test-2plotTree.R b/tests/testthat/test-2plotTree.R index 50b85881..34e8557d 100644 --- a/tests/testthat/test-2plotTree.R +++ b/tests/testthat/test-2plotTree.R @@ -61,7 +61,7 @@ test_that("plot tree", { altExp(GlobalPatterns,"genus") <- agglomerateByRank(GlobalPatterns,"Genus", make_unique = FALSE) altExp(GlobalPatterns,"genus") <- addPerFeatureQC(altExp(GlobalPatterns,"genus")) rowData(altExp(GlobalPatterns,"genus"))$log_mean <- log(rowData(altExp(GlobalPatterns,"genus"))$mean) - top_taxa <- getTopFeatures(altExp(GlobalPatterns,"genus"), + top_taxa <- getTop(altExp(GlobalPatterns,"genus"), method="mean", top=100L, assay.type="counts") diff --git a/vignettes/miaViz.Rmd b/vignettes/miaViz.Rmd index 1159cc64..3c4bb22d 100644 --- a/vignettes/miaViz.Rmd +++ b/vignettes/miaViz.Rmd @@ -73,7 +73,7 @@ plotAbundance(GlobalPatterns, rank = "Kingdom", assay.type = "relabundance") With subsetting to selected features the plot can be fine tuned. ```{r} -prev_phylum <- getPrevalentTaxa(GlobalPatterns, rank = "Phylum", +prev_phylum <- getPrevalent(GlobalPatterns, rank = "Phylum", detection = 0.01, onRankOnly = TRUE) ``` @@ -155,7 +155,7 @@ rowData(altExp(GlobalPatterns,"Genus"))$log_mean <- log(rowData(altExp(GlobalPatterns,"Genus"))$mean) rowData(altExp(GlobalPatterns,"Genus"))$detected <- rowData(altExp(GlobalPatterns,"Genus"))$detected / 100 -top_taxa <- getTopFeatures(altExp(GlobalPatterns,"Genus"), +top_taxa <- getTop(altExp(GlobalPatterns,"Genus"), method="mean", top=100L, assay.type="counts") @@ -268,7 +268,7 @@ library("miaTime") data(SilvermanAGutData, package="miaTime") tse <- SilvermanAGutData tse <- transformAssay(tse, method = "relabundance") -taxa <- getTopFeatures(tse, 2) +taxa <- getTop(tse, 2) ``` Data from samples collected along time can be visualized using `plotSeries`. @@ -300,7 +300,7 @@ Additional variables can be used to modify line type aesthetics. ```{r, eval=FALSE} plotSeries(tse, x = "DAY_ORDER", - y = getTopFeatures(tse, 5), + y = getTop(tse, 5), colour_by = "Family", linetype_by = "Phylum", assay.type = "counts") From 03fc172ac855962cbf7c2534742ac60aa312f573 Mon Sep 17 00:00:00 2001 From: Tuomas Borman <60338854+TuomasBorman@users.noreply.github.com> Date: Fri, 24 May 2024 10:42:47 +0300 Subject: [PATCH 2/3] Update NEWS --- NEWS | 1 - 1 file changed, 1 deletion(-) diff --git a/NEWS b/NEWS index 0a64e57c..b584ddb0 100644 --- a/NEWS +++ b/NEWS @@ -27,4 +27,3 @@ Changes in version 1.11.x Changes in version 1.13.x + plot*Tree: bugfix, ununique nodes -+ replace getPrevalent* with getPrevalent and getTop* with getTop From 305df64185e98add32781a22d4c13ad7c26dc7c8 Mon Sep 17 00:00:00 2001 From: TuomasBorman Date: Fri, 28 Jun 2024 15:36:15 +0300 Subject: [PATCH 3/3] up --- NEWS | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/NEWS b/NEWS index 8fa8af51..5931bea2 100644 --- a/NEWS +++ b/NEWS @@ -27,4 +27,4 @@ Changes in version 1.11.x Changes in version 1.13.x + plot*Tree: bugfix, ununique nodes -+ Added confidence.level parameter to plotCCA ++ Added confidence.level parameter to plotCCA