Schefferville - transitions; contribution of replacement and richness to beta diversity

Tammy L. Elliott

Date: March 1, 2015

R version 3.1

#load data files; TS are fortundra-shrub transition area; SMF files are for spruce-moss forest abundance data
sm.abd<-read.csv("Schefferville_2013_abundance_TLE.csv", head=TRUE, row.names=1)
lg.abd<-read.csv("Schefferville_large_plots_TLE.csv", head=TRUE, row.names=1)
#tundra-shrub transition area
TS.sm.ab<-read.csv("Schefferville_2013_TS_abundance.csv", head=TRUE, row.names=1)
TS.med.ab<-read.csv("Schefferville_2013_TS_med_abundance.csv", head=TRUE, row.names=1)
TS.lg.ab<-read.csv("Schefferville_2013_TS_large_abundance.csv", head=TRUE, row.names=1)
#Spruce-moss forest transition area
SMF.sm.ab<-read.csv("Schefferville_2013_SMF_abundance.csv", head=TRUE, row.names=1)
SMF.med.ab<-read.csv("Schefferville_2013_SMF_med_abundance.csv", head=TRUE, row.names=1)
SMF.lg.ab<-read.csv("Schefferville_2013_SMF_large_abundance.csv", head=TRUE, row.names=1)
#upload site data for each plot
site<-read.csv("Schefferville_2013_sites.csv", head=TRUE, row.names=1)
TS.site<-read.csv("Schefferville_2013_TS_sites.csv", head=TRUE, row.names=1)
SMF.site<-read.csv("Schefferville_2013_SMF_sites.csv", head=TRUE, row.names=1)

#make dataframe for large transects; with plot number, Habitat.description, latitude, longitude
site.trunc<-site[,c(3:5)]

abd.sp<-cbind(sm.abd[,c(2:58, 60:75, 78:114)],lg.abd[,c(1:4)])

#this is large grid plots; should calculate nri from species pool from all species together in plots
#create community matrix with 0 values for  "AreHum" "BetMin" "BetPum" "CarBel" "CarGla" "CopLap" "CorTri" "LuzSpi" "PoaAlp" "SalHer" "SalMyr"
sp.zero.com.matrix.names<-c("AreHum", "BetMin", "BetPum", "CarBel", "CarGla", "CopLap", "CorTri", "LuzSpi", "PoaAlp", "SalHer", "SalMyr")
sp.zero.com.matrix.zeros<-matrix(0, 176, 11)

#add missing species names as colnames  and plot numbers as rownames
colnames(sp.zero.com.matrix.zeros) <-sp.zero.com.matrix.names
rownames(sp.zero.com.matrix.zeros)<-rownames(abd.sp)

#add 0 values for 11 species to large grid community matrix
abd.sp.allsp<-cbind(abd.sp, sp.zero.com.matrix.zeros)

# Calculate Sorensen (Podani family, Sorensen-based indices), with quantitative form of replacement, nestedness and D.
beta.div.comp.vasc <- beta.div.comp(abd.sp.allsp, coef="S", quant=TRUE, save.abc=FALSE)
beta.div.comp.vasc$D[1]
## [1] 0.9097744
beta.div.comp.vasc$repl[1]
## [1] 0.8120301
beta.div.comp.vasc$rich[1]
## [1] 0.09774436
beta.div.comp.vasc$rich[1]+beta.div.comp.vasc$repl[1]
## [1] 0.9097744
vasc.D.m<-as.matrix(beta.div.comp.vasc$D)
vasc.rich.m<-as.matrix(beta.div.comp.vasc$rich)
vasc.repl.m<-as.matrix(beta.div.comp.vasc$repl)

#get small dataframes for each of eight elevations in original transects
vasc.D.m.600<-vasc.D.m[grepl("600*", rownames(vasc.D.m)), ]
vasc.D.m.615<-vasc.D.m[grepl("615*", rownames(vasc.D.m)), ]
vasc.D.m.645<-vasc.D.m[grepl("645*", rownames(vasc.D.m)), ]
vasc.D.m.675<-vasc.D.m[grepl("675*", rownames(vasc.D.m)), ]
vasc.D.m.710<-vasc.D.m[grepl("710*", rownames(vasc.D.m)), ]
vasc.D.m.745<-vasc.D.m[grepl("745*", rownames(vasc.D.m)), ]
vasc.D.m.775<-vasc.D.m[grepl("775*", rownames(vasc.D.m)), ]
vasc.D.m.800<-vasc.D.m[grepl("800*", rownames(vasc.D.m)), ]

#get small dataframes for each of eight additional lines
vasc.D.m.1<-vasc.D.m[grepl("1", rownames(vasc.D.m)), ]
vasc.D.m.1.TAM<-vasc.D.m.1[c(1:11),]
vasc.D.m.2<-vasc.D.m[grepl("2", rownames(vasc.D.m)), ]
vasc.D.m.2.TAM<-vasc.D.m.2[c(1:11),]
vasc.D.m.3<-vasc.D.m[grepl("3", rownames(vasc.D.m)), ]
vasc.D.m.3.TAM<-vasc.D.m.3[c(1:11),]
vasc.D.m.4<-vasc.D.m[grepl("4", rownames(vasc.D.m)), ]
vasc.D.m.4.TAM<-vasc.D.m.4[c(1:11),]
vasc.D.m.5<-vasc.D.m[grepl("5", rownames(vasc.D.m)), ]
vasc.D.m.5.TAM<-vasc.D.m.5[c(1:11),]
vasc.D.m.6<-vasc.D.m[grepl("6", rownames(vasc.D.m)), ]
vasc.D.m.6.TAM<-vasc.D.m.6[c(1:11),]
vasc.D.m.7<-vasc.D.m[grepl("7", rownames(vasc.D.m)), ]
vasc.D.m.7.TAM<-vasc.D.m.7[c(1:11),]
vasc.D.m.8<-vasc.D.m[grepl("8", rownames(vasc.D.m)),]
vasc.D.m.8.TAM<-vasc.D.m.8[c(1:11),]

#Extract pairwise transect information
vasc.D.m.800.775<-(vasc.D.m.800[,grepl("775*", colnames(vasc.D.m.800)) ])
head(vasc.D.m.800.775)
##           E775A1    E775B2    E775C3    E775D4    E775E5    E775F6
## E800A1 0.3818182 0.9913043 0.9344262 0.9327731 0.7864583 0.7000000
## E800B2 0.8169014 0.6907216 0.5855856 0.7142857 0.8725100 0.8682635
## E800C3 0.8723404 0.4405594 0.3885350 0.5629139 0.5084175 0.5962441
## E800D4 0.9727891 0.5882353 0.4482759 0.4545455 0.9140625 0.9418605
## E800E5 0.9041916 0.8360656 0.6323529 0.6769231 0.8840580 0.8958333
## E800F6 0.9148936 0.5944056 0.5031847 0.6556291 0.5622896 0.6244131
##           E775G7    E775H8    E775I9   E775J10   E775K11
## E800A1 0.2831541 0.2539683 0.6387665 0.9447514 0.9380531
## E800B2 0.7945205 0.8612245 0.7021277 0.7083333 0.8709677
## E800C3 0.8333333 0.8762887 0.7857143 0.8510638 0.8417266
## E800D4 0.9205298 0.9520000 0.9393939 0.8113208 0.7755102
## E800E5 0.8362573 0.9407407 0.8487395 0.8082192 0.8135593
## E800F6 0.8750000 0.9175258 0.8571429 0.8510638 0.7266187
vasc.D.m.800.775.mean<-mean(vasc.D.m.800.775[1,1],vasc.D.m.800.775[2,2],vasc.D.m.800.775[3,3],vasc.D.m.800.775[4,4],vasc.D.m.800.775[5,5],vasc.D.m.800.775[6,6],
    vasc.D.m.800.775[7,7],vasc.D.m.800.775[8,8],vasc.D.m.800.775[9,9],vasc.D.m.800.775[10,10],vasc.D.m.800.775[11,11])

vasc.D.m.775.745<-(vasc.D.m.775[,grepl("745*", colnames(vasc.D.m.775)) ])
vasc.D.m.775.745.mean<-mean(vasc.D.m.775.745[1,1],vasc.D.m.775.745[2,2],vasc.D.m.775.745[3,3],vasc.D.m.775.745[4,4],vasc.D.m.775.745[5,5],vasc.D.m.775.745[6,6],
    vasc.D.m.775.745[7,7],vasc.D.m.775.745[8,8],vasc.D.m.775.745[9,9],vasc.D.m.775.745[10,10],vasc.D.m.775.745[11,11])

vasc.D.m.745.710<-(vasc.D.m.745[,grepl("710*", colnames(vasc.D.m.745)) ])
vasc.D.m.745.710.mean<-mean(vasc.D.m.745.710[1,1],vasc.D.m.745.710[2,2],vasc.D.m.745.710[3,3],vasc.D.m.745.710[4,4],vasc.D.m.745.710[5,5],vasc.D.m.745.710[6,6],
    vasc.D.m.745.710[7,7],vasc.D.m.745.710[8,8],vasc.D.m.745.710[9,9],vasc.D.m.745.710[10,10],vasc.D.m.745.710[11,11])

vasc.D.m.710.675<-(vasc.D.m.710[,grepl("675*", colnames(vasc.D.m.710)) ])
vasc.D.m.710.675.mean<-mean(vasc.D.m.710.675[1,1],vasc.D.m.710.675[2,2],vasc.D.m.710.675[3,3],vasc.D.m.710.675[4,4],vasc.D.m.710.675[5,5],vasc.D.m.710.675[6,6],
    vasc.D.m.710.675[7,7],vasc.D.m.710.675[8,8],vasc.D.m.710.675[9,9],vasc.D.m.710.675[10,10],vasc.D.m.710.675[11,11])

vasc.D.m.675.645<-(vasc.D.m.675[,grepl("645*", colnames(vasc.D.m.675)) ])
vasc.D.m.675.645.mean<-mean(vasc.D.m.675.645[1,1],vasc.D.m.675.645[2,2],vasc.D.m.675.645[3,3],vasc.D.m.675.645[4,4],vasc.D.m.675.645[5,5],vasc.D.m.675.645[6,6],
    vasc.D.m.675.645[7,7],vasc.D.m.675.645[8,8],vasc.D.m.675.645[9,9],vasc.D.m.675.645[10,10],vasc.D.m.675.645[11,11])

vasc.D.m.645.615<-(vasc.D.m.645[,grepl("615*", colnames(vasc.D.m.645)) ])
vasc.D.m.645.615.mean<-mean(vasc.D.m.645.615[1,1],vasc.D.m.645.615[2,2],vasc.D.m.645.615[3,3],vasc.D.m.645.615[4,4],vasc.D.m.645.615[5,5],vasc.D.m.645.615[6,6],
    vasc.D.m.645.615[7,7],vasc.D.m.645.615[8,8],vasc.D.m.645.615[9,9],vasc.D.m.645.615[10,10],vasc.D.m.645.615[11,11])

