1

Hello my fellow R community,

I have an ".RData" file, generated by someone somewhere between 2014-2016. This was related to Differential Expression Analysis for his previous RNASeq project. Loading this file into R produces a number of objects that are required for DE Analysis using DESeq2.

However, I am having issues with loading that file into current version of R in Rstudio as there are conflicts related to multiple packages. I tried to figure out how to fix this by installing older versions of R and packages without any clear idea of what versions were used to produce that RData file in the first place as I do not have the code that generated it.

A simple load command in R produces the following error:

Error in h(simpleError(msg, call)) : 
  error in evaluating the argument 'x' in selecting a method for function 'nrow': no slot of name "elementMetadata" for this object of class "DESeqDataSet"
Loading required package: pcaMethods

Attaching package: ‘pcaMethods’

The following object is masked from ‘package:stats’:

    loadings

Error in h(simpleError(msg, call)) : 
  error in evaluating the argument 'x' in selecting a method for function 'nrow': no slot of name "elementMetadata" for this object of class "SummarizedExperiment"
In addition: There were 16 warnings (use warnings() to see them)

My Question is, Is it possible to manipulate that RData file and save it to work with current versions of R? If so, how do we achieve this?

I am hoping that someone has already faced this issue and managed to fix it. I could really use some help as I cannot seem to find solution online.

Any help would be appreciated, thanks.

BS7-ESR10
  • 11
  • 1
  • Welcome to SO! Can you include a reproducible answer? https://stackoverflow.com/help/minimal-reproducible-example – Michael Roswell Apr 19 '23 at 13:30
  • What does the `traceback()` show after the error? Does the the object not load into the global namespace? There's not really a general way to load old rdata files. It probably has less to do with the R version than the package versions for the type of object. It's easier to help you if you include a simple [reproducible example](https://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example) with sample input that can be used to test and verify possible solutions. – MrFlick Apr 19 '23 at 13:34
  • A simple traceback() show the following error: `6: h(simpleError(msg, call)) 5: .handleSimpleError(function (cond) .Internal(C_tryCatchHelper(addr, 1L, cond)), "no slot of name \"elementMetadata\" for this object of class \"SummarizedExperiment\"", base::quote(nrow(x@elementMetadata))) 4: nrow(x@elementMetadata) 3: length(obj) 2: length(obj) 1: .rs.describeObject(, "rld", TRUE)`. Also, producing an RData file with similar errors is difficult for me as I do not know the code that produced it. I'm basically looking at something coming out of a black box. – BS7-ESR10 Apr 19 '23 at 13:45
  • Also @MrFlick, I tried to install an older version of R and load it into R console using that version just now and it seems to load fine but not in RStudio (regardless of older or new version of RStudio). Could this be related to Rstudio? – BS7-ESR10 Apr 19 '23 at 13:52
  • That seems likely. The error is coming from `.rs.describeObject` which is an RStudio specific function. – MrFlick Apr 19 '23 at 14:15
  • This is a good reminder that “RData” and “RDS” aren’t suitable formats for data archival. Luckily I am a far superior R programmer and would never make this mistake (*furiously rewrites an internal package that does exactly that …*). – Konrad Rudolph Apr 22 '23 at 14:56

1 Answers1

0

The simplest and fastest would be to load it with the respective version of R and packages that was used in the first place. Then save the elements of the DESeqDataSet (assays, col- and rowData) as plain text files. Load these into the new analysis environment.

This is not related to RStudio, but the current version of some packages are incompatible with the loaded objects. You can use conda for installing a fitting R environment or use Docker/Apptainer.

My general advise is to always have in- and output data as plain (=generic) text files if possible. RData objects are convenient but as you see they have drawbacks and version issues.

ATpoint
  • 603
  • 5
  • 17