This is a test version of Biostars. For the public version, visit https://www.biostars.org.
RNA-SEQ count matrix: conversion of ensemble transcript ID to gene ID

Hello all, I would like to do DEG analysis on my count matrix using DESEQ2 package in R. My reads are in Ensembl Transcript ID and I know that I need to convert them to gene ID and sum up the reads belonging to the same gene before DEG, I know the package tximport for kalisto files but I have never done such directly from count matrix. Does anyone have some experience to share that how can I proceed?

Thanks a lot! p.s. the species is mmusculus (mouse)

rna-seq deseq2 r id conversion

1 answer

The following is an example code for annotations using AnnotationDbi R package. Change res to the DESeq result object and the annotation file org.Mm.eg.db to the desired organism.

library("AnnotationDbi")
#source("https://bioconductor.org/biocLite.R")
#biocLite("org.Mm.eg.db")
#Mouse annotations
library("org.Mm.eg.db")
#columns(org.Mm.eg.db)
res$symbol = mapIds(org.Mm.eg.db,
                    keys=row.names(res), 
                    column="SYMBOL",
                    keytype="ENSEMBL",
                    multiVals="first")
res$name =   mapIds(org.Mm.eg.db,
                    keys=row.names(res), 
                    column="GENENAME",
                    keytype="ENSEMBL",
                    multiVals="first")
write.table(res,file='res_with_annotation.tsv', sep ="\t",quote = F)

Thanks a lot! I will try it out to see the results !!

Hi again! thanks a lot ! but this package only converts ensemble gene IDs to gene symbol but I have a ensemle transcript IDs and I also need to sum them up if they belong to the same gene. Do you have any other suggestions?

Then a better idea will be to fetch them from reference GTF file.

Log in to answer this question.