Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/list/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
R 如何将数据帧转换为列表并写入文件_R_List_Bioconductor - Fatal编程技术网

R 如何将数据帧转换为列表并写入文件

R 如何将数据帧转换为列表并写入文件,r,list,bioconductor,R,List,Bioconductor,我试图从bioconductor GO数据库中提取信息,但在导出可用于进一步处理和分析的数据时遇到问题 我有一个名为sig的24个Affyid的列表,并访问数据库: source("http://www.bioconductor.org/biocLite.R") biocLite() biocLite("mouse4302.db") library("mouse4302.db") GO=as.list(mouse4302GO) 理想情况下,我希望将文件输出编写为: x 1415670_at.G

我试图从bioconductor GO数据库中提取信息,但在导出可用于进一步处理和分析的数据时遇到问题

我有一个名为sig的24个Affyid的列表,并访问数据库:

source("http://www.bioconductor.org/biocLite.R")
biocLite()
biocLite("mouse4302.db")
library("mouse4302.db")
GO=as.list(mouse4302GO)
理想情况下,我希望将文件输出编写为:

x
1415670_at.GO:0016192.GOID  GO:0016192
1415670_at.GO:0016192.Evidence  IEA
1415670_at.GO:0016192.Ontology  BP

但是,我遇到了一些问题,这些问题超出了用它编写的前几个元素

write.table(unlist(GO[sig[1:13]]), file='b.txt',sep='\t',row.names=T,quote=F)
超出第13个元素将无法打印

x
1   GO:0001701
2   IMP
3   BP
4   GO:0006499
5   IMP
6   BP
....
这是从

write.table(unlist(GO[sig[1:14]]), file='b.txt',sep='\t',row.names=T,quote=F)
如果您有任何想法和帮助,我们将不胜感激

非常感谢


Alex也可以问一些关于电脑上的Bioconductor软件包的问题。记住加载库

library(mouse4302.db)
并确保您的R不是太旧。我的R.version.string的结果是R版本3.0.2已修补2014-01-02 r64626

一种方法是在这些数据库上使用select接口

## discovery
keytypes(mouse4302.db)      ## how to query
columns(mouse4302.db)       ## what to retrieve
这里有一些身份证

eid <- head(keys(mouse4302.db, keytype="PROBEID"))

下面是一个使用注释的示例。

感谢所有回复,但我使用以下代码进行了管理:

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)
同样,sig是affyid的列表。 我的桌子结束了:

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

这是伟大的进一步分析

sig变量是什么?如果不将data.frame或矩阵传递给write.table,它会在写入之前尝试将输入强制为data.frame。查看as.data.frameunlistGO[sig[1:14]]。Hans:sig变量是AffyidRoland的列表:不幸的是,这对我不起作用。感谢链接Martin,不幸的是,在应用函数select I get Error:找不到函数select@alex-我添加了几个提示-确保您使用的是相对较新的R,你已经加载了库。
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)
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