library(biomaRt)
options(stringsAsFactors=F)
human <- useMart("ensembl", dataset = "hsapiens_gene_ensembl")
mouse <- useMart("ensembl", dataset = "mmusculus_gene_ensembl")
mouse.genes <- read.table('color.signatures.txt',sep='\n',header=F)
geneset <- strsplit(mouse.genes[3,],split='\t')[[1]]
###鼠-->人
genes.map = getLDS(mart=mouse, attributes=c("mgi_symbol"), filters="mgi_symbol", values=geneset[c(-1,-2)], attributesL=c("hgnc_symbol"), martL=human, uniqueRows=T)
write.table(genes.map,"mouse.to.human.genes.csv",row.names=F,col.names=T,quote=F)
鑒于biomaRt經常報錯岳锁,推薦使用gprofiler2
library(gprofiler2)
genes.map <- gorth(query=rownames(gene.max.FC), source_organism="mmusculus", target_organism="hsapiens", numeric_ns="ENTREZGENE_ACC")
genes.map <- genes.map[complete.cases(genes.map), ]
genes.map <- genes.map[, c('input','ortholog_name')]
clusterProfiler實現同一物種間不同gene名稱之間的轉換
library(org.Hs.eg.db)
library(clusterProfiler)
rm(list=ls())
geneset <- bitr(geneset, fromType="ENTREZID",toType=c( "SYMBOL"),OrgDb = org.Hs.eg.db)$SYMBOL
AnnotationDbi實現同一物種間不同gene名稱之間的轉換
symbol <- mapIds(org.Hs.eg.db,
keys=ens.str,
column="SYMBOL",
keytype="ENSEMBL",
multiVals="first")
entrez <- mapIds(org.Hs.eg.db,
keys=ens.str,
column="ENTREZID",
keytype="ENSEMBL",
multiVals="first")