在 R 中加载 FASTA 文件比使用来自 seqinr 的 read.fasta() 更快
Loading FASTA file in R faster than when using read.fasta() from seqinr
我目前正在使用 R 包 seqinr 中的函数 read.fasta()
。
我认为创建索引文件已经使读取速度更快,但我想知道是否已经有另一个函数可以更快地加载它?
我从 PopGenome 寻找函数 read.big.fasta()
,但是这个包已经从 CRAN 和 Bioconductor 中删除,所以我不再那么确定了。
有什么建议吗?
您可以使用 Biostrings
中的 readDNAStringSet
。
获取人类基因组:
download.file("https://hgdownload.soe.ucsc.edu/goldenPath/hg38/bigZips/hg38.fa.gz","../Downloads/test.fa.gz")
使用readDNAStringSet
或read.fasta
:
f1 = function(){readDNAStringSet("../Downloads/test.fa.gz")}
f2 = function(){read.fasta("../Downloads/test.fa.gz")}
library(Biostrings)
library(seqinr)
microbenchmark::microbenchmark(f1(),times=5)
Unit: seconds
expr min lq mean median uq max neval
f1() 42.82203 43.57036 45.10369 45.64206 46.37412 47.10987 5
microbenchmark::microbenchmark(f1(),times=5)
### did not finish running
### so definitely not the option for large fasta files
我目前正在使用 R 包 seqinr 中的函数 read.fasta()
。
我认为创建索引文件已经使读取速度更快,但我想知道是否已经有另一个函数可以更快地加载它?
我从 PopGenome 寻找函数 read.big.fasta()
,但是这个包已经从 CRAN 和 Bioconductor 中删除,所以我不再那么确定了。
有什么建议吗?
您可以使用 Biostrings
中的 readDNAStringSet
。
获取人类基因组: download.file("https://hgdownload.soe.ucsc.edu/goldenPath/hg38/bigZips/hg38.fa.gz","../Downloads/test.fa.gz")
使用readDNAStringSet
或read.fasta
:
f1 = function(){readDNAStringSet("../Downloads/test.fa.gz")}
f2 = function(){read.fasta("../Downloads/test.fa.gz")}
library(Biostrings)
library(seqinr)
microbenchmark::microbenchmark(f1(),times=5)
Unit: seconds
expr min lq mean median uq max neval
f1() 42.82203 43.57036 45.10369 45.64206 46.37412 47.10987 5
microbenchmark::microbenchmark(f1(),times=5)
### did not finish running
### so definitely not the option for large fasta files