好物分享——R語(yǔ)言版本的bedtools

不要重復(fù)造輪子

——“哈嘍,能請(qǐng)教你一下怎樣在R server中調(diào)用Linux下的工具?”
——“你為什么要這么做呢?”
——“我想把Linux工具輸出的結(jié)果直接在R中分析,不想換來(lái)?yè)Q去”

bedtools是一個(gè)非常香的工具,幾乎是人盡皆知,是一個(gè)強(qiáng)大的處理bed等文件的工具,正如其自己描述的一樣:a powerful toolset for genome arithmetic。bedtools目前只支持在Linux下以命令行的形式運(yùn)行,所以我們經(jīng)常會(huì)遇到上面的問(wèn)題。

那么如何解決呢?給大家分享一個(gè)好物,既然我們不想在Linux下運(yùn)行bedtools,那為什么不在R下運(yùn)行呢?感謝北卡羅來(lái)納大學(xué)教堂山分校的Phanstiel Lab給了我們這樣的機(jī)會(huì),開發(fā)出了R下的bedtools——bedtoolsr不過(guò),有喜必有悲,看下面這句話:
bedtoolsr should work on any system with R and bedtools installed. It has been tested on macOS (version 10.14 "Mojave") and Linux (Ubuntu version 18.04). bedtools is not available for Windows; however, you can either use a virtual machine or Windows Subsystem for Linux. In either case, R from the Windows side would not be able to access bedtools running on the Linux side, so R and bedtoolsr would also have to be installed on the Linux side.

這意味著這個(gè)工具必須要R和Linux下的bedtools,否則將無(wú)法工作!所以我推薦在R server下使用了~

安裝

#install.packages("devtools")
library(devtools)
devtools::install_github("PhanstielLab/bedtoolsr")

使用示例

bedtools intersect ~ bt.intersect

bedtools intersect的功能不用多介紹,直接上圖:

bedtools intersect

這個(gè)圖到處都能見到,還不知道的朋友可以去隨便查查bedtools intersect是干嘛的,你一定會(huì)覺得非常有用,那么這個(gè)功能對(duì)應(yīng)R包bedtoolsr中的函數(shù)就是bt.intersect。

?bt.intersect
bt.intersect(
  a,
  b,
  wa = NULL,
  wb = NULL,
  loj = NULL,
  wo = NULL,
  wao = NULL,
  u = NULL,
  c = NULL,
  C = NULL,
  v = NULL,
  ubam = NULL,
  s = NULL,
  S = NULL,
  f = NULL,
  F = NULL,
  r = NULL,
  e = NULL,
  split = NULL,
  g = NULL,
  nonamecheck = NULL,
  sorted = NULL,
  names = NULL,
  filenames = NULL,
  sortout = NULL,
  bed = NULL,
  header = NULL,
  nobuf = NULL,
  iobuf = NULL,
  output = NULL
)

這不是和bedtools intersect功能選項(xiàng)幾乎一模一樣?
這里還是用官網(wǎng)的示例數(shù)據(jù)來(lái)做,主要是想輸出有交集的染色體坐標(biāo)區(qū)間及相交區(qū)域的大?。?/p>

#build bed files
A.bed <- data.frame(chrom=c("chr1", "chr1"), start=c(10, 30), end=c(20, 40))
B.bed <- data.frame(chrom=c("chr1"), start=15, end=20)
#bedtools intersect ~ bt.intersect
bedtoolsr::bt.intersect(a = A.bed, b = B.bed, wo = T)
#output
    V1 V2 V3   V4 V5 V6 V7
1 chr1 10 20 chr1 15 20  5

更多的功能就待大家去探索了~把這個(gè)包支持的函數(shù)全部列在下面了,對(duì)應(yīng)bedtools的工具找就好了!


bedtoolsr

今天又是摸魚的一天!

?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時(shí)請(qǐng)結(jié)合常識(shí)與多方信息審慎甄別。
平臺(tái)聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡(jiǎn)書系信息發(fā)布平臺(tái),僅提供信息存儲(chǔ)服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

友情鏈接更多精彩內(nèi)容