rawMatrix<-read.csv("tubes.csv",row.names=1,h=T,na.strings="?") dataMatrix<-rawMatrix[c(-1,-2,-3,-4)] distanceMatrix<-daisy(dataMatrix,metric='gower') nmds2<-metaMDS(distanceMatrix,trymax=500,k=2,autotransform=FALSE) nmds3<-metaMDS(distanceMatrix,trymax=500,k=3,autotransform=FALSE) nmds4<-metaMDS(distanceMatrix,trymax=500,k=4,autotransform=FALSE) nmds5<-metaMDS(distanceMatrix,trymax=500,k=5,autotransform=FALSE) nmds6<-metaMDS(distanceMatrix,trymax=500,k=6,autotransform=FALSE) nmds2 nmds3 nmds4 nmds5 nmds6 dm<-as.matrix(distanceMatrix) dimcheckMDS(dm,distance="gower",k=6,trymax=200,autotransform=FALSE) type<-as.character(rawMatrix[,1]) type2<-as.character(rawMatrix[,2]) type3<-as.character(rawMatrix[,3]) cols<-as.character(rawMatrix[,4]) plot(nmds3,type='n',xlab="NMDS Axis 1",ylab="NMDS Axis 2") with(rawMatrix,points(nmds3,display='sites',col=cols,pch=20)) text(nmds3,display='sites',cex=0.6, pos=4) ordihull(nmds3,type3,draw='polygon',col=cols,lwd=0.5) ordihull(nmds3,type,draw='polygon',col=cols,lwd=0.5) groupEdia<-as.matrix(subset(rawMatrix,rawMatrix[,1]=="Ediacaran")) groupCam<-as.matrix(subset(rawMatrix,rawMatrix[,1]=="Camrbian")) groupEdiaAu<-as.matrix(subset(rawMatrix,rawMatrix[,2]=="Ediacaran")) Edia<-dplyr::filter(rawMatrix,rawMatrix[,1]=="Ediacaran") Ediar<-rownames_to_column(Edia, var = "rowname") Ediacaran<-Ediar$rowname Camb<-dplyr::filter(rawMatrix,rawMatrix[,2]=="Camrbian") Cambr<-rownames_to_column(Camb, var = "rowname") Cambrian<-Cambr$rowname EdiaA<-dplyr::filter(rawMatrix,rawMatrix[,2]=="Ediacaran") EdiaAr<-rownames_to_column(EdiaA, var = "rowname") EdiacaranAurora<-EdiaAr$rowname Au<-dplyr::filter(rawMatrix,rawMatrix[,4]=="black") Aur<-rownames_to_column(Au, var = "rowname") Aurora<-Aur$rowname dm<-as.matrix(distanceMatrix) sub<-custom.subsets(dm,list("Ediacaran"=Ediacaran, "Ediacaran+Auroralumina"=EdiacaranAurora,"Cambrian"=Cambrian)) eac<-custom.subsets(dm,list("Ediacaran+Auroralumina"=EdiacaranAurora,"Cambrian"=Cambrian)) eea<-custom.subsets(dm,list("Ediacaran"=Ediacaran, "Ediacaran+Auroralumina"=EdiacaranAurora)) ec<-custom.subsets(dm,list("Ediacaran"=Ediacaran, "Cambrian"=Cambrian)) addisp<-adonis.dispRity(sub,method="gower") addisp boots<-boot.matrix(sub,bootstraps=100) sum_of_ranges<-dispRity(boots,metric=c(sum,ranges)) summary(sum_of_ranges) plot(sum_of_ranges,main="Sum of Ranges") convol<-dispRity(sub,convhull.volume) ##error - not enough points plot(convol) centroids<-dispRity(boots,metric=c(median, centroids)) plot(centroids, main="Median of Centroids") sum_of_variances<-dispRity(boots, metric=c(sum,variances)) plot(sum_of_variances, main="Sum of Variances") ave_neighbours<-dispRity(boots, metric = neighbours,which = mean, method = "gower") plot(ave_neighbours, main="Average Neighbours") min_neighbours<-dispRity(boots, metric = neighbours,which = min, method = "gower") plot(min_neighbours, main="Nearest Neighbours") pair_dist<-dispRity(boots, metric=pairwise.dist, method = "gower") plot(pair_dist,main = "Pairwise Distances") gp_dist<-dispRity(boots, metric=group.dist, method = "gower") plot(gp_dist,main = "Group Distances")