miaViz
implements plotting function to work with TreeSummarizedExperiment
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 plotColData
, plotExpression
and plotRowData
.
To install miaViz
, install BiocManager
first, if it is not installed.
Afterwards use the install
function from BiocManager
and load miaViz
.
if (!requireNamespace("BiocManager", quietly = TRUE))
install.packages("BiocManager")
BiocManager::install("miaViz")
library(miaViz)
library(scater)
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 Abundance
data of a particular feature.
plotExpression(GlobalPatterns,
features = "549322", assay.type = "counts")
On the other hand, plotAbundance can be used to plot abundance by rank
. A bar plot is returned showing the relative abundance within each sample for a given rank
. At the same
time the features
argument can be set to NULL
(default).
GlobalPatterns <- transformAssay(GlobalPatterns, method = "relabundance")
plotAbundance(GlobalPatterns, rank = "Kingdom", assay.type = "relabundance")
If rank
is set to null however then the bars will be colored by each
individual taxon. Please note that if you’re doing this make sure to agglomerate
your data to a certain taxonomic hand before plotting.
GlobalPatterns_king <- agglomerateByRank(GlobalPatterns, "Kingdom")
plotAbundance(GlobalPatterns_king, assay.type = "relabundance")
With subsetting to selected features the plot can be fine tuned.
prev_phylum <- getPrevalent(GlobalPatterns, rank = "Phylum",
detection = 0.01, onRankOnly = TRUE)
plotAbundance(GlobalPatterns[rowData(GlobalPatterns)$Phylum %in% prev_phylum],
rank = "Phylum",
assay.type = "relabundance")
#> Warning: Removed 101 rows containing missing values or values outside the scale range
#> (`geom_bar()`).
The 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
patchwork
.
library(patchwork)
plots <- plotAbundance(GlobalPatterns[rowData(GlobalPatterns)$Phylum %in% prev_phylum],
features = "SampleType",
rank = "Phylum",
assay.type = "relabundance")
plots$abundance / plots$SampleType +
plot_layout(heights = c(9, 1))
#> Warning: Removed 101 rows containing missing values or values outside the scale range
#> (`geom_bar()`).