Hello,
I have successfully generated the NMDS ordination (I think), and now want to plot it preferably using "ellipses". Here are all the script that I ran to reach to this step:
nmds <- read.csv(file = "mydata.csv", header = TRUE, row.names = 1) # read species data
nmds.env <- read.csv(file = "mydata_env.csv", header = T, row.names = 1) # read metadata or environment
And then
nmds1 <- metaMDS(nmds, distance = "bray", autotransform = FALSE)
This runs ordination and produces nice results (stress = 0.1)
Next, I run the following:
plot(nmds1) # this displays sites and species
All seems good until here. Next, when I try to plot it and use ellipses, then issue arises. Please see below:
ordiplot(nmds1, type = "n", main = "ellipses") # this runs fine
orditorp(nmds1, display = "sites", labels = F, col = c("blue", "orange") [as.numeric(nmds.env$group)], cex = 1) # this produces error "NAs introduced by coercion" BTW I have only two groups that I want to colour blue and orange.
As shown below, then I changed as.numeric to as.vector since I have a total of two groups and they are not numeric.
orditorp(nmds1, display = "sites", labels = F, col = c("blue", "orange") [as.vector(nmds.env$group)], cex = 1)
The script runs but it produces no plot (no dots)
Next, when I run the following command:
ordiellipse(nmds1, groups = nmds.env$group, draw = "polygon", lty = 1, col = "grey90") # it draws empty ellipses nicely but contains no dots showing the data points.
I want show the dots too. I have attached three figures.
- screenshot of "mydata.csv" file
- screenshot of "mydata_env.csv" file
- output of the plotting... that shows ellipses but no dots to represent data.
Please help me in finding out where I went wrong with this. Thanks in advance!