unimplemented type 'list' in 'EncodeElement' error in a Rscript run in Ubuntu terminal
1
1
Entering edit mode
2.2 years ago

Hi,

I get the error of:

 Error in write.table(dxr1, "AS_differential.txt", sep = "\t", quote = F) : 
      unimplemented type 'list' in 'EncodeElement'
    Execution halted

while I'm running a Rscript in Ubuntu. I think it might be due to having a list but my tries for flattening the list (which I don't know which column might be) didn't work. I don't have access to view the result again cause it's in a Rscript and have access to my experiment design that I can't feed it in manual way and using Rstudio. tried this flattening code: df <- apply(df,2,as.character) and then tried to write.csv but no luck, either. I tried some similar issues suggestions but my issue is that I can't see what's going on and can't even view the results or getting the head() and other things.

Before that error there is a warning as well:

converting counts to integer mode
Warning message:
In DESeqDataSet(rse, design, ignoreRank = TRUE) :
some variables in design formula are characters, converting to factors

I should also mention that I get one text file (AS_differential.txt) but it just has one row and obviously had been halted before finishing the work! Library is DEXSeq, and these are last lines of the script:

JUM = estimateExonFoldChanges(JUM, fitExpToVar="condition") 
dxr1 = DEXSeqResults(JUM) 
write.table(dxr1, "AS_differential.txt", sep="\t", quote=F) 
q()

Can someone help to solve this issue please? Thanks a lot. :)

Solved: My data was insanely huge and consisted multi-layers of lists in the DEXSeqResults that I wasn't able to either convert to data.frame nor doing anything on it. At last, I saved the results of analysis in a .RData Image by:

save.image(file='file.RData')

And then opened it in a Rstudio to see what's going on. At the end, I took a subset of my results with pvalue less than 0.05 and then did write.table from that.

dxr1.sig <- as.data.frame(dxr1[dxr1$pvalue < 0.05 & !is.na(dxr1$pvalue),])
write.table(dxr1.sig, "AS_differential.txt", sep="\t", quote=F)
Rscript JUM write.table • 6.9k views
ADD COMMENT
0
Entering edit mode

Rscript and Ubuntu have little to nothing to do with your problem. Are you sure you can write.table a DEXSeqResults object?

ADD REPLY
0
Entering edit mode

At this point, I have to find a way to have the results printed/viewed but nothing works even write.csv and data.frame conversion of result. It says that it's data.frame already then halts the process. The reason that I mentioned it's a Rscript code is that it's automatic and I can't check output of each step. Here's the code I use:

Rscript /path/R_script_JUM.R experiment_design.txt > outputFile.Rout 2> errorFile.Rout
ADD REPLY
1
Entering edit mode

Can you create a copy of the R script and edit it? It's not it's a binary file that you cannot tweak the code in.

ADD REPLY
0
Entering edit mode

Of course, I can and I did. That's why I said I am trying to find a way to change write.table that doesn't work, to something that works like write.csv maybe. But I keep getting other errors. My issue is that I don't know how to print/view/save the results of DEXSeq or DEXSeqResults.

ADD REPLY
0
Entering edit mode

What does class(dxr1) give you?

ADD REPLY
0
Entering edit mode

Is there anyway I can figure it out which of my columns is a list? Like running a code that scan all the columns and tell me which one is list? If I figure that out, I can mutate/unlist it so then can add to data.frame and then to write.table.

I have to run the whole analysis again to add that class(dxr1), so will let u know when finished.

ADD REPLY
0
Entering edit mode

Follow jv's advice - they're further along than me in your track, so their advice will be more pertinent.

unimplemented type 'list' in 'EncodeElement' error in a Rscript run in Ubuntu terminal

ADD REPLY
0
Entering edit mode

You can also run R in the terminal and run the script line by line.

ADD REPLY
0
Entering edit mode

Solved: My data was insanely huge and consisted multi-layers of lists in the DEXSeqResults that I wasn't able to either convert to data.frame nor doing anything on it. At last, I saved the results of analysis in a .RData Image by:

save.image(file='file.RData')

And then opened it in a GUI Rstudio to study what's going on. My tries there to convert subsets of this result to data.frame was also not successful. At the end, I took a subset of my results less tha pvalue 0.05 and then did write.table from that.

dxr1.sig <- as.data.frame(dxr1[dxr1$pvalue < 0.05 & !is.na(dxr1$pvalue),])
write.table(dxr1.sig, "AS_differential.txt", sep="\t", quote=F)
ADD REPLY
2
Entering edit mode

Instead of save.image, saveRDS(dxr1) might have worked better as you're saving just the object that you need, not the entire environment.

ADD REPLY
0
Entering edit mode

Great tip. Thanks!

ADD REPLY
0
Entering edit mode
2.2 years ago
jv ★ 1.8k

According to the manual, the DEXSeqResults object is a subclass of a DataFrame, not a true df. This is confirmed by

data(pasillaDEXSeqDataSet, package="pasilla")
dxd <- estimateSizeFactors( dxd )
dxd <- estimateDispersions( dxd )
dxd <- testForDEU( dxd )
is.data.frame(dxr)
[1] FALSE

please try converting the dxr object to a data.frame object, e.g.

results_df <- as.data.frame(dxr)
write.table(results_df, "AS_differential.txt", sep="\t", quote=F)
ADD COMMENT
0
Entering edit mode

OP says:

... but nothing works even write.csv and data.frame conversion of result. It says that it's data.frame already then halts the process...

Are you sure the as.data.frame will work? OP seems to have tried it already.

ADD REPLY
1
Entering edit mode

I followed all the steps for results generation from the DEXSeq vingette. It's worth noting the example that I followed did not include the use of estimateExonFoldChanges (not sure if that's happening under the hood when running testForDEU) but either way I was able to convert the DEXSeqResults object to a data.frame using as.data.frame and write a table using write.table without any errors.

My guess is there is an additional column, EncodeElement that is part of OP's DEXSeqResults object that I can't replicate and which is contributing to their error, I was also able to find the following which OP could also try: https://stackoverflow.com/questions/24829027/unimplemented-type-list-when-trying-to-write-table

ADD REPLY
0
Entering edit mode

Thank you. I saw this before, but as I just replied to Ram (above), I don't know which of my columns is a list to unlist and then convert to data.frame...

ADD REPLY
0
Entering edit mode

To see what class each of the columns in your dxr1 use the str function, e.g. str(dxr)

Following the top answer in the stackoverflow post that I linked above, l you don't need to know which column is a list, the apply example provided will convert all columns in your results to character vectors.

ADD REPLY
0
Entering edit mode

Solved it. Explained above. :) apply wasn't working, I tried that before.

ADD REPLY
0
Entering edit mode

I did convert to data.frame before and I get the same error.

Error in write.table(results_df, "AS_differential.txt", sep = "\t", quote = F) : 
  unimplemented type 'list' in 'EncodeElement'
ADD REPLY

Login before adding your answer.

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