Skip to content

Commit

Permalink
deprecate Taxa names -> Features
Browse files Browse the repository at this point in the history
  • Loading branch information
himmil committed Sep 7, 2023
1 parent b811da5 commit 4c6f361
Show file tree
Hide file tree
Showing 10 changed files with 60 additions and 34 deletions.
2 changes: 2 additions & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ export(plotAbundanceDensity)
export(plotColGraph)
export(plotColTile)
export(plotDMNFit)
export(plotFeaturePrevalence)
export(plotPrevalence)
export(plotPrevalentAbundance)
export(plotRowGraph)
Expand All @@ -20,6 +21,7 @@ exportMethods(plotColGraph)
exportMethods(plotColTile)
exportMethods(plotColTree)
exportMethods(plotDMNFit)
exportMethods(plotFeaturePrevalence)
exportMethods(plotPrevalence)
exportMethods(plotPrevalentAbundance)
exportMethods(plotRowGraph)
Expand Down
2 changes: 1 addition & 1 deletion R/plotAbundance.R
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
36 changes: 27 additions & 9 deletions R/plotPrevalence.R
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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") +
Expand Down Expand Up @@ -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",
Expand Down Expand Up @@ -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, ...)
}
)
4 changes: 2 additions & 2 deletions R/plotSeries.R
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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")
Expand Down
4 changes: 2 additions & 2 deletions R/plotTree.R
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down Expand Up @@ -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")
Expand Down
2 changes: 1 addition & 1 deletion man/plotAbundance.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

22 changes: 14 additions & 8 deletions man/plotPrevalence.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions man/plotSeries.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions man/plotTree.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 7 additions & 7 deletions vignettes/miaViz.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -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)
```

Expand Down Expand Up @@ -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))
```

Expand Down Expand Up @@ -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")
Expand Down Expand Up @@ -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`.
Expand Down Expand Up @@ -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")
Expand Down

0 comments on commit 4c6f361

Please sign in to comment.