This is a test version of Biostars. For the public version, visit https://www.biostars.org.
How to retrieve all variants for a gene using myvariant.info?

I really like the information that the myvariant.info tool can provide, namely annotating the SNPs within genes.

I would like to retrieve all of the annotations for a handful of individual genes in R.

For instance, in the example API url http://myvariant.info/v1/query/?q=dbnsfp.genename:BTK can retrieve info for 10 variants (hits). But I know there are 5143 total SNPs in the database.

I was able to use this command for downloading 10 default hits

library(jsonlite)
json_data <- fromJSON("http://myvariant.info/v1/query/?q=dbnsfp.genename:BTK")

I thought using the fetch_all=TRUE would work but the following command to retrieve at least 1000 hits

json_data <- fromJSON("http://myvariant.info/v1/query/?q=dbnsfp.genename:BTK&fetch_all=TRUE")

but it gives me this error

Error in readBin(3L, raw(0), 32768L) : 
  transfer closed with outstanding read data remaining

so my post boils down to 1 or 2 questions depending on if they can be done together:

  1. How can I access all the variants (hits) for a given gene?

  2. How can I download the results into R?

Thanks!

Update:

The following command retrieved 1000 variants just fine, but still looking to retrieve ALL variants.

json_data <- fromJSON("http://myvariant.info/v1/query/?q=BTK&fetch_all=TRUE")
myvariant.info snp annotation genome gene

1 answer

Use the myvariant package to fetch data from myvariant.info.

Log in to answer this question.