0
$\begingroup$

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

(https://stackoverflow.com/questions/20251612/map-snp-ids-to-genome-coordinates)

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?

$\endgroup$
2
  • $\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

2
$\begingroup$

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.

library(biomaRt)
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)  

Source

$\endgroup$

Your Answer

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

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