When querying ‘knownDrugs’ associated to a target, I am able to find at most 25 drugs. Would it be possible to retrieve more associated drugs without using Google Big Query?
I tried suggestions like (page: { size: x, index:y }) mentioned here and here, but they did not work for me.
Could you please provide an updated version of this solution? I am still encountering an error.
# Load relevant library for HTTP requests
library(httr)
# Set base URL of Genetics Portal GraphQL API endpoint
base_url <- "https://api.genetics.opentargets.org/graphql"
# Additional query to get known drugs for a target
query_drugs <- "
query q{
target(ensemblId: \"ENSG00000047936\"){
id
knownDrugs(size: 2){
count
rows{
drug{
name
}
}
}
}
}
"
# Construct POST request body object for the drugs query
post_body_drugs <- list(query = query_drugs)
# Perform POST request for drugs query
r_drugs <- POST(url=base_url, body=post_body_drugs, encode='json')
# Check for errors
if (status_code(r_drugs) == 200) {
# Print known drugs data to RStudio console
known_drugs <- content(r_drugs, "parsed")$data$target$knownDrugs$rows
print(known_drugs)
} else {
print(paste("Error:", status_code(r_drugs)))
}