vasc.D.m.615.600<-(vasc.D.m.615[,grepl("600*", colnames(vasc.D.m.615)) ])
vasc.D.m.615.600.mean<-mean(vasc.D.m.615.600[1,1],vasc.D.m.615.600[2,2],vasc.D.m.615.600[3,3],vasc.D.m.615.600[4,4],vasc.D.m.615.600[5,5],vasc.D.m.615.600[6,6],
    vasc.D.m.615.600[7,7],vasc.D.m.615.600[8,8],vasc.D.m.615.600[9,9],vasc.D.m.615.600[10,10],vasc.D.m.615.600[11,11])

vasc.D.m.600.8<-(vasc.D.m.600[,78:88])
vasc.D.m.600.8.mean<-mean(vasc.D.m.600.8[1,1],vasc.D.m.600.8[2,2],vasc.D.m.600.8[3,3],vasc.D.m.600.8[4,4],vasc.D.m.600.8[5,5],vasc.D.m.600.8[6,6],
    vasc.D.m.600.8[7,7],vasc.D.m.600.8[8,8],vasc.D.m.600.8[9,9],vasc.D.m.600.8[10,10],vasc.D.m.600.8[11,11])

vasc.D.m.8.7<-(vasc.D.m.8.TAM[,67:77])
vasc.D.m.8.7.mean<-mean(vasc.D.m.8.7[1,1],vasc.D.m.8.7[2,2],vasc.D.m.8.7[3,3],vasc.D.m.8.7[4,4],vasc.D.m.8.7[5,5],vasc.D.m.8.7[6,6],
    vasc.D.m.8.7[7,7],vasc.D.m.8.7[8,8],vasc.D.m.8.7[9,9],vasc.D.m.8.7[10,10],vasc.D.m.8.7[11,11])

vasc.D.m.7.6<-(vasc.D.m.7.TAM[,56:66])
vasc.D.m.7.6.mean<-mean(vasc.D.m.7.6[1,1],vasc.D.m.7.6[2,2],vasc.D.m.7.6[3,3],vasc.D.m.7.6[4,4],vasc.D.m.7.6[5,5],vasc.D.m.7.6[6,6],
    vasc.D.m.7.6[7,7],vasc.D.m.7.6[8,8],vasc.D.m.7.6[9,9],vasc.D.m.7.6[10,10],vasc.D.m.7.6[11,11])

vasc.D.m.6.5<-(vasc.D.m.6.TAM[,45:55])
vasc.D.m.6.5.mean<-mean(vasc.D.m.6.5[1,1],vasc.D.m.6.5[2,2],vasc.D.m.6.5[3,3],vasc.D.m.6.5[4,4],vasc.D.m.6.5[5,5],vasc.D.m.6.5[6,6],
    vasc.D.m.6.5[7,7],vasc.D.m.6.5[8,8],vasc.D.m.6.5[9,9],vasc.D.m.6.5[10,10],vasc.D.m.6.5[11,11])

vasc.D.m.5.4<-(vasc.D.m.5.TAM[,34:44])
vasc.D.m.5.4.mean<-mean(vasc.D.m.5.4[1,1],vasc.D.m.5.4[2,2],vasc.D.m.5.4[3,3],vasc.D.m.5.4[4,4],vasc.D.m.5.4[5,5],vasc.D.m.5.4[6,6],
    vasc.D.m.5.4[7,7],vasc.D.m.5.4[8,8],vasc.D.m.5.4[9,9],vasc.D.m.5.4[10,10],vasc.D.m.5.4[11,11])

vasc.D.m.4.3<-(vasc.D.m.4.TAM[,23:33])
vasc.D.m.4.3.mean<-mean(vasc.D.m.4.3[1,1],vasc.D.m.4.3[2,2],vasc.D.m.4.3[3,3],vasc.D.m.4.3[4,4],vasc.D.m.4.3[5,5],vasc.D.m.4.3[6,6],
    vasc.D.m.4.3[7,7],vasc.D.m.4.3[8,8],vasc.D.m.4.3[9,9],vasc.D.m.4.3[10,10],vasc.D.m.4.3[11,11])

vasc.D.m.3.2<-(vasc.D.m.3.TAM[,12:22])
vasc.D.m.3.2.mean<-mean(vasc.D.m.3.2[1,1],vasc.D.m.3.2[2,2],vasc.D.m.3.2[3,3],vasc.D.m.3.2[4,4],vasc.D.m.3.2[5,5],vasc.D.m.3.2[6,6],
    vasc.D.m.3.2[7,7],vasc.D.m.3.2[8,8],vasc.D.m.3.2[9,9],vasc.D.m.3.2[10,10],vasc.D.m.3.2[11,11])

vasc.D.m.2.1<-(vasc.D.m.2.TAM[,1:11])
vasc.D.m.2.1.mean<-mean(vasc.D.m.2.1[1,1],vasc.D.m.2.1[2,2],vasc.D.m.2.1[3,3],vasc.D.m.2.1[4,4],vasc.D.m.2.1[5,5],vasc.D.m.2.1[6,6],
    vasc.D.m.2.1[7,7],vasc.D.m.2.1[8,8],vasc.D.m.2.1[9,9],vasc.D.m.2.1[10,10],vasc.D.m.2.1[11,11])

vasc.D.trans<-c(vasc.D.m.800.775.mean, vasc.D.m.775.745.mean,vasc.D.m.745.710.mean,vasc.D.m.710.675.mean,vasc.D.m.675.645.mean,
vasc.D.m.645.615.mean,vasc.D.m.615.600.mean,vasc.D.m.600.8.mean,vasc.D.m.8.7.mean,vasc.D.m.7.6.mean,vasc.D.m.6.5.mean,vasc.D.m.5.4.mean,
vasc.D.m.4.3.mean,vasc.D.m.3.2.mean,vasc.D.m.2.1.mean )

#get small dataframes for each of eight elevations in original transects
vasc.rich.m.600<-vasc.rich.m[grepl("600*", rownames(vasc.rich.m)), ]
vasc.rich.m.615<-vasc.rich.m[grepl("615*", rownames(vasc.rich.m)), ]
vasc.rich.m.645<-vasc.rich.m[grepl("645*", rownames(vasc.rich.m)), ]
vasc.rich.m.675<-vasc.rich.m[grepl("675*", rownames(vasc.rich.m)), ]
vasc.rich.m.710<-vasc.rich.m[grepl("710*", rownames(vasc.rich.m)), ]
vasc.rich.m.745<-vasc.rich.m[grepl("745*", rownames(vasc.rich.m)), ]
vasc.rich.m.775<-vasc.rich.m[grepl("775*", rownames(vasc.rich.m)), ]
vasc.rich.m.800<-vasc.rich.m[grepl("800*", rownames(vasc.rich.m)), ]

#get small dataframes for each of eight additional lines
vasc.rich.m.1<-vasc.rich.m[grepl("1", rownames(vasc.rich.m)), ]
vasc.rich.m.1.TAM<-vasc.rich.m.1[c(1:11),]
vasc.rich.m.2<-vasc.rich.m[grepl("2", rownames(vasc.rich.m)), ]
vasc.rich.m.2.TAM<-vasc.rich.m.2[c(1:11),]
vasc.rich.m.3<-vasc.rich.m[grepl("3", rownames(vasc.rich.m)), ]
vasc.rich.m.3.TAM<-vasc.rich.m.3[c(1:11),]
vasc.rich.m.4<-vasc.rich.m[grepl("4", rownames(vasc.rich.m)), ]
vasc.rich.m.4.TAM<-vasc.rich.m.4[c(1:11),]
vasc.rich.m.5<-vasc.rich.m[grepl("5", rownames(vasc.rich.m)), ]
vasc.rich.m.5.TAM<-vasc.rich.m.5[c(1:11),]
vasc.rich.m.6<-vasc.rich.m[grepl("6", rownames(vasc.rich.m)), ]
vasc.rich.m.6.TAM<-vasc.rich.m.6[c(1:11),]
vasc.rich.m.7<-vasc.rich.m[grepl("7", rownames(vasc.rich.m)), ]
vasc.rich.m.7.TAM<-vasc.rich.m.7[c(1:11),]
vasc.rich.m.8<-vasc.rich.m[grepl("8", rownames(vasc.rich.m)),]
vasc.rich.m.8.TAM<-vasc.rich.m.8[c(1:11),]

#Extract pairwise transect information
vasc.rich.m.800.775<-(vasc.rich.m.800[,grepl("775*", colnames(vasc.rich.m.800)) ])
head(vasc.rich.m.800.775)
##            E775A1     E775B2     E775C3    E775D4     E775E5    E775F6
## E800A1 0.25818182 0.50434783 0.41803279 0.4537815 0.09895833 0.1533333
## E800B2 0.43661972 0.17525773 0.27927928 0.2380952 0.68127490 0.5209581
## E800C3 0.08510638 0.20279720 0.09554140 0.1390728 0.42087542 0.1924883
## E800D4 0.38775510 0.11764706 0.22413793 0.1818182 0.64843750 0.4767442
## E800E5 0.22155689 0.06557377 0.04411765 0.0000000 0.52898551 0.3229167
## E800F6 0.08510638 0.20279720 0.09554140 0.1390728 0.42087542 0.1924883
##           E775G7     E775H8     E775I9   E775J10    E775K11
## E800A1 0.2401434 0.08465608 0.52422907 0.9116022 0.53097345
## E800B2 0.4520548 0.67346939 0.14893617 0.6666667 0.13978495
## E800C3 0.1041667 0.40893471 0.22857143 0.8297872 0.23741007
## E800D4 0.4039735 0.64000000 0.09090909 0.6981132 0.08163265
## E800E5 0.2397661 0.51851852 0.09243697 0.7808219 0.10169492
## E800F6 0.1041667 0.40893471 0.22857143 0.8297872 0.23741007
vasc.rich.m.800.775.mean<-mean(vasc.rich.m.800.775[1,1],vasc.rich.m.800.775[2,2],vasc.rich.m.800.775[3,3],vasc.rich.m.800.775[4,4],vasc.rich.m.800.775[5,5],vasc.rich.m.800.775[6,6],
    vasc.rich.m.800.775[7,7],vasc.rich.m.800.775[8,8],vasc.rich.m.800.775[9,9],vasc.rich.m.800.775[10,10],vasc.rich.m.800.775[11,11])

vasc.rich.m.775.745<-(vasc.rich.m.775[,grepl("745*", colnames(vasc.rich.m.775)) ])
vasc.rich.m.775.745.mean<-mean(vasc.rich.m.775.745[1,1],vasc.rich.m.775.745[2,2],vasc.rich.m.775.745[3,3],vasc.rich.m.775.745[4,4],vasc.rich.m.775.745[5,5],vasc.rich.m.775.745[6,6],
    vasc.rich.m.775.745[7,7],vasc.rich.m.775.745[8,8],vasc.rich.m.775.745[9,9],vasc.rich.m.775.745[10,10],vasc.rich.m.775.745[11,11])

vasc.rich.m.745.710<-(vasc.rich.m.745[,grepl("710*", colnames(vasc.rich.m.745)) ])
vasc.rich.m.745.710.mean<-mean(vasc.rich.m.745.710[1,1],vasc.rich.m.745.710[2,2],vasc.rich.m.745.710[3,3],vasc.rich.m.745.710[4,4],vasc.rich.m.745.710[5,5],vasc.rich.m.745.710[6,6],
    vasc.rich.m.745.710[7,7],vasc.rich.m.745.710[8,8],vasc.rich.m.745.710[9,9],vasc.rich.m.745.710[10,10],vasc.rich.m.745.710[11,11])

