Is there any API where I can input chromosome location and it will provide us gene names, for example input chr: 1 location 154714693:154754070 and it will return a list of gene names or ID within this region?
-
$\begingroup$ Do you just want the gene names? BioPython will allow you to subset a Genbank sequence, complete with all the features if you specify a start and end coordinate, but this is only useful if you want more than the name. $\endgroup$– Joe HealeyCommented Aug 11, 2017 at 23:46
3 Answers
With R biomaRt you can retrieve them.
library(biomaRt)
ensembl = useMart("ensembl",dataset="hsapiens_gene_ensembl")
filterlist <- list("1:154714693:154754070","protein_coding")
genes <- getBM(attributes=c('hgnc_symbol', 'chromosome_name', 'start_position', 'end_position'), filters = c("chromosomal_region","biotype"),values = filterlist, mart = ensembl)
genes
hgnc_symbol chromosome_name start_position end_position 1
KCNN3 1 154697455 154870280
-
$\begingroup$ Thanks! This is exactly what I was looking for. Can I specify Genome Build GRCh38.p0, Genome Name GRCh38.d1.vd1 in th query? Could you the link for the documentation? I can not find it for how to do more custom query. $\endgroup$ Commented Aug 12, 2017 at 20:54
-
$\begingroup$ Great! The user guide is here, but since there is so much you can do with biomaRt sometimes you'll have to search the web for specific tricks (the code above is partly from scripts from internet and partly from my own scripts). The latest version of biomaRt is using GRCh38.p10, I don't know if that differs much from your versions. $\endgroup$– user35628Commented Aug 12, 2017 at 21:48
The NCBI as an API called 'E-utilities' (see short intro) that allows access to almost all their databases. It's a bit tricky to get used to it (and sometimes it wants stupid - even discontinued - identifiers as input), but has a lot of power, there are libraries for this in biopython & bioperl (I think), R might have one too. It's possible to exactly the kind of search you want with the 'efetch' method and rettype 'feature table' (or maybe the full xml record) as well as seq start and stop (you need to have the accession of the chromsome one sequence as a qurey ID).
Another thing I have used are genome annotation tables from NCBI. They are on the FTP server (where the structure is apparently in constant flux, so it's again hard to find), but they list all annotations of a given genome assembly and are sorted by position, so you can easily search them with a script - if you are looking for multiple positions this may well be faster then going through an online API (This folder seems to have multiple files, if you want to take a look at it).
You can use the Ensembl REST API. This is how to do overlap queries: https://rest.ensembl.org/documentation/info/overlap_region
Your example query: https://rest.ensembl.org/overlap/region/human/1:154714693:154754070?feature=gene;content-type=application/json