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") #> Bioconductor version 3.13 (BiocManager 1.30.16), R 4.1.0 (2021-05-18) #> Warning: package(s) not installed when version(s) same as current; use `force = TRUE` to #> re-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", abund_values = "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", abund_values = "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", abund_values = "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", abund_values = "relabundance") plots$abundance / plots$SampleType + plot_layout(heights = c(9, 1))
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))