vasc.rich.m.710.675<-(vasc.rich.m.710[,grepl("675*", colnames(vasc.rich.m.710)) ])
vasc.rich.m.710.675.mean<-mean(vasc.rich.m.710.675[1,1],vasc.rich.m.710.675[2,2],vasc.rich.m.710.675[3,3],vasc.rich.m.710.675[4,4],vasc.rich.m.710.675[5,5],vasc.rich.m.710.675[6,6],
    vasc.rich.m.710.675[7,7],vasc.rich.m.710.675[8,8],vasc.rich.m.710.675[9,9],vasc.rich.m.710.675[10,10],vasc.rich.m.710.675[11,11])

vasc.rich.m.675.645<-(vasc.rich.m.675[,grepl("645*", colnames(vasc.rich.m.675)) ])
vasc.rich.m.675.645.mean<-mean(vasc.rich.m.675.645[1,1],vasc.rich.m.675.645[2,2],vasc.rich.m.675.645[3,3],vasc.rich.m.675.645[4,4],vasc.rich.m.675.645[5,5],vasc.rich.m.675.645[6,6],
    vasc.rich.m.675.645[7,7],vasc.rich.m.675.645[8,8],vasc.rich.m.675.645[9,9],vasc.rich.m.675.645[10,10],vasc.rich.m.675.645[11,11])

vasc.rich.m.645.615<-(vasc.rich.m.645[,grepl("615*", colnames(vasc.rich.m.645)) ])
vasc.rich.m.645.615.mean<-mean(vasc.rich.m.645.615[1,1],vasc.rich.m.645.615[2,2],vasc.rich.m.645.615[3,3],vasc.rich.m.645.615[4,4],vasc.rich.m.645.615[5,5],vasc.rich.m.645.615[6,6],
    vasc.rich.m.645.615[7,7],vasc.rich.m.645.615[8,8],vasc.rich.m.645.615[9,9],vasc.rich.m.645.615[10,10],vasc.rich.m.645.615[11,11])

vasc.rich.m.615.600<-(vasc.rich.m.615[,grepl("600*", colnames(vasc.rich.m.615)) ])
vasc.rich.m.615.600.mean<-mean(vasc.rich.m.615.600[1,1],vasc.rich.m.615.600[2,2],vasc.rich.m.615.600[3,3],vasc.rich.m.615.600[4,4],vasc.rich.m.615.600[5,5],vasc.rich.m.615.600[6,6],
    vasc.rich.m.615.600[7,7],vasc.rich.m.615.600[8,8],vasc.rich.m.615.600[9,9],vasc.rich.m.615.600[10,10],vasc.rich.m.615.600[11,11])

vasc.rich.m.600.8<-(vasc.rich.m.600[,78:88])
vasc.rich.m.600.8.mean<-mean(vasc.rich.m.600.8[1,1],vasc.rich.m.600.8[2,2],vasc.rich.m.600.8[3,3],vasc.rich.m.600.8[4,4],vasc.rich.m.600.8[5,5],vasc.rich.m.600.8[6,6],
    vasc.rich.m.600.8[7,7],vasc.rich.m.600.8[8,8],vasc.rich.m.600.8[9,9],vasc.rich.m.600.8[10,10],vasc.rich.m.600.8[11,11])

vasc.rich.m.8.7<-(vasc.rich.m.8.TAM[,67:77])
vasc.rich.m.8.7.mean<-mean(vasc.rich.m.8.7[1,1],vasc.rich.m.8.7[2,2],vasc.rich.m.8.7[3,3],vasc.rich.m.8.7[4,4],vasc.rich.m.8.7[5,5],vasc.rich.m.8.7[6,6],
    vasc.rich.m.8.7[7,7],vasc.rich.m.8.7[8,8],vasc.rich.m.8.7[9,9],vasc.rich.m.8.7[10,10],vasc.rich.m.8.7[11,11])

vasc.rich.m.7.6<-(vasc.rich.m.7.TAM[,56:66])
vasc.rich.m.7.6.mean<-mean(vasc.rich.m.7.6[1,1],vasc.rich.m.7.6[2,2],vasc.rich.m.7.6[3,3],vasc.rich.m.7.6[4,4],vasc.rich.m.7.6[5,5],vasc.rich.m.7.6[6,6],
    vasc.rich.m.7.6[7,7],vasc.rich.m.7.6[8,8],vasc.rich.m.7.6[9,9],vasc.rich.m.7.6[10,10],vasc.rich.m.7.6[11,11])

vasc.rich.m.6.5<-(vasc.rich.m.6.TAM[,45:55])
vasc.rich.m.6.5.mean<-mean(vasc.rich.m.6.5[1,1],vasc.rich.m.6.5[2,2],vasc.rich.m.6.5[3,3],vasc.rich.m.6.5[4,4],vasc.rich.m.6.5[5,5],vasc.rich.m.6.5[6,6],
    vasc.rich.m.6.5[7,7],vasc.rich.m.6.5[8,8],vasc.rich.m.6.5[9,9],vasc.rich.m.6.5[10,10],vasc.rich.m.6.5[11,11])

vasc.rich.m.5.4<-(vasc.rich.m.5.TAM[,34:44])
vasc.rich.m.5.4.mean<-mean(vasc.rich.m.5.4[1,1],vasc.rich.m.5.4[2,2],vasc.rich.m.5.4[3,3],vasc.rich.m.5.4[4,4],vasc.rich.m.5.4[5,5],vasc.rich.m.5.4[6,6],
    vasc.rich.m.5.4[7,7],vasc.rich.m.5.4[8,8],vasc.rich.m.5.4[9,9],vasc.rich.m.5.4[10,10],vasc.rich.m.5.4[11,11])

vasc.rich.m.4.3<-(vasc.rich.m.4.TAM[,23:33])
vasc.rich.m.4.3.mean<-mean(vasc.rich.m.4.3[1,1],vasc.rich.m.4.3[2,2],vasc.rich.m.4.3[3,3],vasc.rich.m.4.3[4,4],vasc.rich.m.4.3[5,5],vasc.rich.m.4.3[6,6],
    vasc.rich.m.4.3[7,7],vasc.rich.m.4.3[8,8],vasc.rich.m.4.3[9,9],vasc.rich.m.4.3[10,10],vasc.rich.m.4.3[11,11])

vasc.rich.m.3.2<-(vasc.rich.m.3.TAM[,12:22])
vasc.rich.m.3.2.mean<-mean(vasc.rich.m.3.2[1,1],vasc.rich.m.3.2[2,2],vasc.rich.m.3.2[3,3],vasc.rich.m.3.2[4,4],vasc.rich.m.3.2[5,5],vasc.rich.m.3.2[6,6],
    vasc.rich.m.3.2[7,7],vasc.rich.m.3.2[8,8],vasc.rich.m.3.2[9,9],vasc.rich.m.3.2[10,10],vasc.rich.m.3.2[11,11])

vasc.rich.m.2.1<-(vasc.rich.m.2.TAM[,1:11])
vasc.rich.m.2.1.mean<-mean(vasc.rich.m.2.1[1,1],vasc.rich.m.2.1[2,2],vasc.rich.m.2.1[3,3],vasc.rich.m.2.1[4,4],vasc.rich.m.2.1[5,5],vasc.rich.m.2.1[6,6],
    vasc.rich.m.2.1[7,7],vasc.rich.m.2.1[8,8],vasc.rich.m.2.1[9,9],vasc.rich.m.2.1[10,10],vasc.rich.m.2.1[11,11])

vasc.rich.trans<-c(vasc.rich.m.800.775.mean, vasc.rich.m.775.745.mean,vasc.rich.m.745.710.mean,vasc.rich.m.710.675.mean,vasc.rich.m.675.645.mean,
vasc.rich.m.645.615.mean,vasc.rich.m.615.600.mean,vasc.rich.m.600.8.mean,vasc.rich.m.8.7.mean,vasc.rich.m.7.6.mean,vasc.rich.m.6.5.mean,vasc.rich.m.5.4.mean,
vasc.rich.m.4.3.mean,vasc.rich.m.3.2.mean,vasc.rich.m.2.1.mean )


#get small dataframes for each of eight elevations in original transects
vasc.repl.m.600<-vasc.repl.m[grepl("600*", rownames(vasc.repl.m)), ]
vasc.repl.m.615<-vasc.repl.m[grepl("615*", rownames(vasc.repl.m)), ]
vasc.repl.m.645<-vasc.repl.m[grepl("645*", rownames(vasc.repl.m)), ]
vasc.repl.m.675<-vasc.repl.m[grepl("675*", rownames(vasc.repl.m)), ]
vasc.repl.m.710<-vasc.repl.m[grepl("710*", rownames(vasc.repl.m)), ]
vasc.repl.m.745<-vasc.repl.m[grepl("745*", rownames(vasc.repl.m)), ]
vasc.repl.m.775<-vasc.repl.m[grepl("775*", rownames(vasc.repl.m)), ]
vasc.repl.m.800<-vasc.repl.m[grepl("800*", rownames(vasc.repl.m)), ]

#get small dataframes for each of eight additional lines
vasc.repl.m.1<-vasc.repl.m[grepl("1", rownames(vasc.repl.m)), ]
vasc.repl.m.1.TAM<-vasc.repl.m.1[c(1:11),]
vasc.repl.m.2<-vasc.repl.m[grepl("2", rownames(vasc.repl.m)), ]
vasc.repl.m.2.TAM<-vasc.repl.m.2[c(1:11),]
vasc.repl.m.3<-vasc.repl.m[grepl("3", rownames(vasc.repl.m)), ]
vasc.repl.m.3.TAM<-vasc.repl.m.3[c(1:11),]
vasc.repl.m.4<-vasc.repl.m[grepl("4", rownames(vasc.repl.m)), ]
vasc.repl.m.4.TAM<-vasc.repl.m.4[c(1:11),]
vasc.repl.m.5<-vasc.repl.m[grepl("5", rownames(vasc.repl.m)), ]
vasc.repl.m.5.TAM<-vasc.repl.m.5[c(1:11),]
vasc.repl.m.6<-vasc.repl.m[grepl("6", rownames(vasc.repl.m)), ]
vasc.repl.m.6.TAM<-vasc.repl.m.6[c(1:11),]
vasc.repl.m.7<-vasc.repl.m[grepl("7", rownames(vasc.repl.m)), ]
vasc.repl.m.7.TAM<-vasc.repl.m.7[c(1:11),]
vasc.repl.m.8<-vasc.repl.m[grepl("8", rownames(vasc.repl.m)),]
vasc.repl.m.8.TAM<-vasc.repl.m.8[c(1:11),]

