下载安装包
options("repos"=c(CRAN="http://mirrors.tuna.tsinghua.edu.cn/CRAN/"))
options(BioC_mirror="http://mirrors.ustc.edu.cn/bioc/")
install.packages("BiocManager")
BiocManager::install("biomaRt")
library(biomaRt)
把自己想转换的人的基因名合并成建立一个向量
IDHTM <- c("MS4A1", # B cell
"GNLY", # NK
"CD3E",
"CD14",
"FCER1A",
"FCGR3A",
"LYZ",
"PPBP",
"CD8A" )
使用这个包的函数getLDS
human <-useMart("ENSEMBL_MART_ENSEMBL",dataset="hsapiens_gene_ensembl")
mouse <- useMart('ensembl',dataset = "mmusculus_gene_ensembl")
#网络问题Ensembl site unresponsive, trying asia mirror
#Error in curl::curl_fetch_memory(url, handle = handle) :
# Timeout was reached: [useast.ensembl.org:8443] Connection timed out after 10000 milliseconds
HumanToMm <- getLDS(attributes = c("hgnc_symbol"),
filters = "hgnc_symbol", values = IDHTM,#对应的要转换的基因名
mart = human,
attributesL = c("mgi_symbol"), martL = mouse)
运行后得到下面结果
有个问题是有个人的基因在这个库里没有找到 "GNLY";没有搞清楚什么原因,可能跟对应的库有关系
参考了下面
https://www.jianshu.com/p/0dbd5528ce3d
https://cloud.tencent.com/developer/article/1708373