The following packages are needed to succesfully run the examples in this notebook:
mia: tools for microbiome data analysis
ComplexHeatmap: plotting heatmaps
To begin with, we import Tengeler2020 from the mia package and store it into a variable.
First of all, we transform the counts assay to relative abundances and store the new assay back in the TreeSE.
Relative abundances are useful because they are not affected by compositionality, which is present in the counts assay due to sequencing bias (the unequal amplification of DNA from two different samples due to random effects).
tse_phylum <- mergeFeaturesByRank(tse, rank = "Phylum")
tse_list <- splitOn(tse_phylum, f = "patient_status")
top_tab_list <- lapply(
tse_list,
function(x) round(rowMeans(assay(x, "relabundance")[getTopTaxa(x, top = 4L), ]) * 100, 1)
)
knitr::kable(cbind(top_tab_list[[1]], top_tab_list[[2]]), col.names = c("ADHD", "Control"))
ADHD | Control | |
---|---|---|
Bacteroidetes | 69.2 | 61.1 |
Firmicutes | 23.7 | 30.1 |
Verrucomicrobia | 4.7 | 6.9 |
Proteobacteria | 2.4 | 1.8 |
Next, we agglomerate the experiment to the order level, so that information is more condensed and therefore easier to visualise and interpret.
We then perform a CLR transformation sample-wise and a Z transformation feature-wise. The former creates a more homogeneous (logarithmic) scale for the usually very skewed microbiome data, whereas the latter normalises the features across samples for better comparisons between samples.
Finally, we plot the compositional heatmap with the ComplexHeatmap package and illustrate it in Figure 1.