#Extract pairwise transect information
vasc.repl.m.800.775<-(vasc.repl.m.800[,grepl("775*", colnames(vasc.repl.m.800)) ])
head(vasc.repl.m.800.775)
##           E775A1    E775B2    E775C3    E775D4     E775E5    E775F6
## E800A1 0.1236364 0.4869565 0.5163934 0.4789916 0.68750000 0.5466667
## E800B2 0.3802817 0.5154639 0.3063063 0.4761905 0.19123506 0.3473054
## E800C3 0.7872340 0.2377622 0.2929936 0.4238411 0.08754209 0.4037559
## E800D4 0.5850340 0.4705882 0.2241379 0.2727273 0.26562500 0.4651163
## E800E5 0.6826347 0.7704918 0.5882353 0.6769231 0.35507246 0.5729167
## E800F6 0.8297872 0.3916084 0.4076433 0.5165563 0.14141414 0.4319249
##            E775G7    E775H8    E775I9    E775J10   E775K11
## E800A1 0.04301075 0.1693122 0.1145374 0.03314917 0.4070796
## E800B2 0.34246575 0.1877551 0.5531915 0.04166667 0.7311828
## E800C3 0.72916667 0.4673540 0.5571429 0.02127660 0.6043165
## E800D4 0.51655629 0.3120000 0.8484848 0.11320755 0.6938776
## E800E5 0.59649123 0.4222222 0.7563025 0.02739726 0.7118644
## E800F6 0.77083333 0.5085911 0.6285714 0.02127660 0.4892086
vasc.repl.m.800.775.mean<-mean(vasc.repl.m.800.775[1,1],vasc.repl.m.800.775[2,2],vasc.repl.m.800.775[3,3],vasc.repl.m.800.775[4,4],vasc.repl.m.800.775[5,5],vasc.repl.m.800.775[6,6],
    vasc.repl.m.800.775[7,7],vasc.repl.m.800.775[8,8],vasc.repl.m.800.775[9,9],vasc.repl.m.800.775[10,10],vasc.repl.m.800.775[11,11])

vasc.repl.m.775.745<-(vasc.repl.m.775[,grepl("745*", colnames(vasc.repl.m.775)) ])
vasc.repl.m.775.745.mean<-mean(vasc.repl.m.775.745[1,1],vasc.repl.m.775.745[2,2],vasc.repl.m.775.745[3,3],vasc.repl.m.775.745[4,4],vasc.repl.m.775.745[5,5],vasc.repl.m.775.745[6,6],
    vasc.repl.m.775.745[7,7],vasc.repl.m.775.745[8,8],vasc.repl.m.775.745[9,9],vasc.repl.m.775.745[10,10],vasc.repl.m.775.745[11,11])

vasc.repl.m.745.710<-(vasc.repl.m.745[,grepl("710*", colnames(vasc.repl.m.745)) ])
vasc.repl.m.745.710.mean<-mean(vasc.repl.m.745.710[1,1],vasc.repl.m.745.710[2,2],vasc.repl.m.745.710[3,3],vasc.repl.m.745.710[4,4],vasc.repl.m.745.710[5,5],vasc.repl.m.745.710[6,6],
    vasc.repl.m.745.710[7,7],vasc.repl.m.745.710[8,8],vasc.repl.m.745.710[9,9],vasc.repl.m.745.710[10,10],vasc.repl.m.745.710[11,11])

vasc.repl.m.710.675<-(vasc.repl.m.710[,grepl("675*", colnames(vasc.repl.m.710)) ])
vasc.repl.m.710.675.mean<-mean(vasc.repl.m.710.675[1,1],vasc.repl.m.710.675[2,2],vasc.repl.m.710.675[3,3],vasc.repl.m.710.675[4,4],vasc.repl.m.710.675[5,5],vasc.repl.m.710.675[6,6],
    vasc.repl.m.710.675[7,7],vasc.repl.m.710.675[8,8],vasc.repl.m.710.675[9,9],vasc.repl.m.710.675[10,10],vasc.repl.m.710.675[11,11])

vasc.repl.m.675.645<-(vasc.repl.m.675[,grepl("645*", colnames(vasc.repl.m.675)) ])
vasc.repl.m.675.645.mean<-mean(vasc.repl.m.675.645[1,1],vasc.repl.m.675.645[2,2],vasc.repl.m.675.645[3,3],vasc.repl.m.675.645[4,4],vasc.repl.m.675.645[5,5],vasc.repl.m.675.645[6,6],
    vasc.repl.m.675.645[7,7],vasc.repl.m.675.645[8,8],vasc.repl.m.675.645[9,9],vasc.repl.m.675.645[10,10],vasc.repl.m.675.645[11,11])

vasc.repl.m.645.615<-(vasc.repl.m.645[,grepl("615*", colnames(vasc.repl.m.645)) ])
vasc.repl.m.645.615.mean<-mean(vasc.repl.m.645.615[1,1],vasc.repl.m.645.615[2,2],vasc.repl.m.645.615[3,3],vasc.repl.m.645.615[4,4],vasc.repl.m.645.615[5,5],vasc.repl.m.645.615[6,6],
    vasc.repl.m.645.615[7,7],vasc.repl.m.645.615[8,8],vasc.repl.m.645.615[9,9],vasc.repl.m.645.615[10,10],vasc.repl.m.645.615[11,11])

vasc.repl.m.615.600<-(vasc.repl.m.615[,grepl("600*", colnames(vasc.repl.m.615)) ])
vasc.repl.m.615.600.mean<-mean(vasc.repl.m.615.600[1,1],vasc.repl.m.615.600[2,2],vasc.repl.m.615.600[3,3],vasc.repl.m.615.600[4,4],vasc.repl.m.615.600[5,5],vasc.repl.m.615.600[6,6],
    vasc.repl.m.615.600[7,7],vasc.repl.m.615.600[8,8],vasc.repl.m.615.600[9,9],vasc.repl.m.615.600[10,10],vasc.repl.m.615.600[11,11])

vasc.repl.m.600.8<-(vasc.repl.m.600[,78:88])
vasc.repl.m.600.8.mean<-mean(vasc.repl.m.600.8[1,1],vasc.repl.m.600.8[2,2],vasc.repl.m.600.8[3,3],vasc.repl.m.600.8[4,4],vasc.repl.m.600.8[5,5],vasc.repl.m.600.8[6,6],
    vasc.repl.m.600.8[7,7],vasc.repl.m.600.8[8,8],vasc.repl.m.600.8[9,9],vasc.repl.m.600.8[10,10],vasc.repl.m.600.8[11,11])

vasc.repl.m.8.7<-(vasc.repl.m.8.TAM[,67:77])
vasc.repl.m.8.7.mean<-mean(vasc.repl.m.8.7[1,1],vasc.repl.m.8.7[2,2],vasc.repl.m.8.7[3,3],vasc.repl.m.8.7[4,4],vasc.repl.m.8.7[5,5],vasc.repl.m.8.7[6,6],
    vasc.repl.m.8.7[7,7],vasc.repl.m.8.7[8,8],vasc.repl.m.8.7[9,9],vasc.repl.m.8.7[10,10],vasc.repl.m.8.7[11,11])

vasc.repl.m.7.6<-(vasc.repl.m.7.TAM[,56:66])
vasc.repl.m.7.6.mean<-mean(vasc.repl.m.7.6[1,1],vasc.repl.m.7.6[2,2],vasc.repl.m.7.6[3,3],vasc.repl.m.7.6[4,4],vasc.repl.m.7.6[5,5],vasc.repl.m.7.6[6,6],
    vasc.repl.m.7.6[7,7],vasc.repl.m.7.6[8,8],vasc.repl.m.7.6[9,9],vasc.repl.m.7.6[10,10],vasc.repl.m.7.6[11,11])

vasc.repl.m.6.5<-(vasc.repl.m.6.TAM[,45:55])
vasc.repl.m.6.5.mean<-mean(vasc.repl.m.6.5[1,1],vasc.repl.m.6.5[2,2],vasc.repl.m.6.5[3,3],vasc.repl.m.6.5[4,4],vasc.repl.m.6.5[5,5],vasc.repl.m.6.5[6,6],
    vasc.repl.m.6.5[7,7],vasc.repl.m.6.5[8,8],vasc.repl.m.6.5[9,9],vasc.repl.m.6.5[10,10],vasc.repl.m.6.5[11,11])

vasc.repl.m.5.4<-(vasc.repl.m.5.TAM[,34:44])
vasc.repl.m.5.4.mean<-mean(vasc.repl.m.5.4[1,1],vasc.repl.m.5.4[2,2],vasc.repl.m.5.4[3,3],vasc.repl.m.5.4[4,4],vasc.repl.m.5.4[5,5],vasc.repl.m.5.4[6,6],
    vasc.repl.m.5.4[7,7],vasc.repl.m.5.4[8,8],vasc.repl.m.5.4[9,9],vasc.repl.m.5.4[10,10],vasc.repl.m.5.4[11,11])

vasc.repl.m.4.3<-(vasc.repl.m.4.TAM[,23:33])
vasc.repl.m.4.3.mean<-mean(vasc.repl.m.4.3[1,1],vasc.repl.m.4.3[2,2],vasc.repl.m.4.3[3,3],vasc.repl.m.4.3[4,4],vasc.repl.m.4.3[5,5],vasc.repl.m.4.3[6,6],
    vasc.repl.m.4.3[7,7],vasc.repl.m.4.3[8,8],vasc.repl.m.4.3[9,9],vasc.repl.m.4.3[10,10],vasc.repl.m.4.3[11,11])

vasc.repl.m.3.2<-(vasc.repl.m.3.TAM[,12:22])
vasc.repl.m.3.2.mean<-mean(vasc.repl.m.3.2[1,1],vasc.repl.m.3.2[2,2],vasc.repl.m.3.2[3,3],vasc.repl.m.3.2[4,4],vasc.repl.m.3.2[5,5],vasc.repl.m.3.2[6,6],
    vasc.repl.m.3.2[7,7],vasc.repl.m.3.2[8,8],vasc.repl.m.3.2[9,9],vasc.repl.m.3.2[10,10],vasc.repl.m.3.2[11,11])

vasc.repl.m.2.1<-(vasc.repl.m.2.TAM[,1:11])
vasc.repl.m.2.1.mean<-mean(vasc.repl.m.2.1[1,1],vasc.repl.m.2.1[2,2],vasc.repl.m.2.1[3,3],vasc.repl.m.2.1[4,4],vasc.repl.m.2.1[5,5],vasc.repl.m.2.1[6,6],
    vasc.repl.m.2.1[7,7],vasc.repl.m.2.1[8,8],vasc.repl.m.2.1[9,9],vasc.repl.m.2.1[10,10],vasc.repl.m.2.1[11,11])

vasc.repl.trans<-c(vasc.repl.m.800.775.mean, vasc.repl.m.775.745.mean,vasc.repl.m.745.710.mean,vasc.repl.m.710.675.mean,vasc.repl.m.675.645.mean,
vasc.repl.m.645.615.mean,vasc.repl.m.615.600.mean,vasc.repl.m.600.8.mean,vasc.repl.m.8.7.mean,vasc.repl.m.7.6.mean,vasc.repl.m.6.5.mean,vasc.repl.m.5.4.mean,
vasc.repl.m.4.3.mean,vasc.repl.m.3.2.mean,vasc.repl.m.2.1.mean )

##########Angiosperm data
#Analyze angiosperm only data
#subset transdata to remove angiosperms
angio.sp.abd<-abd.sp.allsp[,-match(c("LycAno", "HupApr", "DipCom", "SelSel", "CysMon", "DryExp", "EquSyl", "EquArv", "EquSci", "EquVar", "JunCom", "PicMar", "PicGla", "AbiBal", "LarLar"), names(abd.sp.allsp))]

