This is something of a follow-up to an old (and resolved) question I asked on here over a year ago: List of commands and options available in OTG GraphQL for running PheWAS
Essentially, I had been using the OTG API from an R session for searching for variants I had in a GWAS, obtaining information about those variants and then conducting an OTG PheWAS.
I have already figured out that I needed to update the old code to now have the new API location:
base_url = "https://api.platform.opentargets.org/api/v4/graphql"
However, here is how I had previously been conducting the API queries for my SNPs:
id_query_string = "query useSearchToConvertRSIDIntoIDFormat($query_rsID: String!) {
search(queryString: $query_rsID) {
variant {
id
rsId
nearestGene {
id
start
symbol
tss
description
chromosome
exons
}
nearestGeneDistance
}
}
}"
### Set variables object of arguments to be passed to endpoint
id_variables = list("query_rsID" = query_rsID)
### Construct POST request body object with query string and variables
id_search_body = list(query = id_query_string, variables = id_variables)
### Perform OpenTargets search request
id_search_out = POST(url = base_url, body = id_search_body, encode = "json")
Most specifically I had been searching the platform by rsID (query_rsID was the string for the rsID, e.g. “rs9273078”). However, when I look at content(id_search_out)this now contains the following error:
[1] "Cannot query field 'variant' on type 'SearchResults'. (line 3, column 10):\n\t\t\t\t\t\t\t\t\tvariant {\n ^"
It seems to me that the command “useSearchToConvertRSIDIntoIDFormat” must be the problem now, but I can’t see what is the way to fix this in the OpenTargets playground. Any help resolving this would be greatly appreciated!
