簡體   English   中英

查詢區域內的基因

[英]Query genes within regions

我想檢索一系列區域中存在的基因。 說,我有一個帶有查詢位置的床文件,例如:

1     2665697     4665777      MIR201
1    10391435    12391516      MIR500
1    15106831    17106911      MIR122
1    23436535    25436616      MIR234 
1    23436575    25436656      MIR488

我想得到那些區域內的基因。

我嘗試使用biomaRtbedtools相交,但是我得到的輸出是對應於所有區域的基因列表,而不是一一對應,因為我希望獲得的期望輸出將是每一行中的基因,但是在單獨的行中,如果我一次只執行一個查詢區域。 基本上,我想知道哪些基因屬於每個區域,但仍然能夠識別哪些基因屬於哪些區域。

我正在做的是,從檢測到的miRNA區域向上和向下擴展基因組區域,以便從該miRNA中獲得鄰近的基因。 我正在上下使用一百萬個基本窗口。 這僅對一個查詢有效,但是如何使用biomaRt進行許多查詢或與bedtools進行許多交集,所以我得到的結果類似於:

1     2665697     4665777      MIR201      GENEX, GENEY, GENEZ...
1    10391435    12391516      MIR500      GENEA, GENEB, GENEC...
1    15106831    17106911      MIR122
1    23436535    25436616      MIR234 
1    23436575    25436656      MIR488

這意味着GENEX,GENNEY和GENEZ落在1:2665697-4665777之內,而MIR201位於中間,因為計算該區域會減去100萬bp的sart,並向末端增加100萬bp。

我正在確定每個miRNA的鄰近基因,以便在物種中進行比較,但是我不知道如何使用biomaRtbedtool分別查詢多個區域。

有什么幫助嗎?

您可以嘗試biomarttidyverse解決方案

library(biomaRt)
library(tidyverse)
# specify the database
ensembl = useMart("ensembl",dataset="hsapiens_gene_ensembl")

# queries per row
res <- d %>% 
  split(1:nrow(.)) %>% 
  map(~getBM(attributes=c("external_gene_name", "chromosome_name", "start_position", "end_position"), 
             filters = c("chromosome_name" , "start", "end"), 
             values = list(.$V1, .$V2, .$V3), 
             mart = ensembl))


# plot the results for the first element to check the overlapping genes
plot(data.frame(unlist(d[1, 2:3]), nrow(res$`1`)), type="l", col=2, lwd =3,
     ylim = c(0, nrow(res$`1`)),
     xlim=unlist(d[1, 2:3])+c(-100000,100000))
res$`1` %>% 
  gather(k,v,-external_gene_name,-chromosome_name) %>% 
  arrange(external_gene_name) %>% 
  mutate(n=rep(1:(n()/2),each=2)) %>% 
  split(.$n) %>% 
  map(~with(.,lines(cbind(v, n), type="l", lwd =3)))

在此處輸入圖片說明

# transform the data in your expected data.frame
res %>% 
  map(~transmute(.,new=paste(external_gene_name, collapse="," )) %>% 
        slice(1)) %>% 
  bind_rows() %>% 
  bind_cols(d,.) %>% 
  as.tibble()
# A tibble: 5 x 5
     V1       V2       V3    V4    new                                                                                                               
  <int>    <int>    <int> <fct>  <chr>                                                                                                             