# Calculate Sorensen (Podani family, Sorensen-based indices), with quantitative form of replacement, nestedness and D.
beta.div.comp.angio <- beta.div.comp(angio.sp.abd, coef="S", quant=TRUE, save.abc=FALSE)
beta.div.comp.angio$D[1]
## [1] 0.7983193
beta.div.comp.angio$repl[1]
## [1] 0.5042017
beta.div.comp.angio$rich[1]
## [1] 0.2941176
beta.div.comp.angio$rich[1]+beta.div.comp.angio$repl[1]
## [1] 0.7983193
angio.D.m<-as.matrix(beta.div.comp.angio$D)
angio.rich.m<-as.matrix(beta.div.comp.angio$rich)
angio.repl.m<-as.matrix(beta.div.comp.angio$repl)

#get small dataframes for each of eight elevations in original transects
angio.D.m.600<-angio.D.m[grepl("600*", rownames(angio.D.m)), ]
angio.D.m.615<-angio.D.m[grepl("615*", rownames(angio.D.m)), ]
angio.D.m.645<-angio.D.m[grepl("645*", rownames(angio.D.m)), ]
angio.D.m.675<-angio.D.m[grepl("675*", rownames(angio.D.m)), ]
angio.D.m.710<-angio.D.m[grepl("710*", rownames(angio.D.m)), ]
angio.D.m.745<-angio.D.m[grepl("745*", rownames(angio.D.m)), ]
angio.D.m.775<-angio.D.m[grepl("775*", rownames(angio.D.m)), ]
angio.D.m.800<-angio.D.m[grepl("800*", rownames(angio.D.m)), ]

#get small dataframes for each of eight additional lines
angio.D.m.1<-angio.D.m[grepl("1", rownames(angio.D.m)), ]
angio.D.m.1.TAM<-angio.D.m.1[c(1:11),]
angio.D.m.2<-angio.D.m[grepl("2", rownames(angio.D.m)), ]
angio.D.m.2.TAM<-angio.D.m.2[c(1:11),]
angio.D.m.3<-angio.D.m[grepl("3", rownames(angio.D.m)), ]
angio.D.m.3.TAM<-angio.D.m.3[c(1:11),]
angio.D.m.4<-angio.D.m[grepl("4", rownames(angio.D.m)), ]
angio.D.m.4.TAM<-angio.D.m.4[c(1:11),]
angio.D.m.5<-angio.D.m[grepl("5", rownames(angio.D.m)), ]
angio.D.m.5.TAM<-angio.D.m.5[c(1:11),]
angio.D.m.6<-angio.D.m[grepl("6", rownames(angio.D.m)), ]
angio.D.m.6.TAM<-angio.D.m.6[c(1:11),]
angio.D.m.7<-angio.D.m[grepl("7", rownames(angio.D.m)), ]
angio.D.m.7.TAM<-angio.D.m.7[c(1:11),]
angio.D.m.8<-angio.D.m[grepl("8", rownames(angio.D.m)),]
angio.D.m.8.TAM<-angio.D.m.8[c(1:11),]

#Extract pairwise transect information
angio.D.m.800.775<-(angio.D.m.800[,grepl("775*", colnames(angio.D.m.800)) ])
head(angio.D.m.800.775)
##           E775A1    E775B2    E775C3    E775D4    E775E5    E775F6
## E800A1 0.3818182 0.9913043 0.9344262 0.9327731 0.7859008 0.7000000
## E800B2 0.8169014 0.6907216 0.5855856 0.7142857 0.8720000 0.8682635
## E800C3 0.8723404 0.4405594 0.3885350 0.5629139 0.5067568 0.5962441
## E800D4 0.9727891 0.5882353 0.4482759 0.4545455 0.9137255 0.9418605
## E800E5 0.9041916 0.8360656 0.6323529 0.6769231 0.8836364 0.8958333
## E800F6 0.9148936 0.5944056 0.5031847 0.6556291 0.5608108 0.6244131
##           E775G7    E775H8    E775I9   E775J10   E775K11
## E800A1 0.2831541 0.2539683 0.6387665 0.9447514 0.9345794
## E800B2 0.7945205 0.8612245 0.7021277 0.7083333 0.8518519
## E800C3 0.8333333 0.8762887 0.7857143 0.8510638 0.8267717
## E800D4 0.9205298 0.9520000 0.9393939 0.8113208 0.7441860
## E800E5 0.8362573 0.9407407 0.8487395 0.8082192 0.7924528
## E800F6 0.8750000 0.9175258 0.8571429 0.8510638 0.7007874
angio.D.m.800.775.mean<-mean(angio.D.m.800.775[1,1],angio.D.m.800.775[2,2],angio.D.m.800.775[3,3],angio.D.m.800.775[4,4],angio.D.m.800.775[5,5],angio.D.m.800.775[6,6],
    angio.D.m.800.775[7,7],angio.D.m.800.775[8,8],angio.D.m.800.775[9,9],angio.D.m.800.775[10,10],angio.D.m.800.775[11,11])

angio.D.m.775.745<-(angio.D.m.775[,grepl("745*", colnames(angio.D.m.775)) ])
angio.D.m.775.745.mean<-mean(angio.D.m.775.745[1,1],angio.D.m.775.745[2,2],angio.D.m.775.745[3,3],angio.D.m.775.745[4,4],angio.D.m.775.745[5,5],angio.D.m.775.745[6,6],
    angio.D.m.775.745[7,7],angio.D.m.775.745[8,8],angio.D.m.775.745[9,9],angio.D.m.775.745[10,10],angio.D.m.775.745[11,11])

angio.D.m.745.710<-(angio.D.m.745[,grepl("710*", colnames(angio.D.m.745)) ])
angio.D.m.745.710.mean<-mean(angio.D.m.745.710[1,1],angio.D.m.745.710[2,2],angio.D.m.745.710[3,3],angio.D.m.745.710[4,4],angio.D.m.745.710[5,5],angio.D.m.745.710[6,6],
    angio.D.m.745.710[7,7],angio.D.m.745.710[8,8],angio.D.m.745.710[9,9],angio.D.m.745.710[10,10],angio.D.m.745.710[11,11])

angio.D.m.710.675<-(angio.D.m.710[,grepl("675*", colnames(angio.D.m.710)) ])
angio.D.m.710.675.mean<-mean(angio.D.m.710.675[1,1],angio.D.m.710.675[2,2],angio.D.m.710.675[3,3],angio.D.m.710.675[4,4],angio.D.m.710.675[5,5],angio.D.m.710.675[6,6],
    angio.D.m.710.675[7,7],angio.D.m.710.675[8,8],angio.D.m.710.675[9,9],angio.D.m.710.675[10,10],angio.D.m.710.675[11,11])

angio.D.m.675.645<-(angio.D.m.675[,grepl("645*", colnames(angio.D.m.675)) ])
angio.D.m.675.645.mean<-mean(angio.D.m.675.645[1,1],angio.D.m.675.645[2,2],angio.D.m.675.645[3,3],angio.D.m.675.645[4,4],angio.D.m.675.645[5,5],angio.D.m.675.645[6,6],
    angio.D.m.675.645[7,7],angio.D.m.675.645[8,8],angio.D.m.675.645[9,9],angio.D.m.675.645[10,10],angio.D.m.675.645[11,11])

angio.D.m.645.615<-(angio.D.m.645[,grepl("615*", colnames(angio.D.m.645)) ])
angio.D.m.645.615.mean<-mean(angio.D.m.645.615[1,1],angio.D.m.645.615[2,2],angio.D.m.645.615[3,3],angio.D.m.645.615[4,4],angio.D.m.645.615[5,5],angio.D.m.645.615[6,6],
    angio.D.m.645.615[7,7],angio.D.m.645.615[8,8],angio.D.m.645.615[9,9],angio.D.m.645.615[10,10],angio.D.m.645.615[11,11])

angio.D.m.615.600<-(angio.D.m.615[,grepl("600*", colnames(angio.D.m.615)) ])
angio.D.m.615.600.mean<-mean(angio.D.m.615.600[1,1],angio.D.m.615.600[2,2],angio.D.m.615.600[3,3],angio.D.m.615.600[4,4],angio.D.m.615.600[5,5],angio.D.m.615.600[6,6],
    angio.D.m.615.600[7,7],angio.D.m.615.600[8,8],angio.D.m.615.600[9,9],angio.D.m.615.600[10,10],angio.D.m.615.600[11,11])

angio.D.m.600.8<-(angio.D.m.600[,78:88])
angio.D.m.600.8.mean<-mean(angio.D.m.600.8[1,1],angio.D.m.600.8[2,2],angio.D.m.600.8[3,3],angio.D.m.600.8[4,4],angio.D.m.600.8[5,5],angio.D.m.600.8[6,6],
    angio.D.m.600.8[7,7],angio.D.m.600.8[8,8],angio.D.m.600.8[9,9],angio.D.m.600.8[10,10],angio.D.m.600.8[11,11])

angio.D.m.8.7<-(angio.D.m.8.TAM[,67:77])
angio.D.m.8.7.mean<-mean(angio.D.m.8.7[1,1],angio.D.m.8.7[2,2],angio.D.m.8.7[3,3],angio.D.m.8.7[4,4],angio.D.m.8.7[5,5],angio.D.m.8.7[6,6],
    angio.D.m.8.7[7,7],angio.D.m.8.7[8,8],angio.D.m.8.7[9,9],angio.D.m.8.7[10,10],angio.D.m.8.7[11,11])

angio.D.m.7.6<-(angio.D.m.7.TAM[,56:66])
angio.D.m.7.6.mean<-mean(angio.D.m.7.6[1,1],angio.D.m.7.6[2,2],angio.D.m.7.6[3,3],angio.D.m.7.6[4,4],angio.D.m.7.6[5,5],angio.D.m.7.6[6,6],
    angio.D.m.7.6[7,7],angio.D.m.7.6[8,8],angio.D.m.7.6[9,9],angio.D.m.7.6[10,10],angio.D.m.7.6[11,11])

angio.D.m.6.5<-(angio.D.m.6.TAM[,45:55])
angio.D.m.6.5.mean<-mean(angio.D.m.6.5[1,1],angio.D.m.6.5[2,2],angio.D.m.6.5[3,3],angio.D.m.6.5[4,4],angio.D.m.6.5[5,5],angio.D.m.6.5[6,6],
    angio.D.m.6.5[7,7],angio.D.m.6.5[8,8],angio.D.m.6.5[9,9],angio.D.m.6.5[10,10],angio.D.m.6.5[11,11])

angio.D.m.5.4<-(angio.D.m.5.TAM[,34:44])
angio.D.m.5.4.mean<-mean(angio.D.m.5.4[1,1],angio.D.m.5.4[2,2],angio.D.m.5.4[3,3],angio.D.m.5.4[4,4],angio.D.m.5.4[5,5],angio.D.m.5.4[6,6],
    angio.D.m.5.4[7,7],angio.D.m.5.4[8,8],angio.D.m.5.4[9,9],angio.D.m.5.4[10,10],angio.D.m.5.4[11,11])

