This is a test version of Biostars. For the public version, visit https://www.biostars.org.
Is there a package that outputs gene coordinates given a list of Ensembl IDs?

I need the gene coordinates (CHR, START, END) for a list of genes. I have the Ensembl IDs, but I have over 200 genes. I have been going to NCBI and Ensembl and entering the Ensembl IDs manually. Is there a software package out there that can do this? Biopython and Pyensembl don't seem to have straight-forward options for this and the websites don't seem to accept lists.

Ex:

Gene ID Ensembl ID CHR Start End

ITGA2B ENSG00000005961 chr17 44372180 44389649

ensembl biopython gene

2 answers

You can query Ensembl from within R using biomaRt:

library(biomaRt)

# the mart, so-to-say the "universe", here H.Sapiens
mymart <- useMart(biomart = "ensembl", dataset = "hsapiens_gene_ensembl")

# list everything that this mart offers
attrs  <- listAttributes(mart = mymart)

#/ two example genes:
wanted <- c("ENSG00000066336", "ENSG00000102145")

# retrieve the data for these genes:
genes <- biomaRt::getBM(attributes = c("ensembl_gene_id", "chromosome_name", "start_position", "end_position"),
                        mart = mymart, 
                        filters = "ensembl_gene_id", 
                        values = wanted)

> genes
  ensembl_gene_id chromosome_name start_position end_position
1 ENSG00000066336              11       47354860     47378547
2 ENSG00000102145               X       48786562     48794311

Using EntrezDirect:

$ esearch -db gene -query "ENSG00000005961" | efetch | grep Annotation | awk -F ":" '{print $2}'
 Chromosome 17 NC_000017.11 (44372181..44389649, complement)

Use a loop to get them all.

Log in to answer this question.