<blockquote>
  <p>it's not clear to me that it would support both versions of genome
  builds.</p>
</blockquote>

<p>You can specify what version of the database you are querying.</p>

<p>I'd start with biomart on the ensembl website, see if you can get it to do what you want, then work on getting biomaRt to do what you want.</p>

CC BY-SA 4.0
2019-09-23T19:20:46.777Z
https://www.ensembl.org/biomart/martview/ > CHOOSE DATASET > Ensembl Variation > I can't find any option for GRCh37, only 38
CelineDion
CC BY-SA 4.0
2019-09-23T19:37:02.290Z
The website might not have that enabled, but you can choose old versions in R.  snpmart = useEnsembl(biomart = "snp", dataset="hsapiens_snp", version = 90)
swbarnes2
CC BY-SA 4.0
2019-09-23T19:47:33.543Z
When I do that, the only datasets I can see with `listDatasets(snpmart)` are `GRCh38.p10`.
CelineDion
CC BY-SA 4.0
2019-09-23T19:50:58.687Z
Okay, I had to go all the way back to version 75 from Feb 2014 to get GRCh37. Thanks for your help.
CelineDion
CC BY-SA 4.0
2019-09-24T09:47:32.613Z
Don't use the e75 version of BioMart, it's really out of date. There's a dedicated GRCh37 version where the variation database has been updated. More info here: https://www.ensembl.org/info/data/biomart/biomart_r_package.html
Emily_Ensembl
CC BY-SA 4.0
2019-09-23T19:15:55.477Z
2019-09-23T19:15:55.477Z
swbarnes2
<p>rsIDs change with the dbSNP builds, not with the reference genome builds. rsIDs do not depend on a reference genome. They point to a specified locus regardless of the differences in genomic assemblies. rsIDs numbersare assigned by dbSNP database maintainers. The numbers may be deleted from database (e.g. when a submitter withdraw data) and may change on merges (e.g. when multiple rsIDs were assigned at the same genomic location).</p>
<p>Specifying the location by rsID is stable, and can be only affected by an eventual merge or deletion, if any, with a new dbSNP database build. It cannot be affected by a reference genome build.</p>
<p>However, a base position (offset) of a locus within a chromosome may change between the builds of the reference genome. So, when specifying the location by the chromosome and base position, the reference genome build should be also given, to locate an appropriate rsID.</p>
<p>You can download dbSNP database files (in VCF format) of the database build that was actual at a time when a specific build of a reference genome was also actual, but these files are huge. A possible place to download is <a href="https://ftp.ncbi.nih.gov/snp/pre_build152/organisms/" rel="nofollow noreferrer">https://ftp.ncbi.nih.gov/snp/pre_build152/organisms/</a> or <a href="https://ftp.ncbi.nih.gov/snp/archive/" rel="nofollow noreferrer">https://ftp.ncbi.nih.gov/snp/archive/</a></p>
<p>However, these files are arranged by the dbSNP database build (e.g. 152, 153, 154), not by the reference genome build (e.g. 37 or 38).</p>
<p>If your list is relatively small, you can fetch the data rs numbers via dbSNP API by chromosome and location. The API is available at <a href="https://www.ncbi.nlm.nih.gov/snp/docs/eutils_help/" rel="nofollow noreferrer">https://www.ncbi.nlm.nih.gov/snp/docs/eutils_help/</a></p>
<p>For instance, do “advanced search” of dbSNP at <a href="https://www.ncbi.nlm.nih.gov/snp/advanced" rel="nofollow noreferrer">https://www.ncbi.nlm.nih.gov/snp/advanced</a>
When it comes to search by the base position, you can only specify positions for GRCh37 (called “Base Position Previous”) and GRCh38 (“Base Position”). This URL will help you construct the request string that you will further use for the dbSNP API requests.</p>
<p>You may also need to add “NOT MergedRS[All Fields]” to exclude rsIDs that have already been merged. I wish I knew what to type instead of “All Fields” here to refine the search, but the documentation is very sparse.</p>
<p>In your examples, for <code>13_28025615_G_C_b37</code> specify Chromosome=13 and Base Position Previous=28025615 in the “Advanced Search”.</p>
<p>As about the API, for <code>13_28025615_G_C_b37</code> query <a href="https://eutils.ncbi.nlm.nih.gov/entrez/eutils/esearch.fcgi?db=snp&amp;term=13%5BChromosome%5D+AND+28025615%5BBase+Position+Previous%5D+NOT+MergedRS%5BAll+Fields%5D" rel="nofollow noreferrer">https://eutils.ncbi.nlm.nih.gov/entrez/eutils/esearch.fcgi?db=snp&amp;term=13[Chromosome]+AND+28025615[Base+Position+Previous]+NOT+MergedRS[All+Fields]</a></p>
<p>and for <code>chr22_50473581_G_A_b38</code> query <a href="https://eutils.ncbi.nlm.nih.gov/entrez/eutils/esearch.fcgi?db=snp&amp;term=22%5BChromosome%5D+AND+50473581%5BBase+Position%5D+NOT+MergedRS%5BAll+Fields%5D" rel="nofollow noreferrer">https://eutils.ncbi.nlm.nih.gov/entrez/eutils/esearch.fcgi?db=snp&amp;term=22[Chromosome]+AND+50473581[Base+Position]+NOT+MergedRS[All+Fields]</a></p>
<p>The first rsID that you will get will be the main current rsID, the others (if any) will be the merged ones.</p>
<p>Here is a small perl example on how to retrieve data from the dbSNP. The fetch_GRCh37 function returns the rsID for a given chromosome and base position. For GRCh38, remove the “+Previous” from the URL. You can call the fetch_GRCh37 in a script multiple times. It’s better that you get rsIDs for your both GRCh37 and GRCh38 data to make sure that you refer to the same rsIDs that are actual after eventual merges.</p>
<p>Please make sure to read and comply to the <a href="https://www.ncbi.nlm.nih.gov/books/NBK25497/#chapter2.Usage_Guidelines_and_Requiremen" rel="nofollow noreferrer">requirements</a> before using the API.</p>
<p>A sample Perl script snippet follows:</p>
<pre><code>use XML::LibXML;
use LWP::UserAgent;

