how to convert a dataframe to a list and write to file
I am trying to extract information from bioconductor GO database, but am having problems exporting data I can use for further processing and analysis.
I have a list of 24 affyIDs (called sig) and access the database as such:
source("http://www.bioconductor.org/biocLite.R") biocLite() biocLite("mouse4302.db") library("mouse4302.db") GO=as.list(mouse4302GO)
Ideally I would like the file output to be written as:
x 1415670_at.GO:0016192.GOID GO:0016192 1415670_at.GO:0016192.Evidence IEA 1415670_at.GO:0016192.Ontology BP
but am having issues getting beyond the first few elements to be written with this
going beyond the 13th element does not work and print out
x 1 GO:0001701 2 IMP 3 BP 4 GO:0006499 5 IMP 6 BP ....
This is from
Any ideas, help would be greatly appreciated
Thanks for all the replies, but I managed with the following code:
source("http://www.bioconductor.org/biocLite.R") biocLite() biocLite("mouse4302.db") library("mouse4302.db") x=mouse4302GO write.table(links(x[sig]), file='b.txt',sep='\t',row.names=F,quote=F)
Again, sig is a list of AffyIDs. My table ends up:
probe_id go_id Evidence 1415670_at GO:0016192 IEA 1415670_at GO:0006810 IEA 1415670_at GO:0006886 IEA 1415670_at GO:0015031 IEA 1415671_at GO:0006810 IEA
And this is great fr further analysis!
Might as well ask questions about Bioconductor packages on the Bioconductor mailing list. Remember to load the library
and make sure your R is not too old (The result of my R.version.string is "R version 3.0.2 Patched (2014-01-02 r64626)").
One approach is to use the select interface on these data bases
## discovery keytypes(mouse4302.db) ## how to query columns(mouse4302.db) ## what to retrieve
here are some ids.
eid <- head(keys(mouse4302.db, keytype="PROBEID"))
and the GO identifiers associated with those ids, returned as a simple data.frame
xx <- select(mouse4302.db, eid, "GO", keytype="PROBEID")
Here we write out the data
write.table(xx, file=tempfile(), sep="\t", row.names=FALSE, quote=TRUE)
Here's an introductory workflow for working with annotations.