# set global chunk options:
library(knitr)
opts_chunk$set(cache=FALSE, fig.align='center')
The following shows how among cluster beta diversity is calculated.
#Among beta partitioning; analyzes with Hill number 1
sp.part.among.prep<-phyloDATA2014(tree0, abd.sp.allsp)
sp.part.among<-PhD2014(sp.part.among.prep$pAbun, sp.part.among.prep$pLength, 1)
sp.part.among$pCqN
## [1] 0.6459545
#Among beta partitioning for angiosperms only; analyzes with Hill number 1
sp.angio.part.among.prep<-phyloDATA2014(angiotree0, angio.sp.abd)
sp.angio.part.among<-PhD2014(sp.angio.part.among.prep$pAbun, sp.angio.part.among.prep$pLength, 1)
sp.angio.part.among$pCqN
## [1] 0.6545234
#Among phylogenetic beta partitioning; analyzes with Hill number 1
part.among.prep<-phyloDATA2014(tree, abd.sp.allsp)
part.among<-PhD2014(part.among.prep$pAbun, part.among.prep$pLength, 1)
part.among$pCqN
## [1] 0.9090127
#Among phylogenetic beta partitioning for angiosperms only; analyzes with Hill number 1
angio.part.among.prep<-phyloDATA2014(angiotree, angio.sp.abd)
angio.part.among<-PhD2014(angio.part.among.prep$pAbun, angio.part.among.prep$pLength, 1)
angio.part.among$pCqN
## [1] 0.8869543
In the following analyzes, I partition within and among beta and phylogenetic diversity. I do separate analyzes for Chao’s weighted and non-weighted beta diversity, as well as for both angiosperms and vasculars.
In these analyzes, the clusters are based on those groups from the environmental distance grouping using Gower’s distances. I first calculate 3,4, and 5 environmental distance clusters, and then I divide the plots according to those groups and do all subsequent beta diversity and phylogenetic analyzes based on those groupings. Therefore, the groupings remain the same for all analyzes.
According to Chao’s beta diversity partitioning, non-weighted beta partitioning compares species richness within a cluster to the overall richness.
Abundance-weighting to the order of 1 then compares overall Shannon’s diversity to within cluster diversity.
Chao’s phylogenetic beta diversity compares the branch lengths that are shared among groups to those branch lengths specific to a cluster.
head(vasc.env.clust.3$cluster)
## EA1 EB1 EC1 ED1 EE1 EF1
## 2 2 2 2 2 2
str(vasc.env.clust.4$cluster)
## Named int [1:176] 1 1 3 1 1 1 1 3 1 3 ...
## - attr(*, "names")= chr [1:176] "EA1" "EB1" "EC1" "ED1" ...
str(vasc.env.clust.5$cluster)
## Named int [1:176] 5 5 5 5 5 5 5 5 5 5 ...
## - attr(*, "names")= chr [1:176] "EA1" "EB1" "EC1" "ED1" ...
# Three cluster groupings
abd.sp.groups.3<- cbind(t(abd.sp.allsp), vasc.env.clust.3$cluster)
colnames(abd.sp.groups.3)[which(colnames(abd.sp.groups.3) == "")] <- "Group"
Three.clust.1<-subset(abd.sp.groups.3,abd.sp.groups.3[,126]=="1")
Three.clust.2<-subset(abd.sp.groups.3,abd.sp.groups.3[,126]=="2")
Three.clust.3<-subset(abd.sp.groups.3,abd.sp.groups.3[,126]=="3")
# Check - the following should equal 176
nrow(Three.clust.1)+nrow(Three.clust.2)+nrow(Three.clust.3)
## [1] 176
# Four cluster groupings
abd.sp.groups.4<- cbind(t(abd.sp.allsp), vasc.env.clust.4$cluster)
colnames(abd.sp.groups.4)[which(colnames(abd.sp.groups.4) == "")] <- "Group"
Four.clust.1<-subset(abd.sp.groups.4,abd.sp.groups.4[,126]=="1")
Four.clust.2<-subset(abd.sp.groups.4,abd.sp.groups.4[,126]=="2")
Four.clust.3<-subset(abd.sp.groups.4,abd.sp.groups.4[,126]=="3")
Four.clust.4<-subset(abd.sp.groups.4,abd.sp.groups.4[,126]=="4")
# Five cluster groupings
abd.sp.groups.5<- cbind(t(abd.sp.allsp), vasc.env.clust.5$cluster)
colnames(abd.sp.groups.5)[which(colnames(abd.sp.groups.5) == "")] <- "Group"
Five.clust.1<-subset(abd.sp.groups.5,abd.sp.groups.5[,126]=="1")
Five.clust.2<-subset(abd.sp.groups.5,abd.sp.groups.5[,126]=="2")
Five.clust.3<-subset(abd.sp.groups.5,abd.sp.groups.5[,126]=="3")
Five.clust.4<-subset(abd.sp.groups.5,abd.sp.groups.5[,126]=="4")
Five.clust.5<-subset(abd.sp.groups.5,abd.sp.groups.5[,126]=="5")
The following is sample code of show to calculate within cluster beta diversity.
sp.part.within.prep.1.3<-phyloDATA2014(tree0, t(Three.clust.1))
sp.part.within.1.3<-PhD2014(sp.part.within.prep.1.3$pAbun, sp.part.within.prep.1.3$pLength, 1)
sp.part.within.1.3$pCqN
## [1] 0.6343807
sp.part.within.prep.2.3<-phyloDATA2014(tree0, t(Three.clust.2))
sp.part.within.2.3<-PhD2014(sp.part.within.prep.2.3$pAbun, sp.part.within.prep.2.3$pLength, 1)
sp.part.within.2.3$pCqN
## [1] 0.6578618
sp.part.within.prep.3.3<-phyloDATA2014(tree0, t(Three.clust.3))
sp.part.within.3.3<-PhD2014(sp.part.within.prep.3.3$pAbun, sp.part.within.prep.3.3$pLength, 1)
sp.part.within.3.3$pCqN
## [1] 0.6271168
#Within phylogenetic beta partitioning; analyzes with Hill number 1 for group 1 in three group clustering (vasculars)
ph.part.within.prep.1.3<-phyloDATA2014(tree, t(Three.clust.1))
ph.part.within.1.3<-PhD2014(ph.part.within.prep.1.3$pAbun, ph.part.within.prep.1.3$pLength, 1)
ph.part.within.1.3$pCqN
## [1] 0.9266243
ph.part.within.prep.2.3<-phyloDATA2014(tree, t(Three.clust.2))
ph.part.within.2.3<-PhD2014(ph.part.within.prep.2.3$pAbun, ph.part.within.prep.2.3$pLength, 1)
ph.part.within.2.3$pCqN
## [1] 0.90829
ph.part.within.prep.3.3<-phyloDATA2014(tree, t(Three.clust.3))
ph.part.within.3.3<-PhD2014(ph.part.within.prep.3.3$pAbun, ph.part.within.prep.3.3$pLength, 1)
ph.part.within.3.3$pCqN
## [1] 0.8926333
The following is sample code showing how groups are divided and within group beta diversity is partitioned.
# Three cluster groupings
angio.abd.sp.groups.3<- cbind(t(angio.sp.abd), vasc.env.clust.3$cluster)
colnames(abd.sp.groups.3)[which(colnames(angio.abd.sp.groups.3) == "")] <- "Group"
Three.clust.1.angio<-subset(angio.abd.sp.groups.3,angio.abd.sp.groups.3[,111]=="1")
Three.clust.2.angio<-subset(angio.abd.sp.groups.3,angio.abd.sp.groups.3[,111]=="2")
Three.clust.3.angio<-subset(angio.abd.sp.groups.3,angio.abd.sp.groups.3[,111]=="3")
# Check - the following should equal 176
nrow(Three.clust.1.angio)+nrow(Three.clust.2.angio)+nrow(Three.clust.3.angio)
## [1] 176
# Four cluster groupings
angio.abd.sp.groups.4<- cbind(t(angio.sp.abd), vasc.env.clust.4$cluster)
colnames(angio.abd.sp.groups.4)[which(colnames(angio.abd.sp.groups.4) == "")] <- "Group"
Four.clust.1.angio<-subset(angio.abd.sp.groups.4,angio.abd.sp.groups.4[,111]=="1")
Four.clust.2.angio<-subset(angio.abd.sp.groups.4,angio.abd.sp.groups.4[,111]=="2")
Four.clust.3.angio<-subset(angio.abd.sp.groups.4,angio.abd.sp.groups.4[,111]=="3")
Four.clust.4.angio<-subset(angio.abd.sp.groups.4,angio.abd.sp.groups.4[,111]=="4")
# Five cluster groupings
angio.abd.sp.groups.5<- cbind(t(angio.sp.abd), vasc.env.clust.5$cluster)
colnames(angio.abd.sp.groups.5)[which(colnames(angio.abd.sp.groups.5) == "")] <- "Group"
Five.clust.1.angio<-subset(angio.abd.sp.groups.5,angio.abd.sp.groups.5[,111]=="1")
Five.clust.2.angio<-subset(angio.abd.sp.groups.5,angio.abd.sp.groups.5[,111]=="2")
Five.clust.3.angio<-subset(angio.abd.sp.groups.5,angio.abd.sp.groups.5[,111]=="3")
Five.clust.4.angio<-subset(angio.abd.sp.groups.5,angio.abd.sp.groups.5[,111]=="4")
Five.clust.5.angio<-subset(angio.abd.sp.groups.5,angio.abd.sp.groups.5[,111]=="5")
#Within phylogenetic beta partitioning; analyzes with Hill number 0 for group 1 in three group clustering
no.abd.sp.part.within.prep.1.3.angio<-phyloDATA2014(angiotree0, t(Three.clust.1.angio))
no.abd.sp.part.within.1.3.angio<-PhD2014(no.abd.sp.part.within.prep.1.3.angio$pAbun, no.abd.sp.part.within.prep.1.3.angio$pLength, 0)
no.abd.sp.part.within.1.3.angio$pCqN
## [1] 0.8506986
no.abd.sp.part.within.prep.2.3.angio<-phyloDATA2014(angiotree0, t(Three.clust.2.angio))
no.abd.sp.part.within.2.3.angio<-PhD2014(no.abd.sp.part.within.prep.2.3.angio$pAbun, no.abd.sp.part.within.prep.2.3.angio$pLength, 0)
no.abd.sp.part.within.2.3.angio$pCqN
## [1] 0.93257
no.abd.sp.part.within.prep.3.3.angio<-phyloDATA2014(angiotree0, t(Three.clust.3.angio))
no.abd.sp.part.within.3.3.angio<-PhD2014(no.abd.sp.part.within.prep.3.3.angio$pAbun, no.abd.sp.part.within.prep.3.3.angio$pLength, 0)
no.abd.sp.part.within.3.3.angio$pCqN
## [1] 0.8968521
#dev.new(width=11.8, height=5.5)
par(mfrow=c(1,3))
plot(no.abd.sp.line[1,], axes=FALSE, col="black", pch=16, cex=1.25, ylab="Beta diversity", xlab="Group",las=1, cex.axis=1, cex.lab=1,
main="Phylogenetic beta diversity compared to beta diversity within and \namong sampling bands (vasculars) using Chao's beta diversity \nfor three grouping based on environmental distances", ylim=c(0.45,1),cex.main=0.85, bty="c")
axis(1,1:3,labels=c("Group 1", "Group 2", "Group 3"))
axis(2)
points(no.abd.ph.line[1,], col="gray70", pch=16, cex=1.25)
abline(h=no.abd.sp.part.among$pCqN, lwd=2, lty=2)
abline(h=no.abd.part.among$pCqN, lwd=2, lty=2, col="gray70")
box(bty="l", lwd=3)
legend("bottomright", c("Beta diversity (among)", "Beta diversity (within)", "Phylogenetic beta diversity (among)", "Phylogenetic beta diversity (within)"), col = c("black","black", "gray70", "gray70"), cex=1,
lty = c(2, 0,2,0),lwd=c(2,2,2,2), pch = c(NA, 16, NA, 16), bg = "white", bty="n")
plot(no.abd.sp.line.four[1,], axes=FALSE, col="black", pch=16, cex=1.25, ylab="Beta diversity", xlab="Group",las=1, cex.axis=1, cex.lab=1,
main="Phylogenetic beta diversity compared to beta diversity within and \namong sampling bands (vasculars) using Chao's beta diversity \nfor four grouping based on environmental distances", ylim=c(0.45,1),cex.main=0.85, bty="c")
axis(1,1:4,labels=c("Group 1", "Group 2", "Group 3", "Group 4"))
axis(2)
points(no.abd.ph.line.four[1,], col="gray70", pch=16, cex=1.25)
abline(h=no.abd.sp.part.among$pCqN, lwd=2, lty=2)
abline(h=no.abd.part.among$pCqN, lwd=2, lty=2, col="gray70")
box(bty="l", lwd=3)
legend("bottomright", c("Beta diversity (among)", "Beta diversity (within)", "Phylogenetic beta diversity (among)", "Phylogenetic beta diversity (within)"), col = c("black","black", "gray70", "gray70"), cex=1,
lty = c(2, 0,2,0),lwd=c(2,2,2,2), pch = c(NA, 16, NA, 16), bg = "white", bty="n")
plot(no.abd.sp.line.five[1,], axes=FALSE, col="black", pch=16, cex=1.25, ylab="Beta diversity", xlab="Group",las=1, cex.axis=1, cex.lab=1,
main="Phylogenetic beta diversity compared to beta diversity within and \namong sampling bands (vasculars) using Chao's beta diversity \nfor five grouping based on environmental distances", ylim=c(0.45,1),cex.main=0.85, bty="c")
axis(1,1:5,labels=c("Group 1", "Group 2", "Group 3", "Group 4", "Group 5"))
axis(2)
points(no.abd.ph.line.five[1,], col="gray70", pch=16, cex=1.25)
abline(h=no.abd.sp.part.among$pCqN, lwd=2, lty=2)
abline(h=no.abd.part.among$pCqN, lwd=2, lty=2, col="gray70")
box(bty="l", lwd=3)
legend("bottomright", c("Beta diversity (among)", "Beta diversity (within)", "Phylogenetic beta diversity (among)", "Phylogenetic beta diversity (within)"), col = c("black","black", "gray70", "gray70"), cex=1,
lty = c(2, 0,2,0),lwd=c(2,2,2,2), pch = c(NA, 16, NA, 16), bg = "white", bty="n")
#dev.new(width=11.8, height=5.5)
par(mfrow=c(1,3))
plot(sp.line[1,], axes=FALSE, col="black", pch=16, cex=1.25, ylab="Beta diversity", xlab="Group",las=1, cex.axis=1, cex.lab=1,
main="Phylogenetic beta diversity compared to beta diversity within and \namong sampling bands (vasculars) using Chao's weighted beta diversity \nfor three grouping based on environmental distances", ylim=c(0.3,1),cex.main=0.85, bty="c")
axis(1,1:3,labels=c("Group 1", "Group 2", "Group 3"))
axis(2)
points(ph.line[1,], col="gray70", pch=16, cex=1.25)
abline(h=sp.part.among$pCqN, lwd=2, lty=2)
abline(h=part.among$pCqN, lwd=2, lty=2, col="gray70")
box(bty="l", lwd=3)
legend("bottomright", c("Beta diversity (among)", "Beta diversity (within)", "Phylogenetic beta diversity (among)", "Phylogenetic beta diversity (within)"), col = c("black","black", "gray70", "gray70"), cex=1,
lty = c(2, 0,2,0),lwd=c(2,2,2,2), pch = c(NA, 16, NA, 16), bg = "white", bty="n")
plot(sp.line.four[1,], axes=FALSE, col="black", pch=16, cex=1.25, ylab="Beta diversity", xlab="Group",las=1, cex.axis=1, cex.lab=1,
main="Phylogenetic beta diversity compared to beta diversity within and \namong sampling bands (vasculars) using Chao's weighted beta diversity \nfor four grouping based on environmental distances", ylim=c(0.3,1),cex.main=0.85, bty="c")
axis(1,1:4,labels=c("Group 1", "Group 2", "Group 3", "Group 4"))
axis(2)
points(ph.line.four[1,], col="gray70", pch=16, cex=1.25)
abline(h=sp.part.among$pCqN, lwd=2, lty=2)
abline(h=part.among$pCqN, lwd=2, lty=2, col="gray70")
box(bty="l", lwd=3)
legend("bottomright", c("Beta diversity (among)", "Beta diversity (within)", "Phylogenetic beta diversity (among)", "Phylogenetic beta diversity (within)"), col = c("black","black", "gray70", "gray70"), cex=1,
lty = c(2, 0,2,0),lwd=c(2,2,2,2), pch = c(NA, 16, NA, 16), bg = "white", bty="n")
plot(sp.line.five[1,], axes=FALSE, col="black", pch=16, cex=1.25, ylab="Beta diversity", xlab="Group",las=1, cex.axis=1, cex.lab=1,
main="Phylogenetic beta diversity compared to beta diversity within and \namong sampling bands (vasculars) using Chao's weighted beta diversity \nfor five grouping based on environmental distances", ylim=c(0.3,1),cex.main=0.85, bty="c")
axis(1,1:5,labels=c("Group 1", "Group 2", "Group 3", "Group 4", "Group 5"))
axis(2)
points(ph.line.five[1,], col="gray70", pch=16, cex=1.25)
abline(h=sp.part.among$pCqN, lwd=2, lty=2)
abline(h=part.among$pCqN, lwd=2, lty=2, col="gray70")
box(bty="l", lwd=3)
legend("bottomright", c("Beta diversity (among)", "Beta diversity (within)", "Phylogenetic beta diversity (among)", "Phylogenetic beta diversity (within)"), col = c("black","black", "gray70", "gray70"), cex=1,
lty = c(2, 0,2,0),lwd=c(2,2,2,2), pch = c(NA, 16, NA, 16), bg = "white", bty="n")
#dev.new(width=11.8, height=5.5)
par(mfrow=c(1,3))
plot(no.abd.sp.line.angio[1,], axes=FALSE, col="black", pch=16, cex=1.25, ylab="Beta diversity", xlab="Group",las=1, cex.axis=1, cex.lab=1,
main="Phylogenetic beta diversity compared to beta diversity within and \namong sampling bands (angiosperms) using Chao's beta diversity \nfor three grouping based on environmental distances", ylim=c(0.45,1),cex.main=0.85, bty="c")
axis(1,1:3,labels=c("Group 1", "Group 2", "Group 3"))
axis(2)
points(no.abd.ph.line.angio[1,], col="gray70", pch=16, cex=1.25)
abline(h=sp.angio.part.among$pCqN, lwd=2, lty=2)
abline(h=angio.part.among$pCqN, lwd=2, lty=2, col="gray70")
box(bty="l", lwd=3)
legend("bottomright", c("Beta diversity (among)", "Beta diversity (within)", "Phylogenetic beta diversity (among)", "Phylogenetic beta diversity (within)"), col = c("black","black", "gray70", "gray70"), cex=1,
lty = c(2, 0,2,0),lwd=c(2,2,2,2), pch = c(NA, 16, NA, 16), bg = "white", bty="n")
plot(no.abd.sp.line.four.angio[1,], axes=FALSE, col="black", pch=16, cex=1.25, ylab="Beta diversity", xlab="Group",las=1, cex.axis=1, cex.lab=1,
main="Phylogenetic beta diversity compared to beta diversity within and \namong sampling bands (angiosperms) using Chao's beta diversity \nfor four grouping based on environmental distances", ylim=c(0.45,1),cex.main=0.85, bty="c")
axis(1,1:4,labels=c("Group 1", "Group 2", "Group 3", "Group 4"))
axis(2)
points(no.abd.ph.line.four.angio[1,], col="gray70", pch=16, cex=1.25)
abline(h=sp.angio.part.among$pCqN, lwd=2, lty=2)
abline(h=angio.part.among$pCqN, lwd=2, lty=2, col="gray70")
box(bty="l", lwd=3)
legend("bottomright", c("Beta diversity (among)", "Beta diversity (within)", "Phylogenetic beta diversity (among)", "Phylogenetic beta diversity (within)"), col = c("black","black", "gray70", "gray70"), cex=1,
lty = c(2, 0,2,0),lwd=c(2,2,2,2), pch = c(NA, 16, NA, 16), bg = "white", bty="n")
plot(no.abd.sp.line.five.angio[1,], axes=FALSE, col="black", pch=16, cex=1.25, ylab="Beta diversity", xlab="Group",las=1, cex.axis=1, cex.lab=1,
main="Phylogenetic beta diversity compared to beta diversity within and \namong sampling bands (angiosperms) using Chao's beta diversity \nfor five grouping based on environmental distances", ylim=c(0.45,1),cex.main=0.85, bty="c")
axis(1,1:5,labels=c("Group 1", "Group 2", "Group 3", "Group 4", "Group 5"))
axis(2)
points(no.abd.ph.line.five.angio[1,], col="gray70", pch=16, cex=1.25)
abline(h=sp.angio.part.among$pCqN, lwd=2, lty=2)
abline(h=angio.part.among$pCqN, lwd=2, lty=2, col="gray70")
box(bty="l", lwd=3)
legend("bottomright", c("Beta diversity (among)", "Beta diversity (within)", "Phylogenetic beta diversity (among)", "Phylogenetic beta diversity (within)"), col = c("black","black", "gray70", "gray70"), cex=1,
lty = c(2, 0,2,0),lwd=c(2,2,2,2), pch = c(NA, 16, NA, 16), bg = "white", bty="n")
#dev.new(width=11.8, height=5.5)
par(mfrow=c(1,3))
plot(abd.sp.line.angio[1,], axes=FALSE, col="black", pch=16, cex=1.25, ylab="Beta diversity", xlab="Group",las=1, cex.axis=1, cex.lab=1,
main="Phylogenetic beta diversity compared to beta diversity within and \namong sampling bands (angiosperms) using Chao's weighted beta diversity \nfor three grouping based on environmental distances", ylim=c(0.35,1),cex.main=0.85, bty="c")
axis(1,1:3,labels=c("Group 1", "Group 2", "Group 3"))
axis(2)
points(abd.ph.line.angio[1,], col="gray70", pch=16, cex=1.25)
abline(h=abd.sp.abd.angio.part.among$pCqN, lwd=2, lty=2)
abline(h=abd.angio.part.among$pCqN, lwd=2, lty=2, col="gray70")
box(bty="l", lwd=3)
legend("bottomright", c("Beta diversity (among)", "Beta diversity (within)", "Phylogenetic beta diversity (among)", "Phylogenetic beta diversity (within)"), col = c("black","black", "gray70", "gray70"), cex=1,
lty = c(2, 0,2,0),lwd=c(2,2,2,2), pch = c(NA, 16, NA, 16), bg = "white", bty="n")
plot(abd.sp.line.four.angio[1,], axes=FALSE, col="black", pch=16, cex=1.25, ylab="Beta diversity", xlab="Group",las=1, cex.axis=1, cex.lab=1,
main="Phylogenetic beta diversity compared to beta diversity within and \namong sampling bands (angiosperms) using Chao's weighted beta diversity \nfor four grouping based on environmental distances", ylim=c(0.35,1),cex.main=0.85, bty="c")
axis(1,1:4,labels=c("Group 1", "Group 2", "Group 3", "Group 4"))
axis(2)
points(abd.ph.line.four.angio[1,], col="gray70", pch=16, cex=1.25)
abline(h=abd.sp.abd.angio.part.among$pCqN, lwd=2, lty=2)
abline(h=abd.angio.part.among$pCqN, lwd=2, lty=2, col="gray70")
box(bty="l", lwd=3)
legend("bottomright", c("Beta diversity (among)", "Beta diversity (within)", "Phylogenetic beta diversity (among)", "Phylogenetic beta diversity (within)"), col = c("black","black", "gray70", "gray70"), cex=1,
lty = c(2, 0,2,0),lwd=c(2,2,2,2), pch = c(NA, 16, NA, 16), bg = "white", bty="n")
plot(abd.sp.line.five.angio[1,], axes=FALSE, col="black", pch=16, cex=1.25, ylab="Beta diversity", xlab="Group",las=1, cex.axis=1, cex.lab=1,
main="Phylogenetic beta diversity compared to beta diversity within and \namong sampling bands (angiosperms) using Chao's weighted beta diversity \nfor five grouping based on environmental distances", ylim=c(0.35,1),cex.main=0.85, bty="c")
axis(1,1:5,labels=c("Group 1", "Group 2", "Group 3", "Group 4", "Group 5"))
axis(2)
points(abd.ph.line.five.angio[1,], col="gray70", pch=16, cex=1.25)
abline(h=abd.sp.abd.angio.part.among$pCqN, lwd=2, lty=2)
abline(h=abd.angio.part.among$pCqN, lwd=2, lty=2, col="gray70")
box(bty="l", lwd=3)
legend("bottomright", c("Beta diversity (among)", "Beta diversity (within)", "Phylogenetic beta diversity (among)", "Phylogenetic beta diversity (within)"), col = c("black","black", "gray70", "gray70"), cex=1,
lty = c(2, 0,2,0),lwd=c(2,2,2,2), pch = c(NA, 16, NA, 16), bg = "white", bty="n")
The following sample code shows how I divide the clusters based on my classifications
# Make Tammy classifications
library(plyr)
## Warning: package 'plyr' was built under R version 3.1.1
hab<-site[,c(3:5), drop=FALSE]
hab.types<-hab[,1, drop=FALSE]
hab.types.smaller<-revalue(hab.types[,1], c("Spruce lichen - Shrubs"="Spruce lichen" , "Spruce moss - Spruce lichen"="Spruce lichen",
"Spruce moss - Shrubs"="Spruce moss", "Spruce moss - Fen" = "Fen", "Tundra - Shrubs"="Tundra"))
table(hab.types.smaller)
## hab.types.smaller
## Fen Shrubs Spruce lichen Spruce moss Tundra
## 33 31 10 71 31
hab.new<-cbind(hab.types.smaller,hab[,c(2:3)])
tam.class<-revalue(hab.types.smaller, c("Fen"="1", "Spruce lichen"="2", "Spruce moss"= "3", "Shrubs"= "4","Tundra"="5"))
(tam.class.table<-table(tam.class))
## tam.class
## 1 4 2 3 5
## 33 31 10 71 31
names(tam.class)<-colnames(abd.sp.allsp)
tam.class.groups.5<- cbind(t(abd.sp.allsp), tam.class)
colnames(tam.class.groups.5)[which(colnames(tam.class.groups.5) == "")] <- "Group"
Five.clust.1.tc<-subset(tam.class.groups.5,tam.class.groups.5[,126]=="1")
Five.clust.2.tc<-subset(tam.class.groups.5,tam.class.groups.5[,126]=="2")
Five.clust.3.tc<-subset(tam.class.groups.5,tam.class.groups.5[,126]=="3")
Five.clust.4.tc<-subset(tam.class.groups.5,tam.class.groups.5[,126]=="4")
Five.clust.5.tc<-subset(tam.class.groups.5,tam.class.groups.5[,126]=="5")
#Among beta partitioning for vasculars only; analyzes with Hill number 1
abd.sp.abd.part.among.prep.tc<-phyloDATA2014(tree0, t(tam.class.groups.5))
abd.sp.abd.part.among.tc<-PhD2014(abd.sp.abd.part.among.prep.tc$pAbun, abd.sp.abd.part.among.prep.tc$pLength, 1)
abd.sp.abd.part.among.tc$pCqN
## [1] 0.6459545
#dev.new(width=11.8, height=8)
par(mfrow=c(2,2))
plot(no.abd.sp.line.five[1,], axes=FALSE, col="black", pch=16, cex=1.25, ylab="Beta diversity", xlab="Group",las=1, cex.axis=1, cex.lab=1,
main="Phylogenetic beta diversity compared to beta diversity within and \namong sampling bands (vasculars) using Chao's beta diversity \nfor five grouping based on environmental distances", ylim=c(0.45,1),cex.main=0.85, bty="c")
axis(1,1:5,labels=c("Group 1", "Group 2", "Group 3", "Group 4", "Group 5"))
axis(2)
points(no.abd.ph.line.five[1,], col="gray70", pch=16, cex=1.25)
abline(h=no.abd.sp.part.among$pCqN, lwd=2, lty=2)
abline(h=no.abd.part.among$pCqN, lwd=2, lty=2, col="gray70")
box(bty="l", lwd=3)
legend("bottomright", c("Beta diversity (among)", "Beta diversity (within)", "Phylogenetic beta diversity (among)", "Phylogenetic beta diversity (within)"), col = c("black","black", "gray70", "gray70"), cex=0.8,
lty = c(2, 0,2,0),lwd=c(2,2,2,2), pch = c(NA, 16, NA, 16), bg = "white", bty="n")
plot(sp.line.five[1,], axes=FALSE, col="black", pch=16, cex=1.25, ylab="Beta diversity", xlab="Group",las=1, cex.axis=1, cex.lab=1,
main="Phylogenetic beta diversity compared to beta diversity within and \namong sampling bands (vasculars) using Chao's weighted beta diversity \nfor five grouping based on environmental distances", ylim=c(0.3,1),cex.main=0.85, bty="c")
axis(1,1:5,labels=c("Group 1", "Group 2", "Group 3", "Group 4", "Group 5"))
axis(2)
points(ph.line.five[1,], col="gray70", pch=16, cex=1.25)
abline(h=sp.part.among$pCqN, lwd=2, lty=2)
abline(h=part.among$pCqN, lwd=2, lty=2, col="gray70")
box(bty="l", lwd=3)
legend("bottomright", c("Beta diversity (among)", "Beta diversity (within)", "Phylogenetic beta diversity (among)", "Phylogenetic beta diversity (within)"), col = c("black","black", "gray70", "gray70"), cex=0.8,
lty = c(2, 0,2,0),lwd=c(2,2,2,2), pch = c(NA, 16, NA, 16), bg = "white", bty="n")
plot(tc.sp.line.five[1,], axes=FALSE, col="black", pch=16, cex=1.25, ylab="Beta diversity", xlab="Group",las=1, cex.axis=1, cex.lab=1,
main="Phylogenetic beta diversity compared to beta diversity within and \namong sampling bands (vasculars) using Chao's beta diversity \nfor five grouping based on Tammy's classification", ylim=c(0.3,1),cex.main=0.85, bty="c")
axis(1,1:5,labels=c("Group 1", "Group 2", "Group 3", "Group 4", "Group 5"))
axis(2)
points(tc.ph.line.five[1,], col="gray70", pch=16, cex=1.25)
abline(h=sp.abd.part.among.tc$pCqN, lwd=2, lty=2)
abline(h=part.among.tc$pCqN, lwd=2, lty=2, col="gray70")
box(bty="l", lwd=3)
legend("bottomright", c("Beta diversity (among)", "Beta diversity (within)", "Phylogenetic beta diversity (among)", "Phylogenetic beta diversity (within)"), col = c("black","black", "gray70", "gray70"), cex=0.8,
lty = c(2, 0,2,0),lwd=c(2,2,2,2), pch = c(NA, 16, NA, 16), bg = "white", bty="n")
plot(tc.abd.sp.line.five[1,], axes=FALSE, col="black", pch=16, cex=1.25, ylab="Beta diversity", xlab="Group",las=1, cex.axis=1, cex.lab=1,
main="Phylogenetic beta diversity compared to beta diversity within and \namong sampling bands (vasculars) using Chao's weighted beta diversity \nfor five grouping based on Tammy's classificatoin", ylim=c(0.45,1),cex.main=0.85, bty="c")
axis(1,1:5,labels=c("Group 1", "Group 2", "Group 3", "Group 4", "Group 5"))
axis(2)
points(tc.abd.ph.line.five[1,], col="gray70", pch=16, cex=1.25)
abline(h=abd.sp.abd.part.among.tc$pCqN, lwd=2, lty=2)
abline(h=abd.part.among.tc$pCqN, lwd=2, lty=2, col="gray70")
box(bty="l", lwd=3)
legend("bottomright", c("Beta diversity (among)", "Beta diversity (within)", "Phylogenetic beta diversity (among)", "Phylogenetic beta diversity (within)"), col = c("black","black", "gray70", "gray70"), cex=0.8,
lty = c(2, 0,2,0),lwd=c(2,2,2,2), pch = c(NA, 16, NA, 16), bg = "white", bty="n")
#dev.new(width=11.8, height=8)
par(mfrow=c(2,2))
plot(no.abd.sp.line.five.angio[1,], axes=FALSE, col="black", pch=16, cex=1.25, ylab="Beta diversity", xlab="Group",las=1, cex.axis=1, cex.lab=1,
main="Phylogenetic beta diversity compared to beta diversity within and \namong sampling bands (angiosperms) using Chao's beta diversity \nfor five grouping based on environmental distances", ylim=c(0.45,1),cex.main=0.85, bty="c")
axis(1,1:5,labels=c("Group 1", "Group 2", "Group 3", "Group 4", "Group 5"))
axis(2)
points(no.abd.ph.line.five.angio[1,], col="gray70", pch=16, cex=1.25)
abline(h=sp.angio.part.among$pCqN, lwd=2, lty=2)
abline(h=angio.part.among$pCqN, lwd=2, lty=2, col="gray70")
box(bty="l", lwd=3)
legend("bottomright", c("Beta diversity (among)", "Beta diversity (within)", "Phylogenetic beta diversity (among)", "Phylogenetic beta diversity (within)"), col = c("black","black", "gray70", "gray70"), cex=0.8,
lty = c(2, 0,2,0),lwd=c(2,2,2,2), pch = c(NA, 16, NA, 16), bg = "white", bty="n")
plot(abd.sp.line.five.angio[1,], axes=FALSE, col="black", pch=16, cex=1.25, ylab="Beta diversity", xlab="Group",las=1, cex.axis=1, cex.lab=1,
main="Phylogenetic beta diversity compared to beta diversity within and \namong sampling bands (angiosperms) using Chao's weighted beta diversity \nfor five grouping based on environmental distances", ylim=c(0.35,1),cex.main=0.85, bty="c")
axis(1,1:5,labels=c("Group 1", "Group 2", "Group 3", "Group 4", "Group 5"))
axis(2)
points(abd.ph.line.five.angio[1,], col="gray70", pch=16, cex=1.25)
abline(h=abd.sp.abd.angio.part.among$pCqN, lwd=2, lty=2)
abline(h=abd.angio.part.among$pCqN, lwd=2, lty=2, col="gray70")
box(bty="l", lwd=3)
legend("bottomright", c("Beta diversity (among)", "Beta diversity (within)", "Phylogenetic beta diversity (among)", "Phylogenetic beta diversity (within)"), col = c("black","black", "gray70", "gray70"), cex=0.8,
lty = c(2, 0,2,0),lwd=c(2,2,2,2), pch = c(NA, 16, NA, 16), bg = "white", bty="n")
# These two are based on Tammy's classifications
plot(angio.tc.sp.line.five[1,], axes=FALSE, col="black", pch=16, cex=1.25, ylab="Beta diversity", xlab="Group",las=1, cex.axis=1, cex.lab=1,
main="Phylogenetic beta diversity compared to beta diversity within and \namong sampling bands (angiosperms) using Chao's beta diversity \nfor five grouping based on Tammy's classifications", ylim=c(0.3,1),cex.main=0.85, bty="c")
axis(1,1:5,labels=c("Group 1", "Group 2", "Group 3", "Group 4", "Group 5"))
axis(2)
points(angio.tc.ph.line.five[1,], col="gray70", pch=16, cex=1.25)
abline(h=sp.abd.angio.part.among.tc$pCqN, lwd=2, lty=2)
abline(h=angio.part.among.tc$pCqN, lwd=2, lty=2, col="gray70")
box(bty="l", lwd=3)
legend("bottomright", c("Beta diversity (among)", "Beta diversity (within)", "Phylogenetic beta diversity (among)", "Phylogenetic beta diversity (within)"), col = c("black","black", "gray70", "gray70"), cex=0.8,
lty = c(2, 0,2,0),lwd=c(2,2,2,2), pch = c(NA, 16, NA, 16), bg = "white", bty="n")
plot(angio.tc.abd.sp.line.five[1,], axes=FALSE, col="black", pch=16, cex=1.25, ylab="Beta diversity", xlab="Group",las=1, cex.axis=1, cex.lab=1,
main="Phylogenetic beta diversity compared to beta diversity within and \namong sampling bands (angiosperms) using Chao's weighted beta diversity \nfor five grouping based on Tammy's classifications", ylim=c(0.35,1),cex.main=0.85, bty="c")
axis(1,1:5,labels=c("Group 1", "Group 2", "Group 3", "Group 4", "Group 5"))
axis(2)
points(angio.tc.abd.ph.line.five[1,], col="gray70", pch=16, cex=1.25)
abline(h=abd.sp.abd.angio.part.among.tc$pCqN, lwd=2, lty=2)
abline(h=abd.angio.part.among.tc$pCqN, lwd=2, lty=2, col="gray70")
box(bty="l", lwd=3)
legend("bottomright", c("Beta diversity (among)", "Beta diversity (within)", "Phylogenetic beta diversity (among)", "Phylogenetic beta diversity (within)"), col = c("black","black", "gray70", "gray70"), cex=0.8,
lty = c(2, 0,2,0),lwd=c(2,2,2,2), pch = c(NA, 16, NA, 16), bg = "white", bty="n")