-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathEcoSimRPresentation_Fin.Rmd
150 lines (124 loc) · 4.19 KB
/
EcoSimRPresentation_Fin.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
---
title: "EcoSimR Presentation"
author: "Morgan Southgate"
date: "April 18, 2017"
output:
html_document:
theme: cerulean
---
# EcoSimR - Null Model Analysis of Ecological Data
### The following code demonstrates how to use the EcoSimR package to conduct a species co-occurrence analysis using null models. The results of this analysis reveal if there are statistically significant patterns of species aggregation or segregation in the dataset.
### The following code uses associated species data collected from 19 survey patches across five serpentine outcrops in northern VT, which was collected as part of a maidenhair fern habitat study in the summer of 2016. The following code transforms the associated species data into a presence-absence matrix that is then used for the null model analysis.
[Associated Species Data](AssociatedSppData_Serp.csv)
## 1. Create presence-absence matrix from species list data
```{r, echo=TRUE, message=FALSE, warning=FALSE}
# read in associated species data
sppDat <- read.table("AssociatedSppData_Serp.csv",header=TRUE,sep=",",stringsAsFactors = FALSE)
head(sppDat)
```
```{r, echo=TRUE, message=FALSE, warning=FALSE}
# reshape data using dcast function in reshape2 package
library(reshape2)
PA <- dcast(sppDat,formula=SpeciesName~SitePatch)
head(PA)
dim(PA)
```
## 2. Conduct Species Co-occurrence Analysis using EcoSimR
### SIM9 null model algorithm- row and column sums fixed
#### CHECKER index
```{r, echo=TRUE, message=FALSE}
library(EcoSimR)
library(MASS)
# Run null model with SIM9 algorithm & CHECKER index
adMod1 <- cooc_null_model(PA,
algo="sim9",
metric="checker",
nReps=1000,
suppressProg=T)
# Summary and plots
summary(adMod1)
mean(adMod1$Sim)
plot(adMod1,type="hist")
plot(adMod1,type="cooc")
plot(adMod1,type="burn_in")
```
#### C score index
```{r, echo=TRUE, message=FALSE, warning=FALSE}
## Run null model with SIM9 algorithm and C score index
adMod2 <- cooc_null_model(PA,
algo="sim9",
metric="c_score",
nReps=1000,
suppressProg = T)
# Summary and plots
summary(adMod2)
plot(adMod2,type="hist")
plot(adMod2,type="cooc")
plot(adMod2,type="burn_in")
```
#### COMBO index
```{r, echo=TRUE,eval=F}
# Run null model with SIM9 algorithm and COMBO index
adMod3 <- cooc_null_model(PA,
algo="sim9",
metric="species_combo",
nReps=1000,
suppressProg = T)
# Summary and plots
summary(adMod3)
plot(adMod3,type="hist")
plot(adMod3,type="cooc")
```
### SIM2 null model algorithm- row sums fixed, columns equiprobable
#### CHECKER Index
```{r, echo=TRUE}
# Run null model with SIM2 algorithm and C score index
adMod4 <- cooc_null_model(PA,
algo= "sim2",
metric="c_score",
nReps=1000,
suppressProg=T)
# Summary and plots
summary(adMod4)
plot(adMod4,type="hist")
plot(adMod4,type="cooc")
```
#### C score Index
```{r, echo=TRUE}
# Run null model with SIM2 algorithm and CHECKER index
adMod5 <- cooc_null_model(PA,
algo= "sim2",
metric="checker",
nReps=1000,
suppressProg=T)
# Summary and plots
summary(adMod5)
plot(adMod5,type="hist")
plot(adMod5,type="cooc")
```
#### V ratio Index
```{r, echo=TRUE}
# Run null model with SIM2 algorithm and V ratio index
adMod6 <- cooc_null_model(PA,
algo= "sim2",
metric="v_ratio",
nReps=1000,
suppressProg=T)
# Summary and plots
summary(adMod6)
plot(adMod6,type="hist")
plot(adMod6,type="cooc")
```
#### COMBO Index
```{r, echo=TRUE}
# Run null model with SIM2 algorithm and COMBO index
adMod7 <- cooc_null_model(PA,
algo="sim2",
metric="species_combo",
nReps=1000,
suppressProg=T)
# Summary and plots
summary(adMod7)
plot(adMod7,type="hist")
plot(adMod7,type="cooc")
```