操作指南之下载数据

1. 从NCBI的SRA下载数据

(1) 选中要下载的数据,点击send to,format选RunInfo

(2) 打开生成的文件SraRunInfo.csv

linux下可以使用wget download_path来下载

2. 然而。。也可以用别的办法:

考虑使用R的扩展包SRAdb

(1) 安装

如果从源码安装的话,需要这几个包:RSQLite(DBI)graph(装不了)RCurl(bitops)和GEOquery(一堆依赖)

所以我放弃了。选择用Bioconductor来装

然而官网上给的命令我会报错(微笑),所以应该用sudo R进入R环境,然后输入

## try http:// if https:// URLs are not supported

source("https://bioconductor.org/biocLite.R")

biocLite() ## R version 3.0 or later

然而我还是会报错,系统提示我用install.packages(.......)来安装一个老一点的版本。安装完之后,退出,重进,再输入上面的命令,

貌似就可以了。

(2)导入SRAdb包

biocLite('SRAdb')

发现老是导入失败。。。

SRAdb需要这些

GEOquery需要这些

装XML时会报错

解决:

下载libxml2-git-snapshot.tar.gz

tar -zxvf libxml2-git-snapshot.tar.gz

cd libxml2-2.9.4

./configure  # 被网上的说法坑到

make

make install

××××××××××××××××然而我还是安装失败了××××××××××××××××

换用另一种方式

sudo apt-get -f install

sudo apt-get install libxml2-dev

然后再装XML包,成功

其他装完了之后,用这两条命令:(注意sudo R进入)

source("https://bioconductor.org/biocLite.R")
biocLite("GEOquery")

graph需要BiocGenerics

这两个应当执行上面相同的步骤

最后再装SRAdb包


使用:

library(SRAdb)

srafile = getSRAdbFile() # downloads the most recent SRAdb database file and then connects to it from R

sra_con = dbConnect(SQLite(), srafile)

# unzipping会卡很久,不要着急

下一步又出现很奇怪的问题==

PS:其他使用

1. 查询

rs = getSRA(search_terms="breast cancer", out_types=c("study"),sra_con=sra_con)

SQLite的查询语句格式为fts3

http://www.sqlite.org/fts3.html

可以用head函数来查看结果

举个栗子:

rs <- getSRA(search_terms = ""breast cancer"", out_types = c("run","study"), sra_con = sra_con)

# 限制查询条件,这个是查词组breast cancer

# 然后我们用head函数来展示结果

2. SQLite数据库设计模式

 colDescriptions函数里有,也可以单独查看附件。

# 使用SQL语句来处理数据库。这里是对数据的整合。

rs <- dbGetQuery(sra_con, paste("SELECT library_strategy AS 'Library Strategy',",

"count(*) AS Runs FROM 'experiment'", "GROUP BY library_strategy order by Runs DESC", sep=""))

# 结果

×××××××××××××××××××××××××××××××××××××××××××××××××××××××

http://blog.csdn.net/tanzuozhev/article/details/51078460

http://bmcbioinformatics.biomedcentral.com/articles/10.1186/1471-2105-14-19

 
原文地址:https://www.cnblogs.com/pxy7896/p/6040470.html