angio.D.m.4.3<-(angio.D.m.4.TAM[,23:33])
angio.D.m.4.3.mean<-mean(angio.D.m.4.3[1,1],angio.D.m.4.3[2,2],angio.D.m.4.3[3,3],angio.D.m.4.3[4,4],angio.D.m.4.3[5,5],angio.D.m.4.3[6,6],
    angio.D.m.4.3[7,7],angio.D.m.4.3[8,8],angio.D.m.4.3[9,9],angio.D.m.4.3[10,10],angio.D.m.4.3[11,11])

angio.D.m.3.2<-(angio.D.m.3.TAM[,12:22])
angio.D.m.3.2.mean<-mean(angio.D.m.3.2[1,1],angio.D.m.3.2[2,2],angio.D.m.3.2[3,3],angio.D.m.3.2[4,4],angio.D.m.3.2[5,5],angio.D.m.3.2[6,6],
    angio.D.m.3.2[7,7],angio.D.m.3.2[8,8],angio.D.m.3.2[9,9],angio.D.m.3.2[10,10],angio.D.m.3.2[11,11])

angio.D.m.2.1<-(angio.D.m.2.TAM[,1:11])
angio.D.m.2.1.mean<-mean(angio.D.m.2.1[1,1],angio.D.m.2.1[2,2],angio.D.m.2.1[3,3],angio.D.m.2.1[4,4],angio.D.m.2.1[5,5],angio.D.m.2.1[6,6],
    angio.D.m.2.1[7,7],angio.D.m.2.1[8,8],angio.D.m.2.1[9,9],angio.D.m.2.1[10,10],angio.D.m.2.1[11,11])

angio.D.trans<-c(angio.D.m.800.775.mean, angio.D.m.775.745.mean,angio.D.m.745.710.mean,angio.D.m.710.675.mean,angio.D.m.675.645.mean,
angio.D.m.645.615.mean,angio.D.m.615.600.mean,angio.D.m.600.8.mean,angio.D.m.8.7.mean,angio.D.m.7.6.mean,angio.D.m.6.5.mean,angio.D.m.5.4.mean,
angio.D.m.4.3.mean,angio.D.m.3.2.mean,angio.D.m.2.1.mean )

#get small dataframes for each of eight elevations in original transects
angio.rich.m.600<-angio.rich.m[grepl("600*", rownames(angio.rich.m)), ]
angio.rich.m.615<-angio.rich.m[grepl("615*", rownames(angio.rich.m)), ]
angio.rich.m.645<-angio.rich.m[grepl("645*", rownames(angio.rich.m)), ]
angio.rich.m.675<-angio.rich.m[grepl("675*", rownames(angio.rich.m)), ]
angio.rich.m.710<-angio.rich.m[grepl("710*", rownames(angio.rich.m)), ]
angio.rich.m.745<-angio.rich.m[grepl("745*", rownames(angio.rich.m)), ]
angio.rich.m.775<-angio.rich.m[grepl("775*", rownames(angio.rich.m)), ]
angio.rich.m.800<-angio.rich.m[grepl("800*", rownames(angio.rich.m)), ]

#get small dataframes for each of eight additional lines
angio.rich.m.1<-angio.rich.m[grepl("1", rownames(angio.rich.m)), ]
angio.rich.m.1.TAM<-angio.rich.m.1[c(1:11),]
angio.rich.m.2<-angio.rich.m[grepl("2", rownames(angio.rich.m)), ]
angio.rich.m.2.TAM<-angio.rich.m.2[c(1:11),]
angio.rich.m.3<-angio.rich.m[grepl("3", rownames(angio.rich.m)), ]
angio.rich.m.3.TAM<-angio.rich.m.3[c(1:11),]
angio.rich.m.4<-angio.rich.m[grepl("4", rownames(angio.rich.m)), ]
angio.rich.m.4.TAM<-angio.rich.m.4[c(1:11),]
angio.rich.m.5<-angio.rich.m[grepl("5", rownames(angio.rich.m)), ]
angio.rich.m.5.TAM<-angio.rich.m.5[c(1:11),]
angio.rich.m.6<-angio.rich.m[grepl("6", rownames(angio.rich.m)), ]
angio.rich.m.6.TAM<-angio.rich.m.6[c(1:11),]
angio.rich.m.7<-angio.rich.m[grepl("7", rownames(angio.rich.m)), ]
angio.rich.m.7.TAM<-angio.rich.m.7[c(1:11),]
angio.rich.m.8<-angio.rich.m[grepl("8", rownames(angio.rich.m)),]
angio.rich.m.8.TAM<-angio.rich.m.8[c(1:11),]

#Extract pairwise transect information
angio.rich.m.800.775<-(angio.rich.m.800[,grepl("775*", colnames(angio.rich.m.800)) ])
head(angio.rich.m.800.775)
##            E775A1     E775B2     E775C3    E775D4     E775E5    E775F6
## E800A1 0.25818182 0.50434783 0.41803279 0.4537815 0.09660574 0.1533333
## E800B2 0.43661972 0.17525773 0.27927928 0.2380952 0.68000000 0.5209581
## E800C3 0.08510638 0.20279720 0.09554140 0.1390728 0.41891892 0.1924883
## E800D4 0.38775510 0.11764706 0.22413793 0.1818182 0.64705882 0.4767442
## E800E5 0.22155689 0.06557377 0.04411765 0.0000000 0.52727273 0.3229167
## E800F6 0.08510638 0.20279720 0.09554140 0.1390728 0.41891892 0.1924883
##           E775G7     E775H8     E775I9   E775J10    E775K11
## E800A1 0.2401434 0.08465608 0.52422907 0.9116022 0.61682243
## E800B2 0.4520548 0.67346939 0.14893617 0.6666667 0.01234568
## E800C3 0.1041667 0.40893471 0.22857143 0.8297872 0.35433071
## E800D4 0.4039735 0.64000000 0.09090909 0.6981132 0.04651163
## E800E5 0.2397661 0.51851852 0.09243697 0.7808219 0.22641509
## E800F6 0.1041667 0.40893471 0.22857143 0.8297872 0.35433071
angio.rich.m.800.775.mean<-mean(angio.rich.m.800.775[1,1],angio.rich.m.800.775[2,2],angio.rich.m.800.775[3,3],angio.rich.m.800.775[4,4],angio.rich.m.800.775[5,5],angio.rich.m.800.775[6,6],
    angio.rich.m.800.775[7,7],angio.rich.m.800.775[8,8],angio.rich.m.800.775[9,9],angio.rich.m.800.775[10,10],angio.rich.m.800.775[11,11])

angio.rich.m.775.745<-(angio.rich.m.775[,grepl("745*", colnames(angio.rich.m.775)) ])
angio.rich.m.775.745.mean<-mean(angio.rich.m.775.745[1,1],angio.rich.m.775.745[2,2],angio.rich.m.775.745[3,3],angio.rich.m.775.745[4,4],angio.rich.m.775.745[5,5],angio.rich.m.775.745[6,6],
    angio.rich.m.775.745[7,7],angio.rich.m.775.745[8,8],angio.rich.m.775.745[9,9],angio.rich.m.775.745[10,10],angio.rich.m.775.745[11,11])

angio.rich.m.745.710<-(angio.rich.m.745[,grepl("710*", colnames(angio.rich.m.745)) ])
angio.rich.m.745.710.mean<-mean(angio.rich.m.745.710[1,1],angio.rich.m.745.710[2,2],angio.rich.m.745.710[3,3],angio.rich.m.745.710[4,4],angio.rich.m.745.710[5,5],angio.rich.m.745.710[6,6],
    angio.rich.m.745.710[7,7],angio.rich.m.745.710[8,8],angio.rich.m.745.710[9,9],angio.rich.m.745.710[10,10],angio.rich.m.745.710[11,11])

angio.rich.m.710.675<-(angio.rich.m.710[,grepl("675*", colnames(angio.rich.m.710)) ])
angio.rich.m.710.675.mean<-mean(angio.rich.m.710.675[1,1],angio.rich.m.710.675[2,2],angio.rich.m.710.675[3,3],angio.rich.m.710.675[4,4],angio.rich.m.710.675[5,5],angio.rich.m.710.675[6,6],
    angio.rich.m.710.675[7,7],angio.rich.m.710.675[8,8],angio.rich.m.710.675[9,9],angio.rich.m.710.675[10,10],angio.rich.m.710.675[11,11])

angio.rich.m.675.645<-(angio.rich.m.675[,grepl("645*", colnames(angio.rich.m.675)) ])
angio.rich.m.675.645.mean<-mean(angio.rich.m.675.645[1,1],angio.rich.m.675.645[2,2],angio.rich.m.675.645[3,3],angio.rich.m.675.645[4,4],angio.rich.m.675.645[5,5],angio.rich.m.675.645[6,6],
    angio.rich.m.675.645[7,7],angio.rich.m.675.645[8,8],angio.rich.m.675.645[9,9],angio.rich.m.675.645[10,10],angio.rich.m.675.645[11,11])

angio.rich.m.645.615<-(angio.rich.m.645[,grepl("615*", colnames(angio.rich.m.645)) ])
angio.rich.m.645.615.mean<-mean(angio.rich.m.645.615[1,1],angio.rich.m.645.615[2,2],angio.rich.m.645.615[3,3],angio.rich.m.645.615[4,4],angio.rich.m.645.615[5,5],angio.rich.m.645.615[6,6],
    angio.rich.m.645.615[7,7],angio.rich.m.645.615[8,8],angio.rich.m.645.615[9,9],angio.rich.m.645.615[10,10],angio.rich.m.645.615[11,11])

angio.rich.m.615.600<-(angio.rich.m.615[,grepl("600*", colnames(angio.rich.m.615)) ])
angio.rich.m.615.600.mean<-mean(angio.rich.m.615.600[1,1],angio.rich.m.615.600[2,2],angio.rich.m.615.600[3,3],angio.rich.m.615.600[4,4],angio.rich.m.615.600[5,5],angio.rich.m.615.600[6,6],
    angio.rich.m.615.600[7,7],angio.rich.m.615.600[8,8],angio.rich.m.615.600[9,9],angio.rich.m.615.600[10,10],angio.rich.m.615.600[11,11])

angio.rich.m.600.8<-(angio.rich.m.600[,78:88])
angio.rich.m.600.8.mean<-mean(angio.rich.m.600.8[1,1],angio.rich.m.600.8[2,2],angio.rich.m.600.8[3,3],angio.rich.m.600.8[4,4],angio.rich.m.600.8[5,5],angio.rich.m.600.8[6,6],
    angio.rich.m.600.8[7,7],angio.rich.m.600.8[8,8],angio.rich.m.600.8[9,9],angio.rich.m.600.8[10,10],angio.rich.m.600.8[11,11])

angio.rich.m.8.7<-(angio.rich.m.8.TAM[,67:77])
angio.rich.m.8.7.mean<-mean(angio.rich.m.8.7[1,1],angio.rich.m.8.7[2,2],angio.rich.m.8.7[3,3],angio.rich.m.8.7[4,4],angio.rich.m.8.7[5,5],angio.rich.m.8.7[6,6],
    angio.rich.m.8.7[7,7],angio.rich.m.8.7[8,8],angio.rich.m.8.7[9,9],angio.rich.m.8.7[10,10],angio.rich.m.8.7[11,11])

