-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
34 changed files
with
2,982 additions
and
8,202 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
--- | ||
title: "Identify Co-abundant taxa groups" | ||
author: "Leo Lahti, Sudarshan Shetty et al." | ||
bibliography: | ||
- bibliography.bib | ||
output: | ||
BiocStyle::html_document: | ||
number_sections: no | ||
toc: yes | ||
toc_depth: 4 | ||
toc_float: true | ||
self_contained: true | ||
thumbnails: true | ||
lightbox: true | ||
gallery: true | ||
use_bookdown: false | ||
highlight: haddock | ||
--- | ||
<!-- | ||
%\VignetteIndexEntry{microbiome tutorial} | ||
%\VignetteEngine{knitr::rmarkdown} | ||
%\usepackage[utf8]{inputenc} | ||
%\VignetteEncoding{UTF-8} | ||
--> | ||
|
||
**Co-abundant groups of taxa** | ||
|
||
Get data | ||
```{r cag-1} | ||
library(microbiome) | ||
pseq <- atlas1006 | ||
pseq.rel <- microbiome::transform(pseq, "compositional") | ||
``` | ||
|
||
Identify co-abundant taxa. | ||
```{r cag-2} | ||
# get median abundances | ||
median_abund = apply(abundances(pseq.rel), MARGIN = 1, FUN = median) | ||
# select taxa with median abundance of more than or equal to 0.01 | ||
abundant_taxa = abundances(pseq)[median_abund >= 0.01, ] | ||
# check how many taxa | ||
nrow(abundant_taxa) | ||
# check which taxa | ||
rownames(abundant_taxa) | ||
``` | ||
|
||
|
||
Use Spearman's correlation to identify which of the co-abundant groups show correlation. | ||
```{r cag-1b} | ||
# cor() is from `stats` package | ||
spearman_matrix = cor(t(abundant_taxa), method = "spearman") | ||
# hclust() is from `stats` package | ||
spearman_tree = hclust(dist(spearman_matrix), method = "ward") | ||
plot(spearman_tree) | ||
``` | ||
|
||
Using the `heat` function in `microbiome pkg` now compare the correlation with the tree above. | ||
```{r plot-heat} | ||
spearman_long_df <- reshape2::melt(spearman_matrix) | ||
head(spearman_long_df) | ||
heat(spearman_long_df, "Var1","Var2", | ||
order.rows = TRUE, order.cols = TRUE) + | ||
theme_bw() + theme(axis.text.x = element_text(angle = 90)) | ||
``` | ||
|
||
Validation of CAGs | ||
```{r} | ||
# Validation of CAGs | ||
# Randomly split the dataset, compute a correlation matrix and run a Mantel test | ||
subsample = sample(c(1:300), size = 220, replace = F) | ||
train_data = abundant_taxa[,subsample] | ||
test_data = abundant_taxa[,-subsample] | ||
train_spearman = cor(t(train_data), method = "spearman") | ||
test_spearman = cor(t(test_data), method = "spearman") | ||
vegan::mantel(as.dist(train_spearman), as.dist(test_spearman), permutations=999) | ||
``` | ||
|
||
Further reading: | ||
|
||
[de la Cuesta-Zuluaga, J., Corrales-Agudelo, V., Velásquez-Mejía, E.P. et al. Gut microbiota is associated with obesity and cardiometabolic disease in a population in the midst of Westernization. Sci Rep 8, 11356 (2018).](https://doi.org/10.1038/s41598-018-29687-x) | ||
|
||
[Claesson, M., Jeffery, I., Conde, S. et al. Gut microbiota composition correlates with diet and health in the elderly. Nature 488, 178–184 (2012).](https://doi.org/10.1038/nature11319) |
Large diffs are not rendered by default.
Oops, something went wrong.
Oops, something went wrong.