R语言ENTREZID ID 转换 gene SYMBOL

library(data.table)
library(org.Hs.eg.db)
library(clusterProfiler)

setwd("example")
 
dt <- read.table("VanAllen.self_subtract", sep = "\t", header = T)
dt$geneid <- rownames(dt)

# transform id  
map_dt <- bitr(dt$geneid, fromType = "ENTREZID",toType = c( "SYMBOL"),OrgDb = org.Hs.eg.db)
dt_merge <- merge(map_dt,dt, by.y = "geneid", by.x = "ENTREZID")
rownames(dt_merge) <- dt_merge$SYMBOL
dt_merge$SYMBOL <- NULL
dt_merge$ENTREZID <- NULL

# write out
write.table(dt_merge, file = "example42.txt", sep = "\t", col.names = T, row.names = T, quote = F)

 

posted @ 2020-06-23 21:13  ywliao  阅读(7121)  评论(0编辑  收藏  举报