I am using the biomaRt package to obtain some annotation data in the context of an RNAseq pipeline.
In my script I have the following commands:
library(biomaRt) ensembl <- useMart("ENSEMBL_MART_ENSEMBL", dataset = "hsapiens_gene_ensembl", host = "www.ensembl.org") # Later on in the script I use this ensembl object to annotate my genes
Originally, I used the commands above directly in my pipeline script - in other words, every time I ran the script, I would re-download the data. However, for various reasons, this download is now taking far too long and in fact it crashes before it ends (the download takes over 20min and then crashes).
My question is, is there a way of saving the ensembl object to a file and uploading it in my pipeline? I cannot seem to save the entire file with:
write.table(ensembl, "ensembl-data.txt") Error in as.data.frame.default(x[[i]], optional = TRUE) : cannot coerce class ‘structure("Mart", package = "biomaRt")’ to a data.frame
It feels like there is a simple solution this but I cannot find it. Thanks.
Did you try googling
save r object to file? Please invest some effort to solve your problem.
I didn't think "Mart" objects stored the database tables. Aren't they database handles? Presumably you'd have to
getBMthe information you want to store and save that to your "ensembl-data.txt" file