knitr::opts_chunk$set(echo = TRUE)
If we encounter problems, such as an empty result, we can always ask for Monarch's response to our query.
library(monarchr) gene <- "NCBIGene:8314" results <- bioentity_homologs(gene)
We returned the response as a monarch_api (S3) class with its own print method
class(results$response)
The print method only shows the URL and highest 2 levels of the contents.
results$response
To view at an alternative depth, supply the depth setting to the print method.
# print(results$response, depth=3) # not run.
class(results$response$response) # this is the response we saved from the call to httr GET(url) results$response$url results$response$response$status_code #str(results$response$response) #results$response$response$headers #results$response$response$request
The server should have responded with an OK (200) status. If not, we can confirm the URL ourselves by pasting into a browser, or look at the response and response headers for more info (courtesy of httr).
We can use the URL at the top of monarchr's summary of the response to see the JSON results directly from the server.
(this is easier to view in Firefox):
[https://api.monarchinitiative.org/api/bioentity/gene/NCBIGene%3A8314/homologs/?rows=100&fetch_objects=true&format=json]
If you prefer to see the expected results as HTML, note how the example of looking up NCBIGene:8314 on Monarch Initiative website ended up at a table for Monarch's preferred ID (HGNC:950).
[https://monarchinitiative.org/gene/HGNC:950#homologs]
Replacing HGNC:950 with NCBIGene ID, we are successfully directed to the same view.
[https://monarchinitiative.org/gene/NCBIGene:8314#homologs]
You should see something similar to the following view.
In this case, the results shoud be consistent with what we see below.
results$homologs
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.