diff --git a/NAMESPACE b/NAMESPACE index 387a8e02..768d624d 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -5,6 +5,7 @@ export(plotCCA) export(plotColGraph) export(plotColTile) export(plotDMNFit) +export(plotFeaturePrevalence) export(plotPrevalence) export(plotPrevalentAbundance) export(plotRDA) @@ -23,6 +24,7 @@ exportMethods(plotColGraph) exportMethods(plotColTile) exportMethods(plotColTree) exportMethods(plotDMNFit) +exportMethods(plotFeaturePrevalence) exportMethods(plotPrevalence) exportMethods(plotPrevalentAbundance) exportMethods(plotRDA) @@ -74,7 +76,7 @@ importFrom(dplyr,ungroup) importFrom(ggnewscale,new_scale) importFrom(ggnewscale,new_scale_colour) importFrom(ggnewscale,new_scale_fill) -importFrom(ggplot2,aes_string) +importFrom(ggplot2,aes) importFrom(ggplot2,coord_flip) importFrom(ggplot2,element_blank) importFrom(ggplot2,element_text) diff --git a/R/plotAbundance.R b/R/plotAbundance.R index c64a594e..29f2adad 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, @@ -274,7 +274,7 @@ MELT_VALUES <- "Value" data <- data %>% as.data.frame() %>% mutate(rank = factor(rowData(x)[,rank], unique(rowData(x)[,rank]))) %>% - pivot_longer(cols = !.data$rank, + pivot_longer(cols = !rank, names_to = MELT_NAME, values_to = MELT_VALUES) %>% mutate(!!sym(MELT_NAME) := factor(!!sym(MELT_NAME), unique(!!sym(MELT_NAME)))) %>% @@ -292,7 +292,7 @@ MELT_VALUES <- "Value" lvl <- lvl[order(lvl)] } else if(order_rank_by %in% c("abund","revabund")){ o <- data %>% - select(!.data$X) %>% + select(!.data$X) %>% group_by(.data$colour_by) %>% summarize(sum = sum(.data$Y)) decreasing <- ifelse(order_rank_by == "abund",TRUE,FALSE) @@ -304,7 +304,7 @@ MELT_VALUES <- "Value" } data$colour_by <- factor(data$colour_by, lvl) data <- data[order(data$colour_by),] - # + data } @@ -424,7 +424,7 @@ MELT_VALUES <- "Value" point_alpha = 1, point_size = 2){ # start plotting - plot_out <- ggplot(object, aes_string(x="X", y="Y")) + + plot_out <- ggplot(object, aes(x=.data[["X"]], y=.data[["Y"]])) + xlab(xlab) + ylab(ylab) # either bar or point plot @@ -471,7 +471,7 @@ MELT_VALUES <- "Value" plot_out } -#' @importFrom ggplot2 ggplot aes_string labs geom_point geom_raster +#' @importFrom ggplot2 ggplot aes labs geom_point geom_raster .feature_plotter <- function(feature_data, name, xlab, @@ -485,7 +485,7 @@ MELT_VALUES <- "Value" feature_data$Y <- "" colour_by <- unique(feature_data$feature_name) } - feature_plot_out <- ggplot(feature_data, aes_string(x="X", y="Y")) + + feature_plot_out <- ggplot(feature_data, aes(x=.data[["X"]], y=.data[["Y"]])) + labs(x = xlab, y = name) if(length(unique(feature_data$Y)) == 1L){ feature_out <- .get_bar_args(colour_by, diff --git a/R/plotAbundanceDensity.R b/R/plotAbundanceDensity.R index b8d314d6..278c2063 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 <- getTopTaxa(object, top = n, assay.type = assay.type) + top_taxa <- getTopFeatures(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 @@ -282,7 +282,7 @@ setMethod("plotAbundanceDensity", signature = c(object = "SummarizedExperiment") scales_free = TRUE, angle_x_text = TRUE){ # start plotting - plot_out <- ggplot(density_data, aes_string(x="X")) + + plot_out <- ggplot(density_data, aes(x=.data[["X"]])) + xlab(xlab) + ylab(ylab) # Layout can be "density", "jitter", or "point" diff --git a/R/plotCCA.R b/R/plotCCA.R index 1ad2eec3..43987e2b 100644 --- a/R/plotCCA.R +++ b/R/plotCCA.R @@ -500,7 +500,6 @@ setMethod("plotRDA", signature = c(object = "matrix"), parse.labels = TRUE, vec.text = TRUE, repel.labels = TRUE, add.ellipse = TRUE, position = NULL, nudge_x = NULL, nudge_y = NULL, direction = "both", max.overlaps = 10, check_overlap = FALSE, ...){ - # Get the scatter plot plot <- plot_data[["plot"]] # Add ellipse @@ -517,7 +516,7 @@ setMethod("plotRDA", signature = c(object = "matrix"), aes(x = .data[[xvar]], y = .data[[yvar]], color = .data[[colour_var]], fill = after_scale(color)), geom = "polygon", alpha = ellipse.alpha, - size = ellipse.linewidth, linetype = ellipse.linetype) + linewidth = ellipse.linewidth, linetype = ellipse.linetype) } else if ( add.ellipse %in% c("color", "colour") ){ plot <- plot + stat_ellipse(data = data, diff --git a/R/plotDMN.R b/R/plotDMN.R index f646fd5e..6d6ec767 100644 --- a/R/plotDMN.R +++ b/R/plotDMN.R @@ -46,7 +46,7 @@ setGeneric("plotDMNFit", signature = "x", #' @rdname plotDMN #' @importFrom DirichletMultinomial mixture -#' @importFrom ggplot2 ggplot aes_string geom_point geom_line theme_bw labs +#' @importFrom ggplot2 ggplot aes geom_point geom_line theme_bw labs #' @export setMethod("plotDMNFit", signature = c(x = "SummarizedExperiment"), function(x, name = "DMN", type = c("laplace","AIC","BIC")){ @@ -62,7 +62,7 @@ setMethod("plotDMNFit", signature = c(x = "SummarizedExperiment"), # k <- vapply(dmn, function(d){ncol(mixture(d))}, numeric(1)) fit <- vapply(dmn, fit_FUN, numeric(1)) - ggplot(data.frame(k = k, fit = fit), aes_string(x = k, y = fit)) + + ggplot(data.frame(k = k, fit = fit), aes(x = k, y = fit)) + geom_point() + geom_line() + theme_bw() + diff --git a/R/plotGraph.R b/R/plotGraph.R index 99ecc1e5..133c7f9b 100644 --- a/R/plotGraph.R +++ b/R/plotGraph.R @@ -644,10 +644,11 @@ setMethod("plotRowGraph", #' @importFrom tidyr drop_na .add_graph_labels <- function(plot_out, show_label){ + label <- NULL # disable note: no global binding for variable if(show_label){ - label_data <- plot_out$data %>% drop_na(.data$label) + label_data <- plot_out$data %>% drop_na(label) plot_out <- plot_out + - geom_node_label(mapping = aes_string(label = "label"), + geom_node_label(mapping = aes(label = .data[["label"]]), data = label_data, repel = TRUE, max.overlaps = 100) diff --git a/R/plotPrevalence.R b/R/plotPrevalence.R index 7a64cbe5..2400196c 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", @@ -444,7 +445,7 @@ setMethod("plotTaxaPrevalence", signature = c(x = "SummarizedExperiment"), lvls <- rownames(ans)[order(rowSums(ans))] ans$ID <- rownames(mat)[rowSums(f) != 0] ans <- ans %>% - pivot_longer(!.data$ID, + pivot_longer(!ID, names_to = "detection", values_to = "prevalence") colnames(ans) <- c("Y","X","colour_by") @@ -474,7 +475,7 @@ setMethod("plotTaxaPrevalence", signature = c(x = "SummarizedExperiment"), line_alpha = 1, line_type = NULL, line_size = 1){ - plot_out <- ggplot(plot_data, aes_string(x = "X", y = "Y")) + + plot_out <- ggplot(plot_data, aes(x = .data[["X"]], y = .data[["Y"]])) + labs(x = xlab, y = ylab) if(layout == "line"){ point_args <- .get_point_args(colour_by = colour_by, shape_by = NULL, @@ -485,7 +486,7 @@ setMethod("plotTaxaPrevalence", signature = c(x = "SummarizedExperiment"), size_by = NULL, alpha = line_alpha, linetype = line_type, - size = line_size) + linewidth = line_size) point_args$args$mapping$group <- sym("colour_by") line_args$args$mapping$group <- sym("colour_by") plot_out <- plot_out + @@ -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..5b3eae12 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") @@ -304,7 +304,7 @@ setMethod("plotSeries", signature = c(object = "SummarizedExperiment"), } # Creates a "draft" of a plot plot_out <- ggplot(plot_data, - aes_string(x = "X", y = "Y")) + + aes(x = .data[["X"]], y = .data[["Y"]])) + labs(x = xlab, y = ylab) # if sd column is present add a ribbon if(!is.null(plot_data$sd)){ @@ -313,13 +313,13 @@ setMethod("plotSeries", signature = c(object = "SummarizedExperiment"), plot_out <- plot_out + do.call(geom_ribbon, ribbon_args$args) } - # Fetches arguments fpr geom_line + # Fetches arguments for geom_line line_args <- .get_line_args(colour_by = colour_by, linetype_by = linetype_by, size_by = size_by, alpha = line_alpha, linetype = line_type, - size = line_width) + linewidth = line_width) # Adds arguments to the plot plot_out <- plot_out + do.call(geom_line, line_args$args) @@ -359,7 +359,7 @@ setMethod("plotSeries", signature = c(object = "SummarizedExperiment"), guide_args$linetype <- guide_legend(title = linetype_by) } if (!is.null(size_by)) { - guide_args$size <- guide_legend(title = size_by) + guide_args$linewidth <- guide_legend(title = size_by) } if (length(guide_args)) { plot_out <- plot_out + do.call(guides, guide_args) 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/R/treeData.R b/R/treeData.R index 4c112012..a267fb8d 100644 --- a/R/treeData.R +++ b/R/treeData.R @@ -118,7 +118,7 @@ setMethod("rowTreeData", signature = c(x = "TreeSummarizedExperiment"), DEFAULT_TREE_DATA_COLS <- c("parent","node","branch.length","label") .clean_tree_data <- function(tree_data){ tree_data %>% - select(DEFAULT_TREE_DATA_COLS) + select(all_of(DEFAULT_TREE_DATA_COLS)) } #' @rdname treeData diff --git a/R/utils_plotting.R b/R/utils_plotting.R index 041578da..55c99a7b 100644 --- a/R/utils_plotting.R +++ b/R/utils_plotting.R @@ -253,9 +253,10 @@ NULL .get_bar_args <- function (colour_by, alpha = 0.65, add_border = NULL, n = 0) { - aes_args <- list() fill_colour <- TRUE border <- FALSE + aes_args <- list() + if (!is.null(colour_by)) { aes_args$fill <- "colour_by" } @@ -266,7 +267,8 @@ NULL border <- TRUE aes_args$colour <- "colour_by" } - new_aes <- do.call(aes_string, aes_args) + aes_args <- lapply(aes_args, function(x) if (!is.null(x)) sym(x)) + new_aes <- do.call(aes, aes_args) geom_args <- list(mapping = new_aes, alpha = alpha) if (is.null(colour_by)) { geom_args$colour <- "grey20" @@ -299,7 +301,8 @@ NULL if (!is.null(size_by)) { aes_args$size <- "size_by" } - new_aes <- do.call(aes_string, aes_args) + aes_args <- lapply(aes_args, function(x) if (!is.null(x)) sym(x)) + new_aes <- do.call(aes, aes_args) geom_args <- list(mapping = new_aes, alpha = alpha) if (is.null(colour_by)) { geom_args$fill <- colour @@ -316,7 +319,7 @@ NULL .get_line_args <- function(colour_by, linetype_by, size_by, alpha = 0.65, linetype = 1, - size = NULL, + linewidth = NULL, colour = "grey70") { aes_args <- list() @@ -327,9 +330,10 @@ NULL aes_args$colour <- "colour_by" } if (!is.null(size_by)) { - aes_args$size <- "size_by" + aes_args$linewidth <- "size_by" } - new_aes <- do.call(aes_string, aes_args) + aes_args <- lapply(aes_args, function(x) if (!is.null(x)) sym(x)) + new_aes <- do.call(aes, aes_args) geom_args <- list(mapping = new_aes, alpha = alpha) if (is.null(colour_by)) { geom_args$colour <- colour @@ -338,7 +342,7 @@ NULL geom_args$linetype <- linetype } if (is.null(size_by)) { - geom_args$size <- size + geom_args$linewidth <- linewidth } return(list(args = geom_args)) } @@ -346,13 +350,11 @@ NULL .get_ribbon_args <- function(colour_by, alpha = 0.3) { - aes_args <- list() - aes_args$ymin <- "Y - sd" - aes_args$ymax <- "Y + sd" + aes_args <- aes(ymin = .data[["Y"]] - .data[["sd"]], ymax = .data[["Y"]] + .data[["sd"]]) if (!is.null(colour_by)) { - aes_args$fill <- "colour_by" + aes_args$fill <- substitute(`colour_by`) } - new_aes <- do.call(aes_string, aes_args) + new_aes <- do.call(aes, aes_args) geom_args <- list(mapping = new_aes, alpha = alpha) if (is.null(colour_by)) { geom_args$fill <- "grey70" @@ -369,7 +371,8 @@ NULL if (!is.null(edge_size_by)) { aes_args$size <- "edge_size_by" } - new_aes <- do.call(aes_string, aes_args) + aes_args <- lapply(aes_args, function(x) if (!is.null(x)) sym(x)) + new_aes <- do.call(aes, aes_args) geom_args <- list(mapping = new_aes, alpha = alpha) if (is.null(edge_colour_by)) { geom_args$colour <- "black" @@ -402,7 +405,8 @@ NULL if (!is.null(colour_by)) { aes_args$fill <- "colour_by" } - new_aes <- do.call(aes_string, aes_args) + aes_args <- lapply(aes_args, function(x) if (!is.null(x)) sym(x)) + new_aes <- do.call(aes, aes_args) geom_args <- list(mapping = new_aes, alpha = alpha, colour = colour) return(list(args = geom_args)) } @@ -414,7 +418,8 @@ NULL aes_args$colour <- "colour_by" aes_args$fill <- "colour_by" } - new_aes <- do.call(aes_string, aes_args) + aes_args <- lapply(aes_args, function(x) if (!is.null(x)) sym(x)) + new_aes <- do.call(aes, aes_args) geom_args <- list(mapping = new_aes, alpha = alpha) if (is.null(colour_by)) { 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/tests/testthat/test-2plotTree.R b/tests/testthat/test-2plotTree.R index 8402e3ca..50b85881 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 <- getTopTaxa(altExp(GlobalPatterns,"genus"), + top_taxa <- getTopFeatures(altExp(GlobalPatterns,"genus"), method="mean", top=100L, assay.type="counts") diff --git a/vignettes/miaViz.Rmd b/vignettes/miaViz.Rmd index 09a8baaa..dfc86dd2 100644 --- a/vignettes/miaViz.Rmd +++ b/vignettes/miaViz.Rmd @@ -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") @@ -271,7 +271,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`. @@ -303,7 +303,7 @@ Additional variables can be used to modify line type aesthetics. ```{r, eval=FALSE} plotSeries(tse, x = "DAY_ORDER", - y = getTopTaxa(tse, 5), + y = getTopFeatures(tse, 5), colour_by = "Family", linetype_by = "Phylum", assay.type = "counts")