1     1  2665697  4665777 MIR201 TTC34,AC242022.1,AL592464.2,AL592464.1,AL589702.1,ACTRT2,LINC00982,PRDM16,MIR4251,AL008733.1,AL512383.1,AL590438.~
2     1 10391435 12391516 MIR500 AL139424.2,PGD,AL139424.1,CENPS-CORT,CENPS,CORT,DFFA,AL354956.1,PEX14,RN7SL614P,CASZ1,AL139423.1,HSPE1P24,C1orf12~
3     1 15106831 17106911 MIR122 KAZN,TMEM51-AS1,TMEM51,C1orf195,AL035405.1,AL391094.1,FHAD1,AL031283.2,AL031283.3,AL031283.1,EFHD2,CTRC,CELA2A,CE~
4     1 23436535 25436616 MIR234 ASAP3,E2F2,AL021154.1,ID3,MDS2,AL451000.1,RPL11,ELOA,ELOA-AS1,PITHD1,LYPLA2,GALE,HMGCL,FUCA1,CNR2,BTBD6P1,AL59060~
5     1 23436575 25436656 MIR488 ASAP3,E2F2,AL021154.1,ID3,MDS2,AL451000.1,RPL11,ELOA,ELOA-AS1,PITHD1,LYPLA2,GALE,HMGCL,FUCA1,CNR2,BTBD6P1,AL59060~

如果您需要所有數據,也可以嘗試使用purrr解決方案。 優點:biomart的輸出存儲在列表中,不會丟失。

d %>% 
  nest(-V4) %>% 
  mutate(biomart=map(data, ~getBM(attributes=c("external_gene_name", "chromosome_name", "start_position", "end_position"), 
             filters = c("chromosome_name" , "start", "end"), 
             values = list(.$V1, .$V2, .$V3), 
             mart = ensembl)),  
           Genes = map(biomart, ~paste(.$external_gene_name, collapse = ","))) %>% 
  unnest(Genes, data)
# A tibble: 5 x 6
  V4     biomart                Genes                                                         V1     V2     V3
  <fct>  <list>                 <chr>                                                      <int>  <int>  <int>
1 MIR201 <data.frame [43 x 4]>  TTC34,AC242022.1,AL592464.2,AL592464.1,AL589702.1,ACTRT2,~     1 2.67e6 4.67e6
2 MIR500 <data.frame [72 x 4]>  AL139424.2,PGD,AL139424.1,CENPS-CORT,CENPS,CORT,DFFA,AL35~     1 1.04e7 1.24e7
3 MIR122 <data.frame [101 x 4]> KAZN,TMEM51-AS1,TMEM51,C1orf195,AL035405.1,AL391094.1,FHA~     1 1.51e7 1.71e7
4 MIR234 <data.frame [62 x 4]>  ASAP3,E2F2,AL021154.1,ID3,MDS2,AL451000.1,RPL11,ELOA,ELOA~     1 2.34e7 2.54e7
5 MIR488 <data.frame [62 x 4]>  ASAP3,E2F2,AL021154.1,ID3,MDS2,AL451000.1,RPL11,ELOA,ELOA~     1 2.34e7 2.54e7

@Jimbou相同,沒有tidyverse的方法

library(biomaRt)

# data
d <- read.table(text = "1     2665697     4665777      MIR201
1    10391435    12391516      MIR500
1    15106831    17106911      MIR122
1    23436535    25436616      MIR234 
1    23436575    25436656      MIR488")

# specify the database
ensembl = useMart("ensembl", dataset = "hsapiens_gene_ensembl")

# loop through rows, get genes, then paste with collapse,
# and finally bind back with data d.
res <- cbind(
  d,
  genes = apply(d, 1, function(i){
    x <- getBM(attributes=c("external_gene_name"), 
               filters = c("chromosome_name" , "start", "end"), 
               values = list(i[1], i[2], i[3]), 
               mart = ensembl)
    # keeping only 3 genes, as output is too long.
    # In your case remove below line
    x <- head(x, 3)

    # return genes, comma separated
    paste(x$external_gene_name, collapse = ",")
  })
)

res
#   V1       V2       V3     V4                       genes
# 1  1  2665697  4665777 MIR201 TTC34,AC242022.1,AL592464.2
# 2  1 10391435 12391516 MIR500   AL139424.2,PGD,AL139424.1
# 3  1 15106831 17106911 MIR122      KAZN,TMEM51-AS1,TMEM51
# 4  1 23436535 25436616 MIR234       ASAP3,E2F2,AL021154.1
# 5  1 23436575 25436656 MIR488       ASAP3,E2F2,AL021154.1

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM