I have done a NMDS graph of a fungal community dataset sampled from 144 soil samples collected under three host plants (Dryas, Kobresia, Salix) - 48 plots from each of the three plants. Those 48 plots have been treated with 8 different treatments, (C,N,P,NP,W,WN,WP and WNP). Half of those treatments have water added, and the other half do not.
Thus, I have three factors I wish to identify the points in my NMDS by - plants, water/no water, and the 8 treatments. The standard is to have just two factors with one having the points differentiated by colour, and the other differentiated by shapes. However, the third factor (e.g. water/no water) then lacks an obvious feature to be distinguished by.
This is my code:
#environment vectors#Treatment vector:Treatment=c(rep("WP",1),rep("WP",1),rep("WP",1),rep("P",1),rep("P",1),rep("P",1),rep("N",1),rep("N",1),rep("NP",1),rep("NP",1)......[148]###Water vector:Water=c(rep("Watering",1),rep("Watering",1),rep("Watering",1),rep("No watering",1),rep("No watering",1),rep("No watering",1),rep("No watering",1),rep("No watering",1).......[148]#plant vector:Plantvector=c(rep("Dryas",1),rep("Kobresia",1),rep("Salix",1),rep("Dryas",1),rep("Kobresia",1),rep("Salix",1),rep("Dryas",1)........ #downloading the OTU tablezacktreat<- read.xlsx("Zack_OTUs_NMDS.xlsx", sheetName = "u_roots",row.names=1)env<- read.xlsx("Zack_OTUs_NMDS.xlsx", sheetName = "env1",row.names=1, )env[env == 9999] <- NAenv1<-env[-c(6,10,13,14,15,16)] #reverting itzacktreat<-t(zacktreat)#doing the actual NMDS calculationszacktreat_NMDS<-metaMDS(zacktreat, distance = "bray", k = 2, wascores = TRUE) #laver en Bray-Curtis-matrix og NMDS-analysen p? ?n gangzacktreat_NMDS.envfit <- envfit(zacktreat_NMDS, env = env, perm = 999,na.rm = TRUE) data for the envfit arrowsenv.scores.zacktreat <- as.data.frame(scores(zacktreat_NMDS.envfit, display = "vectors")) #extracts relevant scores from envifitenv.scores.zacktreat <- cbind(env.scores.zacktreat, env.variables = rownames(env.scores.zacktreat)) #and then gives them their namesmult <- 3 #multiplier for the arrows and text for envfit below. You can change this and then rerun the plot command.#The ggplotp1<-ggplot(# Create data object including treatment as a columndata = cbind(comm = rownames(zacktreat_NMDS$points), treat = Expvect, as.data.frame(zacktreat_NMDS$points)), aes(x = MDS1, y = MDS2, xlab=""))+ Create polygon from hull dataframe scale_colour_manual(values=c("green","blue","red","darkgrey","darkgreen","orange","purple4","deeppink","turquoise2")) + scale_shape_manual(values=c(1, 16)) + # Use aesthetics to color points by treatment theme_bw() + geom_point(aes(col=Treatment, shape=Water), size = 3) + geom_segment(data = env.scores.zacktreat, aes(x = 0, xend = mult*NMDS1, y = 0, yend = mult*NMDS2), arrow = arrow(length = unit(0.25, "cm")), colour = "grey") + #arrows for envfit. doubled the length for similarity to the plot() function. NB check ?envfit regarding arrow length if not familiar with lengths geom_text(data = env.scores.zacktreat, #labels the environmental variable arrows * "mult" as for the arrows aes(x = mult*NMDS1, y = mult*NMDS2, label=env.variables), size = 4,fontface="italic", hjust = 0.5) + #scale_fill_discrete(limits=c("C","N","P","NP","W","WN","WP", "WNP")) + #geom_text(aes(label = comm), vjust = 1.5, size=5) + coord_cartesian(xlim=c(-1.4,1.4), ylim=c(-1.0,1.0)) + labs(title="With env.vectors", x="") + theme(plot.margin=unit(c(0,0,0,0), "mm"))
Basically, NMDS plots are merely points sorted in a 2D-space by X and Y (or MDS1 and MDS2). Like this.
zacktreat_NMDS$points MDS1 MDS2X10D_WP_2 -0.02129782 -0.247132940X10K_WP_2 -0.06159335 -0.091143442X10S_WP_2 0.15047218 -0.251961539X11D_P_2 0.18581153 -0.353744033X11K_P_2 -0.20216965 -0.086797786X11S_P_2 0.02733803 -0.335677136X12D_N_2 0.29451589 -0.346472094X12K_N_2 -0.14428059 -0.129560987X13D_NP_2 0.16634831 -0.126218766X13K_NP_2 -0.63748026 -0.402086997X13S_NP_2 0.03787783 -0.054936657X14D_WNP_2 -0.05264202 -0.534361509X14K_WNP_2 -0.37575597 -0.085469131X14S_WNP_2 0.04165887 -0.417154266X15D_C_2 0.25282597 -0.400829162X15K_C_2 -0.05095801 0.019005850X15S_C_2 0.07280139 -0.211689823X16K_W_2 -0.63515249 -0.192958200X16S_W_2 0.31387911 0.223031310X17D_W_3 -0.25269609 0.567593307
I want to draw something like my attached picture (apologies for the haplessness). Either with three factors separated - plant, water, and treatment, and with water as filled symbols, and no water as open symbols - or with the 4 of the 8 treatments that have water added (with W in their acronym) with filled circles/symbols, and those which do not have water added as open symbols, AND all 8 treatment groups additionally in colour.
I hope I am making myself clear, or if not, that my attached picture says more than my 1000 words.