NMDS (Non-metric multidimensional scaling)

So this works for my data!

I had started with the commands under the section NMDS from
http://userweb.eng.gla.ac.uk/umer.ijaz/bioinformatics/ecological.html

the sample and data samples were prepared according to the above.

and proceed with the following:

library("vegan", lib.loc="~/R/win-library/3.2")
library("lattice", lib.loc="C:/Program Files/R/R-3.2.5/library")
set.seed(2)
abund_table<-read.csv("Sample.csv",row.names=1,check.names=FALSE)
#Transpose the data to have sample names on rows
abund_table<-t(abund_table)

abund_table<-t(abund_table)

example_NMDS=metaMDS(abund_table,
k=2)
plot(example_NMDS)

ordiplot(example_NMDS,type="n")
orditorp(example_NMDS,display="species",col="red",air=0.01)
orditorp(example_NMDS,display="sites",cex=1.25,air=0.01)

And I changed "Treatment 1" and "Treatment 2" to:
treat=c(rep("pH",5),rep("Conductivity",5))
ordiplot(example_NMDS,type="n")
ordihull(example_NMDS,groups=treat,draw="polygon",col="grey90",label=F)
orditorp(example_NMDS,display="species",col="red",air=0.01)
orditorp(example_NMDS,display="sites",col=c(rep("green",5),rep("blue",5)),
air=0.01,cex=1.25)

colors=c(rep("red",5),rep("blue",5))
ordiplot(example_NMDS,type="n")

#Plot convex hulls with colors baesd on treatment
for(i in unique(treat)) {
ordihull(example_NMDS$point[grep(i,treat),],draw="polygon",
groups=treat[treat==i],col=colors[grep(i,treat)],label=F) }
orditorp(example_NMDS,display="species",col="red",air=0.01)
orditorp(example_NMDS,display="sites",col=c(rep("green",5),
rep("blue",5)),air=0.01,cex=1.25)



Thanks to this website!
https://jonlefcheck.net/2012/10/24/nmds-tutorial-in-r/

I have been following the above as Jon is an expert in R for ecological data.

Popular posts from this blog

Correlation

Taxa Plot