Question: How can I retrieve the gene names of my count matrix?
0
gravatar for johnsonn573
21 months ago by
johnsonn5730 wrote:

I'm using the code below to create a matrix of counts. The resulting matrix has 25221 rows and I'm wondering how I can retrieve the gene names for each row. 

source("https://bioconductor.org/biocLite.R")

biocLite("TxDb.Hsapiens.UCSC.hg38.knownGene")
library("TxDb.Hsapiens.UCSC.hg38.knownGene")
biocLite("GenomicFeatures")
library("GenomicFeatures")
biocLite("Rsamtools",suppressUpdates=TRUE,suppressAutoUpdate=TRUE)
library("Rsamtools")

filenames=list.files()
bamfiles <- BamFileList(filenames, yieldSize=2000000)

txdb=TxDb.Hsapiens.UCSC.hg38.knownGene
ebg <- exonsBy(txdb, by="gene")
se <- summarizeOverlaps(features=ebg, reads=bamfiles,
                        mode="Union",
                        singleEnd=TRUE,
                        ignore.strand=TRUE)

counts=assay(se)

 

 

> head(rownames(counts))

[1] "1" "10" "100" "1000" "10000" "100008587"

ADD COMMENTlink modified 21 months ago by James W. MacDonald51k • written 21 months ago by johnsonn5730
Answer: How can I retrieve the gene names of my count matrix?
1
gravatar for James W. MacDonald
21 months ago by
United States
James W. MacDonald51k wrote:
library(org.Hs.eg.db)
geneNames <- mapIds(org.Hs.eg.db, rownames(counts), "SYMBOL","ENTREZID")

 

ADD COMMENTlink written 21 months ago by James W. MacDonald51k
Please log in to add an answer.

Help
Access

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.
Powered by Biostar version 16.09
Traffic: 192 users visited in the last hour