我想将essemble ID与数据进行匹配,并想使用R将其替换为相应的ID

时间:2019-01-24 12:53:36

标签: r merge match

在这里, 我有两个数据集 1. TABLE2 ----看起来像

essemble    Entry   Entry name
ENSP00000011292 P15085  CBPA1
ENSP00000166534 O15460  P4HA2
ENSP00000179259 Q9NQ88  TIGAR
ENSP00000196061 Q02809  PLOD1
ENSP00000196371 P55809  SCOT1
ENSP00000205402 P09622  DLDH
ENSP00000216780 Q16822  PCKGM
ENSP00000216951 P48637  GSHB
ENSP00000217961 P08842  STS
ENSP00000221476 P06732  KCRM
ENSP00000222673 Q02218  ODO1
ENSP00000223127 O60568  PLOD3
ENSP00000226253 P09972  ALDOC
ENSP00000226299 P28838  AMPL
  1. TABLE1-第二个数据集看起来像

9606.ENSP00000011292 9606.ENSP00000011292 9606.ENSP00000011292 9606.ENSP00000166534 9606.ENSP00000166534 9606.ENSP00000196371 9606.ENSP00000196371 9606.ENSP00000196371 9606.ENSP00000196371 9606.ENSP00000196371 9606.ENSP00000196371 9606.ENSP00000196371 9606.ENSP00000196371 9606.ENSP00000205402 9606.ENSP00000205402 9606.ENSP00000205402 9606.ENSP00000205402 9606.ENSP00000216780 9606.ENSP00000216780 9606.ENSP00000216780 9606.ENSP00000216780 9606.ENSP00000216780 9606.ENSP00000216780 9606.ENSP00000216951 9606.ENSP00000216951

我的查询是--- 我想将TABLE2数据与Table1数据放置在一起,在其中我想用TABLE1中的条目名称替换TABLE2中的ID

我尝试合并选项,但是由于数据中存在重复的ID,因此无法正常工作。我使用循环但无法正常工作 代码是---

TABLE2 = unite(uniprot_EN_recon_protein, ess, c("h" , "essemble"), sep = ".", remove = TRUE)
ess_id = TABLE2[,1]
prot_name = TABLE2[,3]


result = data.frame(length(TABLE1))
for(i in 1:length(maine))
{
  c = TABLE1[i]
  d = grep(c  , ess_id)
  if(length(d) != 0)
  {

  result[i,1] = prot_name[d]
  }

}

提前致谢

0 个答案:

没有答案