问题描述
我目前正在使用 R 包 seqinr 中的函数 read.fasta()
.
我认为创建索引文件已经使读取速度更快,但我想知道是否已经有另一个函数可以更快地加载它?
I am currently using the function read.fasta()
from the R package seqinr.
I think that creating an index file already make the reading faster but I was wondering if there was already another function to load it faster ?
我从 PopGenome 中寻找函数 read.big.fasta()
,但该包已从 CRAN 和 Bioconductor 中删除,所以我不再那么确定了.有什么建议吗?
I looked for the function read.big.fasta()
from PopGenome, but the package has been removed from CRAN and Bioconductor, so I am not so sure about it anymore.Any advices?
推荐答案
您可以使用 Biostrings
中的 readDNAStringSet
.
You can use readDNAStringSet
from Biostrings
.
获取人类基因组:download.file("https://hgdownload.soe.ucsc.edu/goldenPath/hg38/bigZips/hg38.fa.gz","../Downloads/test.fa.gz")
Get the human genome: 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 中加载 FASTA 文件比使用 seqinr 中的 read.fasta() 更快的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!