<p><strong>EDIT:</strong> Now fixed, using filters = c("chromosome_name","start","end","biotype") instead. Question still stands though if anyone knows?</p>

<p><strong>Original question:</strong>
I've written some code which I think should take chromosomal coordinates (e.g. X:1-200000) and return protein coding genes (e.g. PLCXD1 and LINC00108) within that region on NCBI36. </p>

<p>I'm happy for it to return a gene only partially spanning the region or only genes contained entirely within that region at this stage, but I have no idea what it is actually returning. </p>

<p>Here's some simplified code of what I'm doing:</p>

<pre><code>rm(list=ls())
library("biomaRt")
ensembl54=useMart("ENSEMBL_MART_ENSEMBL", host="may2009.archive.ensembl.org/biomart/martservice/", dataset="hsapiens_gene_ensembl")

chr.region = c("18:19092052-30289323","16:77462979-77500915","X:146419715-146584279","4:32776556-33393589","2:187947442-188506618")

entrez.ids=vector() 
entrez.count=vector()
all.results=data.frame() 

for (i in 1:length(chr.region)){
  filterlist=list(chr.region[i],"protein_coding")

  results=getBM(attributes = c("hgnc_symbol","entrezgene", "chromosome_name", "start_position", "end_position"), 
               filters = c("chromosomal_region","biotype"), 
               values = filterlist, 
               mart = ensembl54)

  results$region = chr.region[i]
  all.results=rbind(all.results,results)

  ids=unique(results$entrezgene) 
  ids &lt;- ids[!is.na(ids)] 

  entrez.ids[i]=paste(ids, sep=",", collapse=",") 
  entrez.count[i]=unique(length(ids)) 
}

write.csv(all.results, file="all_results.csv",row.names=F)
</code></pre>

<p>Many thanks for any advice.</p>

<p>Hi the issue was that <code>chromosomal_region</code> should be given as <code>18:19092052:30289323</code> and not <code>18:19092052-30289323</code></p>

<p>try this you will get the results you want</p>

<p><code>filterlist &lt;- list("18:19092052:30289323","protein_coding")</code></p>

<p><code>results=getBM(attributes = c("hgnc_symbol","entrezgene", "chromosome_name", "start_position", "end_position"),filters = c("chromosomal_region","biotype"),values = filterlist, mart = ensembl54)</code></p>

<p>when you give incorrectly formatted chromosomal_region like  18:19092052-30289323  biomart takes the first value separated by ":" which in this case is 18 (chromosome) and returns all the protein coding genes on Chr.18</p>
