-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMantel_tests.Rmd
34 lines (22 loc) · 1.02 KB
/
Mantel_tests.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
---
title: "Mantel tests"
output: html_notebook
---
This is an Mantel tests Rmd file, introduce how to analysis Mantel tests.
```{r}
library(tidyverse)
library(vegan)
```
Add a new chunk by clicking the *Insert Chunk* button on the toolbar or by pressing *Cmd+Option+I*.
When you save the notebook, an HTML file containing the code and output will be saved alongside it (click the *Preview* button or press *Cmd+Shift+K* to preview the HTML file).
The preview shows you a rendered HTML copy of the contents of the editor. Consequently, unlike *Knit*, *Preview* does not run any R code chunks. Instead, the output of the chunk when it was last run in the editor is displayed.
```{r}
otu.dist <- vegdist(otu, method = 'bray')
env.scale <- scale(env, center = TRUE, scale = TRUE)
env.dist <- dist(env.scale, method = 'euclidean')
```
**重点**
对于env环境数据,根据其尺度的具体情况一般是需要进行scale
```{r}
mantel.result <- mantel(otu.dist, env.dist, method = 'spearman', permutations = 9999, na.rm = TRUE)
```