id转换

id转换

读取差异分析结果

rm(list = ls())
options(stringsAsFactors = F)
res <- read.csv(file="condition_tumor_results.csv",check.names = F,header = T,row.names = 1)
res <- na.omit(res)

得到一个基因list和logFC

dat <- data.frame(gene_id=rownames(res),logFC=res$log2FoldChange)
gtf <- read.table(file = "gtf.txt",sep = "\t",check.names = F,header = T)

新增基因这一列

dat$symbol <- gtf$gene_name[match(dat$gene_id,gtf$gene_id)]

得到基因的entrezid

library(clusterProfiler)
gsea = bitr(dat$symbol, 
                fromType="SYMBOL",
                toType="ENTREZID", 
                OrgDb="org.Hs.eg.db")
length(dat$symbol)
length(gsea$SYMBOL)
head(gsea )
gsea$logFC <- dat$logFC [match(gsea$SYMBOL,dat$symbol)]
save(gsea,file = "gesa input.Rdata")

你可能感兴趣的:(id转换)