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"