I made an R function to grab rsID genotypes from dbSNP using the entrez API. For example, here is the xml output that I am trying to parse:
https://eutils.ncbi.nlm.nih.gov/entrez/eutils/efetch.fcgi?db=snp&id=rs2656176&retmode=xml
the SPDI tag contains the genotype info. so I can easily use xpathSApply to get this tag for many IDs. But for this dbSNP there are two different values, T>C and T>A.
The T>C change is the one that has more support in all pop freq databases, and this is easily grabbed from the dbSNP webpage:
https://www.ncbi.nlm.nih.gov/snp/rs2656176
The "Alt Allele" frequencies show A being nearly 0, while C is the major alt allele.
However, I don't understand how I can parse the data from the XML from above using this... the 'global maf' tag in the XML shows some MAF values, but the 1000G value is only for the reference allele, not the alt in this case. The ALFA tag works, but doesn't always work for different IDs. There are other dbs that show the alt "C" allele but that might not always be the case.
Does anyone have an idea of what tags I should look at? Or is there a better way to hit a different API to get this data instead?
Thanks!
1 answer
You can check out these services:
- https://myvariant.info/v1/api#/
- https://api.ncbi.nlm.nih.gov/variation/v0/
- https://rest.ensembl.org/#VEP
As far as I know they all return JSON. You can check out a tool like jq or a package in your fav language to parse JSON.
Example:
curl -s 'https://rest.ensembl.org/vep/human/id/rs2656176?' -H 'Content-type:application/json' |
jq '.[].colocated_variants[].frequencies'
{
"A": {
"gnomadg_amr": 0,
"gnomadg_afr": 2.423e-05,
"gnomadg": 6.597e-06,
"gnomadg_nfe": 0,
"gnomadg_sas": 0,
"gnomadg_asj": 0,
"gnomadg_oth": 0,
"gnomadg_ami": 0,
"gnomadg_mid": 0,
"gnomadg_eas": 0,
"gnomadg_fin": 0
},
"C": {
"af": 0.521,
"gnomadg": 0.4892,
"amr": 0.4856,
"afr": 0.3502,
"gnomadg_asj": 0.4473,
"gnomadg_nfe": 0.532,
"eas": 0.6786,
"gnomadg_eas": 0.6479,
"gnomadg_fin": 0.5898,
"gnomadg_afr": 0.3772,
"gnomadg_amr": 0.461,
"eur": 0.495,
"sas": 0.6411,
"gnomadg_mid": 0.4146,
"gnomadg_sas": 0.6076,
"gnomadg_oth": 0.4379,
"gnomadg_ami": 0.4736
}
}
Log in to answer this question.