-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy path06-MAW-PV.Rmd
182 lines (111 loc) · 5.08 KB
/
06-MAW-PV.Rmd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
---
title: "OPEN & REPRODUCIBLE MICROBIOME DATA ANALYSIS SPRING SCHOOL 2018"
author: "Sudarshan"
date: "`r Sys.Date()`"
output: bookdown::gitbook
site: bookdown::bookdown_site
---
# Core microbiota
For more information:
[The adult intestinal core microbiota is determined by analysis depth and health status](https://www.sciencedirect.com/science/article/pii/S1198743X14609629?via%3Dihub).
[Intestinal microbiome landscaping: insight in community assemblage and implications for microbial modulation strategies](https://academic.oup.com/femsre/article/41/2/182/2979411).
[Intestinal Microbiota in Healthy Adults: Temporal Analysis Reveals Individual and Common Core and Relation to Intestinal Symptoms](http://journals.plos.org/plosone/article?id=10.1371/journal.pone.0023035).
```{r, warning=FALSE, message=FALSE}
library(microbiome) # data analysis and visualisation
library(phyloseq) # also the basis of data object. Data analysis and visualisation
library(RColorBrewer) # nice color options
library(ggpubr) # publication quality figures, based on ggplot2
library(dplyr) # data handling
```
## Core microbiota anlaysis
We will use the filtered phyloseq object from previous tutorial. We will use the filtered phyloseq object from the first section for pre-processioning.
```{r}
# read non rarefied data
ps1 <- readRDS("./phyobjects/ps.ng.tax.rds")
# use print option to see the data saved as phyloseq object.
```
Subset the data to keep only stool samples.
```{r}
ps1.stool <- subset_samples(ps1, bodysite == "Stool")
# convert to relative abundance
ps1.stool.rel <- microbiome::transform(ps1.stool, "compositional")
print(ps1.stool.rel)
ps1.stool.rel2 <- prune_taxa(taxa_sums(ps1.stool.rel) > 0, ps1.stool.rel)
print(ps1.stool.rel2)
```
Check for the core ASVs
```{r}
core.taxa.standard <- core_members(ps1.stool.rel2, detection = 0.001, prevalence = 50/100)
print(core.taxa.standard)
```
There are 16 ASVs that are core based on the cut-offs for prevalence and detection we choose. However, we only see IDs, not very informative. We can get the classification of these as below.
```{r}
# Extract the taxonomy table
taxonomy <- as.data.frame(tax_table(ps1.stool.rel2))
# Subset this taxonomy table to include only core OTUs
core_taxa_id <- subset(taxonomy, rownames(taxonomy) %in% core.taxa.standard)
DT::datatable(core_taxa_id)
```
## Core abundance and diversity
Total core abundance in each sample (sum of abundances of the core members):
```{r}
core.abundance <- sample_sums(core(ps1.stool.rel2, detection = 0.001, prevalence = 50/100))
DT::datatable(as.data.frame(core.abundance))
```
## Core visualization
### Core heatmaps
This visualization method has been used for instance in [Intestinal microbiome landscaping: insight in community assemblage and implications for microbial modulation strategies](https://academic.oup.com/femsre/article/41/2/182/2979411).
Note that you can order the taxa on the heatmap with the order.taxa argument.
```{r}
# Core with compositionals:
prevalences <- seq(.05, 1, .05)
detections <- 10^seq(log10(1e-3), log10(.2), length = 10)
# Also define gray color palette
gray <- gray(seq(0,1,length=5))
p.core <- plot_core(ps1.stool.rel2,
plot.type = "heatmap",
colours = gray,
prevalences = prevalences,
detections = detections,
min.prevalence = .5) +
xlab("Detection Threshold (Relative Abundance (%))")
print(p.core)
# Same with the viridis color palette
# color-blind friendly and uniform
# options: viridis, magma, plasma, inferno
# https://cran.r-project.org/web/packages/viridis/vignettes/intro-to-viridis.html
# Also discrete=TRUE versions available
library(viridis)
print(p.core + scale_fill_viridis())
```
Color change
```{r}
# Core with compositionals:
prevalences <- seq(.05, 1, .05)
detections <- 10^seq(log10(1e-3), log10(.2), length = 10)
# Also define gray color palette
p.core <- plot_core(ps1.stool.rel2,
plot.type = "heatmap",
colours = rev(brewer.pal(5, "Spectral")),
prevalences = prevalences,
detections = detections,
min.prevalence = .5) +
xlab("Detection Threshold (Relative Abundance (%))")
print(p.core)
```
Use the `format_to_besthit` function from microbiomeutilities to get the best classification of the ASVs.
```{r}
ps1.stool.rel2.f <- microbiomeutilities::format_to_besthit(ps1.stool.rel2)
p.core <- plot_core(ps1.stool.rel2.f,
plot.type = "heatmap",
colours = rev(brewer.pal(5, "Spectral")),
prevalences = prevalences,
detections = detections,
min.prevalence = .5) +
xlab("Detection Threshold (Relative Abundance (%))")
p.core + theme(axis.text.y = element_text(face="italic"))
print(p.core)
```
```{r}
sessionInfo()
```