Load data in Synapter
2
0
Entering edit mode
sogueta • 0
@sogueta-7100
Last seen 9.3 years ago
Spain

Hi everyone

Probably, my question fits better in any global R blog, but I am not sure. Anyway, this is que question:

I have applied synergise function to a set of MSe/HDMSe files and then saved the result as .rda file:

syn <- synergise(.....)

save(syn, file = ......)

Now, I would like to load again that data to follow with the synapter pipeline. To this, I have tried with:

syn <- load(filename)

and when I started to convert it into MSnbase object, (x <- as(syn, "MSnSet")), I get the following message:

Error in as(syn, "MSnSet") :
  no method or default for coercing “character” to “MSnSet”

 

Applying class function to syn, class(syn), returns [1] "character"

How can I save my data after synergise function and then load it again?

 

Thanks in advance

Samuel

 

 

 

synergise synapter • 1.4k views
ADD COMMENT
1
Entering edit mode
@laurent-gatto-5645
Last seen 11 weeks ago
Belgium

load will load the object from your file in your global environment - there is no need for assignment.

> x <- 1:10
> save(x, file = "x.rda")
> rm(x)
> load("x.rda")
> ls()
[1] "x"
> x
 [1]  1  2  3  4  5  6  7  8  9 10

If you assign the output, you will get the name of the variable, instead of its content.

> x <- load("x.rda")
> x
[1] "x"

See saveRDS and readRDS for your use case.

> xx <- 1:10
> saveRDS(xx, file = "xx.rds")
> rm(xx)
> zz <- readRDS("xx.rds")
> zz
 [1]  1  2  3  4  5  6  7  8  9 10
ADD COMMENT
0
Entering edit mode

Thanks again Laurent. I have obtained some data from synapter managing only a few number of MSe/HDMSe files (8). Now, I going to perform the same analysis with a pretty large number of files (40). First attemps in my laptop creating the master file from HDMSe files, crashed R; next ones, will be attemped in a workstation.

Regards

ADD REPLY
0
Entering edit mode
@sebastian-gibb-6858
Last seen 5.5 years ago
Germany

There are several ways to save and load an R object. You could use 'save' and 'load' as you tried. 'load' will add the object to your global environment (and return the object name invisible). That's why your loading fails. You overwrite the real object by its name. Try just: 'load("yourfile")' instead of 'syn <-load("yourfile")'. Another way of saving/reading R objects would be 'saveRDS' and 'readRDS'. While 'save'/'load' could save/load multiple objects 'saveRDS'/'readRDS' could handle only a single object. Please have a look at the corresponding manual pages.

ADD COMMENT
0
Entering edit mode

Thanks Sebastian and sorry for my poor knowledge of R. I am just learning with your synapter package. As Laurent suggests, could saveRDS and readRDS be used to manage synergise data as save/load?

Regards.

ADD REPLY
0
Entering edit mode

synapter uses saveRDS/readRDS when needed (see for example ?makeMaster). In the case you describe, you a free to use saveRDS and syn <- readRDS or save/load.

ADD REPLY

Login before adding your answer.

Traffic: 821 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