diff --git a/NAMESPACE b/NAMESPACE index c4a449db..8a885b13 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -4,6 +4,7 @@ export(plotAbundanceDensity) export(plotColGraph) export(plotColTile) export(plotDMNFit) +export(plotFeaturePrevalence) export(plotPrevalence) export(plotPrevalentAbundance) export(plotRowGraph) @@ -20,6 +21,7 @@ exportMethods(plotColGraph) exportMethods(plotColTile) exportMethods(plotColTree) exportMethods(plotDMNFit) +exportMethods(plotFeaturePrevalence) exportMethods(plotPrevalence) exportMethods(plotPrevalentAbundance) exportMethods(plotRowGraph) diff --git a/R/plotAbundance.R b/R/plotAbundance.R index c64a594e..487129e7 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 <- getTopTaxa(se_phylum,top = 5, assay.type = "relabundance") +#' top_taxa <- getTopFeatures(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/plotPrevalence.R b/R/plotPrevalence.R index 7a64cbe5..3ad6308f 100644 --- a/R/plotPrevalence.R +++ b/R/plotPrevalence.R @@ -1,9 +1,9 @@ #' Plot prevalence information #' -#' \code{plotPrevalence} and \code{plotTaxaPrevalence} visualize prevalence +#' \code{plotPrevalence} and \code{plotFeaturePrevalence} visualize prevalence #' information. #' -#' Whereas \code{plotPrevalence} produces a line plot, \code{plotTaxaPrevalence} +#' Whereas \code{plotPrevalence} produces a line plot, \code{plotFeaturePrevalence} #' returns a heatmap. #' #' @param x a @@ -100,14 +100,14 @@ #' plotPrevalence(GlobalPatterns, rank = "Phylum") + scale_x_log10() #' #' # plotting prevalence per taxa for different detection thresholds as heatmap -#' plotTaxaPrevalence(GlobalPatterns, rank = "Phylum") +#' plotFeaturePrevalence(GlobalPatterns, rank = "Phylum") #' #' # by default a continuous scale is used for different detection levels, #' # but this can be adjusted -#' plotTaxaPrevalence(GlobalPatterns, rank = "Phylum", +#' plotFeaturePrevalence(GlobalPatterns, rank = "Phylum", #' detections = c(0, 0.001, 0.01, 0.1, 0.2)) #' -#' # point layout for plotTaxaPrevalence can be used to visualize by additional +#' # point layout for plotFeaturePrevalence can be used to visualize by additional #' # information #' plotPrevalentAbundance(GlobalPatterns, rank = "Family", #' colour_by = "Phylum") + @@ -337,16 +337,17 @@ setMethod("plotPrevalentAbundance", signature = c(x = "SummarizedExperiment"), } ################################################################################ -# plotTaxaPrevalence +# plotFeaturePrevalence #' @rdname plotPrevalence +#' @aliases plotTaxaPrevalence #' @export -setGeneric("plotTaxaPrevalence", signature = c("x"), - function(x, ...) standardGeneric("plotTaxaPrevalence")) +setGeneric("plotFeaturePrevalence", signature = c("x"), + function(x, ...) standardGeneric("plotFeaturePrevalence")) #' @rdname plotPrevalence #' @export -setMethod("plotTaxaPrevalence", signature = c(x = "SummarizedExperiment"), +setMethod("plotFeaturePrevalence", signature = c(x = "SummarizedExperiment"), function(x, rank = taxonomyRanks(x)[1L], assay.type = assay_name, assay_name = "counts", @@ -542,3 +543,20 @@ setMethod("plotTaxaPrevalence", signature = c(x = "SummarizedExperiment"), angle_x_text = FALSE) plot_out } + +#' @rdname plotPrevalence +#' @aliases plotFeaturePrevalence +#' @export +setGeneric("plotTaxaPrevalence", signature = c("x"), + function(x, ...) + standardGeneric("plotTaxaPrevalence")) + +#' @rdname plotPrevalence +#' @aliases plotFeaturePrevalence +#' @export +setMethod("plotTaxaPrevalence", signature = c(x = "ANY"), + function(x, ...){ + .Deprecated(old ="plotTaxaPrevalence", new = "plotFeaturePrevalence", msg = "The 'plotTaxaPrevalence' function is deprecated. Use 'plotFeaturePrevalence' instead.") + plotFeaturePrevalence(x, ...) + } +) \ No newline at end of file diff --git a/R/plotSeries.R b/R/plotSeries.R index 751825c5..3cb29809 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 = getTopTaxa(object, 2), +#' y = getTopFeatures(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 = getTopTaxa(object, 5), +#' y = getTopFeatures(object, 5), #' colour_by = "Family", #' size_by = "Phylum", #' assay.type = "counts") diff --git a/R/plotTree.R b/R/plotTree.R index 8201510b..377674d0 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 <- getTopTaxa(altExp(GlobalPatterns,"Genus"), +#' top_genus <- getTopFeatures(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 <- getTopTaxa(altExp(GlobalPatterns,"Phylum"), +#' top_phyla <- getTopFeatures(altExp(GlobalPatterns,"Phylum"), #' method="mean", #' top=10L, #' assay.type="counts") diff --git a/man/plotAbundance.Rd b/man/plotAbundance.Rd index 8cd5cbdc..eb29a844 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 <- getTopTaxa(se_phylum,top = 5, assay.type = "relabundance") +top_taxa <- getTopFeatures(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 9975a7f7..0884ae88 100644 --- a/man/plotPrevalence.Rd +++ b/man/plotPrevalence.Rd @@ -5,8 +5,10 @@ \alias{plotPrevalence,SummarizedExperiment-method} \alias{plotPrevalentAbundance} \alias{plotPrevalentAbundance,SummarizedExperiment-method} +\alias{plotFeaturePrevalence} \alias{plotTaxaPrevalence} -\alias{plotTaxaPrevalence,SummarizedExperiment-method} +\alias{plotFeaturePrevalence,SummarizedExperiment-method} +\alias{plotTaxaPrevalence,ANY-method} \title{Plot prevalence information} \usage{ plotPrevalence(x, ...) @@ -39,9 +41,9 @@ plotPrevalentAbundance(x, ...) ... ) -plotTaxaPrevalence(x, ...) +plotFeaturePrevalence(x, ...) -\S4method{plotTaxaPrevalence}{SummarizedExperiment}( +\S4method{plotFeaturePrevalence}{SummarizedExperiment}( x, rank = taxonomyRanks(x)[1L], assay.type = assay_name, @@ -53,6 +55,10 @@ plotTaxaPrevalence(x, ...) BPPARAM = BiocParallel::SerialParam(), ... ) + +plotTaxaPrevalence(x, ...) + +\S4method{plotTaxaPrevalence}{ANY}(x, ...) } \arguments{ \item{x}{a @@ -129,11 +135,11 @@ A \code{ggplot2} object or \code{plotly} object, if more than one \code{prevalences} was defined. } \description{ -\code{plotPrevalence} and \code{plotTaxaPrevalence} visualize prevalence +\code{plotPrevalence} and \code{plotFeaturePrevalence} visualize prevalence information. } \details{ -Whereas \code{plotPrevalence} produces a line plot, \code{plotTaxaPrevalence} +Whereas \code{plotPrevalence} produces a line plot, \code{plotFeaturePrevalence} returns a heatmap. Agglomeration on different taxonomic levels is available through the @@ -151,14 +157,14 @@ plotPrevalence(GlobalPatterns, rank = "Phylum") plotPrevalence(GlobalPatterns, rank = "Phylum") + scale_x_log10() # plotting prevalence per taxa for different detection thresholds as heatmap -plotTaxaPrevalence(GlobalPatterns, rank = "Phylum") +plotFeaturePrevalence(GlobalPatterns, rank = "Phylum") # by default a continuous scale is used for different detection levels, # but this can be adjusted -plotTaxaPrevalence(GlobalPatterns, rank = "Phylum", +plotFeaturePrevalence(GlobalPatterns, rank = "Phylum", detections = c(0, 0.001, 0.01, 0.1, 0.2)) -# point layout for plotTaxaPrevalence can be used to visualize by additional +# point layout for plotFeaturePrevalence can be used to visualize by additional # information plotPrevalentAbundance(GlobalPatterns, rank = "Family", colour_by = "Phylum") + diff --git a/man/plotSeries.Rd b/man/plotSeries.Rd index e45fa6aa..44e10314 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 = getTopTaxa(object, 2), + y = getTopFeatures(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 = getTopTaxa(object, 5), + y = getTopFeatures(object, 5), colour_by = "Family", size_by = "Phylum", assay.type = "counts") diff --git a/man/plotTree.Rd b/man/plotTree.Rd index 72ff6598..74927dad 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 <- getTopTaxa(altExp(GlobalPatterns,"Genus"), +top_genus <- getTopFeatures(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 <- getTopTaxa(altExp(GlobalPatterns,"Phylum"), +top_phyla <- getTopFeatures(altExp(GlobalPatterns,"Phylum"), method="mean", top=10L, assay.type="counts") diff --git a/vignettes/miaViz.Rmd b/vignettes/miaViz.Rmd index 99b0dc2c..07a7cdbc 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 <- getPrevalentFeatures(GlobalPatterns, rank = "Phylum", detection = 0.01) ``` @@ -103,14 +103,14 @@ Further example about composition barplot can be found at Orchestrating Microbio # Prevalence plotting To visualize prevalence within the dataset, two functions are available, -`plotTaxaPrevalence`, `plotPrevalenceAbundance` and `plotPrevalence`. +`plotFeaturePrevalence`, `plotPrevalenceAbundance` and `plotPrevalence`. -`plotTaxaPrevalence` produces a so-called landscape plot, which +`plotFeaturePrevalence` produces a so-called landscape plot, which visualizes the prevalence of samples across abundance thresholds. ```{r} -plotTaxaPrevalence(GlobalPatterns, rank = "Phylum", +plotFeaturePrevalence(GlobalPatterns, rank = "Phylum", detections = c(0, 0.001, 0.01, 0.1, 0.2)) ``` @@ -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 <- getTopTaxa(altExp(GlobalPatterns,"Genus"), +top_taxa <- getTopFeatures(altExp(GlobalPatterns,"Genus"), method="mean", top=100L, assay.type="counts") @@ -262,7 +262,7 @@ library("miaTime") data(SilvermanAGutData, package="miaTime") tse <- SilvermanAGutData tse <- transformAssay(tse, method = "relabundance") -taxa <- getTopTaxa(tse, 2) +taxa <- getTopFeatures(tse, 2) ``` Data from samples collected along time can be visualized using `plotSeries`. @@ -294,7 +294,7 @@ Additional variables can be used to modify line type aesthetics. ```{r} plotSeries(tse, x = "DAY_ORDER", - y = getTopTaxa(tse, 5), + y = getTopFeatures(tse, 5), colour_by = "Family", linetype_by = "Phylum", assay.type = "counts")