-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmetaAnalysis.R
116 lines (78 loc) · 3.74 KB
/
metaAnalysis.R
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
setwd("C:/Users/ac79/MEGA/Projects/LTER/")
#Identify results files
files=list.files("Results1")[grep("result",list.files("Results1"))]
files=files[-2]
#Put it together
metaResults=NULL #
for(i in 1:length(files)){
metaResults=rbind(metaResults,read.csv(paste0("Results1/",files[i])))
}
#ANALYSIS#######################################################################
metaResults=metaResults[-which(metaResults$taxa=="-99999"),]
#Overall counts
metaResults$quadraticSign=metaResults$quadratic
metaResults$quadraticSign[metaResults$curvature>0]="quadPos"
metaResults$quadraticSign[metaResults$curvature<0]="quadNeg"
categories=summarise(group_by(metaResults,quadraticSign),count=n())
categories$proportions=categories$count/sum(categories$count)
# Significant relationships
climateCat <- categories[c(2,4,5),]
climateCat$proportions <- climateCat$count/sum(climateCat$count)
#Ectotherm/Endotherms
metaResults$ectotherms="ectotherm"
metaResults$ectotherms[metaResults$taxa=="mammal" | metaResults$taxa=="bird"]="endotherm"
ectoEndo=summarise(group_by(metaResults,ectotherms,quadraticSign),count=n())
ectoEndo$proportion=ectoEndo$count/c(rep(sum(ectoEndo$count[1:4]),4),rep(sum(ectoEndo$count[5:8]),4))
head(ectoEndo)
tmp=as.table(rbind(ectoEndo$count[1:4],
ectoEndo$count[5:8]))
dimnames(tmp)=list(organism=c("ecto","endo"),
relationship=c("Linear","NULL","quadNeg","quadPos"))
(Xsq <- chisq.test(tmp))
#Plants
plantProp=summarise(group_by(subset(metaResults,taxa=="plant"),quadraticSign),count=n())
plantProp$proportions=plantProp$count/sum(plantProp$count)
#Plants
metaResults$plankton="plankton"
metaResults$plankton[which(metaResults$taxa!="zooplankton" & metaResults$taxa!="plankton")]="nonPlankton"
#Plankton
planktonCount=summarise(group_by(metaResults,plankton,quadraticSign),count=n())
planktonCount$proportion=planktonCount$count/c(rep(sum(planktonCount$count[1:4]),4),rep(sum(planktonCount$count[5:8]),4))
round(planktonCount$proportion[5:8],2)*100
planktonCount$proportion=
tmp=as.table(rbind(planktonCount$count[1:4],
planktonCount$count[5:8]))
dimnames(tmp)=list(organism=c("nonPla","Pla"),
relationship=c("Linear","NULL","quadNeg","quadPos"))
(Xsq <- chisq.test(tmp))
par(mfrow=c(1,2))
boxplot(sensM ~ plankton,data=metaResults)
boxplot(curvature ~ plankton,data=metaResults)
#Proportions
metaResults$environment="terrestrial"
metaResults$environment[metaResults$LTER=="NorthTemperateLakes"]="fresh water"
metaResults$environment[metaResults$LTER=="SantaBarbara"]="marine"
metaResults$environment[metaResults$LTER=="Palmer" & metaResults$taxa=="zooplankton"]="marine"
metaResults$environment[metaResults$LTER=="Konza" & metaResults$taxa=="fish"]="fresh water"
remove=which(abs(metaResults$sens)>sd(abs(metaResults$sens),na.rm=T))
boxplot(abs(sens) ~ environment,data=metaResults[-remove,])
summary(lm(abs(sens) ~ environment,data=metaResults[-remove,]))
par(mfrow=c(1,1))
plot(metaResults$reps,metaResults$R2,pch=16)
mod=lm(metaResults$R2 ~ metaResults$repT)
abline(mod)
boxplot(R2 ~ quadratic,data=metaResults)
plot(metaResults$bestAICweight,metaResults$R2)
boxplot(abs(sens) ~ ectotherms,data=metaResults[-remove,])
summary(lm(abs(sens) ~ ectotherms,data=metaResults[-remove,]))
hist(metaResults$sens)
metaResults
summary(lm(metaResults$repT ~ quadratic,data=metaResults))
boxplot(quadratic ~ taxa,data=summarise(
group_by(subset(metaResults,taxa=="bird" | taxa=="mammal"),taxa,quadratic),count=n()))
unique(metaResults$taxa)
metaResults$taxa[metaResults$taxa=="birds"]="bird"
metaResults$taxa[metaResults$taxa=="smallMammals"]="mammal"
metaResults$taxa[metaResults$taxa=="small mammal"]="mammal"
metaResults$taxa[metaResults$taxa=="small mammal"]="mammal"
unique(metaResults$taxa)