I've modified the getBM() function in biomaRt to submit queries in batches if the number of values exceeds 500. If you have multiple filters each of which have more than 500 values it should generate multiple mutually exclusive queries so that all combinations are run without breaking the 500 value limit. All of this is done internally, so existing biomaRt scripts shouldn't need to be changed. It will also display a progress bar so you can tell it is still proceeding. This is available from biomaRt version 2.33.1
If anyone finds any issues with this, please let me know.
You can test the code with the following example:
library(biomaRt)
ensembl <- useMart("ensembl", dataset = "hsapiens_gene_ensembl" )
Download a list of 20,000 Uniprot/TrEMBL IDs to use as our query values, and then submit the biomaRt query.
protein_ids <- read.table("http://msmith.de/data/20k_uniprot_ids.txt",
header = TRUE,
stringsAsFactors = FALSE,
sep = "\t")
GO_terms <- getBM(attributes = c("uniprotsptrembl",
"go_id",
"name_1006",
"namespace_1003",
"go_linkage_type"),
filters = c('uniprotsptrembl'),
values = protein_ids,
mart = ensembl)
If we run this with the current release version, we see that ~8% of the protein IDs were silently dropped from the return:
> packageVersion("biomaRt")
[1] ‘2.32.0’
> table(protein_ids[,1] %in% GO_terms$uniprotsptrembl)
FALSE TRUE
1618 18382
Using the devel version this no longer happens:
> packageVersion("biomaRt")
[1] ‘2.33.1’
> table(protein_ids[,1] %in% GO_terms$uniprotsptrembl)
TRUE
20000
I added code markup to your post for increased readability. You can do this by selecting the text and clicking the 101010 button. When you compose or edit a post that button is in your toolbar, see image below: