This is a test version of Biostars. For the public version, visit https://www.biostars.org.
Exporting NMDS distance matrix as csv in R

Hi All!

I am running R in my terminal to create an NMDS distance matrix. I want to export it to generate an NMDS plot in RStudio. I have tried the following

library(vegan)
pc = read.csv("1_seraq_que_funciona.csv", header= TRUE)
com = pc[,2:ncol(PC)]
m_com = as.matrix(com)
m_com <- m_com[rowSums(m_com) > 2, ,drop=FALSE]
nrow(m_com)
set.seed(123)
nmds = metaMDS(m_com, distance = "bray")
nmds
save(nmds, file = "my_sol.rda")

Now, I am trying to plot the .rda object in the GUI from RStudio, and I obtain the following:

sol <- load("/Users/paulita/Downloads/my_sol.rda") 
 > plot(sol)

Error in plot.window(...) : need finite 'ylim' values
In addition: Warning messages:
1: In xy.coords(x, y, xlabel, ylabel, log) : NAs introduced by coercion
 2: In min(x) : no non-missing arguments to min; returning Inf
 3: In max(x) : no non-missing arguments to max; returning -Inf
 > plot(sol)
 Error in plot.window(...) : need finite 'ylim' values
 In addition: Warning messages:
 1: In xy.coords(x, y, xlabel, ylabel, log) : NAs introduced by coercion
 2: In min(x) : no non-missing arguments to min; returning Inf
 3: In max(x) : no non-missing arguments to max; returning -Inf

Do you know how to solve this issue?

Thank you so much!

vegan r nmds

The only methods the metaMDS object has documented are print, plot, points and text. You may want to check whether the points function subsets out the correct data from the object.

Hi rpolicastro! I tried exporing it as a .rda object and it worked! However, I do not know how to transform it back to an metaMDS object in the Rstudio GUI. Do you know how to do it? Thanks!

1 answer

Here is the answer!

library(vegan)
pc = read.csv("1_seraq_que_funciona.csv", header= TRUE)
com = pc[,2:ncol(PC)]
m_com = as.matrix(com)
m_com <- m_com[rowSums(m_com) > 2, ,drop=FALSE]
nrow(m_com)
set.seed(123)
nmds = metaMDS(m_com, distance = "bray")
nmds
saveRDS(nmds, file = "./cadagno_proteins_90.rds")

Log in to answer this question.