Here's an example I originally posted to BioStars. If you already have the allele information you can drop that from the attributes.
library(biomaRt)
## Use the default ENSEMBL Variation Mart & Human dataset
snpMart = useEnsembl(biomart = "snps",
dataset = "hsapiens_snp")
## Create an example set of coordinates as a dataframe
SNP_M <- data.frame(CHR = c(1,1), START = c(10020, 10039), END = c(10020, 10039))
## Combine these into the format chr:start:end
## It's important to include the end even if it's a single base,
## otherwise it searches to the end of the chromosome
coords <- apply(SNP_M, 1, paste, collapse = ":")
coords
#> [1] "1:10020:10020" "1:10039:10039"
## Submit the query
getBM(attributes = c('refsnp_id', 'chr_name', 'chrom_start', 'chrom_end', 'allele'),
filters = c('chromosomal_region'),
values = coords,
mart = snpMart)
#> refsnp_id chr_name chrom_start chrom_end allele
#> 1 rs775809821 1 10020 10021 AA/A
#> 2 rs978760828 1 10039 10039 A/C
Hello!! Do you know if there is any package I can use to do the very same thing but with chromossome coordenates on build hg19?
Use the same one, only an archive site.
Also, please don't add comments to three year old posts. If you have a question please make a new post.