Question: R: How to save Mart object (BiomaRt package)
0
gravatar for m93
7 weeks ago by
m93170
m93170 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:

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.

rna-seq biomart R • 120 views
ADD COMMENTlink modified 7 weeks ago by Mike Smith1.3k • written 7 weeks ago by m93170
1

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

ADD REPLYlink written 7 weeks ago by RamRS23k
1

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 7 weeks ago by russhh4.6k
3
gravatar for Mike Smith
7 weeks ago by
Mike Smith1.3k
EMBL Heidelberg / de.NBI
Mike Smith1.3k 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 7 weeks ago by Mike Smith1.3k
Please log in to add an answer.

Help
Access

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