前言
在使用kallisto等基于cDNA数据库注释软件时,获得的gene expression matrix的gene id是transcript id。后续在做数据分析时,需要将其转换成gene symbol。以下介绍两种转换方法。更多知识分享请到 https://zouhua.top/。
第一种方法
在GitHub上有人开发了可以做该种转换的R包, BUSpaRse提供的transcript2gene函数其实套用了biomart包的useMart函数获取了转录ID与基因ID的对应关系。它方便在直接使用,看起来较为清晰简单。
# devtools::install_github("BUStools/BUSpaRse")
library(BUSpaRse)
tr2g <- transcript2gene(
c("Homo sapiens", "Mus musculus"),
type = "vertebrate",
ensembl_version = 100,
kallisto_out_path = "./")

第二种方法
直接使用biomart包的useMart函数,在使用前我们先要提取参考基因组的基因ID,为后面基于该基因ID匹配到转录本ID做准备。
- 获取基因组的基因list
cat Homo_sapiens.GRCh38.101.gtf | awk -F'\t' '{if($3=="gene") {split($9,a,";"); print a[1]"\t"$5-$4};}' | sed 's/[gene_id |"|]//g' | sort -u > Homo_sapiens.GRCh38.101.genelength.tsv
- 获取基因ID与转录本ID对应关系表
library(biomaRt)
library(curl)
genelist <- read.table("Homo_sapiens.GRCh38.101.genelength.tsv", header = T)
human_mart <- useMart(host="www.ensembl.org",
biomart="ENSEMBL_MART_ENSEMBL",
dataset = "hsapiens_gene_ensembl")
human_gene_all <- getBM(attributes=c("ensembl_gene_id",
"entrezgene_id",
"external_gene_name",
"ensembl_transcript_id",
"ensembl_transcript_id_version",
"transcript_biotype",
"description"),
filters="ensembl_gene_id",
values = genelist$Geneid,
mart=human_mart)
Reference
参考文章如引起任何侵权问题,可以与我联系,谢谢。
网友评论