ensemble transcript ID to gene symbol using pybiomart
1
2
Entering edit mode
5.0 years ago
Quak ▴ 520

I am working with STRING protein interaction data where each nodes are ensembl protein ID as following

ENSP00000272298
ENSP00000253401
ENSP00000401445
ENSP00000418915
ENSP00000327801
ENSP00000466298
ENSP00000232564
ENSP00000393379
ENSP00000371253
ENSP00000373713

I wonder how I can convert them into gene symbol in python ? if you don't recommend, how I can convert my gene symbols into ensembl protein IDs ?

I know I can use the mygene in python

import mygene
mg = mygene.MyGeneInfo()

and convert gene symbols into ensembl genes, but I wonder how can tweak this to have protein id instead

result = mg.query("APOE", scopes='symbol', fields=['ensembl'], species="human")

for hit in result["hits"]:
     if "ensembl" in hit and "gene" in hit["ensembl"]:
          print(hit["ensembl"]["gene"])

I have tried biomart through python

from pybiomart import Server

server = Server(host='http://www.ensembl.org')

dataset = (server.marts['ENSEMBL_MART_ENSEMBL']
                 .datasets['hsapiens_gene_ensembl'])

dataset.query(attributes=['ensembl_gene_id', 'ensembl_transcript_id', 'ensembl_peptide_id'],
              filters={'ensembl_transcript_id': ['ENSP00000371253']})

how ever the error I get is

BiomartException: Unknown filter ensembl_transcript_id, check dataset filters for a list of valid filters.

and there is no other relevant as far as I see. I also couldn't find examples in python, and this is the most relevant one in R

ensembl protein symbol id gene • 5.4k views
ADD COMMENT
0
Entering edit mode

Have you tried other utilities, such as eutils or biomart?

ADD REPLY
0
Entering edit mode

just added to the question !

ADD REPLY
1
Entering edit mode

The ensembl_peptide_id that you have used is a valid filter, so is the ensembl_transcript_id (I checked using biomaRt). Unless the python API is inferior to the R api, I think things should work. You can check using the show_filters() method.

ADD REPLY
1
Entering edit mode

It looks like it is the python API problem !! thanks for the confirmation. I do get the result in R but that filter does not exist in the python API.

ADD REPLY
2
Entering edit mode
5.0 years ago
Emily 24k

The easiest way is the Ensembl REST API, which allows language agnostic access to Ensembl data. There's an online course on using the API in Python, R or Perl.

ADD COMMENT
0
Entering edit mode

How would you do this using the Ensembl REST API?

ADD REPLY
0
Entering edit mode

You can do this using the Lookup endpoints, e.g: http://rest.ensembl.org/documentation/info/lookup

ADD REPLY

Login before adding your answer.

Traffic: 1361 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6