We first import the packages used in this tutorial.
We also import Tengeler2020 from the mia package and store it into a variable.
Next, we transform the counts assay to relative abundance assay and store it into the TreeSE.
Then, we agglomerate the experiment to the order level, so that information is more condensed and therefore easier to visualise and interpret.
Microbiome data is compositional. Relative abundance helps us draw less biased comparisons between samples.
# Import packages
library(miaViz)
library(patchwork)
# Plot composition by counts
counts_bar <- plotAbundance(tse_order, rank = "Phylum", use_relative = FALSE) +
ylab("Counts")
# Plot composition by relative abundance
relab_bar <- plotAbundance(tse_order, rank = "Phylum", use_relative = TRUE) +
ylab("Relative Abundance")
# Combine plots
(counts_bar | relab_bar) +
plot_layout(guides = "collect")
To reduce data skewness, we further transform the relative abundance assay with the Centered-Log Ratio (CLR), which is defined as follows:
\[ clr = log \frac{x}{g(x)} = log(x)−log[g(x)] \]
where x is a feature and g(x) is the geometric mean of all features in a sample.
Lastly, we get the row-wise z-scores of every feature from the clr assay to standardise abundances across samples.
Finally, we visualise the clr-z assay with ComplexHeatmap
.
A CLR-z transformation improves comparability in two steps:
Extra: