Genomic Annotation Package Ensembl
1
0
Entering edit mode
Bine ▴ 20
@bine-23912
Last seen 5 days ago
Spain

Dear all,

I am reading the annotation for my dataset via Ensembl, which works well with library("AnnotationDbi") library("org.Hs.eg.db").

But now I need to know for each of my rows (genes) on which chromosome that gene is.. (in particular whether it is on the X-Chromosome or not).

Has anyone an idea how I could do that?

Thank you so much, Bine

Chromosome Annotation • 234 views
0
Entering edit mode
@james-w-macdonald-5106
Last seen 17 hours ago
United States

You use a TxDb or EnsDb package for that. You say 'dataset via Ensembl', which I am not sure I understand? Anyway, a simple, if naive way to do that would be

library(TxDb.Hsapiens.UCSC.hg38.knownGene)
gns <- genes(TxDb.Hsapiens.UCSC.hg38.knownGene, single.strand.genes.only = FALSE)
## assuming that you have NCBI Gene IDs
gns <- unlist(gns)[<vector of NCBI Gene IDs goes here, make sure it's character>]
chrlocs <- as.character(seqnames(gns))


And the chrlocs object now has the chromosome locations, in the same order as your Gene IDs.

0
Entering edit mode

Thank you James. Not sure what I am doing wrong but so far it is not working.

Before to get other annotations for my res- Object (Result Object created from DeSeq2 Package) I used

library("AnnotationDbi")
library("org.Hs.eg.db")
ens.str <- substr(rownames(res), 1, 15)
res\$symbol <- mapIds(org.Hs.eg.db,keys=ens.str,column="SYMBOL",keytype="ENSEMBL",multiVals="first")


Which worked fine, but unfortunately this way the chromosome information is not given. I meant earlier that I use Ensembl gene IDs. So when i got the previous information (Symbol for my gene) I used the Ensembl gene ID as a key.

How can I use your code with Ensembl gene IDs. In my case they are the rownames(res)?

Hope that is understandable.

0
Entering edit mode

I am currently trying the other package you mentionend maybe it is better for Ensembl IDs?

0
Entering edit mode

Does this help?

> z <- select(Homo.sapiens, head(keys(org.Hs.eg.db, "ENSEMBL")), c("SYMBOL","TXCHROM"), "ENSEMBL")
'select()' returned 1:1 mapping between keys and columns
> z
ENSEMBL   SYMBOL TXCHROM
1 ENSG00000121410     A1BG   chr19
2 ENSG00000175899      A2M   chr12
3 ENSG00000256069    A2MP1   chr12
4 ENSG00000171428     NAT1    chr8
5 ENSG00000156006     NAT2    chr8
6 ENSG00000196136 SERPINA3   chr14



Also, please format your posts by converting your code to code blocks. If you don't know how to do that (I fixed your last comment for you) then see the FAQ.