Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Writing and loading expression sets to and from csv files

In R, one can write a bioconductor ExpressionSet into a csv file using csv.write. For example, using the standard bladderbatch data available as a bioconductor package the following code writes a csv file to the current working drectory:

library("bladderbatch")
data("bladderdata")
write.csv(bladderEset, "bladderEset.csv")

Is there a tool which can read the produced csv file back into R as an ExpressionSet?

If not, is there an ExpressionSet ↔ csv serialiser/deserialiser, which can both output ExpressionSets as csv files and read csv files as ExpressionSets?

The reason I'm asking is because I need to interact with ExpressionsSets with python and java code, and I can easily work with "csv" files, but not with ".rda", ".CEL" or other binary files.

like image 283
Adam Kurkiewicz Avatar asked Nov 30 '17 11:11

Adam Kurkiewicz


2 Answers

If you just wanted to interact with the data using R and python, consider saving the ExpressionSet as a feather object.

https://github.com/wesm/feather

like image 136
jjl Avatar answered Oct 18 '22 00:10

jjl


The comment from @Nathan Werth is what I think you are looking for. By calling readExpressionSet you can easily read in a CSV file as an ExpressionSet.

First, write out the CSV file as your initial code:

library("bladderbatch")
data("bladderdata")
write.csv(bladderEset, "bladderEset.csv")

Then read it back in:

temp <- Biobase::readExpressionSet("bladderEset.csv")
> class(temp)
[1] "ExpressionSet"
attr(,"package")
[1] "Biobase"
like image 43
Stedy Avatar answered Oct 18 '22 00:10

Stedy