miaViz implements plotting function to work with
and related objects in a context of microbiome analysis. For more general
plotting function on
SummarizedExperiment objects the
scater package offers
several options, such as
BiocManager first, if it is not installed.
Afterwards use the
install function from
BiocManager and load
if (!requireNamespace("BiocManager", quietly = TRUE)) install.packages("BiocManager") BiocManager::install("miaViz")
library(miaViz) data(GlobalPatterns, package = "mia")
in contrast to other fields of sequencing based fields of research for which
expression of genes is usually studied, microbiome research uses the more
term Abundance to described the numeric data measured and analyzed.
Technically, especially in context of
SummarizedExperiment objects, there is
no difference. Therefore
plotExpression can be used to plot
plotAbundance can be used as well and as long as
rank is set
plotAbundance(GlobalPatterns, rank = NULL, features = "549322", assay_name = "counts")
However, if the
rank is set not
NULL a bar plot is returned. At the same
features argument can be set to
GlobalPatterns <- transformCounts(GlobalPatterns, method = "relabundance")
plotAbundance(GlobalPatterns, rank = "Kingdom", assay_name = "relabundance")
With subsetting to selected features the plot can be fine tuned.
prev_phylum <- getPrevalentTaxa(GlobalPatterns, rank = "Phylum", detection = 0.01)
plotAbundance(GlobalPatterns[rowData(GlobalPatterns)$Phylum %in% prev_phylum], rank = "Phylum", assay_name = "relabundance")
features argument is reused for plotting data along the different samples.
In the next example the SampleType is plotted along the samples. In this case
the result is a list, which can combined using external tools, for example
library(patchwork) plots <- plotAbundance(GlobalPatterns[rowData(GlobalPatterns)$Phylum %in% prev_phylum], features = "SampleType", rank = "Phylum", assay_name = "relabundance") plots$abundance / plots$SampleType + plot_layout(heights = c(9, 1))
Further example about composition barplot can be found at Orchestrating Microbiome Analysis (Lahti, Shetty, and Ernst 2021).
To visualize prevalence within the dataset, two functions are available,
plotTaxaPrevalence produces a so-called landscape plot, which
visualizes the prevalence of samples across abundance thresholds.
plotTaxaPrevalence(GlobalPatterns, rank = "Phylum", detections = c(0, 0.001, 0.01, 0.1, 0.2))