Question: R: How to save Mart object (BiomaRt package)
gravatar for m98
17 months ago by
m98260 wrote:

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:

ensembl <- useMart("ENSEMBL_MART_ENSEMBL", dataset = "hsapiens_gene_ensembl", host = "")

# 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[[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.

rna-seq biomart R • 619 views
ADD COMMENTlink modified 17 months ago by Mike Smith1.6k • written 17 months ago by m98260

Did you try googling save r object to file? Please invest some effort to solve your problem.

ADD REPLYlink written 17 months ago by _r_am31k

I didn't think "Mart" objects stored the database tables. Aren't they database handles? Presumably you'd have to getBM the information you want to store and save that to your "ensembl-data.txt" file

ADD REPLYlink written 17 months ago by russhh5.5k
gravatar for Mike Smith
17 months ago by
Mike Smith1.6k
EMBL Heidelberg / de.NBI
Mike Smith1.6k wrote:

I think there's a few issues here, but the fundamental problem in your example is that ensembl is an object of class Mart not a table of results. It stores various information about the 'Mart' (which you can think of a resource) such as the URL and properties of dataset you want to access such as the available attributes and filters. What it doesn't hold is the result of any query, since you could can ask many questions of a mart.

What you want to save will be the results of running the getBM() command with that particular Mart object plus the filter, values, and attributes. You should then be able to save that via write.table() or save().

Since you don't give an example of the getBM() command you're trying to run, it's hard to advise on why it might be crashing.

ADD COMMENTlink written 17 months ago by Mike Smith1.6k
Please log in to add an answer.


Use of this site constitutes acceptance of our User Agreement and Privacy Policy.
Powered by Biostar version 2.3.0
Traffic: 1038 users visited in the last hour