forked from microbiome/tutorials
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDOC.Rmd
executable file
·76 lines (55 loc) · 1.78 KB
/
DOC.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
---
title: "Dissimilarity-Overlap analysis"
author: "Leo Lahti "
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
---
<!--
%\VignetteEngine{knitr::rmarkdown}
%\VignetteIndexEntry{microbiome tutorial - doc}
%\usepackage[utf8]{inputenc}
%\VignetteEncoding{UTF-8}
-->
```{r setup, message = FALSE, warning = FALSE, results = 'hide'}
#library("devtools")
#install_github("microbiome/microbiome")
```
# Dissimilarity-Overlap analysis
This page provides an example of running the dissimilarity-overlap analysis as proposed in Bashan, A., Gibson, T., Friedman, J. et al. Universality of human microbial dynamics. Nature 534, 259–262 (2016). [DOI:10.1038/nature18301](https://doi.org/10.1038/nature18301).
Load example data:
```{r doc_data, warning=FALSE, message=FALSE}
# Dissimilarity-Overlap analysis
library(microbiome)
data(atlas1006)
```
Estimate the overlap and dissimilarity quantities:
```{r doc_quantities, warning=FALSE, message=FALSE}
# Dissimilarity
d <- phyloseq::distance(microbiome::transform(atlas1006, "compositional"), "jsd", parallel=TRUE)
# Overlap
o <- overlap(atlas1006, detection = 0.2/100)
```
```{r doc_compare, warning=FALSE, message=FALSE}
# Compare
dvec <- d[lower.tri(d)]
ovec <- o[lower.tri(o)]
# Assess rough correlation
cc <- cor(dvec, ovec, method = "spearman", use = "pairwise.complete.obs")
# Scatterplot
plot(dvec, ovec, pch = ".", main = paste("Spearman rho", round(cc, 2)), las = 1, xlab = "Dissimilarity (Jensen-Shannon)", ylab = "Overlap")
#p <- data.frame(D = dvec, O = ovec) %>%
# ggplot(aes(x = D, y = O)) +
# geom_hex()
```