angio.rich.m.7.6<-(angio.rich.m.7.TAM[,56:66])
angio.rich.m.7.6.mean<-mean(angio.rich.m.7.6[1,1],angio.rich.m.7.6[2,2],angio.rich.m.7.6[3,3],angio.rich.m.7.6[4,4],angio.rich.m.7.6[5,5],angio.rich.m.7.6[6,6],
    angio.rich.m.7.6[7,7],angio.rich.m.7.6[8,8],angio.rich.m.7.6[9,9],angio.rich.m.7.6[10,10],angio.rich.m.7.6[11,11])

angio.rich.m.6.5<-(angio.rich.m.6.TAM[,45:55])
angio.rich.m.6.5.mean<-mean(angio.rich.m.6.5[1,1],angio.rich.m.6.5[2,2],angio.rich.m.6.5[3,3],angio.rich.m.6.5[4,4],angio.rich.m.6.5[5,5],angio.rich.m.6.5[6,6],
    angio.rich.m.6.5[7,7],angio.rich.m.6.5[8,8],angio.rich.m.6.5[9,9],angio.rich.m.6.5[10,10],angio.rich.m.6.5[11,11])

angio.rich.m.5.4<-(angio.rich.m.5.TAM[,34:44])
angio.rich.m.5.4.mean<-mean(angio.rich.m.5.4[1,1],angio.rich.m.5.4[2,2],angio.rich.m.5.4[3,3],angio.rich.m.5.4[4,4],angio.rich.m.5.4[5,5],angio.rich.m.5.4[6,6],
    angio.rich.m.5.4[7,7],angio.rich.m.5.4[8,8],angio.rich.m.5.4[9,9],angio.rich.m.5.4[10,10],angio.rich.m.5.4[11,11])

angio.rich.m.4.3<-(angio.rich.m.4.TAM[,23:33])
angio.rich.m.4.3.mean<-mean(angio.rich.m.4.3[1,1],angio.rich.m.4.3[2,2],angio.rich.m.4.3[3,3],angio.rich.m.4.3[4,4],angio.rich.m.4.3[5,5],angio.rich.m.4.3[6,6],
    angio.rich.m.4.3[7,7],angio.rich.m.4.3[8,8],angio.rich.m.4.3[9,9],angio.rich.m.4.3[10,10],angio.rich.m.4.3[11,11])

angio.rich.m.3.2<-(angio.rich.m.3.TAM[,12:22])
angio.rich.m.3.2.mean<-mean(angio.rich.m.3.2[1,1],angio.rich.m.3.2[2,2],angio.rich.m.3.2[3,3],angio.rich.m.3.2[4,4],angio.rich.m.3.2[5,5],angio.rich.m.3.2[6,6],
    angio.rich.m.3.2[7,7],angio.rich.m.3.2[8,8],angio.rich.m.3.2[9,9],angio.rich.m.3.2[10,10],angio.rich.m.3.2[11,11])

angio.rich.m.2.1<-(angio.rich.m.2.TAM[,1:11])
angio.rich.m.2.1.mean<-mean(angio.rich.m.2.1[1,1],angio.rich.m.2.1[2,2],angio.rich.m.2.1[3,3],angio.rich.m.2.1[4,4],angio.rich.m.2.1[5,5],angio.rich.m.2.1[6,6],
    angio.rich.m.2.1[7,7],angio.rich.m.2.1[8,8],angio.rich.m.2.1[9,9],angio.rich.m.2.1[10,10],angio.rich.m.2.1[11,11])

angio.rich.trans<-c(angio.rich.m.800.775.mean, angio.rich.m.775.745.mean,angio.rich.m.745.710.mean,angio.rich.m.710.675.mean,angio.rich.m.675.645.mean,
angio.rich.m.645.615.mean,angio.rich.m.615.600.mean,angio.rich.m.600.8.mean,angio.rich.m.8.7.mean,angio.rich.m.7.6.mean,angio.rich.m.6.5.mean,angio.rich.m.5.4.mean,
angio.rich.m.4.3.mean,angio.rich.m.3.2.mean,angio.rich.m.2.1.mean )


#get small dataframes for each of eight elevations in original transects
angio.repl.m.600<-angio.repl.m[grepl("600*", rownames(angio.repl.m)), ]
angio.repl.m.615<-angio.repl.m[grepl("615*", rownames(angio.repl.m)), ]
angio.repl.m.645<-angio.repl.m[grepl("645*", rownames(angio.repl.m)), ]
angio.repl.m.675<-angio.repl.m[grepl("675*", rownames(angio.repl.m)), ]
angio.repl.m.710<-angio.repl.m[grepl("710*", rownames(angio.repl.m)), ]
angio.repl.m.745<-angio.repl.m[grepl("745*", rownames(angio.repl.m)), ]
angio.repl.m.775<-angio.repl.m[grepl("775*", rownames(angio.repl.m)), ]
angio.repl.m.800<-angio.repl.m[grepl("800*", rownames(angio.repl.m)), ]

#get small dataframes for each of eight additional lines
angio.repl.m.1<-angio.repl.m[grepl("1", rownames(angio.repl.m)), ]
angio.repl.m.1.TAM<-angio.repl.m.1[c(1:11),]
angio.repl.m.2<-angio.repl.m[grepl("2", rownames(angio.repl.m)), ]
angio.repl.m.2.TAM<-angio.repl.m.2[c(1:11),]
angio.repl.m.3<-angio.repl.m[grepl("3", rownames(angio.repl.m)), ]
angio.repl.m.3.TAM<-angio.repl.m.3[c(1:11),]
angio.repl.m.4<-angio.repl.m[grepl("4", rownames(angio.repl.m)), ]
angio.repl.m.4.TAM<-angio.repl.m.4[c(1:11),]
angio.repl.m.5<-angio.repl.m[grepl("5", rownames(angio.repl.m)), ]
angio.repl.m.5.TAM<-angio.repl.m.5[c(1:11),]
angio.repl.m.6<-angio.repl.m[grepl("6", rownames(angio.repl.m)), ]
angio.repl.m.6.TAM<-angio.repl.m.6[c(1:11),]
angio.repl.m.7<-angio.repl.m[grepl("7", rownames(angio.repl.m)), ]
angio.repl.m.7.TAM<-angio.repl.m.7[c(1:11),]
angio.repl.m.8<-angio.repl.m[grepl("8", rownames(angio.repl.m)),]
angio.repl.m.8.TAM<-angio.repl.m.8[c(1:11),]

#Extract pairwise transect information
angio.repl.m.800.775<-(angio.repl.m.800[,grepl("775*", colnames(angio.repl.m.800)) ])
head(angio.repl.m.800.775)
##           E775A1    E775B2    E775C3    E775D4     E775E5    E775F6
## E800A1 0.1236364 0.4869565 0.5163934 0.4789916 0.68929504 0.5466667
## E800B2 0.3802817 0.5154639 0.3063063 0.4761905 0.19200000 0.3473054
## E800C3 0.7872340 0.2377622 0.2929936 0.4238411 0.08783784 0.4037559
## E800D4 0.5850340 0.4705882 0.2241379 0.2727273 0.26666667 0.4651163
## E800E5 0.6826347 0.7704918 0.5882353 0.6769231 0.35636364 0.5729167
## E800F6 0.8297872 0.3916084 0.4076433 0.5165563 0.14189189 0.4319249
##            E775G7    E775H8    E775I9    E775J10   E775K11
## E800A1 0.04301075 0.1693122 0.1145374 0.03314917 0.3177570
## E800B2 0.34246575 0.1877551 0.5531915 0.04166667 0.8395062
## E800C3 0.72916667 0.4673540 0.5571429 0.02127660 0.4724409
## E800D4 0.51655629 0.3120000 0.8484848 0.11320755 0.6976744
## E800E5 0.59649123 0.4222222 0.7563025 0.02739726 0.5660377
## E800F6 0.77083333 0.5085911 0.6285714 0.02127660 0.3464567
angio.repl.m.800.775.mean<-mean(angio.repl.m.800.775[1,1],angio.repl.m.800.775[2,2],angio.repl.m.800.775[3,3],angio.repl.m.800.775[4,4],angio.repl.m.800.775[5,5],angio.repl.m.800.775[6,6],
    angio.repl.m.800.775[7,7],angio.repl.m.800.775[8,8],angio.repl.m.800.775[9,9],angio.repl.m.800.775[10,10],angio.repl.m.800.775[11,11])

angio.repl.m.775.745<-(angio.repl.m.775[,grepl("745*", colnames(angio.repl.m.775)) ])
angio.repl.m.775.745.mean<-mean(angio.repl.m.775.745[1,1],angio.repl.m.775.745[2,2],angio.repl.m.775.745[3,3],angio.repl.m.775.745[4,4],angio.repl.m.775.745[5,5],angio.repl.m.775.745[6,6],
    angio.repl.m.775.745[7,7],angio.repl.m.775.745[8,8],angio.repl.m.775.745[9,9],angio.repl.m.775.745[10,10],angio.repl.m.775.745[11,11])

angio.repl.m.745.710<-(angio.repl.m.745[,grepl("710*", colnames(angio.repl.m.745)) ])
angio.repl.m.745.710.mean<-mean(angio.repl.m.745.710[1,1],angio.repl.m.745.710[2,2],angio.repl.m.745.710[3,3],angio.repl.m.745.710[4,4],angio.repl.m.745.710[5,5],angio.repl.m.745.710[6,6],
    angio.repl.m.745.710[7,7],angio.repl.m.745.710[8,8],angio.repl.m.745.710[9,9],angio.repl.m.745.710[10,10],angio.repl.m.745.710[11,11])

angio.repl.m.710.675<-(angio.repl.m.710[,grepl("675*", colnames(angio.repl.m.710)) ])
angio.repl.m.710.675.mean<-mean(angio.repl.m.710.675[1,1],angio.repl.m.710.675[2,2],angio.repl.m.710.675[3,3],angio.repl.m.710.675[4,4],angio.repl.m.710.675[5,5],angio.repl.m.710.675[6,6],
    angio.repl.m.710.675[7,7],angio.repl.m.710.675[8,8],angio.repl.m.710.675[9,9],angio.repl.m.710.675[10,10],angio.repl.m.710.675[11,11])

angio.repl.m.675.645<-(angio.repl.m.675[,grepl("645*", colnames(angio.repl.m.675)) ])
angio.repl.m.675.645.mean<-mean(angio.repl.m.675.645[1,1],angio.repl.m.675.645[2,2],angio.repl.m.675.645[3,3],angio.repl.m.675.645[4,4],angio.repl.m.675.645[5,5],angio.repl.m.675.645[6,6],
    angio.repl.m.675.645[7,7],angio.repl.m.675.645[8,8],angio.repl.m.675.645[9,9],angio.repl.m.675.645[10,10],angio.repl.m.675.645[11,11])

