Exporting NMDS distance matrix as csv in R
1
0
Entering edit mode
23 months ago
Paula ▴ 60

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 • 1.4k views
ADD COMMENT
0
Entering edit mode

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.

ADD REPLY
0
Entering edit mode

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!

ADD REPLY
3
Entering edit mode
22 months ago
Paula ▴ 60

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")
ADD COMMENT

Login before adding your answer.

Traffic: 1450 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6