Hi,
Is the data source scores accessible through API weighted?
Thanks
Philge
Hi,
Is the data source scores accessible through API weighted?
Thanks
Philge
Hi @philge_philip,
yes, this is available through the API. We provide some examples that can be helpful in our /api page. This is how the query would look like to fetch the associations for IL22 split by data source:
query associatedDiseases {
target(ensemblId: "ENSG00000127318") {
id
approvedSymbol
associatedDiseases {
count
rows {
disease {
id
name
}
datasourceScores {
id
score
}
}
}
}
}
In this case, the default weights are already applied.
I hope this is helpful!
Irene
Thanks Irene for the great solution!!! I’d like to share the R version based on Irene’s solution
library(httr)
library(jsonlite)
# Define the query string
query_string <- '
query associatedDiseases {
target(ensemblId: "ENSG00000127318") {
id
approvedSymbol
associatedDiseases {
count
rows {
disease {
id
name
}
datasourceScores {
id
score
}
}
}
}
}
'
# Define the URL for the API endpoint
base_url <- "https://api.platform.opentargets.org/api/v4/graphql"
# Perform the POST request
response <- POST(
url = base_url,
body = list(query = query_string),
encode = "json"
)
# Check the status code of the response
if (status_code(response) == 200) {
# Parse the response from JSON
api_response <- content(response, as = "parsed", type = "application/json")
# Print the response in a readable format
print(toJSON(api_response, pretty = TRUE))
} else {
# Print the error message if the request failed
print(paste("Error:", status_code(response)))
}