I am looking for a way to obtain SNP names from their coordinates (Chromosome:BP) - very much the reverse of the question answered here:


Example: I have identified that a SNP at position 64377836 on Chromosome 17 is associated with a certain factor in my analysis and would like to find out whether it has a SNP ID and what this ID is.

Manually, I can search databases for Chr17:64377836 and find rs668 - but I would like to find a way to do this automatically, preferably in R.

Is this possible in R - and if so, how?

  • $\begingroup$ in what format you already have your input data? Is it a table, VCF? plink? $\endgroup$
    – JRodrigoF
    Dec 8, 2022 at 12:09
  • $\begingroup$ In a table - but I could easily reformat it. $\endgroup$
    – Gux
    Dec 8, 2022 at 12:16

1 Answer 1


You can do this in R using the library biomaRt from Bioconductor. Here an example starting from a table with 3 columns: Chr, Start, End. Positions are assumed to be in GRCh38.

snpMart = useEnsembl(biomart = "snps", 
             dataset = "hsapiens_snp")

# assuming your table is tab-separated, with column names
myData <- read.table("myTable.txt", sep="\t", header=True)

coords <- apply(myData, 1, paste, collapse = ":")

# submit the query
getBM(attributes = c('refsnp_id', 'chr_name', 'chrom_start', 'chrom_end', 'allele'),
  filters = c('chromosomal_region'), 
  values = coords, 
  mart = snpMart)  



Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.