Get 'SNP' ('Single-Nucleotide' 'Polymorphism') Data on the Web

A programmatic interface to various 'SNP' 'datasets' on the web: 'OpenSNP' (< https://opensnp.org>), and 'NBCIs' 'dbSNP' database (< https://www.ncbi.nlm.nih.gov/projects/SNP>). Functions are included for searching for 'NCBI'. For 'OpenSNP', functions are included for getting 'SNPs', and data for 'genotypes', 'phenotypes', annotations, and bulk downloads of data by user.


cran checks Build Status Build status codecov.io cran version rstudio mirror downloads

rsnps used to be ropensnp

Data sources

This set of functions/package accesses data from:

Install

Install from CRAN

install.packages("rsnps")

Or dev version

install.packages("devtools")
devtools::install_github("ropensci/rsnps")
library("rsnps")

Using NCBI dbSNP data

SNPs <- c("rs332", "rs420358", "rs1837253", "rs1209415715", "rs111068718")
ncbi_snp_query(SNPs)
#>          Query Chromosome       Marker  Class Gene Alleles Major Minor
#> 1        rs332          7  rs121909001 in-del CFTR   -/TTT  <NA>  <NA>
#> 2     rs420358          1     rs420358    snp CFTR   A,G,T     A     G
#> 3    rs1837253          5    rs1837253    snp CFTR     C/T     C     T
#> 4 rs1209415715          9 rs1209415715    snp CFTR     C,T     C     T
#>      MAF        BP AncestralAllele
#> 1     NA 117559593            <NA>
#> 2     NA 117559593     T,T,T,T,T,T
#> 3 0.3822 117559593     T,T,T,T,T,T
#> 4     NA 117559593            <NA>

Using openSNP data

genotypes() function

genotypes('rs9939609', userid='1,6,8', df=TRUE)
#>    snp_name snp_chromosome snp_position                 user_name user_id
#> 1 rs9939609             16     53786615 Bastian Greshake Tzovaras       1
#> 2 rs9939609             16     53786615              Nash Parovoz       6
#> 3 rs9939609             16     53786615         Samantha B. Clark       8
#>   genotype_id genotype
#> 1           9       AT
#> 2           5       AT
#> 3           2       TT

phenotypes() function

out <- phenotypes(userid=1)
out$phenotypes$`Hair Type`
#> $phenotype_id
#> [1] 16
#> 
#> $variation
#> [1] "straight"

Meta

  • Please report any issues or bugs.
  • License: MIT
  • Get citation information for rsnsps in R doing citation(package = 'rsnps')
  • Please note that this project is released with a Contributor Code of Conduct. By participating in this project you agree to abide by its terms.

ropensci_footer

News

rsnps 0.3.0

DEPRECATED AND DEFUNCT

  • ld_search() is now defunct. The Broad Insitute has taken down the SNAP service behind the function. (#46) (#53) (#60)

NEW FEATURES

  • the three NCBI functions gain a new parameter key for passing in an NCBI Entrez API key. You can alteernatively (and we encourage this) store your key as an environment variable and we'll use that instead. The key allows you to have higher rate limits than without a key (#58)
  • gains new function ncbi_snp_summary() for summary data on a SNP (#31)

MINOR IMPROVEMENTS

  • http requests are now done using crul instead of httr (#44)
  • now using markdown formatted documentation (#56)
  • documented in ncbi_snp_query() that we can not change the assembly (#49)

BUG FIXES

  • fix to ncbi_snp_query2(): when many IDs passed in, we were failing with a "URI too long" message. We now check how many Ids are passed in and do a POST request as needed (#39)
  • fixed problem in ncbi_snp_query() where it wasn't pulling out correctly the gene name and BP position (#25)

rsnps 0.2.0

NEW FEATURES

  • LDSearch() is now ld_search(), but LDSearch() still works until the next CRAN release when it will be defunct (#33)
  • NCBI_snp_query() is now ncbi_snp_query(), but NCBI_snp_query() still works until the next CRAN release when it will be defunct (#33)
  • NCBI_snp_query2() is now ncbi_snp_query2(), but NCBI_snp_query2() still works until the next CRAN release when it will be defunct (#33)

MINOR IMPROVEMENTS

  • Namespace all base R package function calls (#21)
  • Improve httr::content call to parse to text, and encoding = "UTF-8" (#24)
  • Added tests for ld_search() (#12)
  • Added tests for ncbi_snp_query() and ncbi_snp_query2() (#13)
  • Added ancestral allele output to ncbi_snp_query() (#23)

BUG FIXES

  • Fix to fetch_genotypes(), was failing sometimes when the commented metadata lines at top varied in length (#22)
  • Fix to ld_search() (#32)

rsnps 0.1.6

MINOR IMPROVEMENTS

  • All examples now in \dontrun. (#11)
  • Added additional tests for LDSearch() and NCBI_snp_query().
  • Added a vignette.

BUG FIXES

  • Bugs fixed in LDSearch(), which were actually bugs in NCBI_snp_query(). (#9)
  • Bug fixed in NCBI_snp_query() as chromosome might also be "X".

rsnps 0.1.0

NEW FEATURES

  • Bug fixes to all openSNP functions.

rsnps 0.0.5

NEW FEATURES

  • released to CRAN

Reference manual

It appears you don't have a PDF plugin for this browser. You can click here to download the reference manual.

install.packages("rsnps")

0.3.0 by Scott Chamberlain, 9 months ago


https://github.com/ropensci/rsnps


Report a bug at https://github.com/ropensci/rsnps/issues


Browse source code at https://github.com/cran/rsnps


Authors: Scott Chamberlain [aut, cre] , Kevin Ushey [aut] , Hao Zhu [aut]


Documentation:   PDF Manual  


Task views:


MIT + file LICENSE license


Imports plyr, stringr, crul, data.table, XML, xml2, jsonlite

Suggests testthat, knitr


Suggested by solarius.


See at CRAN