What is the best way to query pheWAS traits for multiple variants?

Hi Open Target Team,

I’d like to query multiple genetic variants (100s) for pheWAS trait associations using UKBB, FinnGen, and GWAS catalog. Is it best to use an API approach or download the entire dataset from the Open Targets Genetics portal? If the former, is the GraphiQL only linked to the PheWAS catalog or all pheWAS datasets? If the latter, what is the data table I would want to download?

Thank you,

Sarah

Hello @slifong08! :wave:

Welcome to the Open Targets Community! :tada:

Unfortunately, due to the size and scope of our PheWAS plot data, we are unable to provide the raw data in downloadable datasets.

You can access the data through our GraphQL API, using the pheWAS endpoint and passing the variant in our variant format of chromosome + _ + position + _ + reference allele + _ + alternative/effect allele format (e.g. 12_130461363_C_A).

For example, to get the PheWAS data for 12_130461363_C_A, you would construct the following GraphQL query:

query PheWASQuery{
  pheWAS(variantId: "1_154453788_C_T") {
    associations {
      study {
        studyId
        traitReported
        traitCategory
        pmid
        pubDate
        pubAuthor
        source
      }
      pval
      beta
      oddsRatio
      nTotal
      nCases
      eaf
      se
    }
  }
}

Run this query in our GraphQL API playground

It is important to note that our GraphQL API only returns trait associations from UK Biobank, FinnGen, and GWAS Catalog where the p-value is < 0.005 and this threshold cannot be adjusted.

Thank you! This is very helpful!

Hi, any further script to clear the format to data.frame? Thanks.

Hi. In my attempts to implement the solution in R, I’m encountering errors with the pheWAS API query. If someone please help me get it up and running, I would be very grateful.

query_url = ‘https://api.platform.opentargets.org/api/v4/graphql

Building query

request_body = list(operationName= ‘PheWASQuery’,
variables = list(
variantId = “1_154453788_C_T”
),
query = ’
query PheWASQuery($variantId: String!){
pheWAS(variantId: $variantId) {
associations {
study {
studyId
traitReported
traitCategory
pmid
pubDate
pubAuthor
source
}
pval
beta
oddsRatio
nTotal
nCases
eaf
se
}
}
}’
)
response = POST(query_url, body=request_body, encode=‘json’)

char = rawToChar(response$content)
data = jsonlite::fromJSON(char)

OUTPUT

data
$data
NULL
$errors
message
1 Cannot query field ‘pheWAS’ on type ‘Query’. (line 3, column 7):\n pheWAS(variantId: $variantId) {\n ^
locations
1 3, 7

Hi, the only problem with your query is that the API of the Genetics Portal has a different address: https://api.genetics.opentargets.org/graphql/ your query looks like this. Please let us know if my answer was not fully resolving the issue.

2 Likes