sub fetch_GRCh37 {
        my <span class="math-container">$chromosome = $</span>_[0];
        my <span class="math-container">$basepos = $</span>_[1];
        my <span class="math-container">$url = 'https://eutils.ncbi.nlm.nih.gov/entrez/eutils/esearch.fcgi?db=snp&amp;term='.$</span>chromosome.'[Chromosome]+AND+'.<span class="math-container">$basepos.'[Base+Position+Previous]+NOT+MergedRS[All+Fields]';
        my $</span>UserAgent = new LWP::UserAgent ();
        my <span class="math-container">$GET = $</span>UserAgent-&gt;get(<span class="math-container">$url)-&gt;content;
        my $</span>dom = XML::LibXML-&gt;load_xml(string =&gt; <span class="math-container">$GET);
        my $</span>numberofnodes = int(<span class="math-container">$dom-&gt;findnodes('eSearchResult/Count')-&gt;to_literal());
        if ($</span>numberofnodes &gt; 0) {foreach my <span class="math-container">$title ($</span>dom-&gt;findnodes('eSearchResult/IdList/Id')){return(&quot;rs&quot;.$title-&gt;to_literal());}}
}

print fetch_GRCh37(13, 28025615);
</code></pre>

CC BY-SA 4.0
2020-08-20T20:10:12.247Z
2020-08-22T17:44:50.183Z
2020-08-22T17:44:50.183Z
Maxim Masiutin
<p>I have a long list of variant IDs that I generated as a result of research done one GRCh37 genomes (e.g. <code>13_28025615_G_C_b37</code>). I want to get their rsIDs and compare them to a newly-obtained list of GRCh38 rsIDs that have also been retrieved from similarly formatted variant IDs (e.g. <code>chr22_50473581_G_A_b38</code>). How would I go about doing this? I've tried installing <code>biomaRt</code> as a package but I can't quite make heads or tails of it and it's not clear to me that it would support both versions of genome builds. </p>

<variation><biomart>
Find rsIDs for GRCh37 SNPs and rsIDs for GRCh38 SNPs and compare for overlap
# Find rsIDs for GRCh37 SNPs and rsIDs for GRCh38 SNPs and compare for overlap

(Asked by: username_0 on 2019-09-23)

I have a long list of variant IDs that I generated as a result of research done one GRCh37 genomes (e.g. `13_28025615_G_C_b37`). I want to get their rsIDs and compare them to a newly-obtained list of GRCh38 rsIDs that have also been retrieved from similarly formatted variant IDs (e.g. `chr22_50473581_G_A_b38`). How would I go about doing this? I've tried installing `biomaRt` as a package but I can't quite make heads or tails of it and it's not clear to me that it would support both versions of genome builds.

**Tags:** variation, biomart

---

## 2 answers

### Answer by username_1 on 2019-09-23. Score: 3 | Accepted answer

> it's not clear to me that it would support both versions of genome
> builds.

You can specify what version of the database you are querying.

I'd start with biomart on the ensembl website, see if you can get it to do what you want, then work on getting biomaRt to do what you want.