angio.repl.m.645.615<-(angio.repl.m.645[,grepl("615*", colnames(angio.repl.m.645)) ])
angio.repl.m.645.615.mean<-mean(angio.repl.m.645.615[1,1],angio.repl.m.645.615[2,2],angio.repl.m.645.615[3,3],angio.repl.m.645.615[4,4],angio.repl.m.645.615[5,5],angio.repl.m.645.615[6,6],
    angio.repl.m.645.615[7,7],angio.repl.m.645.615[8,8],angio.repl.m.645.615[9,9],angio.repl.m.645.615[10,10],angio.repl.m.645.615[11,11])

angio.repl.m.615.600<-(angio.repl.m.615[,grepl("600*", colnames(angio.repl.m.615)) ])
angio.repl.m.615.600.mean<-mean(angio.repl.m.615.600[1,1],angio.repl.m.615.600[2,2],angio.repl.m.615.600[3,3],angio.repl.m.615.600[4,4],angio.repl.m.615.600[5,5],angio.repl.m.615.600[6,6],
    angio.repl.m.615.600[7,7],angio.repl.m.615.600[8,8],angio.repl.m.615.600[9,9],angio.repl.m.615.600[10,10],angio.repl.m.615.600[11,11])

angio.repl.m.600.8<-(angio.repl.m.600[,78:88])
angio.repl.m.600.8.mean<-mean(angio.repl.m.600.8[1,1],angio.repl.m.600.8[2,2],angio.repl.m.600.8[3,3],angio.repl.m.600.8[4,4],angio.repl.m.600.8[5,5],angio.repl.m.600.8[6,6],
    angio.repl.m.600.8[7,7],angio.repl.m.600.8[8,8],angio.repl.m.600.8[9,9],angio.repl.m.600.8[10,10],angio.repl.m.600.8[11,11])

angio.repl.m.8.7<-(angio.repl.m.8.TAM[,67:77])
angio.repl.m.8.7.mean<-mean(angio.repl.m.8.7[1,1],angio.repl.m.8.7[2,2],angio.repl.m.8.7[3,3],angio.repl.m.8.7[4,4],angio.repl.m.8.7[5,5],angio.repl.m.8.7[6,6],
    angio.repl.m.8.7[7,7],angio.repl.m.8.7[8,8],angio.repl.m.8.7[9,9],angio.repl.m.8.7[10,10],angio.repl.m.8.7[11,11])

angio.repl.m.7.6<-(angio.repl.m.7.TAM[,56:66])
angio.repl.m.7.6.mean<-mean(angio.repl.m.7.6[1,1],angio.repl.m.7.6[2,2],angio.repl.m.7.6[3,3],angio.repl.m.7.6[4,4],angio.repl.m.7.6[5,5],angio.repl.m.7.6[6,6],
    angio.repl.m.7.6[7,7],angio.repl.m.7.6[8,8],angio.repl.m.7.6[9,9],angio.repl.m.7.6[10,10],angio.repl.m.7.6[11,11])

angio.repl.m.6.5<-(angio.repl.m.6.TAM[,45:55])
angio.repl.m.6.5.mean<-mean(angio.repl.m.6.5[1,1],angio.repl.m.6.5[2,2],angio.repl.m.6.5[3,3],angio.repl.m.6.5[4,4],angio.repl.m.6.5[5,5],angio.repl.m.6.5[6,6],
    angio.repl.m.6.5[7,7],angio.repl.m.6.5[8,8],angio.repl.m.6.5[9,9],angio.repl.m.6.5[10,10],angio.repl.m.6.5[11,11])

angio.repl.m.5.4<-(angio.repl.m.5.TAM[,34:44])
angio.repl.m.5.4.mean<-mean(angio.repl.m.5.4[1,1],angio.repl.m.5.4[2,2],angio.repl.m.5.4[3,3],angio.repl.m.5.4[4,4],angio.repl.m.5.4[5,5],angio.repl.m.5.4[6,6],
    angio.repl.m.5.4[7,7],angio.repl.m.5.4[8,8],angio.repl.m.5.4[9,9],angio.repl.m.5.4[10,10],angio.repl.m.5.4[11,11])

angio.repl.m.4.3<-(angio.repl.m.4.TAM[,23:33])
angio.repl.m.4.3.mean<-mean(angio.repl.m.4.3[1,1],angio.repl.m.4.3[2,2],angio.repl.m.4.3[3,3],angio.repl.m.4.3[4,4],angio.repl.m.4.3[5,5],angio.repl.m.4.3[6,6],
    angio.repl.m.4.3[7,7],angio.repl.m.4.3[8,8],angio.repl.m.4.3[9,9],angio.repl.m.4.3[10,10],angio.repl.m.4.3[11,11])

angio.repl.m.3.2<-(angio.repl.m.3.TAM[,12:22])
angio.repl.m.3.2.mean<-mean(angio.repl.m.3.2[1,1],angio.repl.m.3.2[2,2],angio.repl.m.3.2[3,3],angio.repl.m.3.2[4,4],angio.repl.m.3.2[5,5],angio.repl.m.3.2[6,6],
    angio.repl.m.3.2[7,7],angio.repl.m.3.2[8,8],angio.repl.m.3.2[9,9],angio.repl.m.3.2[10,10],angio.repl.m.3.2[11,11])

angio.repl.m.2.1<-(angio.repl.m.2.TAM[,1:11])
angio.repl.m.2.1.mean<-mean(angio.repl.m.2.1[1,1],angio.repl.m.2.1[2,2],angio.repl.m.2.1[3,3],angio.repl.m.2.1[4,4],angio.repl.m.2.1[5,5],angio.repl.m.2.1[6,6],
    angio.repl.m.2.1[7,7],angio.repl.m.2.1[8,8],angio.repl.m.2.1[9,9],angio.repl.m.2.1[10,10],angio.repl.m.2.1[11,11])

angio.repl.trans<-c(angio.repl.m.800.775.mean, angio.repl.m.775.745.mean,angio.repl.m.745.710.mean,angio.repl.m.710.675.mean,angio.repl.m.675.645.mean,
angio.repl.m.645.615.mean,angio.repl.m.615.600.mean,angio.repl.m.600.8.mean,angio.repl.m.8.7.mean,angio.repl.m.7.6.mean,angio.repl.m.6.5.mean,angio.repl.m.5.4.mean,
angio.repl.m.4.3.mean,angio.repl.m.3.2.mean,angio.repl.m.2.1.mean )


#dev.new(width=11.8, height=6)
plot(vasc.D.trans, ylim=c(0,1),type="l",axes=FALSE, col="black", lwd=2, bty="n", ylab="Contribution to beta diversity", cex.lab=1.25, xlab="Comparison between sampling bands",
 main="Contribution of richness and replacement to beta diversity \nbetweem sampling bands for vascular plants" , cex.main=1.5) 
lines(vasc.rich.trans, lwd=2, col="grey70", lty=2)
lines(vasc.repl.trans, lwd=2, col="grey40", lty=2)
axis(2, lwd=2)
axis(1,1:15,labels=c("800x775", "775x745", "745x710", "710x675", "675x645", "645x615", "615x600", "600x8","8x7", "7x6","6x5", "5x4", "4x3", "3x2", "2x1"))
box(bty="l", lwd=4)
legend("topright", c("Sorensen's beta diversity", "Contribution of richness", "Contribution of replacement"), col = c("black","grey70", "grey40" ), cex=1.1,
      lty = c(1, 2,2), pch = c(NA, NA, NA), lwd=3 , bg = "white", bty="n")

#dev.new(width=11.8, height=6)
plot(angio.D.trans, ylim=c(0,1),type="l",axes=FALSE, col="black", lwd=2, bty="n", ylab="Contribution to beta diversity", cex.lab=1.25, xlab="Comparison between sampling bands",
 main="Contribution of richness and replacement to beta diversity \nbetweem sampling bands for angiosperms" , cex.main=1.5) 
lines(angio.rich.trans, lwd=2, col="grey70", lty=2)
lines(angio.repl.trans, lwd=2, col="grey40", lty=2)
axis(2, lwd=2)
axis(1,1:15,labels=c("800x775", "775x745", "745x710", "710x675", "675x645", "645x615", "615x600", "600x8","8x7", "7x6","6x5", "5x4", "4x3", "3x2", "2x1"))
box(bty="l", lwd=4)
legend("topright", c("Sorensen's beta diversity", "Contribution of richness", "Contribution of replacement"), col = c("black","grey70", "grey40" ), cex=1.1,
      lty = c(1, 2,2), pch = c(NA, NA, NA), lwd=3 , bg = "white", bty="n")

#dev.new(width=11.8, height=8)
par(mfrow=c(2,2))
plot(vasc.D.trans, ylim=c(0,1),type="l",axes=FALSE, col="black", lwd=2, bty="n", ylab="Contribution to beta diversity", cex.lab=1, xlab="Comparison between sampling bands",
 main="Beta diversity \nbetweem sampling bands" , cex.main=1) 
lines(angio.D.trans, lwd=2, col="grey70", lty=1)
axis(2, lwd=2)
axis(1,1:15,labels=c("800x775", "775x745", "745x710", "710x675", "675x645", "645x615", "615x600", "600x8","8x7", "7x6","6x5", "5x4", "4x3", "3x2", "2x1"))
box(bty="l", lwd=4)
legend("bottomleft", c("Sorensen's beta diversity - vasculars", "Sorensen's beta diversity - angiosperms"), col = c("black","grey70" ), cex=1.1,
      lty = c(1, 1), pch = c(NA, NA), lwd=2 , bg = "white", bty="n")

plot.new()

plot(vasc.rich.trans, ylim=c(0,1),type="l",axes=FALSE, col="black", lwd=2, bty="n", ylab="Contribution of richness to beta diversity", cex.lab=1, xlab="Comparison between sampling bands",
 main="Contribution of richness to beta diversity \nbetweem sampling bands" , cex.main=1) 
lines(angio.rich.trans, lwd=2, col="grey70", lty=1)
axis(2, lwd=2)
axis(1,1:15,labels=c("800x775", "775x745", "745x710", "710x675", "675x645", "645x615", "615x600", "600x8","8x7", "7x6","6x5", "5x4", "4x3", "3x2", "2x1"))
box(bty="l", lwd=4)
legend("topright", c("Contribution of richness - vasculars", "Contribution of richness - angiosperms"), col = c("black","grey70" ), cex=1.1,
      lty = c(1, 1), pch = c(NA, NA), lwd=2 , bg = "white", bty="n")

plot(vasc.repl.trans, ylim=c(0,1),type="l",axes=FALSE, col="black", lwd=2, bty="n", ylab="Contribution of replacement to beta diversity", cex.lab=1, xlab="Comparison between sampling bands",
 main="Contribution of replacement to beta diversity \nbetweem sampling bands" , cex.main=1) 
lines(angio.repl.trans, lwd=2, col="grey70", lty=1)
axis(2, lwd=2)
axis(1,1:15,labels=c("800x775", "775x745", "745x710", "710x675", "675x645", "645x615", "615x600", "600x8","8x7", "7x6","6x5", "5x4", "4x3", "3x2", "2x1"))
box(bty="l", lwd=4)
legend("topright", c("Contribution of replacement - vasculars", "Contribution of replacement - angiosperms"), col = c("black","grey70" ), cex=1.1,
      lty = c(1, 1), pch = c(NA, NA), lwd=2 , bg = "white", bty="n")