1

NCBI SRA データベースにアクセスし、ID のリストをクエリして、出力をマトリックスに保存しようとしています。

これを行うために Bioconductor の sradb パッケージを使用していますが、データベースにアクセスしてクエリを実行できるようになりましたが、非常に遅く、ループ出力を保存する方法がわかりませんでした。

ファイル GPL11154_GSMs.txt には、私が興味を持っている ID が含まれています。これは次のようになります。

GSM616127
GSM616128
GSM616129
GSM663427
GSM665037

私が今持っているものは、反復ごとに結果を更新します。

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

#connect to databasse
sqlfile <- getSRAdbFile()
sra_con <- dbConnect(SQLite(),sqlfile)


## lists all the tables in the SQLite database
sra_tables <- dbListTables(sra_con)
sra_tables


dbGetQuery(sra_con,'PRAGMA TABLE_INFO(study)')

## checking the structure of the tables
#dbListFields(sra_con,"experiment")
#dbListFields(sra_con,"run")



#read in file with sample IDs per platform
x <- scan("GPL11154_GSMs.txt", what="", sep="\n")
gsm_list <- strsplit(x, "[[:space:]]+")  # Separate elements by one or more whitepace
for (gsm in gsm_list){
  gsm_to_srr <- getSRA(search_terms = gsm, out_types = c("submission", "study", "sample","experiment", "run"), sra_con)
  print(gsm_to_srr)
  }
4

1 に答える 1

0

lapplyの代わりに使用してforloop、試してください:

res <- lapply(gsm_list, function(gsm){
  getSRA(search_terms = gsm,
         out_types = c("submission", "study",
                       "sample","experiment", "run"),
         sra_con) })

マニュアルから、getSRAdata.frame を返す必要があるため、resオブジェクトには data.frame のリストが含まれます。data.frames のリストを 1 つの data.frame に変換する必要がある場合は、この投稿でその方法を説明します。

于 2016-11-10T11:56:58.857 に答える