> **Comments:**
> **username_0**: https://www.ensembl.org/biomart/martview/ > CHOOSE DATASET > Ensembl Variation > I can't find any option for GRCh37, only 38  
> **username_1**: The website might not have that enabled, but you can choose old versions in R.  snpmart = useEnsembl(biomart = "snp", dataset="hsapiens_snp", version = 90)  
> **username_0**: When I do that, the only datasets I can see with `listDatasets(snpmart)` are `GRCh38.p10`.  
> **username_0**: Okay, I had to go all the way back to version 75 from Feb 2014 to get GRCh37. Thanks for your help.  
> **username_2**: Don't use the e75 version of BioMart, it's really out of date. There's a dedicated GRCh37 version where the variation database has been updated. More info here: https://www.ensembl.org/info/data/biomart/biomart_r_package.html  

---

### Answer by username_3 on 2020-08-20. Score: 2

rsIDs change with the dbSNP builds, not with the reference genome builds. rsIDs do not depend on a reference genome. They point to a specified locus regardless of the differences in genomic assemblies. rsIDs numbersare assigned by dbSNP database maintainers. The numbers may be deleted from database (e.g. when a submitter withdraw data) and may change on merges (e.g. when multiple rsIDs were assigned at the same genomic location).
Specifying the location by rsID is stable, and can be only affected by an eventual merge or deletion, if any, with a new dbSNP database build. It cannot be affected by a reference genome build.
However, a base position (offset) of a locus within a chromosome may change between the builds of the reference genome. So, when specifying the location by the chromosome and base position, the reference genome build should be also given, to locate an appropriate rsID.
You can download dbSNP database files (in VCF format) of the database build that was actual at a time when a specific build of a reference genome was also actual, but these files are huge. A possible place to download is https://ftp.ncbi.nih.gov/snp/pre_build152/organisms/ or https://ftp.ncbi.nih.gov/snp/archive/
However, these files are arranged by the dbSNP database build (e.g. 152, 153, 154), not by the reference genome build (e.g. 37 or 38).
If your list is relatively small, you can fetch the data rs numbers via dbSNP API by chromosome and location. The API is available at https://www.ncbi.nlm.nih.gov/snp/docs/eutils_help/
For instance, do “advanced search” of dbSNP at https://www.ncbi.nlm.nih.gov/snp/advanced
When it comes to search by the base position, you can only specify positions for GRCh37 (called “Base Position Previous”) and GRCh38 (“Base Position”). This URL will help you construct the request string that you will further use for the dbSNP API requests.
You may also need to add “NOT MergedRS[All Fields]” to exclude rsIDs that have already been merged. I wish I knew what to type instead of “All Fields” here to refine the search, but the documentation is very sparse.
In your examples, for 13_28025615_G_C_b37 specify Chromosome=13 and Base Position Previous=28025615 in the “Advanced Search”.
As about the API, for 13_28025615_G_C_b37 query https://eutils.ncbi.nlm.nih.gov/entrez/eutils/esearch.fcgi?db=snp&term=13[Chromosome]+AND+28025615[Base+Position+Previous]+NOT+MergedRS[All+Fields]
and for chr22_50473581_G_A_b38 query https://eutils.ncbi.nlm.nih.gov/entrez/eutils/esearch.fcgi?db=snp&term=22[Chromosome]+AND+50473581[Base+Position]+NOT+MergedRS[All+Fields]
The first rsID that you will get will be the main current rsID, the others (if any) will be the merged ones.
Here is a small perl example on how to retrieve data from the dbSNP. The fetch_GRCh37 function returns the rsID for a given chromosome and base position. For GRCh38, remove the “+Previous” from the URL. You can call the fetch_GRCh37 in a script multiple times. It’s better that you get rsIDs for your both GRCh37 and GRCh38 data to make sure that you refer to the same rsIDs that are actual after eventual merges.
Please make sure to read and comply to the requirements before using the API.
A sample Perl script snippet follows:
use XML::LibXML;
use LWP::UserAgent;

sub fetch_GRCh37 {
        my $chromosome = $_[0];
        my $basepos = $_[1];
        my $url = 'https://eutils.ncbi.nlm.nih.gov/entrez/eutils/esearch.fcgi?db=snp&term='.$chromosome.'[Chromosome]+AND+'.$basepos.'[Base+Position+Previous]+NOT+MergedRS[All+Fields]';
        my $UserAgent = new LWP::UserAgent ();
        my $GET = $UserAgent->get($url)->content;
        my $dom = XML::LibXML->load_xml(string => $GET);
        my $numberofnodes = int($dom->findnodes('eSearchResult/Count')->to_literal());
        if ($numberofnodes > 0) {foreach my $title ($dom->findnodes('eSearchResult/IdList/Id')){return("rs".$title->to_literal());}}
}

print fetch_GRCh37(13, 28025615);


---

