Answers.Body: <p>You can do this in R using the library <a href="https://bioconductor.org/packages/release/bioc/html/biomaRt.html" rel="nofollow noreferrer">biomaRt</a> from Bioconductor. Here an example starting from a table with 3 columns: Chr, Start, End. Positions are assumed to be in GRCh38.</p>
  <pre><code>library(biomaRt)
  snpMart = useEnsembl(biomart = &quot;snps&quot;, 
               dataset = &quot;hsapiens_snp&quot;)
  
  # assuming your table is tab-separated, with column names
  myData &lt;- read.table(&quot;myTable.txt&quot;, sep=&quot;\t&quot;, header=True)
  
  coords &lt;- apply(myData, 1, paste, collapse = &quot;:&quot;)
  
  
  # submit the query
  getBM(attributes = c('refsnp_id', 'chr_name', 'chrom_start', 'chrom_end', 'allele'),
    filters = c('chromosomal_region'), 
    values = coords, 
    mart = snpMart)  
  </code></pre>
  <p><a href="https://support.bioconductor.org/p/133105/" rel="nofollow noreferrer">Source</a></p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2022-12-08T14:54:17.223Z
Answers.LastActivityDate: 2022-12-08T14:54:17.223Z
Answers.UserDisplayName: JRodrigoF
Body: <p>I am looking for a way to obtain SNP names from their coordinates (Chromosome:BP) - very much the reverse of the question answered here:</p>
  <p>(<a href="https://stackoverflow.com/questions/20251612/map-snp-ids-to-genome-coordinates">https://stackoverflow.com/questions/20251612/map-snp-ids-to-genome-coordinates</a>)</p>
  <p><em>Example:</em> 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.</p>
  <p>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.</p>
  <p>Is this possible in R - and if so, how?</p>
  
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2022-12-08T12:09:59.617Z
Comments.Text: in what format you already have your input data? Is it a table, VCF? plink?
Comments.UserDisplayName: JRodrigoF
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2022-12-08T12:16:34.663Z
Comments.Text: In a table - but I could easily reformat it.
Comments.UserDisplayName: Gux
Tags: <r><gwas>
Title: Identify SNP from genetic position
ThreadText: # Identify SNP from genetic position
  
  (Asked by: username_0 on 2022-12-07)
  
  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?
  
  **Tags:** r, gwas
  
  > **Comments:**
  > **username_1**: in what format you already have your input data? Is it a table, VCF? plink?  
  > **username_0**: In a table - but I could easily reformat it.  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2022-12-08. Score: 2 | Accepted answer
  
  You can do this in R using the library [biomaRt](https://bioconductor.org/packages/release/bioc/html/biomaRt.html) 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](https://support.bioconductor.org/p/133105/)
  
  
  ---
  
  